void ui_draw_checkbox( UI_GADGET_CHECKBOX * checkbox ) { if ((checkbox->status==1) || (checkbox->position != checkbox->oldposition)) { checkbox->status = 0; ui_mouse_hide(); gr_set_current_canvas( checkbox->canvas ); if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)checkbox) gr_set_fontcolor( CRED, -1 ); else gr_set_fontcolor( CBLACK, -1 ); if (checkbox->position == 0 ) { ui_draw_box_out( 0, 0, checkbox->width-1, checkbox->height-1 ); if (checkbox->flag) ui_string_centered( Middle(checkbox->width), Middle(checkbox->height), "X" ); else ui_string_centered( Middle(checkbox->width), Middle(checkbox->height), " " ); } else { ui_draw_box_in( 0, 0, checkbox->width-1, checkbox->height-1 ); if (checkbox->flag) ui_string_centered( Middle(checkbox->width)+1, Middle(checkbox->height)+1, "X" ); else ui_string_centered( Middle(checkbox->width)+1, Middle(checkbox->height)+1, " " ); } gr_ustring( checkbox->width+4, 2, checkbox->text ); ui_mouse_show(); } }
void ui_draw_radio( UI_DIALOG *dlg, UI_GADGET_RADIO * radio ) { #if 0 //ndef OGL if ((radio->status==1) || (radio->position != radio->oldposition)) #endif { radio->status = 0; gr_set_current_canvas( radio->canvas ); if (dlg->keyboard_focus_gadget == (UI_GADGET *) radio) gr_set_fontcolor(CRED, -1); else gr_set_fontcolor(CBLACK, -1); if (radio->position == 0 ) { ui_draw_box_out( 0, 0, radio->width-1, radio->height-1 ); if (radio->flag) ui_string_centered(Middle(radio->width), Middle(radio->height), "O"); else ui_string_centered(Middle(radio->width), Middle(radio->height), " "); } else { ui_draw_box_in( 0, 0, radio->width-1, radio->height-1 ); if (radio->flag) ui_string_centered(Middle(radio->width) + 1, Middle(radio->height) + 1, "O"); else ui_string_centered(Middle(radio->width) + 1, Middle(radio->height) + 1, " "); } gr_ustring( radio->width+4, 2, radio->text ); } }
void ui_draw_radio( UI_GADGET_RADIO * radio ) { if ((radio->status==1) || (radio->position != radio->oldposition)) { radio->status = 0; ui_mouse_hide(); gr_set_current_canvas( radio->canvas ); if (radio->flag) gr_set_fontcolor( CRED, -1 ); else gr_set_fontcolor( CBLACK, -1 ); if (radio->position == 0 ) { ui_draw_box_out( 0, 0, radio->width-1, radio->height-1 ); ui_string_centered( Middle(radio->width), Middle(radio->height), "þ" ); } else { ui_draw_box_in( 0, 0, radio->width-1, radio->height-1 ); ui_string_centered( Middle(radio->width)+1, Middle(radio->height)+1, "þ" ); } if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)radio) gr_set_fontcolor( CRED, CWHITE ); else gr_set_fontcolor( CBLACK, CWHITE ); gr_ustring( radio->width+4, 2, radio->text ); ui_mouse_show(); } }
void UI_ICON::draw() { if (uses_bmaps) { gr_reset_clip(); if (disabled_flag) { if (bmap_ids[ICON_DISABLED] != -1) { gr_set_bitmap(bmap_ids[ICON_DISABLED]); gr_bitmap(x,y); } } else if (this->is_mouse_on()) { if (B1_PRESSED) { if (bmap_ids[ICON_SELECTED] != -1) { gr_set_bitmap(bmap_ids[ICON_SELECTED]); gr_bitmap(x, y); } } else { if (bmap_ids[ICON_HIGHLIGHT] != -1) { gr_set_bitmap(bmap_ids[ICON_HIGHLIGHT]); gr_bitmap(x, y); } } } else { if (bmap_ids[ICON_NORMAL] != -1) { gr_set_bitmap(bmap_ids[ICON_NORMAL]); gr_bitmap(x, y); } } } else { gr_set_font(my_wnd->f_id); gr_set_clip(x, y, w, h); ui_draw_box_out(0, 0, w-1, h-1); if (disabled_flag) gr_set_color_fast(&CDARK_GRAY); else gr_set_color_fast(&CBLACK); if (text) ui_string_centered(Middle(w), Middle(h), text); gr_reset_clip(); } }
// Render button. How it draws exactly depends on it's current state. void UI_BUTTON::draw() { int offset, frame_num = -1; if (uses_bmaps) { gr_reset_clip(); // if button is down, draw it that way if (button_down()) { if (bmap_ids[B_PRESSED] >= 0){ frame_num = B_PRESSED; } // otherwise if button is disabled, draw it that way } else if (disabled_flag) { if (bmap_ids[B_DISABLED] >= 0){ frame_num = B_DISABLED; } // otherwise, if button is highlighted (mouse is over it, but mouse buttons not down) draw it that way } else if (m_flags & BF_HIGHLIGHTED) { if (bmap_ids[B_HIGHLIGHT] >= 0){ frame_num = B_HIGHLIGHT; } // otherwise, just draw it normally } else { if (bmap_ids[B_NORMAL] >= 0){ frame_num = B_NORMAL; } } if (frame_num >= 0) { gr_set_bitmap(bmap_ids[frame_num]); gr_bitmap(x, y); } } else { gr_set_font(my_wnd->f_id); gr_set_clip( x, y, w, h ); // draw the button's box if (button_down()) { ui_draw_box_in( 0, 0, w-1, h-1 ); offset = 1; } else { ui_draw_box_out( 0, 0, w-1, h-1 ); offset = 0; } // now draw the button's text if (disabled_flag){ gr_set_color_fast(&CDARK_GRAY); } else if (my_wnd->selected_gadget == this){ gr_set_color_fast(&CBRIGHT_GREEN); } else { gr_set_color_fast(&CBLACK); } if (text){ ui_string_centered( Middle(w) + offset, Middle(h) + offset, text ); } gr_reset_clip(); } }
void UI_CHECKBOX::draw() { int offset; if ( uses_bmaps ) { if ( disabled_flag ) { if ( flag ) { if ( bmap_ids[CBOX_DISABLED_MARKED] != -1 ) { gr_set_bitmap(bmap_ids[CBOX_DISABLED_MARKED]); gr_bitmap(x,y,GR_RESIZE_MENU); } } else { if ( bmap_ids[CBOX_DISABLED_CLEAR] != -1 ) { gr_set_bitmap(bmap_ids[CBOX_DISABLED_CLEAR]); gr_bitmap(x,y,GR_RESIZE_MENU); } } } else { // not disabled if ( position == 0 ) { // up if ( flag ) { // marked if ( bmap_ids[CBOX_UP_MARKED] != -1 ) { gr_set_bitmap(bmap_ids[CBOX_UP_MARKED]); gr_bitmap(x,y,GR_RESIZE_MENU); } } else { // not marked if ( bmap_ids[CBOX_UP_CLEAR] != -1 ) { gr_set_bitmap(bmap_ids[CBOX_UP_CLEAR]); gr_bitmap(x,y,GR_RESIZE_MENU); } } } else { // down if ( flag ) { // marked if ( bmap_ids[CBOX_DOWN_MARKED] != -1 ) { gr_set_bitmap(bmap_ids[CBOX_DOWN_MARKED]); gr_bitmap(x,y,GR_RESIZE_MENU); } } else { // not marked if ( bmap_ids[CBOX_DOWN_CLEAR] != -1 ) { gr_set_bitmap(bmap_ids[CBOX_DOWN_CLEAR]); gr_bitmap(x,y,GR_RESIZE_MENU); } } } } } else { font::set_font(my_wnd->f_id); gr_set_clip( x, y, w, h, GR_RESIZE_MENU ); if (position == 0 ) { ui_draw_box_out( 0, 0, w-1, h-1 ); offset = 0; } else { ui_draw_box_in( 0, 0, w-1, h-1 ); offset = 1; } if (disabled_flag) gr_set_color_fast( &CGRAY ); else if (my_wnd->selected_gadget == this) gr_set_color_fast( &CBRIGHT_GREEN ); else gr_set_color_fast( &CGREEN ); if (flag) ui_string_centered( Middle(w) + offset, Middle(h) + offset, "X" ); else ui_string_centered( Middle(w) + offset, Middle(h) + offset, " " ); if (text) { gr_reset_clip(); gr_string( x+w+4, y+2, text, GR_RESIZE_MENU ); } } }
double ui_input_number( short xc, short yc, char * text, double OrgNumber ) { UI_WINDOW * wnd; UI_GADGET_INPUTBOX * InputBox; int text_width, text_height, avg; short box_width, box_height, width, height, x, y; short w, h; char string[100]; sprintf( string, "%f", OrgNumber ); box_width = box_height = 0; gr_set_current_canvas( &grd_curscreen->sc_canvas ); box_width = 8*20; box_height = 20; gr_get_string_size(text, &text_width, &text_height, &avg ); width = box_width + 50; text_width += avg*6; text_width += 10; if (text_width > width ) width = text_width; height = text_height; height += box_height; height += 4*5; // Center X and Y w = grd_curscreen->sc_w; h = grd_curscreen->sc_h; if ( xc == -1 ) xc = Mouse.x; if ( yc == -1 ) yc = Mouse.y - box_height/2; if ( xc == -2 ) xc = w/2; if ( yc == -2 ) yc = h/2; x = xc - width/2; y = yc - height/2; // Make sure that we're onscreen if (x < 0 ) x = 0; if ( (x+width-1) >= w ) x = w - width; if (y < 0 ) y = 0; if ( (y+height-1) >= h ) y = h - height; wnd = ui_open_window( x, y, width, height, WIN_DIALOG ); y = TEXT_EXTRA_HEIGHT + text_height/2 - 1; ui_string_centered( width/2, y, text ); y = 2*TEXT_EXTRA_HEIGHT + text_height; y = height - TEXT_EXTRA_HEIGHT - box_height-10; InputBox = ui_add_gadget_inputbox( wnd, 10, y, 20, 20, string ); ui_gadget_calc_keys(wnd); //key_flush(); wnd->keyboard_focus_gadget = (UI_GADGET *)InputBox; while(1) { ui_mega_process(); ui_window_do_gadgets(wnd); if (InputBox->pressed) break; } ui_close_window(wnd); OrgNumber = atof(InputBox->text); return OrgNumber; }