static void create_controls( ConvolveInst *inst ) { const LWDisplayMetrics *dm; int x, y, dx, dy, w, i, pw, ph; /* create a control */ ctl[ 0 ] = FLOAT_CTL( panf, panel, "" ); /* find out how much vertical space the panel wants for drawing its own decorations */ ph = PAN_GETH( panf, panel ); ph -= CON_H( ctl[ 0 ] ); /* create the rest of the controls */ for ( i = 1; i < 9; i++ ) ctl[ i ] = FLOAT_CTL( panf, panel, "" ); ctl[ 9 ] = WPOPUP_CTL( panf, panel, "Presets", preset, 150 ); /* position all of the controls */ x = CON_X( ctl[ 0 ] ); y = CON_Y( ctl[ 0 ] ); dx = CON_HOTW( ctl[ 0 ] ) + 8; dy = CON_HOTH( ctl[ 0 ] ) + 4; for ( i = 1; i < 9; i++ ) MOVE_CON( ctl[ i ], x + dx * ( i % 3 ), y + dy * ( i / 3 )); w = CON_W( ctl[ 9 ] ); MOVE_CON( ctl[ 9 ], x + 3 * dx - w, y + 10 * dy / 3 ); /* now that we know how much room the controls will take up, set the height of the panel and center it */ ph += CON_Y( ctl[ 9 ] ); ph += CON_HOTH( ctl[ 9 ] ); PAN_SETH( panf, panel, ph - 6 ); pw = PAN_GETW( panf, panel ); dm = panf->drawFuncs->dispMetrics(); MOVE_PAN( panf, panel, ( dm->width - pw ) / 2, ( dm->height - ph ) / 2 ); /* initialize the controls */ set_kernctl( inst ); SET_INT( ctl[ 9 ], pindex ); /* set the control event callbacks */ CON_SETEVENT( ctl[ 9 ], handle_preset, inst ); }
// DrawKeysPanel(): // Called to draw the Keyboard Help Panel void DrawKeysPanel( LWPanelID panel, void *data, DrMode mode ) { CDrawFuncs *df = fk_int->panel_funcs->DrawFuncs; int ph = PAN_GETH( fk_int->panel_funcs->orig_struct, fk_int->keys_panel ); int pw = PAN_GETW( fk_int->panel_funcs->orig_struct, fk_int->keys_panel ); const int column_center = 170; int y = 5; for( int i=0; keys_text[i] != NULL; i+=2 ) { df->WriteText( fk_int->keys_panel, keys_text[i], COLOR_WHITE, column_center - 5 - df->TextWidth(fk_int->about_panel, keys_text[i]), y ); df->WriteText( fk_int->keys_panel, keys_text[i+1], COLOR_BLACK, column_center + 5, y ); y += 15; } }
// DrawMainPanel() { void DrawPanel( LWPanelID panel, void *data, DrMode mode) { CDrawFuncs df( rint->panel_funcs->drawFuncs ); int ph = PAN_GETH( rint->panel_funcs, rint->panel ); int pw = PAN_GETW( rint->panel_funcs, rint->panel ); // Horizontal Dividers int y = CON_Y( rint->match_toggle ); int h = CON_H( rint->match_toggle ); PanelDraw::HorizontalDivider( rint->panel, &df, 0, y + h + 3, pw, 1 ); y = CON_Y( rint->list ); h = CON_H( rint->list ); PanelDraw::HorizontalDivider( rint->panel, &df, 0, y + h + 3, pw, 1 ); y = CON_Y( rint->enable ); h = CON_H( rint->enable ); PanelDraw::HorizontalDivider( rint->panel, &df, 0, y + h + 3, pw, 1 ); }
// DrawRegisterPanel(): // Called to draw the Register Panel void DrawRegisterPanel( LWPanelID panel_id, void *panel_user, DrMode panel_draw_mode ) { CDrawFuncs *df = fk_int->panel_funcs->DrawFuncs; // Title Image logo.DrawInLWPanels( fk_int->fkd->register_panel, df, -280, 0 ); int ph = PAN_GETH( fk_int->panel_funcs->orig_struct, fk_int->fkd->register_panel ); int pw = PAN_GETW( fk_int->panel_funcs->orig_struct, fk_int->fkd->register_panel ); int y = 85; for( int i=0; register_text[i] != NULL; i++ ) { df->WriteText( fk_int->fkd->register_panel, (char *)register_text[i], COLOR_BLACK, (pw/2)-(df->TextWidth(fk_int->fkd->register_panel, (char *)(register_text[i]) ))/2, y ); y += 15; } y = CON_Y( fk_int->fkd->register_now ) + 50; df->WriteText( fk_int->fkd->register_panel, (char *)trial_text, COLOR_BLACK, (pw/2)-(df->TextWidth(fk_int->fkd->register_panel, (char *)(trial_text) ))/2, y ); }
// DrawMainPanel(): // Draw details on the main panel (ie: dividers) void SG_DrawMainPanel( LWPanelID panel_id, void *panel_user, DrMode panel_draw_mode ) { CDrawFuncs *df = simpg_int->panel_funcs->DrawFuncs; int ph = PAN_GETH( simpg_int->panel_funcs->orig_struct, simpg_int->main_panel ); int pw = PAN_GETW( simpg_int->panel_funcs->orig_struct, simpg_int->main_panel ); // Horizontal Dividers int y = CON_Y( simpg_int->output_scene ); int h = CON_H( simpg_int->output_scene ); PanelDraw::HorizontalDivider( simpg_int->main_panel, df, 0, y+h+2, pw, 1 ); /* y = CON_Y( simpg_int->render_filename ); h = CON_H( simpg_int->render_filename ); PanelDraw::HorizontalDivider( simpg_int->main_panel, df, 0, y+h+2, pw, 1 ); y = CON_Y( simpg_int->lod_distance ); h = CON_H( simpg_int->lod_distance ); PanelDraw::HorizontalDivider( simpg_int->main_panel, df, 0, y+h+2, pw, 1 ); */ // Title Image // PanelDraw::DrawImage( simp_int->main_panel, df, logo, -25, 0 ); logo.DrawInLWPanels( simpg_int->main_panel, df, -25, 0 ); }
static void create_controls( void ) { static char *labtype[] = { "Byte", "Word", "Long", "Float", "Double", NULL }; static char *labbyte[] = { "Intel", "Motorola", NULL }; static char *labjump[] = { "Absolute", "Forward", "Backward", NULL }; static char *labsrch[] = { "Text", "Text + Hex", "Current", NULL }; int x, y, ph; /* create a control */ ctl[ 1 ] = STR_CTL( panf, panel, "", 58 ); /* find out how much vertical space the panel wants for drawing its own decorations */ ph = PAN_GETH( panf, panel ) - CON_H( ctl[ 1 ] ); /* create the rest of the controls */ ctl[ 0 ] = CANVAS_CTL( panf, panel, "", 78 * TXWIDTH + DX * 2, NROWS * TXHEIGHT + DY * 2 ); ctl[ 2 ] = STRRO_CTL( panf, panel, "", 21 ); ctl[ 3 ] = WPOPUP_CTL( panf, panel, "", labtype, 76 ); ctl[ 4 ] = BOOL_CTL( panf, panel, "Unsigned" ); ctl[ 5 ] = WPOPUP_CTL( panf, panel, "", labbyte, 76 ); ctl[ 6 ] = MINISLIDER_CTL( panf, panel, "", 4, 1, 16 ); ctl[ 7 ] = STR_CTL( panf, panel, "Jump", 12 ); ctl[ 8 ] = WBUTTON_CTL( panf, panel, "Search", 56 ); ctl[ 9 ] = STRRO_CTL( panf, panel, "Mod", 4 ); ctl[ 10 ] = VSLIDER_CTL( panf, panel, "", NROWS * TXHEIGHT + DY * 2, 0, 1000 ); ctl[ 11 ] = STRRO_CTL( panf, panel, "", 12 ); ctl[ 12 ] = WPOPUP_CTL( panf, panel, "", labjump, 80 ); ctl[ 13 ] = STR_CTL( panf, panel, "", 24 ); ctl[ 14 ] = WPOPUP_CTL( panf, panel, "", labsrch, 80 ); ctl[ 15 ] = CANVAS_CTL( panf, panel, "", 32, 32 ); ctl[ 16 ] = WBUTTON_CTL( panf, panel, "New", 40 ); /* position all of the controls */ x = CON_X( ctl[ 0 ] ); y = CON_Y( ctl[ 0 ] ); y += CON_H( ctl[ 2 ] ); MOVE_CON( ctl[ 0 ], x, y + 2 ); y = CON_Y( ctl[ 0 ] ); MOVE_CON( ctl[ 10 ], 79 * TXWIDTH + 10, y + 1 ); y = CON_Y( ctl[ 1 ] ) + 2; x = CON_X( ctl[ 0 ] ); MOVE_CON( ctl[ 16 ], x + DX, y ); x += CON_W( ctl[ 16 ] ); MOVE_CON( ctl[ 1 ], x, y ); x = CON_X( ctl[ 1 ] ); x += CON_W( ctl[ 1 ] ); MOVE_CON( ctl[ 2 ], x, y ); x = CON_X( ctl[ 10 ] ); x += CON_W( ctl[ 10 ] ); MOVE_CON( ctl[ 15 ], x - 32, y ); y += CON_H( ctl[ 1 ] ) - 2; x = CON_X( ctl[ 0 ] ); MOVE_CON( ctl[ 11 ], x - 3, y ); x += CON_W( ctl[ 11 ] ); MOVE_CON( ctl[ 9 ], x, y ); x = CON_X( ctl[ 9 ] ); x += CON_W( ctl[ 9 ] ); MOVE_CON( ctl[ 6 ], x, y ); x = CON_X( ctl[ 6 ] ); x += CON_W( ctl[ 6 ] ); MOVE_CON( ctl[ 5 ], x, y ); x = CON_X( ctl[ 5 ] ); x += CON_W( ctl[ 5 ] ); MOVE_CON( ctl[ 3 ], x - 6, y ); x = CON_X( ctl[ 3 ] ); x += CON_W( ctl[ 3 ] ); MOVE_CON( ctl[ 4 ], x, y ); y = CON_Y( ctl[ 0 ] ); y += CON_H( ctl[ 0 ] ); x = CON_X( ctl[ 0 ] ); MOVE_CON( ctl[ 7 ], x + DX, y ); x = CON_X( ctl[ 7 ] ); x += CON_W( ctl[ 7 ] ); MOVE_CON( ctl[ 12 ], x - 4, y ); x = CON_X( ctl[ 12 ] ); x += CON_W( ctl[ 12 ] ); MOVE_CON( ctl[ 8 ], x + 18, y ); x = CON_X( ctl[ 8 ] ); x += CON_W( ctl[ 8 ] ); MOVE_CON( ctl[ 13 ], x - 4, y ); x = CON_X( ctl[ 13 ] ); x += CON_W( ctl[ 13 ] ); MOVE_CON( ctl[ 14 ], x - 4, y ); /* now that we know how much room the controls will take up, set the height of the panel */ y = CON_Y( ctl[ 8 ] ); y += CON_H( ctl[ 8 ] ); PAN_SETH( panf, panel, y + ph - 6 ); /* initialize the controls */ SET_INT( ctl[ 3 ], datatype ); SET_INT( ctl[ 4 ], unsign ); SET_INT( ctl[ 5 ], byteorder ); SET_INT( ctl[ 6 ], linesize ); SET_STR( ctl[ 7 ], "0", 2 ); SET_STR( ctl[ 9 ], "0", 2 ); SET_INT( ctl[ 10 ], 0 ); SET_STR( ctl[ 11 ], "0", 2 ); SET_INT( ctl[ 12 ], 0 ); SET_INT( ctl[ 14 ], 0 ); /* set the control event callbacks */ CON_SETEVENT( ctl[ 1 ], handle_file, NULL ); CON_SETEVENT( ctl[ 3 ], handle_datatype, NULL ); CON_SETEVENT( ctl[ 4 ], handle_unsigned, NULL ); CON_SETEVENT( ctl[ 5 ], handle_byteorder, NULL ); CON_SETEVENT( ctl[ 6 ], handle_rowsize, NULL ); CON_SETEVENT( ctl[ 7 ], handle_jump, NULL ); CON_SETEVENT( ctl[ 8 ], handle_search, NULL ); CON_SETEVENT( ctl[ 10 ], handle_scroll, NULL ); CON_SETEVENT( ctl[ 13 ], handle_search, NULL ); CON_SETEVENT( ctl[ 16 ], handle_new, NULL ); /* set the control drawing callbacks */ ival.ptr.ptr = drawcb_text; ctl[ 0 ]->set( ctl[ 0 ], CTL_USERDRAW, &ival ); ival.ptr.ptr = drawcb_icon; ctl[ 15 ]->set( ctl[ 15 ], CTL_USERDRAW, &ival ); }
int get_user( UnwrapParams *uwp ) { static char *text[] = { "Draws polygons in the 2D coordinate system of the selected texture layer.", NULL }; static char *fgopt[] = { "Use Color", "Invert Background", "Brighten", "Darken", NULL }; static char *bgopt[] = { "Use Color", "Copy Image Map", NULL }; LWPanControlDesc desc; LWValue ival = { LWT_INTEGER }, sval = { LWT_STRING }, ivecval = { LWT_VINT }; LWPanelID panel; LWControl *ctl[ 10 ], *bdr[ 2 ]; Node *root; int i, x, y, w, ph, ok; root = make_list( panf->globalFun ); if ( !root ) return 0; if( !( panel = PAN_CREATE( panf, "Unwrap" ))) { free_tree( root, 1 ); return 0; } if ( !uwp->filename[ 0 ] ) { strcpy( uwp->filename, "unwrapped" ); filename_ext( uwp->saver, uwp->filename ); uwp->bgcolor[ 0 ] = uwp->bgcolor[ 1 ] = uwp->bgcolor[ 2 ] = 255; } TEXT_CTL( panf, panel, "", text ); ctl[ 0 ] = TREE_CTL( panf, panel, "Texture Layer", 200, 200, tree_info, tree_count, tree_child ); ph = PAN_GETH( panf, panel ); ph -= CON_X( ctl[ 0 ] ); ph -= CON_H( ctl[ 0 ] ); ctl[ 1 ] = SAVE_CTL( panf, panel, "Save As", 40 ); ctl[ 2 ] = CUSTPOPUP_CTL( panf, panel, "", 150, sname, scount ); ctl[ 3 ] = INT_CTL( panf, panel, "Width" ); ctl[ 4 ] = INT_CTL( panf, panel, "Height" ); ctl[ 5 ] = BUTTON_CTL( panf, panel, "From Image Map" ); ctl[ 6 ] = WPOPUP_CTL( panf, panel, "Edges", fgopt, 150 ); ctl[ 7 ] = MINIRGB_CTL( panf, panel, "" ); ctl[ 8 ] = WPOPUP_CTL( panf, panel, "Background", bgopt, 150 ); ctl[ 9 ] = MINIRGB_CTL( panf, panel, "" ); w = CON_W( ctl[ 1 ] ); w -= CON_LW( ctl[ 1 ] ); bdr[ 0 ] = BORDER_CTL( panf, panel, "", w, 2 ); bdr[ 1 ] = BORDER_CTL( panf, panel, "", w, 2 ); x = CON_X( ctl[ 0 ] ); x += CON_W( ctl[ 0 ] ); x += CON_LW( ctl[ 8 ] ) + 8; y = CON_Y( ctl[ 0 ] ); w = CON_LW( ctl[ 1 ] ); MOVE_CON( ctl[ 1 ], x - w, y ); w = CON_LW( ctl[ 2 ] ); y += CON_HOTH( ctl[ 1 ] ) + 4; MOVE_CON( ctl[ 2 ], x - w, y ); y += CON_HOTH( ctl[ 2 ] ) + 6; MOVE_CON( bdr[ 0 ], x, y ); w = CON_LW( ctl[ 3 ] ); y += 6; MOVE_CON( ctl[ 3 ], x - w, y ); w = CON_X( ctl[ 3 ] ); w += CON_W( ctl[ 3 ] ); MOVE_CON( ctl[ 5 ], w + 16, y ); w = CON_LW( ctl[ 4 ] ); y += CON_HOTH( ctl[ 3 ] ) + 4; MOVE_CON( ctl[ 4 ], x - w, y ); y += CON_HOTH( ctl[ 2 ] ) + 6; MOVE_CON( bdr[ 1 ], x, y ); y += 6; for ( i = 6; i <= 9; i++ ) { w = CON_LW( ctl[ i ] ); MOVE_CON( ctl[ i ], x - w, y ); y += CON_HOTH( ctl[ i ] ) + 4; } y = CON_Y( ctl[ 9 ] ); y += CON_H( ctl[ 9 ] ); PAN_SETH( panf, panel, y + ph ); SET_STR( ctl[ 1 ], uwp->filename, sizeof( uwp->filename )); SET_INT( ctl[ 2 ], uwp->saver ); SET_INT( ctl[ 3 ], uwp->width ); SET_INT( ctl[ 4 ], uwp->height ); SET_INT( ctl[ 6 ], uwp->fgoptions ); SET_INT( ctl[ 8 ], uwp->bgoptions ); SETV_IVEC( ctl[ 7 ], uwp->fgcolor ); SETV_IVEC( ctl[ 9 ], uwp->bgcolor ); CON_SETEVENT( ctl[ 0 ], tree_event, root ); CON_SETEVENT( ctl[ 2 ], saver_event, ctl[ 1 ] ); CON_SETEVENT( ctl[ 5 ], sizebtn_event, ctl ); ok = panf->open( panel, PANF_BLOCKING | PANF_CANCEL ); if ( ok ) { GET_STR( ctl[ 1 ], uwp->filename, sizeof( uwp->filename )); GET_INT( ctl[ 2 ], uwp->saver ); GET_INT( ctl[ 3 ], uwp->width ); GET_INT( ctl[ 4 ], uwp->height ); GET_INT( ctl[ 6 ], uwp->fgoptions ); GET_INT( ctl[ 8 ], uwp->bgoptions ); GETV_IVEC( ctl[ 7 ], uwp->fgcolor ); GETV_IVEC( ctl[ 9 ], uwp->bgcolor ); ctl[ 0 ]->get( ctl[ 0 ], CTL_VALUE, &ival ); if ( !getsel_tree( uwp, ( Node * ) ival.ptr.ptr )) { msgf->error( "No texture layer selected", NULL ); ok = 0; } } PAN_KILL( panf, panel ); free_tree( root, 1 ); return ok; }
static void ctl_create( void ) { static char *labatype[] = { "Point", "Sphere", "Dodec", NULL }; static char *labbtype[] = { "Line", "Cylinder", NULL }; static char *labradii[] = { "Radii", NULL }; int x, y, w, h, ph, i; /* create a control */ ctl[ 0 ] = STR_CTL( panf, panel, "Sequence", 40 ); /* find out how much vertical space the panel wants for drawing its own decorations, and get some other panel metrics */ ph = PAN_GETH( panf, panel ) - CON_H( ctl[ 0 ] ); dmet = panf->drawFuncs->dispMetrics(); /* create the rest of the controls */ ctl[ 1 ] = WPOPUP_CTL( panf, panel, "Atoms", labatype, 100 ); ctl[ 2 ] = INT_CTL( panf, panel, "Sides" ); ctl[ 3 ] = INT_CTL( panf, panel, "Segments" ); ctl[ 4 ] = TEXT_CTL( panf, panel, "", labradii ); ctl[ 5 ] = FLOAT_CTL( panf, panel, "Carbon" ); ctl[ 6 ] = FLOAT_CTL( panf, panel, "Hydrogen" ); ctl[ 7 ] = FLOAT_CTL( panf, panel, "Nitrogen" ); ctl[ 8 ] = FLOAT_CTL( panf, panel, "Oxygen" ); ctl[ 9 ] = FLOAT_CTL( panf, panel, "Phosphorus" ); ctl[ 10 ] = WPOPUP_CTL( panf, panel, "Bonds", labbtype, 100 ); ctl[ 11 ] = INT_CTL( panf, panel, "Sides" ); ctl[ 12 ] = INT_CTL( panf, panel, "Segments" ); ctl[ 13 ] = FLOAT_CTL( panf, panel, "Radius" ); ctl[ 14 ] = BOOL_CTL( panf, panel, "Base Plates" ); w = 2 * panf->drawFuncs->textWidth( panel, "Polygons:" ) + 16; ctl[ 15 ] = CANVAS_CTL( panf, panel, "", w, 3 * dmet->textHeight ); /* position all of the controls */ x = CON_X( ctl[ 0 ] ); x += CON_W( ctl[ 1 ] ); h = CON_HOTH( ctl[ 1 ] ) + 4; w = CON_W( ctl[ 1 ] ); y = CON_Y( ctl[ 0 ] ) + 3 * h / 2; MOVE_CON( ctl[ 1 ], x - w, y ); w = CON_W( ctl[ 2 ] ); MOVE_CON( ctl[ 2 ], x - w, y + 3 * h / 2 ); w = CON_W( ctl[ 3 ] ); y = CON_Y( ctl[ 2 ] ); MOVE_CON( ctl[ 3 ], x - w, y + h ); w = CON_W( ctl[ 4 ] ); y = CON_Y( ctl[ 3 ] ); MOVE_CON( ctl[ 4 ], ( x - w ) / 2, y + 3 * h / 2 ); for ( i = 5; i < 10; i++ ) { w = CON_W( ctl[ i ] ); y = CON_Y( ctl[ i - 1 ] ); MOVE_CON( ctl[ i ], x - w, y + h ); } x = x * 2 + 10; w = CON_W( ctl[ 10 ] ); y = CON_Y( ctl[ 1 ] ); MOVE_CON( ctl[ 10 ], x - w, y ); w = CON_W( ctl[ 11 ] ); y = CON_Y( ctl[ 10 ] ); MOVE_CON( ctl[ 11 ], x - w, y + 3 * h / 2 ); w = CON_W( ctl[ 12 ] ); y = CON_Y( ctl[ 11 ] ); MOVE_CON( ctl[ 12 ], x - w, y + h ); w = CON_W( ctl[ 13 ] ); y = CON_Y( ctl[ 12 ] ); MOVE_CON( ctl[ 13 ], x - w, y + 3 * h / 2 ); w = CON_W( ctl[ 14 ] ); y = CON_Y( ctl[ 13 ] ); MOVE_CON( ctl[ 14 ], x - w, y + 3 * h / 2 ); w = CON_W( ctl[ 15 ] ); y = CON_Y( ctl[ 14 ] ); MOVE_CON( ctl[ 15 ], x - w, y + 2 * h ); /* now that we know how much room the controls will take up, set the height of the panel */ h = CON_Y( ctl[ 9 ] ); h += CON_HOTH( ctl[ 9 ] ); PAN_SETH( panf, panel, h + ph - 6 ); /* initialize the controls */ ctl_set(); /* set the event handlers and user data */ for ( i = 0; i < 15; i++ ) CON_SETEVENT( ctl[ i ], ctl_event, NULL ); ival.ptr.ptr = ctl_draw; ctl[ 15 ]->set( ctl[ 15 ], CTL_USERDRAW, &ival ); }