From f857e441bf68aa9c7585aefd26b64f0728387062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?W=C5=82odzimierz=20Skiba?= Date: Tue, 3 Aug 2004 14:39:09 +0000 Subject: [PATCH] Full headers, Unicode markup, whitespaces, wxID_ANY, wxDefaultCoord conventions applied with some warning fixes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- .../foldbar/foldpanelbar/foldpanelbartest.cpp | 103 ++-- .../foldbar/foldpanelbar/foldpanelbartest.rc | 8 +- .../foldbar/foldpanelbar/foldtestpanel.cpp | 46 +- .../foldbar/foldpanelbar/foldtestpanel.h | 20 +- .../foldbar/foldpanelbar/layouttest.cpp | 28 +- .../samples/foldbar/foldpanelbar/layouttest.h | 14 +- contrib/samples/foldbar/foldpanelbar/test.cpp | 46 +- contrib/samples/foldbar/foldpanelbar/test.h | 14 +- contrib/src/foldbar/captionbar.cpp | 470 +++++++++--------- contrib/src/foldbar/foldpanelbar.cpp | 426 ++++++++-------- contrib/src/foldbar/foldpanelitem.cpp | 240 ++++----- 11 files changed, 713 insertions(+), 702 deletions(-) diff --git a/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp b/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp index 69a3bed261..67f061286c 100644 --- a/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp +++ b/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.cpp @@ -1,8 +1,11 @@ - ///////////////////////////////////////////////////////////////////////////// -// Name: FoldPanelBarTest.cpp -// Purpose: FoldPanelBarTest Test application -// Created: 06/18/04 +// Name: foldpanelbartest.cpp +// Purpose: +// Author: Jorgen Bodde +// Modified by: +// Created: 18/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -18,8 +21,8 @@ enum { - ID_COLLAPSEME = 10000, - ID_EXPANDME + ID_COLLAPSEME = 10000, + ID_EXPANDME }; #include "wx/foldbar/foldpanelbar.h" @@ -58,14 +61,14 @@ private: void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); - // extra handlers for the bar, to show how it works + // extra handlers for the bar, to show how it works - void OnCollapseMe(wxCommandEvent &event); - void OnExpandMe(wxCommandEvent &event); + void OnCollapseMe(wxCommandEvent &event); + void OnExpandMe(wxCommandEvent &event); private: - wxMenuBar *CreateMenuBar(); - wxFoldPanelBar *_pnl; + wxMenuBar *CreateMenuBar(); + wxFoldPanelBar *_pnl; private: DECLARE_EVENT_TABLE() @@ -89,8 +92,8 @@ enum BEGIN_EVENT_TABLE(MyAppFrame, wxFrame) EVT_MENU(FoldPanelBarTest_Quit, MyAppFrame::OnQuit) EVT_MENU(FoldPanelBarTest_About, MyAppFrame::OnAbout) - EVT_BUTTON(ID_COLLAPSEME, MyAppFrame::OnCollapseMe) - EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe) + EVT_BUTTON(ID_COLLAPSEME, MyAppFrame::OnCollapseMe) + EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe) END_EVENT_TABLE() IMPLEMENT_APP(MyApp) @@ -108,10 +111,10 @@ bool MyApp::OnInit() MyAppFrame *frame = new MyAppFrame(_T("FoldPanelBarTest wxWindows Test Application"), wxPoint(50, 50), wxSize(200, 500)); - SetTopWindow(frame); + SetTopWindow(frame); - frame->Show(TRUE); - return TRUE; + frame->Show(true); + return true; } // ---------------------------------------------------------------------------- @@ -119,7 +122,7 @@ bool MyApp::OnInit() // ---------------------------------------------------------------------------- MyAppFrame::MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) - : wxFrame(NULL, -1, title, pos, size, style) + : wxFrame(NULL, wxID_ANY, title, pos, size, style) { SetIcon(wxICON(mondrian)); @@ -128,53 +131,51 @@ MyAppFrame::MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& CreateStatusBar(2); SetStatusText(_T("Welcome to wxWindows!")); - _pnl = new wxFoldPanelBar(this, -1, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM); - - wxFoldPanel item = _pnl->AddFoldPanel("Test me", false); - _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, "Collapse Me")); + _pnl = new wxFoldPanelBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM); - item = _pnl->AddFoldPanel("Test me too!", true); - _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_EXPANDME, "Expand first one")); - _pnl->AddFoldPanelSeperator(item); - _pnl->AddFoldPanelWindow(item, new FoldTestPanel(item.GetParent(), -1)); + wxFoldPanel item = _pnl->AddFoldPanel(_T("Test me"), false); + _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse Me"))); - _pnl->AddFoldPanelSeperator(item); + item = _pnl->AddFoldPanel(_T("Test me too!"), true); + _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_EXPANDME, _T("Expand first one"))); + _pnl->AddFoldPanelSeperator(item); + _pnl->AddFoldPanelWindow(item, new FoldTestPanel(item.GetParent(), wxID_ANY)); - _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), -1, "Comment"), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20); + _pnl->AddFoldPanelSeperator(item); - item = _pnl->AddFoldPanel("Some opinions ...", false); - _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), -1, "I like this")); - _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), -1, "And also this")); - _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), -1, "And gimme this too")); + _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20); - _pnl->AddFoldPanelSeperator(item); - - _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), -1, "Check this too if you like")); - _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), -1, "What about this")); + item = _pnl->AddFoldPanel(_T("Some opinions ..."), false); + _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("I like this"))); + _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And also this"))); + _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And gimme this too"))); + + _pnl->AddFoldPanelSeperator(item); + + _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("Check this too if you like"))); + _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("What about this"))); - item = _pnl->AddFoldPanel("Choose one ...", false); - _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, "Enter your comment")); - _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), -1, "Comment"), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20); + item = _pnl->AddFoldPanel(_T("Choose one ..."), false); + _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter your comment"))); + _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20); } wxMenuBar *MyAppFrame::CreateMenuBar() { - wxMenuBar *value = 0; - wxMenu *menuFile = new wxMenu; menuFile->Append(FoldPanelBarTest_Quit, _T("E&xit\tAlt-X"), _T("Quit this program")); wxMenu *helpMenu = new wxMenu; helpMenu->Append(FoldPanelBarTest_About, _T("&About...\tF1"), _T("Show about dialog")); - value = new wxMenuBar(); + wxMenuBar *value = new wxMenuBar(); value->Append(menuFile, _T("&File")); value->Append(helpMenu, _T("&Help")); - + return value; -} +} // event handlers @@ -182,8 +183,8 @@ wxMenuBar *MyAppFrame::CreateMenuBar() void MyAppFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) { - // TRUE is to force the frame to close - Close(TRUE); + // true is to force the frame to close + Close(true); } void MyAppFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) @@ -195,14 +196,14 @@ void MyAppFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) wxMessageBox(msg, _T("About FoldPanelBarTest"), wxOK | wxICON_INFORMATION, this); } -void MyAppFrame::OnCollapseMe(wxCommandEvent &event) +void MyAppFrame::OnCollapseMe(wxCommandEvent &WXUNUSED(event)) { - wxFoldPanel item = _pnl->Item(0); - _pnl->Collapse(item); + wxFoldPanel item = _pnl->Item(0); + _pnl->Collapse(item); } -void MyAppFrame::OnExpandMe(wxCommandEvent &event) +void MyAppFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event)) { - _pnl->Expand(_pnl->Item(0)); - _pnl->Collapse(_pnl->Item(1)); + _pnl->Expand(_pnl->Item(0)); + _pnl->Collapse(_pnl->Item(1)); } diff --git a/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.rc b/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.rc index 545d02f478..359a983cdb 100644 --- a/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.rc +++ b/contrib/samples/foldbar/foldpanelbar/foldpanelbartest.rc @@ -1,4 +1,6 @@ -mondrian ICON "mondrian.ico" +mondrian ICON "sample.ico" -#define FOLDPANELBARTEST_QUIT 1 -#define FOLDPANELBARTEST_ABOUT 102 +#define FOLDPANELBARTEST_QUIT 1 +#define FOLDPANELBARTEST_ABOUT 102 + +#include "wx/msw/wx.rc" \ No newline at end of file diff --git a/contrib/samples/foldbar/foldpanelbar/foldtestpanel.cpp b/contrib/samples/foldbar/foldpanelbar/foldtestpanel.cpp index d8688d0489..9a8e1bc7f5 100644 --- a/contrib/samples/foldbar/foldpanelbar/foldtestpanel.cpp +++ b/contrib/samples/foldbar/foldpanelbar/foldtestpanel.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: foldtestpanel.cpp -// Purpose: +// Purpose: // Author: Jorgen Bodde -// Modified by: -// Created: 06/18/04 22:37:15 -// RCS-ID: -// Copyright: -// Licence: +// Modified by: +// Created: 18/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(__APPLE__) @@ -47,8 +47,8 @@ BEGIN_EVENT_TABLE( FoldTestPanel, wxPanel ) ////@begin FoldTestPanel event table entries ////@end FoldTestPanel event table entries - //EVT_CAPTIONBAR(-1, FoldTestPanel::OnCaptionPanel) - EVT_CAPTIONBAR(wxID_ANY, FoldTestPanel::OnCaptionPanel) + //EVT_CAPTIONBAR(wxID_ANY, FoldTestPanel::OnCaptionPanel) + EVT_CAPTIONBAR(wxID_ANY, FoldTestPanel::OnCaptionPanel) END_EVENT_TABLE() @@ -59,7 +59,7 @@ END_EVENT_TABLE() FoldTestPanel::FoldTestPanel( ) { - delete _images; + delete _images; } FoldTestPanel::FoldTestPanel( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) @@ -71,7 +71,7 @@ FoldTestPanel::FoldTestPanel( wxWindow* parent, wxWindowID id, const wxString& c * FoldTestPanel creator */ -bool FoldTestPanel::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +bool FoldTestPanel::Create( wxWindow* parent, wxWindowID id, const wxString& WXUNUSED(caption), const wxPoint& pos, const wxSize& size, long style ) { ////@begin FoldTestPanel member initialisation blaat = NULL; @@ -86,7 +86,7 @@ bool FoldTestPanel::Create( wxWindow* parent, wxWindowID id, const wxString& cap GetSizer()->SetSizeHints(this); Centre(); ////@end FoldTestPanel creation - return TRUE; + return true; } /*! @@ -94,7 +94,7 @@ bool FoldTestPanel::Create( wxWindow* parent, wxWindowID id, const wxString& cap */ void FoldTestPanel::CreateControls() -{ +{ ////@begin FoldTestPanel content construction @@ -103,13 +103,13 @@ void FoldTestPanel::CreateControls() wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); blaat = item2; item1->SetSizer(item2); - item1->SetAutoLayout(TRUE); - /* wxPanel* item3 = new wxPanel( item1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); */ - wxPanel* item3 = new wxPanel( item1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL ); + item1->SetAutoLayout(true); + /* wxPanel* item3 = new wxPanel( item1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); */ + wxPanel* item3 = new wxPanel( item1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL ); item2->Add(item3, 1, wxGROW|wxADJUST_MINSIZE, 5); wxBoxSizer* item4 = new wxBoxSizer(wxVERTICAL); item3->SetSizer(item4); - item3->SetAutoLayout(TRUE); + item3->SetAutoLayout(true); wxString item5Strings[] = { _("One"), _("Two"), @@ -120,17 +120,17 @@ void FoldTestPanel::CreateControls() wxTextCtrl* item6 = new wxTextCtrl( item3, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); item4->Add(item6, 1, wxGROW|wxALL, 5); wxRadioButton* item7 = new wxRadioButton( item3, ID_RADIOBUTTON, _("I like this"), wxDefaultPosition, wxDefaultSize, 0 ); - item7->SetValue(TRUE); + item7->SetValue(true); item4->Add(item7, 0, wxALIGN_LEFT|wxALL, 5); wxRadioButton* item8 = new wxRadioButton( item3, ID_RADIOBUTTON1, _("I hate it"), wxDefaultPosition, wxDefaultSize, 0 ); - item8->SetValue(FALSE); + item8->SetValue(false); item4->Add(item8, 0, wxALIGN_LEFT|wxALL, 5); ////@end FoldTestPanel content construction } -void FoldTestPanel::OnCaptionPanel(wxCaptionBarEvent &event) +void FoldTestPanel::OnCaptionPanel(wxCaptionBarEvent &WXUNUSED(event)) { - // TODO: What else + // TODO: What else } /*! @@ -139,14 +139,14 @@ void FoldTestPanel::OnCaptionPanel(wxCaptionBarEvent &event) bool FoldTestPanel::ShowToolTips() { - return TRUE; + return true; } /*! * Get bitmap resources */ -wxBitmap FoldTestPanel::GetBitmapResource( const wxString& name ) +wxBitmap FoldTestPanel::GetBitmapResource( const wxString& WXUNUSED(name) ) { // Bitmap retrieval ////@begin FoldTestPanel bitmap retrieval @@ -158,7 +158,7 @@ wxBitmap FoldTestPanel::GetBitmapResource( const wxString& name ) * Get icon resources */ -wxIcon FoldTestPanel::GetIconResource( const wxString& name ) +wxIcon FoldTestPanel::GetIconResource( const wxString& WXUNUSED(name) ) { // Icon retrieval ////@begin FoldTestPanel icon retrieval diff --git a/contrib/samples/foldbar/foldpanelbar/foldtestpanel.h b/contrib/samples/foldbar/foldpanelbar/foldtestpanel.h index ef00ec4b16..5d3b8df730 100644 --- a/contrib/samples/foldbar/foldpanelbar/foldtestpanel.h +++ b/contrib/samples/foldbar/foldpanelbar/foldtestpanel.h @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: foldtestpanel.h -// Purpose: +// Purpose: // Author: Jorgen Bodde -// Modified by: -// Created: 06/18/04 22:37:15 -// RCS-ID: -// Copyright: -// Licence: +// Modified by: +// Created: 18/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _FOLDTESTPANEL_H_ @@ -67,15 +67,15 @@ class wxBoxSizer; */ class FoldTestPanel: public wxPanel -{ +{ DECLARE_CLASS( FoldTestPanel ) DECLARE_EVENT_TABLE() private: - wxImageList *_images; - wxRect _oldsize; + wxImageList *_images; + wxRect _oldsize; - void OnCaptionPanel(wxCaptionBarEvent &event); + void OnCaptionPanel(wxCaptionBarEvent &event); public: /// Constructors diff --git a/contrib/samples/foldbar/foldpanelbar/layouttest.cpp b/contrib/samples/foldbar/foldpanelbar/layouttest.cpp index c0a23bff8f..86f2e85e34 100644 --- a/contrib/samples/foldbar/foldpanelbar/layouttest.cpp +++ b/contrib/samples/foldbar/foldpanelbar/layouttest.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: layouttest.cpp -// Purpose: +// Purpose: // Author: Jorgen Bodde -// Modified by: -// Created: 06/25/04 19:48:57 -// RCS-ID: -// Copyright: -// Licence: +// Modified by: +// Created: 25/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(__APPLE__) @@ -66,7 +66,7 @@ LayoutTest::LayoutTest( wxWindow* parent, wxWindowID id, const wxString& caption * LayoutTest creator */ -bool LayoutTest::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) +bool LayoutTest::Create( wxWindow* parent, wxWindowID id, const wxString& WXUNUSED(caption), const wxPoint& pos, const wxSize& size, long style ) { ////@begin LayoutTest member initialisation ////@end LayoutTest member initialisation @@ -80,7 +80,7 @@ bool LayoutTest::Create( wxWindow* parent, wxWindowID id, const wxString& captio GetSizer()->SetSizeHints(this); Centre(); ////@end LayoutTest creation - return TRUE; + return true; } /*! @@ -88,14 +88,14 @@ bool LayoutTest::Create( wxWindow* parent, wxWindowID id, const wxString& captio */ void LayoutTest::CreateControls() -{ +{ ////@begin LayoutTest content construction LayoutTest* item1 = this; wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); item1->SetSizer(item2); - item1->SetAutoLayout(TRUE); + item1->SetAutoLayout(true); wxStaticText* item3 = new wxStaticText( item1, wxID_STATIC, _("lbaaaaaa"), wxDefaultPosition, wxDefaultSize, 0 ); item3->SetBackgroundColour(wxColour(139, 139, 139)); item2->Add(item3, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); @@ -103,7 +103,7 @@ void LayoutTest::CreateControls() item2->Add(item4, 0, wxGROW, 5); wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL); item4->SetSizer(item5); - item4->SetAutoLayout(TRUE); + item4->SetAutoLayout(true); wxStaticText* item6 = new wxStaticText( item4, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); item5->Add(item6, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); wxButton* item7 = new wxButton( item4, ID_BUTTON, _("Button"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -117,14 +117,14 @@ void LayoutTest::CreateControls() bool LayoutTest::ShowToolTips() { - return TRUE; + return true; } /*! * Get bitmap resources */ -wxBitmap LayoutTest::GetBitmapResource( const wxString& name ) +wxBitmap LayoutTest::GetBitmapResource( const wxString& WXUNUSED(name) ) { // Bitmap retrieval ////@begin LayoutTest bitmap retrieval @@ -136,7 +136,7 @@ wxBitmap LayoutTest::GetBitmapResource( const wxString& name ) * Get icon resources */ -wxIcon LayoutTest::GetIconResource( const wxString& name ) +wxIcon LayoutTest::GetIconResource( const wxString& WXUNUSED(name) ) { // Icon retrieval ////@begin LayoutTest icon retrieval diff --git a/contrib/samples/foldbar/foldpanelbar/layouttest.h b/contrib/samples/foldbar/foldpanelbar/layouttest.h index 96b44f7c04..636995bd3c 100644 --- a/contrib/samples/foldbar/foldpanelbar/layouttest.h +++ b/contrib/samples/foldbar/foldpanelbar/layouttest.h @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: layouttest.h -// Purpose: +// Purpose: // Author: Jorgen Bodde -// Modified by: -// Created: 06/25/04 19:48:57 -// RCS-ID: -// Copyright: -// Licence: +// Modified by: +// Created: 25/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _LAYOUTTEST_H_ @@ -61,7 +61,7 @@ */ class LayoutTest: public wxPanel -{ +{ DECLARE_CLASS( LayoutTest ) DECLARE_EVENT_TABLE() diff --git a/contrib/samples/foldbar/foldpanelbar/test.cpp b/contrib/samples/foldbar/foldpanelbar/test.cpp index 710a9f0942..b56eba3292 100644 --- a/contrib/samples/foldbar/foldpanelbar/test.cpp +++ b/contrib/samples/foldbar/foldpanelbar/test.cpp @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: test.cpp -// Purpose: +// Purpose: // Author: Jorgen Bodde -// Modified by: -// Created: 06/27/04 13:34:20 -// RCS-ID: -// Copyright: -// Licence: +// Modified by: +// Created: 27/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(__APPLE__) @@ -82,7 +82,7 @@ bool TestTest::Create( wxWindow* parent, wxWindowID id, const wxString& caption, GetSizer()->SetSizeHints(this); Centre(); ////@end TestTest creation - return TRUE; + return true; } /*! @@ -90,7 +90,7 @@ bool TestTest::Create( wxWindow* parent, wxWindowID id, const wxString& caption, */ void TestTest::CreateControls() -{ +{ ////@begin TestTest content construction TestTest* item1 = this; @@ -99,19 +99,19 @@ void TestTest::CreateControls() item2->AddGrowableRow(0); item2->AddGrowableCol(0); item1->SetSizer(item2); - item1->SetAutoLayout(TRUE); + item1->SetAutoLayout(true); wxPanel* item3 = new wxPanel( item1, ID_PANEL7, wxDefaultPosition, wxSize(100, 50), wxNO_BORDER|wxTAB_TRAVERSAL ); item2->Add(item3, 1, wxGROW|wxGROW|wxADJUST_MINSIZE, 5); wxBoxSizer* item4 = new wxBoxSizer(wxVERTICAL); item3->SetSizer(item4); - item3->SetAutoLayout(TRUE); + item3->SetAutoLayout(true); wxPanel* item5 = new wxPanel( item3, ID_PANEL6, wxDefaultPosition, wxSize(100, 80), wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); item4->Add(item5, 1, wxGROW|wxALL|wxADJUST_MINSIZE, 5); wxFlexGridSizer* item6 = new wxFlexGridSizer(2, 1, 0, 0); item6->AddGrowableRow(1); item6->AddGrowableCol(0); item5->SetSizer(item6); - item5->SetAutoLayout(TRUE); + item5->SetAutoLayout(true); wxStaticText* item7 = new wxStaticText( item5, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); item6->Add(item7, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxALL|wxADJUST_MINSIZE, 5); wxPanel* item8 = new wxPanel( item5, ID_PANEL3, wxDefaultPosition, wxSize(100, 80), wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); @@ -119,12 +119,12 @@ void TestTest::CreateControls() wxBoxSizer* item9 = new wxBoxSizer(wxVERTICAL); blaat = item9; item8->SetSizer(item9); - item8->SetAutoLayout(TRUE); + item8->SetAutoLayout(true); wxPanel* item10 = new wxPanel( item8, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); item9->Add(item10, 1, wxGROW, 5); wxBoxSizer* item11 = new wxBoxSizer(wxVERTICAL); item10->SetSizer(item11); - item10->SetAutoLayout(TRUE); + item10->SetAutoLayout(true); wxString item12Strings[] = { _("One"), _("Two"), @@ -133,10 +133,10 @@ void TestTest::CreateControls() wxChoice* item12 = new wxChoice( item10, ID_CHOICE, wxDefaultPosition, wxDefaultSize, 3, item12Strings, 0 ); item11->Add(item12, 0, wxGROW|wxALL, 5); wxRadioButton* item13 = new wxRadioButton( item10, ID_RADIOBUTTON, _("I like this"), wxDefaultPosition, wxDefaultSize, 0 ); - item13->SetValue(TRUE); + item13->SetValue(true); item11->Add(item13, 0, wxALIGN_LEFT|wxALL, 5); wxRadioButton* item14 = new wxRadioButton( item10, ID_RADIOBUTTON1, _("I hate it"), wxDefaultPosition, wxDefaultSize, 0 ); - item14->SetValue(FALSE); + item14->SetValue(false); item11->Add(item14, 0, wxALIGN_LEFT|wxALL, 5); wxPanel* item15 = new wxPanel( item3, ID_PANEL2, wxDefaultPosition, wxSize(100, 80), wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); item4->Add(item15, 1, wxGROW|wxALL|wxADJUST_MINSIZE, 5); @@ -144,7 +144,7 @@ void TestTest::CreateControls() item16->AddGrowableRow(1); item16->AddGrowableCol(0); item15->SetSizer(item16); - item15->SetAutoLayout(TRUE); + item15->SetAutoLayout(true); wxStaticText* item17 = new wxStaticText( item15, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); item16->Add(item17, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxALL|wxADJUST_MINSIZE|wxFIXED_MINSIZE, 5); wxPanel* item18 = new wxPanel( item15, ID_PANEL4, wxDefaultPosition, wxSize(100, 80), wxSUNKEN_BORDER|wxTAB_TRAVERSAL ); @@ -152,12 +152,12 @@ void TestTest::CreateControls() wxBoxSizer* item19 = new wxBoxSizer(wxVERTICAL); blaat = item19; item18->SetSizer(item19); - item18->SetAutoLayout(TRUE); + item18->SetAutoLayout(true); wxPanel* item20 = new wxPanel( item18, ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); item19->Add(item20, 1, wxGROW, 5); wxBoxSizer* item21 = new wxBoxSizer(wxVERTICAL); item20->SetSizer(item21); - item20->SetAutoLayout(TRUE); + item20->SetAutoLayout(true); wxString item22Strings[] = { _("One"), _("Two"), @@ -166,10 +166,10 @@ void TestTest::CreateControls() wxChoice* item22 = new wxChoice( item20, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 3, item22Strings, 0 ); item21->Add(item22, 0, wxGROW|wxALL, 5); wxRadioButton* item23 = new wxRadioButton( item20, ID_RADIOBUTTON2, _("I like this"), wxDefaultPosition, wxDefaultSize, 0 ); - item23->SetValue(TRUE); + item23->SetValue(true); item21->Add(item23, 0, wxALIGN_LEFT|wxALL, 5); wxRadioButton* item24 = new wxRadioButton( item20, ID_RADIOBUTTON3, _("I hate it"), wxDefaultPosition, wxDefaultSize, 0 ); - item24->SetValue(FALSE); + item24->SetValue(false); item21->Add(item24, 0, wxALIGN_LEFT|wxALL, 5); wxPanel* item25 = new wxPanel( item1, ID_PANEL1, wxDefaultPosition, wxSize(100, 20), wxNO_BORDER|wxTAB_TRAVERSAL ); item25->SetBackgroundColour(wxColour(98, 98, 98)); @@ -183,14 +183,14 @@ void TestTest::CreateControls() bool TestTest::ShowToolTips() { - return TRUE; + return true; } /*! * Get bitmap resources */ -wxBitmap TestTest::GetBitmapResource( const wxString& name ) +wxBitmap TestTest::GetBitmapResource( const wxString& WXUNUSED(name) ) { // Bitmap retrieval ////@begin TestTest bitmap retrieval @@ -202,7 +202,7 @@ wxBitmap TestTest::GetBitmapResource( const wxString& name ) * Get icon resources */ -wxIcon TestTest::GetIconResource( const wxString& name ) +wxIcon TestTest::GetIconResource( const wxString& WXUNUSED(name) ) { // Icon retrieval ////@begin TestTest icon retrieval diff --git a/contrib/samples/foldbar/foldpanelbar/test.h b/contrib/samples/foldbar/foldpanelbar/test.h index 1acf964b5a..2855860127 100644 --- a/contrib/samples/foldbar/foldpanelbar/test.h +++ b/contrib/samples/foldbar/foldpanelbar/test.h @@ -1,12 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// // Name: test.h -// Purpose: +// Purpose: // Author: Jorgen Bodde -// Modified by: -// Created: 06/27/04 13:34:20 -// RCS-ID: -// Copyright: -// Licence: +// Modified by: +// Created: 27/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _TEST_H_ @@ -74,7 +74,7 @@ class wxBoxSizer; */ class TestTest: public wxDialog -{ +{ DECLARE_CLASS( TestTest ) DECLARE_EVENT_TABLE() diff --git a/contrib/src/foldbar/captionbar.cpp b/contrib/src/foldbar/captionbar.cpp index e95402feba..64341339d3 100644 --- a/contrib/src/foldbar/captionbar.cpp +++ b/contrib/src/foldbar/captionbar.cpp @@ -3,8 +3,8 @@ // Purpose: wxCaptionBar class belonging to the wxFoldPanel (but can be used independent) // Author: Jorgen Bodde // Modified by: -// Created: June 18, 2004 -// RCS-ID: +// Created: 18/06/2004 +// RCS-ID: $Id$ // Copyright: (c) Jorgen Bodde // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -37,29 +37,29 @@ BEGIN_EVENT_TABLE(wxCaptionBar, wxWindow) EVT_PAINT(wxCaptionBar::OnPaint) EVT_CHAR(wxCaptionBar::OnChar) EVT_MOUSE_EVENTS(wxCaptionBar::OnMouseEvent) - EVT_SIZE(wxCaptionBar::OnSize) + EVT_SIZE(wxCaptionBar::OnSize) END_EVENT_TABLE() -wxCaptionBar::wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images, wxWindowID id, - const wxCaptionBarStyle &cbstyle, const wxPoint& pos, const wxSize& size, long style) - : wxWindow(parent, id, pos, size, style) - , _caption(caption) - , _collapsed(false) - , _foldIcons(images) - , _rightIndent(wxFPB_BMP_RIGHTSPACE) - , _iconWidth(16) - , _iconHeight(16) +wxCaptionBar::wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images, wxWindowID id, + const wxCaptionBarStyle &cbstyle, const wxPoint& pos, const wxSize& size, long style) + : wxWindow(parent, id, pos, size, style) + , _caption(caption) + , _collapsed(false) + , _foldIcons(images) + , _rightIndent(wxFPB_BMP_RIGHTSPACE) + , _iconWidth(16) + , _iconHeight(16) { - // do initialisy thingy stuff - - ApplyCaptionStyle(cbstyle, true); + // do initialisy thingy stuff - // set initial size - if(_foldIcons) - { - wxASSERT(_foldIcons->GetImageCount() > 1); - _foldIcons->GetSize(0, _iconWidth, _iconHeight); - } + ApplyCaptionStyle(cbstyle, true); + + // set initial size + if(_foldIcons) + { + wxASSERT(_foldIcons->GetImageCount() > 1); + _foldIcons->GetSize(0, _iconWidth, _iconHeight); + } } wxCaptionBar::~wxCaptionBar() @@ -69,323 +69,323 @@ wxCaptionBar::~wxCaptionBar() void wxCaptionBar::ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool applyDefault) { - wxASSERT(GetParent()); + wxASSERT(GetParent()); - wxCaptionBarStyle newstyle = cbstyle; - - // set defaults in newly created style copy if needed - if(applyDefault) - { - // get first colour from style or make it default - if(!newstyle.FirstColourUsed()) - newstyle.SetFirstColour(*wxWHITE); - - // get second colour from style or make it default - if(!newstyle.SecondColourUsed()) - { - // make the second colour slightly darker then the background - wxColour col = GetParent()->GetBackgroundColour(); - col.Set((col.Red() >> 1) + 20, (col.Green() >> 1) + 20, (col.Blue() >> 1) + 20); - newstyle.SetSecondColour(col); - } + wxCaptionBarStyle newstyle = cbstyle; - // get text colour - if(!newstyle.CaptionColourUsed()) - newstyle.SetCaptionColour(*wxBLACK); + // set defaults in newly created style copy if needed + if(applyDefault) + { + // get first colour from style or make it default + if(!newstyle.FirstColourUsed()) + newstyle.SetFirstColour(*wxWHITE); - // get font colour - if(!newstyle.CaptionFontUsed()) - newstyle.SetCaptionFont(GetParent()->GetFont()); + // get second colour from style or make it default + if(!newstyle.SecondColourUsed()) + { + // make the second colour slightly darker then the background + wxColour col = GetParent()->GetBackgroundColour(); + col.Set((col.Red() >> 1) + 20, (col.Green() >> 1) + 20, (col.Blue() >> 1) + 20); + newstyle.SetSecondColour(col); + } - // apply caption style - if(!newstyle.CaptionStyleUsed()) - newstyle.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_V); - } + // get text colour + if(!newstyle.CaptionColourUsed()) + newstyle.SetCaptionColour(*wxBLACK); - // apply the style - _style = newstyle; + // get font colour + if(!newstyle.CaptionFontUsed()) + newstyle.SetCaptionFont(GetParent()->GetFont()); + + // apply caption style + if(!newstyle.CaptionStyleUsed()) + newstyle.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_V); + } + + // apply the style + _style = newstyle; } void wxCaptionBar::OnPaint(wxPaintEvent& WXUNUSED(event)) { - wxPaintDC dc(this); + wxPaintDC dc(this); - // TODO: Maybe first a memory DC should draw all, and then paint it on the - // caption. This way a flickering arrow during resize is not visible + // TODO: Maybe first a memory DC should draw all, and then paint it on the + // caption. This way a flickering arrow during resize is not visible - // draw basics + // draw basics - FillCaptionBackground(dc); + FillCaptionBackground(dc); - dc.SetFont(_style.GetCaptionFont()); - dc.DrawText(_caption, 4, (wxFPB_EXTRA_Y / 2)); + dc.SetFont(_style.GetCaptionFont()); + dc.DrawText(_caption, 4, (wxFPB_EXTRA_Y / 2)); - // draw small icon, either collapsed or expanded - // based on the state of the bar. If we have - // any bmp's + // draw small icon, either collapsed or expanded + // based on the state of the bar. If we have + // any bmp's - if(_foldIcons) - { - wxCHECK2(_foldIcons->GetImageCount() > 1, return); + if(_foldIcons) + { + wxCHECK2(_foldIcons->GetImageCount() > 1, return); - int index = 0; - if(_collapsed) - index = 1; + int index = 0; + if(_collapsed) + index = 1; - wxRect wndRect = GetRect(); - _foldIcons->Draw(index, dc, wndRect.GetRight() - _iconWidth - _rightIndent, (wndRect.GetHeight() - _iconHeight) / 2, - wxIMAGELIST_DRAW_TRANSPARENT); - } + wxRect wndRect = GetRect(); + _foldIcons->Draw(index, dc, wndRect.GetRight() - _iconWidth - _rightIndent, (wndRect.GetHeight() - _iconHeight) / 2, + wxIMAGELIST_DRAW_TRANSPARENT); + } } void wxCaptionBar::FillCaptionBackground(wxPaintDC &dc) { - // dispatch right style for caption drawing + // dispatch right style for caption drawing - switch(_style.GetCaptionStyle()) - { - case wxCAPTIONBAR_GRADIENT_V: - DrawVerticalGradient(dc, GetRect()); - break; - case wxCAPTIONBAR_GRADIENT_H: - DrawHorizontalGradient(dc, GetRect()); - break; - case wxCAPTIONBAR_SINGLE: - DrawSingleColour(dc, GetRect()); - break; - case wxCAPTIONBAR_RECTANGLE: - case wxCAPTIONBAR_FILLED_RECTANGLE: - DrawSingleRectangle(dc, GetRect()); - break; - default: - break; - } + switch(_style.GetCaptionStyle()) + { + case wxCAPTIONBAR_GRADIENT_V: + DrawVerticalGradient(dc, GetRect()); + break; + case wxCAPTIONBAR_GRADIENT_H: + DrawHorizontalGradient(dc, GetRect()); + break; + case wxCAPTIONBAR_SINGLE: + DrawSingleColour(dc, GetRect()); + break; + case wxCAPTIONBAR_RECTANGLE: + case wxCAPTIONBAR_FILLED_RECTANGLE: + DrawSingleRectangle(dc, GetRect()); + break; + default: + break; + } } void wxCaptionBar::OnMouseEvent(wxMouseEvent& event) { - // if clicked on the arrow (single) or double on the caption - // we change state and an event must be fired to let this - // panel collapse or expand + // if clicked on the arrow (single) or double on the caption + // we change state and an event must be fired to let this + // panel collapse or expand - bool send_event = false; + bool send_event = false; - if (event.LeftDown() && _foldIcons) - { - wxPoint pt(event.GetPosition()); - wxRect rect = GetRect(); + if (event.LeftDown() && _foldIcons) + { + wxPoint pt(event.GetPosition()); + wxRect rect = GetRect(); - if(pt.x > (rect.GetWidth() - _iconWidth - _rightIndent)) - send_event = true; - } - else if(event.LeftDClick()) - send_event = true; + if(pt.x > (rect.GetWidth() - _iconWidth - _rightIndent)) + send_event = true; + } + else if(event.LeftDClick()) + send_event = true; - // send the collapse, expand event to the parent + // send the collapse, expand event to the parent - if(send_event) - { - wxCaptionBarEvent event(wxEVT_CAPTIONBAR); - event.SetBar(this); + if(send_event) + { + wxCaptionBarEvent event(wxEVT_CAPTIONBAR); + event.SetBar(this); - ::wxPostEvent(this, event); + ::wxPostEvent(this, event); - } + } } void wxCaptionBar::OnChar(wxKeyEvent &event) { - // TODO: Anything here? - - event.Skip(); + // TODO: Anything here? + + event.Skip(); } wxSize wxCaptionBar::DoGetBestSize() const { - int x,y; + int x,y; - GetTextExtent(_caption, &x, &y); - - if(x < _iconWidth) - x = _iconWidth; - - if(y < _iconHeight) - y = _iconHeight; - - // TODO: The extra wxFPB_EXTRA_X constants should be adjustable as well + GetTextExtent(_caption, &x, &y); - return wxSize(x + wxFPB_EXTRA_X, y + wxFPB_EXTRA_Y); + if(x < _iconWidth) + x = _iconWidth; + + if(y < _iconHeight) + y = _iconHeight; + + // TODO: The extra wxFPB_EXTRA_X constants should be adjustable as well + + return wxSize(x + wxFPB_EXTRA_X, y + wxFPB_EXTRA_Y); } void wxCaptionBar::DrawVerticalGradient(wxDC &dc, const wxRect &rect ) { - // gradient fill from colour 1 to colour 2 with top to bottom + // gradient fill from colour 1 to colour 2 with top to bottom - if(rect.height < 1 || rect.width < 1) - return; + if(rect.height < 1 || rect.width < 1) + return; - dc.SetPen(*wxTRANSPARENT_PEN); - + dc.SetPen(*wxTRANSPARENT_PEN); - // calculate gradient coefficients - wxColour col2 = _style.GetSecondColour(), - col1 = _style.GetFirstColour(); - double rstep = double((col2.Red() - col1.Red())) / double(rect.height), rf = 0, - gstep = double((col2.Green() - col1.Green())) / double(rect.height), gf = 0, - bstep = double((col2.Blue() - col1.Blue())) / double(rect.height), bf = 0; + // calculate gradient coefficients + wxColour col2 = _style.GetSecondColour(), + col1 = _style.GetFirstColour(); - wxColour currCol; - for(int y = rect.y; y < rect.y + rect.height; y++) - { - currCol.Set(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf); - dc.SetBrush( wxBrush( currCol, wxSOLID ) ); - dc.DrawRectangle( rect.x, rect.y + (y - rect.y), rect.width, rect.height ); - //currCol.Set(currCol.Red() + rstep, currCol.Green() + gstep, currCol.Blue() + bstep); - rf += rstep; gf += gstep; bf += bstep; - } + double rstep = double((col2.Red() - col1.Red())) / double(rect.height), rf = 0, + gstep = double((col2.Green() - col1.Green())) / double(rect.height), gf = 0, + bstep = double((col2.Blue() - col1.Blue())) / double(rect.height), bf = 0; + + wxColour currCol; + for(int y = rect.y; y < rect.y + rect.height; y++) + { + currCol.Set(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf); + dc.SetBrush( wxBrush( currCol, wxSOLID ) ); + dc.DrawRectangle( rect.x, rect.y + (y - rect.y), rect.width, rect.height ); + //currCol.Set(currCol.Red() + rstep, currCol.Green() + gstep, currCol.Blue() + bstep); + rf += rstep; gf += gstep; bf += bstep; + } } void wxCaptionBar::DrawHorizontalGradient(wxDC &dc, const wxRect &rect ) { - // gradient fill from colour 1 to colour 2 with left to right + // gradient fill from colour 1 to colour 2 with left to right - if(rect.height < 1 || rect.width < 1) - return; + if(rect.height < 1 || rect.width < 1) + return; - dc.SetPen(*wxTRANSPARENT_PEN); - - // calculate gradient coefficients - wxColour col2 = _style.GetSecondColour(), - col1 = _style.GetFirstColour(); + dc.SetPen(*wxTRANSPARENT_PEN); - double rstep = double((col2.Red() - col1.Red())) / double(rect.width), rf = 0, - gstep = double((col2.Green() - col1.Green())) / double(rect.width), gf = 0, - bstep = double((col2.Blue() - col1.Blue())) / double(rect.width), bf = 0; + // calculate gradient coefficients + wxColour col2 = _style.GetSecondColour(), + col1 = _style.GetFirstColour(); - wxColour currCol; - for(int x = rect.x; x < rect.x + rect.width; x++) - { - currCol.Set(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf); - dc.SetBrush( wxBrush( currCol, wxSOLID ) ); - dc.DrawRectangle( rect.x + (x - rect.x), rect.y, 1, rect.height ); - rf += rstep; gf += gstep; bf += bstep; - } + double rstep = double((col2.Red() - col1.Red())) / double(rect.width), rf = 0, + gstep = double((col2.Green() - col1.Green())) / double(rect.width), gf = 0, + bstep = double((col2.Blue() - col1.Blue())) / double(rect.width), bf = 0; + + wxColour currCol; + for(int x = rect.x; x < rect.x + rect.width; x++) + { + currCol.Set(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf); + dc.SetBrush( wxBrush( currCol, wxSOLID ) ); + dc.DrawRectangle( rect.x + (x - rect.x), rect.y, 1, rect.height ); + rf += rstep; gf += gstep; bf += bstep; + } } void wxCaptionBar::DrawSingleColour(wxDC &dc, const wxRect &rect ) { - // single colour fill. This is the most easy one to find + // single colour fill. This is the most easy one to find - if(rect.height < 1 || rect.width < 1) - return; + if(rect.height < 1 || rect.width < 1) + return; - dc.SetPen(*wxTRANSPARENT_PEN); + dc.SetPen(*wxTRANSPARENT_PEN); - // draw simple rectangle - dc.SetBrush( wxBrush( _style.GetFirstColour(), wxSOLID ) ); - dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); + // draw simple rectangle + dc.SetBrush( wxBrush( _style.GetFirstColour(), wxSOLID ) ); + dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); } void wxCaptionBar::DrawSingleRectangle(wxDC &dc, const wxRect &rect ) { - wxASSERT(GetParent()); - - // single colour fill. This is the most easy one to find + wxASSERT(GetParent()); - if(rect.height < 2 || rect.width < 1) - return; + // single colour fill. This is the most easy one to find - // single frame, set up internal fill colour - - wxBrush br; - br.SetStyle(wxSOLID); + if(rect.height < 2 || rect.width < 1) + return; - if(_style.GetCaptionStyle() == wxCAPTIONBAR_RECTANGLE) - br.SetColour(GetParent()->GetBackgroundColour()); - else - br.SetColour(_style.GetFirstColour()); + // single frame, set up internal fill colour - // setup the pen frame + wxBrush br; + br.SetStyle(wxSOLID); - wxPen pen(_style.GetSecondColour()); - dc.SetPen(pen); - - dc.SetBrush( br ); - dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height - 1); - - wxPen bgpen(GetParent()->GetBackgroundColour()); - dc.SetPen(bgpen); - dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1); + if(_style.GetCaptionStyle() == wxCAPTIONBAR_RECTANGLE) + br.SetColour(GetParent()->GetBackgroundColour()); + else + br.SetColour(_style.GetFirstColour()); + + // setup the pen frame + + wxPen pen(_style.GetSecondColour()); + dc.SetPen(pen); + + dc.SetBrush( br ); + dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height - 1); + + wxPen bgpen(GetParent()->GetBackgroundColour()); + dc.SetPen(bgpen); + dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1); } void wxCaptionBar::OnSize(wxSizeEvent &event) { - wxSize size = event.GetSize(); + wxSize size = event.GetSize(); - if(_foldIcons) - { - // What I am doing here is simply invalidating the part of the window exposed. So when I - // make a rect with as width the newly exposed part, and the x,y of the old window size origin, - // I don't need a bitmap calulation in it, or do I ? The bitmap needs redrawing anyway. Leave it - // like this until I figured it out + if(_foldIcons) + { + // What I am doing here is simply invalidating the part of the window exposed. So when I + // make a rect with as width the newly exposed part, and the x,y of the old window size origin, + // I don't need a bitmap calulation in it, or do I ? The bitmap needs redrawing anyway. Leave it + // like this until I figured it out - // set rect to redraw as old bitmap area which is entitled to redraw + // set rect to redraw as old bitmap area which is entitled to redraw - wxRect rect(size.GetWidth() - _iconWidth - _rightIndent, 0, _iconWidth + _rightIndent, - _iconWidth + _rightIndent); + wxRect rect(size.GetWidth() - _iconWidth - _rightIndent, 0, _iconWidth + _rightIndent, + _iconWidth + _rightIndent); - // adjust rectangle when more is slided so we need to redraw all - // the old stuff but not all (ugly flickering) + // adjust rectangle when more is slided so we need to redraw all + // the old stuff but not all (ugly flickering) - int diffX = size.GetWidth() - _oldSize.GetWidth(); - if(diffX > 1) - { - // adjust the rect with all the crap to redraw + int diffX = size.GetWidth() - _oldSize.GetWidth(); + if(diffX > 1) + { + // adjust the rect with all the crap to redraw - rect.SetWidth(rect.GetWidth() + diffX + 10); - rect.SetX(rect.GetX() - diffX - 10); - } + rect.SetWidth(rect.GetWidth() + diffX + 10); + rect.SetX(rect.GetX() - diffX - 10); + } - RefreshRect(rect); - } - else - { - wxRect rect = GetRect(); - RefreshRect(rect); - } + RefreshRect(rect); + } + else + { + wxRect rect = GetRect(); + RefreshRect(rect); + } - _oldSize = size; + _oldSize = size; } void wxCaptionBar::RedrawIconBitmap() { - if(_foldIcons) - { - // invalidate the bitmap area and force a redraw - - wxRect rect = GetRect(); - - rect.SetX(rect.GetWidth() - _iconWidth - _rightIndent); - rect.SetWidth(_iconWidth + _rightIndent); - RefreshRect(rect); - } + if(_foldIcons) + { + // invalidate the bitmap area and force a redraw + + wxRect rect = GetRect(); + + rect.SetX(rect.GetWidth() - _iconWidth - _rightIndent); + rect.SetWidth(_iconWidth + _rightIndent); + RefreshRect(rect); + } } /* - * wxCaptionBarEvent + * wxCaptionBarEvent */ -DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR) +DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR) wxCaptionBarEvent::wxCaptionBarEvent(const wxCaptionBarEvent &event) - : wxCommandEvent(event) + : wxCommandEvent(event) { - _bar = event._bar; + _bar = event._bar; } //DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR) //IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxEvent) -IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxCommandEvent) diff --git a/contrib/src/foldbar/foldpanelbar.cpp b/contrib/src/foldbar/foldpanelbar.cpp index f9f067e2cd..e7d6ff5268 100644 --- a/contrib/src/foldbar/foldpanelbar.cpp +++ b/contrib/src/foldbar/foldpanelbar.cpp @@ -1,8 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wxFoldPanelBar.cpp -// Author: XX -// Created: Tuesday, June 22, 2004 20:40:00 -// Copyright: XX +// Name: foldpanelbar.cpp +// Purpose: +// Author: Jorgen Bodde +// Modified by: +// Created: 22/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". @@ -24,9 +28,9 @@ IMPLEMENT_CLASS( wxFoldPanelBar, wxPanel ) BEGIN_EVENT_TABLE(wxFoldPanelBar,wxPanel) - EVT_SIZE(wxFoldPanelBar::OnSizePanel) - //EVT_PAINT(wxFoldPanelBar::OnPaint) - EVT_CAPTIONBAR(-1, wxFoldPanelBar::OnPressCaption) + EVT_SIZE(wxFoldPanelBar::OnSizePanel) + //EVT_PAINT(wxFoldPanelBar::OnPaint) + EVT_CAPTIONBAR(wxID_ANY, wxFoldPanelBar::OnPressCaption) END_EVENT_TABLE() wxFoldPanelBar::wxFoldPanelBar() @@ -34,313 +38,313 @@ wxFoldPanelBar::wxFoldPanelBar() } -wxFoldPanelBar::wxFoldPanelBar( wxWindow *parent, wxWindowID id, const wxPoint &position, - const wxSize& size, long style, long extraStyle) - : _foldPanel(0) - , _bottomPanel(0) - , _controlCreated(false) +wxFoldPanelBar::wxFoldPanelBar( wxWindow *parent, wxWindowID id, const wxPoint &position, + const wxSize& size, long style, long extraStyle) + : _foldPanel(0) + , _bottomPanel(0) + , _controlCreated(false) { - Create( parent, id, position, size, style, extraStyle); + Create( parent, id, position, size, style, extraStyle); } -void wxFoldPanelBar::Create( wxWindow *parent, wxWindowID id, const wxPoint &position, - const wxSize& size, long style, long extraStyle ) +void wxFoldPanelBar::Create( wxWindow *parent, wxWindowID id, const wxPoint &position, + const wxSize& size, long style, long extraStyle ) { - - _extraStyle = extraStyle; - - // create the panel (duh!). This causes a size event, which we are going - // to skip when we are not initialised - - wxPanel::Create(parent, id, position, size, style); - // the fold panel area - - _foldPanel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL); - - // the extra area for some icons / context menu etc + _extraStyle = extraStyle; + + // create the panel (duh!). This causes a size event, which we are going + // to skip when we are not initialised + + wxPanel::Create(parent, id, position, size, style); + + // the fold panel area + + _foldPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL); + + // the extra area for some icons / context menu etc #if 0 - _bottomPanel = new wxPanel(this, -1, wxDefaultPosition, wxSize(-1,22), wxNO_BORDER|wxTAB_TRAVERSAL); - _bottomPanel->SetBackgroundColour(*wxWHITE); + _bottomPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(wxDefaultCoord,22), wxNO_BORDER|wxTAB_TRAVERSAL); + _bottomPanel->SetBackgroundColour(*wxWHITE); #endif - // create the fold icons to be used in the captions + // create the fold icons to be used in the captions - _images = new wxImageList(16, 16); - - wxBitmap *bmp = new wxBitmap(icon_expanded); - _images->Add(*bmp); - delete bmp; + _images = new wxImageList(16, 16); - bmp = new wxBitmap(icon_collapsed); - _images->Add(*bmp); - delete bmp; + wxBitmap *bmp = new wxBitmap(icon_expanded); + _images->Add(*bmp); + delete bmp; - _moreBmp = new wxBitmap(icon_theresmore); + bmp = new wxBitmap(icon_collapsed); + _images->Add(*bmp); + delete bmp; - // do this as last, to check if create is already called - - _controlCreated = true; + _moreBmp = new wxBitmap(icon_theresmore); + + // do this as last, to check if create is already called + + _controlCreated = true; } wxFoldPanelBar::~wxFoldPanelBar() { delete _images; - delete _moreBmp; + delete _moreBmp; } wxFoldPanel wxFoldPanelBar::AddFoldPanel(const wxString &caption, bool collapsedInitially, const wxCaptionBarStyle &style) { - wxASSERT(_controlCreated); + wxASSERT(_controlCreated); - // create a fold panel item, which is first only the caption. - // the user can now add a panel area which will be folded in - // when pressed. + // create a fold panel item, which is first only the caption. + // the user can now add a panel area which will be folded in + // when pressed. - wxFoldPanelItem *item = new wxFoldPanelItem(_foldPanel, caption, _images, collapsedInitially, style); - - // look at the last added one and reposition this one - int y = 0; - if(_panels.GetCount() > 0) - y = _panels.Last()->GetY() + _panels.Last()->GetPanelHeight(); + wxFoldPanelItem *item = new wxFoldPanelItem(_foldPanel, caption, _images, collapsedInitially, style); - item->Reposition(y); - _panels.Add(item); + // look at the last added one and reposition this one + int y = 0; + if(_panels.GetCount() > 0) + y = _panels.Last()->GetY() + _panels.Last()->GetPanelHeight(); - //return wxFoldPanel(item); - return wxFoldPanel(item); + item->Reposition(y); + _panels.Add(item); + + //return wxFoldPanel(item); + return wxFoldPanel(item); } int wxFoldPanelBar::AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags, int ySpacing, int leftSpacing, - int rightSpacing) + int rightSpacing) { - wxCHECK(panel.IsOk(), -1); - panel.GetItem()->AddWindow(window, flags, ySpacing, leftSpacing, rightSpacing); + wxCHECK(panel.IsOk(), -1); + panel.GetItem()->AddWindow(window, flags, ySpacing, leftSpacing, rightSpacing); - // TODO: Take old and new height, and if difference, reposition all the lower panels - // this is because the user can add new wxWindow controls somewhere in between - // when other panels are already present. + // TODO: Take old and new height, and if difference, reposition all the lower panels + // this is because the user can add new wxWindow controls somewhere in between + // when other panels are already present. - return 0; + return 0; } int wxFoldPanelBar::AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color, int ySpacing, int leftSpacing, - int rightSpacing) + int rightSpacing) { - wxCHECK(panel.IsOk(), -1); - panel.GetItem()->AddSeparator(color, ySpacing, leftSpacing, rightSpacing); + wxCHECK(panel.IsOk(), -1); + panel.GetItem()->AddSeparator(color, ySpacing, leftSpacing, rightSpacing); - return 0; + return 0; } void wxFoldPanelBar::OnSizePanel(wxSizeEvent &event) { - // skip all stuff when we are not initialised yet + // skip all stuff when we are not initialised yet - if(!_controlCreated) - { - event.Skip(); - return; - } + if(!_controlCreated) + { + event.Skip(); + return; + } - // now size the fold panel area and the - // lower bar in such a way that the bar is always - // visible + // now size the fold panel area and the + // lower bar in such a way that the bar is always + // visible - wxRect foldrect = GetRect(); - - // fold panel itself. If too little space, - // don't show it + wxRect foldrect = GetRect(); + + // fold panel itself. If too little space, + // don't show it #if 0 - if(foldrect.GetHeight() < 23) - foldrect.SetHeight(0); - else - foldrect.SetHeight(foldrect.GetHeight() - 22); + if(foldrect.GetHeight() < 23) + foldrect.SetHeight(0); + else + foldrect.SetHeight(foldrect.GetHeight() - 22); #endif - foldrect.SetX(0); - foldrect.SetY(0); - _foldPanel->SetSize(foldrect); + foldrect.SetX(0); + foldrect.SetY(0); + _foldPanel->SetSize(foldrect); - if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM) - { - wxRect rect = RepositionCollapsedToBottom(); - if(rect.GetHeight() > 0) - RefreshRect(rect); - } + if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM) + { + wxRect rect = RepositionCollapsedToBottom(); + if(rect.GetHeight() > 0) + RefreshRect(rect); + } - // TODO: A smart way to check wether the old - new width of the - // panel changed, if so no need to resize the fold panel items + // TODO: A smart way to check wether the old - new width of the + // panel changed, if so no need to resize the fold panel items - RedisplayFoldPanelItems(); + RedisplayFoldPanelItems(); - // tool panel for icons and other stuff + // tool panel for icons and other stuff #if 0 - wxRect bottomrect = GetRect(); - if(bottomrect.GetHeight() < 22) - bottomrect.SetY(0); - else - bottomrect.SetY(bottomrect.GetHeight() - 22); + wxRect bottomrect = GetRect(); + if(bottomrect.GetHeight() < 22) + bottomrect.SetY(0); + else + bottomrect.SetY(bottomrect.GetHeight() - 22); - bottomrect.SetHeight(22); - bottomrect.SetX(0); - _bottomPanel->SetSize(bottomrect); + bottomrect.SetHeight(22); + bottomrect.SetX(0); + _bottomPanel->SetSize(bottomrect); - // TODO: redraw the bitmap properly - // use the captionbar algorithm for that + // TODO: redraw the bitmap properly + // use the captionbar algorithm for that - _bottomPanel->Refresh(); + _bottomPanel->Refresh(); #endif } void wxFoldPanelBar::OnPaint(wxPaintEvent &event) { - if(!_controlCreated) - return; + if(!_controlCreated) + return; #if 0 - // paint the bottom panel only, where the - // arrow is shown when there is more to show the user - // just as informative icon + // paint the bottom panel only, where the + // arrow is shown when there is more to show the user + // just as informative icon - wxPaintDC dc(_bottomPanel); + wxPaintDC dc(_bottomPanel); - wxSize size = _bottomPanel->GetSize(); - int offset = (size.GetHeight() - _moreBmp->GetHeight()) / 2; + wxSize size = _bottomPanel->GetSize(); + int offset = (size.GetHeight() - _moreBmp->GetHeight()) / 2; - dc.DrawBitmap(*_moreBmp, size.GetWidth() - _moreBmp->GetWidth() - 2, offset, true); + dc.DrawBitmap(*_moreBmp, size.GetWidth() - _moreBmp->GetWidth() - 2, offset, true); #endif - event.Skip(); + event.Skip(); } void wxFoldPanelBar::OnPressCaption(wxCaptionBarEvent &event) { - // act upon the folding or expanding status of the bar - // to expand or collapse the panel(s) - - if(event.GetFoldStatus()) - Collapse(wxFoldPanel((wxFoldPanelItem *)event.GetTag())); - else - Expand(wxFoldPanel((wxFoldPanelItem *)event.GetTag())); + // act upon the folding or expanding status of the bar + // to expand or collapse the panel(s) + + if(event.GetFoldStatus()) + Collapse(wxFoldPanel((wxFoldPanelItem *)event.GetTag())); + else + Expand(wxFoldPanel((wxFoldPanelItem *)event.GetTag())); } void wxFoldPanelBar::RefreshPanelsFrom(wxFoldPanelItem *item) { - wxASSERT(item); + wxASSERT(item); - size_t i = _panels.Index(item); - if(i != wxNOT_FOUND) - RefreshPanelsFrom(i); + size_t i = _panels.Index(item); + if(i != wxNOT_FOUND) + RefreshPanelsFrom(i); } void wxFoldPanelBar::RefreshPanelsFrom(size_t i) { - Freeze(); + Freeze(); - // if collapse to bottom is on, the panels that are not expanded - // should be drawn at the bottom. All panels that are expanded - // are drawn on top. The last expanded panel gets all the extra space + // if collapse to bottom is on, the panels that are not expanded + // should be drawn at the bottom. All panels that are expanded + // are drawn on top. The last expanded panel gets all the extra space - if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM) - { - int offset = 0; - - for(size_t j = 0; j < _panels.GetCount(); j++) - { - if(_panels.Item(j)->IsExpanded()) - offset += _panels.Item(j)->Reposition(offset); - } - - // put all non collapsed panels at the bottom where there is space, else - // put them right behind the expanded ones - - RepositionCollapsedToBottom(); - } - else - { - int y = _panels.Item(i)->GetY() + _panels.Item(i)->GetPanelHeight(); - for(i++; i < _panels.GetCount(); i++) - y += _panels.Item(i)->Reposition(y); - } - Thaw(); + if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM) + { + int offset = 0; + + for(size_t j = 0; j < _panels.GetCount(); j++) + { + if(_panels.Item(j)->IsExpanded()) + offset += _panels.Item(j)->Reposition(offset); + } + + // put all non collapsed panels at the bottom where there is space, else + // put them right behind the expanded ones + + RepositionCollapsedToBottom(); + } + else + { + int y = _panels.Item(i)->GetY() + _panels.Item(i)->GetPanelHeight(); + for(i++; i < _panels.GetCount(); i++) + y += _panels.Item(i)->Reposition(y); + } + Thaw(); } void wxFoldPanelBar::RedisplayFoldPanelItems() { - // resize them all. No need to reposition + // resize them all. No need to reposition - wxFoldPanelItem *item; - for(size_t i = 0; i < _panels.GetCount(); i++) - { - item = _panels.Item(i); - wxASSERT(item); + wxFoldPanelItem *item; + for(size_t i = 0; i < _panels.GetCount(); i++) + { + item = _panels.Item(i); + wxASSERT(item); - item->ResizePanel(); - } + item->ResizePanel(); + } } wxRect wxFoldPanelBar::RepositionCollapsedToBottom() { - wxRect value(0,0,0,0); + wxRect value(0,0,0,0); - // determine wether the number of panels left - // times the size of their captions is enough - // to be placed in the left over space + // determine wether the number of panels left + // times the size of their captions is enough + // to be placed in the left over space - int expanded = 0, collapsed = 0, offset; - GetPanelsHeight(collapsed, expanded); - - // if no room stick them behind the normal ones, else - // at the bottom + int expanded = 0, collapsed = 0, offset; + GetPanelsHeight(collapsed, expanded); - if((GetSize().GetHeight() - expanded - collapsed) < 0) - offset = expanded; - else - { - // value is the region which is left unpainted - // I will send it back as 'slack' so it does not need to - // be recalulated. - - value.SetX(0); - value.SetY(expanded); - value.SetHeight(GetSize().GetHeight() - expanded); - value.SetWidth(GetSize().GetWidth()); + // if no room stick them behind the normal ones, else + // at the bottom - offset = GetSize().GetHeight() - collapsed; - } - + if((GetSize().GetHeight() - expanded - collapsed) < 0) + offset = expanded; + else + { + // value is the region which is left unpainted + // I will send it back as 'slack' so it does not need to + // be recalulated. - // go reposition + value.SetX(0); + value.SetY(expanded); + value.SetHeight(GetSize().GetHeight() - expanded); + value.SetWidth(GetSize().GetWidth()); - for(size_t i = 0; i < _panels.GetCount(); i++) - { - if(!_panels.Item(i)->IsExpanded()) - offset += _panels.Item(i)->Reposition(offset); - } + offset = GetSize().GetHeight() - collapsed; + } - return value; + + // go reposition + + for(size_t i = 0; i < _panels.GetCount(); i++) + { + if(!_panels.Item(i)->IsExpanded()) + offset += _panels.Item(i)->Reposition(offset); + } + + return value; } int wxFoldPanelBar::GetPanelsHeight(int &collapsed, int &expanded) { - int value = 0, offset = 0; - - // assumed here that all the panels that are expanded - // are positioned after eachother from 0,0 to end. - - for(size_t j = 0; j < _panels.GetCount(); j++) - { - offset = _panels.Item(j)->GetPanelHeight(); - value += offset; - if(_panels.Item(j)->IsExpanded()) - expanded += offset; - else - collapsed += offset; - } - - return value; + int value = 0; + + // assumed here that all the panels that are expanded + // are positioned after eachother from 0,0 to end. + + for(size_t j = 0; j < _panels.GetCount(); j++) + { + int offset = _panels.Item(j)->GetPanelHeight(); + value += offset; + if(_panels.Item(j)->IsExpanded()) + expanded += offset; + else + collapsed += offset; + } + + return value; } \ No newline at end of file diff --git a/contrib/src/foldbar/foldpanelitem.cpp b/contrib/src/foldbar/foldpanelitem.cpp index 0b632863ba..6f6897b936 100644 --- a/contrib/src/foldbar/foldpanelitem.cpp +++ b/contrib/src/foldbar/foldpanelitem.cpp @@ -1,8 +1,12 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: wxFoldPanelItem.cpp -// Author: XX -// Created: Tuesday, June 22, 2004 21:01:02 -// Copyright: XX +// Name: foldpanelitem.cpp +// Purpose: +// Author: Jorgen Bodde +// Modified by: +// Created: 22/06/2004 +// RCS-ID: $Id$ +// Copyright: (c) Jorgen Bodde +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". @@ -24,63 +28,63 @@ WX_DEFINE_OBJARRAY(wxFoldWindowItemArray); IMPLEMENT_CLASS( wxFoldPanelItem, wxPanel ) BEGIN_EVENT_TABLE(wxFoldPanelItem,wxPanel) - EVT_CAPTIONBAR(-1, wxFoldPanelItem::OnPressCaption) - EVT_PAINT(wxFoldPanelItem::OnPaint) - //EVT_SIZE(wxFoldPanelItem::OnSize) + EVT_CAPTIONBAR(wxID_ANY, wxFoldPanelItem::OnPressCaption) + EVT_PAINT(wxFoldPanelItem::OnPaint) + //EVT_SIZE(wxFoldPanelItem::OnSize) END_EVENT_TABLE() -wxFoldPanelItem::wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons, bool collapsedInitially, - const wxCaptionBarStyle &style ) - : _controlCreated(false) - , _yUserSize(0) - , _yPanelSize(0) - , _yPos(0) - , _userSized(false) - , _yLastInsertPos(0) +wxFoldPanelItem::wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons, bool collapsedInitially, + const wxCaptionBarStyle &style ) + : _controlCreated(false) + , _yUserSize(0) + , _yPanelSize(0) + , _yPos(0) + , _userSized(false) + , _yLastInsertPos(0) { wxCHECK2(parent, return); - - wxPanel::Create(parent, -1); - - // create the caption bar, in collapsed or expanded state - _captionBar = new wxCaptionBar(this, caption, icons, -1, style, wxPoint(0,0)); - //_captionBar->SetBoldFont(); - - if(collapsedInitially) - _captionBar->Collapse(); - - _controlCreated = true; - - // make initial size for component, if collapsed, the - // size is determined on the panel height and won't change + wxPanel::Create(parent, wxID_ANY); - wxSize size = _captionBar->GetSize(); - _yPanelSize = size.GetHeight(); - _yLastInsertPos = _yPanelSize; + // create the caption bar, in collapsed or expanded state + + _captionBar = new wxCaptionBar(this, caption, icons, wxID_ANY, style, wxPoint(0,0)); + //_captionBar->SetBoldFont(); + + if(collapsedInitially) + _captionBar->Collapse(); + + _controlCreated = true; + + // make initial size for component, if collapsed, the + // size is determined on the panel height and won't change + + wxSize size = _captionBar->GetSize(); + _yPanelSize = size.GetHeight(); + _yLastInsertPos = _yPanelSize; } - + void wxFoldPanelItem::AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing) { - wxASSERT(window); - - wxFoldWindowItem *wi = new wxFoldWindowItem(window, flags, ySpacing, leftSpacing, rightSpacing); - _items.Add(wi); + wxASSERT(window); - window->SetSize(leftSpacing, _yLastInsertPos + ySpacing, -1, -1, wxSIZE_USE_EXISTING); - _yLastInsertPos += wi->GetWindowHeight(); - - ResizePanel(); + wxFoldWindowItem *wi = new wxFoldWindowItem(window, flags, ySpacing, leftSpacing, rightSpacing); + _items.Add(wi); + + window->SetSize(leftSpacing, _yLastInsertPos + ySpacing, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING); + _yLastInsertPos += wi->GetWindowHeight(); + + ResizePanel(); } void wxFoldPanelItem::AddSeparator(const wxColour &color, int ySpacing, int leftSpacing, int rightSpacing) -{ - wxFoldWindowItem *wi = new wxFoldWindowItem(_yLastInsertPos, color, ySpacing, leftSpacing, rightSpacing); - _items.Add(wi); +{ + wxFoldWindowItem *wi = new wxFoldWindowItem(_yLastInsertPos, color, ySpacing, leftSpacing, rightSpacing); + _items.Add(wi); - _yLastInsertPos += wi->GetWindowHeight(); - - ResizePanel(); + _yLastInsertPos += wi->GetWindowHeight(); + + ResizePanel(); } @@ -91,110 +95,110 @@ wxFoldPanelItem::~wxFoldPanelItem() void wxFoldPanelItem::OnPressCaption(wxCaptionBarEvent &event) { - // tell the upper container we are responsible - // for this event, so it can fold the panel item - // and do a refresh + // tell the upper container we are responsible + // for this event, so it can fold the panel item + // and do a refresh - event.SetTag((void *)this); - event.Skip(); + event.SetTag((void *)this); + event.Skip(); } /* Inactive */ void wxFoldPanelItem::OnSize(wxSizeEvent &event) { - // deny access to pointers (yet) + // deny access to pointers (yet) - if(!_controlCreated) - { - event.Skip(); - return; - } + if(!_controlCreated) + { + event.Skip(); + return; + } - // calculate the size needed for this window, so - // we get the parent size, and determine the size for the caption and the panel - - //wxRect rect = GetRect(); + // calculate the size needed for this window, so + // we get the parent size, and determine the size for the caption and the panel - //wxSize size(0,-1); - //size.SetWidth(rect.GetWidth()); - //_captionBar->SetSize(size); + //wxRect rect = GetRect(); + + //wxSize size(0,wxDefaultCoord); + //size.SetWidth(rect.GetWidth()); + //_captionBar->SetSize(size); } int wxFoldPanelItem::Reposition(int y) { - // NOTE: Call Resize before Reposition when an item is added, because the new - // size needed will be calculated by Resize. Ofcourse the relative position - // of the controls have to be correct in respect to the caption bar - - Freeze(); - - SetSize(-1, y, -1, -1, wxSIZE_USE_EXISTING); - _yPos = y; + // NOTE: Call Resize before Reposition when an item is added, because the new + // size needed will be calculated by Resize. Ofcourse the relative position + // of the controls have to be correct in respect to the caption bar - Thaw(); + Freeze(); - return GetPanelHeight(); + SetSize(wxDefaultCoord, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING); + _yPos = y; + + Thaw(); + + return GetPanelHeight(); } void wxFoldPanelItem::ResizePanel() { - // prevent unnecessary updates by blocking repaints for a sec + // prevent unnecessary updates by blocking repaints for a sec - Freeze(); + Freeze(); - // force this panel to take the width of the parent panel and the y of the - // user or calulated width (which will be recalculated by the contents here + // force this panel to take the width of the parent panel and the y of the + // user or calulated width (which will be recalculated by the contents here - wxSize size; - if(_captionBar->IsCollapsed()) - { - size = _captionBar->GetSize(); - _yPanelSize = size.GetHeight(); - } - else - { - size = GetBestSize(); - _yPanelSize = size.GetHeight(); + wxSize size; + if(_captionBar->IsCollapsed()) + { + size = _captionBar->GetSize(); + _yPanelSize = size.GetHeight(); + } + else + { + size = GetBestSize(); + _yPanelSize = size.GetHeight(); - if(_userSized) - size.SetHeight(_yUserSize); - } + if(_userSized) + size.SetHeight(_yUserSize); + } - wxSize pnlsize = GetParent()->GetSize(); - size.SetWidth(pnlsize.GetWidth()); + wxSize pnlsize = GetParent()->GetSize(); + size.SetWidth(pnlsize.GetWidth()); - // resize caption bar - _captionBar->SetSize(wxSize(size.GetWidth(), -1)); - - // resize the panel - SetSize(size); + // resize caption bar + _captionBar->SetSize(wxSize(size.GetWidth(), wxDefaultCoord)); - // go by all the controls and call Layout + // resize the panel + SetSize(size); - for(size_t i = 0; i < _items.GetCount(); i++) - _items.Item(i).ResizeItem(size.GetWidth()); + // go by all the controls and call Layout - // and draw all + for(size_t i = 0; i < _items.GetCount(); i++) + _items.Item(i).ResizeItem(size.GetWidth()); - Thaw(); + // and draw all + + Thaw(); } void wxFoldPanelItem::OnPaint(wxPaintEvent& WXUNUSED(event)) { - // draw all the items that are lines + // draw all the items that are lines - wxPaintDC dc(this); - - for(size_t i = 0; i < _items.GetCount(); i++) - { - wxFoldWindowItem &item = _items.Item(i); - wxPen pen(item.GetLineColour(), 1, wxSOLID); - if(item.GetType() == wxFoldWindowItem::SEPARATOR) - { - dc.SetPen(pen); - dc.DrawLine(item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing(), - item.GetLineWidth() + item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing()); - } - } + wxPaintDC dc(this); + + for(size_t i = 0; i < _items.GetCount(); i++) + { + wxFoldWindowItem &item = _items.Item(i); + wxPen pen(item.GetLineColour(), 1, wxSOLID); + if(item.GetType() == wxFoldWindowItem::SEPARATOR) + { + dc.SetPen(pen); + dc.DrawLine(item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing(), + item.GetLineWidth() + item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing()); + } + } }