2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
27 #define MENU_VERT_SPACING 2
29 extern void ui_mouse_flip_buttons(void);
31 int PopupMenu( int NumButtons, char * text[] )
34 UI_GADGET_BUTTON * ButtonG[10];
36 short SavedMouseX, SavedMouseY;
39 int button_width, button_height, width, height;
46 ui_mouse_flip_buttons();
52 ui_mouse_flip_buttons();
56 if ((NumButtons < 1) || (NumButtons>10))
58 ui_mouse_flip_buttons();
62 SavedMouseX = Mouse.x; SavedMouseY = Mouse.y;
64 button_width = button_height = 0;
66 gr_set_current_canvas( &grd_curscreen->sc_canvas );
68 for (i=0; i<NumButtons; i++ )
72 ui_get_button_size( Button[i], &width, &height );
74 if ( width > button_width ) button_width = width;
75 if ( height > button_height ) button_height = height;
78 width = button_width + 2*(MENU_BORDER+3);
80 height = (button_height*NumButtons) + (MENU_VERT_SPACING*(NumButtons-1)) ;
81 height += (MENU_BORDER+3) * 2;
83 x = Mouse.x - width/2;
84 y = Mouse.y - (MENU_BORDER+3) - button_height/2;
86 w = grd_curscreen->sc_w;
87 h = grd_curscreen->sc_h;
91 Mouse.x = x + width / 2;
94 if ( (x+width-1) >= w ) {
96 Mouse.x = x + width / 2;
101 Mouse.y = y + (MENU_BORDER+3) + button_height/2;
104 if ( (y+height-1) >= h ) {
106 Mouse.y = y + (MENU_BORDER+3) + button_height/2;
109 wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
111 //mouse_set_pos(Mouse.x, Mouse.y);
116 for (i=0; i<NumButtons; i++ )
118 ButtonG[i] = ui_add_gadget_button( wnd, x, y, button_width, button_height, Button[i], NULL );
119 y += button_height+MENU_VERT_SPACING;
127 ui_window_do_gadgets(wnd);
129 for (i=0; i<NumButtons; i++ )
131 if (ButtonG[i]->pressed) {
137 if ( (choice==0) && B1_JUST_RELEASED ) {
145 ui_close_window(wnd);
147 ui_mouse_flip_buttons();