gui.h

Go to the documentation of this file.
00001 
00007 #ifndef GUI_H
00008 #define GUI_H
00009 
00010 /*
00011  * #define GUI_NO_STATE
00012  * If you will never use the state machine code, you can save eight whole bytes off the size of the structure
00013  */
00014 
00015 /*
00016  * #define SIMPLE_DIRTY
00017  * If you want just a single bounding box for repaints...
00018  */
00019 
00020 #ifndef CLIPRECT_H
00021 #include "cliprect.h"
00022 #endif
00023 
00024 #if !defined(GUI_NO_STATE) && !defined(GEN_H)
00025 #include "ctl/state.h"
00026 #endif
00027 
00028 #ifndef GUI_CHAR
00029 
00033 #define GUI_CHAR    char
00034 #endif
00035 
00036 #define GUI_TAB_IGNORE  12
00037 
00038 struct GUI;
00039 struct GUI_Control;
00040 
00045 #define EDEF_GUIMESSAGES(def) \
00046     def(GUI_Cycle)      /* Passed by GUI handler to GUI every animation cycle */\
00047     def(GUI_CycleCtrl)  /* Passed by GUI handler cycle to app to give it a chance to override control behavior; use GUI_GetNotifyID(gui) to see which one */\
00048     def(GUI_Paint)      /* Passed by GUI handler to GUI and controls when they should paint; param is a drawing context */\
00049     def(GUI_PaintCtrl)  /* Passed to GUI handler to give app a chance to override control appearance; use GUI_GetNotifyID(gui) to see which one */\
00050     def(GUI_Notify)     /* Passed to GUI handler from controls to notify of changes; use GUI_GetNotifyID(gui) to see which one */\
00051     def(GUI_Focus)      /* Passed to GUI handler when focus has been modified; GUI_GetFocus(gui) to see what has focus NOW */\
00052     def(GUI_Init)       /* Passed by GUI handler to tell things to initialize themselves */\
00053     def(GUI_Destroy)    /* Passed by GUI handler to tell things to release any resources */\
00054 
00055 
00058 typedef enum 
00059 {
00060 #define XENUM(enum) enum,
00061     EDEF_GUIMESSAGES(XENUM)
00062 #undef XENUM
00063 } GUI_Message;
00064 
00065 /*
00066  * Handler/control types
00067  */
00068 #define EDEF_HANDLERS(def) \
00069     def(  _,    Invalid,    0)\
00070     def(art_,   ArtResource,0)\
00071     def(pal_,   PaletteData,0)\
00072     def(bg_,    Background, 0)\
00073     def(ov_,    Overlay,    0)\
00074     def(st_,    StaticFrame,GUI_Control_State)\
00075     def(bn_,    Button,     GUI_Button_State)\
00076     def(ck_,    Checkbox,   GUI_Checkbox_State)\
00077     def(an_,    Animation,  GUI_Animation_State)\
00078     def(sb_,    Scrollbar,  GUI_Scrollbar_State)\
00079     def(tk_,    Ticker,     GUI_Ticker_State)\
00080     def(tb_,    Tumbler,    GUI_Tumbler_State)\
00081     def(gui_,   GUI,        GUI_Control_State)\
00082 
00083 typedef enum 
00084 {
00085 #define XENUM(tag,verbose,data) guih_##verbose,
00086     EDEF_HANDLERS(XENUM)
00087 #undef XENUM
00088     GUIHandlers_COUNT
00089 } GUIHandlers;
00090 
00097 typedef void (*GUI_handler)( struct GUI* gui, GUI_Message msg );
00098 typedef void (*GUI_Ctrl_handler)( struct GUI* gui, const struct GUI_Control* control, GUI_Message msg );
00099 
00103 typedef struct GUI_Control
00104 {
00105     GUIHandlers     type;       
00106     Rect            bound;      
00107     const OPCShape* const* state; 
00108     size_t          cState;     
00109     size_t          offData;    
00110     const void*     params;     
00111 } GUI_Control;
00112 
00116 typedef struct GUI
00117 {
00118     GUI_handler     handler;    
00119     struct GUI*     parent;     
00120     const GUI_Control* control; 
00121     unsigned        mask;       
00122 #define GUIM_DEFAULT        0
00123 #define GUIM_ALIVE          1
00124 #define GUIM_FOCUSCHANGED   2
00125 #define GUIM_INPAINT        4
00126     int             focus;      
00127     int             iControl;   
00129 #ifndef GUI_NO_STATE
00130     state           state;      
00131 #endif
00132 
00133     const GUI_Control* list;    
00134     const GUI_Control* const * htab; 
00135     const GUI_Control* const * vtab; 
00136     int             cControl;   
00138     const OPCShape* bg;         
00139     const OPCShape* ov;         
00141     OPC             opc;        
00142     Rect            dirty;      
00143 #ifndef SIMPLE_DIRTY
00144     ClipRect*       cdirty;     
00145 #endif
00146     int             offx,offy;  
00148     void*           param;      
00149 } GUI;
00150 
00154 typedef struct GUI_Control_State
00155 {
00156     unsigned    mask;       
00157 #define GUICS_DEFAULT   0   
00158 #define GUICS_INVISIBLE 1   
00159 #define GUICS_NOFOCUS   2   
00160 #define GUICS_NOTIFY    16  
00161     short       offx,offy;  
00162     const OPCShape* const* frames;  
00163     size_t      cFrames;    
00164     const GUI_CHAR* text;   
00165     unsigned    align;      
00166 } GUI_Control_State;
00167 
00168 /* Set basic control state to known values */
00169 void GUI_Def_State( GUI* gui, const GUI_Control* control, unsigned initmask, unsigned align );
00170 
00172 #define GUI_Control_Get_Data( gui, index )          GUI_Control_Data( (gui), GUI_Control_Get( (gui), (index) ) )
00173 
00175 #define GUI_Control_Dirty( gui, control )       _GUI_Control_Dirty( (GUI*)(gui), (control) )
00176 void _GUI_Control_Dirty( GUI* gui, const GUI_Control* control );
00177 
00179 #define GUI_Control_Bound( gui, control, bound )    _GUI_Control_Bound( (GUI*)(gui), (control), (bound) )
00180 void _GUI_Control_Bound( GUI* gui, const GUI_Control* control, Rect* bound );
00181 
00183 #define GUI_Control_Offset( gui, control, px,py )   { GUI_Control_State* state = GUI_Control_Data( ((GUI*)(gui)), (control)); *(px) = state->offx; *(py) = state->offy; }
00184 
00186 #define GUI_Control_Set_Offset( gui, index, x,y )   _GUI_Control_Set_Offset( (GUI*)(gui), (index), (x),(y) )    
00187 void _GUI_Control_Set_Offset( GUI* gui, int index, int x, int y );
00188 
00190 #define GUI_Control_Get_Offset( gui, index, px,py ) { GUI_Control_State* state = GUI_Control_Get_Data( ((GUI*)(gui)), (index)); *(px) = state->offx; *(py) = state->offy; }
00191 
00193 #define GUI_Control_GetText(gui,index)              (GUI_Control_Get_Data( (gui), (index) )->text)
00194 
00196 #define GUI_Control_SetText(gui,index, szText)      _GUI_Control_SetText((GUI*)(gui), (index), (szText) )
00197 void _GUI_Control_SetText(GUI* gui, int index, const GUI_CHAR* szText);
00198 
00200 #define GUI_Control_SetJustify(gui,index, just)     _GUI_Control_SetJustify((GUI*)(gui), (index), (just) )
00201 void _GUI_Control_SetJustify(GUI* gui, int index, unsigned just );
00202 
00204 #define GUI_Control_SetupText(gui,index, szText,just)   _GUI_Control_SetupText((GUI*)(gui), (index), (szText), (just) )
00205 void _GUI_Control_SetupText(GUI* gui, int index, const GUI_CHAR* szText, unsigned just );
00206 
00208 #define GUI_Control_GetFrames(gui,index)            (((const GUI_Control_State*)GUI_Control_Get_Data( (gui), (index) ))->frames)
00209 
00211 #define GUI_Control_GetFrameCount(gui,index)        (((const GUI_Control_State*)GUI_Control_Get_Data( (gui), (index) ))->cFrames)
00212 
00214 #define GUI_Control_SetFrames(gui,index,newframes,newcount) _GUI_Control_SetFrames( (GUI*)(gui), (index), (newframes), (newcount) )
00215 void _GUI_Control_SetFrames( GUI* gui, int index, const OPCShape* const* frames, size_t cFrames );
00216 
00218 #define GUI_Control_Get_Mask( gui, control )        (GUI_Control_Get_Data( ((GUI*)(gui)), (control))->mask)
00219 
00221 #define GUI_Control_IsFocused( gui, control )       _GUI_Control_IsFocused( (const GUI*)(gui), (const GUI_Control*)(control) )  
00222 bool _GUI_Control_IsFocused( const GUI* gui, const GUI_Control* control );
00223 
00225 #define GUI_Control_IsHidden( gui, index )          _GUI_Control_IsHidden( (const GUI*)(gui), (index) )
00226 bool _GUI_Control_IsHidden( const GUI* gui, int index );
00227 
00229 #define GUI_Control_Hide( gui, index )              _GUI_Control_Hide( (GUI*)(gui), (index) )
00230 void _GUI_Control_Hide( GUI* gui, int index );
00231 
00233 #define GUI_Control_Show( gui, index )              _GUI_Control_Show( (GUI*)(gui), (index) )
00234 void _GUI_Control_Show( GUI* gui, int index );
00235 
00237 #define GUI_Control_IsDisabled( gui, index )        _GUI_Control_IsDisabled( (const GUI*)(gui), (index) )   
00238 bool _GUI_Control_IsDisabled( const GUI* gui, int index );
00239 
00241 #define GUI_Control_Disable( gui, index )           _GUI_Control_Disable( (GUI*)(gui), (index) )
00242 void _GUI_Control_Disable( GUI* gui, int index );
00243 
00245 #define GUI_Control_Enable( gui, index )            _GUI_Control_Enable( (GUI*)(gui), (index) )
00246 void _GUI_Control_Enable( GUI* gui, int index );
00247 
00249 #define GUI_Control_SetNotify(gui,index)            (GUI_Control_Get_Data( ((GUI*)(gui)), (index))->mask |= GUICS_NOTIFY)
00250 
00252 #define GUI_Control_Get_Bound( gui, index, bound )  { GUI* pgui = (GUI*)(gui); _GUI_Control_Bound( pgui, GUI_Control_Get( pgui, (index) ), (bound) ); }
00253 
00255 #define GUI_Control_Get_Type( gui, index )          ( GUI_Control_Get( (gui), (index) )->type )
00256 
00258 #define GUI_Control_Get_Shape( gui, index, cel )    ( GUI_Control_Get( (gui), (index) )->state[(cel)] )
00259 
00261 #define GUI_Control_Set_Dirty( gui, index )         { GUI* pgui = (GUI*)(gui); _GUI_Control_Dirty( pgui, GUI_Control_Get( pgui, (index) ) ); }
00262 
00263 /* Get dirty refresh region */
00264 #define GUI_Control_Get_Paint( gui, index, opc )    GUI_Control_Paint( (GUI*)(gui), GUI_Control_Get( (GUI*)(gui), (index) ), (opc) )
00265 
00270 #define EDEF_BUTTON(def) \
00271     def(up_,    Neutral)        /* Button is idle */\
00272     def(sl_,    Selected)       /* Button is focused, has 'Activate' clicked, waiting for button up */\
00273     def(hi_,    Focus)          /* Button is focused, or has mouse/pointer over it */\
00274     def(hilo_,  FocusUnder)     /* Button is focused, or has mouse/pointer over it; drawn under 'neutral' or 'selected' button art */\
00275     def(hiov_,  FocusOver)      /* Button is focused, or has mouse/pointer over it; drawn over 'neutral' or 'selected' button art */\
00276 
00277 typedef enum 
00278 {
00279 #define XENUM(tag,verbose) guibs_##verbose,
00280     EDEF_BUTTON(XENUM)
00281 #undef XENUM
00282     GUIButtonStates_COUNT
00283 } GUIButtonStates;
00284 
00288 typedef struct GUI_Button_State
00289 {
00290     GUI_Control_State   basic;      
00291     GUIButtonStates     tracking;   
00292 } GUI_Button_State;
00293 
00294 
00299 #define EDEF_CHECKBOX(def) \
00300     def(off_,   Unchecked)          /* Checkbox is idle, and 'off' */\
00301     def(on_,    Checked)            /* Checkbox is idle, and 'on' */\
00302     def(hi_,    Focus)              /* Checkbox has focus/pointer over it */\
00303 
00304 typedef enum 
00305 {
00306 #define XENUM(tag,verbose) guics_##verbose,
00307     EDEF_CHECKBOX(XENUM)
00308 #undef XENUM
00309     GUICheckboxStates_COUNT
00310 } GUICheckboxStates;
00311 
00315 typedef struct GUI_Checkbox_State
00316 {
00317     GUI_Control_State   basic;      
00318     bool                bCheck;     
00319 } GUI_Checkbox_State;
00320 
00322 #define GUI_Checkbox_GetCheck(gui,index)        (((const GUI_Checkbox_State*)GUI_Control_Get_Data( (gui), (index) ))->bCheck)
00323 
00325 #define GUI_Checkbox_SetCheck(gui,index,bCheck) _GUI_Checkbox_SetCheck((GUI*)(gui),(index),(bCheck))
00326 bool _GUI_Checkbox_SetCheck( GUI* gui, int index, bool bCheck);
00327 
00328 
00329 
00330 typedef enum
00331 {
00332     gad_Stop,
00333     gad_ForwardOneshot,     /* Animate to last frame and stop, generate Notify */
00334     gad_BackwardOneshot,    /* Animate to first frame and stop, generate Notify */
00335     gad_ForwardLoop,        /* Animate to last frame and start at first forever */
00336     gad_BackwardLoop,       /* Animate to last frame and start at first forever */
00337     gad_ForwardPingPong,    /* Animate first to last, last to first (state is changed to gad_BackwardPingPong) */
00338     gad_BackwardPingPong,   /* Animate last to first, first to last (state is changed to gad_ForwardPingPong) */
00339     gad_Random,             /* Pick random frames  */
00340 } GUI_AnimDir;
00344 typedef struct GUI_Animation_State
00345 {
00346     GUI_Control_State   basic;      
00347     int                 iFrame;     
00348     GUI_AnimDir         aDir;       
00349     unsigned            msframe;    
00350     unsigned            msprev;     
00351 } GUI_Animation_State;
00352 
00354 #define GUI_Animation_SetAnim(gui,index, animdir, startframe, msframe) _GUI_Animation_SetAnim((GUI*)(gui),(index),(animdir), (startframe),(msframe))
00355 void _GUI_Animation_SetAnim( GUI* gui, int index, GUI_AnimDir animdir, int startFrame, unsigned msFrameTime );
00356 
00358 #define GUI_Animation_SetSpeed( gui, idControl, msperframe )    (((GUI_Animation_State*)GUI_Control_Get_Data( (gui), (index) ))->msframe = (msperframe))
00359 
00361 #define GUI_Animation_SetFrame(gui,index, frame )   _GUI_Animation_SetFrame((GUI*)(gui),(index),(frame))
00362 int _GUI_Animation_SetFrame( GUI* gui, int index, int frame );
00363 
00365 #define GUI_Animation_GetFrame(gui,index)           (((const GUI_Animation_State*)GUI_Control_Get_Data( (gui), (index) ))->iFrame )
00366 
00371 #define EDEF_SCROLLBAR(def) \
00372     def(fr_,    Frame)      /* Backdrop where thumb can go */\
00373     def(hi_,    Focus)      /* Focused version of frame backdrop */\
00374     def(hilo_,  FocusUnder) /* Focus underlay */\
00375     def(hiov_,  FocusOver)  /* Focus overlay */\
00376     def(fill1_, Fill1)      /* Fill from the left/top of slider to thumb */\
00377     def(fill2_, Fill2)      /* Fill from thumb to right/bottom */\
00378     def(th_,    Thumb)      /* Thumb for picking values in the bounding box */\
00379     def(thhi_,  ThumbFocus) /* Focused thumb */\
00380 
00381 typedef enum 
00382 {
00383 #define XENUM(tag,verbose) guisp_##verbose,
00384     EDEF_SCROLLBAR(XENUM)
00385 #undef XENUM
00386     GUIScrollbarParts_COUNT
00387 } GUIScrollbarParts;
00388 
00392 typedef struct GUI_Scrollbar_State
00393 {
00394     GUI_Control_State   basic;      
00395     int                 vmin;       
00396     int                 vmax;       
00397     int                 value;      
00398     int                 oldValue;   
00399     unsigned            msRepeat;   
00400     unsigned            msPrev;     
00401     unsigned            keyPrev;    
00402 } GUI_Scrollbar_State;
00404 #define GUI_Scrollbar_GetFrames(gui,index)              (((const GUI_Scrollbar_State*)GUI_Control_Get_Data( (gui), (index) ))->frames)
00405 
00406 #define GUI_Scrollbar_SetFrames(gui,index,newframes)    _GUI_Scrollbar_SetFrames( (GUI*)(gui), (index), (newframes) )
00407 void _GUI_Scrollbar_SetFrames( GUI* gui, int index, const OPCShape* const* frames );
00409 #define GUI_Scrollbar_GetValue(gui,index)               (((const GUI_Scrollbar_State*)GUI_Control_Get_Data( (gui), (index) ))->value)
00410 
00411 #define GUI_Scrollbar_SetValue(gui,index, newValue, minValue, maxValue ) _GUI_Scrollbar_SetValue( (GUI*)gui, idControl, newValue, minValue, maxValue )
00412 int _GUI_Scrollbar_SetValue( struct GUI* gui, int idControl, int newValue, int minValue, int maxValue );
00414 #define GUI_Scrollbar_GetRepeatRate(gui,index)          (((const GUI_Scrollbar_State*)GUI_Control_Get_Data( (gui), (index) ))->msRepeat)
00415 
00416 #define GUI_Scrollbar_SetRepeatRate(gui,index,msval)    (((GUI_Scrollbar_State*)GUI_Control_Get_Data( (gui), (index) ))->msRepeat = (msval))
00417 
00422 typedef struct GUI_Ticker_State
00423 {
00424     GUI_Control_State   basic;      
00425     int                 tWide;      
00426     int                 offset;     
00427     unsigned            msframe;    
00428     unsigned            msprev;     
00429     const char*         szNext;     
00430 } GUI_Ticker_State;
00432 #define GUI_Ticker_SetText( gui, idControl, sz )    _GUI_Ticker_SetText( (GUI*)(gui), (idControl), (sz) )
00433 void _GUI_Ticker_SetText( struct GUI* gui, int idControl, const GUI_CHAR* sz );
00434 
00436 #define GUI_Ticker_SetNextText( gui, idControl, sz ) (((GUI_Ticker_State*)GUI_Control_Get_Data( (gui), (index) ))->szNext = (sz))
00437 
00439 #define GUI_Ticker_SetSpeed( gui, idControl, msDelay, msframe ) _GUI_Ticker_SetSpeed( (GUI*)(gui), (idControl), (msDelay), (msframe) )
00440 void _GUI_Ticker_SetSpeed( struct GUI* gui, int idControl, unsigned msDelay, unsigned msframe );
00441 
00443 #define GUI_Ticker_GetOffset(gui,index)             (((const GUI_Ticker_State*)GUI_Control_Get_Data( (gui), (index) ))->offset)
00444 
00445 #define GUI_Ticker_SetOffset(gui,index,newOff)      (((GUI_Ticker_State*)GUI_Control_Get_Data( (gui), (index) ))->offset = (newOff))
00446 
00450 #define EDEF_TUMBLER(def) \
00451     def(lb_,    LBn)        /* Left button */\
00452     def(lh_,    LBnHi)      /* Left button highlight */\
00453     def(rb_,    RBn)        /* Right button */\
00454     def(rh_,    RBnHi)      /* Right button highlight */\
00455     def(lo_,    Under)      /* Underlay/background */\
00456     def(hilo_,  FocusUnder) /* Focus underlay */\
00457     def(hiov_,  FocusOver)  /* Focus overlay */\
00458     def(ov_,    Overlay)    /* For rounded window appearance when scrolling contents across */\
00459 
00460 typedef enum 
00461 {
00462 #define XENUM(tag,verbose) guitb_##verbose,
00463     EDEF_TUMBLER(XENUM)
00464 #undef XENUM
00465     GUITumblerParts_COUNT
00466 } GUITumblerParts;
00467 
00473 typedef struct GUI_Tumbler_State
00474 {
00475     GUI_Control_State   basic;      
00476     const OPCShape* const* states;  
00477     const GUI_CHAR* const*  tstates;    
00478     unsigned            ialign;     
00479     int                 cStates;    
00480     int                 stateCurr;  
00481     int                 statePrev;  
00482     int                 offPrev;    
00483     int                 cTransition;
00484     unsigned            msRepeat;   
00485     unsigned            msPrev;     
00486     unsigned            keyPrev;    
00487 } GUI_Tumbler_State;
00488 
00490 #define GUI_Tumbler_Setup( gui, id, shapes, shapeAlign, szz, szzAlign, count, transition, curr )    _GUI_Tumbler_Setup( (GUI*)(gui), (id), (shapes), (shapeAlign), (szz), (szzAlign), (count), (transition), (curr) )
00491 void _GUI_Tumbler_Setup( GUI* gui, int id, const OPCShape* const* shapes, unsigned shapeAlign, const GUI_CHAR* const* szz, unsigned szzAlign, size_t count, int transition, int curr );
00492 
00494 #define GUI_Tumbler_SetFrame( gui, id, curr )   _GUI_Tumbler_SetFrame( (GUI*)(gui), (id), (curr) )
00495 void _GUI_Tumbler_SetFrame( GUI* gui, int id, int curr );
00496 
00498 #define GUI_Tumbler_GetFrame( gui, id )             (((const GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (id) ))->stateCurr)
00499 
00501 #define GUI_Tumbler_GetRepeatRate(gui,index)        (((const GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (index) ))->msRepeat)
00502 
00503 #define GUI_Tumbler_SetRepeatRate(gui,index,msval)  (((GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (index) ))->msRepeat = (msval))
00504 
00506 #define GUI_Tumbler_GetTransitions(gui,index)       (((const GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (index) ))->cTransition)
00507 
00508 #define GUI_Tumbler_SetTransitions(gui,index,frames)    (((GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (index) ))->cTransition = (frames))
00509 
00511 #define GUI_Tumbler_GetAlign(gui,index)         (((const GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (index) ))->ialign)
00512 
00513 #define GUI_Tumbler_SetAlign(gui,index,how)     (((GUI_Tumbler_State*)GUI_Control_Get_Data( (gui), (index) ))->ialign = (how))
00514 
00515 
00517 #define GUI_GUI_GetGUI(gui,index)               ((GUI*)(GUI_Control_Get_Data((gui), (index))+1))
00518 
00520 #define GUI_IsOpen( gui )                       _GUI_IsOpen( (GUI*)(gui) )
00521 bool _GUI_IsOpen( GUI* gui );
00522 
00524 #define GUI_Param( gui )                        (((GUI*)(gui))->param)
00525 
00527 #define GUI_ParamAuto( gui, type, label )       type* label = (type*)(((GUI*)(gui))->param)
00528 
00530 #define GUI_User( gui )                         ((void*)((GUI*)(gui) + 1))
00531 
00533 #define GUI_UserAuto( gui, type, label )        type* label = (type*)((GUI*)(gui) + 1)
00534 
00536 #define GUI_GetFocus( gui )                     ( ((GUI*)(gui))->focus )
00537 
00539 #define GUI_SetFocus( gui, ifocus )             _GUI_SetFocus( (GUI*)(gui), (ifocus) )
00540 int _GUI_SetFocus( GUI* gui, int ifocus );
00541 
00543 #define GUI_GetNotify( gui )                    GUI_Control_Get( ((GUI*)(gui)), ((GUI*)(gui))->iControl )
00544 
00546 #define GUI_GetFocusID( gui )                   (((GUI*)(gui))->focus)
00547 
00549 #define GUI_GetNotifyID( gui )                  (((GUI*)(gui))->iControl)
00550 
00552 #define GUI_Handle(gui,msg)                     { GUI* pgui = (GUI*)(gui); pgui->handler( pgui, msg ); }
00553 
00555 #define GUI_Heartbeat(gui)                      _GUI_Heartbeat( (GUI*)(gui) )
00556 void _GUI_Heartbeat( GUI* gui );
00557 
00559 #define GUI_CallCycle(gui)                      GUI_Handle(gui,GUI_Cycle)
00560 
00562 #define GUI_CallPaint(gui)                      GUI_Handle(gui,GUI_Paint)
00563 
00565 #define GUI_CallNotifies(gui)                   _GUI_CallNotifies( (GUI*)(gui) )
00566 void _GUI_CallNotifies( GUI* gui );
00567 
00569 #define GUI_CallDestroy(gui)                    GUI_Handle(gui,GUI_Destroy)
00570 
00572 #define GUI_Implode(gui,times,divide)               _GUI_Explode( (GUI*)(gui), (times), (divide) )
00573 
00575 #define GUI_Implode_Set(gui,times,divide,first,last) _GUI_Explode_Set( (GUI*)(gui), (times), (divide), (first), (last) )
00576 
00578 #define GUI_Explode(gui,times,divide)               _GUI_Explode( (GUI*)(gui), (times), (divide) )
00579 bool _GUI_Explode( GUI* gui, int times, int divide );
00580 
00582 #define GUI_Explode_Set(gui,times,divide,first,last) _GUI_Explode_Set( (GUI*)(gui), (times), (divide), (first), (last) )
00583 bool _GUI_Explode_Set( GUI* gui, int times, int divide, int first, int last );
00584 
00586 #define GUI_Sweep_Set(gui,x,y,times,divide,first,last)  _GUI_Sweep_Set((GUI*)(gui),(x),(y),(times),(divide),(first),(last))
00587 void _GUI_Sweep_Set( GUI* gui, int x, int y, int times, int divide, int from, int to );
00588 
00589 #define GUI_Sweep(gui,x,y,times,divide)             _GUI_Sweep((GUI*)(gui),(x),(y),(times),(divide))
00590 void _GUI_Sweep( GUI* gui, int x, int y, int times, int divide );
00591 
00593 #define GUI_Offset_Group(gui,from,to,byx,byy)       _GUI_Offset_Group( (GUI*)(gui), (from), (to), (byx), (byy) )
00594 void _GUI_Offset_Group( GUI* gui, int from, int to, int byx, int byy );
00595 
00597 #define GUI_Offset_Control( gui, control, x,y )     _GUI_Offset_Control( (GUI*)(gui), (control), (x),(y) )
00598 void _GUI_Offset_Control( GUI* gui, const GUI_Control* control, int x, int y );
00599 
00601 #define GUI_Move( gui, x,y )                    _GUI_Move( (GUI*)(gui), x, y )
00602 void _GUI_Move( GUI* gui, int x, int y );
00603 
00605 #define GUI_Motion( gui, tx,ty )                _GUI_Motion( (GUI*)(gui), tx,ty )
00606 bool _GUI_Motion( GUI* gui, int tx, int ty );
00607 
00609 #define GUI_Control_Index( gui, control )       ( (control) - ((GUI*)(gui))->list )
00610 
00611 #ifdef NDEBUG
00612 
00613 #define GUI_Control_Data( gui, control )        ( (GUI_Control_State*)((uint8*)(gui) + (control)->offData) )
00614 
00615 #define GUI_Control_Get( gui, index )           ( ((GUI*)(gui))->list + (index) )
00616 
00617 #define GUI_Assert_Type( gui, index, type )
00618 #else
00619 #define GUI_Control_Data( gui, control )        _GUI_Control_Data( (const GUI*)(gui), (control) )
00620 #define GUI_Control_Get( gui, index )           _GUI_Control_Get( (GUI*)(gui), (index) )
00621 GUI_Control_State* _GUI_Control_Data( const GUI* gui, const GUI_Control* control );
00622 const GUI_Control* _GUI_Control_Get( const GUI* gui, int index );
00623 #define GUI_Assert_Type( gui, index, gtype )    assert( GUI_Control_Get( (gui), (index) )->type == (gtype) )
00624 #endif
00625 
00627 #define GUI_Dirty_Rect( gui, prc )              _GUI_Dirty_Rect( (GUI*)(gui), (prc) )
00628 void _GUI_Dirty_Rect( GUI* gui, const Rect* prc );
00629 
00631 #define GUI_Dirty( gui )                        GUI_Dirty_Rect( (gui), &((GUI*)(gui))->opc.clip )
00632 
00634 #define GUI_SetBG( gui, sbg )                   { GUI* pgui = (GUI*)(gui); pgui->bg = (sbg); GUI_Dirty_Rect( pgui, &pgui->opc.clip.rect ); }
00635 
00637 #define GUI_SetOV( gui, sov )                   { GUI* pgui = (GUI*)(gui); pgui->ov = (sov); GUI_Dirty_Rect( pgui, &pgui->opc.clip.rect ); }
00638 
00640 #define GUI_Control_Mask( gui, control )        (GUI_Control_Data( ((GUI*)(gui)), (control))->mask)
00641 
00642 /* Pass a message to a control */
00643 void GUI_Control_Handle( struct GUI* gui, const GUI_Control* control, GUI_Message msg );
00644 
00645 /* Get dirty refresh region */
00646 bool GUI_Control_Paint( const struct GUI* gui, const GUI_Control* control, OPC* opc );
00647 
00649 #define GUI_Control_Notify( gui, control )      { GUI_Control_Data( (gui), (control) )->mask |= GUICS_NOTIFY; }
00650 
00651 
00652 /* Invoke default GUI handling */
00653 #define GUI_Default(gui,msg) _GUI_Default( (GUI*)(gui), (msg) )
00654 void _GUI_Default( struct GUI* gui, GUI_Message msg );
00655 
00656 /* Tabbing helpers */
00657 bool GUI_tableft( GUI* gui );
00658 bool GUI_tabright( GUI* gui );
00659 bool GUI_tabup( GUI* gui );
00660 bool GUI_tabdown( GUI* gui );
00661 bool GUI_tabhandler( GUI* gui );
00662 
00663 #ifndef GUI_EXCLUDE_BLIB
00664 /* Work out how big a piece of data needs to be passed to 'gui' for GUI_BlibInit */
00665 size_t GUI_BlibNeeds( const void* pData, size_t size, size_t myExtra );
00666 
00667 /* Invoke a GUI that's mapped into memory */
00668 GUI* GUI_BlibInit( const void* pData, size_t size, size_t myExtra, void* pguiBuff, GUI_handler handler, void* param, const OPC* opc
00669 #ifdef SIMPLE_DIRTY
00670     );
00671 #else
00672   , ClipRect* cliprect );
00673 #endif
00674 #endif
00675 
00676 #ifndef offsetof
00677 
00683 #define offsetof(s,m)   ((size_t)&(((s *)0)->m))
00684 #endif
00685 
00686 #ifndef GUI_NO_STATE
00687 
00707 #define gui_notified(gui) \
00708     gen_yield(((GUI*)gui)->state)\
00709     for( btmp = 0, ((GUI*)gui)->iControl = 0; ((GUI*)gui)->iControl < ((GUI*)gui)->cControl; GUI_Control_Get_Data( (GUI*)gui, ((GUI*)gui)->iControl++ )->mask &= ~GUICS_NOTIFY )\
00710     if( !(GUI_Control_Get_Data( (GUI*)gui, ((GUI*)gui)->iControl )->mask & GUICS_NOTIFY) || !++btmp )\
00711     {\
00712         if( !btmp && ((GUI*)gui)->iControl == ((GUI*)gui)->cControl-1 )\
00713             state_repeat(((GUI*)gui)->state);\
00714         continue;\
00715     }\
00716     else /* Following block is what's invoked for each signaled control */
00717 #endif /* GUI_NO_STATE */
00718 
00719 
00720 #endif /* GUI_H */

Generated on Fri Jan 2 15:28:34 2009 for Squat by  doxygen 1.5.6