3 #define PUMENU_BUTTON_HEIGHT 25
4 #define PUMENU_BUTTON_EXTRA_WIDTH 25
6 puObject *puPopupMenu::add_item ( char *str, puCallback cb )
10 puOneShot *b = new puOneShot ( 0, h, str ) ;
11 b->setStyle ( PUSTYLE_PLAIN ) ;
12 b->setColourScheme ( colour[PUCOL_FOREGROUND][0],
13 colour[PUCOL_FOREGROUND][1],
14 colour[PUCOL_FOREGROUND][2],
15 colour[PUCOL_FOREGROUND][3] ) ;
16 b->setCallback ( cb ) ;
21 void puPopupMenu::close ( void )
26 puObject *ob = dlist ;
29 * June 17th, 1998, Shammi
30 * There seems to be some mismatch with the
31 * #define pumenusize and the actual size
32 * There seems to be some overlap resulting
33 * in more than one option being highlighted.
34 * By setting the size to the actual values,
35 * the overlap area seems to be less now.
40 for ( ob = dlist ; ob != NULL ; ob = ob -> next )
42 ob -> getSize ( &w, &h ) ;
44 if ( w > widest ) widest = w ;
47 for ( ob = dlist ; ob != NULL ; ob = ob -> next )
49 ob -> getSize ( &w, &h ) ;
50 ob -> setSize ( widest, h ) ;
57 int puPopupMenu::checkKey ( int key, int updown )
59 if ( dlist == NULL || ! isVisible () || ! isActive () )
62 if ( updown == PU_DOWN )
66 /* Turn everything off ready for next time. */
68 for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
75 We have to walk the list backwards to ensure that
76 the click order is the same as the DRAW order.
79 for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
80 /* Find the last object in our list. */ ;
82 for ( ; bo != NULL ; bo = bo->prev )
83 if ( bo -> checkKey ( key, updown ) )
90 int puPopupMenu::checkHit ( int button, int updown, int x, int y )
92 if ( dlist == NULL || ! isVisible () || ! isActive () )
95 /* Must test 'isHit' before making the menu invisible! */
97 int hit = isHit ( x, y ) ;
100 * June 17th, 1998, Shammi :
101 * There seemed to be a miscalculation with the menus initially
102 * Therefore I moved the recalculation stuff before the clearing.
106 This might be a bit redundant - but it's too hard to keep
107 track of changing abox sizes when daughter objects are
116 * June 17th, 1998, Shammi :
117 * Also clear the menu when the dragging the mouse and not hit.
120 if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN ||
121 ( updown == PU_DRAG && !hit ) )
124 /* June 17th, 1998, Shammi :
125 * Do not hide the menu if mouse is dragged out
128 if ( updown != PU_DRAG )
131 /* Turn everything off ready for next time. */
133 /* June 17th, 1998, Shammi:
134 * Make sure we check for a hit, if the mouse is moved
138 for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
141 bo -> checkHit ( button, updown, x , y ) ;
153 We have to walk the list backwards to ensure that
154 the click order is the same as the DRAW order.
157 /* June 17th, 1998, Shammi :
158 * If the mouse is dragged and the menuItem is not hit,
162 for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
163 if ( updown == PU_DRAG && ! bo -> checkHit ( button, updown, x, y ) )
166 /* Find the last object in our list. */ ;
168 for ( ; bo != NULL ; bo = bo->prev )
169 if ( bo -> checkHit ( button, updown, x, y ) )