Wednesday, February 01, 2006

CompFramework and widgets

The c++ framework is starting to take shape. CWidget, and CButton are the newest additions to the CompFramework. Every widget will now inherit the CWidget class. Every CWindow has a function called AddWidget, which takes a pointer to a CWidget object as a parameter. The AddWidget fuction is also in the CWidget class itself, so in theory (I havent actually tested it yet) one should be able to add widgets to widgets. This essentially makes the CWidget class equivilent to BeOS's BView. This function then calls the widgets Create(HANDLE hWnd) function. On its own, in just a plain CWidget object, this function just creates a plain empty skygi window (not a normal window, but a skygi window (which is basically a blank slate for custom widgets)). Classes like CButton override this function to create a skygi button, rather than a blank window. The CWidget also accepts messages via the same hook functions a CWindow uses for messages. So to create a custom widget, all one has to do is subclass CWidget, and override the Redraw, mouse clicked, or whatever they need for the widget. Any extra variables, or flags, etc specific to the custom widget can just be private, or public, or whatever members of the class.

Future plans for CWidget will be to create some drawing functions, like DrawLine, or Blit, or something. Stay tuned.