// 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; }
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; }