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.
28 #define Middle(x) ((2*(x)+1)/4)
30 void ui_draw_checkbox( UI_GADGET_CHECKBOX * checkbox )
33 if ((checkbox->status==1) || (checkbox->position != checkbox->oldposition))
38 gr_set_current_canvas( checkbox->canvas );
40 if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)checkbox)
41 gr_set_fontcolor( CRED, -1 );
43 gr_set_fontcolor( CBLACK, -1 );
45 if (checkbox->position == 0 )
47 ui_draw_box_out( 0, 0, checkbox->width-1, checkbox->height-1 );
49 ui_string_centered( Middle(checkbox->width), Middle(checkbox->height), "X" );
51 ui_string_centered( Middle(checkbox->width), Middle(checkbox->height), " " );
53 ui_draw_box_in( 0, 0, checkbox->width-1, checkbox->height-1 );
55 ui_string_centered( Middle(checkbox->width)+1, Middle(checkbox->height)+1, "X" );
57 ui_string_centered( Middle(checkbox->width)+1, Middle(checkbox->height)+1, " " );
60 gr_ustring( checkbox->width+4, 2, checkbox->text );
67 UI_GADGET_CHECKBOX * ui_add_gadget_checkbox( UI_WINDOW * wnd, short x, short y, short w, short h, short group, char * text )
69 UI_GADGET_CHECKBOX * checkbox;
71 checkbox = (UI_GADGET_CHECKBOX *)ui_gadget_add( wnd, 5, x, y, x+w-1, y+h-1 );
73 checkbox->text = d_malloc((int)strlen(text) + 5);
74 strcpy(checkbox->text,text);
77 checkbox->position = 0;
78 checkbox->oldposition = 0;
79 checkbox->pressed = 0;
81 checkbox->group = group;
88 void ui_checkbox_do( UI_GADGET_CHECKBOX * checkbox, int keypress )
90 int OnMe, ButtonLastSelected;
92 OnMe = ui_mouse_on_gadget( (UI_GADGET *)checkbox );
94 checkbox->oldposition = checkbox->position;
96 if ((selected_gadget != NULL) && (selected_gadget->kind !=5))
97 ButtonLastSelected = 0;
99 ButtonLastSelected = 1;
101 if ( B1_PRESSED && OnMe && ButtonLastSelected )
103 checkbox->position = 1;
105 checkbox->position = 0;
109 if ((CurWindow->keyboard_focus_gadget==(UI_GADGET *)checkbox) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER] ) )
110 checkbox->position = 2;
112 if ((checkbox->position==0) && (checkbox->oldposition==1) && OnMe )
113 checkbox->pressed = 1;
114 else if ((checkbox->position==0) && (checkbox->oldposition==2) && (CurWindow->keyboard_focus_gadget==(UI_GADGET *)checkbox) )
115 checkbox->pressed = 1;
117 checkbox->pressed = 0;
119 if (checkbox->pressed == 1)
122 ui_draw_checkbox( checkbox );
126 void ui_checkbox_check(UI_GADGET_CHECKBOX * checkbox, sbyte check)
129 if (checkbox->flag == check)
132 checkbox->flag = check;
133 checkbox->status = 1; // redraw