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.
30 #define Middle(x) ((2*(x)+1)/4)
32 void ui_draw_radio( UI_GADGET_RADIO * radio )
35 if ((radio->status==1) || (radio->position != radio->oldposition))
40 gr_set_current_canvas( radio->canvas );
42 if (CurWindow->keyboard_focus_gadget == (UI_GADGET *) radio)
43 gr_set_fontcolor(CRED, -1);
45 gr_set_fontcolor(CBLACK, -1);
47 if (radio->position == 0 )
49 ui_draw_box_out( 0, 0, radio->width-1, radio->height-1 );
51 ui_string_centered(Middle(radio->width), Middle(radio->height), "O");
53 ui_string_centered(Middle(radio->width), Middle(radio->height), " ");
55 ui_draw_box_in( 0, 0, radio->width-1, radio->height-1 );
57 ui_string_centered(Middle(radio->width) + 1, Middle(radio->height) + 1, "O");
59 ui_string_centered(Middle(radio->width) + 1, Middle(radio->height) + 1, " ");
62 gr_ustring( radio->width+4, 2, radio->text );
69 UI_GADGET_RADIO * ui_add_gadget_radio( UI_WINDOW * wnd, short x, short y, short w, short h, short group, char * text )
71 UI_GADGET_RADIO * radio;
73 radio = (UI_GADGET_RADIO *)ui_gadget_add( wnd, 4, x, y, x+w-1, y+h-1 );
75 radio->text = d_strdup(text);
79 radio->oldposition = 0;
89 void ui_radio_do( UI_GADGET_RADIO * radio, int keypress )
92 UI_GADGET_RADIO * tmpr;
93 int OnMe, ButtonLastSelected;
95 OnMe = ui_mouse_on_gadget( (UI_GADGET *)radio );
97 radio->oldposition = radio->position;
99 if (selected_gadget != NULL)
101 if (selected_gadget->kind==4)
102 ButtonLastSelected = 1;
104 ButtonLastSelected = 0;
106 ButtonLastSelected = 1;
109 if ( B1_PRESSED && OnMe && ButtonLastSelected )
118 if ((CurWindow->keyboard_focus_gadget==(UI_GADGET *)radio) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER] ) )
121 if ((radio->position==0) && (radio->oldposition==1) && OnMe )
123 else if ((radio->position==0) && (radio->oldposition==2) && (CurWindow->keyboard_focus_gadget==(UI_GADGET *)radio) )
128 if ((radio->pressed == 1) && (radio->flag==0))
130 tmp = (UI_GADGET *)radio->next;
132 while (tmp != (UI_GADGET *)radio )
136 tmpr = (UI_GADGET_RADIO *)tmp;
137 if ((tmpr->group == radio->group ) && (tmpr->flag) )
149 ui_draw_radio( radio );
153 void ui_radio_set_value(UI_GADGET_RADIO *radio, sbyte value)
155 UI_GADGET_RADIO *tmp;
157 if (radio->flag == value)
161 radio->status = 1; // redraw
163 tmp = (UI_GADGET_RADIO *) radio->next;
167 if ((tmp->kind == 4) && (tmp->group == radio->group) && tmp->flag)
172 tmp = (UI_GADGET_RADIO *) tmp->next;