📄 extended.cpp
字号:
m_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter some comments")),
wxFPB_ALIGN_WIDTH, 5, 20);
m_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comments")),
wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
m_leftWindow1->SizeWindows();
}
void MyFrame::OnCreateBottomStyle(wxCommandEvent& event)
{
// recreate with style collapse to bottom, which means
// all panels that are collapsed are placed at the bottom,
// or normal
if(event.IsChecked())
m_flags |= wxFPB_COLLAPSE_TO_BOTTOM;
else
m_flags &= ~wxFPB_COLLAPSE_TO_BOTTOM;
ReCreateFoldPanel(m_flags);
}
void MyFrame::OnCreateNormalStyle(wxCommandEvent& event)
{
// receate with style where only one panel at the time is
// allowed to be opened
// TODO: Not yet implemented!
if(event.IsChecked())
m_flags |= wxFPB_SINGLE_FOLD;
else
m_flags &= ~wxFPB_SINGLE_FOLD;
ReCreateFoldPanel(m_flags);
}
void MyFrame::OnCollapseMe(wxCommandEvent &WXUNUSED(event))
{
wxFoldPanel item(0);
for(size_t i = 0; i < m_pnl->GetCount(); i++)
{
item = m_pnl->Item(i);
m_pnl->Collapse(item);
}
}
void MyFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event))
{
wxColour col1((unsigned char)m_rslider1->GetValue(),
(unsigned char)m_gslider1->GetValue(),
(unsigned char)m_bslider1->GetValue()),
col2((unsigned char)m_rslider2->GetValue(),
(unsigned char)m_gslider2->GetValue(),
(unsigned char)m_bslider2->GetValue());
wxCaptionBarStyle style;
style.SetFirstColour(col1);
style.SetSecondColour(col2);
m_pnl->ApplyCaptionStyleAll(style);
}
wxMenuBar *CreateMenuBar(bool with_window)
{
// Make a menubar
wxMenu *file_menu = new wxMenu;
file_menu->Append(FPBTEST_NEW_WINDOW, _T("&New window"));
if(with_window)
file_menu->Append(FPBTEST_CHILD_QUIT, _T("&Close child"));
file_menu->AppendSeparator();
file_menu->Append(FPBTEST_QUIT, _T("&Exit"));
wxMenu *option_menu = 0;
if(with_window)
{
// Dummy option
option_menu = new wxMenu;
option_menu->Append(FPBTEST_REFRESH, _T("&Refresh picture"));
}
// make fold panel menu
wxMenu *fpb_menu = new wxMenu;
fpb_menu->AppendCheckItem(FPB_BOTTOM_STICK, _T("Create with &wxFPB_COLLAPSE_TO_BOTTOM"));
//fpb_menu->AppendCheckItem(FPB_SINGLE_FOLD, _T("Create with &wxFPB_SINGLE_FOLD"));
fpb_menu->AppendSeparator();
fpb_menu->Append(FPBTEST_TOGGLE_WINDOW, _T("&Toggle FoldPanelBar"));
wxMenu *help_menu = new wxMenu;
help_menu->Append(FPBTEST_ABOUT, _T("&About"));
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _T("&File"));
menu_bar->Append(fpb_menu, _T("&FoldPanel"));
if(option_menu)
menu_bar->Append(option_menu, _T("&Options"));
menu_bar->Append(help_menu, _T("&Help"));
return menu_bar;
}
void MyFrame::OnSlideColour(wxScrollEvent &WXUNUSED(event))
{
wxColour col1((unsigned char)m_rslider1->GetValue(),
(unsigned char)m_gslider1->GetValue(),
(unsigned char)m_bslider1->GetValue()),
col2((unsigned char)m_rslider2->GetValue(),
(unsigned char)m_gslider2->GetValue(),
(unsigned char)m_bslider2->GetValue());
//m_btn->SetBackgroundColour(col);
wxCaptionBarStyle style;
style.SetFirstColour(col1);
style.SetSecondColour(col2);
wxFoldPanel item = m_pnl->Item(0);
m_pnl->ApplyCaptionStyle(item, style);
}
void MyFrame::OnStyleChange(wxCommandEvent &event)
{
wxCaptionBarStyle style;
switch(event.GetId())
{
case ID_USE_HGRADIENT:
style.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_H);
break;
case ID_USE_VGRADIENT:
style.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_V);
break;
case ID_USE_SINGLE:
style.SetCaptionStyle(wxCAPTIONBAR_SINGLE);
break;
case ID_USE_RECTANGLE:
style.SetCaptionStyle(wxCAPTIONBAR_RECTANGLE);
break;
case ID_USE_FILLED_RECTANGLE:
style.SetCaptionStyle(wxCAPTIONBAR_FILLED_RECTANGLE);
break;
default:
break;
}
if(m_single->GetValue())
{
wxFoldPanel item = m_pnl->Item(1);
m_pnl->ApplyCaptionStyle(item, style);
}
else
{
m_pnl->ApplyCaptionStyleAll(style);
}
}
/* ----------------------------------------------------------------------------------------------- */
BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
EVT_MOUSE_EVENTS(MyCanvas::OnEvent)
END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size)
:wxScrolledWindow(parent, wxID_ANY, pos, size,
wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE)
{
SetBackgroundColour(* wxWHITE);
}
// Define the repainting behaviour
void MyCanvas::OnDraw(wxDC& dc)
{
dc.SetFont(*wxSWISS_FONT);
dc.SetPen(*wxGREEN_PEN);
dc.DrawLine(0, 0, 200, 200);
dc.DrawLine(200, 0, 0, 200);
dc.SetBrush(*wxCYAN_BRUSH);
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(100, 100, 100, 50);
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
dc.DrawEllipse(250, 250, 100, 50);
#if wxUSE_SPLINES
dc.DrawSpline(50, 200, 50, 100, 200, 10);
#endif // wxUSE_SPLINES
dc.DrawLine(50, 230, 200, 230);
dc.DrawText(_T("This is a test string"), 50, 230);
wxPoint points[3];
points[0].x = 200; points[0].y = 300;
points[1].x = 100; points[1].y = 400;
points[2].x = 300; points[2].y = 400;
dc.DrawPolygon(3, points);
}
// This implements a tiny doodling program! Drag the mouse using
// the left button.
void MyCanvas::OnEvent(wxMouseEvent& event)
{
wxClientDC dc(this);
PrepareDC(dc);
wxPoint pt(event.GetLogicalPosition(dc));
if (xpos > -1 && ypos > -1 && event.Dragging())
{
dc.SetPen(*wxBLACK_PEN);
dc.DrawLine(xpos, ypos, pt.x, pt.y);
}
xpos = pt.x;
ypos = pt.y;
}
void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event))
{
#if wxUSE_MDI_ARCHITECTURE
wxLayoutAlgorithm layout;
layout.LayoutMDIFrame(this);
#endif // wxUSE_MDI_ARCHITECTURE
}
// Note that FPBTEST_NEW_WINDOW and FPBTEST_ABOUT commands get passed
// to the parent window for processing, so no need to
// duplicate event handlers here.
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
EVT_MENU(FPBTEST_CHILD_QUIT, MyChild::OnQuit)
END_EVENT_TABLE()
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title,
const wxPoint& pos, const wxSize& size,
const long style)
:wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
{
canvas = NULL;
my_children.Append(this);
}
MyChild::~MyChild(void)
{
my_children.DeleteObject(this);
}
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}
void MyChild::OnActivate(wxActivateEvent& event)
{
if (event.GetActive() && canvas)
canvas->SetFocus();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -