///////////////////////////////////////////////////////////////////////////////
// Name: auidemo.cpp
// Purpose: wxaui: wx advanced user interface - sample/test program
// Author: Benjamin I. Williams
// Modified by:
// Created: 2005-10-03
// RCS-ID: $Id: auidemo.cpp,v 1.45.2.1 2007/02/12 21:01:51 JS Exp $
// Copyright: (C) Copyright 2005, Kirix Corporation, All Rights Reserved.
// Licence: wxWindows Library Licence, Version 3.1
///////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/app.h"
#include "wx/grid.h"
#include "wx/treectrl.h"
#include "wx/spinctrl.h"
#include "wx/artprov.h"
#include "wx/clipbrd.h"
#include "wx/image.h"
#include "wx/colordlg.h"
#include "wx/wxhtml.h"
#include "wx/imaglist.h"
#include "wx/dataobj.h"
#include "wx/dcclient.h"
#include "wx/bmpbuttn.h"
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
#include "wx/msgdlg.h"
#include "wx/textdlg.h"
#include "wx/aui/aui.h"
#include "../sample.xpm"
// -- application --
class MyApp : public wxApp
{
public:
bool OnInit();
};
DECLARE_APP(MyApp)
IMPLEMENT_APP(MyApp)
class wxSizeReportCtrl;
// -- frame --
class MyFrame : public wxFrame
{
enum
{
ID_CreateTree = wxID_HIGHEST+1,
ID_CreateGrid,
ID_CreateText,
ID_CreateHTML,
ID_CreateNotebook,
ID_CreateSizeReport,
ID_GridContent,
ID_TextContent,
ID_TreeContent,
ID_HTMLContent,
ID_NotebookContent,
ID_SizeReportContent,
ID_CreatePerspective,
ID_CopyPerspectiveCode,
ID_AllowFloating,
ID_AllowActivePane,
ID_TransparentHint,
ID_VenetianBlindsHint,
ID_RectangleHint,
ID_NoHint,
ID_HintFade,
ID_NoVenetianFade,
ID_TransparentDrag,
ID_NoGradient,
ID_VerticalGradient,
ID_HorizontalGradient,
ID_Settings,
ID_NotebookNoCloseButton,
ID_NotebookCloseButton,
ID_NotebookCloseButtonAll,
ID_NotebookCloseButtonActive,
ID_NotebookAllowTabMove,
ID_NotebookAllowTabExternalMove,
ID_NotebookAllowTabSplit,
ID_NotebookWindowList,
ID_NotebookScrollButtons,
ID_NotebookTabFixedWidth,
ID_NotebookArtGloss,
ID_NotebookArtSimple,
ID_FirstPerspective = ID_CreatePerspective+1000
};
public:
MyFrame(wxWindow* parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxSUNKEN_BORDER);
~MyFrame();
wxAuiDockArt* GetDockArt();
void DoUpdate();
private:
wxTextCtrl* CreateTextCtrl(const wxString& text = wxEmptyString);
wxGrid* CreateGrid();
wxTreeCtrl* CreateTreeCtrl();
wxSizeReportCtrl* CreateSizeReportCtrl(int width = 80, int height = 80);
wxPoint GetStartPosition();
wxHtmlWindow* CreateHTMLCtrl(wxWindow* parent = NULL);
wxAuiNotebook* CreateNotebook();
wxString GetIntroText();
private:
void OnEraseBackground(wxEraseEvent& evt);
void OnSize(wxSizeEvent& evt);
void OnCreateTree(wxCommandEvent& evt);
void OnCreateGrid(wxCommandEvent& evt);
void OnCreateHTML(wxCommandEvent& evt);
void OnCreateNotebook(wxCommandEvent& evt);
void OnCreateText(wxCommandEvent& evt);
void OnCreateSizeReport(wxCommandEvent& evt);
void OnChangeContentPane(wxCommandEvent& evt);
void OnCreatePerspective(wxCommandEvent& evt);
void OnCopyPerspectiveCode(wxCommandEvent& evt);
void OnRestorePerspective(wxCommandEvent& evt);
void OnSettings(wxCommandEvent& evt);
void OnAllowNotebookDnD(wxAuiNotebookEvent& evt);
void OnNotebookPageClose(wxAuiNotebookEvent& evt);
void OnExit(wxCommandEvent& evt);
void OnAbout(wxCommandEvent& evt);
void OnGradient(wxCommandEvent& evt);
void OnManagerFlag(wxCommandEvent& evt);
void OnNotebookFlag(wxCommandEvent& evt);
void OnUpdateUI(wxUpdateUIEvent& evt);
void OnPaneClose(wxAuiManagerEvent& evt);
private:
wxAuiManager m_mgr;
wxArrayString m_perspectives;
wxMenu* m_perspectives_menu;
long m_notebook_style;
long m_notebook_theme;
DECLARE_EVENT_TABLE()
};
// -- wxSizeReportCtrl --
// (a utility control that always reports it's client size)
class wxSizeReportCtrl : public wxControl
{
public:
wxSizeReportCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
wxAuiManager* mgr = NULL)
: wxControl(parent, id, pos, size, wxNO_BORDER)
{
m_mgr = mgr;
}
private:
void OnPaint(wxPaintEvent& WXUNUSED(evt))
{
wxPaintDC dc(this);
wxSize size = GetClientSize();
wxString s;
int h, w, height;
s.Printf(wxT("Size: %d x %d"), size.x, size.y);
dc.SetFont(*wxNORMAL_FONT);
dc.GetTextExtent(s, &w, &height);
height += 3;
dc.SetBrush(*wxWHITE_BRUSH);
dc.SetPen(*wxWHITE_PEN);
dc.DrawRectangle(0, 0, size.x, size.y);
dc.SetPen(*wxLIGHT_GREY_PEN);
dc.DrawLine(0, 0, size.x, size.y);
dc.DrawLine(0, size.y, size.x, 0);
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2));
if (m_mgr)
{
wxAuiPaneInfo pi = m_mgr->GetPane(this);
s.Printf(wxT("Layer: %d"), pi.dock_layer);
dc.GetTextExtent(s, &w, &h);
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*1));
s.Printf(wxT("Dock: %d Row: %d"), pi.dock_direction, pi.dock_row);
dc.GetTextExtent(s, &w, &h);
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*2));
s.Printf(wxT("Position: %d"), pi.dock_pos);
dc.GetTextExtent(s, &w, &h);
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*3));
s.Printf(wxT("Proportion: %d"), pi.dock_proportion);
dc.GetTextExtent(s, &w, &h);
dc.DrawText(s, (size.x-w)/2, ((size.y-(height*5))/2)+(height*4));
}
}
void OnEraseBackground(wxEraseEvent& WXUNUSED(evt))
{
// intentionally empty
}
void OnSize(wxSizeEvent& WXUNUSED(evt))
{
Refresh();
}
private:
wxAuiManager* m_mgr;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(wxSizeReportCtrl, wxControl)
EVT_PAINT(wxSizeReportCtrl::OnPaint)
EVT_SIZE(wxSizeReportCtrl::OnSize)
EVT_ERASE_BACKGROUND(wxSizeReportCtrl::OnEraseBackground)
END_EVENT_TABLE()
class SettingsPanel : public wxPanel
{
enum
{
ID_PaneBorderSize = wxID_HIGHEST+1,
ID_SashSize,
ID_CaptionSize,
ID_BackgroundColor,
ID_SashColor,
ID_InactiveCaptionColor,
ID_InactiveCaptionGradientColor,
ID_InactiveCaptionTextColor,
ID_ActiveCaptionColor,
ID_ActiveCaptionGradientColor,
ID_ActiveCaptionTextColor,
ID_BorderColor,
ID_GripperColor
};
public:
SettingsPanel(wxWindow* parent, MyFrame* frame)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize),
m_frame(frame)
{
//wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL);
//vert->Add(1, 1, 1, wxEXPAND);
wxBoxSizer* s1 = new wxBoxSizer(wxHORIZONTAL);
m_border_size = new wxSpinCtrl(this,