[Plib-cvs] plib/src/pui pu.cxx,1.67,1.68 pu.h,1.149,1.150 puObject.cxx,1.51,1.52
Brought to you by:
sjbaker
From: John F. F. <fa...@us...> - 2005-05-06 18:47:27
|
Update of /cvsroot/plib/plib/src/pui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30598 Modified Files: pu.cxx pu.h puObject.cxx Log Message: Adding code to allow the application to specify whether a widget gets deactivated when the user releases the mouse button or when the user activates the next widget. Index: pu.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.cxx,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- pu.cxx 16 Feb 2004 22:09:34 -0000 1.67 +++ pu.cxx 6 May 2005 18:46:28 -0000 1.68 @@ -377,7 +377,8 @@ x_offset -= active -> getABox () -> min [0] ; y_offset -= active -> getABox () -> min [1] ; - if ( ! active -> isHit ( pu_mouse_x - x_offset, pu_mouse_y - y_offset ) ) + if ( ( ! active -> isHit ( pu_mouse_x - x_offset, pu_mouse_y - y_offset ) ) && + ( active -> getWhenToDeactivate () == PUDEACTIVATE_ON_MOUSE_CLICK ) ) { active -> invokeDownCallback () ; puDeactivateWidget () ; @@ -392,6 +393,7 @@ { puCursor ( x, y ) ; + // Pick buttons in order of descending priority: Left, Right, Middle int button = (last_buttons & (1<<PU_LEFT_BUTTON )) ? PU_LEFT_BUTTON : (last_buttons & (1<<PU_MIDDLE_BUTTON)) ? PU_MIDDLE_BUTTON : @@ -409,9 +411,11 @@ */ if ( puActiveWidget () ) { - puActiveWidget()->doHit(button, PU_DRAG, pu_mouse_x - pu_mouse_offset_x, - pu_mouse_y - pu_mouse_offset_y) ; - return TRUE ; + if ( puActiveWidget()->checkHit(button, PU_DRAG, pu_mouse_x - pu_mouse_offset_x, + pu_mouse_y - pu_mouse_offset_y) ) + return TRUE ; + else + return FALSE ; } int return_value = puGetBaseLiveInterface () -> checkHit ( button, Index: pu.h =================================================================== RCS file: /cvsroot/plib/plib/src/pui/pu.h,v retrieving revision 1.149 retrieving revision 1.150 diff -u -d -r1.149 -r1.150 --- pu.h 6 May 2005 18:31:08 -0000 1.149 +++ pu.h 6 May 2005 18:46:28 -0000 1.150 @@ -215,6 +215,10 @@ #define PU_RADIO_BUTTON_SIZE 16 +/* When to deactivate a widget and call its down callback */ +#define PUDEACTIVATE_ON_MOUSE_CLICK 0 +#define PUDEACTIVATE_ON_NEXT_WIDGET_ACTIVATION 1 + extern int puRefresh ; /* Should not be used directly by applications any longer. Instead, use puPostRefresh () and puNeedRefresh (). */ @@ -600,6 +604,8 @@ void *render_data ; int border_thickness ; + short when_to_deactivate ; /* On next mouseclick or on next widget activation */ + virtual void draw_legend ( int dx, int dy ) ; virtual void draw_label ( int dx, int dy ) ; @@ -722,6 +728,9 @@ void setActiveButton ( int b ) { active_mouse_button = b ; } int getActiveButton ( void ) const { return active_mouse_button ; } + void setWhenToDeactivate ( short d ) { when_to_deactivate = d ; } + short getWhenToDeactivate ( void ) const { return when_to_deactivate ; } + void setLegend ( const char *l ) { legend = l ; recalc_bbox() ; puPostRefresh () ; } const char *getLegend ( void ) const { return legend ; } Index: puObject.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pui/puObject.cxx,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- puObject.cxx 6 May 2005 18:31:25 -0000 1.51 +++ puObject.cxx 6 May 2005 18:46:34 -0000 1.52 @@ -171,6 +171,8 @@ legendFont = defaultLegendFont ; legendPlace = PUPLACE_LEGEND_DEFAULT ; + when_to_deactivate = PUDEACTIVATE_ON_MOUSE_CLICK ; + for ( int i = 0 ; i < PUCOL_MAX ; i++ ) puSetColour ( colour[i], _puDefaultColourTable[i] ) ; @@ -504,7 +506,8 @@ int puObject::checkHit ( int button, int updown, int x, int y ) { - if ( ( ( puGetPressedButton () || updown == PU_UP ) ) && isHit( x, y ) ) + if ( ( puGetPressedButton () || ( updown == PU_UP ) ) && isHit( x, y ) || + puGetPressedButton () && ( isHit( x, y ) || ( puActiveWidget () == this ) ) ) { doHit ( button, updown, x, y ) ; return TRUE ; |