/****************************************************************** DrawToggleButton() -- This function draws the specified toggle button gadget. ******************************************************************/ GS_errorType DrawToggleButton(GSgadgetStruct *bg) { if (bg->gadget_type == GSTOGBUTTON) { switch(bg->togbutton->shape) { case GSTOGSQUARE: if (bg->togbutton->state == FALSE) { /* draw background of button */ SRGP_setColor(bg->gadget_bgd_color); SRGP_fillRectangle(bg->togbutton->square); /* draw outline of button */ SRGP_setColor(bg->gadget_bor_color); SRGP_rectangle(bg->togbutton->square); } else { /* draw background of button */ SRGP_setColor(bg->gadget_bor_color); SRGP_fillRectangle(bg->togbutton->square); /* draw outline of button */ SRGP_setColor(bg->gadget_bgd_color); SRGP_rectangle(bg->togbutton->square); } break; case GSTOGDIAMOND: break; case GSTOGCIRCLE: break; default: break; } /* draw label of button */ SRGP_setColor(bg->gadget_fgd_color); SRGP_text(bg->togbutton->label_pos, bg->togbutton->label); } else return(GSNOTBUTTONERR); return(GSNOERROR); } /* end of DrawToggleButton() */
/****************************************************************** DrawDrawingArea() -- This function draws the specified drawing area. ******************************************************************/ GS_errorType DrawDrawingArea(GSgadgetStruct *area) { if (area->gadget_type == GSDRAWAREA) { /* draw background of drawing area */ SRGP_setColor(area->gadget_bgd_color); SRGP_fillRectangle(area->gadget_extent); /* draw outline of drawing area */ SRGP_setColor(area->gadget_bor_color); SRGP_rectangle(area->gadget_extent); /* reset drawing color back to foreground color */ SRGP_setColor(area->gadget_fgd_color); } else return(GSNOTDRAWAREA); return(GSNOERROR); } /* end of DrawDrawingArea()*/
/****************************************************************** DrawSubMenu() -- This function draws the specified submenu gadget. ******************************************************************/ GS_errorType DrawSubMenu(GSgadgetStruct *sm) { int i; char *item_label; GS_errorType ExtractItemLabel(); if (sm->gadget_type == GSSUBMENU) { /* draw background of sub menu */ SRGP_setColor(sm->gadget_bgd_color); SRGP_fillRectangle(sm->gadget_extent); /* draw outline of sub menu */ SRGP_setColor(sm->gadget_bor_color); SRGP_rectangle(sm->gadget_extent); /* draw menu labels of sub menu */ SRGP_setColor(sm->gadget_fgd_color); for (i = 0; i < sm->submenu->item_count; i++) { ExtractItemLabel(i, sm->submenu->item_list, item_label); SRGP_text(sm->submenu->item_pos[i], item_label); } } else return(GSNOTSUBMENUERR); return(GSNOERROR); } /* end of DrawSubMenu()*/
/****************************************************************** DrawMenuBar() -- This function draws the specified menu bar gadget. ******************************************************************/ GS_errorType DrawMenuBar(GSgadgetStruct *mb) { int i; char *item_label; GS_errorType ExtractItemLabel(); if (mb->gadget_type == GSMENUBAR) { /* draw background of menu bar */ SRGP_setColor(mb->gadget_bgd_color); SRGP_fillRectangle(mb->gadget_extent); /* draw outline of menu bar */ SRGP_setColor(mb->gadget_bor_color); SRGP_rectangle(mb->gadget_extent); /* draw menu labels of menu bar */ SRGP_setColor(mb->gadget_fgd_color); for (i = 0; i < mb->menubar->item_count; i++) { ExtractItemLabel(i, mb->menubar->item_list, item_label); SRGP_text(mb->menubar->item_pos[i], item_label); } } else return(GSNOTMENUBARERR); return(GSNOERROR); } /* end of DrawMenuBar()*/
/****************************************************************** DrawPushButton() -- This function draws the specified push button gadget. ******************************************************************/ GS_errorType DrawPushButton(GSgadgetStruct *bg) { if (bg->gadget_type == GSPUSHBUTTON) { /* draw background of button */ SRGP_setColor(bg->gadget_bgd_color); SRGP_fillRectangle(bg->gadget_extent); /* draw outline of button */ SRGP_setColor(bg->gadget_bor_color); SRGP_rectangle(bg->gadget_extent); /* draw label of button */ SRGP_setColor(bg->gadget_fgd_color); SRGP_text(bg->button->label_pos, bg->button->label); } else return(GSNOTBUTTONERR); return(GSNOERROR); } /* end of DrawPushButton() */
void print_coords(infoptr pic, point mouse_pos, rectangle box) { char coord_string[20]; dpoint coords; /* Peitetään vanha teksti */ SRGP_setColor(SRGP_BLACK); SRGP_fillRectangle(box); /* Muotoillaan uusi teksti */ coords = to_dpoint(mouse_pos, pic); sprintf(coord_string, "(%.17f, %.17f)", coords.x, coords.y); SRGP_setColor(SRGP_WHITE); SRGP_setClipRectangle(box); /* Varmistetaan ettei teksti ylitä rajoja */ SRGP_text(box.bottom_left, coord_string); SRGP_setClipRectangle(pic->area); }