📄 fl_demo2.cpp
字号:
#endif
font.SetStyle( wxSLANT );
font.SetWeight( wxNORMAL );
font.SetPointSize( 8 );
#ifdef __WXMSW__
font.RealizeResource();
#endif
mAboutBox.Center( wxBOTH );
mAboutBox.Show(true);
}
void MyFrame::OnChar( wxKeyEvent& event )
{
wxCommandEvent evt;
if ( event.m_keyCode == WXK_F1 )
{
OnFirst( evt );
}
else
{
if ( event.m_keyCode == WXK_F2 )
{
OnSecond( evt );
}
else
{
if ( event.m_keyCode == WXK_F3 )
{
OnThird( evt );
}
if ( event.m_keyCode == WXK_F4 && !event.AltDown() )
{
// "AI" :-)
wxMessageBox(_("There are only 3 layouts in this demo :-("));
}
else
{
if ( event.m_keyCode == WXK_TAB )
{
// USEFUL TRICK:: avoids flickering of application's frame
// when closing NN windows on exit:
Show(false);
if ( (mAutoSave && mSavedAlready) || !mAutoSave )
{
}
else
{
wxCommandEvent evt;
OnStore(evt);
}
Destroy();
}
else
{
event.Skip();
}
}
}
}
}
void MyFrame::OnSayItsOk( wxCommandEvent& WXUNUSED(event) )
{
wxMessageBox(_("It's OK :-)\n\n now click on the border around the button\n and try dragging it!") );
}
void MyFrame::OnBtnYes( wxCommandEvent& WXUNUSED(event) )
{
mAboutBox.Show(false);
}
void MyFrame::OnBtnNo( wxCommandEvent& WXUNUSED(event) )
{
mAboutBox.Show(false);
}
void MyFrame::OnBtnEsc( wxCommandEvent& WXUNUSED(event) )
{
mAboutBox.Show(false);
}
/*** helper methods ***/
void MyFrame::InitAboutBox()
{
wxPanel* pArea = new wxPanel();
pArea->Create( &mAboutBox, wxID_ANY );
new wxStaticText(pArea, wxID_ANY, _("This is wxFrameLayout contribution demo."),
wxPoint(10, 10) );
new wxStaticText(pArea, wxID_ANY, _("Aleksandras Gluchovas (c) 1998"),
wxPoint(10, 30) );
new wxStaticText(pArea, wxID_ANY, _("<mailto:alex@soften.ktu.lt>"),
wxPoint(10, 50) );
mpAboutBoxLayout = new wxFrameLayout( &mAboutBox, pArea, true );
wxFrameLayout& layout = *mpAboutBoxLayout;
cbDimInfo sizes( 90,40, // when docked horizontally
45,55, // when docked vertically
90,40, // when floated
true, 4, 4 // true - bar is fixed-size
);
wxButton* pYes = CreateButton(_("&Yes"), &mAboutBox, ID_SAY_ITSOK );
wxButton* pNo = CreateButton(_("&No"), &mAboutBox, ID_BTN_NO );
wxButton* pEsc = CreateButton(_("Cancel"), &mAboutBox, ID_BTN_ESC );
layout.AddBar( pEsc, sizes, FL_ALIGN_BOTTOM, 0, 20, _("cancel button"));
layout.AddBar( pNo, sizes, FL_ALIGN_BOTTOM, 0, 20, _("no button"));
layout.AddBar( pYes, sizes, FL_ALIGN_BOTTOM, 0, 20, _("yes button"));
layout.mBorderPen.SetColour( 192, 192, 192 );
layout.SetMargins( 15, 15, 15, 15, wxALL_PANES );
cbCommonPaneProperties props;
layout.GetPaneProperties( props, FL_ALIGN_TOP );
props.mShow3DPaneBorderOn = false;
layout.SetPaneProperties( props, wxALL_PANES );
layout.Activate();
pYes->SetDefault();
pYes->SetFocus();
}
wxTextCtrl* MyFrame::CreateTxtCtrl( const wxString& txt, wxWindow* parent )
{
return new wxTextCtrl( (parent != NULL ) ? parent : mpInternalFrm,
wxID_ANY, txt, wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE );
}
wxButton* MyFrame::CreateButton( const wxString& label,
wxWindow* pParent, long id )
{
return new wxButton( (pParent)?pParent : mpInternalFrm, id,
label, wxPoint( 0,0 ), wxSize( 0,0 ) );
}
wxTreeCtrl* MyFrame::CreateTreeCtrl( const wxString& label )
{
wxTreeCtrl* pTree = new wxTreeCtrl( mpInternalFrm, wxID_ANY );
const wxTreeItemId rootid = pTree->AddRoot(label);
if ( label.StartsWith(_T("X")) )
{
pTree->AppendItem(rootid, _("Scully"));
pTree->AppendItem(rootid, _("Mulder"));
}
else
{
pTree->AppendItem(rootid, _("Leaf1"));
pTree->AppendItem(rootid, _("Leaf2"));
}
return pTree;
}
wxChoice* MyFrame::CreateChoice( const wxString& txt )
{
wxString choice_strings[5];
choice_strings[0] = txt;
choice_strings[1] = _("Julian");
choice_strings[2] = _("Hattie");
choice_strings[3] = _("Ken");
choice_strings[4] = _("Dick");
wxChoice *choice = new wxChoice( mpInternalFrm, 301, wxDefaultPosition,
wxDefaultSize, 5, choice_strings);
choice->SetSelection(0);
return choice;
}
// helper
void MyFrame::AddSearchToolbars( wxFrameLayout& layout, wxWindow* WXUNUSED(pParent) )
{
cbDimInfo sizes2( 275,38, // when docked horizontally
45,275, // when docked vertically
80,30, // when floated
true, // the bar is fixed-size
4, // vertical gap (bar border)
4, // horizontal gap (bar border)
new cbDynToolBarDimHandler()
);
cbDimInfo sizes3( 275,55, // when docked horizontally
275,60, // when docked vertically
45,130, // when floated
true, // the bar is fixed-size
4, // vertical gap (bar border)
4, // horizontal gap (bar border)
new cbDynToolBarDimHandler()
);
cbDimInfo sizes4( 430,35, // when docked horizontally
44,375, // when docked vertically
80,100, // when floated
true, // the bar is fixed-size
4, // vertical gap (bar border)
4, // horizontal gap (bar border)
new cbDynToolBarDimHandler()
);
wxDynamicToolBar* pTBar2 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
wxChoice* pChoice = new wxChoice( pTBar2, wxID_ANY, wxDefaultPosition, wxSize( 140,25 ) );
pTBar2->AddTool( 1, pChoice );
pTBar2->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("search.bmp") );
//pTBar2->AddSeparator();
pTBar2->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp") );
pTBar2->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp") );
pTBar2->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp") );
wxDynamicToolBar* pTBar3 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
pTBar3->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("open.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) );
pTBar3->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("save.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save ")) );
pTBar3->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("saveall.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Save All ")) );
//pTBar3->AddSeparator();
pTBar3->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("cut.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Open ")) );
pTBar3->AddTool( 5, wxString(wxT(BMP_DIR)) + wxT("copy.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Copy ")) );
pTBar3->AddTool( 6, wxString(wxT(BMP_DIR)) + wxT("paste.bmp"), wxBITMAP_TYPE_BMP, wxString(_(" Paste ")) );
#ifdef __WXMSW__
pTBar3->EnableTool( 2, false );
#endif
wxDynamicToolBar* pTBar4 = new wxDynamicToolBar( mpInternalFrm, wxID_ANY );
pTBar4->AddTool( 1, wxString(wxT(BMP_DIR)) + wxT("bookmarks.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Bookmarks ")), true );
pTBar4->AddTool( 2, wxString(wxT(BMP_DIR)) + wxT("nextmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Next bookmark ")), true );
pTBar4->AddTool( 3, wxString(wxT(BMP_DIR)) + wxT("prevmark.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Prev bookmark ")), true );
//pTBar4->AddSeparator();
pTBar4->AddTool( 4, wxString(wxT(BMP_DIR)) + wxT("search.bmp"), wxBITMAP_TYPE_BMP, wxString(_("Search ")), true );
#ifdef __WXMSW__
pTBar4->EnableTool( 4, false );
#endif
layout.AddBar( pTBar2,
sizes2, FL_ALIGN_TOP,
0,
0,
wxT("Search"),
true
);
layout.AddBar( pTBar3,
sizes3, FL_ALIGN_BOTTOM,
0,
0,
wxT("Titled"),
true
);
layout.AddBar( pTBar4,
sizes4, FL_ALIGN_BOTTOM,
1,
0,
wxT("Bookmarks"),
true
);
}
wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
{
bool isNested = (pParent != mpInternalFrm);
// check if we're creating nested layout
if ( isNested )
{
layout.mBorderPen.SetColour( 128,255,128 );
// if so, than make border smaller
for( int i = 0; i != MAX_PANES; ++i )
{
cbDockPane& pane = *layout.GetPane( i );
pane.mTopMargin = 5;
pane.mBottomMargin = 5;
pane.mLeftMargin = 5;
pane.mRightMargin = 5;
}
}
int cbWidth = 200;
int cbHeight = ( isNested ) ? 50 : 150;
cbDimInfo sizes4( cbWidth,cbHeight,
cbWidth,cbHeight,
cbWidth,cbHeight, false );
cbWidth = 75;
cbHeight = 31;
cbDimInfo sizes5( cbWidth,cbHeight,
42,65,
cbWidth,cbHeight, true,
3, // vertical gap (bar border)
3 // horizontal gap (bar border)
);
// create "workplace" window in the third layout
// SEB: originally here was a wxpp (wxWorkshop) class demotrated
// wxTabbedWindow* pMiniTabArea = new wxTabbedWindow();
// pMiniTabArea->Create( pParent, wxID_ANY );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -