⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 extended.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////// Name:        expended.cpp// Purpose:     Layout/foldpanelbar sample// Author:      Jorgen Bodde// Modified by:// Created:     24/07/2004// Copyright:   (c) Jorgen Bodde based upon FoldPanelBarTest (c) Julian Smart// Licence:     wxWindows license/////////////////////////////////////////////////////////////////////////////// For compilers that support precompilation, includes "wx/wx.h".#include "wx/wxprec.h"#ifdef __BORLANDC__#pragma hdrstop#endif#ifndef WX_PRECOMP#include "wx/wx.h"#include "wx/mdi.h"#endif#include "wx/toolbar.h"#include "wx/laywin.h"#include "wx/spinctrl.h"#include "wx/slider.h"#include "sample.xpm"#include "extended.h"MyFrame *frame = NULL;wxList my_children;IMPLEMENT_APP(MyApp)// For drawing lines in a canvaslong xpos = -1;long ypos = -1;int winNumber = 1;// Initialise this in OnInit, not staticallybool MyApp::OnInit(void){    // Create the main frame window    frame = new MyFrame(NULL, wxID_ANY, _T("FoldPanelBar Extended Demo"), wxDefaultPosition, wxSize(500, 600),                        wxDEFAULT_FRAME_STYLE |                        wxNO_FULL_REPAINT_ON_RESIZE |                        wxHSCROLL | wxVSCROLL);    frame->SetIcon(wxIcon(sample_xpm));    // Associate the menu bar with the frame    frame->SetMenuBar(CreateMenuBar(false));    frame->CreateStatusBar();    frame->Show(true);    SetTopWindow(frame);    return true;}BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)    EVT_MENU(FPBTEST_ABOUT, MyFrame::OnAbout)    EVT_MENU(FPBTEST_NEW_WINDOW, MyFrame::OnNewWindow)    EVT_SIZE(MyFrame::OnSize)    EVT_MENU(FPBTEST_QUIT, MyFrame::OnQuit)    EVT_MENU(FPBTEST_TOGGLE_WINDOW, MyFrame::OnToggleWindow)    EVT_SASH_DRAGGED_RANGE(ID_WINDOW_TOP, ID_WINDOW_BOTTOM, MyFrame::OnFoldPanelBarDrag)    EVT_MENU(FPB_BOTTOM_STICK, MyFrame::OnCreateBottomStyle)    EVT_MENU(FPB_SINGLE_FOLD, MyFrame::OnCreateNormalStyle)    EVT_BUTTON(ID_COLLAPSEME, MyFrame::OnCollapseMe)    EVT_BUTTON(ID_APPLYTOALL, MyFrame::OnExpandMe)    EVT_SCROLL(MyFrame::OnSlideColour)    EVT_RADIOBUTTON(ID_USE_HGRADIENT, MyFrame::OnStyleChange)    EVT_RADIOBUTTON(ID_USE_VGRADIENT, MyFrame::OnStyleChange)    EVT_RADIOBUTTON(ID_USE_SINGLE, MyFrame::OnStyleChange)    EVT_RADIOBUTTON(ID_USE_RECTANGLE, MyFrame::OnStyleChange)    EVT_RADIOBUTTON(ID_USE_FILLED_RECTANGLE, MyFrame::OnStyleChange)END_EVENT_TABLE()// Define my frame constructorMyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,    const long style)  : wxMDIParentFrame(parent, id, title, pos, size, style)  , m_flags(0){    m_leftWindow1 = new wxSashLayoutWindow(this, ID_WINDOW_LEFT1,                                wxDefaultPosition, wxSize(200, 30),                                wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN);    m_leftWindow1->SetDefaultSize(wxSize(160, 1000));    m_leftWindow1->SetOrientation(wxLAYOUT_VERTICAL);    m_leftWindow1->SetAlignment(wxLAYOUT_LEFT);    m_leftWindow1->SetSashVisible(wxSASH_RIGHT, true);    m_leftWindow1->SetExtraBorderSize(0);    m_pnl = NULL;    ReCreateFoldPanel(0);}void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)){    Close(true);}void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)){    (void)wxMessageBox(_T("wxWidgets 2.0 FoldPanelBar Demo\nAuthor: Julian Smart (c) 1998"), _T("About FoldPanelBar Demo"));}void MyFrame::OnToggleWindow(wxCommandEvent& WXUNUSED(event)){    m_leftWindow1->Show(!m_leftWindow1->IsShown());#if wxUSE_MDI_ARCHITECTURE    wxLayoutAlgorithm layout;    layout.LayoutMDIFrame(this);#endif // wxUSE_MDI_ARCHITECTURE}void MyFrame::OnFoldPanelBarDrag(wxSashEvent& event){    if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)        return;    if(event.GetId() == ID_WINDOW_LEFT1)        m_leftWindow1->SetDefaultSize(wxSize(event.GetDragRect().width, 1000));#if wxUSE_MDI_ARCHITECTURE    wxLayoutAlgorithm layout;    layout.LayoutMDIFrame(this);#endif // wxUSE_MDI_ARCHITECTURE    // Leaves bits of itself behind sometimes    GetClientWindow()->Refresh();}void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)){    // Make another frame, containing a canvas    MyChild *subframe = new MyChild(frame, _T("Canvas Frame"),                                    wxPoint(10, 10), wxSize(300, 300),                                    wxDEFAULT_FRAME_STYLE |                                    wxNO_FULL_REPAINT_ON_RESIZE);    subframe->SetTitle(wxString::Format(_T("Canvas Frame %d"), winNumber));    winNumber ++;    // Give it a status line    subframe->CreateStatusBar();    // Associate the menu bar with the frame    subframe->SetMenuBar(CreateMenuBar(true));    int width, height;    subframe->GetClientSize(&width, &height);    MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));    canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));    subframe->canvas = canvas;    // Give it scrollbars    canvas->SetScrollbars(20, 20, 50, 50);    subframe->Show(true);}void MyFrame::ReCreateFoldPanel(int fpb_flags){    // delete earlier panel    m_leftWindow1->DestroyChildren();    // recreate the foldpanelbar    m_pnl = new wxFoldPanelBar(m_leftWindow1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, fpb_flags);    wxFoldPanel item = m_pnl->AddFoldPanel(_T("Caption colours"), false);    m_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Adjust the first colour")),                              wxFPB_ALIGN_WIDTH, 5, 20);    // RED color spin control    m_rslider1 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);    m_pnl->AddFoldPanelWindow(item, m_rslider1, wxFPB_ALIGN_WIDTH,                              2, 20);    // GREEN color spin control    m_gslider1 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);    m_pnl->AddFoldPanelWindow(item, m_gslider1, wxFPB_ALIGN_WIDTH,                              0, 20);    // BLUE color spin control    m_bslider1 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);    m_pnl->AddFoldPanelWindow(item, m_bslider1, wxFPB_ALIGN_WIDTH,                              0, 20);    m_pnl->AddFoldPanelSeperator(item);    m_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Adjust the second colour")),                              wxFPB_ALIGN_WIDTH, 5, 20);    // RED color spin control    m_rslider2 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);    m_pnl->AddFoldPanelWindow(item, m_rslider2, wxFPB_ALIGN_WIDTH,                              2, 20);    // GREEN color spin control    m_gslider2 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);    m_pnl->AddFoldPanelWindow(item, m_gslider2, wxFPB_ALIGN_WIDTH,                              0, 20);    // BLUE color spin control    m_bslider2 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);    m_pnl->AddFoldPanelWindow(item, m_bslider2, wxFPB_ALIGN_WIDTH,                              0, 20);    m_pnl->AddFoldPanelSeperator(item);    m_btn = new wxButton(item.GetParent(), ID_APPLYTOALL, _T("Apply to all"));    m_pnl->AddFoldPanelWindow(item, m_btn);    // read back current gradients and set the sliders    // for the colour which is now taken as default    wxCaptionBarStyle style = m_pnl->GetCaptionStyle(item);    wxColour col = style.GetFirstColour();    m_rslider1->SetValue(col.Red());    m_gslider1->SetValue(col.Green());    m_bslider1->SetValue(col.Blue());    col = style.GetSecondColour();    m_rslider2->SetValue(col.Red());    m_gslider2->SetValue(col.Green());    m_bslider2->SetValue(col.Blue());    // put down some caption styles from which the user can    // select to show how the current or all caption bars will look like    item = m_pnl->AddFoldPanel(_T("Caption style"), false);    wxRadioButton *currStyle =  new wxRadioButton(item.GetParent(), ID_USE_VGRADIENT, _T("&Vertical gradient"));    m_pnl->AddFoldPanelWindow(item, currStyle,  wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);    currStyle->SetValue(true);    m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_HGRADIENT, _T("&Horizontal gradient")),                              wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);    m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_SINGLE, _T("&Single colour")),                              wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);    m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_RECTANGLE, _T("&Rectangle box")),                              wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);    m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_FILLED_RECTANGLE, _T("&Filled rectangle box")),                              wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);    m_pnl->AddFoldPanelSeperator(item);    m_single = new wxCheckBox(item.GetParent(), wxID_ANY, _T("&Only this caption"));    m_pnl->AddFoldPanelWindow(item, m_single, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);    // one more panel to finish it    wxCaptionBarStyle cs;    cs.SetCaptionStyle(wxCAPTIONBAR_RECTANGLE);    item = m_pnl->AddFoldPanel(_T("Misc stuff"), true, cs);    m_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse All")));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -