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
This commit is contained in:
Włodzimierz Skiba
2004-08-03 14:39:09 +00:00
parent 8fa4d6b87b
commit f857e441bf
11 changed files with 713 additions and 702 deletions

View File

@@ -1,8 +1,11 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: FoldPanelBarTest.cpp // Name: foldpanelbartest.cpp
// Purpose: FoldPanelBarTest Test application // Purpose:
// Created: 06/18/04 // Author: Jorgen Bodde
// Modified by:
// Created: 18/06/2004
// RCS-ID: $Id$
// Copyright: (c) Jorgen Bodde
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -18,8 +21,8 @@
enum enum
{ {
ID_COLLAPSEME = 10000, ID_COLLAPSEME = 10000,
ID_EXPANDME ID_EXPANDME
}; };
#include "wx/foldbar/foldpanelbar.h" #include "wx/foldbar/foldpanelbar.h"
@@ -58,14 +61,14 @@ private:
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(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 OnCollapseMe(wxCommandEvent &event);
void OnExpandMe(wxCommandEvent &event); void OnExpandMe(wxCommandEvent &event);
private: private:
wxMenuBar *CreateMenuBar(); wxMenuBar *CreateMenuBar();
wxFoldPanelBar *_pnl; wxFoldPanelBar *_pnl;
private: private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
@@ -89,8 +92,8 @@ enum
BEGIN_EVENT_TABLE(MyAppFrame, wxFrame) BEGIN_EVENT_TABLE(MyAppFrame, wxFrame)
EVT_MENU(FoldPanelBarTest_Quit, MyAppFrame::OnQuit) EVT_MENU(FoldPanelBarTest_Quit, MyAppFrame::OnQuit)
EVT_MENU(FoldPanelBarTest_About, MyAppFrame::OnAbout) EVT_MENU(FoldPanelBarTest_About, MyAppFrame::OnAbout)
EVT_BUTTON(ID_COLLAPSEME, MyAppFrame::OnCollapseMe) EVT_BUTTON(ID_COLLAPSEME, MyAppFrame::OnCollapseMe)
EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe) EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_APP(MyApp) IMPLEMENT_APP(MyApp)
@@ -108,10 +111,10 @@ bool MyApp::OnInit()
MyAppFrame *frame = new MyAppFrame(_T("FoldPanelBarTest wxWindows Test Application"), MyAppFrame *frame = new MyAppFrame(_T("FoldPanelBarTest wxWindows Test Application"),
wxPoint(50, 50), wxSize(200, 500)); wxPoint(50, 50), wxSize(200, 500));
SetTopWindow(frame); SetTopWindow(frame);
frame->Show(TRUE); frame->Show(true);
return TRUE; return true;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -119,7 +122,7 @@ bool MyApp::OnInit()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
MyAppFrame::MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) 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)); SetIcon(wxICON(mondrian));
@@ -128,53 +131,51 @@ MyAppFrame::MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize&
CreateStatusBar(2); CreateStatusBar(2);
SetStatusText(_T("Welcome to wxWindows!")); SetStatusText(_T("Welcome to wxWindows!"));
_pnl = new wxFoldPanelBar(this, -1, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM); _pnl = new wxFoldPanelBar(this, wxID_ANY, 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"));
item = _pnl->AddFoldPanel("Test me too!", true); wxFoldPanel item = _pnl->AddFoldPanel(_T("Test me"), false);
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_EXPANDME, "Expand first one")); _pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse Me")));
_pnl->AddFoldPanelSeperator(item);
_pnl->AddFoldPanelWindow(item, new FoldTestPanel(item.GetParent(), -1));
_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 wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
_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->AddFoldPanelSeperator(item); 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(), -1, "Check this too if you like")); _pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And also this")));
_pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), -1, "What about 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); item = _pnl->AddFoldPanel(_T("Choose one ..."), false);
_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, "Enter your comment")); _pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter your comment")));
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), -1, "Comment"), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20); _pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
} }
wxMenuBar *MyAppFrame::CreateMenuBar() wxMenuBar *MyAppFrame::CreateMenuBar()
{ {
wxMenuBar *value = 0;
wxMenu *menuFile = new wxMenu; wxMenu *menuFile = new wxMenu;
menuFile->Append(FoldPanelBarTest_Quit, _T("E&xit\tAlt-X"), _T("Quit this program")); menuFile->Append(FoldPanelBarTest_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
wxMenu *helpMenu = new wxMenu; wxMenu *helpMenu = new wxMenu;
helpMenu->Append(FoldPanelBarTest_About, _T("&About...\tF1"), _T("Show about dialog")); 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(menuFile, _T("&File"));
value->Append(helpMenu, _T("&Help")); value->Append(helpMenu, _T("&Help"));
return value; return value;
} }
// event handlers // event handlers
@@ -182,8 +183,8 @@ wxMenuBar *MyAppFrame::CreateMenuBar()
void MyAppFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyAppFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{ {
// TRUE is to force the frame to close // true is to force the frame to close
Close(TRUE); Close(true);
} }
void MyAppFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) 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); 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); wxFoldPanel item = _pnl->Item(0);
_pnl->Collapse(item); _pnl->Collapse(item);
} }
void MyAppFrame::OnExpandMe(wxCommandEvent &event) void MyAppFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event))
{ {
_pnl->Expand(_pnl->Item(0)); _pnl->Expand(_pnl->Item(0));
_pnl->Collapse(_pnl->Item(1)); _pnl->Collapse(_pnl->Item(1));
} }

View File

@@ -1,4 +1,6 @@
mondrian ICON "mondrian.ico" mondrian ICON "sample.ico"
#define FOLDPANELBARTEST_QUIT 1 #define FOLDPANELBARTEST_QUIT 1
#define FOLDPANELBARTEST_ABOUT 102 #define FOLDPANELBARTEST_ABOUT 102
#include "wx/msw/wx.rc"

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: foldtestpanel.cpp // Name: foldtestpanel.cpp
// Purpose: // Purpose:
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: 06/18/04 22:37:15 // Created: 18/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: // Copyright: (c) Jorgen Bodde
// Licence: // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(__APPLE__) #if defined(__GNUG__) && !defined(__APPLE__)
@@ -47,8 +47,8 @@ BEGIN_EVENT_TABLE( FoldTestPanel, wxPanel )
////@begin FoldTestPanel event table entries ////@begin FoldTestPanel event table entries
////@end 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() END_EVENT_TABLE()
@@ -59,7 +59,7 @@ END_EVENT_TABLE()
FoldTestPanel::FoldTestPanel( ) FoldTestPanel::FoldTestPanel( )
{ {
delete _images; delete _images;
} }
FoldTestPanel::FoldTestPanel( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) 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 * 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 ////@begin FoldTestPanel member initialisation
blaat = NULL; blaat = NULL;
@@ -86,7 +86,7 @@ bool FoldTestPanel::Create( wxWindow* parent, wxWindowID id, const wxString& cap
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
Centre(); Centre();
////@end FoldTestPanel creation ////@end FoldTestPanel creation
return TRUE; return true;
} }
/*! /*!
@@ -94,7 +94,7 @@ bool FoldTestPanel::Create( wxWindow* parent, wxWindowID id, const wxString& cap
*/ */
void FoldTestPanel::CreateControls() void FoldTestPanel::CreateControls()
{ {
////@begin FoldTestPanel content construction ////@begin FoldTestPanel content construction
@@ -103,13 +103,13 @@ void FoldTestPanel::CreateControls()
wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
blaat = item2; blaat = item2;
item1->SetSizer(item2); item1->SetSizer(item2);
item1->SetAutoLayout(TRUE); 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|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL ); */
wxPanel* item3 = new wxPanel( item1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL ); wxPanel* item3 = new wxPanel( item1, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
item2->Add(item3, 1, wxGROW|wxADJUST_MINSIZE, 5); item2->Add(item3, 1, wxGROW|wxADJUST_MINSIZE, 5);
wxBoxSizer* item4 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item4 = new wxBoxSizer(wxVERTICAL);
item3->SetSizer(item4); item3->SetSizer(item4);
item3->SetAutoLayout(TRUE); item3->SetAutoLayout(true);
wxString item5Strings[] = { wxString item5Strings[] = {
_("One"), _("One"),
_("Two"), _("Two"),
@@ -120,17 +120,17 @@ void FoldTestPanel::CreateControls()
wxTextCtrl* item6 = new wxTextCtrl( item3, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); wxTextCtrl* item6 = new wxTextCtrl( item3, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
item4->Add(item6, 1, wxGROW|wxALL, 5); item4->Add(item6, 1, wxGROW|wxALL, 5);
wxRadioButton* item7 = new wxRadioButton( item3, ID_RADIOBUTTON, _("I like this"), wxDefaultPosition, wxDefaultSize, 0 ); 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); item4->Add(item7, 0, wxALIGN_LEFT|wxALL, 5);
wxRadioButton* item8 = new wxRadioButton( item3, ID_RADIOBUTTON1, _("I hate it"), wxDefaultPosition, wxDefaultSize, 0 ); 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); item4->Add(item8, 0, wxALIGN_LEFT|wxALL, 5);
////@end FoldTestPanel content construction ////@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() bool FoldTestPanel::ShowToolTips()
{ {
return TRUE; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
wxBitmap FoldTestPanel::GetBitmapResource( const wxString& name ) wxBitmap FoldTestPanel::GetBitmapResource( const wxString& WXUNUSED(name) )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin FoldTestPanel bitmap retrieval ////@begin FoldTestPanel bitmap retrieval
@@ -158,7 +158,7 @@ wxBitmap FoldTestPanel::GetBitmapResource( const wxString& name )
* Get icon resources * Get icon resources
*/ */
wxIcon FoldTestPanel::GetIconResource( const wxString& name ) wxIcon FoldTestPanel::GetIconResource( const wxString& WXUNUSED(name) )
{ {
// Icon retrieval // Icon retrieval
////@begin FoldTestPanel icon retrieval ////@begin FoldTestPanel icon retrieval

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: foldtestpanel.h // Name: foldtestpanel.h
// Purpose: // Purpose:
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: 06/18/04 22:37:15 // Created: 18/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: // Copyright: (c) Jorgen Bodde
// Licence: // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _FOLDTESTPANEL_H_ #ifndef _FOLDTESTPANEL_H_
@@ -67,15 +67,15 @@ class wxBoxSizer;
*/ */
class FoldTestPanel: public wxPanel class FoldTestPanel: public wxPanel
{ {
DECLARE_CLASS( FoldTestPanel ) DECLARE_CLASS( FoldTestPanel )
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
private: private:
wxImageList *_images; wxImageList *_images;
wxRect _oldsize; wxRect _oldsize;
void OnCaptionPanel(wxCaptionBarEvent &event); void OnCaptionPanel(wxCaptionBarEvent &event);
public: public:
/// Constructors /// Constructors

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: layouttest.cpp // Name: layouttest.cpp
// Purpose: // Purpose:
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: 06/25/04 19:48:57 // Created: 25/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: // Copyright: (c) Jorgen Bodde
// Licence: // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(__APPLE__) #if defined(__GNUG__) && !defined(__APPLE__)
@@ -66,7 +66,7 @@ LayoutTest::LayoutTest( wxWindow* parent, wxWindowID id, const wxString& caption
* LayoutTest creator * 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 ////@begin LayoutTest member initialisation
////@end LayoutTest member initialisation ////@end LayoutTest member initialisation
@@ -80,7 +80,7 @@ bool LayoutTest::Create( wxWindow* parent, wxWindowID id, const wxString& captio
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
Centre(); Centre();
////@end LayoutTest creation ////@end LayoutTest creation
return TRUE; return true;
} }
/*! /*!
@@ -88,14 +88,14 @@ bool LayoutTest::Create( wxWindow* parent, wxWindowID id, const wxString& captio
*/ */
void LayoutTest::CreateControls() void LayoutTest::CreateControls()
{ {
////@begin LayoutTest content construction ////@begin LayoutTest content construction
LayoutTest* item1 = this; LayoutTest* item1 = this;
wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item2 = new wxBoxSizer(wxVERTICAL);
item1->SetSizer(item2); item1->SetSizer(item2);
item1->SetAutoLayout(TRUE); item1->SetAutoLayout(true);
wxStaticText* item3 = new wxStaticText( item1, wxID_STATIC, _("lbaaaaaa"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* item3 = new wxStaticText( item1, wxID_STATIC, _("lbaaaaaa"), wxDefaultPosition, wxDefaultSize, 0 );
item3->SetBackgroundColour(wxColour(139, 139, 139)); item3->SetBackgroundColour(wxColour(139, 139, 139));
item2->Add(item3, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5); item2->Add(item3, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5);
@@ -103,7 +103,7 @@ void LayoutTest::CreateControls()
item2->Add(item4, 0, wxGROW, 5); item2->Add(item4, 0, wxGROW, 5);
wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item5 = new wxBoxSizer(wxVERTICAL);
item4->SetSizer(item5); item4->SetSizer(item5);
item4->SetAutoLayout(TRUE); item4->SetAutoLayout(true);
wxStaticText* item6 = new wxStaticText( item4, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* item6 = new wxStaticText( item4, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 );
item5->Add(item6, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5); item5->Add(item6, 0, wxALIGN_LEFT|wxALL|wxADJUST_MINSIZE, 5);
wxButton* item7 = new wxButton( item4, ID_BUTTON, _("Button"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* item7 = new wxButton( item4, ID_BUTTON, _("Button"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -117,14 +117,14 @@ void LayoutTest::CreateControls()
bool LayoutTest::ShowToolTips() bool LayoutTest::ShowToolTips()
{ {
return TRUE; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
wxBitmap LayoutTest::GetBitmapResource( const wxString& name ) wxBitmap LayoutTest::GetBitmapResource( const wxString& WXUNUSED(name) )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin LayoutTest bitmap retrieval ////@begin LayoutTest bitmap retrieval
@@ -136,7 +136,7 @@ wxBitmap LayoutTest::GetBitmapResource( const wxString& name )
* Get icon resources * Get icon resources
*/ */
wxIcon LayoutTest::GetIconResource( const wxString& name ) wxIcon LayoutTest::GetIconResource( const wxString& WXUNUSED(name) )
{ {
// Icon retrieval // Icon retrieval
////@begin LayoutTest icon retrieval ////@begin LayoutTest icon retrieval

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: layouttest.h // Name: layouttest.h
// Purpose: // Purpose:
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: 06/25/04 19:48:57 // Created: 25/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: // Copyright: (c) Jorgen Bodde
// Licence: // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _LAYOUTTEST_H_ #ifndef _LAYOUTTEST_H_
@@ -61,7 +61,7 @@
*/ */
class LayoutTest: public wxPanel class LayoutTest: public wxPanel
{ {
DECLARE_CLASS( LayoutTest ) DECLARE_CLASS( LayoutTest )
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: test.cpp // Name: test.cpp
// Purpose: // Purpose:
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: 06/27/04 13:34:20 // Created: 27/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: // Copyright: (c) Jorgen Bodde
// Licence: // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(__APPLE__) #if defined(__GNUG__) && !defined(__APPLE__)
@@ -82,7 +82,7 @@ bool TestTest::Create( wxWindow* parent, wxWindowID id, const wxString& caption,
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints(this);
Centre(); Centre();
////@end TestTest creation ////@end TestTest creation
return TRUE; return true;
} }
/*! /*!
@@ -90,7 +90,7 @@ bool TestTest::Create( wxWindow* parent, wxWindowID id, const wxString& caption,
*/ */
void TestTest::CreateControls() void TestTest::CreateControls()
{ {
////@begin TestTest content construction ////@begin TestTest content construction
TestTest* item1 = this; TestTest* item1 = this;
@@ -99,19 +99,19 @@ void TestTest::CreateControls()
item2->AddGrowableRow(0); item2->AddGrowableRow(0);
item2->AddGrowableCol(0); item2->AddGrowableCol(0);
item1->SetSizer(item2); item1->SetSizer(item2);
item1->SetAutoLayout(TRUE); item1->SetAutoLayout(true);
wxPanel* item3 = new wxPanel( item1, ID_PANEL7, wxDefaultPosition, wxSize(100, 50), wxNO_BORDER|wxTAB_TRAVERSAL ); wxPanel* item3 = new wxPanel( item1, ID_PANEL7, wxDefaultPosition, wxSize(100, 50), wxNO_BORDER|wxTAB_TRAVERSAL );
item2->Add(item3, 1, wxGROW|wxGROW|wxADJUST_MINSIZE, 5); item2->Add(item3, 1, wxGROW|wxGROW|wxADJUST_MINSIZE, 5);
wxBoxSizer* item4 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item4 = new wxBoxSizer(wxVERTICAL);
item3->SetSizer(item4); 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 ); 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); item4->Add(item5, 1, wxGROW|wxALL|wxADJUST_MINSIZE, 5);
wxFlexGridSizer* item6 = new wxFlexGridSizer(2, 1, 0, 0); wxFlexGridSizer* item6 = new wxFlexGridSizer(2, 1, 0, 0);
item6->AddGrowableRow(1); item6->AddGrowableRow(1);
item6->AddGrowableCol(0); item6->AddGrowableCol(0);
item5->SetSizer(item6); item5->SetSizer(item6);
item5->SetAutoLayout(TRUE); item5->SetAutoLayout(true);
wxStaticText* item7 = new wxStaticText( item5, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* item7 = new wxStaticText( item5, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 );
item6->Add(item7, 0, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxALL|wxADJUST_MINSIZE, 5); 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 ); 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); wxBoxSizer* item9 = new wxBoxSizer(wxVERTICAL);
blaat = item9; blaat = item9;
item8->SetSizer(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 ); wxPanel* item10 = new wxPanel( item8, ID_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL );
item9->Add(item10, 1, wxGROW, 5); item9->Add(item10, 1, wxGROW, 5);
wxBoxSizer* item11 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item11 = new wxBoxSizer(wxVERTICAL);
item10->SetSizer(item11); item10->SetSizer(item11);
item10->SetAutoLayout(TRUE); item10->SetAutoLayout(true);
wxString item12Strings[] = { wxString item12Strings[] = {
_("One"), _("One"),
_("Two"), _("Two"),
@@ -133,10 +133,10 @@ void TestTest::CreateControls()
wxChoice* item12 = new wxChoice( item10, ID_CHOICE, wxDefaultPosition, wxDefaultSize, 3, item12Strings, 0 ); wxChoice* item12 = new wxChoice( item10, ID_CHOICE, wxDefaultPosition, wxDefaultSize, 3, item12Strings, 0 );
item11->Add(item12, 0, wxGROW|wxALL, 5); item11->Add(item12, 0, wxGROW|wxALL, 5);
wxRadioButton* item13 = new wxRadioButton( item10, ID_RADIOBUTTON, _("I like this"), wxDefaultPosition, wxDefaultSize, 0 ); 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); item11->Add(item13, 0, wxALIGN_LEFT|wxALL, 5);
wxRadioButton* item14 = new wxRadioButton( item10, ID_RADIOBUTTON1, _("I hate it"), wxDefaultPosition, wxDefaultSize, 0 ); 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); 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 ); 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); item4->Add(item15, 1, wxGROW|wxALL|wxADJUST_MINSIZE, 5);
@@ -144,7 +144,7 @@ void TestTest::CreateControls()
item16->AddGrowableRow(1); item16->AddGrowableRow(1);
item16->AddGrowableCol(0); item16->AddGrowableCol(0);
item15->SetSizer(item16); item15->SetSizer(item16);
item15->SetAutoLayout(TRUE); item15->SetAutoLayout(true);
wxStaticText* item17 = new wxStaticText( item15, wxID_STATIC, _("Static text"), wxDefaultPosition, wxDefaultSize, 0 ); 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); 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 ); 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); wxBoxSizer* item19 = new wxBoxSizer(wxVERTICAL);
blaat = item19; blaat = item19;
item18->SetSizer(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 ); wxPanel* item20 = new wxPanel( item18, ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL );
item19->Add(item20, 1, wxGROW, 5); item19->Add(item20, 1, wxGROW, 5);
wxBoxSizer* item21 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* item21 = new wxBoxSizer(wxVERTICAL);
item20->SetSizer(item21); item20->SetSizer(item21);
item20->SetAutoLayout(TRUE); item20->SetAutoLayout(true);
wxString item22Strings[] = { wxString item22Strings[] = {
_("One"), _("One"),
_("Two"), _("Two"),
@@ -166,10 +166,10 @@ void TestTest::CreateControls()
wxChoice* item22 = new wxChoice( item20, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 3, item22Strings, 0 ); wxChoice* item22 = new wxChoice( item20, ID_CHOICE1, wxDefaultPosition, wxDefaultSize, 3, item22Strings, 0 );
item21->Add(item22, 0, wxGROW|wxALL, 5); item21->Add(item22, 0, wxGROW|wxALL, 5);
wxRadioButton* item23 = new wxRadioButton( item20, ID_RADIOBUTTON2, _("I like this"), wxDefaultPosition, wxDefaultSize, 0 ); 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); item21->Add(item23, 0, wxALIGN_LEFT|wxALL, 5);
wxRadioButton* item24 = new wxRadioButton( item20, ID_RADIOBUTTON3, _("I hate it"), wxDefaultPosition, wxDefaultSize, 0 ); 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); item21->Add(item24, 0, wxALIGN_LEFT|wxALL, 5);
wxPanel* item25 = new wxPanel( item1, ID_PANEL1, wxDefaultPosition, wxSize(100, 20), wxNO_BORDER|wxTAB_TRAVERSAL ); wxPanel* item25 = new wxPanel( item1, ID_PANEL1, wxDefaultPosition, wxSize(100, 20), wxNO_BORDER|wxTAB_TRAVERSAL );
item25->SetBackgroundColour(wxColour(98, 98, 98)); item25->SetBackgroundColour(wxColour(98, 98, 98));
@@ -183,14 +183,14 @@ void TestTest::CreateControls()
bool TestTest::ShowToolTips() bool TestTest::ShowToolTips()
{ {
return TRUE; return true;
} }
/*! /*!
* Get bitmap resources * Get bitmap resources
*/ */
wxBitmap TestTest::GetBitmapResource( const wxString& name ) wxBitmap TestTest::GetBitmapResource( const wxString& WXUNUSED(name) )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin TestTest bitmap retrieval ////@begin TestTest bitmap retrieval
@@ -202,7 +202,7 @@ wxBitmap TestTest::GetBitmapResource( const wxString& name )
* Get icon resources * Get icon resources
*/ */
wxIcon TestTest::GetIconResource( const wxString& name ) wxIcon TestTest::GetIconResource( const wxString& WXUNUSED(name) )
{ {
// Icon retrieval // Icon retrieval
////@begin TestTest icon retrieval ////@begin TestTest icon retrieval

View File

@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: test.h // Name: test.h
// Purpose: // Purpose:
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: 06/27/04 13:34:20 // Created: 27/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: // Copyright: (c) Jorgen Bodde
// Licence: // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef _TEST_H_ #ifndef _TEST_H_
@@ -74,7 +74,7 @@ class wxBoxSizer;
*/ */
class TestTest: public wxDialog class TestTest: public wxDialog
{ {
DECLARE_CLASS( TestTest ) DECLARE_CLASS( TestTest )
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -3,8 +3,8 @@
// Purpose: wxCaptionBar class belonging to the wxFoldPanel (but can be used independent) // Purpose: wxCaptionBar class belonging to the wxFoldPanel (but can be used independent)
// Author: Jorgen Bodde // Author: Jorgen Bodde
// Modified by: // Modified by:
// Created: June 18, 2004 // Created: 18/06/2004
// RCS-ID: // RCS-ID: $Id$
// Copyright: (c) Jorgen Bodde // Copyright: (c) Jorgen Bodde
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@@ -37,29 +37,29 @@ BEGIN_EVENT_TABLE(wxCaptionBar, wxWindow)
EVT_PAINT(wxCaptionBar::OnPaint) EVT_PAINT(wxCaptionBar::OnPaint)
EVT_CHAR(wxCaptionBar::OnChar) EVT_CHAR(wxCaptionBar::OnChar)
EVT_MOUSE_EVENTS(wxCaptionBar::OnMouseEvent) EVT_MOUSE_EVENTS(wxCaptionBar::OnMouseEvent)
EVT_SIZE(wxCaptionBar::OnSize) EVT_SIZE(wxCaptionBar::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxCaptionBar::wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images, wxWindowID id, wxCaptionBar::wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images, wxWindowID id,
const wxCaptionBarStyle &cbstyle, const wxPoint& pos, const wxSize& size, long style) const wxCaptionBarStyle &cbstyle, const wxPoint& pos, const wxSize& size, long style)
: wxWindow(parent, id, pos, size, style) : wxWindow(parent, id, pos, size, style)
, _caption(caption) , _caption(caption)
, _collapsed(false) , _collapsed(false)
, _foldIcons(images) , _foldIcons(images)
, _rightIndent(wxFPB_BMP_RIGHTSPACE) , _rightIndent(wxFPB_BMP_RIGHTSPACE)
, _iconWidth(16) , _iconWidth(16)
, _iconHeight(16) , _iconHeight(16)
{ {
// do initialisy thingy stuff // do initialisy thingy stuff
ApplyCaptionStyle(cbstyle, true);
// set initial size ApplyCaptionStyle(cbstyle, true);
if(_foldIcons)
{ // set initial size
wxASSERT(_foldIcons->GetImageCount() > 1); if(_foldIcons)
_foldIcons->GetSize(0, _iconWidth, _iconHeight); {
} wxASSERT(_foldIcons->GetImageCount() > 1);
_foldIcons->GetSize(0, _iconWidth, _iconHeight);
}
} }
wxCaptionBar::~wxCaptionBar() wxCaptionBar::~wxCaptionBar()
@@ -69,323 +69,323 @@ wxCaptionBar::~wxCaptionBar()
void wxCaptionBar::ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool applyDefault) void wxCaptionBar::ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool applyDefault)
{ {
wxASSERT(GetParent()); wxASSERT(GetParent());
wxCaptionBarStyle newstyle = cbstyle; 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);
}
// get text colour // set defaults in newly created style copy if needed
if(!newstyle.CaptionColourUsed()) if(applyDefault)
newstyle.SetCaptionColour(*wxBLACK); {
// get first colour from style or make it default
if(!newstyle.FirstColourUsed())
newstyle.SetFirstColour(*wxWHITE);
// get font colour // get second colour from style or make it default
if(!newstyle.CaptionFontUsed()) if(!newstyle.SecondColourUsed())
newstyle.SetCaptionFont(GetParent()->GetFont()); {
// 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 // get text colour
if(!newstyle.CaptionStyleUsed()) if(!newstyle.CaptionColourUsed())
newstyle.SetCaptionStyle(wxCAPTIONBAR_GRADIENT_V); newstyle.SetCaptionColour(*wxBLACK);
}
// apply the style // get font colour
_style = newstyle; 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)) 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 // 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 // caption. This way a flickering arrow during resize is not visible
// draw basics // draw basics
FillCaptionBackground(dc); FillCaptionBackground(dc);
dc.SetFont(_style.GetCaptionFont()); dc.SetFont(_style.GetCaptionFont());
dc.DrawText(_caption, 4, (wxFPB_EXTRA_Y / 2)); dc.DrawText(_caption, 4, (wxFPB_EXTRA_Y / 2));
// draw small icon, either collapsed or expanded // draw small icon, either collapsed or expanded
// based on the state of the bar. If we have // based on the state of the bar. If we have
// any bmp's // any bmp's
if(_foldIcons) if(_foldIcons)
{ {
wxCHECK2(_foldIcons->GetImageCount() > 1, return); wxCHECK2(_foldIcons->GetImageCount() > 1, return);
int index = 0; int index = 0;
if(_collapsed) if(_collapsed)
index = 1; index = 1;
wxRect wndRect = GetRect(); wxRect wndRect = GetRect();
_foldIcons->Draw(index, dc, wndRect.GetRight() - _iconWidth - _rightIndent, (wndRect.GetHeight() - _iconHeight) / 2, _foldIcons->Draw(index, dc, wndRect.GetRight() - _iconWidth - _rightIndent, (wndRect.GetHeight() - _iconHeight) / 2,
wxIMAGELIST_DRAW_TRANSPARENT); wxIMAGELIST_DRAW_TRANSPARENT);
} }
} }
void wxCaptionBar::FillCaptionBackground(wxPaintDC &dc) void wxCaptionBar::FillCaptionBackground(wxPaintDC &dc)
{ {
// dispatch right style for caption drawing // dispatch right style for caption drawing
switch(_style.GetCaptionStyle()) switch(_style.GetCaptionStyle())
{ {
case wxCAPTIONBAR_GRADIENT_V: case wxCAPTIONBAR_GRADIENT_V:
DrawVerticalGradient(dc, GetRect()); DrawVerticalGradient(dc, GetRect());
break; break;
case wxCAPTIONBAR_GRADIENT_H: case wxCAPTIONBAR_GRADIENT_H:
DrawHorizontalGradient(dc, GetRect()); DrawHorizontalGradient(dc, GetRect());
break; break;
case wxCAPTIONBAR_SINGLE: case wxCAPTIONBAR_SINGLE:
DrawSingleColour(dc, GetRect()); DrawSingleColour(dc, GetRect());
break; break;
case wxCAPTIONBAR_RECTANGLE: case wxCAPTIONBAR_RECTANGLE:
case wxCAPTIONBAR_FILLED_RECTANGLE: case wxCAPTIONBAR_FILLED_RECTANGLE:
DrawSingleRectangle(dc, GetRect()); DrawSingleRectangle(dc, GetRect());
break; break;
default: default:
break; break;
} }
} }
void wxCaptionBar::OnMouseEvent(wxMouseEvent& event) void wxCaptionBar::OnMouseEvent(wxMouseEvent& event)
{ {
// if clicked on the arrow (single) or double on the caption // if clicked on the arrow (single) or double on the caption
// we change state and an event must be fired to let this // we change state and an event must be fired to let this
// panel collapse or expand // panel collapse or expand
bool send_event = false; bool send_event = false;
if (event.LeftDown() && _foldIcons) if (event.LeftDown() && _foldIcons)
{ {
wxPoint pt(event.GetPosition()); wxPoint pt(event.GetPosition());
wxRect rect = GetRect(); wxRect rect = GetRect();
if(pt.x > (rect.GetWidth() - _iconWidth - _rightIndent)) if(pt.x > (rect.GetWidth() - _iconWidth - _rightIndent))
send_event = true; send_event = true;
} }
else if(event.LeftDClick()) else if(event.LeftDClick())
send_event = true; send_event = true;
// send the collapse, expand event to the parent // send the collapse, expand event to the parent
if(send_event) if(send_event)
{ {
wxCaptionBarEvent event(wxEVT_CAPTIONBAR); wxCaptionBarEvent event(wxEVT_CAPTIONBAR);
event.SetBar(this); event.SetBar(this);
::wxPostEvent(this, event); ::wxPostEvent(this, event);
} }
} }
void wxCaptionBar::OnChar(wxKeyEvent &event) void wxCaptionBar::OnChar(wxKeyEvent &event)
{ {
// TODO: Anything here? // TODO: Anything here?
event.Skip(); event.Skip();
} }
wxSize wxCaptionBar::DoGetBestSize() const wxSize wxCaptionBar::DoGetBestSize() const
{ {
int x,y; int x,y;
GetTextExtent(_caption, &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
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 ) 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) if(rect.height < 1 || rect.width < 1)
return; 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, // calculate gradient coefficients
gstep = double((col2.Green() - col1.Green())) / double(rect.height), gf = 0, wxColour col2 = _style.GetSecondColour(),
bstep = double((col2.Blue() - col1.Blue())) / double(rect.height), bf = 0; col1 = _style.GetFirstColour();
wxColour currCol; double rstep = double((col2.Red() - col1.Red())) / double(rect.height), rf = 0,
for(int y = rect.y; y < rect.y + rect.height; y++) gstep = double((col2.Green() - col1.Green())) / double(rect.height), gf = 0,
{ bstep = double((col2.Blue() - col1.Blue())) / double(rect.height), bf = 0;
currCol.Set(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf);
dc.SetBrush( wxBrush( currCol, wxSOLID ) ); wxColour currCol;
dc.DrawRectangle( rect.x, rect.y + (y - rect.y), rect.width, rect.height ); for(int y = rect.y; y < rect.y + rect.height; y++)
//currCol.Set(currCol.Red() + rstep, currCol.Green() + gstep, currCol.Blue() + bstep); {
rf += rstep; gf += gstep; bf += bstep; 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 ) 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) if(rect.height < 1 || rect.width < 1)
return; 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.width), rf = 0, // calculate gradient coefficients
gstep = double((col2.Green() - col1.Green())) / double(rect.width), gf = 0, wxColour col2 = _style.GetSecondColour(),
bstep = double((col2.Blue() - col1.Blue())) / double(rect.width), bf = 0; col1 = _style.GetFirstColour();
wxColour currCol; double rstep = double((col2.Red() - col1.Red())) / double(rect.width), rf = 0,
for(int x = rect.x; x < rect.x + rect.width; x++) gstep = double((col2.Green() - col1.Green())) / double(rect.width), gf = 0,
{ bstep = double((col2.Blue() - col1.Blue())) / double(rect.width), bf = 0;
currCol.Set(col1.Red() + rf, col1.Green() + gf, col1.Blue() + bf);
dc.SetBrush( wxBrush( currCol, wxSOLID ) ); wxColour currCol;
dc.DrawRectangle( rect.x + (x - rect.x), rect.y, 1, rect.height ); for(int x = rect.x; x < rect.x + rect.width; x++)
rf += rstep; gf += gstep; bf += bstep; {
} 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 ) 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) if(rect.height < 1 || rect.width < 1)
return; return;
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
// draw simple rectangle // draw simple rectangle
dc.SetBrush( wxBrush( _style.GetFirstColour(), wxSOLID ) ); dc.SetBrush( wxBrush( _style.GetFirstColour(), wxSOLID ) );
dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height ); dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height );
} }
void wxCaptionBar::DrawSingleRectangle(wxDC &dc, const wxRect &rect ) void wxCaptionBar::DrawSingleRectangle(wxDC &dc, const wxRect &rect )
{ {
wxASSERT(GetParent()); wxASSERT(GetParent());
// single colour fill. This is the most easy one to find
if(rect.height < 2 || rect.width < 1) // single colour fill. This is the most easy one to find
return;
// single frame, set up internal fill colour if(rect.height < 2 || rect.width < 1)
return;
wxBrush br;
br.SetStyle(wxSOLID);
if(_style.GetCaptionStyle() == wxCAPTIONBAR_RECTANGLE) // single frame, set up internal fill colour
br.SetColour(GetParent()->GetBackgroundColour());
else
br.SetColour(_style.GetFirstColour());
// setup the pen frame wxBrush br;
br.SetStyle(wxSOLID);
wxPen pen(_style.GetSecondColour()); if(_style.GetCaptionStyle() == wxCAPTIONBAR_RECTANGLE)
dc.SetPen(pen); br.SetColour(GetParent()->GetBackgroundColour());
else
dc.SetBrush( br ); br.SetColour(_style.GetFirstColour());
dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height - 1);
// setup the pen frame
wxPen bgpen(GetParent()->GetBackgroundColour());
dc.SetPen(bgpen); wxPen pen(_style.GetSecondColour());
dc.DrawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width, rect.y + rect.height - 1); 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) void wxCaptionBar::OnSize(wxSizeEvent &event)
{ {
wxSize size = event.GetSize(); wxSize size = event.GetSize();
if(_foldIcons) if(_foldIcons)
{ {
// What I am doing here is simply invalidating the part of the window exposed. So when I // 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, // 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 // 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 // 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, wxRect rect(size.GetWidth() - _iconWidth - _rightIndent, 0, _iconWidth + _rightIndent,
_iconWidth + _rightIndent); _iconWidth + _rightIndent);
// adjust rectangle when more is slided so we need to redraw all // adjust rectangle when more is slided so we need to redraw all
// the old stuff but not all (ugly flickering) // the old stuff but not all (ugly flickering)
int diffX = size.GetWidth() - _oldSize.GetWidth(); int diffX = size.GetWidth() - _oldSize.GetWidth();
if(diffX > 1) if(diffX > 1)
{ {
// adjust the rect with all the crap to redraw // adjust the rect with all the crap to redraw
rect.SetWidth(rect.GetWidth() + diffX + 10); rect.SetWidth(rect.GetWidth() + diffX + 10);
rect.SetX(rect.GetX() - diffX - 10); rect.SetX(rect.GetX() - diffX - 10);
} }
RefreshRect(rect); RefreshRect(rect);
} }
else else
{ {
wxRect rect = GetRect(); wxRect rect = GetRect();
RefreshRect(rect); RefreshRect(rect);
} }
_oldSize = size; _oldSize = size;
} }
void wxCaptionBar::RedrawIconBitmap() void wxCaptionBar::RedrawIconBitmap()
{ {
if(_foldIcons) if(_foldIcons)
{ {
// invalidate the bitmap area and force a redraw // invalidate the bitmap area and force a redraw
wxRect rect = GetRect(); wxRect rect = GetRect();
rect.SetX(rect.GetWidth() - _iconWidth - _rightIndent); rect.SetX(rect.GetWidth() - _iconWidth - _rightIndent);
rect.SetWidth(_iconWidth + _rightIndent); rect.SetWidth(_iconWidth + _rightIndent);
RefreshRect(rect); RefreshRect(rect);
} }
} }
/* /*
* wxCaptionBarEvent * wxCaptionBarEvent
*/ */
DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR) DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR)
wxCaptionBarEvent::wxCaptionBarEvent(const wxCaptionBarEvent &event) wxCaptionBarEvent::wxCaptionBarEvent(const wxCaptionBarEvent &event)
: wxCommandEvent(event) : wxCommandEvent(event)
{ {
_bar = event._bar; _bar = event._bar;
} }
//DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR) //DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR)
//IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxEvent) //IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxEvent)
IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxCaptionBarEvent, wxCommandEvent)

View File

@@ -1,8 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wxFoldPanelBar.cpp // Name: foldpanelbar.cpp
// Author: XX // Purpose:
// Created: Tuesday, June 22, 2004 20:40:00 // Author: Jorgen Bodde
// Copyright: XX // 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". // For compilers that support precompilation, includes "wx/wx.h".
@@ -24,9 +28,9 @@
IMPLEMENT_CLASS( wxFoldPanelBar, wxPanel ) IMPLEMENT_CLASS( wxFoldPanelBar, wxPanel )
BEGIN_EVENT_TABLE(wxFoldPanelBar,wxPanel) BEGIN_EVENT_TABLE(wxFoldPanelBar,wxPanel)
EVT_SIZE(wxFoldPanelBar::OnSizePanel) EVT_SIZE(wxFoldPanelBar::OnSizePanel)
//EVT_PAINT(wxFoldPanelBar::OnPaint) //EVT_PAINT(wxFoldPanelBar::OnPaint)
EVT_CAPTIONBAR(-1, wxFoldPanelBar::OnPressCaption) EVT_CAPTIONBAR(wxID_ANY, wxFoldPanelBar::OnPressCaption)
END_EVENT_TABLE() END_EVENT_TABLE()
wxFoldPanelBar::wxFoldPanelBar() wxFoldPanelBar::wxFoldPanelBar()
@@ -34,313 +38,313 @@ wxFoldPanelBar::wxFoldPanelBar()
} }
wxFoldPanelBar::wxFoldPanelBar( wxWindow *parent, wxWindowID id, const wxPoint &position, wxFoldPanelBar::wxFoldPanelBar( wxWindow *parent, wxWindowID id, const wxPoint &position,
const wxSize& size, long style, long extraStyle) const wxSize& size, long style, long extraStyle)
: _foldPanel(0) : _foldPanel(0)
, _bottomPanel(0) , _bottomPanel(0)
, _controlCreated(false) , _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, void wxFoldPanelBar::Create( wxWindow *parent, wxWindowID id, const wxPoint &position,
const wxSize& size, long style, long extraStyle ) 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 _extraStyle = extraStyle;
_foldPanel = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL); // create the panel (duh!). This causes a size event, which we are going
// to skip when we are not initialised
// the extra area for some icons / context menu etc
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 #if 0
_bottomPanel = new wxPanel(this, -1, wxDefaultPosition, wxSize(-1,22), wxNO_BORDER|wxTAB_TRAVERSAL); _bottomPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(wxDefaultCoord,22), wxNO_BORDER|wxTAB_TRAVERSAL);
_bottomPanel->SetBackgroundColour(*wxWHITE); _bottomPanel->SetBackgroundColour(*wxWHITE);
#endif #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); _images = new wxImageList(16, 16);
wxBitmap *bmp = new wxBitmap(icon_expanded);
_images->Add(*bmp);
delete bmp;
bmp = new wxBitmap(icon_collapsed); wxBitmap *bmp = new wxBitmap(icon_expanded);
_images->Add(*bmp); _images->Add(*bmp);
delete 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 _moreBmp = new wxBitmap(icon_theresmore);
_controlCreated = true; // do this as last, to check if create is already called
_controlCreated = true;
} }
wxFoldPanelBar::~wxFoldPanelBar() wxFoldPanelBar::~wxFoldPanelBar()
{ {
delete _images; delete _images;
delete _moreBmp; delete _moreBmp;
} }
wxFoldPanel wxFoldPanelBar::AddFoldPanel(const wxString &caption, bool collapsedInitially, const wxCaptionBarStyle &style) 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. // create a fold panel item, which is first only the caption.
// the user can now add a panel area which will be folded in // the user can now add a panel area which will be folded in
// when pressed. // when pressed.
wxFoldPanelItem *item = new wxFoldPanelItem(_foldPanel, caption, _images, collapsedInitially, style); 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();
item->Reposition(y); // look at the last added one and reposition this one
_panels.Add(item); int y = 0;
if(_panels.GetCount() > 0)
y = _panels.Last()->GetY() + _panels.Last()->GetPanelHeight();
//return wxFoldPanel(item); item->Reposition(y);
return wxFoldPanel(item); _panels.Add(item);
//return wxFoldPanel(item);
return wxFoldPanel(item);
} }
int wxFoldPanelBar::AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags, int ySpacing, int leftSpacing, int wxFoldPanelBar::AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags, int ySpacing, int leftSpacing,
int rightSpacing) int rightSpacing)
{ {
wxCHECK(panel.IsOk(), -1); wxCHECK(panel.IsOk(), -1);
panel.GetItem()->AddWindow(window, flags, ySpacing, leftSpacing, rightSpacing); panel.GetItem()->AddWindow(window, flags, ySpacing, leftSpacing, rightSpacing);
// TODO: Take old and new height, and if difference, reposition all the lower panels // 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 // this is because the user can add new wxWindow controls somewhere in between
// when other panels are already present. // when other panels are already present.
return 0; return 0;
} }
int wxFoldPanelBar::AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color, int ySpacing, int leftSpacing, int wxFoldPanelBar::AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color, int ySpacing, int leftSpacing,
int rightSpacing) int rightSpacing)
{ {
wxCHECK(panel.IsOk(), -1); wxCHECK(panel.IsOk(), -1);
panel.GetItem()->AddSeparator(color, ySpacing, leftSpacing, rightSpacing); panel.GetItem()->AddSeparator(color, ySpacing, leftSpacing, rightSpacing);
return 0; return 0;
} }
void wxFoldPanelBar::OnSizePanel(wxSizeEvent &event) 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) if(!_controlCreated)
{ {
event.Skip(); event.Skip();
return; return;
} }
// now size the fold panel area and the // now size the fold panel area and the
// lower bar in such a way that the bar is always // lower bar in such a way that the bar is always
// visible // visible
wxRect foldrect = GetRect(); wxRect foldrect = GetRect();
// fold panel itself. If too little space, // fold panel itself. If too little space,
// don't show it // don't show it
#if 0 #if 0
if(foldrect.GetHeight() < 23) if(foldrect.GetHeight() < 23)
foldrect.SetHeight(0); foldrect.SetHeight(0);
else else
foldrect.SetHeight(foldrect.GetHeight() - 22); foldrect.SetHeight(foldrect.GetHeight() - 22);
#endif #endif
foldrect.SetX(0); foldrect.SetX(0);
foldrect.SetY(0); foldrect.SetY(0);
_foldPanel->SetSize(foldrect); _foldPanel->SetSize(foldrect);
if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM) if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM)
{ {
wxRect rect = RepositionCollapsedToBottom(); wxRect rect = RepositionCollapsedToBottom();
if(rect.GetHeight() > 0) if(rect.GetHeight() > 0)
RefreshRect(rect); RefreshRect(rect);
} }
// TODO: A smart way to check wether the old - new width of the // 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 // 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 #if 0
wxRect bottomrect = GetRect(); wxRect bottomrect = GetRect();
if(bottomrect.GetHeight() < 22) if(bottomrect.GetHeight() < 22)
bottomrect.SetY(0); bottomrect.SetY(0);
else else
bottomrect.SetY(bottomrect.GetHeight() - 22); bottomrect.SetY(bottomrect.GetHeight() - 22);
bottomrect.SetHeight(22); bottomrect.SetHeight(22);
bottomrect.SetX(0); bottomrect.SetX(0);
_bottomPanel->SetSize(bottomrect); _bottomPanel->SetSize(bottomrect);
// TODO: redraw the bitmap properly // TODO: redraw the bitmap properly
// use the captionbar algorithm for that // use the captionbar algorithm for that
_bottomPanel->Refresh(); _bottomPanel->Refresh();
#endif #endif
} }
void wxFoldPanelBar::OnPaint(wxPaintEvent &event) void wxFoldPanelBar::OnPaint(wxPaintEvent &event)
{ {
if(!_controlCreated) if(!_controlCreated)
return; return;
#if 0 #if 0
// paint the bottom panel only, where the // paint the bottom panel only, where the
// arrow is shown when there is more to show the user // arrow is shown when there is more to show the user
// just as informative icon // just as informative icon
wxPaintDC dc(_bottomPanel); wxPaintDC dc(_bottomPanel);
wxSize size = _bottomPanel->GetSize(); wxSize size = _bottomPanel->GetSize();
int offset = (size.GetHeight() - _moreBmp->GetHeight()) / 2; 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 #endif
event.Skip(); event.Skip();
} }
void wxFoldPanelBar::OnPressCaption(wxCaptionBarEvent &event) void wxFoldPanelBar::OnPressCaption(wxCaptionBarEvent &event)
{ {
// act upon the folding or expanding status of the bar // act upon the folding or expanding status of the bar
// to expand or collapse the panel(s) // to expand or collapse the panel(s)
if(event.GetFoldStatus()) if(event.GetFoldStatus())
Collapse(wxFoldPanel((wxFoldPanelItem *)event.GetTag())); Collapse(wxFoldPanel((wxFoldPanelItem *)event.GetTag()));
else else
Expand(wxFoldPanel((wxFoldPanelItem *)event.GetTag())); Expand(wxFoldPanel((wxFoldPanelItem *)event.GetTag()));
} }
void wxFoldPanelBar::RefreshPanelsFrom(wxFoldPanelItem *item) void wxFoldPanelBar::RefreshPanelsFrom(wxFoldPanelItem *item)
{ {
wxASSERT(item); wxASSERT(item);
size_t i = _panels.Index(item); size_t i = _panels.Index(item);
if(i != wxNOT_FOUND) if(i != wxNOT_FOUND)
RefreshPanelsFrom(i); RefreshPanelsFrom(i);
} }
void wxFoldPanelBar::RefreshPanelsFrom(size_t i) void wxFoldPanelBar::RefreshPanelsFrom(size_t i)
{ {
Freeze(); Freeze();
// if collapse to bottom is on, the panels that are not expanded // if collapse to bottom is on, the panels that are not expanded
// should be drawn at the bottom. All panels that are 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 // are drawn on top. The last expanded panel gets all the extra space
if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM) if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM)
{ {
int offset = 0; int offset = 0;
for(size_t j = 0; j < _panels.GetCount(); j++) for(size_t j = 0; j < _panels.GetCount(); j++)
{ {
if(_panels.Item(j)->IsExpanded()) if(_panels.Item(j)->IsExpanded())
offset += _panels.Item(j)->Reposition(offset); offset += _panels.Item(j)->Reposition(offset);
} }
// put all non collapsed panels at the bottom where there is space, else // put all non collapsed panels at the bottom where there is space, else
// put them right behind the expanded ones // put them right behind the expanded ones
RepositionCollapsedToBottom(); RepositionCollapsedToBottom();
} }
else else
{ {
int y = _panels.Item(i)->GetY() + _panels.Item(i)->GetPanelHeight(); int y = _panels.Item(i)->GetY() + _panels.Item(i)->GetPanelHeight();
for(i++; i < _panels.GetCount(); i++) for(i++; i < _panels.GetCount(); i++)
y += _panels.Item(i)->Reposition(y); y += _panels.Item(i)->Reposition(y);
} }
Thaw(); Thaw();
} }
void wxFoldPanelBar::RedisplayFoldPanelItems() void wxFoldPanelBar::RedisplayFoldPanelItems()
{ {
// resize them all. No need to reposition // resize them all. No need to reposition
wxFoldPanelItem *item; wxFoldPanelItem *item;
for(size_t i = 0; i < _panels.GetCount(); i++) for(size_t i = 0; i < _panels.GetCount(); i++)
{ {
item = _panels.Item(i); item = _panels.Item(i);
wxASSERT(item); wxASSERT(item);
item->ResizePanel(); item->ResizePanel();
} }
} }
wxRect wxFoldPanelBar::RepositionCollapsedToBottom() wxRect wxFoldPanelBar::RepositionCollapsedToBottom()
{ {
wxRect value(0,0,0,0); wxRect value(0,0,0,0);
// determine wether the number of panels left // determine wether the number of panels left
// times the size of their captions is enough // times the size of their captions is enough
// to be placed in the left over space // to be placed in the left over space
int expanded = 0, collapsed = 0, offset; int expanded = 0, collapsed = 0, offset;
GetPanelsHeight(collapsed, expanded); GetPanelsHeight(collapsed, expanded);
// if no room stick them behind the normal ones, else
// at the bottom
if((GetSize().GetHeight() - expanded - collapsed) < 0) // if no room stick them behind the normal ones, else
offset = expanded; // at the bottom
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());
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++) offset = GetSize().GetHeight() - collapsed;
{ }
if(!_panels.Item(i)->IsExpanded())
offset += _panels.Item(i)->Reposition(offset);
}
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 wxFoldPanelBar::GetPanelsHeight(int &collapsed, int &expanded)
{ {
int value = 0, offset = 0; int value = 0;
// assumed here that all the panels that are expanded // assumed here that all the panels that are expanded
// are positioned after eachother from 0,0 to end. // are positioned after eachother from 0,0 to end.
for(size_t j = 0; j < _panels.GetCount(); j++) for(size_t j = 0; j < _panels.GetCount(); j++)
{ {
offset = _panels.Item(j)->GetPanelHeight(); int offset = _panels.Item(j)->GetPanelHeight();
value += offset; value += offset;
if(_panels.Item(j)->IsExpanded()) if(_panels.Item(j)->IsExpanded())
expanded += offset; expanded += offset;
else else
collapsed += offset; collapsed += offset;
} }
return value; return value;
} }

View File

@@ -1,8 +1,12 @@
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Name: wxFoldPanelItem.cpp // Name: foldpanelitem.cpp
// Author: XX // Purpose:
// Created: Tuesday, June 22, 2004 21:01:02 // Author: Jorgen Bodde
// Copyright: XX // 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". // For compilers that support precompilation, includes "wx/wx.h".
@@ -24,63 +28,63 @@ WX_DEFINE_OBJARRAY(wxFoldWindowItemArray);
IMPLEMENT_CLASS( wxFoldPanelItem, wxPanel ) IMPLEMENT_CLASS( wxFoldPanelItem, wxPanel )
BEGIN_EVENT_TABLE(wxFoldPanelItem,wxPanel) BEGIN_EVENT_TABLE(wxFoldPanelItem,wxPanel)
EVT_CAPTIONBAR(-1, wxFoldPanelItem::OnPressCaption) EVT_CAPTIONBAR(wxID_ANY, wxFoldPanelItem::OnPressCaption)
EVT_PAINT(wxFoldPanelItem::OnPaint) EVT_PAINT(wxFoldPanelItem::OnPaint)
//EVT_SIZE(wxFoldPanelItem::OnSize) //EVT_SIZE(wxFoldPanelItem::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
wxFoldPanelItem::wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons, bool collapsedInitially, wxFoldPanelItem::wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons, bool collapsedInitially,
const wxCaptionBarStyle &style ) const wxCaptionBarStyle &style )
: _controlCreated(false) : _controlCreated(false)
, _yUserSize(0) , _yUserSize(0)
, _yPanelSize(0) , _yPanelSize(0)
, _yPos(0) , _yPos(0)
, _userSized(false) , _userSized(false)
, _yLastInsertPos(0) , _yLastInsertPos(0)
{ {
wxCHECK2(parent, return); 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)); wxPanel::Create(parent, wxID_ANY);
//_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(); // create the caption bar, in collapsed or expanded state
_yPanelSize = size.GetHeight();
_yLastInsertPos = _yPanelSize; _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) void wxFoldPanelItem::AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing)
{ {
wxASSERT(window); wxASSERT(window);
wxFoldWindowItem *wi = new wxFoldWindowItem(window, flags, ySpacing, leftSpacing, rightSpacing);
_items.Add(wi);
window->SetSize(leftSpacing, _yLastInsertPos + ySpacing, -1, -1, wxSIZE_USE_EXISTING); wxFoldWindowItem *wi = new wxFoldWindowItem(window, flags, ySpacing, leftSpacing, rightSpacing);
_yLastInsertPos += wi->GetWindowHeight(); _items.Add(wi);
ResizePanel(); 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) void wxFoldPanelItem::AddSeparator(const wxColour &color, int ySpacing, int leftSpacing, int rightSpacing)
{ {
wxFoldWindowItem *wi = new wxFoldWindowItem(_yLastInsertPos, color, ySpacing, leftSpacing, rightSpacing); wxFoldWindowItem *wi = new wxFoldWindowItem(_yLastInsertPos, color, ySpacing, leftSpacing, rightSpacing);
_items.Add(wi); _items.Add(wi);
_yLastInsertPos += wi->GetWindowHeight(); _yLastInsertPos += wi->GetWindowHeight();
ResizePanel(); ResizePanel();
} }
@@ -91,110 +95,110 @@ wxFoldPanelItem::~wxFoldPanelItem()
void wxFoldPanelItem::OnPressCaption(wxCaptionBarEvent &event) void wxFoldPanelItem::OnPressCaption(wxCaptionBarEvent &event)
{ {
// tell the upper container we are responsible // tell the upper container we are responsible
// for this event, so it can fold the panel item // for this event, so it can fold the panel item
// and do a refresh // and do a refresh
event.SetTag((void *)this); event.SetTag((void *)this);
event.Skip(); event.Skip();
} }
/* Inactive */ /* Inactive */
void wxFoldPanelItem::OnSize(wxSizeEvent &event) void wxFoldPanelItem::OnSize(wxSizeEvent &event)
{ {
// deny access to pointers (yet) // deny access to pointers (yet)
if(!_controlCreated) if(!_controlCreated)
{ {
event.Skip(); event.Skip();
return; return;
} }
// calculate the size needed for this window, so // calculate the size needed for this window, so
// we get the parent size, and determine the size for the caption and the panel // we get the parent size, and determine the size for the caption and the panel
//wxRect rect = GetRect();
//wxSize size(0,-1); //wxRect rect = GetRect();
//size.SetWidth(rect.GetWidth());
//_captionBar->SetSize(size); //wxSize size(0,wxDefaultCoord);
//size.SetWidth(rect.GetWidth());
//_captionBar->SetSize(size);
} }
int wxFoldPanelItem::Reposition(int y) int wxFoldPanelItem::Reposition(int y)
{ {
// NOTE: Call Resize before Reposition when an item is added, because the new // NOTE: Call Resize before Reposition when an item is added, because the new
// size needed will be calculated by Resize. Ofcourse the relative position // size needed will be calculated by Resize. Ofcourse the relative position
// of the controls have to be correct in respect to the caption bar // of the controls have to be correct in respect to the caption bar
Freeze();
SetSize(-1, y, -1, -1, wxSIZE_USE_EXISTING);
_yPos = y;
Thaw(); Freeze();
return GetPanelHeight(); SetSize(wxDefaultCoord, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
_yPos = y;
Thaw();
return GetPanelHeight();
} }
void wxFoldPanelItem::ResizePanel() 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 // 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 // user or calulated width (which will be recalculated by the contents here
wxSize size; wxSize size;
if(_captionBar->IsCollapsed()) if(_captionBar->IsCollapsed())
{ {
size = _captionBar->GetSize(); size = _captionBar->GetSize();
_yPanelSize = size.GetHeight(); _yPanelSize = size.GetHeight();
} }
else else
{ {
size = GetBestSize(); size = GetBestSize();
_yPanelSize = size.GetHeight(); _yPanelSize = size.GetHeight();
if(_userSized) if(_userSized)
size.SetHeight(_yUserSize); size.SetHeight(_yUserSize);
} }
wxSize pnlsize = GetParent()->GetSize(); wxSize pnlsize = GetParent()->GetSize();
size.SetWidth(pnlsize.GetWidth()); size.SetWidth(pnlsize.GetWidth());
// resize caption bar // resize caption bar
_captionBar->SetSize(wxSize(size.GetWidth(), -1)); _captionBar->SetSize(wxSize(size.GetWidth(), wxDefaultCoord));
// resize the panel
SetSize(size);
// go by all the controls and call Layout // resize the panel
SetSize(size);
for(size_t i = 0; i < _items.GetCount(); i++) // go by all the controls and call Layout
_items.Item(i).ResizeItem(size.GetWidth());
// 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)) void wxFoldPanelItem::OnPaint(wxPaintEvent& WXUNUSED(event))
{ {
// draw all the items that are lines // draw all the items that are lines
wxPaintDC dc(this); wxPaintDC dc(this);
for(size_t i = 0; i < _items.GetCount(); i++) for(size_t i = 0; i < _items.GetCount(); i++)
{ {
wxFoldWindowItem &item = _items.Item(i); wxFoldWindowItem &item = _items.Item(i);
wxPen pen(item.GetLineColour(), 1, wxSOLID); wxPen pen(item.GetLineColour(), 1, wxSOLID);
if(item.GetType() == wxFoldWindowItem::SEPARATOR) if(item.GetType() == wxFoldWindowItem::SEPARATOR)
{ {
dc.SetPen(pen); dc.SetPen(pen);
dc.DrawLine(item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing(), dc.DrawLine(item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing(),
item.GetLineWidth() + item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing()); item.GetLineWidth() + item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing());
} }
} }
} }