📄 fl_demo2.cpp
字号:
wxTreeCtrl* pClassView = new wxTreeCtrl( pParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS ); pClassView->SetImageList( &mImageList ); wxTreeItemId rootId = pClassView->AddRoot( wxT("wxWidgets 2.0 classes"), 0 ); pClassView->AppendItem( rootId, _("wxWin Dynamic classes (grabbed at run-time)"), 0 ); pClassView->AppendItem( rootId, _("serializer-classes (grabbed at run-time)"), 0 ); // now create "output" window wxNotebook* pTabbedArea = new wxNotebook(pParent, wxID_ANY); // SEB: originally here was a wxpp (wxWorkshop) class used // wxPaggedWindow* pTabbedArea = new wxPaggedWindow(); // pTabbedArea->Create( pParent, wxID_ANY ); wxPanel* pSheet3 = new wxPanel(); pSheet3->Create( pTabbedArea, wxID_ANY ); pSheet3->Show(false); pTabbedArea->AddPage( CreateTxtCtrl(wxT("build"), pTabbedArea), wxT("Build")); pTabbedArea->AddPage( CreateTxtCtrl(wxT("debug"), pTabbedArea), wxT("Debug")); pTabbedArea->AddPage( pSheet3, wxT("is THIS recursive - or what !?")); pTabbedArea->AddPage( CreateTxtCtrl(wxT("profile"), pTabbedArea), wxT("Profile")); layout.AddBar( new StartButton95(pParent), sizes5, FL_ALIGN_TOP, 0, 0, wxT("Start...") ); layout.AddBar( pClassView, sizes4, FL_ALIGN_LEFT, 0, 0, wxT("Project Workplace") ); layout.AddBar( pTabbedArea, sizes4, FL_ALIGN_BOTTOM, 0, 50, wxT("Output") ); return pSheet3;}void MyFrame::DropInSomeBars( int layoutNo ){ /* create once... and forget! */ // setup dimension infos for various bar shapes int cbWidth = 90; int cbHeight = 30; if ( layoutNo == SECOND_LAYOUT ) cbHeight = 60; wxFrameLayout& layout = *mLayouts[layoutNo]; cbDimInfo sizes( cbWidth,cbHeight, // when docked horizontally cbWidth,cbHeight, // when docked vertically cbWidth,cbHeight, // when floated true // true - bar is fixed-size ); cbWidth = 120; cbDimInfo sizes1( cbWidth,cbHeight, cbWidth,cbHeight, cbWidth,cbHeight, false ); // false - bar is "flexible" cbWidth = 120; cbHeight = 40; cbDimInfo sizes3( cbWidth,cbHeight, cbWidth,cbHeight, cbWidth,cbHeight, true ); // -/- cbWidth = 200; cbHeight = 150; cbDimInfo sizes4( cbWidth,cbHeight, cbWidth,cbHeight, cbWidth,cbHeight, false ); // -/- cbWidth = 63; cbHeight = 31; cbDimInfo sizes5( cbWidth,cbHeight, cbHeight,cbWidth, cbWidth,cbHeight, true, 3, // vertical gap (bar border) 3 // horizontal gap (bar border) ); // -/- if ( layoutNo == FIRST_LAYOUT ) { // add 4 fixed-size bars (`sizes' dim-info) and one "flexible" (with `sizes1' dim-info) wxWindow* pGreenOne = new MyTestPanel(mpInternalFrm); pGreenOne->SetBackgroundColour( wxColour(128,255,128) ); layout.AddBar( pGreenOne, sizes, FL_ALIGN_TOP, 0, 50, wxT("Bar1"), true ); layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_TOP, 2, 50, wxT("Bar2"), true ); layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_BOTTOM, 2, 50, wxT("Bar3"), true ); layout.AddBar( new MyTestPanel(mpInternalFrm), sizes, FL_ALIGN_LEFT, 2, 50, wxT("Bar4"), true ); layout.AddBar( new MyTestPanel(mpInternalFrm), sizes1, wxCBAR_HIDDEN, 2, 50, wxT("Super-Bar"), true ); } else { if ( layoutNo == SECOND_LAYOUT ) { // show off various wx-controls in the second layout layout.AddBar( CreateTxtCtrl(), sizes, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area&0") ); layout.AddBar( CreateButton(wxT("OK")), sizes, FL_ALIGN_TOP, 0, 100, wxT("First Button") ); layout.AddBar( CreateTxtCtrl(), sizes1, FL_ALIGN_BOTTOM, 0, 50, wxT("First Tree") ); layout.AddBar( CreateTreeCtrl(wxT("Root")), sizes1, FL_ALIGN_LEFT, 0, 0, wxT("TreeCtrl Window") ); layout.AddBar( CreateChoice(wxT("Choice 1")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 1 (buggy)"), false, wxCBAR_HIDDEN ); layout.AddBar( CreateChoice(wxT("Choice 2")), sizes3, FL_ALIGN_TOP, 0, 0, wxT("Choice 2 (buggy)"), false, wxCBAR_HIDDEN ); layout.AddBar( CreateTreeCtrl(wxT("X-Files")), sizes1, FL_ALIGN_RIGHT, 0, 100, wxT("X-Files") ); layout.AddBar( CreateTxtCtrl(wxT("smaller1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("smaller Area1") ); layout.AddBar( CreateTxtCtrl(wxT("smaller2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("sm&ller Area2") ); } else { if ( layoutNo == THIRD_LAYOUT ) {#if defined(__WXGTK__) || defined(__WXX11__) cbCommonPaneProperties props; layout.GetPaneProperties( props ); props.mRealTimeUpdatesOn = false; // real-time OFF for gtk!!! layout.SetPaneProperties( props, wxALL_PANES );#endif layout.AddBar( CreateTxtCtrl(wxT("Tool1")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area1") ); layout.AddBar( CreateTxtCtrl(wxT("Tool2")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area2") ); layout.AddBar( CreateTxtCtrl(wxT("Tool3")), sizes3, FL_ALIGN_TOP, 0, 50, wxT("Fixed text Area3") ); layout.AddBar( CreateTxtCtrl(wxT("Tool4")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area4") ); layout.AddBar( CreateTxtCtrl(wxT("Tool5")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area5") ); layout.AddBar( CreateTxtCtrl(wxT("Tool6")), sizes3, FL_ALIGN_TOP, 1, 50, wxT("Fixed text Area6") ); layout.AddBar( CreateTxtCtrl(wxT("Tool7")), sizes3, FL_ALIGN_TOP, 2,250, wxT("Fixed text Area7") ); cbDimInfo sizes10( 175,35, // when docked horizontally 175,38, // when docked vertically 170,35, // when floated true, // the bar is not fixed-size 4, // vertical gap (bar border) 4, // horizontal gap (bar border) new cbDynToolBarDimHandler() ); wxDynamicToolBar* pToolBar = new wxDynamicToolBar(); pToolBar->Create( mpInternalFrm, wxID_ANY ); // 1001-1006 ids of command events fired by added tool-buttons pToolBar->AddTool( 1001, wxString(wxT(BMP_DIR)) + wxT("new.bmp") ); pToolBar->AddTool( 1002, wxString(wxT(BMP_DIR)) + wxT("open.bmp") ); pToolBar->AddTool( 1003, wxString(wxT(BMP_DIR)) + wxT("save.bmp") ); pToolBar->AddTool( 1004, wxString(wxT(BMP_DIR)) + wxT("cut.bmp") ); pToolBar->AddTool( 1005, wxString(wxT(BMP_DIR)) + wxT("copy.bmp") ); pToolBar->AddTool( 1006, wxString(wxT(BMP_DIR)) + wxT("paste.bmp") ); layout.AddBar( pToolBar, // bar window (can be NULL) sizes10, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) 0, // insert into 0th row (vert. position) 0, // offset from the start of row (in pixels) wxT("Real-Toolbar"), // name to refere in customization pop-ups false ); // create first "developement" layout AddSearchToolbars( layout, mpInternalFrm); wxWindow* pSheet3 = CreateDevLayout( layout, mpInternalFrm); // create another ***secreat developement*** layout inside // the third sheet of the outter one's output bar mpNestedLayout = new wxFrameLayout( pSheet3, CreateTxtCtrl(wxT("\"Mobils in Mobile\" --C.Nemo"),pSheet3), false ); CreateDevLayout( *mpNestedLayout, pSheet3 ); mpNestedLayout->Activate(); } } }}void MyFrame::CreateLayout( int layoutNo ){ wxFrameLayout* pLayout = new wxFrameLayout( mpInternalFrm, mpClntWindow, false ); if ( layoutNo == THIRD_LAYOUT ) { pLayout->PushDefaultPlugins(); pLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars#if defined(__WXGTK__) || defined(__WXX11__) pLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );#endif pLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) ); } mLayouts[layoutNo] = pLayout; DropInSomeBars( layoutNo );}void MyFrame::RemoveLayout( int layoutNo ){ wxFrameLayout* pLayout = mLayouts[layoutNo]; if ( !pLayout ) return; pLayout->HideBarWindows(); // destroy nested layout first if ( layoutNo == THIRD_LAYOUT ) { if ( mpNestedLayout ) delete mpNestedLayout; mpNestedLayout = NULL; } // NOTE:: bar windows are NOT destroyed automatically by frame-layout pLayout->DestroyBarWindows(); delete pLayout; mLayouts[layoutNo] = NULL; Refresh();}void MyFrame::SyncMenuBarItems(){ for( int i = 0; i != MAX_LAYOUTS; ++i ) { GetMenuBar()->Check( ID_FIRST+i, mActiveLayoutNo == FIRST_LAYOUT+i ); } GetMenuBar()->Check( ID_AUTOSAVE, mAutoSave );}void MyFrame::ActivateLayout( int layoutNo ){ if ( layoutNo == mActiveLayoutNo ) return; if ( mLayouts[mActiveLayoutNo] ) mLayouts[mActiveLayoutNo]->Deactivate(); mActiveLayoutNo = layoutNo; if ( mLayouts[mActiveLayoutNo] ) mLayouts[mActiveLayoutNo]->Activate(); else Refresh(); SyncMenuBarItems();}/***** Implementation for class StartButton95 (just for fun) *****/IMPLEMENT_DYNAMIC_CLASS( StartButton95, wxPanel )BEGIN_EVENT_TABLE( StartButton95, wxPanel ) EVT_LEFT_DOWN( StartButton95::OnMouseDown ) EVT_LEFT_UP ( StartButton95::OnMouseUp ) EVT_PAINT ( StartButton95::OnPaint )END_EVENT_TABLE()void StartButton95::OnMouseDown( wxMouseEvent& WXUNUSED(event) ){ m_bPressed = true; Refresh(); CaptureMouse();}void StartButton95::OnMouseUp( wxMouseEvent& WXUNUSED(event) ){ // "this is not a bug" SetCursor( wxCURSOR_WAIT ); GetParent()->SetCursor( wxCURSOR_WAIT ); ::wxSetCursor( wxCURSOR_WAIT ); wxSleep(1); for( int i = 1; i != 6; ++i ) { m_bPressed = (i % 2) != 0; Refresh(); wxSleep(1); } GetParent()->Close(); //*((char*)(i)-3) = 'X'; // Aleks what's the meaning of this???}void StartButton95::OnPaint( wxPaintEvent& WXUNUSED(event) ){ wxBitmap* pBmp; if ( m_bPressed ) { if ( !m_PBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp") ) ) m_PBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_pr.bmp"), wxBITMAP_TYPE_BMP ); pBmp = &m_PBmp; } else { if ( !m_DBmp.Ok() && wxFileExists( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp") ) ) m_DBmp.LoadFile( wxString(wxT(BMP_DIR)) + wxT("start95_dp.bmp"), wxBITMAP_TYPE_BMP ); pBmp = &m_DBmp; } if (!pBmp) return; wxMemoryDC mdc; wxPaintDC dc(this); mdc.SelectObject( *pBmp ); dc.Blit( 0,0, pBmp->GetWidth(), pBmp->GetHeight(), &mdc, 0,0, wxCOPY ); mdc.SelectObject( wxNullBitmap );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -