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.
26 #define MENU_VERT_SPACING 2
28 extern void ui_mouse_flip_buttons();
30 int PopupMenu( int NumButtons, char * text[] )
33 UI_GADGET_BUTTON * ButtonG[10];
35 short SavedMouseX, SavedMouseY;
38 int button_width, button_height, width, height;
45 ui_mouse_flip_buttons();
51 ui_mouse_flip_buttons();
55 if ((NumButtons < 1) || (NumButtons>10))
57 ui_mouse_flip_buttons();
61 SavedMouseX = Mouse.x; SavedMouseY = Mouse.y;
63 button_width = button_height = 0;
65 gr_set_current_canvas( &grd_curscreen->sc_canvas );
67 for (i=0; i<NumButtons; i++ )
71 ui_get_button_size( Button[i], &width, &height );
73 if ( width > button_width ) button_width = width;
74 if ( height > button_height ) button_height = height;
77 width = button_width + 2*(MENU_BORDER+3);
79 height = (button_height*NumButtons) + (MENU_VERT_SPACING*(NumButtons-1)) ;
80 height += (MENU_BORDER+3) * 2;
82 x = Mouse.x - width/2;
83 y = Mouse.y - (MENU_BORDER+3) - button_height/2;
85 w = grd_curscreen->sc_w;
86 h = grd_curscreen->sc_h;
90 Mouse.x = x + width / 2;
93 if ( (x+width-1) >= w ) {
95 Mouse.x = x + width / 2;
100 Mouse.y = y + (MENU_BORDER+3) + button_height/2;
103 if ( (y+height-1) >= h ) {
105 Mouse.y = y + (MENU_BORDER+3) + button_height/2;
108 wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
110 //mouse_set_pos(Mouse.x, Mouse.y);
115 for (i=0; i<NumButtons; i++ )
117 ButtonG[i] = ui_add_gadget_button( wnd, x, y, button_width, button_height, Button[i], NULL );
118 y += button_height+MENU_VERT_SPACING;
126 ui_window_do_gadgets(wnd);
128 for (i=0; i<NumButtons; i++ )
130 if (ButtonG[i]->pressed) {
136 if ( (choice==0) && B1_JUST_RELEASED ) {
144 ui_close_window(wnd);
146 ui_mouse_flip_buttons();