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.
14 #pragma off (unreferenced)
15 static char rcsid[] = "$Id: popup.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $";
16 #pragma on (unreferenced)
25 #define MENU_VERT_SPACING 2
27 extern void ui_mouse_flip_buttons();
29 int PopupMenu( int NumButtons, char * text[] )
32 UI_GADGET_BUTTON * ButtonG[10];
34 short SavedMouseX, SavedMouseY;
37 int button_width, button_height, width, height;
44 ui_mouse_flip_buttons();
50 ui_mouse_flip_buttons();
54 if ((NumButtons < 1) || (NumButtons>10))
56 ui_mouse_flip_buttons();
60 SavedMouseX = Mouse.x; SavedMouseY = Mouse.y;
62 button_width = button_height = 0;
64 gr_set_current_canvas( &grd_curscreen->sc_canvas );
66 for (i=0; i<NumButtons; i++ )
70 ui_get_button_size( Button[i], &width, &height );
72 if ( width > button_width ) button_width = width;
73 if ( height > button_height ) button_height = height;
76 width = button_width + 2*(MENU_BORDER+3);
78 height = (button_height*NumButtons) + (MENU_VERT_SPACING*(NumButtons-1)) ;
79 height += (MENU_BORDER+3) * 2;
81 x = Mouse.x - width/2;
82 y = Mouse.y - (MENU_BORDER+3) - button_height/2;
84 w = grd_curscreen->sc_w;
85 h = grd_curscreen->sc_h;
89 Mouse.x = x + width / 2;
92 if ( (x+width-1) >= w ) {
94 Mouse.x = x + width / 2;
99 Mouse.y = y + (MENU_BORDER+3) + button_height/2;
102 if ( (y+height-1) >= h ) {
104 Mouse.y = y + (MENU_BORDER+3) + button_height/2;
107 wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
109 mouse_set_pos( Mouse.x, Mouse.y );
114 for (i=0; i<NumButtons; i++ )
116 ButtonG[i] = ui_add_gadget_button( wnd, x, y, button_width, button_height, Button[i], NULL );
117 y += button_height+MENU_VERT_SPACING;
125 ui_window_do_gadgets(wnd);
127 for (i=0; i<NumButtons; i++ )
129 if (ButtonG[i]->pressed) {
135 if ( (choice==0) && B1_JUST_RELEASED ) {
142 ui_close_window(wnd);
144 ui_mouse_flip_buttons();