// MakeRegisterPanel(): // Creates the Register Panel bool SimplifyDongle::MakeRegisterPanel() { if( simp_int == NULL ) return false; // Create the Panel register_panel = simp_int->panel_funcs->Create( "Simplify Registration" ); try { if( !( dongle_id = STRRO_CTL( simp_int->panel_funcs->orig_struct, register_panel, "Dongle ID", 43 ) ) ) throw false; if( !( reg_code = STR_CTL( simp_int->panel_funcs->orig_struct, register_panel, "Reg Code", 43 ) ) ) throw false; if( !( register_now = WBUTTON_CTL( simp_int->panel_funcs->orig_struct, register_panel, "Register Now", 150 ) ) ) throw false; // Position some things MOVE_CON( dongle_id, 25, 212 ); PanelTools::AlignLabels( dongle_id, reg_code ); PAN_SETW( simp_int->panel_funcs->orig_struct, register_panel, 400 ); PAN_SETH( simp_int->panel_funcs->orig_struct, register_panel, 350 ); PanelTools::PutUnder( reg_code, register_now ); int pw = PAN_GETW( simp_int->panel_funcs->orig_struct, register_panel ); int w = CON_W( register_now ); int y = CON_Y( register_now ); MOVE_CON( register_now, (pw/2 - w/2), y ); // Default Values char buffer[10]; sprintf( buffer, "%ld", GetDongleID() ); SET_STR( dongle_id, buffer, strlen( buffer ) ); // Listener Functions CON_SETEVENT( register_now, OnRegisterNow, this ); CON_SETEVENT( reg_code, OnRegisterNow, this ); // Set the Draw Functions simp_int->panel_funcs->Set( register_panel, PAN_USERDRAW, DrawRegisterPanel ); return true; } catch( bool a ) { if( !a ) { simp_int->message->Error("Error creating interface controls; aborting" ); return false; } } return true; }
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 ); }
// MakeGroupControls(): bool FreeKeyInterface::MakeGroupControls() { try { int x, y; // Group Controls if( !( group_name = STR_CTL( panel_funcs->orig_struct, main_panel, "Group Name", 75 ) ) ) throw false; if( !( group_delete = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "Del", 50 ) ) ) throw false; if( !( group_edit_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Modify", group_edit_text, 250 ) ) ) throw false; if( !( group_edit_apply = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "Apply", 100 ) ) ) throw false; PanelTools::PutUnder( tool_options_tabs, group_name ); x = CON_X( group_name ); y = CON_Y( group_name ); MOVE_CON( group_name, x, y+4 ); PanelTools::PutOnLineWith( group_name, group_delete ); PanelTools::AlignLabels( group_name, group_edit_mode ); PanelTools::PutOnLineWith( group_edit_mode, group_edit_apply ); // Event Handler Functions CON_SETEVENT( group_name, OnGroupName, this ); CON_SETEVENT( group_delete, OnGroupDel, this ); CON_SETEVENT( group_edit_apply, OnGroupEditApply, this ); return true; } catch( bool ) { return false; } return true; }
// Constructor PanelControls_WPopdown::PanelControls_WPopdown( GlobalFunc *_global, LWPanelID _panel, int width, const char *_title, WPopdown_Name *_name, WPopdown_Count *_count ) : global(_global), panel(_panel), title(_title), event(NULL), user_data(NULL), strings(NULL), string_count(0), count(_count), name(_name) { panel_funcs = (LWPanelFuncs *)global( LWPANELFUNCS_GLOBAL, GFUSE_ACQUIRE ); context_funcs = (ContextMenuFuncs *)global( LWCONTEXTMENU_GLOBAL, GFUSE_ACQUIRE ); control = AREA_CTL( panel_funcs, panel, "", width-2, panel_funcs->drawFuncs->dispMetrics()->textHeight + 4 ); CON_SETEVENT( control, WPopdown_ControlEvent, this ); ival.intv.value = (int)&WPopdown_ControlDraw; (*control->set)( control, CTL_USERDRAW, &ival ); menu = CONTEXT_MENU( context_funcs, WPopdown_StringName, WPopdown_StringCount, this ); }
// Constructor PanelControls_WPopdown::PanelControls_WPopdown( GlobalFunc *_global, LWPanelID _panel, int width, const char *_title, const char **_strings ) : global(_global), panel(_panel), title(_title), event(NULL), user_data(NULL), strings(_strings), string_count(0), count(NULL), name(NULL), prev_index(0) { strings = _strings; for( string_count=0; strings[ string_count ] != NULL; string_count++ ) { ; } panel_funcs = (LWPanelFuncs *)global( LWPANELFUNCS_GLOBAL, GFUSE_ACQUIRE ); raster_funcs = (LWRasterFuncs *)global( LWRASTERFUNCS_GLOBAL, GFUSE_ACQUIRE ); context_funcs = (ContextMenuFuncs *)global( LWCONTEXTMENU_GLOBAL, GFUSE_ACQUIRE ); control = AREA_CTL( panel_funcs, panel, "", width-2, panel_funcs->drawFuncs->dispMetrics()->textHeight + 4 ); CON_SETEVENT( control, WPopdown_ControlEvent, this ); ival.intv.value = (int)&WPopdown_ControlDraw; (*control->set)( control, CTL_USERDRAW, &ival ); menu = CONTEXT_MENU( context_funcs, WPopdown_StringName, WPopdown_StringCount, this ); }
int ShowShaderPanel(GlobalFunc * global, const char * title, std::vector<std::string>& shaders, int * selection) { int ret; LWPanelFuncs *panf; LWPanelID ID; ret = 0; if (panf = (LWPanelFuncs*)global( LWPANELFUNCS_GLOBAL, GFUSE_TRANSIENT )) { ID = PAN_CREATE(panf, (char*)title); controls.shader_list = LISTBOX_CTL(panf, ID, "Shaders", DEF_SHADER_LB_WIDTH, DEF_SHADER_LIST_HEIGHT, sslb_name, sslb_count); ShaderUserdata userData = {shaders.size(), shaders}; CON_SETEVENT(controls.shader_list, sslb_event, &userData); if ( ret = panf->open( ID, PANF_BLOCKING | PANF_CANCEL | PANF_FRAME)) { GET_INT(controls.shader_list, *selection); } } return ret; }
static LWPanelID get_panel( void ) { LWPanControlDesc desc; LWPanelID panel; LWValue ival = { LWT_INTEGER }; LWControl *ctl[ 9 ]; int i; if( !( panel = PAN_CREATE( panf, "Panels Control Test" ))) return NULL; ctl[ 0 ] = BUTTON_CTL( panf, panel, "Edit" ); ctl[ 1 ] = BUTTON_CTL( panf, panel, "Slider" ); ctl[ 2 ] = BUTTON_CTL( panf, panel, "Choice" ); ctl[ 3 ] = BUTTON_CTL( panf, panel, "Tree" ); ctl[ 4 ] = BUTTON_CTL( panf, panel, "Color" ); ctl[ 5 ] = BUTTON_CTL( panf, panel, "File" ); ctl[ 6 ] = BUTTON_CTL( panf, panel, "Draw" ); ctl[ 7 ] = BOOL_CTL( panf, panel, "Boolean" ); ctl[ 8 ] = BOOLBUTTON_CTL( panf, panel, "Bool Button" ); CON_SETEVENT( ctl[ 0 ], event, open_editpan ); CON_SETEVENT( ctl[ 1 ], event, open_sliderpan ); CON_SETEVENT( ctl[ 2 ], event, open_choicepan ); CON_SETEVENT( ctl[ 3 ], event, open_treepan ); CON_SETEVENT( ctl[ 4 ], event, open_colorpan ); CON_SETEVENT( ctl[ 5 ], event, open_filepan ); CON_SETEVENT( ctl[ 6 ], event, open_drawpan ); /* align */ for ( i = 0; i < 9; i++ ) { ival.intv.value = 100 - CON_LW( ctl[ i ] ); ctl[ i ]->set( ctl[ i ], CTL_X, &ival ); } return panel; }
// MakeMainControls(): bool FreeKeyInterface::MakeMainControls() { try { int x, y, w; // Title Image (OpenGL) if( !( title_image = OPENGL_CTL( panel_funcs->orig_struct, main_panel, "", decoded_logo_small->GetWidth() - 25, decoded_logo_small->GetHeight() ) ) ) throw false; MOVE_CON( title_image, -13, -4 ); // File ItemSelection Conrols if( !( source_scene = FILE_CTL( panel_funcs->orig_struct, main_panel, "Source Scene", 91 ) ) ) throw false; if( !( source_popup = POPDOWN_CTL( panel_funcs->orig_struct, main_panel, "Source Tools", source_popup_text ) ) ) throw false; if( !( output_scene = FILE_CTL( panel_funcs->orig_struct, main_panel, "Output Scene", 91 ) ) ) throw false; if( !( output_popup = POPDOWN_CTL( panel_funcs->orig_struct, main_panel, " Output Tools", output_popup_text ) ) ) throw false; // x = CON_X( source_scene ); // y = CON_Y( source_scene ); // MOVE_CON( source_scene, x, y + 35 ); PanelTools::PutUnder( source_scene, source_scene, -11 ); PanelTools::AlignLabels( source_scene, output_scene, 5 ); PanelTools::PutOnLineWith( source_scene, source_popup, -10 ); PanelTools::PutOnLineWith( output_scene, output_popup, -10 ); // Default Settings for String/File and Popup Controls SET_STR( source_scene, (char *)fk->GetSource(), strlen( fk->GetSource() ) ); SET_STR( output_scene, (char *)fk->GetOutput(), strlen( fk->GetOutput() ) ); const int list_x_offset = 130; // List Controls if( !( list_fold = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "Fold", 50 ) ) ) throw false; if( !( list_unfold = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "Unfold", 50 ) ) ) throw false; if( !( select_count = INTRO_CTL( panel_funcs->orig_struct, main_panel, "" ) ) ) throw false; // Display Controls if( !( display_key_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Key Mode", display_key_mode_text, 130 ) ) ) throw false; if( !( display_item_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Item List", display_mode_text, 130 ) ) ) throw false; SET_INT( display_key_mode, fk->GetKeyDisplayMode() ); SET_INT( display_item_mode, fk->GetItemDisplayMode() ); PanelTools::PutUnder( output_scene, list_fold ); PanelTools::PutUnder( list_fold, list_fold ); x = CON_X( list_fold ); y = CON_Y( list_fold ); MOVE_CON( list_fold, x + 10 + list_x_offset, y-6 ); PanelTools::PutOnLineWith( list_fold, list_unfold, -7 ); PanelTools::PutOnLineWith( list_unfold, select_count, 15); PanelTools::PutOnLineWith( select_count, display_key_mode, 15 ); PanelTools::PutOnLineWith( display_key_mode, display_item_mode ); // Time Controls if( !( item_first_frame = FLOAT_CTL( panel_funcs->orig_struct, main_panel, "Low Frame" ) ) ) throw false; if( !( item_current_frame = FLOAT_CTL( panel_funcs->orig_struct, main_panel, "Current Frame" ) ) ) throw false; if( !( item_jump_to_frame = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "", 20 ) ) ) throw false; if( !( item_last_frame = FLOAT_CTL( panel_funcs->orig_struct, main_panel, "High Frame" ) ) ) throw false; if( !( item_range_presets = POPDOWN_CTL( panel_funcs->orig_struct, main_panel, " Ranges", item_range_preset_text ) ) ) throw false; SET_FLOAT( item_current_frame, fk->GetCurrentTime() * default_fps ); SET_FLOAT( item_first_frame, fk->GetDisplayMin() * default_fps ); SET_FLOAT( item_last_frame, fk->GetDisplayMax() * default_fps ); PanelTools::PutUnder( list_fold, item_first_frame ); x = CON_X( item_first_frame ); y = CON_Y( item_first_frame ); MOVE_CON( item_first_frame, x + list_x_offset + 40, y ); PanelTools::PutOnLineWith( item_first_frame, item_current_frame, 20 ); PanelTools::PutOnLineWith( item_current_frame, item_jump_to_frame, -5 ); PanelTools::PutOnLineWith( item_jump_to_frame, item_last_frame, 20 ); PanelTools::PutOnLineWith( item_last_frame, item_range_presets, -2 ); // Item List if( !( item_list = CANVAS_CTL( panel_funcs->orig_struct, main_panel, "", 625, 263 ) ) ) throw false; if( !( opengl_item_list = OPENGL_CTL( panel_funcs->orig_struct, main_panel, "", 625, 263 ) ) ) throw false; if( !( item_scroll = VSLIDER_CTL( panel_funcs->orig_struct, main_panel, "", 259, 0, 0 ) ) ) throw false; PanelTools::PutUnder( item_first_frame, item_list ); x = CON_X( item_list ); y = CON_Y( item_list ); MOVE_CON( item_list, x + list_x_offset, y ); MOVE_CON( opengl_item_list, x + list_x_offset, y ); w = CON_W( item_list ); MOVE_CON( item_scroll, x+w-18 + list_x_offset, y ); UpdateItemListType( fk->GetUseOpenGLItemList() ); // MultiSlider/Zoom if( !( item_zoom = PERCENT_CTL( panel_funcs->orig_struct, main_panel, "Zoom" ) ) ) throw false; SET_FLOAT( item_zoom, fk->GetZoom() * 100.0 ); if( !( item_multiscroll = DRAGAREA_CTL( panel_funcs->orig_struct, main_panel, "", 620 + list_x_offset - CON_W( item_zoom ) - 1, 16 ) ) ) throw false; PanelTools::PutUnder( item_list, item_zoom ); x = CON_X( item_zoom ); y = CON_Y( item_zoom ); MOVE_CON( item_zoom, x+8, y ); PanelTools::PutOnLineWith( item_zoom, item_multiscroll ); x = CON_X( item_multiscroll ); y = CON_Y( item_multiscroll ); MOVE_CON( item_multiscroll, x, y+1 ); // Tabs if( !( tool_options_tabs = TABCHOICE_CTL( panel_funcs->orig_struct, main_panel, "", tool_option_tab_text ) ) ) throw false; PanelTools::PutUnder( item_multiscroll, tool_options_tabs ); PanelTools::PutUnder( tool_options_tabs, tool_options_tabs ); // Group List if( !( group_list = CUSTPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Group", 200, GroupNames, GroupCount ) ) ) throw false; PanelTools::PutOnLineWith( tool_options_tabs, group_list, 12 ); x = CON_X( group_list ); y = CON_Y( group_list ); MOVE_CON( group_list, x, y-5 ); // About FreeKey button if( !( about = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "About", 63 ) ) ) throw false; // F1 (Keyboard Help) Button if( !( f1 = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "F1", 30 ) ) ) throw false; PanelTools::PutOnLineWith( group_list, about ); PanelTools::PutOnLineWith( about, f1 ); // Range Controls if( !( range_low = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel, "Range Low", 30, 0, 1000000 ) ) ) throw false; if( !( range_high = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel, "High", 30, 0, 1000000 ) ) ) throw false; SET_INT( range_high, 1000000 ); PanelTools::PutUnder( tool_options_tabs, range_low ); PanelTools::PutUnder( range_low, range_low ); PanelTools::PutUnder( range_low, range_low ); PanelTools::PutUnder( range_low, range_low ); PanelTools::PutUnder( range_low, range_low ); PanelTools::PutOnLineWith( range_low, range_high ); // Remove Mode if( !( remove_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Remove Mode", remove_mode_text, 250 ) ) ) throw false; PanelTools::PutOnLineWith( range_high, remove_mode, 20 ); y = CON_Y( remove_mode ); MOVE_CON( remove_mode, 325, y ); // Step if( !( step_amount = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel, "Step Amount", 30, 0, 32767 ) ) ) throw false; if( !( step_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Step Mode", step_mode_text, 250 ) ) ) throw false; PanelTools::PutUnder( range_low, step_amount ); PanelTools::PutOnLineWith( step_amount, step_mode ); // Delta if( !( delta_amount = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel, "Delta Amount", 30, -32768, 32767 ) ) ) throw false; if( !( delta_mode = BOOL_CTL( panel_funcs->orig_struct, main_panel, "Enable Time Delta" ) ) ) throw false; PanelTools::PutUnder( step_amount, delta_amount ); PanelTools::PutOnLineWith( delta_amount, delta_mode ); // Direction if( !( direction_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Direction", direction_mode_text, 250 ) ) ) throw false; PanelTools::PutOnLineWith( delta_amount, direction_mode ); // Scale if( !( scale_amount = FLOAT_CTL( panel_funcs->orig_struct, main_panel, "Scale Factor" ) ) ) throw false; if( !( scale_mode = BOOL_CTL( panel_funcs->orig_struct, main_panel, "Enable Scale Keys" ) ) ) throw false; PanelTools::PutUnder( delta_amount, scale_amount ); PanelTools::PutOnLineWith( scale_amount, scale_mode ); // Fix Some Alignments LWControl *align1[] = { range_low, step_amount, delta_amount, scale_amount, NULL }; PanelTools::AlignLabels( align1 ); PanelTools::PutOnLineWith( range_low, range_high ); LWControl *align2[] = { remove_mode, step_mode, direction_mode, NULL }; PanelTools::AlignLabels( align2 ); PanelTools::PutOnLineWith( delta_amount, delta_mode ); x = CON_X( delta_mode ); y = CON_Y( scale_mode ); MOVE_CON( scale_mode, x, y ); // Status Line if( !( status_line = CANVAS_CTL( panel_funcs->orig_struct, main_panel, // Compare Mode pop-up "", 600, 15 ) ) ) throw false; PanelTools::PutUnder( scale_amount, status_line ); PanelTools::PutUnder( status_line, status_line ); // FreeKey-ify button if( !( freekey = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "FreeKey-ify!", 150 ) ) ) throw false; PanelTools::PutOnLineWith( status_line, freekey, -8 ); // Right-Align the F1 Button int x2 = CON_X( item_scroll ); int w2 = CON_W( item_scroll ); y = CON_Y( f1 ); w = CON_W( f1 ); MOVE_CON( f1, x2+w2-w, y ); // Move the About Button just to the left of the F1 Button y = CON_Y( about ); w = CON_W( about ); x = CON_X( f1 ); MOVE_CON( about, x-w+5, y ); PAN_SETW( panel_funcs->orig_struct, main_panel, decoded_logo_small->GetWidth() - 30 ); // Envent Handler Functions CON_SETEVENT( about, OnAbout, this ); CON_SETEVENT( source_scene, OnSourceFile, this ); CON_SETEVENT( output_scene, OnOutputFile, this ); CON_SETEVENT( source_popup, OnSourcePopup, this ); CON_SETEVENT( output_popup, OnOutputPopup, this ); CON_SETEVENT( item_first_frame, OnFirstFrame, this ); CON_SETEVENT( item_last_frame, OnLastFrame, this ); CON_SETEVENT( item_range_presets, OnItemRangePresets, this ); CON_SETEVENT( item_scroll, OnItemScroll, this ); CON_SETEVENT( item_multiscroll, OnItemMultiScroll2, this ); CON_SETEVENT( item_zoom, OnItemZoom, this ); CON_SETEVENT( list_fold, OnFoldList, this ); CON_SETEVENT( list_unfold, OnUnFoldList, this ); CON_SETEVENT( display_key_mode, OnKeyFrameMode, this ); CON_SETEVENT( display_item_mode, OnDisplayMode, this ); CON_SETEVENT( tool_options_tabs, OnToolOptionsTabs, this ); CON_SETEVENT( group_list, OnGroupList, this ); CON_SETEVENT( range_low, OnRangeLow, this ); CON_SETEVENT( range_high, OnRangeHigh, this ); CON_SETEVENT( remove_mode, OnRemoveMode, this ); CON_SETEVENT( step_amount, OnStepAmount, this ); CON_SETEVENT( step_mode, OnStepMode, this ); CON_SETEVENT( delta_amount, OnDeltaAmount, this ); CON_SETEVENT( delta_mode, OnDeltaMode, this ); CON_SETEVENT( scale_amount, OnScaleAmount, this ); CON_SETEVENT( scale_mode, OnScaleMode, this ); CON_SETEVENT( direction_mode, OnDirectionMode, this ); CON_SETEVENT( f1, OnF1, this ); CON_SETEVENT( freekey, OnFreeKey, this ); CON_SETEVENT( item_list, OnItemList, this ); // CON_SETEVENT( opengl_item_list, OnItemList, this ); // Set the Draw Functions ival.intv.value = (int)&DrawItemJumpToFrame; (*item_jump_to_frame->set)( item_jump_to_frame, CTL_USERDRAW, &ival ); ival.intv.value = (int)&DrawItemListbox; (*item_list->set)( item_list, CTL_USERDRAW, &ival ); // For some inexplicable reason, the draw function is an event for OpenGL controls. Go fig. // ival.intv.value = (int)&DrawOpenGLItemListbox; // (*opengl_item_list->set)( opengl_item_list, CTL_USERDRAW, &ival ); CON_SETEVENT( opengl_item_list, DrawOpenGLItemListbox, this ); ival.intv.value = (int)&DrawItemMultiScroll; (*item_multiscroll->set)( item_multiscroll, CTL_USERDRAW, &ival ); ival.intv.value = (int)&DrawStatusLine; (*status_line->set)( status_line, CTL_USERDRAW, &ival ); CON_SETEVENT( title_image, DrawTitleImage, this ); return true; } catch( bool ) { return false; } return true; }
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 ); }
// MakeOptionControls(): bool FreeKeyInterface::MakeOptionControls() { try { int x, y; // Undo Levels if( !( opt_undo_levels = MINISLIDER_CTL( panel_funcs->orig_struct, main_panel, "Undo Levels", 30, 0, 128 ) ) ) throw false; // Fractional Keyframes if( !( opt_fractional_frames = BOOL_CTL( panel_funcs->orig_struct, main_panel, "Allow Fractional Frames" ) ) ) throw false; // Item List Draw Style if( !( opt_draw_style = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Item List Draw Style", opt_draw_style_text, 150 ) ) ) throw false; SET_INT( opt_draw_style, fk->GetDrawStyle() ); // Use OpenGL Item List if( !( opt_use_opengl_item_list = BOOL_CTL( panel_funcs->orig_struct, main_panel, "Use OpenGL Item List" ) ) ) throw false; SET_INT( opt_use_opengl_item_list, (int)fk->GetUseOpenGLItemList() ); // Use OpenGL Legacy Alignment if( !( opt_use_opengl_legacy = BOOL_CTL( panel_funcs->orig_struct, main_panel, "Use Legacy OpenGL Icon Alignment" ) ) ) throw false; SET_INT( opt_use_opengl_legacy, (int)GLTLWIcons::GetLegacyOffset() ); PanelTools::PutUnder( tool_options_tabs, opt_undo_levels ); x = CON_X( opt_undo_levels ); y = CON_Y( opt_undo_levels ); MOVE_CON( opt_undo_levels, x, y+4 ); PanelTools::PutOnLineWith( opt_undo_levels, opt_fractional_frames, 25 ); PanelTools::PutOnLineWith( opt_fractional_frames, opt_draw_style, 25 ); PanelTools::PutUnder( opt_fractional_frames, opt_use_opengl_item_list ); x = CON_X( opt_fractional_frames ); y = CON_Y( opt_use_opengl_item_list ); MOVE_CON( opt_use_opengl_item_list, x, y ); PanelTools::PutUnder( opt_use_opengl_item_list, opt_use_opengl_legacy ); y = CON_Y( opt_use_opengl_legacy ); MOVE_CON( opt_use_opengl_legacy, x, y ); // Event Handler Functions CON_SETEVENT( opt_draw_style, OnOptDrawStyle, this ); CON_SETEVENT( opt_use_opengl_item_list, OnOptUseOpenGLItemList, this ); CON_SETEVENT( opt_use_opengl_legacy, OnOptUseOpenGLLegacy, this ); return true; } catch( bool ) { return false; } return true; }
// OpenUI(): // Opens the user interface. Returns after the panel has been closed. bool ReplaceObjects_Interface::OpenUI() { // Destroy the panel if it hasn't been destroyed yet if( panel != NULL ) { (*panel_funcs->destroy)( panel ); panel = NULL; } char title_string[256]; sprintf( title_string, "ReplaceObjects -- %c2001 Joe Angell, TM Productions", 169 ); panel = (*panel_funcs->create)( title_string, panel_funcs ); if( !panel ) { // Make sure the panel was created (*message->error)("Error creating main panel, aborting", NULL ); return false; } // Limit To Pop-Up limit_to_popup = WPOPUP_CTL( panel_funcs, panel, "Limit To", limit_to_popup_strings, 110 ); // Sort By Pop-Up sort_by_popup = WPOPUP_CTL( panel_funcs, panel, "Sort By", sort_by_popup_strings, 110 ); PanelTools::PutOnLineWith( limit_to_popup, sort_by_popup, 10 ); // Match match_toggle = BOOL_CTL( panel_funcs, panel, "Match Name" ); match_string = STR_CTL( panel_funcs, panel, "Name Contains", 41 ); PanelTools::PutOnLineWith( match_toggle, match_string, 10 ); // List list = MULTILIST_CTL( panel_funcs, panel, "Swap Objects", 300, 20, ListNames, ListCount, ListColumnWidths ); PanelTools::PutUnder( match_toggle, list, 20 ); // Add add = WBUTTON_CTL( panel_funcs, panel, "Add", 60 ); PanelTools::PutOnLineWith( list, add, 3); // Clone clone = WBUTTON_CTL( panel_funcs, panel, "Clone", 60 ); PanelTools::AlignLabels( add, clone ); // Remove remove = WBUTTON_CTL( panel_funcs, panel, "Remove", 60 ); PanelTools::AlignLabels( clone, remove ); // Clear All clear_all = WBUTTON_CTL( panel_funcs, panel, "Clear All", 60 ); PanelTools::AlignLabels( remove, clear_all ); PanelTools::PutUnder( clear_all, clear_all ); // About about = WBUTTON_CTL( panel_funcs, panel, "About", 60 ); PanelTools::PutOnLineWith( sort_by_popup, about ); // Load load = LOADBUTTON_CTL( panel_funcs, panel, "Load", 60 ); PanelTools::PutOnLineWith( sort_by_popup, about ); // Save save = SAVEBUTTON_CTL( panel_funcs, panel, "Save", 60 ); PanelTools::PutOnLineWith( sort_by_popup, about ); // Path path = FILE_CTL( panel_funcs, panel, "Object Path", 59 ); PanelTools::PutUnder( list, path, 18 ); // Weight weight = FLOAT_CTL( panel_funcs, panel, "Weight" ); PanelTools::AlignLabels( path, weight ); // Enable enable = BOOL_CTL( panel_funcs, panel, "Enable" ); PanelTools::PutOnLineWith( weight, enable ); // Store Original Names store_original_name = BOOL_CTL( panel_funcs, panel, "Store Original Object Name As Tag" ); SET_INT( store_original_name, store_original_name_value ); PanelTools::AlignLabels( weight, store_original_name, 18 ); int x = CON_X( add ); int y = CON_Y( list ); int h = CON_H( list ); int h2 = CON_H( about ); MOVE_CON( about, x, (y + h) - h2 ); MOVE_CON( save, x, (y + h) - (h2 * 3) + 10 ); MOVE_CON( load, x, (y + h) - (h2 * 4) + 15 ); // Default Values SET_INT( list, -1 ); HandleList( list, NULL ); // Event Handlers CON_SETEVENT( list, HandleList, NULL ); CON_SETEVENT( about, HandleAbout, NULL ); CON_SETEVENT( sort_by_popup, HandleSortBy, NULL ); CON_SETEVENT( match_toggle, HandleMatchToggle, NULL ); CON_SETEVENT( add, HandleAdd, NULL ); CON_SETEVENT( clone, HandleClone, NULL ); CON_SETEVENT( remove, HandleRemove, NULL ); CON_SETEVENT( clear_all, HandleClearAll, NULL ); CON_SETEVENT( load, HandleLoad, NULL ); CON_SETEVENT( save, HandleSave, NULL ); CON_SETEVENT( path, HandlePath, NULL ); CON_SETEVENT( weight, HandleWeight, NULL ); CON_SETEVENT( enable, HandleEnable, NULL ); // Panel-Level Callbacks (*panel_funcs->set)( panel, PAN_USERDRAW, DrawPanel ); // Get a copy of the swaps swaps.Flush(); ReplaceObjects_SwapObject *new_swap; for( unsigned long i=0; i < old_swaps.NumElements(); i++ ) { new_swap = new ReplaceObjects_SwapObject; *new_swap = *old_swaps[i]; swaps.Add( new_swap ); } HandleMatchToggle( match_toggle, NULL ); // Open the Panel int retval = (*panel_funcs->open)( panel, PANF_BLOCKING | PANF_CANCEL | PANF_PASSALLKEYS ); if( retval > 0 ) { do_process = true; GET_INT( store_original_name, store_original_name_value ); old_swaps.Flush(); ReplaceObjects_SwapObject *new_swap; for( unsigned long i=0; i < swaps.NumElements(); i++ ) { new_swap = new ReplaceObjects_SwapObject; *new_swap = *swaps[i]; old_swaps.Add( new_swap ); } } return do_process; }
// MakeItemSelectionControls(): bool FreeKeyInterface::MakeItemSelectionControls() { try { int x, y; // ItemSelection Controls if( !( select_item_name = STR_CTL( panel_funcs->orig_struct, main_panel, "Match String", 65 ) ) ) throw false; if( !( select_name_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Compare", selection_name_text, 100 ) ) ) throw false; if( !( select_toggle = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "Mode", select_toggle_text, 83 ) ) ) throw false; if( !( select_item_mode = WPOPUP_CTL( panel_funcs->orig_struct, main_panel, "", selection_mode_text, 257 ) ) ) throw false; if( !( select_children_toggle = BOOL_CTL( panel_funcs->orig_struct, main_panel, "And Children" ) ) ) throw false; if( !( apply_select_item_name = WBUTTON_CTL( panel_funcs->orig_struct, main_panel, "Apply", 100 ) ) ) throw false; SET_INT( select_item_mode, 1 ); SET_INT( select_name_mode, 1 ); SET_INT( select_children_toggle, 1 ); SET_INT( select_toggle, 0 ); PanelTools::PutUnder( tool_options_tabs, select_item_name ); x = CON_X( select_item_name ); y = CON_Y( select_item_name ); MOVE_CON( select_item_name, x, y+4 ); PanelTools::PutOnLineWith( select_item_name, select_name_mode, -2 ); PanelTools::AlignLabels( select_item_name, select_toggle ); PanelTools::PutOnLineWith( select_toggle, select_item_mode ); PanelTools::PutOnLineWith( select_item_mode, select_children_toggle ); PanelTools::PutOnLineWith( select_children_toggle, apply_select_item_name ); x = CON_X( apply_select_item_name ); int w = CON_W( apply_select_item_name ); int x2 = CON_X( item_scroll ); int w2 = CON_W( item_scroll ); int y2 = CON_HOTY( select_name_mode ); y = CON_HOTY( apply_select_item_name ); int h = CON_HOTH( apply_select_item_name ); // Item Selection Info if( !( select_info_area = AREA_CTL( panel_funcs->orig_struct, main_panel, "", (x2+w2) - (x+w) - 20, (y+h) - y2 ) ) ) throw false; PanelTools::PutOnLineWith( select_name_mode, select_info_area ); // Event Handler Functions CON_SETEVENT( apply_select_item_name, OnApplySelection, this ); CON_SETEVENT( select_item_mode, OnSelectionMode, this ); CON_SETEVENT( select_toggle, OnSelectionMode, this ); // Set the Draw Functions ival.intv.value = (int)&DrawSelectInfo; (*select_info_area->set)( select_info_area, CTL_USERDRAW, &ival ); return true; } catch( bool ) { return false; } return true; }
int open_choicepan( LWPanelFuncs *panf ) { LWPanControlDesc desc; LWValue ival = { LWT_INTEGER }, sval = { LWT_STRING }; LWPanelID panel; LWControl *ctl[ 11 ] = { NULL }; LWChannelInfo *chinfo; LWItemInfo *iteminfo; int n, w, ok; chinfo = panf->globalFun( LWCHANNELINFO_GLOBAL, GFUSE_TRANSIENT ); iteminfo = panf->globalFun( LWITEMINFO_GLOBAL, GFUSE_TRANSIENT ); if ( !chinfo || !iteminfo ) return 0; if ( !id ) id = pid = iteminfo->first( LWI_CAMERA, LWITEM_NULL ); if ( !chan ) chan = chinfo->nextChannel( iteminfo->chanGroup( id ), NULL ); if( !( panel = PAN_CREATE( panf, "Choice" ))) return 0; ctl[ 0 ] = TABCHOICE_CTL( panf, panel, "Tab Choice", choices ); ctl[ 1 ] = HCHOICE_CTL( panf, panel, "Horizontal Choice", choices ); ctl[ 2 ] = VCHOICE_CTL( panf, panel, "Vertical Choice", choices ); ctl[ 3 ] = POPUP_CTL( panf, panel, "Popup", choices ); ctl[ 4 ] = CUSTPOPUP_CTL( panf, panel, "Custom Popup", 100, name, count ); ctl[ 5 ] = POPDOWN_CTL( panf, panel, "Popdown", choices ); ctl[ 6 ] = LISTBOX_CTL( panf, panel, "List Box", 100, 5, name, count ); ctl[ 7 ] = MULTILIST_CTL( panf, panel, "Multi List Box", 200, 3, mname, count, colwidth ); ctl[ 8 ] = ITEM_CTL( panf, panel, "Item", panf->globalFun, LWI_CAMERA ); ctl[ 9 ] = PIKITEM_CTL( panf, panel, "Pikitem", panf->globalFun, LWI_CAMERA, 100 ); ctl[ 10 ] = CHANNEL_CTL( panf, panel, "Channel", 200, 140 ); /* align */ for ( n = 0; n < 11; n++ ) { if ( ctl[ n ] ) { w = CON_LW( ctl[ n ] ); ival.intv.value = 100 - w; ctl[ n ]->set( ctl[ n ], CTL_X, &ival ); } } SET_INT( ctl[ 0 ], tab ); SET_INT( ctl[ 1 ], hc ); SET_INT( ctl[ 2 ], vc ); SET_INT( ctl[ 3 ], pop ); SET_INT( ctl[ 4 ], cpop ); SET_INT( ctl[ 5 ], dpop ); SET_INT( ctl[ 6 ], list ); SET_INT( ctl[ 7 ], mlist ); SET_INT( ctl[ 8 ], ( int ) id ); SET_INT( ctl[ 9 ], ( int ) pid ); SET_INT( ctl[ 10 ], ( int ) chan ); /* need these so that Panels can do some formatting */ CON_SETEVENT( ctl[ 6 ], NULL, NULL ); CON_SETEVENT( ctl[ 7 ], NULL, NULL ); ok = panf->open( panel, PANF_BLOCKING | PANF_CANCEL ); if ( ok ) { GET_INT( ctl[ 1 ], hc ); GET_INT( ctl[ 2 ], vc ); GET_INT( ctl[ 3 ], pop ); GET_INT( ctl[ 4 ], cpop ); GET_INT( ctl[ 5 ], dpop ); GET_INT( ctl[ 6 ], list ); GET_INT( ctl[ 7 ], mlist ); ctl[ 8 ]->get( ctl[ 8 ], CTL_VALUE, &ival ); id = ( LWItemID ) ival.intv.value; ctl[ 9 ]->get( ctl[ 9 ], CTL_VALUE, &ival ); pid = ( LWItemID ) ival.intv.value; ctl[ 10 ]->get( ctl[ 10 ], CTL_VALUE, &ival ); chan = ( LWChannelID ) ival.ptr.ptr; } PAN_KILL( panf, panel ); return 1; }
int open_sliderpan( LWPanelFuncs *panf ) { LWPanControlDesc desc; LWValue ival = { LWT_INTEGER }, fval = { LWT_FLOAT }; LWPanelID panel; LWControl *ctl[ 10 ]; int n, w, ok; if( !( panel = PAN_CREATE( panf, "Slider" ))) return 0; panf->set( panel, PAN_USERDATA, panf ); panf->set( panel, PAN_MOUSEBUTTON, mevent ); panf->set( panel, PAN_MOUSEMOVE, mevent ); ctl[ 0 ] = SLIDER_CTL( panf, panel, "Slider", 100, -20, 100 ); ctl[ 1 ] = VSLIDER_CTL( panf, panel, "Vertical Slider", 60, 0, 100 ); ctl[ 2 ] = HSLIDER_CTL( panf, panel, "Horizontal Slider", 100, -20, 100 ); ctl[ 3 ] = UNSLIDER_CTL( panf, panel, "Unbounded Slider", 100, -20, 100 ); ctl[ 4 ] = MINISLIDER_CTL( panf, panel, "Minislider", 100, -20, 100 ); ctl[ 5 ] = PERCENT_CTL( panf, panel, "Percent" ); ctl[ 6 ] = ANGLE_CTL( panf, panel, "Angle" ); ctl[ 7 ] = DRAGBUT_CTL( panf, panel, "Drag Button", 40, 40 ); ctl[ 8 ] = VDRAGBUT_CTL( panf, panel, "Vertical Drag Button" ); ctl[ 9 ] = HDRAGBUT_CTL( panf, panel, "Horizontal Drag Button" ); CON_SETEVENT( ctl[ 1 ], sevent, NULL ); CON_SETEVENT( ctl[ 2 ], sevent, NULL ); CON_SETEVENT( ctl[ 7 ], devent, NULL ); CON_SETEVENT( ctl[ 8 ], devent, NULL ); CON_SETEVENT( ctl[ 9 ], devent, NULL ); /* align */ for ( n = 0; n < 10; n++ ) { w = CON_LW( ctl[ n ] ); ival.intv.value = 100 - w; ctl[ n ]->set( ctl[ n ], CTL_X, &ival ); } for ( n = 0; n < 5; n++ ) SET_INT( ctl[ n ], slideval[ n ] ); SET_FLOAT( ctl[ 5 ], pct ); SET_FLOAT( ctl[ 6 ], angle ); ok = panf->open( panel, PANF_BLOCKING | PANF_CANCEL | PANF_MOUSETRAP ); if ( ok ) { for ( n = 0; n < 5; n++ ) GET_INT( ctl[ n ], slideval[ n ] ); GET_FLOAT( ctl[ 5 ], pct ); GET_FLOAT( ctl[ 6 ], angle ); } PAN_KILL( panf, panel ); return 1; }
// Constructor: LWLister::LWLister( GlobalFunc *_global, LWPanelFuncs *_panel_funcs, LWPanelID _panel, int w, int h, int (__cdecl *_count)( void *data ), const char * (__cdecl *_name)( void *data, int index, int col ), int (__cdecl *_col_widths)( void *data, int col ), void * _user_data ) : global(_global), panel_funcs(_panel_funcs), panel(_panel), count(_count), name(_name), col_widths(_col_widths), select(NULL), user_data(_user_data), first_visible_item(0), leftmost_visible_pixel(0), max_hscroll(500) { // Fetch RasterFuncs raster_funcs = (LWRasterFuncs *)global( LWRASTERFUNCS_GLOBAL, GFUSE_ACQUIRE ); // Get the column count int value; for( int i=0; (value = col_widths( user_data, i)) != 0; i++ ) column_widths.Add( value ); // Check the interface sizes if( h < 45 ) h = 45; if( w < 60 ) w = 60; // Create the slider raster images vslider_raster_knob = raster_funcs->create( 15, 1, 0 ); vslider_raster_trough = raster_funcs->create( 15, 1, 0 ); hslider_raster_knob = raster_funcs->create( 1, 15, 0 ); hslider_raster_trough = raster_funcs->create( 1, 15, 0 ); for( double d=0; d < 15.0; d++ ) { raster_funcs->drawRGBPixel( vslider_raster_knob, (int)(184 - (44 * (d/14.0))), (int)(196 - (44 * (d/14.0))), (int)(184 - (44 * (d/14.0))), (int)d, 0 ); raster_funcs->drawRGBPixel( vslider_raster_trough, (int)(104 + (60 * (d/14.0))), (int)(104 + (60 * (d/14.0))), (int)(104 + (60 * (d/14.0))), (int)d, 0 ); raster_funcs->drawRGBPixel( hslider_raster_knob, (int)(184 - (44 * (d/14.0))), (int)(196 - (44 * (d/14.0))), (int)(184 - (44 * (d/14.0))), 0, (int)d ); raster_funcs->drawRGBPixel( hslider_raster_trough, (int)(104 + (60 * (d/14.0))), (int)(104 + (60 * (d/14.0))), (int)(104 + (60 * (d/14.0))), 0, (int)d ); } // Create the controls lister = CANVAS_CTL( panel_funcs, panel, "", w-18, h-18 ); vslider = CANVAS_CTL( panel_funcs, panel, "", 15, h-18 ); hslider = CANVAS_CTL( panel_funcs, panel, "", w-18, 15 ); PanelTools::PutOnLineWith( lister, vslider ); PanelTools::AlignLabels( lister, hslider ); CON_SETEVENT( lister, NULL, this ); CON_SETEVENT( vslider, NULL, this ); CON_SETEVENT( hslider, NULL, this ); ival.intv.value = (int)&DrawLWLister; (*lister->set)( lister, CTL_USERDRAW, &ival ); ival.intv.value = (int)&DrawLWListerVSlider; (*vslider->set)( vslider, CTL_USERDRAW, &ival ); ival.intv.value = (int)&DrawLWListerHSlider; (*hslider->set)( hslider, CTL_USERDRAW, &ival ); }