Full headers, Unicode markup, whitespaces, wxID_ANY, wxDefaultCoord conventions applied.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28600 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba 2004-08-03 11:55:18 +00:00
parent 957f5ab77a
commit c2a4197860
4 changed files with 742 additions and 712 deletions

View File

@ -1,227 +1,238 @@
/////////////////////////////////////////////////////////////////////////////
// Name: captionbar.h
// Purpose: wxFoldPanel
// Author: Jorgen Bodde
// Modified by:
// Created: 22/06/2004
// RCS-ID: $Id$
// Copyright: (c) Jorgen Bodde
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __FOLDPANELBAR_H__
#define __FOLDPANELBAR_H__
#define wxFPB_EXTRA_X 10
#define wxFPB_EXTRA_Y 4
#define wxFPB_BMP_RIGHTSPACE 2 // pixels of the bmp to be alligned from the right filled with space
#define wxFPB_BMP_RIGHTSPACE 2 // pixels of the bmp to be alligned from the right filled with space
enum
{
/** Specifies the bars as gradient vertical filled caption bars going from top to bottom. The gradient
starts with first colour, and ends with second colour */
wxCAPTIONBAR_GRADIENT_V = 1,
/** Specifies the gradient going from left to right. The gradient starts with first colour, and
ends with second colour on the right */
wxCAPTIONBAR_GRADIENT_H,
/** Fills the captionbar with a single colour. The first colour is used for this fill */
wxCAPTIONBAR_SINGLE,
/** Draws a rectangle only using the second colour. The first colour is not used*/
wxCAPTIONBAR_RECTANGLE,
/** Fills the captionbar with a single colour (first colour) and draws a rectangle around it
using the second colour. */
wxCAPTIONBAR_FILLED_RECTANGLE
/** Specifies the bars as gradient vertical filled caption bars going from top to bottom. The gradient
starts with first colour, and ends with second colour */
wxCAPTIONBAR_GRADIENT_V = 1,
/** Specifies the gradient going from left to right. The gradient starts with first colour, and
ends with second colour on the right */
wxCAPTIONBAR_GRADIENT_H,
/** Fills the captionbar with a single colour. The first colour is used for this fill */
wxCAPTIONBAR_SINGLE,
/** Draws a rectangle only using the second colour. The first colour is not used*/
wxCAPTIONBAR_RECTANGLE,
/** Fills the captionbar with a single colour (first colour) and draws a rectangle around it
using the second colour. */
wxCAPTIONBAR_FILLED_RECTANGLE
};
/** \class wxCaptionBarStyle
This class encapsulates the styles you wish to set for the wxCaptionBar (this is the part of the wxFoldPanel
This class encapsulates the styles you wish to set for the wxCaptionBar (this is the part of the wxFoldPanel
where the caption is displayed). It can either be applied at creation time be reapplied when styles need to
be changed.
At construction time, all styles are set to their default transparency. This means none of the styles will be
applied to the wxCaptionBar in question, meaning it will be created using the default internals. When setting i.e
the color, font or panel style, these styles become active to be used.
be changed.
At construction time, all styles are set to their default transparency. This means none of the styles will be
applied to the wxCaptionBar in question, meaning it will be created using the default internals. When setting i.e
the color, font or panel style, these styles become active to be used.
*/
class wxCaptionBarStyle
{
private:
// boolean flags for default transparency on styles
bool _firstColourUsed,
_secondColourUsed,
_textColourUsed,
_captionFontUsed,
_captionStyleUsed;
// boolean flags for default transparency on styles
bool _firstColourUsed,
_secondColourUsed,
_textColourUsed,
_captionFontUsed,
_captionStyleUsed;
wxFont _captionFont;
wxColour _firstColour, _secondColour, _textColour;
wxFont _captionFont;
wxColour _firstColour, _secondColour, _textColour;
int _captionStyle;
int _captionStyle;
public:
/** Default constructor for this class */
wxCaptionBarStyle() {
ResetDefaults();
};
/** Default constructor for this class */
wxCaptionBarStyle() {
ResetDefaults();
};
~wxCaptionBarStyle() {
~wxCaptionBarStyle() {
};
};
void ResetDefaults() {
_firstColourUsed = false;
_secondColourUsed = false;
_textColourUsed = false;
_captionFontUsed = false;
_captionStyleUsed = false;
_captionStyle = wxCAPTIONBAR_GRADIENT_V;
};
/** Copy operator. Only the styles in use in the source object are being copied to the destination object. All other
styles are not copied */
void operator=(const wxCaptionBarStyle &s) {
if(s._captionStyleUsed)
{
_captionStyleUsed = true;
_captionStyle = s._captionStyle;
}
if(s._captionFontUsed)
{
_captionFontUsed = true;
_captionFont = s._captionFont;
}
if(s._firstColourUsed)
{
_firstColourUsed = true;
_firstColour = s._firstColour;
}
if(s._secondColourUsed)
{
_secondColourUsed = true;
_secondColour = s._secondColour;
}
if(s._textColourUsed)
{
_textColourUsed = true;
_textColour = s._textColour;
}
};
void ResetDefaults() {
_firstColourUsed = false;
_secondColourUsed = false;
_textColourUsed = false;
_captionFontUsed = false;
_captionStyleUsed = false;
_captionStyle = wxCAPTIONBAR_GRADIENT_V;
};
/** Copy operator. Only the styles in use in the source object are being copied to the destination object. All other
styles are not copied */
void operator=(const wxCaptionBarStyle &s) {
if(s._captionStyleUsed)
{
_captionStyleUsed = true;
_captionStyle = s._captionStyle;
}
if(s._captionFontUsed)
{
_captionFontUsed = true;
_captionFont = s._captionFont;
}
if(s._firstColourUsed)
{
_firstColourUsed = true;
_firstColour = s._firstColour;
}
if(s._secondColourUsed)
{
_secondColourUsed = true;
_secondColour = s._secondColour;
}
if(s._textColourUsed)
{
_textColourUsed = true;
_textColour = s._textColour;
}
};
// ------- CaptionBar Font -------
// ------- CaptionBar Font -------
/** Set font for the caption bar. If this is not set, the font property is undefined
and will not be used. Use CaptionFontUsed() to check if this style is used */
void SetCaptionFont(const wxFont &font) {
_captionFont = font;
_captionFontUsed = true;
};
/** Set font for the caption bar. If this is not set, the font property is undefined
and will not be used. Use CaptionFontUsed() to check if this style is used */
void SetCaptionFont(const wxFont &font) {
_captionFont = font;
_captionFontUsed = true;
};
/** Checks if the caption bar font is set */
bool CaptionFontUsed() const {
return _captionFontUsed;
};
/** Checks if the caption bar font is set */
bool CaptionFontUsed() const {
return _captionFontUsed;
};
/** Returns the font for the caption bar. Please be warned this will result in an assertion failure when
this property is not previously set
\sa SetCaptionFont(), CaptionFontUsed() */
wxFont GetCaptionFont() const {
wxASSERT(_captionFontUsed);
return _captionFont;
};
/** Returns the font for the caption bar. Please be warned this will result in an assertion failure when
this property is not previously set
\sa SetCaptionFont(), CaptionFontUsed() */
wxFont GetCaptionFont() const {
wxASSERT(_captionFontUsed);
return _captionFont;
};
// ------- FirstColour -------
// ------- FirstColour -------
/** Set first colour for the caption bar. If this is not set, the colour property is
undefined and will not be used. Use FirstColourUsed() to check if this
style is used */
void SetFirstColour(const wxColour &col) {
_firstColour = col;
_firstColourUsed = true;
};
/** Set first colour for the caption bar. If this is not set, the colour property is
undefined and will not be used. Use FirstColourUsed() to check if this
style is used */
void SetFirstColour(const wxColour &col) {
_firstColour = col;
_firstColourUsed = true;
};
/** Checks if the first colour of the caption bar is set */
bool FirstColourUsed() const {
return _firstColourUsed;
};
/** Checks if the first colour of the caption bar is set */
bool FirstColourUsed() const {
return _firstColourUsed;
};
/** Returns the first colour for the caption bar. Please be warned this will
result in an assertion failure when this property is not previously set.
\sa SetCaptionFirstColour(), CaptionFirstColourUsed() */
wxColour GetFirstColour() const {
wxASSERT(_firstColourUsed);
return _firstColour;
};
/** Returns the first colour for the caption bar. Please be warned this will
result in an assertion failure when this property is not previously set.
\sa SetCaptionFirstColour(), CaptionFirstColourUsed() */
wxColour GetFirstColour() const {
wxASSERT(_firstColourUsed);
return _firstColour;
};
// ------- SecondColour -------
// ------- SecondColour -------
/** Set second colour for the caption bar. If this is not set, the colour property is undefined and
will not be used. Use SecondColourUsed() to check if this style is used */
void SetSecondColour(const wxColour &col) {
_secondColour = col;
_secondColourUsed = true;
};
/** Set second colour for the caption bar. If this is not set, the colour property is undefined and
will not be used. Use SecondColourUsed() to check if this style is used */
void SetSecondColour(const wxColour &col) {
_secondColour = col;
_secondColourUsed = true;
};
/** Checks if the second colour of the caption bar is set */
bool SecondColourUsed() const {
return _secondColourUsed;
};
/** Checks if the second colour of the caption bar is set */
bool SecondColourUsed() const {
return _secondColourUsed;
};
/** Returns the second colour for the caption bar. Please be warned this will result in
an assertion failure when this property is not previously set.
\sa SetSecondColour(), SecondColourUsed() */
wxColour GetSecondColour() const {
wxASSERT(_secondColourUsed);
return _secondColour;
};
/** Returns the second colour for the caption bar. Please be warned this will result in
an assertion failure when this property is not previously set.
\sa SetSecondColour(), SecondColourUsed() */
wxColour GetSecondColour() const {
wxASSERT(_secondColourUsed);
return _secondColour;
};
// ------- Caption Text Colour -------
// ------- Caption Text Colour -------
/** Set caption colour for the caption bar. If this is not set, the colour property is
undefined and will not be used. Use CaptionColourUsed() to check if this style is used */
void SetCaptionColour(const wxColour &col) {
_textColour = col;
_textColourUsed = true;
};
/** Set caption colour for the caption bar. If this is not set, the colour property is
undefined and will not be used. Use CaptionColourUsed() to check if this style is used */
void SetCaptionColour(const wxColour &col) {
_textColour = col;
_textColourUsed = true;
};
/** Checks if the caption colour of the caption bar is set */
bool CaptionColourUsed() const {
return _textColourUsed;
};
/** Checks if the caption colour of the caption bar is set */
bool CaptionColourUsed() const {
return _textColourUsed;
};
/** Returns the caption colour for the caption bar. Please be warned this will
result in an assertion failure when this property is not previously set.
\sa SetCaptionColour(), CaptionColourUsed() */
wxColour GetCaptionColour() const {
wxASSERT(_textColourUsed);
return _textColour;
};
/** Returns the caption colour for the caption bar. Please be warned this will
result in an assertion failure when this property is not previously set.
\sa SetCaptionColour(), CaptionColourUsed() */
wxColour GetCaptionColour() const {
wxASSERT(_textColourUsed);
return _textColour;
};
// ------- CaptionStyle -------
// ------- CaptionStyle -------
/** Set caption style for the caption bar. If this is not set, the property is
undefined and will not be used. Use CaptionStyleUsed() to check if this style is used.
The following styles can be applied:
- wxCAPTIONBAR_GRADIENT_V: Draws a vertical gradient from top to bottom
- wxCAPTIONBAR_GRADIENT_H: Draws a horizontal gradient from left to right
- wxCAPTIONBAR_SINGLE: Draws a single filled rectangle to draw the caption
- wxCAPTIONBAR_RECTANGLE: Draws a single colour with a rectangle around the caption
- wxCAPTIONBAR_FILLED_RECTANGLE: Draws a filled rectangle and a border around it
*/
void SetCaptionStyle(int style) {
_captionStyle = style;
_captionStyleUsed = true;
};
/** Set caption style for the caption bar. If this is not set, the property is
undefined and will not be used. Use CaptionStyleUsed() to check if this style is used.
The following styles can be applied:
- wxCAPTIONBAR_GRADIENT_V: Draws a vertical gradient from top to bottom
- wxCAPTIONBAR_GRADIENT_H: Draws a horizontal gradient from left to right
- wxCAPTIONBAR_SINGLE: Draws a single filled rectangle to draw the caption
- wxCAPTIONBAR_RECTANGLE: Draws a single colour with a rectangle around the caption
- wxCAPTIONBAR_FILLED_RECTANGLE: Draws a filled rectangle and a border around it
*/
void SetCaptionStyle(int style) {
_captionStyle = style;
_captionStyleUsed = true;
};
/** Checks if the caption style of the caption bar is set */
bool CaptionStyleUsed() const {
return _captionStyleUsed;
};
/** Checks if the caption style of the caption bar is set */
bool CaptionStyleUsed() const {
return _captionStyleUsed;
};
/** Returns the caption style for the caption bar. Please be warned this will
result in an assertion failure when this property is not previously set.
\sa SetCaptionStyle(), CaptionStyleUsed() */
int GetCaptionStyle() const {
wxASSERT(_captionStyleUsed);
return _captionStyle;
};
/** Returns the caption style for the caption bar. Please be warned this will
result in an assertion failure when this property is not previously set.
\sa SetCaptionStyle(), CaptionStyleUsed() */
int GetCaptionStyle() const {
wxASSERT(_captionStyleUsed);
return _captionStyle;
};
};
#ifndef _NO_CAPTIONBAR_
/** \class wxCaptionBar
This class is a graphical caption component that consists of a caption and a clickable arrow.
The wxCaptionBar fires an event EVT_CAPTIONBAR which is a wxCaptionBarEvent. This event can be caught
and the parent window can act upon the collapsed or expanded state of the bar (which is actually just
the icon which changed). The parent panel can reduce size or expand again.
This class is a graphical caption component that consists of a caption and a clickable arrow.
The wxCaptionBar fires an event EVT_CAPTIONBAR which is a wxCaptionBarEvent. This event can be caught
and the parent window can act upon the collapsed or expanded state of the bar (which is actually just
the icon which changed). The parent panel can reduce size or expand again.
*/
#include <wx/imaglist.h>
@ -232,134 +243,134 @@ public:
class wxCaptionBar: public wxWindow
{
private:
wxString _caption;
wxImageList *_foldIcons;
wxSize _oldSize;
//wxFont _captionFont;
int _rightIndent;
int _iconWidth, _iconHeight;
//int _captionStyle;
wxString _caption;
wxImageList *_foldIcons;
wxSize _oldSize;
//wxFont _captionFont;
int _rightIndent;
int _iconWidth, _iconHeight;
//int _captionStyle;
//wxColour _firstColour, _secondColour, _textColour;
//wxColour _firstColour, _secondColour, _textColour;
/** True when the caption is in collapsed state (means at the bottom of the wxFoldPanel */
bool _collapsed;
/** True when the caption is in collapsed state (means at the bottom of the wxFoldPanel */
bool _collapsed;
wxCaptionBarStyle _style;
wxCaptionBarStyle _style;
/** Fills the background of the caption with either a gradient, or a solid color */
void FillCaptionBackground(wxPaintDC &dc);
/** Fills the background of the caption with either a gradient, or a solid color */
void FillCaptionBackground(wxPaintDC &dc);
/* Draw methods */
void DrawHorizontalGradient(wxDC &dc, const wxRect &rect );
void DrawVerticalGradient(wxDC &dc, const wxRect &rect );
void DrawSingleColour(wxDC &dc, const wxRect &rect );
void DrawSingleRectangle(wxDC &dc, const wxRect &rect );
/* Draw methods */
void DrawHorizontalGradient(wxDC &dc, const wxRect &rect );
void DrawVerticalGradient(wxDC &dc, const wxRect &rect );
void DrawSingleColour(wxDC &dc, const wxRect &rect );
void DrawSingleRectangle(wxDC &dc, const wxRect &rect );
void RedrawIconBitmap();
void RedrawIconBitmap();
void ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool applyDefault);
void ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool applyDefault);
public:
/** Constructor of wxCaptionBar. To create a wxCaptionBar with the arrow images, simply pass an image list
which contains at least two bitmaps. The bitmaps contain the expanded and collapsed icons needed to
represent it's state. If you don't want images, simply pass a null pointer and the bitmap is disabled. */
wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images,
wxWindowID id = -1, const wxCaptionBarStyle &cbstyle = wxEmptyCaptionBarStyle,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);
which contains at least two bitmaps. The bitmaps contain the expanded and collapsed icons needed to
represent it's state. If you don't want images, simply pass a null pointer and the bitmap is disabled. */
wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images,
wxWindowID id = wxID_ANY, const wxCaptionBarStyle &cbstyle = wxEmptyCaptionBarStyle,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);
~wxCaptionBar();
~wxCaptionBar();
/** Set wxCaptionBar styles with wxCapionBarSyle class. All styles that are actually set, are applied. If you
set applyDefault to true, all other (not defined) styles will be set to default. If it is false,
the styles which are not set in the wxCaptionBarStyle will be ignored */
void SetCaptionStyle(bool applyDefault, wxCaptionBarStyle style = wxEmptyCaptionBarStyle) {
ApplyCaptionStyle(style, applyDefault);
Refresh();
};
/** Returns the current style of the captionbar in a wxCaptionBarStyle class. This can be used to change and set back the
changes. */
wxCaptionBarStyle GetCaptionStyle() {
return _style;
};
/** Set wxCaptionBar styles with wxCapionBarSyle class. All styles that are actually set, are applied. If you
set applyDefault to true, all other (not defined) styles will be set to default. If it is false,
the styles which are not set in the wxCaptionBarStyle will be ignored */
void SetCaptionStyle(bool applyDefault, wxCaptionBarStyle style = wxEmptyCaptionBarStyle) {
ApplyCaptionStyle(style, applyDefault);
Refresh();
};
/** Returns the current style of the captionbar in a wxCaptionBarStyle class. This can be used to change and set back the
changes. */
wxCaptionBarStyle GetCaptionStyle() {
return _style;
};
#if 0
/** Sets a pointer to an image list resource (a non owned pointer) to the collapsed and expand icon bitmap.
The reason why it will be assigned a pointer is that it is very likely that multiple caption bars will
be used and if they all have their own bitmap resources it will eat up more memory then needed. It will
also ease the use of shared icon change, when there is any need to.
If no wxImageList is assigned, there will be no fold icons and only the doubleclick on the panel
will work to collapse / expand.
The image list must contain 2 bitmaps. Index 0 will be the expanded state, and index 1 will be the
collapsed state of the bitmap. The size of the bitmap is taken in account when the minimal height and
widht is calculated.
/** Sets a pointer to an image list resource (a non owned pointer) to the collapsed and expand icon bitmap.
The reason why it will be assigned a pointer is that it is very likely that multiple caption bars will
be used and if they all have their own bitmap resources it will eat up more memory then needed. It will
also ease the use of shared icon change, when there is any need to.
If no wxImageList is assigned, there will be no fold icons and only the doubleclick on the panel
will work to collapse / expand.
The image list must contain 2 bitmaps. Index 0 will be the expanded state, and index 1 will be the
collapsed state of the bitmap. The size of the bitmap is taken in account when the minimal height and
widht is calculated.
The bitmaps must be the second thing to be done before using it (SetRightIndent should be the first thing),
make sure if the icons are larger than the font, that the parent of this window gets a Fit call to resize
all the windows accordingly */
The bitmaps must be the second thing to be done before using it (SetRightIndent should be the first thing),
make sure if the icons are larger than the font, that the parent of this window gets a Fit call to resize
all the windows accordingly */
void SetFoldIcons(wxImageList *images) {
_foldIcons = images;
_iconWidth = _iconHeight = 0;
if(_foldIcons)
_foldIcons->GetSize(0, _iconWidth, _iconHeight);
void SetFoldIcons(wxImageList *images) {
_foldIcons = images;
_iconWidth = _iconHeight = 0;
if(_foldIcons)
_foldIcons->GetSize(0, _iconWidth, _iconHeight);
Refresh();
};
Refresh();
};
#endif
/** Returns wether the status of the bar is expanded or collapsed */
bool IsCollapsed() const {
return _collapsed;
};
/** Returns wether the status of the bar is expanded or collapsed */
bool IsCollapsed() const {
return _collapsed;
};
/** Sets the amount of pixels on the right from which the bitmap is trailing. If this is 0, it will be
drawn all the way to the right, default is equal to wxFPB_BMP_RIGHTSPACE. Assign this before
assigning an image list to prevent a redraw */
/** Sets the amount of pixels on the right from which the bitmap is trailing. If this is 0, it will be
drawn all the way to the right, default is equal to wxFPB_BMP_RIGHTSPACE. Assign this before
assigning an image list to prevent a redraw */
void SetRightIndent(int pixels) {
wxCHECK2(pixels >= 0, return);
_rightIndent = pixels;
// issue a refresh (if we have a bmp)
if(_foldIcons)
Refresh();
};
void SetRightIndent(int pixels) {
wxCHECK2(pixels >= 0, return);
_rightIndent = pixels;
// issue a refresh (if we have a bmp)
if(_foldIcons)
Refresh();
};
/** Return the best size for this panel, based upon the font assigned to this window, and the
caption string */
wxSize DoGetBestSize() const;
/** Return the best size for this panel, based upon the font assigned to this window, and the
caption string */
wxSize DoGetBestSize() const;
/** This sets the internal state / representation to collapsed. This does not trigger a wxCaptionBarEvent
to be sent to the parent */
void Collapse() {
_collapsed = true;
RedrawIconBitmap();
};
/** This sets the internal state / representation to collapsed. This does not trigger a wxCaptionBarEvent
to be sent to the parent */
void Collapse() {
_collapsed = true;
RedrawIconBitmap();
};
/** This sets the internal state / representation to expanded. This does not trigger a wxCaptionBarEvent
to be sent to the parent */
void Expand() {
_collapsed = false;
RedrawIconBitmap();
};
/** This sets the internal state / representation to expanded. This does not trigger a wxCaptionBarEvent
to be sent to the parent */
void Expand() {
_collapsed = false;
RedrawIconBitmap();
};
void SetBoldFont() {
GetFont().SetWeight(wxBOLD);
};
void SetBoldFont() {
GetFont().SetWeight(wxBOLD);
};
void SetNormalFont() {
GetFont().SetWeight(wxNORMAL);
};
void SetNormalFont() {
GetFont().SetWeight(wxNORMAL);
};
private:
/** The paint event for flat or gradient fill */
void OnPaint(wxPaintEvent& event);
void OnPaint(wxPaintEvent& event);
/** For clicking the icon, the mouse event must be intercepted */
void OnMouseEvent(wxMouseEvent& event);
@ -367,7 +378,7 @@ private:
/** Maybe when focus (don't know how yet) a cursor left or backspace will collapse or expand */
void OnChar(wxKeyEvent& event);
void OnSize(wxSizeEvent &event);
void OnSize(wxSizeEvent &event);
protected:
@ -378,60 +389,60 @@ protected:
/***********************************************************************************************************/
/** \class wxCaptionBarEvent
This event will be sent when a EVT_CAPTIONBAR is mapped in the parent. It is to notify the parent
that the bar is now in collapsed or expanded state. The parent should re-arrange the associated
windows accordingly */
This event will be sent when a EVT_CAPTIONBAR is mapped in the parent. It is to notify the parent
that the bar is now in collapsed or expanded state. The parent should re-arrange the associated
windows accordingly */
class WXDLLEXPORT wxCaptionBarEvent : public wxCommandEvent
{
private:
bool _collapsed;
wxCaptionBar *_bar;
void *_tag;
bool _collapsed;
wxCaptionBar *_bar;
void *_tag;
public:
wxCaptionBarEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
: wxCommandEvent(commandType, id)
, _collapsed(false)
, _bar(0)
, _tag(0)
{ }
, _collapsed(false)
, _bar(0)
, _tag(0)
{ }
/** Constructor for clone copy */
wxCaptionBarEvent(const wxCaptionBarEvent &event);
/** Clone function */
virtual wxEvent *Clone() const {
return new wxCaptionBarEvent(*this);
};
/** Constructor for clone copy */
wxCaptionBarEvent(const wxCaptionBarEvent &event);
/** Clone function */
virtual wxEvent *Clone() const {
return new wxCaptionBarEvent(*this);
};
/** Returns wether the bar is expanded or collapsed. True means expanded */
bool GetFoldStatus() const {
wxCHECK(_bar, false);
return !_bar->IsCollapsed();
};
/** Returns wether the bar is expanded or collapsed. True means expanded */
bool GetFoldStatus() const {
wxCHECK(_bar, false);
return !_bar->IsCollapsed();
};
/** Returns the bar associated with this event */
wxCaptionBar *GetBar() const {
return _bar;
};
/** Returns the bar associated with this event */
wxCaptionBar *GetBar() const {
return _bar;
};
void SetTag(void *tag) {
_tag = tag;
};
void SetTag(void *tag) {
_tag = tag;
};
void *GetTag() const {
return _tag;
};
void *GetTag() const {
return _tag;
};
/** Sets the bar associated with this event, should not used
by any other then the originator of the event */
void SetBar(wxCaptionBar *bar) {
_bar = bar;
};
/** Sets the bar associated with this event, should not used
by any other then the originator of the event */
void SetBar(wxCaptionBar *bar) {
_bar = bar;
};
DECLARE_DYNAMIC_CLASS(wxCaptionBarEvent)
DECLARE_DYNAMIC_CLASS(wxCaptionBarEvent)
};
@ -443,7 +454,7 @@ typedef void (wxEvtHandler::*wxCaptionBarEventFunction)(wxCaptionBarEvent&);
#define EVT_CAPTIONBAR(id, fn) \
DECLARE_EVENT_TABLE_ENTRY( \
wxEVT_CAPTIONBAR, id, -1, \
wxEVT_CAPTIONBAR, id, wxID_ANY, \
(wxObjectEventFunction)(wxEventFunction)(wxCaptionBarEventFunction) \
& fn, \
(wxObject *) NULL \

View File

@ -1,55 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: doc_mainpage.h
// Purpose: wxFoldPanel
// Author: Jorgen Bodde
// Modified by:
// Created: 22/06/2004
// RCS-ID: $Id$
// Copyright: (c) Jorgen Bodde
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/** \author Jorgen Bodde
\mainpage
This is the wxFoldPanel documentation guide. This control is written for wxWidgets (http://www.wxwidgets.com), and
can be used as a side bar with managed panels which can collapse and expand.
The wxFoldPanelBar is very easy in it's use and allows great flexibility in manipulating it even after creation. It can
be created in two modes:
- In place folding: This means that the panels which are collapsed, stay where they are.
- To bottom folding: This means that the panels are collapsed to the bottom
The caption bars are managed by another stand alone control (which I will fix up to be released soon), called the
wxCaptionBar. You as user don't have to do much with this control right now, all styles are rerouted through the
wxFoldPanelBar. The only class of interest is wxCaptionBarStyle which takes care of the visual style of the
bar. The caption bar can be drawn in the following modes:
- Gradient horizontal fill
- Gradient vertical fill
- Single flat colour
- Single colour with border
- Single border with background fill
wxFoldPanelBar is freeware and distributed under the wxWidgets license. wxWidgets is THE toolkit for
(cross platform) C++ / Python programming!
\section things_done Things to be done
I would like to add the following features when time allows me. When you really like one of these features to be in the
next release, you can either make that clear to me, or help me with it. They aren't that hard.
- Single fold which means all other panels are collapsed automatically
- Smart size of panels when only one is open, take the whole space, or use sizers to proportionally size
- Small icons next to the caption for clarity and make it a bit more visually nice
- A bottom bar with visual icon when the bar cannot be completely shown to aid the user that there is more then can be seen
- Panels can be hidden. This feature will also need the bottom bar, so that the icons of hidden panels will apear there
- Resizable panels, the user can manually size the panels bigger or smaller
This is the wxFoldPanel documentation guide. This control is written for wxWidgets (http://www.wxwidgets.com), and
can be used as a side bar with managed panels which can collapse and expand.
\section how_work How does it work?
The internals of the wxFoldPanelBar is a list of wxFoldPanelItem classes. Through the reference of wxFoldPanel these
panels can be controlled by adding new controls to a wxFoldPanel or adding new wxFoldPanels to the wxFoldPanelBar. The
wxCaptionBar fires events to the parent (container of all panel items) when a sub-panel needs resizing (either folding
or expanding). The fold or expand process is simply a resize of the panel so it looks like all controls on it are gone.
All controls are still child of the wxFoldPanel they are located on. If they don't handle the event (and they won't)
then the owner of the wxFoldPanelBar gets the events. This is what you need to handle the controls. There isn't much to it
just a lot of calculations to see what panel belongs where. There are no sizers involved in the panels, everything is
purely xy positioning.
\section what_dp What can it do and what not?
What it can do:
The wxFoldPanelBar is very easy in it's use and allows great flexibility in manipulating it even after creation. It can
be created in two modes:
- In place folding: This means that the panels which are collapsed, stay where they are.
- To bottom folding: This means that the panels are collapsed to the bottom
The caption bars are managed by another stand alone control (which I will fix up to be released soon), called the
wxCaptionBar. You as user don't have to do much with this control right now, all styles are rerouted through the
wxFoldPanelBar. The only class of interest is wxCaptionBarStyle which takes care of the visual style of the
bar. The caption bar can be drawn in the following modes:
- Gradient horizontal fill
- Gradient vertical fill
- Single flat colour
- Single colour with border
- Single border with background fill
wxFoldPanelBar is freeware and distributed under the wxWidgets license. wxWidgets is THE toolkit for
(cross platform) C++ / Python programming!
\section things_done Things to be done
I would like to add the following features when time allows me. When you really like one of these features to be in the
next release, you can either make that clear to me, or help me with it. They aren't that hard.
- Single fold which means all other panels are collapsed automatically
- Smart size of panels when only one is open, take the whole space, or use sizers to proportionally size
- Small icons next to the caption for clarity and make it a bit more visually nice
- A bottom bar with visual icon when the bar cannot be completely shown to aid the user that there is more then can be seen
- Panels can be hidden. This feature will also need the bottom bar, so that the icons of hidden panels will apear there
- Resizable panels, the user can manually size the panels bigger or smaller
\section how_work How does it work?
The internals of the wxFoldPanelBar is a list of wxFoldPanelItem classes. Through the reference of wxFoldPanel these
panels can be controlled by adding new controls to a wxFoldPanel or adding new wxFoldPanels to the wxFoldPanelBar. The
wxCaptionBar fires events to the parent (container of all panel items) when a sub-panel needs resizing (either folding
or expanding). The fold or expand process is simply a resize of the panel so it looks like all controls on it are gone.
All controls are still child of the wxFoldPanel they are located on. If they don't handle the event (and they won't)
then the owner of the wxFoldPanelBar gets the events. This is what you need to handle the controls. There isn't much to it
just a lot of calculations to see what panel belongs where. There are no sizers involved in the panels, everything is
purely xy positioning.
\section what_dp What can it do and what not?
What it can do:
- Run-time addition of panels (no deletion just yet)
- Run time addition of controls to the panel (it will be resized accordingly)
@ -57,12 +68,12 @@
- Various modes of caption behaviour and filling to make it more appealing
- Panels can be folded and collapsed (or all of them) to allow more space
What it cannot do:
What it cannot do:
- Selection of a panel like in a list ctrl
- Dragging and dropping the panels
- Re-ordering the panels (not yet)
Special thanks to Julian Smart et al. for making this great toolkit!
Special thanks to Julian Smart et al. for making this great toolkit!
*/

View File

@ -1,8 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wxFoldPanelBar.h
// Author: XX
// Created: Tuesday, June 22, 2004 20:40:00
// Copyright: XX
// Name: foldpanelbar.h
// Purpose: wxFoldPanel
// Author: Jorgen Bodde
// Modified by:
// Created: 22/06/2004
// RCS-ID: $Id$
// Copyright: (c) Jorgen Bodde
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXFOLDPANELBAR_H__
@ -16,67 +20,67 @@
/** Not yet supported but added for future reference. Single fold forces other panels to close when
they are open, and only opens the current panel. This will allow the open panel to gain the full
size left in the client area */
#define wxFPB_SINGLE_FOLD 0x0001
size left in the client area */
#define wxFPB_SINGLE_FOLD 0x0001
/** All panels are stacked to the bottom. When they are expanded again they show up at the top */
#define wxFPB_COLLAPSE_TO_BOTTOM 0x0002
#define wxFPB_COLLAPSE_TO_BOTTOM 0x0002
/** Not yet supported, but added for future reference. Single fold plus panels will be stacked at the bottom */
#define wxFPB_EXCLUSIVE_FOLD wxFPB_SINGLE_FOLD | wxFPB_COLLAPSE_TO_BOTTOM
#define wxFPB_EXCLUSIVE_FOLD wxFPB_SINGLE_FOLD | wxFPB_COLLAPSE_TO_BOTTOM
/** Default style of the wxFoldPanelBar */
#define wxFPB_DEFAULT_EXTRASTYLE 0
#define wxFPB_DEFAULT_EXTRASTYLE 0
#define wxFPB_DEFAULT_STYLE wxTAB_TRAVERSAL | wxNO_BORDER
#define wxFPB_DEFAULT_STYLE wxTAB_TRAVERSAL | wxNO_BORDER
/** \class wxFoldPanel
This class is used to return a reference to the fold panel that is added by wxFoldPanelBar::AddFoldPanel(). Use
wxFoldPanel::IsOk() to check wether the result is ok to be used in further operations. Use wxFoldPanel::GetItem()
to obtain a parent window reference to create the controls on you want to add with wxFoldPanelBar::AddFoldPanelWindow().<br><br>
This class is used to return a reference to the fold panel that is added by wxFoldPanelBar::AddFoldPanel(). Use
wxFoldPanel::IsOk() to check wether the result is ok to be used in further operations. Use wxFoldPanel::GetItem()
to obtain a parent window reference to create the controls on you want to add with wxFoldPanelBar::AddFoldPanelWindow().<br><br>
*/
class wxFoldPanel
{
private:
wxFoldPanelItem *_item;
wxFoldPanelItem *_item;
public:
/** Constructor, usually not directly used by the developer. */
wxFoldPanel(wxFoldPanelItem *item)
: _item(item)
{
}
/** Constructor, usually not directly used by the developer. */
wxFoldPanel(wxFoldPanelItem *item)
: _item(item)
{
}
/** Returns true if this is a valid wxFoldPanelItem reference. */
bool IsOk() const {
return (_item != 0);
};
/** Returns true if this is a valid wxFoldPanelItem reference. */
bool IsOk() const {
return (_item != 0);
};
/** Copy operator to assign one instance to the other, this is needed because these classes are passed
as instance not by reference. */
virtual void operator=(const wxFoldPanel &item) {
_item = item._item;
};
/** Copy operator to assign one instance to the other, this is needed because these classes are passed
as instance not by reference. */
virtual void operator=(const wxFoldPanel &item) {
_item = item._item;
};
#ifndef _NO_DOXYGEN_
// not allowed to be seen by doxygen
wxFoldPanelItem *GetItem() const {
return _item;
};
// not allowed to be seen by doxygen
wxFoldPanelItem *GetItem() const {
return _item;
};
#endif
/** Use this method to obtain the wxPanel derived class to which you need to add your components. For example;<br>
/** Use this method to obtain the wxPanel derived class to which you need to add your components. For example;<br>
\code
wxFoldPanel item = _pnl->AddFoldPanel("Test me", false);
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), -1, "Press Me"));
\endcode
*/
wxFoldPanelItem *GetParent() const {
wxASSERT(_item);
return _item;
};
\code
wxFoldPanel item = _pnl->AddFoldPanel(wxT("Test me"), false);
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), wxID_ANY, wxT("Press Me")));
\endcode
*/
wxFoldPanelItem *GetParent() const {
wxASSERT(_item);
return _item;
};
};
@ -85,16 +89,16 @@ public:
WX_DEFINE_ARRAY(wxFoldPanelItem *, wxFoldPanelItemArray);
/** \class wxFoldPanelBar
The wxFoldPanelBar is a class which can maintain a list of collapsable panels. Once a panel is collapsed, only
it's panel bar is visible to the user. This will provide more space for the other panels, or allow the user to
close panels which are not used often to get the most out of the work area.
The wxFoldPanelBar is a class which can maintain a list of collapsable panels. Once a panel is collapsed, only
it's panel bar is visible to the user. This will provide more space for the other panels, or allow the user to
close panels which are not used often to get the most out of the work area.
This control is easy to use. Simply create it as a child for a panel or sash window, and populate panels with
wxFoldPanelBar::AddFoldPanel(). Then use the wxFoldPanelBar::AddFoldPanelWindow() to add wxWindow derived controls
to the current fold panel. Use wxFoldPanelBar::AddFoldPanelSeperator() to put separators between the groups of
controls that need a visual separator to group them together. After all is constructed, the user can fold
the panels by doubleclicking on the bar or single click on the arrow, which will indicate the collapsed or
expanded state.
This control is easy to use. Simply create it as a child for a panel or sash window, and populate panels with
wxFoldPanelBar::AddFoldPanel(). Then use the wxFoldPanelBar::AddFoldPanelWindow() to add wxWindow derived controls
to the current fold panel. Use wxFoldPanelBar::AddFoldPanelSeperator() to put separators between the groups of
controls that need a visual separator to group them together. After all is constructed, the user can fold
the panels by doubleclicking on the bar or single click on the arrow, which will indicate the collapsed or
expanded state.
*/
class wxFoldPanelBar: public wxPanel
@ -103,179 +107,179 @@ private:
DECLARE_CLASS( wxFoldPanelBar )
DECLARE_EVENT_TABLE()
wxImageList *_images;
wxFoldPanelItemArray _panels;
wxBoxSizer* _panelSizer;
wxPanel *_foldPanel, *_bottomPanel;
wxFlexGridSizer* _mainSizer;
bool _controlCreated;
wxBitmap *_moreBmp;
int _extraStyle;
wxImageList *_images;
wxFoldPanelItemArray _panels;
wxBoxSizer* _panelSizer;
wxPanel *_foldPanel, *_bottomPanel;
wxFlexGridSizer* _mainSizer;
bool _controlCreated;
wxBitmap *_moreBmp;
int _extraStyle;
private:
/** Refreshes all the panels from given index down to last one */
void RefreshPanelsFrom(size_t i);
/** Refreshes all the panels from given index down to last one */
void RefreshPanelsFrom(size_t i);
/** Refreshes all the panels from given pointer down to last one in the list */
void RefreshPanelsFrom(wxFoldPanelItem *item);
/** Refreshes all the panels from given pointer down to last one in the list */
void RefreshPanelsFrom(wxFoldPanelItem *item);
/** Returns the height of the panels that are expanded and collapsed. This is useful to determine
quickly what size is used to display, and what is left at the bottom to allign
the collapsed panels. */
int GetPanelsHeight(int &collapsed, int &expanded);
/** Returns the height of the panels that are expanded and collapsed. This is useful to determine
quickly what size is used to display, and what is left at the bottom to allign
the collapsed panels. */
int GetPanelsHeight(int &collapsed, int &expanded);
/** Reposition all the collapsed panels to the bottom. When it is not possible to
allign them to the bottom, stick them behind the visible panels. The Rect holds the
slack area left between last repositioned panel and the bottom panels. This needs to
get a refresh */
wxRect RepositionCollapsedToBottom();
/** Reposition all the collapsed panels to the bottom. When it is not possible to
allign them to the bottom, stick them behind the visible panels. The Rect holds the
slack area left between last repositioned panel and the bottom panels. This needs to
get a refresh */
wxRect RepositionCollapsedToBottom();
public:
/** Two step constructor used for XRC. Use wxFoldPanelBar::Create() to create the panel. Do not call
any other methods before the control is fully created! */
any other methods before the control is fully created! */
wxFoldPanelBar();
/** One step creation. Look at wxPanel for the argument and style flags. The extraStyle flags are
- wxFPB_DEFAULT_EXTRASTYLE : Takes default styles.
- wxFPB_COLLAPSE_TO_BOTTOM : When panels are collapsed, they are put at the bottom of the area. */
wxFoldPanelBar( wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
wxFoldPanelBar( wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxFPB_DEFAULT_STYLE,
long extraStyle = wxFPB_DEFAULT_EXTRASTYLE);
long extraStyle = wxFPB_DEFAULT_EXTRASTYLE);
/** wxFoldPanelBar destructor */
virtual ~wxFoldPanelBar();
/** wxFoldPanelBar destructor */
virtual ~wxFoldPanelBar();
/** Two step create call. Use this when the control is not created using the wxPanel derived constructor.
WARNING: Do not create this component more then once! */
virtual void Create( wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxFPB_DEFAULT_STYLE,
long extraStyle = wxFPB_DEFAULT_EXTRASTYLE);
/** Two step create call. Use this when the control is not created using the wxPanel derived constructor.
WARNING: Do not create this component more then once! */
virtual void Create( wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxFPB_DEFAULT_STYLE,
long extraStyle = wxFPB_DEFAULT_EXTRASTYLE);
/** Adds a fold panel to the list of panels. If the flag collapsedInitially is set to true, the panel
is collapsed initially. The wxFoldPanel item which is returned, can be used as a reference to
perform actions upon the fold panel like collapsing it, expanding it, or deleting it from the list.
Use this foldpanel to add windows to it. Please consult wxFoldPanelBar::AddFoldPanelWindow() and
wxFoldPanelBar::AddFoldPanelSeparator() how to add wxWindow items to the panels. */
wxFoldPanel AddFoldPanel(const wxString &caption, bool collapsedInitially = false,
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
/** Adds a fold panel to the list of panels. If the flag collapsedInitially is set to true, the panel
is collapsed initially. The wxFoldPanel item which is returned, can be used as a reference to
perform actions upon the fold panel like collapsing it, expanding it, or deleting it from the list.
Use this foldpanel to add windows to it. Please consult wxFoldPanelBar::AddFoldPanelWindow() and
wxFoldPanelBar::AddFoldPanelSeparator() how to add wxWindow items to the panels. */
wxFoldPanel AddFoldPanel(const wxString &caption, bool collapsedInitially = false,
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
/** Adds a wxWindow derived class to the referenced wxFoldPanel. IMPORTANT: Make the to be created window,
child of the wxFoldPanel. See example that follows. The flags to be used are:
/** Adds a wxWindow derived class to the referenced wxFoldPanel. IMPORTANT: Make the to be created window,
child of the wxFoldPanel. See example that follows. The flags to be used are:
- wxFPB_ALIGN_WIDTH: Which means the wxWindow to be added will be alligned to fit the width of the
wxFoldPanel when it is resized. Very handy for sizer items, buttons and text boxes.
- wxFPB_ALIGN_LEFT: Alligns left instead of fitting the width of the child window to be added. Use either
this one or wxFPB_ALIGN_WIDTH.
The wxWindow to be added can be slightly indented from left and right so it is more visibly placed
in the wxFoldPanel. Use ySpacing > 0 to give the control an y offset from the previous wxWindow added,
use leftSpacing to give it a slight indent from the left, and rightSpacing also reserves a little space
on the right so the wxWindow can be properly placed in the wxFoldPanel.
The wxWindow to be added can be slightly indented from left and right so it is more visibly placed
in the wxFoldPanel. Use ySpacing > 0 to give the control an y offset from the previous wxWindow added,
use leftSpacing to give it a slight indent from the left, and rightSpacing also reserves a little space
on the right so the wxWindow can be properly placed in the wxFoldPanel.
The following example adds a wxFoldPanel to the wxFoldPanelBar and adds two wxWindow derived controls
to the wxFoldPanel:
The following example adds a wxFoldPanel to the wxFoldPanelBar and adds two wxWindow derived controls
to the wxFoldPanel:
\code
\code
// create the wxFoldPanelBar
_pnl = new wxFoldPanelBar(this, -1, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM);
// create the wxFoldPanelBar
_pnl = new wxFoldPanelBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM);
// add a foldpanel to the control. "Test me" is the caption and it is initially not collapsed.
wxFoldPanel item = _pnl->AddFoldPanel("Test me", false);
// add a foldpanel to the control. "Test me" is the caption and it is initially not collapsed.
wxFoldPanel item = _pnl->AddFoldPanel(wxT("Test me"), false);
// now add a button to the fold panel. Mind that the button should be made child of the
// wxFoldPanel and not of the main form.
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, "Collapse Me"));
// now add a button to the fold panel. Mind that the button should be made child of the
// wxFoldPanel and not of the main form.
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, wxT("Collapse Me")));
// add a separator between the two controls. This is purely a visual line that can have a certain
// color and also the indents and width alligning like a control.
_pnl->AddFoldPanelSeperator(item);
// add a separator between the two controls. This is purely a visual line that can have a certain
// color and also the indents and width alligning like a control.
_pnl->AddFoldPanelSeperator(item);
// now add a text ctrl. Also very easy. Allign this on width so that when the control gets wider
// the text control also sizes along.
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), -1, "Comment"), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
// now add a text ctrl. Also very easy. Allign this on width so that when the control gets wider
// the text control also sizes along.
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, wxT("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
\endcode
*/
int AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags = wxFPB_ALIGN_WIDTH,
int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTSPACING,
int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING);
\endcode
*/
int AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags = wxFPB_ALIGN_WIDTH,
int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTSPACING,
int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING);
/** Adds a seperator line to the current wxFoldPanel. The seperator is a simple line which is drawn and is no
real component. It can be used to seperate groups of controls which belong to eachother. The colour is
adjustable, and it takes the same ySpacing, leftSpacing and rightSpacing as AddFoldPanelWindow(). */
int AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color = wxColour(167,167,167),
int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING);
/** Adds a seperator line to the current wxFoldPanel. The seperator is a simple line which is drawn and is no
real component. It can be used to seperate groups of controls which belong to eachother. The colour is
adjustable, and it takes the same ySpacing, leftSpacing and rightSpacing as AddFoldPanelWindow(). */
int AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color = wxColour(167,167,167),
int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING);
/** Returns the number of panels currently present in the wxFoldPanelBar. This is independent if they are
visible or hidden. */
size_t GetCount() const {
return _panels.GetCount();
};
/** Returns the number of panels currently present in the wxFoldPanelBar. This is independent if they are
visible or hidden. */
size_t GetCount() const {
return _panels.GetCount();
};
/** Returns the wxFoldPanel reference belonging to the current index. An empty panel is returned when the
index is out of bounds. Use GetCount() to get the amount of panels present. Collapsing and folding the
panel does not change the order in which they are indexed. So it is safe enough to keep a reference
to the panel by number. */
wxFoldPanel Item(size_t i) {
wxCHECK(i >= 0 && i < GetCount(), wxFoldPanel(0));
return wxFoldPanel(_panels.Item(i));
};
/** Returns the wxFoldPanel reference belonging to the current index. An empty panel is returned when the
index is out of bounds. Use GetCount() to get the amount of panels present. Collapsing and folding the
panel does not change the order in which they are indexed. So it is safe enough to keep a reference
to the panel by number. */
wxFoldPanel Item(size_t i) {
wxCHECK(i >= 0 && i < GetCount(), wxFoldPanel(0));
return wxFoldPanel(_panels.Item(i));
};
/** Collapses the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
style, all collapsed captions are put at the bottom of the control. In the normal mode, they stay where
they are */
void Collapse(const wxFoldPanel &item) {
wxCHECK2(item.IsOk(), return);
item.GetItem()->Collapse();
RefreshPanelsFrom(item.GetItem());
};
/** Collapses the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
style, all collapsed captions are put at the bottom of the control. In the normal mode, they stay where
they are */
void Collapse(const wxFoldPanel &item) {
wxCHECK2(item.IsOk(), return);
item.GetItem()->Collapse();
RefreshPanelsFrom(item.GetItem());
};
/** Expands the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
they will be removed from the bottom and the order where the panel originally was placed is restored. */
void Expand(const wxFoldPanel &item) {
wxCHECK2(item.IsOk(), return);
item.GetItem()->Expand();
RefreshPanelsFrom(item.GetItem());
};
/** Expands the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
they will be removed from the bottom and the order where the panel originally was placed is restored. */
void Expand(const wxFoldPanel &item) {
wxCHECK2(item.IsOk(), return);
item.GetItem()->Expand();
RefreshPanelsFrom(item.GetItem());
};
/** Sets the style of the caption bar (called wxCaptionBar) of the wxFoldPanel. The changes are applied immediately.
All styles not set in the wxCaptionBarStyle class are not applied. Use the wxCaptionBar reference to indicate
what captionbar you want to apply the style to. To apply one style to all wxCaptionBar items, use
ApplyCaptionStyleAll() */
void ApplyCaptionStyle(wxFoldPanel &fp, const wxCaptionBarStyle &style) {
wxCHECK2(fp.IsOk(), return);
fp.GetItem()->ApplyCaptionStyle(style);
};
All styles not set in the wxCaptionBarStyle class are not applied. Use the wxCaptionBar reference to indicate
what captionbar you want to apply the style to. To apply one style to all wxCaptionBar items, use
ApplyCaptionStyleAll() */
void ApplyCaptionStyle(wxFoldPanel &fp, const wxCaptionBarStyle &style) {
wxCHECK2(fp.IsOk(), return);
fp.GetItem()->ApplyCaptionStyle(style);
};
/** Sets the style of all the caption bars of the wxFoldPanel. The changes are applied immediately */
void ApplyCaptionStyleAll(const wxCaptionBarStyle &style) {
for(size_t i = 0; i < GetCount(); i++)
{
wxFoldPanel item = Item(i);
ApplyCaptionStyle(item, style);
}
};
/** Sets the style of all the caption bars of the wxFoldPanel. The changes are applied immediately */
void ApplyCaptionStyleAll(const wxCaptionBarStyle &style) {
for(size_t i = 0; i < GetCount(); i++)
{
wxFoldPanel item = Item(i);
ApplyCaptionStyle(item, style);
}
};
/** Returns the currently used caption style for the wxFoldPanel. It is returned as a wxCaptionBarStyle class.
after modifying it, it can be set again */
wxCaptionBarStyle GetCaptionStyle(wxFoldPanel &fp) const {
wxCHECK2(fp.IsOk(), wxEmptyCaptionBarStyle);
return fp.GetItem()->GetCaptionStyle();
};
/** Returns the currently used caption style for the wxFoldPanel. It is returned as a wxCaptionBarStyle class.
after modifying it, it can be set again */
wxCaptionBarStyle GetCaptionStyle(wxFoldPanel &fp) const {
wxCHECK2(fp.IsOk(), wxEmptyCaptionBarStyle);
return fp.GetItem()->GetCaptionStyle();
};
private:
void OnPressCaption(wxCaptionBarEvent &event);
void OnSizePanel(wxSizeEvent &event);
void OnPressCaption(wxCaptionBarEvent &event);
void OnSizePanel(wxSizeEvent &event);
/** Resize the fold panels so they match the width */
void RedisplayFoldPanelItems();
/** Resize the fold panels so they match the width */
void RedisplayFoldPanelItems();
void OnPaint(wxPaintEvent &event);
void OnPaint(wxPaintEvent &event);
};
#endif // __WXFOLDPANELBAR_H__

View File

@ -1,8 +1,12 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wxFoldPanelItem.h
// Author: XX
// Created: Tuesday, June 22, 2004 21:01:02
// Copyright: XX
// Name: foldpanelitem.h
// Purpose: wxFoldPanel
// Author: Jorgen Bodde
// Modified by:
// Created: 22/06/2004
// RCS-ID: $Id$
// Copyright: (c) Jorgen Bodde
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __WXFOLDPANELITEM_H__
@ -27,119 +31,119 @@
class wxFoldWindowItem
{
private:
wxWindow *_wnd;
int _type, _flags;
int _leftSpacing,
_rightSpacing,
_ySpacing;
int _lineWidth, _lineY;
wxColour _sepLineColour;
wxWindow *_wnd;
int _type, _flags;
int _leftSpacing,
_rightSpacing,
_ySpacing;
int _lineWidth, _lineY;
wxColour _sepLineColour;
public:
enum
{
WINDOW = 0,
SEPARATOR
};
// wxWindow constructor. This initialises the class as a wxWindow type
wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH, int ySpacing = wxFPB_DEFAULT_YSPACING,
int leftSpacing = wxFPB_DEFAULT_LEFTSPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING)
: _wnd(wnd)
, _type(WINDOW)
, _ySpacing(ySpacing)
, _leftSpacing(leftSpacing)
, _rightSpacing(rightSpacing)
, _flags(flags)
, _lineWidth(0)
, _lineY(0)
{
};
enum
{
WINDOW = 0,
SEPARATOR
};
// separator constructor. This initialises the class as a separator type
wxFoldWindowItem(int y, const wxColour &lineColor = *wxBLACK, int ySpacing = wxFPB_DEFAULT_YSPACING,
int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING)
: _wnd(0)
, _type(SEPARATOR)
, _ySpacing(ySpacing)
, _leftSpacing(leftSpacing)
, _rightSpacing(rightSpacing)
, _flags(wxFPB_ALIGN_WIDTH)
, _sepLineColour(lineColor)
, _lineWidth(0)
, _lineY(y)
{
};
// wxWindow constructor. This initialises the class as a wxWindow type
wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH, int ySpacing = wxFPB_DEFAULT_YSPACING,
int leftSpacing = wxFPB_DEFAULT_LEFTSPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING)
: _wnd(wnd)
, _type(WINDOW)
, _ySpacing(ySpacing)
, _leftSpacing(leftSpacing)
, _rightSpacing(rightSpacing)
, _flags(flags)
, _lineWidth(0)
, _lineY(0)
{
};
// TODO: Make a c'tor for a captioned splitter
// separator constructor. This initialises the class as a separator type
wxFoldWindowItem(int y, const wxColour &lineColor = *wxBLACK, int ySpacing = wxFPB_DEFAULT_YSPACING,
int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING)
: _wnd(0)
, _type(SEPARATOR)
, _ySpacing(ySpacing)
, _leftSpacing(leftSpacing)
, _rightSpacing(rightSpacing)
, _flags(wxFPB_ALIGN_WIDTH)
, _sepLineColour(lineColor)
, _lineWidth(0)
, _lineY(y)
{
};
int GetType() const {
return _type;
};
// TODO: Make a c'tor for a captioned splitter
int GetLineY() const {
return _lineY;
};
int GetType() const {
return _type;
};
int GetLineWidth() const {
return _lineWidth;
};
int GetLineY() const {
return _lineY;
};
const wxColour &GetLineColour() const {
return _sepLineColour;
};
int GetLineWidth() const {
return _lineWidth;
};
int GetLeftSpacing() const {
return _leftSpacing;
};
const wxColour &GetLineColour() const {
return _sepLineColour;
};
int GetRightSpacing() const {
return _rightSpacing;
};
int GetLeftSpacing() const {
return _leftSpacing;
};
int GetYSpacing() const {
return _ySpacing;
};
int GetRightSpacing() const {
return _rightSpacing;
};
// returns the window height if type is wxFoldWindowItem::WINDOW
// and returns the total size plus the extra spacing
int GetYSpacing() const {
return _ySpacing;
};
int GetWindowHeight() const {
int value = 0;
if(_type == WINDOW)
{
wxCHECK(_wnd, 0);
wxSize size = _wnd->GetSize();
value = size.GetHeight() + _ySpacing;
}
else if(_type == SEPARATOR)
value = 1 + _ySpacing;
// returns the window height if type is wxFoldWindowItem::WINDOW
// and returns the total size plus the extra spacing
return value;
};
int GetWindowHeight() const {
int value = 0;
if(_type == WINDOW)
{
wxCHECK(_wnd, 0);
wxSize size = _wnd->GetSize();
value = size.GetHeight() + _ySpacing;
}
else if(_type == SEPARATOR)
value = 1 + _ySpacing;
// resize the element, whatever it is. A separator or
// line will be always alligned by width
void ResizeItem(int width) {
if((_flags & wxFPB_ALIGN_WIDTH))
{
// allign by taking full width
int myWidth = width - _leftSpacing - _rightSpacing;
if(myWidth < 0)
myWidth = 10; // can't have negative width
if(_type == SEPARATOR)
_lineWidth = myWidth;
else
{
wxCHECK2(_wnd, return);
_wnd->SetSize(wxSize(myWidth, -1));
}
}
};
return value;
};
// resize the element, whatever it is. A separator or
// line will be always alligned by width
void ResizeItem(int width) {
if((_flags & wxFPB_ALIGN_WIDTH))
{
// allign by taking full width
int myWidth = width - _leftSpacing - _rightSpacing;
if(myWidth < 0)
myWidth = 10; // can't have negative width
if(_type == SEPARATOR)
_lineWidth = myWidth;
else
{
wxCHECK2(_wnd, return);
_wnd->SetSize(wxSize(myWidth, wxDefaultCoord));
}
}
};
};
@ -150,104 +154,104 @@ WX_DECLARE_OBJARRAY(wxFoldWindowItem, wxFoldWindowItemArray);
/** \wxFoldPanelItem
This class is a child sibling of the wxFoldPanelBar class. It will be containing a wxCaptionBar class
for receiving of events, and a the rest of the area can be populated by a wxPanel derived class.
for receiving of events, and a the rest of the area can be populated by a wxPanel derived class.
*/
class wxFoldPanelItem: public wxPanel
{
private:
wxCaptionBar *_captionBar;
wxCaptionBar *_captionBar;
bool _controlCreated;
int _yUserSize,
_yPanelSize,
_yLastInsertPos;
int _yPos;
bool _userSized;
bool _controlCreated;
int _yUserSize,
_yPanelSize,
_yLastInsertPos;
int _yPos;
bool _userSized;
private:
DECLARE_CLASS( wxFoldPanelItem )
DECLARE_EVENT_TABLE()
private:
wxFoldWindowItemArray _items;
wxFoldWindowItemArray _items;
void OnSize(wxSizeEvent &event);
void OnPressCaption(wxCaptionBarEvent &event);
void OnPaint(wxPaintEvent &event);
void OnSize(wxSizeEvent &event);
void OnPressCaption(wxCaptionBarEvent &event);
void OnPaint(wxPaintEvent &event);
public:
// constructors and destructors
wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons = 0, bool collapsedInitially = false,
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons = 0, bool collapsedInitially = false,
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
virtual ~wxFoldPanelItem();
/** Add a window item to the list of items on this panel. The flags are wxFPB_ALIGN_LEFT for a non sizing
window element, and wxFPB_ALIGN_WIDTH for a width alligned item. The ySpacing parameter reserves a number
of pixels before the window element, and leftSpacing is an indent. rightSpacing is only relevant when the
style wxFPB_ALIGN_WIDTH is chosen. */
void AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing);
void AddSeparator(const wxColour &color, int ySpacing, int leftSpacing, int rightSpacing);
/** Add a window item to the list of items on this panel. The flags are wxFPB_ALIGN_LEFT for a non sizing
window element, and wxFPB_ALIGN_WIDTH for a width alligned item. The ySpacing parameter reserves a number
of pixels before the window element, and leftSpacing is an indent. rightSpacing is only relevant when the
style wxFPB_ALIGN_WIDTH is chosen. */
void AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing);
void AddSeparator(const wxColour &color, int ySpacing, int leftSpacing, int rightSpacing);
/** Repositions this wxFoldPanelBar and reports the height occupied for the next wxFoldPanelBar in the
list */
int Reposition(int y);
/** Repositions this wxFoldPanelBar and reports the height occupied for the next wxFoldPanelBar in the
list */
int Reposition(int y);
void ResizePanel();
void ResizePanel();
/** Return expanded or collapsed status. If the panel is expanded, true is returned */
bool IsExpanded() const {
return !_captionBar->IsCollapsed();
};
/** Return expanded or collapsed status. If the panel is expanded, true is returned */
bool IsExpanded() const {
return !_captionBar->IsCollapsed();
};
/** Return Y pos */
/** Return Y pos */
int GetY() const {
return _yPos;
};
int GetY() const {
return _yPos;
};
// this should not be called by the user, because it doesn't trigger the parent
// to tell it that we are collapsed or expanded, it only changes visual state
void Collapse() {
_captionBar->Collapse();
ResizePanel();
};
// this should not be called by the user, because it doesn't trigger the parent
// to tell it that we are collapsed or expanded, it only changes visual state
void Collapse() {
_captionBar->Collapse();
ResizePanel();
};
// this should not be called by the user, because it doesn't trigger the parent
// to tell it that we are collapsed or expanded, it only changes visual state
void Expand() {
_captionBar->Expand();
ResizePanel();
};
// this should not be called by the user, because it doesn't trigger the parent
// to tell it that we are collapsed or expanded, it only changes visual state
void Expand() {
_captionBar->Expand();
ResizePanel();
};
/* Return size of panel */
/* Return size of panel */
int GetPanelHeight() const {
if(_captionBar->IsCollapsed())
return GetCaptionHeight();
else if(_userSized)
return _yUserSize;
return _yPanelSize;
};
int GetPanelHeight() const {
if(_captionBar->IsCollapsed())
return GetCaptionHeight();
else if(_userSized)
return _yUserSize;
return _yPanelSize;
};
// returns height of caption only. This is for folding calulation
// purposes
// returns height of caption only. This is for folding calulation
// purposes
int GetCaptionHeight() const {
wxSize size = _captionBar->GetSize();
return size.GetHeight();
};
int GetCaptionHeight() const {
wxSize size = _captionBar->GetSize();
return size.GetHeight();
};
void ApplyCaptionStyle(const wxCaptionBarStyle &style) {
wxCHECK2(_captionBar, return);
_captionBar->SetCaptionStyle(false, style);
};
void ApplyCaptionStyle(const wxCaptionBarStyle &style) {
wxCHECK2(_captionBar, return);
_captionBar->SetCaptionStyle(false, style);
};
wxCaptionBarStyle GetCaptionStyle() {
wxCHECK(_captionBar, wxEmptyCaptionBarStyle);
return _captionBar->GetCaptionStyle();
};
wxCaptionBarStyle GetCaptionStyle() {
wxCHECK(_captionBar, wxEmptyCaptionBarStyle);
return _captionBar->GetCaptionStyle();
};
};