Re: Creating a new selection box.

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...

Once you learn how to use sizers, you'll find things are much easier to arrange on the screen. smile

+1

This could use some prettying up / spacing tweaks, but here's a version that uses sizers.

-- Program testcombo.exw  
--  
include "wxeu/wxeud.e"   
without warning   
sequence listsize = {24 , 60 , 75 }  
constant    
    frmMain     = create( wxFrame, {0, -1, "Combo Demo", -1, -1, 600, 300} ),   
    pnlMain     = create( wxPanel, {frmMain} ),   
    lblMain1    = create( wxStaticText, {pnlMain, -1, "Furniture:"} ),   
    mainBox    = create( wxComboBox, {pnlMain, -1, "Fbox"} ),   
    lblType = create( wxStaticText, {pnlMain, -1, "Type:"} ),   
    typeBox      = create( wxComboBox, {pnlMain, -1,"Ibox"} ),   
    lblItems  = create( wxStaticText, {pnlMain, -1, "Items:"} ),   
    itemList    = create( wxListBox, {pnlMain} ), 
     
    main_sizer  = create( wxBoxSizer, wxHORIZONTAL ), 
    left_sizer  = create( wxBoxSizer, wxVERTICAL ), 
    right_sizer = create( wxBoxSizer, wxHORIZONTAL ), 
    furniture_sizer = create( wxBoxSizer, wxHORIZONTAL ), 
    type_sizer      = create( wxBoxSizer, wxHORIZONTAL ), 
    $   
 
 
add_window_to_sizer( furniture_sizer, lblMain1, 0, 0, 0 ) 
add_window_to_sizer( furniture_sizer, mainBox, 0, 0, 0 ) 
 
add_window_to_sizer( type_sizer, lblType, 0, 0, 0 ) 
add_window_to_sizer( type_sizer, typeBox, 0, 0, 0 ) 
 
 
add_window_to_sizer( right_sizer, lblItems, 0, 0, 0 ) 
add_window_to_sizer( right_sizer, itemList, 1, 0, 0 ) 
 
add_sizer_to_sizer( left_sizer, furniture_sizer, 0, 0, 0 ) 
add_sizer_to_sizer( left_sizer, type_sizer, 0, wxGROW, 0 ) 
add_sizer_to_sizer( main_sizer, left_sizer, 1, 0, 0 ) 
add_sizer_to_sizer( main_sizer, right_sizer, 1, 0, 0 ) 
 
set_sizer( pnlMain, main_sizer ) 
 
procedure resize() 
    layout_sizer( furniture_sizer) 
    layout_sizer( type_sizer ) 
    layout_sizer( left_sizer ) 
    layout_sizer( right_sizer ) 
    layout_sizer( main_sizer ) 
end procedure 
 
-- populate the combobox   
for i = 1 to listsize[1] do   
    add_item( mainBox, sprintf("Group %d", i) )   
end for   
   
-- hide the details   
-- show_window( lblType , wxFalse )   
show_window( typeBox  , wxFalse )   
-- show_window( lblItems  , wxFalse )   
show_window( itemList, wxFalse )   
  
procedure mainbox_handler( atom this, atom event_type, atom id, atom event )   
       
    integer index = get_selection( this )   
    sequence item = get_combo_item_string( this, index )   
       
    -- clear any existing details   
    clear_list( typeBox   )   
    clear_list( itemList )   
    
    -- populate the details   
    for i = 1 to listsize[2]  do   
        add_item( typeBox  , sprintf("%s Type %d", {item, i}) )   
    end for   
       
    -- show the details   
    show_window( lblType , wxTrue )   
    show_window( typeBox  , wxTrue )   
     
    resize() 
end procedure   
set_event_handler( mainBox, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("mainbox_handler") )   
   
procedure typebox_handler( atom this, atom event_type, atom id, atom event )   
       
    integer index = get_selection( this )   
    sequence item = get_combo_item_string( this, index )   
       
    -- clear any existing details   
    clear_list( typeBox   )   
    clear_list( itemList )   
    
    -- populate the details   
    for i = 1 to listsize[3]  do   
        add_item( itemList, sprintf("%s Item %d", {item, i}) )   
    end for   
       
    -- show the details   
    show_window( lblItems , wxTrue )   
    show_window( itemList, wxTrue )   
     
    resize() 
   
end procedure   
set_event_handler( typeBox  , -1, wxEVT_COMMAND_COMBOBOX_SELECTED, routine_id("typebox_handler") )   
   
wxMain( frmMain )   
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu