4 #define PUMENU_BUTTON_HEIGHT 25
5 #define PUMENU_BUTTON_EXTRA_WIDTH 25
7 puObject *puPopupMenu::add_item ( char *str, puCallback cb )
11 puOneShot *b = new puOneShot ( 0, h, str ) ;
12 b->setStyle ( PUSTYLE_PLAIN ) ;
13 b->setColourScheme ( colour[PUCOL_FOREGROUND][0],
14 colour[PUCOL_FOREGROUND][1],
15 colour[PUCOL_FOREGROUND][2],
16 colour[PUCOL_FOREGROUND][3] ) ;
17 b->setCallback ( cb ) ;
22 void puPopupMenu::close ( void )
27 puObject *ob = dlist ;
29 for ( ob = dlist ; ob != NULL ; ob = ob -> next )
33 ob -> getSize ( &w, &h ) ;
35 if ( w > widest ) widest = w ;
38 for ( ob = dlist ; ob != NULL ; ob = ob -> next )
39 ob -> setSize ( widest, PUMENU_BUTTON_HEIGHT ) ;
45 int puPopupMenu::checkKey ( int key, int updown )
47 if ( dlist == NULL || ! isVisible () || ! isActive () )
50 if ( updown == PU_DOWN )
54 /* Turn everything off ready for next time. */
56 for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
63 We have to walk the list backwards to ensure that
64 the click order is the same as the DRAW order.
67 for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
68 /* Find the last object in our list. */ ;
70 for ( ; bo != NULL ; bo = bo->prev )
71 if ( bo -> checkKey ( key, updown ) )
78 int puPopupMenu::checkHit ( int button, int updown, int x, int y )
80 if ( dlist == NULL || ! isVisible () || ! isActive () )
83 /* Must test 'isHit' before making the menu invisible! */
85 int hit = isHit ( x, y ) ;
87 if ( updown == active_mouse_edge || active_mouse_edge == PU_UP_AND_DOWN )
91 /* Turn everything off ready for next time. */
93 for ( puObject *bo = dlist ; bo != NULL ; bo = bo->next )
101 This might be a bit redundant - but it's too hard to keep
102 track of changing abox sizes when daughter objects are
114 We have to walk the list backwards to ensure that
115 the click order is the same as the DRAW order.
118 for ( bo = dlist ; bo->next != NULL ; bo = bo->next )
119 /* Find the last object in our list. */ ;
121 for ( ; bo != NULL ; bo = bo->prev )
122 if ( bo -> checkHit ( button, updown, x, y ) )