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_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_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 scigraphics::sequence::graphViewLineHystogram::drawLineBetweenPoints( painter &Painter, std::vector<wpoint> *Points ) const { assert( Points != NULL ); const size_t Size = Points->size(); if ( Size <= 1 ) return; Points->resize( 2*Size-1, wpoint(0,0) ); for ( size_t i = Size-1; i >= 1; i-- ) { const size_t j = i*2; assert( j >= 1 ); assert( j >= i ); assert( j < Points->size() ); wpoint Prev = (*Points)[i-1]; wpoint Next = (*Points)[i]; wpoint Middle( Next.x(), Prev.y() ); (*Points)[j] = Next; (*Points)[j-1] = Middle; } Painter.drawLineW( *Points ); }
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(); } }
void DivideAndConquer(PointList* L,PointClosed* pointClosed, int begin,int end) { if(end - begin + 1 < 4) { BruteForce(L,pointClosed,begin,end); } else { int mid_point = (begin + end) / 2; double mid_index_x =L->list[mid_point].x; DivideAndConquer(L,pointClosed,begin,mid_point); DivideAndConquer(L,pointClosed,mid_point+1,end); Middle(L,pointClosed,mid_point,mid_index_x); } }
// 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 ); } } }
void UI_RADIO::draw() { int offset; if ( uses_bmaps ) { if ( disabled_flag ) { if ( flag ) { if ( bmap_ids[RADIO_DISABLED_MARKED] != -1 ) { gr_set_bitmap(bmap_ids[RADIO_DISABLED_MARKED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); gr_bitmap(x,y); } } else { if ( bmap_ids[RADIO_DISABLED_CLEAR] != -1 ) { gr_set_bitmap(bmap_ids[RADIO_DISABLED_CLEAR], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); gr_bitmap(x,y); } } } else { // not disabled if ( position == 0 ) { // up if ( flag ) { // marked if ( bmap_ids[RADIO_UP_MARKED] != -1 ) { gr_set_bitmap(bmap_ids[RADIO_UP_MARKED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); gr_bitmap(x,y); } } else { // not marked if ( bmap_ids[RADIO_UP_CLEAR] != -1 ) { gr_set_bitmap(bmap_ids[RADIO_UP_CLEAR], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); gr_bitmap(x,y); } } } else { // down if ( flag ) { // marked if ( bmap_ids[RADIO_DOWN_MARKED] != -1 ) { gr_set_bitmap(bmap_ids[RADIO_DOWN_MARKED], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); gr_bitmap(x,y); } } else { // not marked if ( bmap_ids[RADIO_DOWN_CLEAR] != -1 ) { gr_set_bitmap(bmap_ids[RADIO_DOWN_CLEAR], GR_ALPHABLEND_NONE, GR_BITBLT_MODE_NORMAL, 1.0f, -1, -1); gr_bitmap(x,y); } } } } } else { gr_set_font(my_wnd->f_id); gr_set_clip( x, y, w, h ); 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(&CDARK_GRAY); 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, "*" ); // else // ui_string_centered( Middle(w)+offset, Middle(h)+offset, "o" ); if (flag) { gr_circle( Middle(w)+offset, Middle(h)+offset, 8 ); } else { gr_circle( Middle(w)+offset, Middle(h)+offset, 8 ); gr_set_color_fast( &CWHITE ); gr_circle( Middle(w)+offset, Middle(h)+offset, 4 ); } 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(&CGREEN); if ( text ) { gr_reset_clip(); gr_string( x+w+4, y+2, text ); } } }