Untitled

Published February 18, 2006
Advertisement
Muppets muppets muppets.

This is Part II of the GUI system baloney. We left off with a brief overview of the core components, IComponent and IContainer so lets move onto some other fun stuff.

BOOM HEADSHOT.

IWindow : public IContainer - this wonderful class is the first control which actually does something. Well, not really. It essentially is just a bin for managing WindowEvents, the real power is contained in the template class Window.

But first - IWindow methods

  • addWindowListener( WindowListener* );
    delWindowListener( WindowListener* );

    Management of the window-specific events ( WINDOW_MOVE, WINDOW_RESIZE, WINDOW_CLOSE, etc ) which it sends out to listeners. Pretty boring really.


Now I'm still a little bit iffy on how the following pieces fit together, simply because Window (which derives from IWindow), IMO, contains some crap that should be in IWindow. But, at the same time, shouldn't. Its really weird, but the way it is now works for me - any fixes can easily be made by deriving a better class from IWindow. But I mean... bleh.

Okay, I'm getting tired of thinking. So we're going to take a short break.


"Now, Beakie, we'll just flip this switch and 60,000 refreshing
volts of electricity will surge through your body. Ready?"

Anyway. So Window.

I guess this is where some of the steaming evil comes in with templates and such. Essentially this is where the API abstraction comes in -

template < class GfxAdapter, class style = Defaultstyle< GfxAdapter > >
class Window : public IWindow, public style

GfxAdapter is the class that we're using to render the GUI. Each control should store a pointer to the adapter to use for drawing calls (because singletons/static methods are teh suck!) like so and initialize them in the constructor.

class Window {
GfxAdapter* _gfx;

explicit Window( GfxAdapter* gfx)
: _gfx( gfx ) { }
};

I just realized just now that it should really be an explicit constructor so nothing weird happens. So I added it in just now. Whee.

The style is a static policy class that allows you to create a unified style for all the controls. Basically, when you're writing your own controls you put the stuff you need in the style class.

The Defaultstyle is actually a parameterized template -

template < class GfxAdapter, int instance >
class Defaultstyle

First, we need the size/color typedefs from the GfxAdapter to store information. Secondly, if we want multiple style sets, we can instanciate multiple Defaultstyle classes. (Remember, they're filled with static data so we'd need a completely different class).

All of the functionality from Window comes through a listener injected into its own listener list. In fact, this is how almost all of control functionality is implemented.

It also implements IComponent's draw method, thus making it an instanciable class.

Err, pretty much all of the other control classes work the same way.

And now a word from our sponsors (EDI)~

POLL!


Do you think Ivy needs more cleavage? My suggestion was to have her wear a V-neck shirt like the picture on the right.
Previous Entry Untitled
Next Entry Untitled
0 likes 3 comments

Comments

Rob Loach
You definately can't take Ivy seriously [wink].
February 19, 2006 12:14 AM
evelyn
That's not too bad an idea. She looks too butch imo, and I would have her wearing thigh length boots ;)
February 19, 2006 06:22 AM
Mushu
omg EDI sneaky sneaky changed the picture of Ivy. Now she's got glasses, a choker and a v-neck shirt. Very gothy :S
February 19, 2006 10:26 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Untitled

5338 views

Untitled

1046 views

Untitled

1189 views

Untitled

1103 views

Untitled

1148 views

Untitled

1433 views

Untitled

1101 views

Untitled

1003 views

Untitled

1007 views

Untitled

1186 views
Advertisement