X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4c6819972f9536b2508dd21100eb0c09ed8350a9..f57fe24c6389876d7ddf02aa7a09f3b48a6956de:/user/wxFile/wxFile.cpp?ds=sidebyside diff --git a/user/wxFile/wxFile.cpp b/user/wxFile/wxFile.cpp index d4030d7189..5c93b977df 100644 --- a/user/wxFile/wxFile.cpp +++ b/user/wxFile/wxFile.cpp @@ -52,51 +52,43 @@ IMPLEMENT_APP(MyApp) // MyFrame //----------------------------------------------------------------------------- -const ID_FILECTRL = 1000; -const ID_DIRCTRL = 1001; -const ID_TOOLBAR = 1002; +const int ID_FILECTRL = 1000; +const int ID_DIRCTRL = 1001; +const int ID_TOOLBAR = 1002; -const ID_QUIT = 100; -const ID_ABOUT = 101; +const int ID_QUIT = 100; +const int ID_ABOUT = 101; -const ID_LIST = 200; -const ID_REPORT = 201; -const ID_ICON = 202; +const int ID_LIST = 200; +const int ID_REPORT = 201; +const int ID_ICON = 202; -const ID_SINGLE = 203; -const ID_TREE = 204; -const ID_COMMANDER = 205; +const int ID_SINGLE = 203; +const int ID_TREE = 204; +const int ID_COMMANDER = 205; -const ID_HOME = 400; -const ID_PARENT = 401; -const ID_MOUNT = 402; -const ID_SEARCH = 403; +const int ID_HOME = 400; +const int ID_PARENT = 401; +const int ID_MOUNT = 402; +const int ID_SEARCH = 403; -const ID_DELETE = 501; -const ID_MD = 502; +const int ID_DELETE = 501; +const int ID_MD = 502; IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) BEGIN_EVENT_TABLE(MyFrame,wxFrame) - EVT_SIZE (MyFrame::OnSize) EVT_MENU (ID_ABOUT, MyFrame::OnAbout) - EVT_TOOL (ID_ABOUT, MyFrame::OnAbout) EVT_MENU (ID_QUIT, MyFrame::OnCommand) - EVT_TOOL (ID_QUIT, MyFrame::OnCommand) EVT_MENU (ID_HOME, MyFrame::OnCommand) - EVT_TOOL (ID_HOME, MyFrame::OnCommand) EVT_MENU (ID_PARENT, MyFrame::OnCommand) - EVT_TOOL (ID_PARENT, MyFrame::OnCommand) EVT_MENU (ID_LIST, MyFrame::OnView) EVT_MENU (ID_REPORT, MyFrame::OnView) EVT_MENU (ID_ICON, MyFrame::OnView) - EVT_TOOL (ID_LIST, MyFrame::OnView) - EVT_TOOL (ID_REPORT, MyFrame::OnView) - EVT_TOOL (ID_ICON, MyFrame::OnView) - EVT_TOOL (ID_TREE, MyFrame::OnView) - EVT_TOOL (ID_SINGLE, MyFrame::OnView) - EVT_TOOL (ID_COMMANDER, MyFrame::OnView) + EVT_MENU (ID_TREE, MyFrame::OnView) + EVT_MENU (ID_SINGLE, MyFrame::OnView) + EVT_MENU (ID_COMMANDER, MyFrame::OnView) EVT_LIST_KEY_DOWN (ID_FILECTRL, MyFrame::OnListKeyDown) EVT_LIST_DELETE_ITEM (ID_FILECTRL, MyFrame::OnListDeleteItem) EVT_LIST_END_LABEL_EDIT (ID_FILECTRL, MyFrame::OnListEndLabelEdit) @@ -106,7 +98,7 @@ BEGIN_EVENT_TABLE(MyFrame,wxFrame) END_EVENT_TABLE() MyFrame::MyFrame(void) : - wxFrame( NULL, -1, "wxFile", wxPoint(20,20), wxSize(470,360) ) + wxFrame( (wxFrame *) NULL, -1, (char *) "wxFile", wxPoint(20,20), wxSize(470,360) ) { wxMenu *file_menu = new wxMenu( "Menu 1" ); file_menu->Append( ID_ABOUT, "About.."); @@ -129,68 +121,43 @@ MyFrame::MyFrame(void) : SetStatusText( "Welcome", 0 ); SetStatusText( "wxFile v0.2 by Robert Roebling.", 1 ); - m_tb = new wxToolBarGTK( this, ID_TOOLBAR, wxPoint(2,60), wxSize(300-4,26) ); + wxToolBar *m_tb = CreateToolBar(); m_tb->SetMargins( 2, 2 ); - wxBitmap *bm; m_tb->AddSeparator(); - - bm = new wxBitmap( exit_xpm ); - m_tb->AddTool( ID_QUIT, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Exit wxFile" ); + m_tb->AddTool( ID_QUIT, wxBitmap( exit_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Exit wxFile" ); m_tb->AddSeparator(); - - bm = new wxBitmap( prev_xpm ); - m_tb->AddTool( ID_PARENT, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Go to parent directory" ); - bm = new wxBitmap( home_xpm ); - m_tb->AddTool( ID_HOME, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Go to home directory" ); + m_tb->AddTool( ID_PARENT, wxBitmap( prev_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Go to parent directory" ); + m_tb->AddTool( ID_HOME, wxBitmap( home_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Go to home directory" ); m_tb->AddSeparator(); - - bm = new wxBitmap( delete_xpm ); - m_tb->AddTool( ID_DELETE, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Delete file" ); + m_tb->AddTool( ID_DELETE, wxBitmap( delete_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Delete file" ); m_tb->AddSeparator(); - - bm = new wxBitmap( fileopen_xpm ); - m_tb->AddTool( ID_MD, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Create directory" ); + m_tb->AddTool( ID_MD, wxBitmap( fileopen_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Create directory" ); m_tb->AddSeparator(); - - bm = new wxBitmap( listview_xpm ); - m_tb->AddTool( ID_LIST, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "List view" ); - bm = new wxBitmap( reportview_xpm ); - m_tb->AddTool( ID_REPORT, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Report view" ); - bm = new wxBitmap( iconview_xpm ); - m_tb->AddTool( ID_ICON, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Icon view" ); + m_tb->AddTool( ID_LIST, wxBitmap( listview_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "List view" ); + m_tb->AddTool( ID_REPORT, wxBitmap( reportview_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Report view" ); + m_tb->AddTool( ID_ICON, wxBitmap( iconview_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Icon view" ); m_tb->AddSeparator(); - - bm = new wxBitmap( treeview_xpm ); - m_tb->AddTool( ID_TREE, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Tree view" ); - bm = new wxBitmap( commanderview_xpm ); - m_tb->AddTool( ID_COMMANDER, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Commander view" ); - bm = new wxBitmap( singleview_xpm ); - m_tb->AddTool( ID_SINGLE, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Single view" ); + m_tb->AddTool( ID_TREE, wxBitmap( treeview_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Tree view" ); + m_tb->AddTool( ID_COMMANDER, wxBitmap( commanderview_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Commander view" ); + m_tb->AddTool( ID_SINGLE, wxBitmap( singleview_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Single view" ); m_tb->AddSeparator(); - - bm = new wxBitmap( search_xpm ); - m_tb->AddTool( ID_MOUNT, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Mount devices" ); + m_tb->AddTool( ID_MOUNT, wxBitmap( search_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Mount devices" ); m_tb->AddSeparator(); - - bm = new wxBitmap( save_xpm ); - m_tb->AddTool( ID_SEARCH, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "Find file(s)" ); + m_tb->AddTool( ID_SEARCH, wxBitmap( save_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "Find file(s)" ); m_tb->AddSeparator(); - - bm = new wxBitmap( help_xpm ); - m_tb->AddTool( ID_ABOUT, *bm, wxNullBitmap, FALSE, -1, -1, NULL, "About wxFile" ); + m_tb->AddTool( ID_ABOUT, wxBitmap( help_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "About wxFile" ); - m_tb->Layout(); + m_tb->Realize(); m_splitter = new wxSplitterWindow( this, -1, wxPoint(0,0), wxSize(400,300), wxSP_3D ); - m_leftFile = NULL; + m_leftFile = (wxFileCtrl *) NULL; m_dir = new wxDirCtrl( m_splitter, ID_DIRCTRL, "/", wxPoint(10,45), wxSize(200,330) ); - wxString homepath( "/home" ); - char buf[300]; - wxGetHomeDir( buf ); - homepath = buf; + wxString homepath; + wxGetHomeDir( &homepath ); + m_rightFile = new wxFileCtrl( m_splitter, ID_FILECTRL, homepath, wxPoint(220,5), wxSize(200,330) ); m_leftFile = new wxFileCtrl( m_splitter, ID_FILECTRL, homepath, wxPoint(0,5), wxSize(200,330) ); @@ -199,26 +166,16 @@ MyFrame::MyFrame(void) : m_leftFile->m_lastFocus = m_rightFile; int x = 0; - GetClientSize( &x, NULL ); + GetClientSize( &x, (int *) NULL ); m_splitter->SplitVertically( m_dir, m_rightFile, x / 3 ); m_splitter->SetMinimumPaneSize( 10 ); }; -void MyFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - int x = 0; - int y = 0; - GetClientSize( &x, &y ); - - m_tb->SetSize( 1, 0, x-2, 30 ); - m_splitter->SetSize( 0, 31, x, y-31 ); -}; - void MyFrame::OnView( wxCommandEvent &event ) { int x = 0; - GetClientSize( &x, NULL ); + GetClientSize( &x, (int *) NULL ); switch (event.GetId()) { case ID_LIST: @@ -334,6 +291,8 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) (void) new wxButton( &dialog, wxID_OK, "Return", wxPoint(w/2-40,h-50), wxSize(80,30) ); + dialog.Fit(); + dialog.ShowModal(); }; @@ -354,8 +313,11 @@ void MyFrame::OnListEndLabelEdit( wxListEvent &event ) void MyFrame::OnListDrag( wxListEvent &event ) { - printf( "OnDrag.\n" ); - return; + wxFileDataObject data; + data.AddFile( "/home/karl/test.txt" ); + + wxDropSource drag( data, m_leftFile->m_lastFocus ); + drag.DoDragDrop(); }; void MyFrame::OnTreeSelected( wxTreeEvent &event )