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.
15 #pragma off (unreferenced)
16 static char rcsid[] = "$Id: number.c,v 1.1.1.1 2001-01-19 03:30:14 bradleyb Exp $";
17 #pragma on (unreferenced)
28 #define TEXT_EXTRA_HEIGHT 5
30 double ui_input_number( short xc, short yc, char * text, double OrgNumber )
33 UI_GADGET_INPUTBOX * InputBox;
35 short i, width, height, avg, x, y;
36 short box_width, box_height, text_height, text_width;
40 sprintf( string, "%f", OrgNumber );
42 box_width = box_height = 0;
44 gr_set_current_canvas( &grd_curscreen->sc_canvas );
49 gr_get_string_size(text, &text_width, &text_height, &avg );
51 width = box_width + 50;
56 if (text_width > width )
64 w = grd_curscreen->sc_w;
65 h = grd_curscreen->sc_h;
67 if ( xc == -1 ) xc = Mouse.x;
68 if ( yc == -1 ) yc = Mouse.y - box_height/2;
69 if ( xc == -2 ) xc = w/2;
70 if ( yc == -2 ) yc = h/2;
75 // Make sure that we're onscreen
77 if ( (x+width-1) >= w ) x = w - width;
79 if ( (y+height-1) >= h ) y = h - height;
82 wnd = ui_open_window( x, y, width, height, WIN_DIALOG );
84 y = TEXT_EXTRA_HEIGHT + text_height/2 - 1;
86 ui_string_centered( width/2, y, text );
88 y = 2*TEXT_EXTRA_HEIGHT + text_height;
90 y = height - TEXT_EXTRA_HEIGHT - box_height-10;
92 InputBox = ui_add_gadget_inputbox( wnd, 10, y, 20, 20, string );
94 ui_gadget_calc_keys(wnd);
98 wnd->keyboard_focus_gadget = (UI_GADGET *)InputBox;
103 ui_window_do_gadgets(wnd);
105 if (InputBox->pressed) break;
108 ui_close_window(wnd);
110 OrgNumber = atof(inputbox->text);