SEAL Forum Index SEAL
The SEAL Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DOC: Writing Widgets for SEAL 3.0

 
Post new topic   Reply to topic    SEAL Forum Index -> Seal 3.0 Development
View previous topic :: View next topic  
Author Message
lukas139



Joined: 29 Mar 2002
Posts: 293
Location: Slovakia

PostPosted: Sun Aug 04, 2002 12:07 pm    Post subject: DOC: Writing Widgets for SEAL 3.0 Reply with quote

Writing Widgets for SEAL 3.0
=======================


Every widget in SEAL derives from a class called stkWidget.

Our basic header file will be :

class stkFoo : public stkWidget
{
//skeleton widget
};


The next thing we are interested in is drawing the widget, because the widget right now only draws a white filled rectangle.

So we have to overload the virtual function called event_draw (BITMAP *). The bitmap argument is a pointer into which we are going to draw. Obviously we cannot draw into "screen" bitmap.

Now our widget definition becomes

class stkFoo : public stkWidget
{
public :
void event_draw (BITMAP *);

};


Next, there are some standard events that our widget can handle. They are (with arguments ):

void event_button_pressed (sdkMouseEvent *);
void event_button_held (sdkMouseEvent *);
void event_button_released (sdkMouseEvent *);
void event_mouse_over (sdkMouseEvent *);
void event_lost_mouse_over (sdkMouseEvent *);
void event_mouse_move (sdkMouseEvent *);
void event_key (sdkKeyEvent *);
void event_got_focus (sdkKeyEvent *);
void event_lost_focus (sdkKeyEvent *);

These event handlers are called when the respective event occurs over our widget.

You may be interested in the definition of sdkMouseEvent and sdkKeyEvent

struct sdkMouseEvent
{
int x; //x cood
int y; //y cood
int b; //button
};

struct sdkKeyEvent
{
int scancode; //keyboard scancode
int ascii; //ascii value
int shifts; //keyboard shifts (like ctrl, alt etc)
};


Finally, our widget can emit signals to the Window Manager. These signals can be picked up by apps which have made connections.

To emit a signal,
emit ("friendly name", "data" );

"friendly name" can be anything that you wish, it only has to be documented so that application authors can actually respond to these signals. There isnt a "respond-to-all-signals" yet, you know !

"data" is data that you can send back to signal's slot.

An example is that of a scroll bar, "friendly name" can be "value changed" and data can be the scroll value.
_________________
Lukas Lipka
My Home
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
BadSector
Administrator


Joined: 24 Oct 2001
Posts: 328
Location: Greece, Samos

PostPosted: Sat Aug 17, 2002 5:21 pm    Post subject: ? Reply with quote

has anyone thought about the overhead of this "message broadcasting" method? I don't say that "free messages" are bad, but not as fast as integer messages (like in windows).
_________________
main(){printf("Hello, world!n"); return 0;}
Bad Sector - http://www.bsector.cjb.net/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
ganesh



Joined: 11 Jul 2002
Posts: 133
Location: Vancouver, BC, CA

PostPosted: Sat Aug 17, 2002 10:41 pm    Post subject: Reply with quote

Internally the "free messages" are hashed to get an unique integer. See the debug file, it will show you the signal integer with which it was connected.

There is a small overhead in the hashing scheme, but its very marginal. I am also planning to write a hash table algorithm, so that the hash of the same keys is not calculated over and over.
_________________
Ganesh lives @
www.iamganesh.com
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    SEAL Forum Index -> Seal 3.0 Development All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group