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.
27 #define Middle(x) ((2*(x)+1)/4)
29 extern void ui_draw_shad( short x1, short y1, short x2, short y2, short c1, short c2 );
31 void ui_draw_box_in1( short x1, short y1, short x2, short y2 )
34 gr_setcolor( CWHITE );
35 gr_urect( x1+1, y1+1, x2-1, y2-1 );
37 ui_draw_shad( x1+0, y1+0, x2-0, y2-0, CGREY, CBRIGHT );
41 void ui_draw_icon( UI_GADGET_ICON * icon )
43 int height, width, avg;
47 if ((icon->status==1) || (icon->position != icon->oldposition))
53 gr_set_current_canvas( icon->canvas );
54 gr_get_string_size(icon->text, &width, &height, &avg );
56 x = ((icon->width-1)/2)-((width-1)/2);
57 y = ((icon->height-1)/2)-((height-1)/2);
59 if (icon->position==1 )
62 ui_draw_box_in( 0, 0, icon->width, icon->height );
68 ui_draw_box_in1( 0, 0, icon->width, icon->height );
74 ui_draw_box_out( 0, 0, icon->width, icon->height );
77 gr_set_fontcolor( CBLACK, -1 );
78 gr_ustring( x, y, icon->text );
85 UI_GADGET_ICON * ui_add_gadget_icon( UI_WINDOW * wnd, char * text, short x, short y, short w, short h, int k,int (*f)(void) )
87 UI_GADGET_ICON * icon;
89 icon = (UI_GADGET_ICON *)ui_gadget_add( wnd, 9, x, y, x+w-1, y+h-1 );
93 MALLOC( icon->text, char, (int)strlen( text )+2);
94 strcpy( icon->text, text );
96 icon->user_function = f;
97 icon->oldposition = 0;
100 icon->canvas->cv_font = ui_small_font;
102 // Call twice to get original;
105 icon->flag = (sbyte)f();
106 icon->flag = (sbyte)f();
116 void ui_icon_do( UI_GADGET_ICON * icon, int keypress )
120 OnMe = ui_mouse_on_gadget( (UI_GADGET *)icon );
122 icon->oldposition = icon->position;
124 if ( B1_PRESSED && OnMe )
133 if ((icon->position==0) && (icon->oldposition==1) && OnMe )
136 if (icon->pressed == 1 || keypress==icon->trap_key )
139 icon->flag = (sbyte)icon->user_function();
140 if (keypress==icon->trap_key) last_keypress = 0;
143 ui_draw_icon( icon );