Skip to content

Commit 39da6df

Browse files
committed
Compiles with wxListBox move
not all bugs fixed yet
1 parent b839425 commit 39da6df

File tree

5 files changed

+40
-32
lines changed

5 files changed

+40
-32
lines changed

source/form.fbp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -818,14 +818,14 @@
818818
<property name="wrap">-1</property>
819819
</object>
820820
</object>
821-
<object class="gbsizeritem" expanded="0">
821+
<object class="gbsizeritem" expanded="1">
822822
<property name="border">5</property>
823823
<property name="colspan">1</property>
824824
<property name="column">0</property>
825825
<property name="flag">wxALL|wxEXPAND</property>
826826
<property name="row">1</property>
827827
<property name="rowspan">1</property>
828-
<object class="wxListCtrl" expanded="0">
828+
<object class="wxListBox" expanded="1">
829829
<property name="BottomDockable">1</property>
830830
<property name="LeftDockable">1</property>
831831
<property name="RightDockable">1</property>
@@ -839,6 +839,7 @@
839839
<property name="caption"></property>
840840
<property name="caption_visible">1</property>
841841
<property name="center_pane">0</property>
842+
<property name="choices"></property>
842843
<property name="close_button">1</property>
843844
<property name="context_help"></property>
844845
<property name="context_menu">1</property>
@@ -870,7 +871,7 @@
870871
<property name="resize">Resizable</property>
871872
<property name="show">1</property>
872873
<property name="size"></property>
873-
<property name="style">wxLC_LIST|wxLC_SINGLE_SEL</property>
874+
<property name="style">wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE</property>
874875
<property name="subclass">; ; forward_declare</property>
875876
<property name="toolbar_pane">0</property>
876877
<property name="tooltip"></property>
@@ -883,14 +884,14 @@
883884
<property name="window_style"></property>
884885
</object>
885886
</object>
886-
<object class="gbsizeritem" expanded="0">
887+
<object class="gbsizeritem" expanded="1">
887888
<property name="border">5</property>
888889
<property name="colspan">1</property>
889890
<property name="column">0</property>
890891
<property name="flag">wxALL|wxEXPAND</property>
891892
<property name="row">3</property>
892893
<property name="rowspan">1</property>
893-
<object class="wxListCtrl" expanded="0">
894+
<object class="wxListBox" expanded="1">
894895
<property name="BottomDockable">1</property>
895896
<property name="LeftDockable">1</property>
896897
<property name="RightDockable">1</property>
@@ -904,6 +905,7 @@
904905
<property name="caption"></property>
905906
<property name="caption_visible">1</property>
906907
<property name="center_pane">0</property>
908+
<property name="choices"></property>
907909
<property name="close_button">1</property>
908910
<property name="context_help"></property>
909911
<property name="context_menu">1</property>
@@ -935,7 +937,7 @@
935937
<property name="resize">Resizable</property>
936938
<property name="show">1</property>
937939
<property name="size"></property>
938-
<property name="style">wxLC_LIST|wxLC_NO_HEADER|wxLC_SINGLE_SEL</property>
940+
<property name="style">wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE</property>
939941
<property name="subclass">; ; forward_declare</property>
940942
<property name="toolbar_pane">0</property>
941943
<property name="tooltip"></property>

source/interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
7373

7474
iManSizer->Add( m_staticText6, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
7575

76-
installsList = new wxListCtrl( installs_pane, wxID_FLOPPY, wxDefaultPosition, wxDefaultSize, wxLC_LIST|wxLC_SINGLE_SEL );
76+
installsList = new wxListBox( installs_pane, wxID_FLOPPY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
7777
iManSizer->Add( installsList, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 );
7878

79-
installsPathsList = new wxListCtrl( installs_pane, wxID_HOME, wxDefaultPosition, wxDefaultSize, wxLC_LIST|wxLC_NO_HEADER|wxLC_SINGLE_SEL );
79+
installsPathsList = new wxListBox( installs_pane, wxID_HOME, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
8080
iManSizer->Add( installsPathsList, wxGBPosition( 3, 0 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 );
8181

8282
wxBoxSizer* bSizer4;

source/interface.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
#include <wx/gbsizer.h>
2424
#include <wx/panel.h>
2525
#include <wx/stattext.h>
26+
#include <wx/listbox.h>
2627
#include <wx/notebook.h>
2728
#include <wx/menu.h>
2829
#include <wx/frame.h>
2930
#include <wx/textctrl.h>
3031
#include <wx/choice.h>
3132
#include <wx/dialog.h>
32-
#include <wx/listbox.h>
3333

3434
///////////////////////////////////////////////////////////////////////////
3535

@@ -59,8 +59,8 @@ class MainFrame : public wxFrame
5959
wxPanel* installs_pane;
6060
wxStaticText* m_staticText5;
6161
wxStaticText* m_staticText6;
62-
wxListCtrl* installsList;
63-
wxListCtrl* installsPathsList;
62+
wxListBox* installsList;
63+
wxListBox* installsPathsList;
6464
wxButton* m_button5;
6565
wxButton* m_button6;
6666
wxButton* launchHubBtn;

source/interface_derived.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ EVT_BUTTON(wxID_BACKWARD,MainFrameDerived::OnOpenHub)
3636
EVT_BUTTON(wxID_RELOAD,MainFrameDerived::OnReloadEditors)
3737
EVT_BUTTON(OPEN_WITH, MainFrameDerived::OnOpenWith)
3838
EVT_LIST_ITEM_ACTIVATED(wxID_HARDDISK, MainFrameDerived::OnOpenProject)
39-
EVT_LIST_ITEM_ACTIVATED(wxID_FLOPPY,MainFrameDerived::OnRevealEditor)
40-
EVT_LIST_ITEM_ACTIVATED(wxID_HOME,MainFrameDerived::OnRevealInstallLocation)
39+
EVT_LISTBOX_DCLICK(wxID_FLOPPY,MainFrameDerived::OnRevealEditor)
40+
EVT_LISTBOX_DCLICK(wxID_HOME,MainFrameDerived::OnRevealInstallLocation)
4141
wxEND_EVENT_TABLE()
4242

4343
//call superclass constructor
@@ -80,7 +80,7 @@ MainFrameDerived::MainFrameDerived() : MainFrame(NULL){
8080
void MainFrameDerived::ReloadData(){
8181
//clear any existing items
8282
projectsList->DeleteAllItems();
83-
installsPathsList->DeleteAllItems();
83+
installsPathsList->Clear();
8484
projects.clear();
8585
installPaths.clear();
8686
editors.clear();
@@ -180,23 +180,21 @@ void MainFrameDerived::LoadEditorPath(const string& path){
180180
SaveEditorVersions();
181181

182182
//add to the UI
183-
wxListItem i;
184-
i.SetColumn(0);
185-
i.SetId(0);
186-
i.SetText(path);
183+
wxArrayString a;
184+
a.Add(path);
187185

188-
installsPathsList->InsertItem(i);
186+
installsPathsList->InsertItems(a,0);
189187
}
190188

191189
void MainFrameDerived::OnRemoveInstallPath(wxCommandEvent& event){
192-
long itemIndex = wxListCtrl_get_selected(installsPathsList);
193-
if (itemIndex > -1){
190+
int itemIndex = installsPathsList->GetSelection();
191+
if (itemIndex != wxNOT_FOUND){
194192
// Got the selected item index
195193
//remove it from the vector
196194
installPaths.erase(installPaths.begin()+itemIndex);
197195

198196
//update the UI
199-
installsPathsList->DeleteItem(itemIndex);
197+
installsPathsList->Delete(itemIndex);
200198

201199
//commit to file
202200
SaveEditorVersions();
@@ -408,14 +406,15 @@ void MainFrameDerived::AddProject(const project& p){
408406
*/
409407
void MainFrameDerived::LoadEditorVersions(){
410408
//clear list control
411-
installsList->ClearAll();
409+
installsList->Clear();
412410

413411
//iterate over the search paths
414412
for (string& path : installPaths){
415413
//open the folder
416414
DIR* dir = opendir(path.c_str());
417415
struct dirent *entry = readdir(dir);
418416
//loop over the contents
417+
wxArrayString a;
419418
while (entry != NULL)
420419
{
421420
//is this a folder?
@@ -424,7 +423,7 @@ void MainFrameDerived::LoadEditorVersions(){
424423
string p = string(path + dirsep + entry->d_name + dirsep + executable);
425424
if (file_exists(p)){
426425
//add it to the list
427-
installsList->InsertItem(0,string(entry->d_name) + " - " + path);
426+
a.Add(string(entry->d_name) + " - " + path);
428427

429428
//add it to the backing datastructure
430429
editor e = {entry->d_name, path};
@@ -433,6 +432,7 @@ void MainFrameDerived::LoadEditorVersions(){
433432
}
434433
entry = readdir(dir);
435434
}
435+
installsList->InsertItems(a, 0);
436436
//free resources when finished
437437
closedir(dir);
438438
free(entry);

source/interface_derived.hpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,25 @@ class MainFrameDerived : public MainFrame{
8282
Called when an item in the installs pane is activated. Reveals that editor in the system's file browser.
8383
@param event the list event created by the wxListCtrl
8484
*/
85-
void OnRevealEditor(wxListEvent& event){
86-
editor& e = editors[event.GetIndex()];
87-
string path = e.path + dirsep + e.name;
88-
reveal_in_explorer(path);
85+
void OnRevealEditor(wxCommandEvent& event){
86+
int id = installsList->GetSelection();
87+
if (id != wxNOT_FOUND){
88+
editor& e = editors[id];
89+
string path = e.path + dirsep + e.name;
90+
reveal_in_explorer(path);
91+
}
8992
}
9093
/**
9194
Called when an item in the install search paths pane is activated. Reveals that location in the system's file browser.
9295
@param event the list event created by the wxListCtrl
9396
*/
94-
void OnRevealInstallLocation(wxListEvent& event){
95-
editor& e = editors[event.GetIndex()];
96-
string path = e.path;
97-
reveal_in_explorer(path);
97+
void OnRevealInstallLocation(wxCommandEvent& event){
98+
int id = installsPathsList->GetSelection();
99+
if (id != wxNOT_FOUND){
100+
editor& e = editors[id];
101+
string path = e.path;
102+
reveal_in_explorer(path);
103+
}
98104
}
99105
void OnOpenHub(wxCommandEvent& event){
100106
reveal_in_explorer(hubDefault);

0 commit comments

Comments
 (0)