wxFoldBar now also horizontal (with API methods renamed to mean length rather than height) and more with wxWidgets coding standards. Sample adjustement to changing orientation.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2,7 +2,8 @@
|
|||||||
// Name: captionbar.h
|
// Name: captionbar.h
|
||||||
// Purpose: wxFoldPanel
|
// Purpose: wxFoldPanel
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 22/06/2004
|
// Created: 22/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -27,44 +28,44 @@
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
/** Specifies the bars as gradient vertical filled caption bars going from top to bottom. The gradient
|
/** 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 */
|
starts with first colour, and ends with second colour */
|
||||||
wxCAPTIONBAR_GRADIENT_V = 1,
|
wxCAPTIONBAR_GRADIENT_V = 1,
|
||||||
/** Specifies the gradient going from left to right. The gradient starts with first colour, and
|
/** Specifies the gradient going from left to right. The gradient starts with first colour, and
|
||||||
ends with second colour on the right */
|
ends with second colour on the right */
|
||||||
wxCAPTIONBAR_GRADIENT_H,
|
wxCAPTIONBAR_GRADIENT_H,
|
||||||
/** Fills the captionbar with a single colour. The first colour is used for this fill */
|
/** Fills the captionbar with a single colour. The first colour is used for this fill */
|
||||||
wxCAPTIONBAR_SINGLE,
|
wxCAPTIONBAR_SINGLE,
|
||||||
/** Draws a rectangle only using the second colour. The first colour is not used*/
|
/** Draws a rectangle only using the second colour. The first colour is not used*/
|
||||||
wxCAPTIONBAR_RECTANGLE,
|
wxCAPTIONBAR_RECTANGLE,
|
||||||
/** Fills the captionbar with a single colour (first colour) and draws a rectangle around it
|
/** Fills the captionbar with a single colour (first colour) and draws a rectangle around it
|
||||||
using the second colour. */
|
using the second colour. */
|
||||||
wxCAPTIONBAR_FILLED_RECTANGLE
|
wxCAPTIONBAR_FILLED_RECTANGLE
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \class wxCaptionBarStyle
|
/** \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
|
where the caption is displayed). It can either be applied at creation time be reapplied when styles need to
|
||||||
be changed.
|
be changed.
|
||||||
|
|
||||||
At construction time, all styles are set to their default transparency. This means none of the styles will be
|
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
|
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.
|
the color, font or panel style, these styles become active to be used.
|
||||||
*/
|
*/
|
||||||
class wxCaptionBarStyle
|
class wxCaptionBarStyle
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// boolean flags for default transparency on styles
|
// boolean flags for default transparency on styles
|
||||||
bool _firstColourUsed,
|
bool m_firstColourUsed,
|
||||||
_secondColourUsed,
|
m_secondColourUsed,
|
||||||
_textColourUsed,
|
m_textColourUsed,
|
||||||
_captionFontUsed,
|
m_captionFontUsed,
|
||||||
_captionStyleUsed;
|
m_captionStyleUsed;
|
||||||
|
|
||||||
wxFont _captionFont;
|
wxFont m_captionFont;
|
||||||
wxColour _firstColour, _secondColour, _textColour;
|
wxColour m_firstColour, m_secondColour, m_textColour;
|
||||||
|
|
||||||
int _captionStyle;
|
int m_captionStyle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Default constructor for this class */
|
/** Default constructor for this class */
|
||||||
@@ -77,41 +78,41 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void ResetDefaults() {
|
void ResetDefaults() {
|
||||||
_firstColourUsed = false;
|
m_firstColourUsed = false;
|
||||||
_secondColourUsed = false;
|
m_secondColourUsed = false;
|
||||||
_textColourUsed = false;
|
m_textColourUsed = false;
|
||||||
_captionFontUsed = false;
|
m_captionFontUsed = false;
|
||||||
_captionStyleUsed = false;
|
m_captionStyleUsed = false;
|
||||||
_captionStyle = wxCAPTIONBAR_GRADIENT_V;
|
m_captionStyle = wxCAPTIONBAR_GRADIENT_V;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Copy operator. Only the styles in use in the source object are being copied to the destination object. All other
|
/** Copy operator. Only the styles in use in the source object are being copied to the destination object. All other
|
||||||
styles are not copied */
|
styles are not copied */
|
||||||
void operator=(const wxCaptionBarStyle &s) {
|
void operator=(const wxCaptionBarStyle &s) {
|
||||||
if(s._captionStyleUsed)
|
if(s.m_captionStyleUsed)
|
||||||
{
|
{
|
||||||
_captionStyleUsed = true;
|
m_captionStyleUsed = true;
|
||||||
_captionStyle = s._captionStyle;
|
m_captionStyle = s.m_captionStyle;
|
||||||
}
|
}
|
||||||
if(s._captionFontUsed)
|
if(s.m_captionFontUsed)
|
||||||
{
|
{
|
||||||
_captionFontUsed = true;
|
m_captionFontUsed = true;
|
||||||
_captionFont = s._captionFont;
|
m_captionFont = s.m_captionFont;
|
||||||
}
|
}
|
||||||
if(s._firstColourUsed)
|
if(s.m_firstColourUsed)
|
||||||
{
|
{
|
||||||
_firstColourUsed = true;
|
m_firstColourUsed = true;
|
||||||
_firstColour = s._firstColour;
|
m_firstColour = s.m_firstColour;
|
||||||
}
|
}
|
||||||
if(s._secondColourUsed)
|
if(s.m_secondColourUsed)
|
||||||
{
|
{
|
||||||
_secondColourUsed = true;
|
m_secondColourUsed = true;
|
||||||
_secondColour = s._secondColour;
|
m_secondColour = s.m_secondColour;
|
||||||
}
|
}
|
||||||
if(s._textColourUsed)
|
if(s.m_textColourUsed)
|
||||||
{
|
{
|
||||||
_textColourUsed = true;
|
m_textColourUsed = true;
|
||||||
_textColour = s._textColour;
|
m_textColour = s.m_textColour;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,94 +121,94 @@ public:
|
|||||||
/** Set font for the caption bar. If this is not set, the font property is undefined
|
/** 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 */
|
and will not be used. Use CaptionFontUsed() to check if this style is used */
|
||||||
void SetCaptionFont(const wxFont &font) {
|
void SetCaptionFont(const wxFont &font) {
|
||||||
_captionFont = font;
|
m_captionFont = font;
|
||||||
_captionFontUsed = true;
|
m_captionFontUsed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Checks if the caption bar font is set */
|
/** Checks if the caption bar font is set */
|
||||||
bool CaptionFontUsed() const {
|
bool CaptionFontUsed() const {
|
||||||
return _captionFontUsed;
|
return m_captionFontUsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the font for the caption bar. Please be warned this will result in an assertion failure when
|
/** Returns the font for the caption bar. Please be warned this will result in an assertion failure when
|
||||||
this property is not previously set
|
this property is not previously set
|
||||||
\sa SetCaptionFont(), CaptionFontUsed() */
|
\sa SetCaptionFont(), CaptionFontUsed() */
|
||||||
wxFont GetCaptionFont() const {
|
wxFont GetCaptionFont() const {
|
||||||
wxASSERT(_captionFontUsed);
|
wxASSERT(m_captionFontUsed);
|
||||||
return _captionFont;
|
return m_captionFont;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------- FirstColour -------
|
// ------- FirstColour -------
|
||||||
|
|
||||||
/** Set first colour for the caption bar. If this is not set, the colour property is
|
/** 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
|
undefined and will not be used. Use FirstColourUsed() to check if this
|
||||||
style is used */
|
style is used */
|
||||||
void SetFirstColour(const wxColour &col) {
|
void SetFirstColour(const wxColour &col) {
|
||||||
_firstColour = col;
|
m_firstColour = col;
|
||||||
_firstColourUsed = true;
|
m_firstColourUsed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Checks if the first colour of the caption bar is set */
|
/** Checks if the first colour of the caption bar is set */
|
||||||
bool FirstColourUsed() const {
|
bool FirstColourUsed() const {
|
||||||
return _firstColourUsed;
|
return m_firstColourUsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the first colour for the caption bar. Please be warned this will
|
/** 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.
|
result in an assertion failure when this property is not previously set.
|
||||||
\sa SetCaptionFirstColour(), CaptionFirstColourUsed() */
|
\sa SetCaptionFirstColour(), CaptionFirstColourUsed() */
|
||||||
wxColour GetFirstColour() const {
|
wxColour GetFirstColour() const {
|
||||||
wxASSERT(_firstColourUsed);
|
wxASSERT(m_firstColourUsed);
|
||||||
return _firstColour;
|
return m_firstColour;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------- SecondColour -------
|
// ------- SecondColour -------
|
||||||
|
|
||||||
/** Set second colour for the caption bar. If this is not set, the colour property is undefined and
|
/** 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 */
|
will not be used. Use SecondColourUsed() to check if this style is used */
|
||||||
void SetSecondColour(const wxColour &col) {
|
void SetSecondColour(const wxColour &col) {
|
||||||
_secondColour = col;
|
m_secondColour = col;
|
||||||
_secondColourUsed = true;
|
m_secondColourUsed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Checks if the second colour of the caption bar is set */
|
/** Checks if the second colour of the caption bar is set */
|
||||||
bool SecondColourUsed() const {
|
bool SecondColourUsed() const {
|
||||||
return _secondColourUsed;
|
return m_secondColourUsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the second colour for the caption bar. Please be warned this will result in
|
/** 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.
|
an assertion failure when this property is not previously set.
|
||||||
\sa SetSecondColour(), SecondColourUsed() */
|
\sa SetSecondColour(), SecondColourUsed() */
|
||||||
wxColour GetSecondColour() const {
|
wxColour GetSecondColour() const {
|
||||||
wxASSERT(_secondColourUsed);
|
wxASSERT(m_secondColourUsed);
|
||||||
return _secondColour;
|
return m_secondColour;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------- Caption Text Colour -------
|
// ------- Caption Text Colour -------
|
||||||
|
|
||||||
/** Set caption colour for the caption bar. If this is not set, the colour property is
|
/** 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 */
|
undefined and will not be used. Use CaptionColourUsed() to check if this style is used */
|
||||||
void SetCaptionColour(const wxColour &col) {
|
void SetCaptionColour(const wxColour &col) {
|
||||||
_textColour = col;
|
m_textColour = col;
|
||||||
_textColourUsed = true;
|
m_textColourUsed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Checks if the caption colour of the caption bar is set */
|
/** Checks if the caption colour of the caption bar is set */
|
||||||
bool CaptionColourUsed() const {
|
bool CaptionColourUsed() const {
|
||||||
return _textColourUsed;
|
return m_textColourUsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the caption colour for the caption bar. Please be warned this will
|
/** 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.
|
result in an assertion failure when this property is not previously set.
|
||||||
\sa SetCaptionColour(), CaptionColourUsed() */
|
\sa SetCaptionColour(), CaptionColourUsed() */
|
||||||
wxColour GetCaptionColour() const {
|
wxColour GetCaptionColour() const {
|
||||||
wxASSERT(_textColourUsed);
|
wxASSERT(m_textColourUsed);
|
||||||
return _textColour;
|
return m_textColour;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ------- CaptionStyle -------
|
// ------- CaptionStyle -------
|
||||||
|
|
||||||
/** Set caption style for the caption bar. If this is not set, the property is
|
/** 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.
|
undefined and will not be used. Use CaptionStyleUsed() to check if this style is used.
|
||||||
The following styles can be applied:
|
The following styles can be applied:
|
||||||
- wxCAPTIONBAR_GRADIENT_V: Draws a vertical gradient from top to bottom
|
- wxCAPTIONBAR_GRADIENT_V: Draws a vertical gradient from top to bottom
|
||||||
- wxCAPTIONBAR_GRADIENT_H: Draws a horizontal gradient from left to right
|
- wxCAPTIONBAR_GRADIENT_H: Draws a horizontal gradient from left to right
|
||||||
@@ -216,21 +217,21 @@ public:
|
|||||||
- wxCAPTIONBAR_FILLED_RECTANGLE: Draws a filled rectangle and a border around it
|
- wxCAPTIONBAR_FILLED_RECTANGLE: Draws a filled rectangle and a border around it
|
||||||
*/
|
*/
|
||||||
void SetCaptionStyle(int style) {
|
void SetCaptionStyle(int style) {
|
||||||
_captionStyle = style;
|
m_captionStyle = style;
|
||||||
_captionStyleUsed = true;
|
m_captionStyleUsed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Checks if the caption style of the caption bar is set */
|
/** Checks if the caption style of the caption bar is set */
|
||||||
bool CaptionStyleUsed() const {
|
bool CaptionStyleUsed() const {
|
||||||
return _captionStyleUsed;
|
return m_captionStyleUsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the caption style for the caption bar. Please be warned this will
|
/** 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.
|
result in an assertion failure when this property is not previously set.
|
||||||
\sa SetCaptionStyle(), CaptionStyleUsed() */
|
\sa SetCaptionStyle(), CaptionStyleUsed() */
|
||||||
int GetCaptionStyle() const {
|
int GetCaptionStyle() const {
|
||||||
wxASSERT(_captionStyleUsed);
|
wxASSERT(m_captionStyleUsed);
|
||||||
return _captionStyle;
|
return m_captionStyle;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -238,7 +239,7 @@ public:
|
|||||||
|
|
||||||
/** \class wxCaptionBar
|
/** \class wxCaptionBar
|
||||||
This class is a graphical caption component that consists of a caption and a clickable arrow.
|
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
|
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
|
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.
|
the icon which changed). The parent panel can reduce size or expand again.
|
||||||
@@ -252,20 +253,20 @@ public:
|
|||||||
class WXDLLIMPEXP_FOLDBAR wxCaptionBar: public wxWindow
|
class WXDLLIMPEXP_FOLDBAR wxCaptionBar: public wxWindow
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wxString _caption;
|
wxString m_caption;
|
||||||
wxImageList *_foldIcons;
|
wxImageList *m_foldIcons;
|
||||||
wxSize _oldSize;
|
wxSize m_oldSize;
|
||||||
//wxFont _captionFont;
|
//wxFont m_captionFont;
|
||||||
int _rightIndent;
|
int m_rightIndent;
|
||||||
int _iconWidth, _iconHeight;
|
int m_iconWidth, m_iconHeight;
|
||||||
//int _captionStyle;
|
//int m_captionStyle;
|
||||||
|
|
||||||
//wxColour _firstColour, _secondColour, _textColour;
|
//wxColour m_firstColour, m_secondColour, m_textColour;
|
||||||
|
|
||||||
/** True when the caption is in collapsed state (means at the bottom of the wxFoldPanel */
|
/** True when the caption is in collapsed state (means at the bottom of the wxFoldPanel */
|
||||||
bool _collapsed;
|
bool m_collapsed;
|
||||||
|
|
||||||
wxCaptionBarStyle _style;
|
wxCaptionBarStyle m_captionStyle;
|
||||||
|
|
||||||
/** Fills the background of the caption with either a gradient, or a solid color */
|
/** Fills the background of the caption with either a gradient, or a solid color */
|
||||||
void FillCaptionBackground(wxPaintDC &dc);
|
void FillCaptionBackground(wxPaintDC &dc);
|
||||||
@@ -282,38 +283,40 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructor of wxCaptionBar. To create a wxCaptionBar with the arrow images, simply pass an image list
|
/** 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
|
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. */
|
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,
|
wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images,
|
||||||
wxWindowID id = wxID_ANY, const wxCaptionBarStyle &cbstyle = wxEmptyCaptionBarStyle,
|
wxWindowID id = wxID_ANY, const wxCaptionBarStyle &cbstyle = wxEmptyCaptionBarStyle,
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);
|
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 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,
|
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 */
|
the styles which are not set in the wxCaptionBarStyle will be ignored */
|
||||||
void SetCaptionStyle(bool applyDefault, wxCaptionBarStyle style = wxEmptyCaptionBarStyle) {
|
void SetCaptionStyle(bool applyDefault, wxCaptionBarStyle style = wxEmptyCaptionBarStyle) {
|
||||||
ApplyCaptionStyle(style, applyDefault);
|
ApplyCaptionStyle(style, applyDefault);
|
||||||
Refresh();
|
Refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the current style of the captionbar in a wxCaptionBarStyle class. This can be used to change and set back the
|
/** Returns the current style of the captionbar in a wxCaptionBarStyle class. This can be used to change and set back the
|
||||||
changes. */
|
changes. */
|
||||||
wxCaptionBarStyle GetCaptionStyle() {
|
wxCaptionBarStyle GetCaptionStyle() {
|
||||||
return _style;
|
return m_captionStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool IsVertical() const;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/** Sets a pointer to an image list resource (a non owned pointer) to the collapsed and expand icon bitmap.
|
/** 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
|
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
|
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.
|
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
|
If no wxImageList is assigned, there will be no fold icons and only the doubleclick on the panel
|
||||||
will work to collapse / expand.
|
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
|
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
|
collapsed state of the bitmap. The size of the bitmap is taken in account when the minimal height and
|
||||||
widht is calculated.
|
widht is calculated.
|
||||||
|
|
||||||
@@ -322,10 +325,10 @@ public:
|
|||||||
all the windows accordingly */
|
all the windows accordingly */
|
||||||
|
|
||||||
void SetFoldIcons(wxImageList *images) {
|
void SetFoldIcons(wxImageList *images) {
|
||||||
_foldIcons = images;
|
m_foldIcons = images;
|
||||||
_iconWidth = _iconHeight = 0;
|
m_iconWidth = m_iconHeight = 0;
|
||||||
if(_foldIcons)
|
if(m_foldIcons)
|
||||||
_foldIcons->GetSize(0, _iconWidth, _iconHeight);
|
m_foldIcons->GetSize(0, m_iconWidth, m_iconHeight);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
};
|
};
|
||||||
@@ -334,37 +337,37 @@ public:
|
|||||||
|
|
||||||
/** Returns wether the status of the bar is expanded or collapsed */
|
/** Returns wether the status of the bar is expanded or collapsed */
|
||||||
bool IsCollapsed() const {
|
bool IsCollapsed() const {
|
||||||
return _collapsed;
|
return m_collapsed;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Sets the amount of pixels on the right from which the bitmap is trailing. If this is 0, it will be
|
/** 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
|
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 */
|
assigning an image list to prevent a redraw */
|
||||||
|
|
||||||
void SetRightIndent(int pixels) {
|
void SetRightIndent(int pixels) {
|
||||||
wxCHECK2(pixels >= 0, return);
|
wxCHECK2(pixels >= 0, return);
|
||||||
_rightIndent = pixels;
|
m_rightIndent = pixels;
|
||||||
// issue a refresh (if we have a bmp)
|
// issue a refresh (if we have a bmp)
|
||||||
if(_foldIcons)
|
if(m_foldIcons)
|
||||||
Refresh();
|
Refresh();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Return the best size for this panel, based upon the font assigned to this window, and the
|
/** Return the best size for this panel, based upon the font assigned to this window, and the
|
||||||
caption string */
|
caption string */
|
||||||
wxSize DoGetBestSize() const;
|
wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
/** This sets the internal state / representation to collapsed. This does not trigger a wxCaptionBarEvent
|
/** This sets the internal state / representation to collapsed. This does not trigger a wxCaptionBarEvent
|
||||||
to be sent to the parent */
|
to be sent to the parent */
|
||||||
void Collapse() {
|
void Collapse() {
|
||||||
_collapsed = true;
|
m_collapsed = true;
|
||||||
RedrawIconBitmap();
|
RedrawIconBitmap();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This sets the internal state / representation to expanded. This does not trigger a wxCaptionBarEvent
|
/** This sets the internal state / representation to expanded. This does not trigger a wxCaptionBarEvent
|
||||||
to be sent to the parent */
|
to be sent to the parent */
|
||||||
void Expand() {
|
void Expand() {
|
||||||
_collapsed = false;
|
m_collapsed = false;
|
||||||
RedrawIconBitmap();
|
RedrawIconBitmap();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -380,10 +383,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
/** The paint event for flat or gradient fill */
|
/** 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 */
|
/** For clicking the icon, the mouse event must be intercepted */
|
||||||
void OnMouseEvent(wxMouseEvent& event);
|
void OnMouseEvent(wxMouseEvent& event);
|
||||||
|
|
||||||
/** Maybe when focus (don't know how yet) a cursor left or backspace will collapse or expand */
|
/** Maybe when focus (don't know how yet) a cursor left or backspace will collapse or expand */
|
||||||
void OnChar(wxKeyEvent& event);
|
void OnChar(wxKeyEvent& event);
|
||||||
|
|
||||||
@@ -398,7 +401,7 @@ protected:
|
|||||||
/***********************************************************************************************************/
|
/***********************************************************************************************************/
|
||||||
|
|
||||||
/** \class wxCaptionBarEvent
|
/** \class wxCaptionBarEvent
|
||||||
This event will be sent when a EVT_CAPTIONBAR is mapped in the parent. It is to notify the parent
|
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
|
that the bar is now in collapsed or expanded state. The parent should re-arrange the associated
|
||||||
windows accordingly */
|
windows accordingly */
|
||||||
|
|
||||||
@@ -406,49 +409,49 @@ class WXDLLIMPEXP_FOLDBAR wxCaptionBarEvent : public wxCommandEvent
|
|||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _collapsed;
|
bool m_collapsed;
|
||||||
wxCaptionBar *_bar;
|
wxCaptionBar *m_captionBar;
|
||||||
void *_tag;
|
void *m_tag;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxCaptionBarEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
wxCaptionBarEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
||||||
: wxCommandEvent(commandType, id)
|
: wxCommandEvent(commandType, id)
|
||||||
, _collapsed(false)
|
, m_collapsed(false)
|
||||||
, _bar(0)
|
, m_captionBar(NULL)
|
||||||
, _tag(0)
|
, m_tag(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/** Constructor for clone copy */
|
/** Constructor for clone copy */
|
||||||
wxCaptionBarEvent(const wxCaptionBarEvent &event);
|
wxCaptionBarEvent(const wxCaptionBarEvent &event);
|
||||||
|
|
||||||
/** Clone function */
|
/** Clone function */
|
||||||
virtual wxEvent *Clone() const {
|
virtual wxEvent *Clone() const {
|
||||||
return new wxCaptionBarEvent(*this);
|
return new wxCaptionBarEvent(*this);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns wether the bar is expanded or collapsed. True means expanded */
|
/** Returns wether the bar is expanded or collapsed. True means expanded */
|
||||||
bool GetFoldStatus() const {
|
bool GetFoldStatus() const {
|
||||||
wxCHECK(_bar, false);
|
wxCHECK(m_captionBar, false);
|
||||||
return !_bar->IsCollapsed();
|
return !m_captionBar->IsCollapsed();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the bar associated with this event */
|
/** Returns the bar associated with this event */
|
||||||
wxCaptionBar *GetBar() const {
|
wxCaptionBar *GetCaptionBar() const {
|
||||||
return _bar;
|
return m_captionBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetTag(void *tag) {
|
void SetTag(void *tag) {
|
||||||
_tag = tag;
|
m_tag = tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
void *GetTag() const {
|
void *GetTag() const {
|
||||||
return _tag;
|
return m_tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Sets the bar associated with this event, should not used
|
/** Sets the bar associated with this event, should not used
|
||||||
by any other then the originator of the event */
|
by any other then the originator of the event */
|
||||||
void SetBar(wxCaptionBar *bar) {
|
void SetCaptionBar(wxCaptionBar *bar) {
|
||||||
_bar = bar;
|
m_captionBar = bar;
|
||||||
};
|
};
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxCaptionBarEvent)
|
DECLARE_DYNAMIC_CLASS(wxCaptionBarEvent)
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldpanelbar.h
|
// Name: foldpanelbar.h
|
||||||
// Purpose: wxFoldPanel
|
// Purpose: wxFoldPanel
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 22/06/2004
|
// Created: 22/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -12,12 +13,6 @@
|
|||||||
#ifndef __WXFOLDPANELBAR_H__
|
#ifndef __WXFOLDPANELBAR_H__
|
||||||
#define __WXFOLDPANELBAR_H__
|
#define __WXFOLDPANELBAR_H__
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
|
||||||
#include "wx/wx.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "foldpanelitem.h"
|
|
||||||
|
|
||||||
/** Not yet supported but added for future reference. Single fold forces other panels to close when
|
/** 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
|
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 */
|
size left in the client area */
|
||||||
@@ -26,6 +21,10 @@
|
|||||||
/** All panels are stacked to the bottom. When they are expanded again they show up at the top */
|
/** 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
|
||||||
|
|
||||||
|
/** Orientation flag **/
|
||||||
|
#define wxFPB_HORIZONTAL wxHORIZONTAL /* 0x0004 */
|
||||||
|
#define wxFPB_VERTICAL wxVERTICAL /* 0x0008 */
|
||||||
|
|
||||||
/** Not yet supported, but added for future reference. Single fold plus panels will be stacked at the bottom */
|
/** 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
|
||||||
|
|
||||||
@@ -34,6 +33,8 @@
|
|||||||
|
|
||||||
#define wxFPB_DEFAULT_STYLE wxTAB_TRAVERSAL | wxNO_BORDER
|
#define wxFPB_DEFAULT_STYLE wxTAB_TRAVERSAL | wxNO_BORDER
|
||||||
|
|
||||||
|
#include "wx/foldbar/foldpanelitem.h"
|
||||||
|
|
||||||
/** \class wxFoldPanel
|
/** \class wxFoldPanel
|
||||||
This class is used to return a reference to the fold panel that is added by wxFoldPanelBar::AddFoldPanel(). Use
|
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()
|
wxFoldPanel::IsOk() to check wether the result is ok to be used in further operations. Use wxFoldPanel::GetItem()
|
||||||
@@ -43,43 +44,43 @@
|
|||||||
class wxFoldPanel
|
class wxFoldPanel
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wxFoldPanelItem *_item;
|
wxFoldPanelItem *m_item;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructor, usually not directly used by the developer. */
|
/** Constructor, usually not directly used by the developer. */
|
||||||
wxFoldPanel(wxFoldPanelItem *item)
|
wxFoldPanel(wxFoldPanelItem *item)
|
||||||
: _item(item)
|
: m_item(item)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true if this is a valid wxFoldPanelItem reference. */
|
/** Returns true if this is a valid wxFoldPanelItem reference. */
|
||||||
bool IsOk() const {
|
bool IsOk() const {
|
||||||
return (_item != 0);
|
return (m_item != 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Copy operator to assign one instance to the other, this is needed because these classes are passed
|
/** Copy operator to assign one instance to the other, this is needed because these classes are passed
|
||||||
as instance not by reference. */
|
as instance not by reference. */
|
||||||
virtual void operator=(const wxFoldPanel &item) {
|
virtual void operator=(const wxFoldPanel &item) {
|
||||||
_item = item._item;
|
m_item = item.m_item;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _NO_DOXYGEN_
|
#ifndef _NO_DOXYGEN_
|
||||||
// not allowed to be seen by doxygen
|
// not allowed to be seen by doxygen
|
||||||
wxFoldPanelItem *GetItem() const {
|
wxFoldPanelItem *GetItem() const {
|
||||||
return _item;
|
return m_item;
|
||||||
};
|
};
|
||||||
#endif
|
#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
|
\code
|
||||||
wxFoldPanel item = _pnl->AddFoldPanel(wxT("Test me"), false);
|
wxFoldPanel item = m_pnl->AddFoldPanel(wxT("Test me"), false);
|
||||||
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), wxID_ANY, wxT("Press Me")));
|
m_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), wxID_ANY, wxT("Press Me")));
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
wxFoldPanelItem *GetParent() const {
|
wxFoldPanelItem *GetParent() const {
|
||||||
wxASSERT(_item);
|
wxASSERT(m_item);
|
||||||
return _item;
|
return m_item;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -107,14 +108,14 @@ private:
|
|||||||
DECLARE_CLASS( wxFoldPanelBar )
|
DECLARE_CLASS( wxFoldPanelBar )
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
wxImageList *_images;
|
wxImageList *m_images;
|
||||||
wxFoldPanelItemArray _panels;
|
wxFoldPanelItemArray m_panels;
|
||||||
wxBoxSizer* _panelSizer;
|
wxBoxSizer* m_panelSizer;
|
||||||
wxPanel *_foldPanel, *_bottomPanel;
|
wxPanel *m_foldPanel, *m_bottomPanel;
|
||||||
wxFlexGridSizer* _mainSizer;
|
wxFlexGridSizer* m_mainSizer;
|
||||||
bool _controlCreated;
|
bool m_controlCreated;
|
||||||
wxBitmap *_moreBmp;
|
wxBitmap *m_moreBmp;
|
||||||
int _extraStyle;
|
int m_extraStyle;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** Refreshes all the panels from given index down to last one */
|
/** Refreshes all the panels from given index down to last one */
|
||||||
@@ -123,10 +124,10 @@ private:
|
|||||||
/** Refreshes all the panels from given pointer down to last one in the list */
|
/** Refreshes all the panels from given pointer down to last one in the list */
|
||||||
void RefreshPanelsFrom(wxFoldPanelItem *item);
|
void RefreshPanelsFrom(wxFoldPanelItem *item);
|
||||||
|
|
||||||
/** Returns the height of the panels that are expanded and collapsed. This is useful to determine
|
/** Returns the length 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
|
quickly what size is used to display, and what is left at the bottom (right) to allign
|
||||||
the collapsed panels. */
|
the collapsed panels. */
|
||||||
int GetPanelsHeight(int &collapsed, int &expanded);
|
int GetPanelsLength(int &collapsed, int &expanded);
|
||||||
|
|
||||||
/** Reposition all the collapsed panels to the bottom. When it is not possible to
|
/** 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
|
allign them to the bottom, stick them behind the visible panels. The Rect holds the
|
||||||
@@ -182,49 +183,54 @@ public:
|
|||||||
\code
|
\code
|
||||||
|
|
||||||
// create the wxFoldPanelBar
|
// create the wxFoldPanelBar
|
||||||
_pnl = new wxFoldPanelBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM);
|
m_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.
|
// 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);
|
wxFoldPanel item = m_pnl->AddFoldPanel(wxT("Test me"), false);
|
||||||
|
|
||||||
// now add a button to the fold panel. Mind that the button should be made child of the
|
// 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.
|
// wxFoldPanel and not of the main form.
|
||||||
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, wxT("Collapse Me")));
|
m_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
|
// 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.
|
// color and also the indents and width alligning like a control.
|
||||||
_pnl->AddFoldPanelSeperator(item);
|
m_pnl->AddFoldPanelSeperator(item);
|
||||||
|
|
||||||
// now add a text ctrl. Also very easy. Allign this on width so that when the control gets wider
|
// 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.
|
// the text control also sizes along.
|
||||||
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, wxT("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
|
m_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, wxT("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 20);
|
||||||
|
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
int AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags = wxFPB_ALIGN_WIDTH,
|
int AddFoldPanelWindow(const wxFoldPanel &panel, wxWindow *window, int flags = wxFPB_ALIGN_WIDTH,
|
||||||
int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTSPACING,
|
int Spacing = wxFPB_DEFAULT_SPACING, int leftSpacing = wxFPB_DEFAULT_LEFTSPACING,
|
||||||
int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING);
|
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
|
/** 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
|
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(). */
|
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 AddFoldPanelSeperator(const wxFoldPanel &panel, const wxColour &color = wxColour(167,167,167),
|
||||||
int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
|
int Spacing = wxFPB_DEFAULT_SPACING, int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
|
||||||
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING);
|
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING);
|
||||||
|
|
||||||
/** Returns the number of panels currently present in the wxFoldPanelBar. This is independent if they are
|
/** Returns the number of panels currently present in the wxFoldPanelBar. This is independent if they are
|
||||||
visible or hidden. */
|
visible or hidden. */
|
||||||
size_t GetCount() const {
|
size_t GetCount() const {
|
||||||
return _panels.GetCount();
|
return m_panels.GetCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool IsVertical() const
|
||||||
|
{
|
||||||
|
return HasFlag(wxFPB_VERTICAL);
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the wxFoldPanel reference belonging to the current index. An empty panel is returned when the
|
/** 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
|
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
|
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. */
|
to the panel by number. */
|
||||||
wxFoldPanel Item(size_t i) {
|
wxFoldPanel Item(size_t i) {
|
||||||
wxCHECK((int)i >= 0 && i < GetCount(), wxFoldPanel(0));
|
wxCHECK((int)i >= 0 && i < GetCount(), wxFoldPanel(0));
|
||||||
return wxFoldPanel(_panels.Item(i));
|
return wxFoldPanel(m_panels.Item(i));
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Collapses the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
|
/** Collapses the given wxFoldPanel reference, and updates the foldpanel bar. In the wxFPB_COLLAPSE_TO_BOTTOM
|
||||||
@@ -271,7 +277,6 @@ public:
|
|||||||
return fp.GetItem()->GetCaptionStyle();
|
return fp.GetItem()->GetCaptionStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnPressCaption(wxCaptionBarEvent &event);
|
void OnPressCaption(wxCaptionBarEvent &event);
|
||||||
void OnSizePanel(wxSizeEvent &event);
|
void OnSizePanel(wxSizeEvent &event);
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldpanelitem.h
|
// Name: foldpanelitem.h
|
||||||
// Purpose: wxFoldPanel
|
// Purpose: wxFoldPanel
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 22/06/2004
|
// Created: 22/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -12,18 +13,14 @@
|
|||||||
#ifndef __WXFOLDPANELITEM_H__
|
#ifndef __WXFOLDPANELITEM_H__
|
||||||
#define __WXFOLDPANELITEM_H__
|
#define __WXFOLDPANELITEM_H__
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#include "wx/foldbar/captionbar.h"
|
||||||
#include "wx/wx.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "captionbar.h"
|
#define wxFPB_ALIGN_LEFT 0
|
||||||
|
|
||||||
#define wxFPB_ALIGN_LEFT 0
|
|
||||||
#define wxFPB_ALIGN_WIDTH 1
|
#define wxFPB_ALIGN_WIDTH 1
|
||||||
|
|
||||||
#define wxFPB_DEFAULT_LEFTSPACING 5
|
#define wxFPB_DEFAULT_LEFTSPACING 5
|
||||||
#define wxFPB_DEFAULT_RIGHTSPACING 10
|
#define wxFPB_DEFAULT_RIGHTSPACING 10
|
||||||
#define wxFPB_DEFAULT_YSPACING 8
|
#define wxFPB_DEFAULT_SPACING 8
|
||||||
|
|
||||||
#define wxFPB_DEFAULT_LEFTLINESPACING 2
|
#define wxFPB_DEFAULT_LEFTLINESPACING 2
|
||||||
#define wxFPB_DEFAULT_RIGHTLINESPACING 2
|
#define wxFPB_DEFAULT_RIGHTLINESPACING 2
|
||||||
@@ -31,116 +28,117 @@
|
|||||||
class wxFoldWindowItem
|
class wxFoldWindowItem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wxWindow *_wnd;
|
wxWindow *m_wndItem;
|
||||||
int _type, _flags;
|
int m_type, m_flags;
|
||||||
int _leftSpacing,
|
int m_leftSpacing,
|
||||||
_rightSpacing,
|
m_rightSpacing,
|
||||||
_ySpacing;
|
m_Spacing;
|
||||||
int _lineWidth, _lineY;
|
int m_lineLength, m_lineY;
|
||||||
wxColour _sepLineColour;
|
wxColour m_sepLineColour;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
WINDOW = 0,
|
WINDOW = 0,
|
||||||
SEPARATOR
|
SEPARATOR
|
||||||
};
|
};
|
||||||
|
|
||||||
// wxWindow constructor. This initialises the class as a wxWindow type
|
// wxWindow constructor. This initialises the class as a wxWindow type
|
||||||
wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH, int ySpacing = wxFPB_DEFAULT_YSPACING,
|
wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH, int Spacing = wxFPB_DEFAULT_SPACING,
|
||||||
int leftSpacing = wxFPB_DEFAULT_LEFTSPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING)
|
int leftSpacing = wxFPB_DEFAULT_LEFTSPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING)
|
||||||
: _wnd(wnd)
|
: m_wndItem(wnd)
|
||||||
, _type(WINDOW)
|
, m_type(WINDOW)
|
||||||
, _flags(flags)
|
, m_flags(flags)
|
||||||
, _leftSpacing(leftSpacing)
|
, m_leftSpacing(leftSpacing)
|
||||||
, _rightSpacing(rightSpacing)
|
, m_rightSpacing(rightSpacing)
|
||||||
, _ySpacing(ySpacing)
|
, m_Spacing(Spacing)
|
||||||
, _lineWidth(0)
|
, m_lineLength(0)
|
||||||
, _lineY(0)
|
, m_lineY(0)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
// separator constructor. This initialises the class as a separator type
|
// separator constructor. This initialises the class as a separator type
|
||||||
wxFoldWindowItem(int y, const wxColour &lineColor = *wxBLACK, int ySpacing = wxFPB_DEFAULT_YSPACING,
|
wxFoldWindowItem(int y, const wxColour &lineColor = *wxBLACK, int Spacing = wxFPB_DEFAULT_SPACING,
|
||||||
int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
|
int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
|
||||||
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING)
|
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING)
|
||||||
: _wnd(0)
|
: m_wndItem(NULL)
|
||||||
, _type(SEPARATOR)
|
, m_type(SEPARATOR)
|
||||||
, _flags(wxFPB_ALIGN_WIDTH)
|
, m_flags(wxFPB_ALIGN_WIDTH)
|
||||||
, _leftSpacing(leftSpacing)
|
, m_leftSpacing(leftSpacing)
|
||||||
, _rightSpacing(rightSpacing)
|
, m_rightSpacing(rightSpacing)
|
||||||
, _ySpacing(ySpacing)
|
, m_Spacing(Spacing)
|
||||||
, _lineWidth(0)
|
, m_lineLength(0)
|
||||||
, _lineY(y)
|
, m_lineY(y)
|
||||||
, _sepLineColour(lineColor)
|
, m_sepLineColour(lineColor)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Make a c'tor for a captioned splitter
|
// TODO: Make a c'tor for a captioned splitter
|
||||||
|
|
||||||
int GetType() const {
|
int GetType() const {
|
||||||
return _type;
|
return m_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetLineY() const {
|
int GetLineY() const {
|
||||||
return _lineY;
|
return m_lineY;
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetLineWidth() const {
|
int GetLineLength() const {
|
||||||
return _lineWidth;
|
return m_lineLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
const wxColour &GetLineColour() const {
|
const wxColour &GetLineColour() const {
|
||||||
return _sepLineColour;
|
return m_sepLineColour;
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetLeftSpacing() const {
|
int GetLeftSpacing() const {
|
||||||
return _leftSpacing;
|
return m_leftSpacing;
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetRightSpacing() const {
|
int GetRightSpacing() const {
|
||||||
return _rightSpacing;
|
return m_rightSpacing;
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetYSpacing() const {
|
int GetSpacing() const {
|
||||||
return _ySpacing;
|
return m_Spacing;
|
||||||
};
|
};
|
||||||
|
|
||||||
// returns the window height if type is wxFoldWindowItem::WINDOW
|
// returns space needed by the window if type is wxFoldWindowItem::WINDOW
|
||||||
// and returns the total size plus the extra spacing
|
// and returns the total size plus the extra spacing
|
||||||
|
|
||||||
int GetWindowHeight() const {
|
int GetWindowLength(bool vertical) const {
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if(_type == WINDOW)
|
if(m_type == WINDOW)
|
||||||
{
|
{
|
||||||
wxCHECK(_wnd, 0);
|
wxCHECK(m_wndItem, 0);
|
||||||
wxSize size = _wnd->GetSize();
|
wxSize size = m_wndItem->GetSize();
|
||||||
value = size.GetHeight() + _ySpacing;
|
value = ( vertical ? size.GetHeight() : size.GetWidth() ) + m_Spacing;
|
||||||
}
|
}
|
||||||
else if(_type == SEPARATOR)
|
else if(m_type == SEPARATOR)
|
||||||
value = 1 + _ySpacing;
|
value = 1 + m_Spacing;
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
|
|
||||||
// resize the element, whatever it is. A separator or
|
// resize the element, whatever it is. A separator or
|
||||||
// line will be always alligned by width
|
// line will be always alligned by width or hight
|
||||||
|
// depending on orientation of the whole panel
|
||||||
|
|
||||||
void ResizeItem(int width) {
|
void ResizeItem(int size, bool vertical) {
|
||||||
if((_flags & wxFPB_ALIGN_WIDTH))
|
if(m_flags & wxFPB_ALIGN_WIDTH)
|
||||||
{
|
{
|
||||||
// allign by taking full width
|
// allign by taking full width
|
||||||
int myWidth = width - _leftSpacing - _rightSpacing;
|
int mySize = size - m_leftSpacing - m_rightSpacing;
|
||||||
|
|
||||||
if(myWidth < 0)
|
if(mySize < 0)
|
||||||
myWidth = 10; // can't have negative width
|
mySize = 10; // can't have negative width
|
||||||
|
|
||||||
if(_type == SEPARATOR)
|
if(m_type == SEPARATOR)
|
||||||
_lineWidth = myWidth;
|
m_lineLength = mySize;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxCHECK2(_wnd, return);
|
wxCHECK2(m_wndItem, return);
|
||||||
_wnd->SetSize(wxSize(myWidth, wxDefaultCoord));
|
m_wndItem->SetSize(vertical?mySize:wxDefaultCoord, vertical?wxDefaultCoord:mySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -154,27 +152,27 @@ WX_DECLARE_OBJARRAY(wxFoldWindowItem, wxFoldWindowItemArray);
|
|||||||
|
|
||||||
/** \wxFoldPanelItem
|
/** \wxFoldPanelItem
|
||||||
This class is a child sibling of the wxFoldPanelBar class. It will be containing a wxCaptionBar class
|
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 WXDLLIMPEXP_FOLDBAR wxFoldPanelItem: public wxPanel
|
class WXDLLIMPEXP_FOLDBAR wxFoldPanelItem: public wxPanel
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
wxCaptionBar *_captionBar;
|
wxCaptionBar *m_captionBar;
|
||||||
|
|
||||||
bool _controlCreated;
|
bool m_controlCreated;
|
||||||
int _yUserSize,
|
int m_userSize,
|
||||||
_yPanelSize,
|
m_panelSize,
|
||||||
_yLastInsertPos;
|
m_lastInsertPos;
|
||||||
int _yPos;
|
int m_itemPos;
|
||||||
bool _userSized;
|
bool m_userSized;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_CLASS( wxFoldPanelItem )
|
DECLARE_CLASS( wxFoldPanelItem )
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxFoldWindowItemArray _items;
|
wxFoldWindowItemArray m_items;
|
||||||
|
|
||||||
void OnSize(wxSizeEvent &event);
|
void OnSize(wxSizeEvent &event);
|
||||||
void OnPressCaption(wxCaptionBarEvent &event);
|
void OnPressCaption(wxCaptionBarEvent &event);
|
||||||
@@ -182,75 +180,77 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// constructors and destructors
|
// constructors and destructors
|
||||||
wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons = 0, bool collapsedInitially = false,
|
wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons = 0, bool collapsedInitially = false,
|
||||||
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
|
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
|
||||||
virtual ~wxFoldPanelItem();
|
virtual ~wxFoldPanelItem();
|
||||||
|
|
||||||
/** Add a window item to the list of items on this panel. The flags are wxFPB_ALIGN_LEFT for a non sizing
|
/** 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
|
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
|
of pixels before the window element, and leftSpacing is an indent. rightSpacing is only relevant when the
|
||||||
style wxFPB_ALIGN_WIDTH is chosen. */
|
style wxFPB_ALIGN_WIDTH is chosen. */
|
||||||
void AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing);
|
void AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing);
|
||||||
|
|
||||||
void AddSeparator(const wxColour &color, 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
|
/** Repositions this wxFoldPanelBar and reports the length occupied for the next wxFoldPanelBar in the
|
||||||
list */
|
list */
|
||||||
int Reposition(int y);
|
int Reposition(int pos);
|
||||||
|
|
||||||
void ResizePanel();
|
void ResizePanel();
|
||||||
|
|
||||||
/** Return expanded or collapsed status. If the panel is expanded, true is returned */
|
/** Return expanded or collapsed status. If the panel is expanded, true is returned */
|
||||||
bool IsExpanded() const {
|
bool IsExpanded() const {
|
||||||
return !_captionBar->IsCollapsed();
|
return !m_captionBar->IsCollapsed();
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Return Y pos */
|
/** Return Y pos */
|
||||||
|
|
||||||
int GetY() const {
|
int GetItemPos() const {
|
||||||
return _yPos;
|
return m_itemPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
// this should not be called by the user, because it doesn't trigger the parent
|
// 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
|
// to tell it that we are collapsed or expanded, it only changes visual state
|
||||||
void Collapse() {
|
void Collapse() {
|
||||||
_captionBar->Collapse();
|
m_captionBar->Collapse();
|
||||||
ResizePanel();
|
ResizePanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
// this should not be called by the user, because it doesn't trigger the parent
|
// 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
|
// to tell it that we are collapsed or expanded, it only changes visual state
|
||||||
void Expand() {
|
void Expand() {
|
||||||
_captionBar->Expand();
|
m_captionBar->Expand();
|
||||||
ResizePanel();
|
ResizePanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Return size of panel */
|
/* Return size of panel */
|
||||||
|
|
||||||
int GetPanelHeight() const {
|
int GetPanelLength() const {
|
||||||
if(_captionBar->IsCollapsed())
|
if(m_captionBar->IsCollapsed())
|
||||||
return GetCaptionHeight();
|
return GetCaptionLength();
|
||||||
else if(_userSized)
|
else if(m_userSized)
|
||||||
return _yUserSize;
|
return m_userSize;
|
||||||
return _yPanelSize;
|
return m_panelSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
// returns height of caption only. This is for folding calulation
|
bool IsVertical() const;
|
||||||
|
|
||||||
|
// returns space of caption only. This is for folding calulation
|
||||||
// purposes
|
// purposes
|
||||||
|
|
||||||
int GetCaptionHeight() const {
|
int GetCaptionLength() const {
|
||||||
wxSize size = _captionBar->GetSize();
|
wxSize size = m_captionBar->GetSize();
|
||||||
return size.GetHeight();
|
return IsVertical() ? size.GetHeight() : size.GetWidth();
|
||||||
};
|
};
|
||||||
|
|
||||||
void ApplyCaptionStyle(const wxCaptionBarStyle &style) {
|
void ApplyCaptionStyle(const wxCaptionBarStyle &style) {
|
||||||
wxCHECK2(_captionBar, return);
|
wxCHECK2(m_captionBar, return);
|
||||||
_captionBar->SetCaptionStyle(false, style);
|
m_captionBar->SetCaptionStyle(false, style);
|
||||||
};
|
};
|
||||||
|
|
||||||
wxCaptionBarStyle GetCaptionStyle() {
|
wxCaptionBarStyle GetCaptionStyle() {
|
||||||
wxCHECK(_captionBar, wxEmptyCaptionBarStyle);
|
wxCHECK(m_captionBar, wxEmptyCaptionBarStyle);
|
||||||
return _captionBar->GetCaptionStyle();
|
return m_captionBar->GetCaptionStyle();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldpanelbartest.cpp
|
// Name: foldpanelbartest.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 18/06/2004
|
// Created: 18/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -19,12 +20,6 @@
|
|||||||
#include "wx/wx.h"
|
#include "wx/wx.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
ID_COLLAPSEME = 10000,
|
|
||||||
ID_EXPANDME
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "wx/foldbar/foldpanelbar.h"
|
#include "wx/foldbar/foldpanelbar.h"
|
||||||
#include "foldtestpanel.h"
|
#include "foldtestpanel.h"
|
||||||
|
|
||||||
@@ -54,12 +49,15 @@ public:
|
|||||||
class MyAppFrame : public wxFrame
|
class MyAppFrame : public wxFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
|
MyAppFrame(const wxString& title,
|
||||||
long style = wxDEFAULT_FRAME_STYLE);
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxDEFAULT_FRAME_STYLE);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
void OnOrientation(wxCommandEvent& event);
|
||||||
|
|
||||||
// extra handlers for the bar, to show how it works
|
// extra handlers for the bar, to show how it works
|
||||||
|
|
||||||
@@ -68,7 +66,8 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
wxMenuBar *CreateMenuBar();
|
wxMenuBar *CreateMenuBar();
|
||||||
wxFoldPanelBar *_pnl;
|
void CreateFoldBar(bool vertical = true);
|
||||||
|
wxFoldPanelBar *m_pnl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
@@ -81,8 +80,12 @@ private:
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
// menu items
|
// menu items
|
||||||
FoldPanelBarTest_Quit = 1,
|
FoldPanelBarTest_Quit = wxID_EXIT,
|
||||||
FoldPanelBarTest_About = wxID_ABOUT
|
FoldPanelBarTest_About = wxID_ABOUT,
|
||||||
|
ID_COLLAPSEME = wxID_HIGHEST,
|
||||||
|
ID_EXPANDME,
|
||||||
|
FoldPanelBarTest_Horizontal,
|
||||||
|
FoldPanelBarTest_Vertical
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -90,10 +93,12 @@ 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_MENU(FoldPanelBarTest_Horizontal, MyAppFrame::OnOrientation)
|
||||||
EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe)
|
EVT_MENU(FoldPanelBarTest_Vertical, MyAppFrame::OnOrientation)
|
||||||
|
EVT_BUTTON(ID_COLLAPSEME, MyAppFrame::OnCollapseMe)
|
||||||
|
EVT_BUTTON(ID_EXPANDME, MyAppFrame::OnExpandMe)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
IMPLEMENT_APP(MyApp)
|
IMPLEMENT_APP(MyApp)
|
||||||
@@ -108,8 +113,7 @@ IMPLEMENT_APP(MyApp)
|
|||||||
|
|
||||||
bool MyApp::OnInit()
|
bool MyApp::OnInit()
|
||||||
{
|
{
|
||||||
MyAppFrame *frame = new MyAppFrame(_T("FoldPanelBarTest wxWidgets Test Application"),
|
MyAppFrame *frame = new MyAppFrame(_T("FoldPanelBarTest wxWidgets Test Application"));
|
||||||
wxPoint(50, 50), wxSize(200, 500));
|
|
||||||
|
|
||||||
SetTopWindow(frame);
|
SetTopWindow(frame);
|
||||||
|
|
||||||
@@ -122,49 +126,24 @@ 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, wxID_ANY, title, pos, size, style)
|
: wxFrame(NULL, wxID_ANY, title, pos, size, style), m_pnl(NULL)
|
||||||
{
|
{
|
||||||
SetIcon(wxICON(mondrian));
|
SetIcon(wxICON(mondrian));
|
||||||
|
|
||||||
SetMenuBar(CreateMenuBar());
|
SetMenuBar(CreateMenuBar());
|
||||||
|
|
||||||
|
CreateFoldBar();
|
||||||
|
|
||||||
CreateStatusBar(2);
|
CreateStatusBar(2);
|
||||||
SetStatusText(_T("Welcome to wxWidgets!"));
|
SetStatusText(_T("Welcome to wxWidgets!"));
|
||||||
|
|
||||||
_pnl = new wxFoldPanelBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, wxFPB_COLLAPSE_TO_BOTTOM);
|
|
||||||
|
|
||||||
wxFoldPanel item = _pnl->AddFoldPanel(_T("Test me"), false);
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse Me")));
|
|
||||||
|
|
||||||
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->AddFoldPanelSeperator(item);
|
|
||||||
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
|
|
||||||
|
|
||||||
item = _pnl->AddFoldPanel(_T("Some opinions ..."), false);
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("I like this")));
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And also this")));
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And gimme this too")));
|
|
||||||
|
|
||||||
_pnl->AddFoldPanelSeperator(item);
|
|
||||||
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("Check this too if you like")));
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("What about this")));
|
|
||||||
|
|
||||||
|
|
||||||
item = _pnl->AddFoldPanel(_T("Choose one ..."), false);
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter your comment")));
|
|
||||||
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_YSPACING, 20);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenuBar *MyAppFrame::CreateMenuBar()
|
wxMenuBar *MyAppFrame::CreateMenuBar()
|
||||||
{
|
{
|
||||||
wxMenu *menuFile = new wxMenu;
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
menuFile->Append(FoldPanelBarTest_Horizontal, _T("&Horizontal\tAlt-H"));
|
||||||
|
menuFile->Append(FoldPanelBarTest_Vertical, _T("&Vertical\tAlt-V"));
|
||||||
|
menuFile->AppendSeparator();
|
||||||
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;
|
||||||
@@ -177,9 +156,61 @@ wxMenuBar *MyAppFrame::CreateMenuBar()
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// event handlers
|
void MyAppFrame::CreateFoldBar(bool vertical)
|
||||||
|
{
|
||||||
|
if (vertical)
|
||||||
|
SetSize(200,500);
|
||||||
|
else
|
||||||
|
SetSize(900,200);
|
||||||
|
|
||||||
|
wxFoldPanelBar *bar = new wxFoldPanelBar(this,
|
||||||
|
wxID_ANY,
|
||||||
|
wxDefaultPosition,
|
||||||
|
wxDefaultSize,
|
||||||
|
wxFPB_DEFAULT_STYLE | ( vertical ? wxFPB_VERTICAL : wxFPB_HORIZONTAL ) ,
|
||||||
|
wxFPB_COLLAPSE_TO_BOTTOM);
|
||||||
|
|
||||||
|
wxFoldPanel item = bar->AddFoldPanel(_T("Test me"), false);
|
||||||
|
bar->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse Me")));
|
||||||
|
|
||||||
|
item = bar->AddFoldPanel(_T("Test me too!"), true);
|
||||||
|
bar->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_EXPANDME, _T("Expand first one")));
|
||||||
|
bar->AddFoldPanelSeperator(item);
|
||||||
|
bar->AddFoldPanelWindow(item, new FoldTestPanel(item.GetParent(), wxID_ANY));
|
||||||
|
|
||||||
|
bar->AddFoldPanelSeperator(item);
|
||||||
|
|
||||||
|
bar->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 20);
|
||||||
|
|
||||||
|
item = bar->AddFoldPanel(_T("Some opinions ..."), false);
|
||||||
|
bar->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("I like this")));
|
||||||
|
if( vertical)
|
||||||
|
{
|
||||||
|
// do not add this for horizontal for better presentation
|
||||||
|
bar->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And also this")));
|
||||||
|
bar->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("And gimme this too")));
|
||||||
|
}
|
||||||
|
|
||||||
|
bar->AddFoldPanelSeperator(item);
|
||||||
|
|
||||||
|
bar->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("Check this too if you like")));
|
||||||
|
if( vertical)
|
||||||
|
{
|
||||||
|
// do not add this for horizontal for better presentation
|
||||||
|
bar->AddFoldPanelWindow(item, new wxCheckBox(item.GetParent(), wxID_ANY, _T("What about this")));
|
||||||
|
}
|
||||||
|
|
||||||
|
item = bar->AddFoldPanel(_T("Choose one ..."), false);
|
||||||
|
bar->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter your comment")));
|
||||||
|
bar->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comment")), wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 20);
|
||||||
|
|
||||||
|
if (m_pnl) m_pnl->Destroy();
|
||||||
|
|
||||||
|
m_pnl = bar;
|
||||||
|
|
||||||
|
wxSize size = GetClientSize();
|
||||||
|
m_pnl->SetSize( 0, 0, size.GetWidth(), size.GetHeight() );
|
||||||
|
}
|
||||||
|
|
||||||
void MyAppFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
void MyAppFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
@@ -196,14 +227,19 @@ 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::OnOrientation(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
CreateFoldBar(event.GetId()==FoldPanelBarTest_Vertical);
|
||||||
|
}
|
||||||
|
|
||||||
void MyAppFrame::OnCollapseMe(wxCommandEvent &WXUNUSED(event))
|
void MyAppFrame::OnCollapseMe(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxFoldPanel item = _pnl->Item(0);
|
wxFoldPanel item = m_pnl->Item(0);
|
||||||
_pnl->Collapse(item);
|
m_pnl->Collapse(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAppFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event))
|
void MyAppFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event))
|
||||||
{
|
{
|
||||||
_pnl->Expand(_pnl->Item(0));
|
m_pnl->Expand(m_pnl->Item(0));
|
||||||
_pnl->Collapse(_pnl->Item(1));
|
m_pnl->Collapse(m_pnl->Item(1));
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldtestpanel.cpp
|
// Name: foldtestpanel.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 18/06/2004
|
// Created: 18/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -17,7 +18,7 @@
|
|||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
@@ -59,7 +60,7 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
FoldTestPanel::FoldTestPanel( )
|
FoldTestPanel::FoldTestPanel( )
|
||||||
{
|
{
|
||||||
delete _images;
|
delete m_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 )
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldtestpanel.h
|
// Name: foldtestpanel.h
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 18/06/2004
|
// Created: 18/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
* Includes
|
* Includes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wx/foldbar/captionbar.h"
|
#include "wx/foldbar/foldpanelbar.h"
|
||||||
|
|
||||||
////@begin includes
|
////@begin includes
|
||||||
////@end includes
|
////@end includes
|
||||||
@@ -72,8 +73,8 @@ class FoldTestPanel: public wxPanel
|
|||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxImageList *_images;
|
wxImageList *m_images;
|
||||||
wxRect _oldsize;
|
wxRect m_oldsize;
|
||||||
|
|
||||||
void OnCaptionPanel(wxCaptionBarEvent &event);
|
void OnCaptionPanel(wxCaptionBarEvent &event);
|
||||||
|
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: captionbar.cpp
|
// Name: captionbar.cpp
|
||||||
// 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: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 18/06/2004
|
// Created: 18/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -17,17 +18,14 @@
|
|||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/wx.h"
|
||||||
#include "wx/dcclient.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wx/app.h>
|
#include "wx/foldbar/foldpanelbar.h"
|
||||||
|
|
||||||
#include "wx/foldbar/captionbar.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxCaptionBar
|
* wxCaptionBar
|
||||||
@@ -43,22 +41,22 @@ 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)
|
, m_caption(caption)
|
||||||
, _foldIcons(images)
|
, m_foldIcons(images)
|
||||||
, _rightIndent(wxFPB_BMP_RIGHTSPACE)
|
, m_rightIndent(wxFPB_BMP_RIGHTSPACE)
|
||||||
, _iconWidth(16)
|
, m_iconWidth(16)
|
||||||
, _iconHeight(16)
|
, m_iconHeight(16)
|
||||||
, _collapsed(false)
|
, m_collapsed(false)
|
||||||
{
|
{
|
||||||
// do initialisy thingy stuff
|
// do initialisy thingy stuff
|
||||||
|
|
||||||
ApplyCaptionStyle(cbstyle, true);
|
ApplyCaptionStyle(cbstyle, true);
|
||||||
|
|
||||||
// set initial size
|
// set initial size
|
||||||
if(_foldIcons)
|
if(m_foldIcons)
|
||||||
{
|
{
|
||||||
wxASSERT(_foldIcons->GetImageCount() > 1);
|
wxASSERT(m_foldIcons->GetImageCount() > 1);
|
||||||
_foldIcons->GetSize(0, _iconWidth, _iconHeight);
|
m_foldIcons->GetSize(0, m_iconWidth, m_iconHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,12 +103,14 @@ void wxCaptionBar::ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool appl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply the style
|
// apply the style
|
||||||
_style = newstyle;
|
m_captionStyle = newstyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCaptionBar::OnPaint(wxPaintEvent& WXUNUSED(event))
|
void wxCaptionBar::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
wxRect wndRect = GetRect();
|
||||||
|
bool vertical = IsVertical();
|
||||||
|
|
||||||
// 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
|
||||||
@@ -119,24 +119,36 @@ void wxCaptionBar::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
FillCaptionBackground(dc);
|
FillCaptionBackground(dc);
|
||||||
|
|
||||||
dc.SetFont(_style.GetCaptionFont());
|
dc.SetFont(m_captionStyle.GetCaptionFont());
|
||||||
dc.DrawText(_caption, 4, (wxFPB_EXTRA_Y / 2));
|
if(vertical)
|
||||||
|
dc.DrawText(m_caption, 4, (wxFPB_EXTRA_Y / 2));
|
||||||
|
else
|
||||||
|
dc.DrawRotatedText(m_caption, (wxFPB_EXTRA_Y / 2) , wndRect.GetBottom() - 4 , 90 );
|
||||||
|
|
||||||
// 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(m_foldIcons)
|
||||||
{
|
{
|
||||||
wxCHECK2(_foldIcons->GetImageCount() > 1, return);
|
wxCHECK2(m_foldIcons->GetImageCount() > 1, return);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if(_collapsed)
|
if(m_collapsed)
|
||||||
index = 1;
|
index = 1;
|
||||||
|
|
||||||
wxRect wndRect = GetRect();
|
if(vertical)
|
||||||
_foldIcons->Draw(index, dc, wndRect.GetRight() - _iconWidth - _rightIndent, (wndRect.GetHeight() - _iconHeight) / 2,
|
m_foldIcons->Draw(index,
|
||||||
wxIMAGELIST_DRAW_TRANSPARENT);
|
dc,
|
||||||
|
wndRect.GetRight() - m_iconWidth - m_rightIndent,
|
||||||
|
(wndRect.GetHeight() - m_iconHeight) / 2,
|
||||||
|
wxIMAGELIST_DRAW_TRANSPARENT);
|
||||||
|
else
|
||||||
|
m_foldIcons->Draw(index,
|
||||||
|
dc,
|
||||||
|
(wndRect.GetWidth() - m_iconWidth) / 2,
|
||||||
|
m_rightIndent,
|
||||||
|
wxIMAGELIST_DRAW_TRANSPARENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,13 +156,19 @@ void wxCaptionBar::FillCaptionBackground(wxPaintDC &dc)
|
|||||||
{
|
{
|
||||||
// dispatch right style for caption drawing
|
// dispatch right style for caption drawing
|
||||||
|
|
||||||
switch(_style.GetCaptionStyle())
|
switch(m_captionStyle.GetCaptionStyle())
|
||||||
{
|
{
|
||||||
case wxCAPTIONBAR_GRADIENT_V:
|
case wxCAPTIONBAR_GRADIENT_V:
|
||||||
DrawVerticalGradient(dc, GetRect());
|
if (IsVertical())
|
||||||
|
DrawVerticalGradient(dc, GetRect());
|
||||||
|
else
|
||||||
|
DrawHorizontalGradient(dc, GetRect());
|
||||||
break;
|
break;
|
||||||
case wxCAPTIONBAR_GRADIENT_H:
|
case wxCAPTIONBAR_GRADIENT_H:
|
||||||
DrawHorizontalGradient(dc, GetRect());
|
if (IsVertical())
|
||||||
|
DrawHorizontalGradient(dc, GetRect());
|
||||||
|
else
|
||||||
|
DrawVerticalGradient(dc, GetRect());
|
||||||
break;
|
break;
|
||||||
case wxCAPTIONBAR_SINGLE:
|
case wxCAPTIONBAR_SINGLE:
|
||||||
DrawSingleColour(dc, GetRect());
|
DrawSingleColour(dc, GetRect());
|
||||||
@@ -172,12 +190,14 @@ void wxCaptionBar::OnMouseEvent(wxMouseEvent& event)
|
|||||||
|
|
||||||
bool send_event = false;
|
bool send_event = false;
|
||||||
|
|
||||||
if (event.LeftDown() && _foldIcons)
|
if (event.LeftDown() && m_foldIcons)
|
||||||
{
|
{
|
||||||
wxPoint pt(event.GetPosition());
|
wxPoint pt(event.GetPosition());
|
||||||
wxRect rect = GetRect();
|
wxRect rect = GetRect();
|
||||||
|
bool vertical = IsVertical();
|
||||||
|
|
||||||
if(pt.x > (rect.GetWidth() - _iconWidth - _rightIndent))
|
if((vertical && pt.x > (rect.GetWidth() - m_iconWidth - m_rightIndent))||
|
||||||
|
(!vertical && pt.y < m_iconHeight + m_rightIndent))
|
||||||
send_event = true;
|
send_event = true;
|
||||||
}
|
}
|
||||||
else if(event.LeftDClick())
|
else if(event.LeftDClick())
|
||||||
@@ -188,7 +208,7 @@ void wxCaptionBar::OnMouseEvent(wxMouseEvent& event)
|
|||||||
if(send_event)
|
if(send_event)
|
||||||
{
|
{
|
||||||
wxCaptionBarEvent event(wxEVT_CAPTIONBAR);
|
wxCaptionBarEvent event(wxEVT_CAPTIONBAR);
|
||||||
event.SetBar(this);
|
event.SetCaptionBar(this);
|
||||||
|
|
||||||
::wxPostEvent(this, event);
|
::wxPostEvent(this, event);
|
||||||
|
|
||||||
@@ -206,13 +226,16 @@ wxSize wxCaptionBar::DoGetBestSize() const
|
|||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
|
|
||||||
GetTextExtent(_caption, &x, &y);
|
if(IsVertical())
|
||||||
|
GetTextExtent(m_caption, &x, &y);
|
||||||
|
else
|
||||||
|
GetTextExtent(m_caption, &y, &x);
|
||||||
|
|
||||||
if(x < _iconWidth)
|
if(x < m_iconWidth)
|
||||||
x = _iconWidth;
|
x = m_iconWidth;
|
||||||
|
|
||||||
if(y < _iconHeight)
|
if(y < m_iconHeight)
|
||||||
y = _iconHeight;
|
y = m_iconHeight;
|
||||||
|
|
||||||
// TODO: The extra wxFPB_EXTRA_X constants should be adjustable as well
|
// TODO: The extra wxFPB_EXTRA_X constants should be adjustable as well
|
||||||
|
|
||||||
@@ -227,19 +250,21 @@ void wxCaptionBar::DrawVerticalGradient(wxDC &dc, const wxRect &rect )
|
|||||||
if(rect.height < 1 || rect.width < 1)
|
if(rect.height < 1 || rect.width < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int size = rect.height;
|
||||||
|
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
|
||||||
|
|
||||||
// calculate gradient coefficients
|
// calculate gradient coefficients
|
||||||
wxColour col2 = _style.GetSecondColour(),
|
wxColour col2 = m_captionStyle.GetSecondColour(),
|
||||||
col1 = _style.GetFirstColour();
|
col1 = m_captionStyle.GetFirstColour();
|
||||||
|
|
||||||
double rstep = double((col2.Red() - col1.Red())) / double(rect.height), rf = 0,
|
double rstep = double((col2.Red() - col1.Red())) / double(size), rf = 0,
|
||||||
gstep = double((col2.Green() - col1.Green())) / double(rect.height), gf = 0,
|
gstep = double((col2.Green() - col1.Green())) / double(size), gf = 0,
|
||||||
bstep = double((col2.Blue() - col1.Blue())) / double(rect.height), bf = 0;
|
bstep = double((col2.Blue() - col1.Blue())) / double(size), bf = 0;
|
||||||
|
|
||||||
wxColour currCol;
|
wxColour currCol;
|
||||||
for(int y = rect.y; y < rect.y + rect.height; y++)
|
for(int y = rect.y; y < rect.y + size; y++)
|
||||||
{
|
{
|
||||||
currCol.Set(
|
currCol.Set(
|
||||||
(unsigned char)(col1.Red() + rf),
|
(unsigned char)(col1.Red() + rf),
|
||||||
@@ -247,7 +272,7 @@ void wxCaptionBar::DrawVerticalGradient(wxDC &dc, const wxRect &rect )
|
|||||||
(unsigned char)(col1.Blue() + bf)
|
(unsigned char)(col1.Blue() + bf)
|
||||||
);
|
);
|
||||||
dc.SetBrush( wxBrush( currCol, wxSOLID ) );
|
dc.SetBrush( wxBrush( currCol, wxSOLID ) );
|
||||||
dc.DrawRectangle( rect.x, rect.y + (y - rect.y), rect.width, rect.height );
|
dc.DrawRectangle( rect.x, rect.y + (y - rect.y), rect.width, size );
|
||||||
//currCol.Set(currCol.Red() + rstep, currCol.Green() + gstep, currCol.Blue() + bstep);
|
//currCol.Set(currCol.Red() + rstep, currCol.Green() + gstep, currCol.Blue() + bstep);
|
||||||
rf += rstep; gf += gstep; bf += bstep;
|
rf += rstep; gf += gstep; bf += bstep;
|
||||||
}
|
}
|
||||||
@@ -260,18 +285,20 @@ void wxCaptionBar::DrawHorizontalGradient(wxDC &dc, const wxRect &rect )
|
|||||||
if(rect.height < 1 || rect.width < 1)
|
if(rect.height < 1 || rect.width < 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
int size = rect.width;
|
||||||
|
|
||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
|
||||||
// calculate gradient coefficients
|
// calculate gradient coefficients
|
||||||
wxColour col2 = _style.GetSecondColour(),
|
wxColour col2 = m_captionStyle.GetSecondColour(),
|
||||||
col1 = _style.GetFirstColour();
|
col1 = m_captionStyle.GetFirstColour();
|
||||||
|
|
||||||
double rstep = double((col2.Red() - col1.Red())) / double(rect.width), rf = 0,
|
double rstep = double((col2.Red() - col1.Red())) / double(size), rf = 0,
|
||||||
gstep = double((col2.Green() - col1.Green())) / double(rect.width), gf = 0,
|
gstep = double((col2.Green() - col1.Green())) / double(size), gf = 0,
|
||||||
bstep = double((col2.Blue() - col1.Blue())) / double(rect.width), bf = 0;
|
bstep = double((col2.Blue() - col1.Blue())) / double(size), bf = 0;
|
||||||
|
|
||||||
wxColour currCol;
|
wxColour currCol;
|
||||||
for(int x = rect.x; x < rect.x + rect.width; x++)
|
for(int x = rect.x; x < rect.x + size; x++)
|
||||||
{
|
{
|
||||||
currCol.Set(
|
currCol.Set(
|
||||||
(unsigned char)(col1.Red() + rf),
|
(unsigned char)(col1.Red() + rf),
|
||||||
@@ -294,7 +321,7 @@ void wxCaptionBar::DrawSingleColour(wxDC &dc, const wxRect &rect )
|
|||||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||||
|
|
||||||
// draw simple rectangle
|
// draw simple rectangle
|
||||||
dc.SetBrush( wxBrush( _style.GetFirstColour(), wxSOLID ) );
|
dc.SetBrush( wxBrush( m_captionStyle.GetFirstColour(), wxSOLID ) );
|
||||||
dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height );
|
dc.DrawRectangle( rect.x, rect.y, rect.width, rect.height );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,14 +339,14 @@ void wxCaptionBar::DrawSingleRectangle(wxDC &dc, const wxRect &rect )
|
|||||||
wxBrush br;
|
wxBrush br;
|
||||||
br.SetStyle(wxSOLID);
|
br.SetStyle(wxSOLID);
|
||||||
|
|
||||||
if(_style.GetCaptionStyle() == wxCAPTIONBAR_RECTANGLE)
|
if(m_captionStyle.GetCaptionStyle() == wxCAPTIONBAR_RECTANGLE)
|
||||||
br.SetColour(GetParent()->GetBackgroundColour());
|
br.SetColour(GetParent()->GetBackgroundColour());
|
||||||
else
|
else
|
||||||
br.SetColour(_style.GetFirstColour());
|
br.SetColour(m_captionStyle.GetFirstColour());
|
||||||
|
|
||||||
// setup the pen frame
|
// setup the pen frame
|
||||||
|
|
||||||
wxPen pen(_style.GetSecondColour());
|
wxPen pen(m_captionStyle.GetSecondColour());
|
||||||
dc.SetPen(pen);
|
dc.SetPen(pen);
|
||||||
|
|
||||||
dc.SetBrush( br );
|
dc.SetBrush( br );
|
||||||
@@ -335,7 +362,7 @@ void wxCaptionBar::OnSize(wxSizeEvent &event)
|
|||||||
{
|
{
|
||||||
wxSize size = event.GetSize();
|
wxSize size = event.GetSize();
|
||||||
|
|
||||||
if(_foldIcons)
|
if(m_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,
|
||||||
@@ -344,13 +371,13 @@ void wxCaptionBar::OnSize(wxSizeEvent &event)
|
|||||||
|
|
||||||
// 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() - m_iconWidth - m_rightIndent, 0, m_iconWidth + m_rightIndent,
|
||||||
_iconWidth + _rightIndent);
|
m_iconWidth + m_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() - m_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
|
||||||
@@ -367,23 +394,32 @@ void wxCaptionBar::OnSize(wxSizeEvent &event)
|
|||||||
RefreshRect(rect);
|
RefreshRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
_oldSize = size;
|
m_oldSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCaptionBar::RedrawIconBitmap()
|
void wxCaptionBar::RedrawIconBitmap()
|
||||||
{
|
{
|
||||||
if(_foldIcons)
|
if(m_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() - m_iconWidth - m_rightIndent);
|
||||||
rect.SetWidth(_iconWidth + _rightIndent);
|
rect.SetWidth(m_iconWidth + m_rightIndent);
|
||||||
RefreshRect(rect);
|
RefreshRect(rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxCaptionBar::IsVertical() const
|
||||||
|
{
|
||||||
|
// parent of wxCaptionBar is wxFoldPanelItem
|
||||||
|
// default is vertical
|
||||||
|
wxFoldPanelItem *bar = wxDynamicCast(GetParent(), wxFoldPanelItem);
|
||||||
|
wxCHECK_MSG( bar, true, _T("wrong parent") );
|
||||||
|
return bar->IsVertical();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* wxCaptionBarEvent
|
* wxCaptionBarEvent
|
||||||
*/
|
*/
|
||||||
@@ -393,7 +429,7 @@ DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR)
|
|||||||
wxCaptionBarEvent::wxCaptionBarEvent(const wxCaptionBarEvent &event)
|
wxCaptionBarEvent::wxCaptionBarEvent(const wxCaptionBarEvent &event)
|
||||||
: wxCommandEvent(event)
|
: wxCommandEvent(event)
|
||||||
{
|
{
|
||||||
_bar = event._bar;
|
m_captionBar = event.m_captionBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR)
|
//DEFINE_EVENT_TYPE(wxEVT_CAPTIONBAR)
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldpanelbar.cpp
|
// Name: foldpanelbar.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 22/06/2004
|
// Created: 22/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -16,6 +17,10 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/foldbar/foldpanelbar.h"
|
#include "wx/foldbar/foldpanelbar.h"
|
||||||
#include "icon_collapsed.xpm"
|
#include "icon_collapsed.xpm"
|
||||||
#include "icon_expanded.xpm"
|
#include "icon_expanded.xpm"
|
||||||
@@ -40,9 +45,9 @@ 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)
|
: m_foldPanel(NULL)
|
||||||
, _bottomPanel(0)
|
, m_bottomPanel(NULL)
|
||||||
, _controlCreated(false)
|
, m_controlCreated(false)
|
||||||
{
|
{
|
||||||
Create( parent, id, position, size, style, extraStyle);
|
Create( parent, id, position, size, style, extraStyle);
|
||||||
}
|
}
|
||||||
@@ -51,7 +56,11 @@ void wxFoldPanelBar::Create( wxWindow *parent, wxWindowID id, const wxPoint &pos
|
|||||||
const wxSize& size, long style, long extraStyle )
|
const wxSize& size, long style, long extraStyle )
|
||||||
{
|
{
|
||||||
|
|
||||||
_extraStyle = extraStyle;
|
m_extraStyle = extraStyle;
|
||||||
|
|
||||||
|
// make sure there is any orientation
|
||||||
|
if ( ( style & wxFPB_HORIZONTAL ) != wxFPB_HORIZONTAL )
|
||||||
|
style |= wxFPB_VERTICAL;
|
||||||
|
|
||||||
// create the panel (duh!). This causes a size event, which we are going
|
// create the panel (duh!). This causes a size event, which we are going
|
||||||
// to skip when we are not initialised
|
// to skip when we are not initialised
|
||||||
@@ -60,57 +69,57 @@ void wxFoldPanelBar::Create( wxWindow *parent, wxWindowID id, const wxPoint &pos
|
|||||||
|
|
||||||
// the fold panel area
|
// the fold panel area
|
||||||
|
|
||||||
_foldPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL);
|
m_foldPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL);
|
||||||
|
|
||||||
// the extra area for some icons / context menu etc
|
// the extra area for some icons / context menu etc
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
_bottomPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(wxDefaultCoord,22), wxNO_BORDER|wxTAB_TRAVERSAL);
|
m_bottomPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(wxDefaultCoord,22), wxNO_BORDER|wxTAB_TRAVERSAL);
|
||||||
_bottomPanel->SetBackgroundColour(*wxWHITE);
|
m_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);
|
m_images = new wxImageList(16, 16);
|
||||||
|
|
||||||
wxBitmap *bmp = new wxBitmap(icon_expanded);
|
wxBitmap *bmp = new wxBitmap(icon_expanded);
|
||||||
_images->Add(*bmp);
|
m_images->Add(*bmp);
|
||||||
delete bmp;
|
delete bmp;
|
||||||
|
|
||||||
bmp = new wxBitmap(icon_collapsed);
|
bmp = new wxBitmap(icon_collapsed);
|
||||||
_images->Add(*bmp);
|
m_images->Add(*bmp);
|
||||||
delete bmp;
|
delete bmp;
|
||||||
|
|
||||||
_moreBmp = new wxBitmap(icon_theresmore);
|
m_moreBmp = new wxBitmap(icon_theresmore);
|
||||||
|
|
||||||
// do this as last, to check if create is already called
|
// do this as last, to check if create is already called
|
||||||
|
|
||||||
_controlCreated = true;
|
m_controlCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFoldPanelBar::~wxFoldPanelBar()
|
wxFoldPanelBar::~wxFoldPanelBar()
|
||||||
{
|
{
|
||||||
delete _images;
|
delete m_images;
|
||||||
delete _moreBmp;
|
delete m_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(m_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(m_foldPanel, caption, m_images, collapsedInitially, style);
|
||||||
|
|
||||||
// look at the last added one and reposition this one
|
// look at the last added one and reposition this one
|
||||||
int y = 0;
|
int pos = 0;
|
||||||
if(_panels.GetCount() > 0)
|
if(m_panels.GetCount() > 0)
|
||||||
y = _panels.Last()->GetY() + _panels.Last()->GetPanelHeight();
|
pos = m_panels.Last()->GetItemPos() + m_panels.Last()->GetPanelLength();
|
||||||
|
|
||||||
item->Reposition(y);
|
item->Reposition(pos);
|
||||||
_panels.Add(item);
|
m_panels.Add(item);
|
||||||
|
|
||||||
//return wxFoldPanel(item);
|
//return wxFoldPanel(item);
|
||||||
return wxFoldPanel(item);
|
return wxFoldPanel(item);
|
||||||
@@ -142,7 +151,7 @@ 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(!m_controlCreated)
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
return;
|
return;
|
||||||
@@ -166,12 +175,13 @@ void wxFoldPanelBar::OnSizePanel(wxSizeEvent &event)
|
|||||||
|
|
||||||
foldrect.SetX(0);
|
foldrect.SetX(0);
|
||||||
foldrect.SetY(0);
|
foldrect.SetY(0);
|
||||||
_foldPanel->SetSize(foldrect);
|
m_foldPanel->SetSize(foldrect);
|
||||||
|
|
||||||
if(_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM)
|
if(m_extraStyle & wxFPB_COLLAPSE_TO_BOTTOM)
|
||||||
{
|
{
|
||||||
wxRect rect = RepositionCollapsedToBottom();
|
wxRect rect = RepositionCollapsedToBottom();
|
||||||
if(rect.GetHeight() > 0)
|
bool vertical = IsVertical();
|
||||||
|
if((vertical && rect.GetHeight() > 0) || (!vertical && rect.GetWidth() > 0))
|
||||||
RefreshRect(rect);
|
RefreshRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,30 +201,30 @@ void wxFoldPanelBar::OnSizePanel(wxSizeEvent &event)
|
|||||||
|
|
||||||
bottomrect.SetHeight(22);
|
bottomrect.SetHeight(22);
|
||||||
bottomrect.SetX(0);
|
bottomrect.SetX(0);
|
||||||
_bottomPanel->SetSize(bottomrect);
|
m_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();
|
m_bottomPanel->Refresh();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFoldPanelBar::OnPaint(wxPaintEvent &event)
|
void wxFoldPanelBar::OnPaint(wxPaintEvent &event)
|
||||||
{
|
{
|
||||||
if(!_controlCreated)
|
if(!m_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(m_bottomPanel);
|
||||||
|
|
||||||
wxSize size = _bottomPanel->GetSize();
|
wxSize size = m_bottomPanel->GetSize();
|
||||||
int offset = (size.GetHeight() - _moreBmp->GetHeight()) / 2;
|
int offset = (size.GetHeight() - m_moreBmp->GetHeight()) / 2;
|
||||||
|
|
||||||
dc.DrawBitmap(*_moreBmp, size.GetWidth() - _moreBmp->GetWidth() - 2, offset, true);
|
dc.DrawBitmap(*m_moreBmp, size.GetWidth() - m_moreBmp->GetWidth() - 2, offset, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
@@ -235,7 +245,7 @@ void wxFoldPanelBar::RefreshPanelsFrom(wxFoldPanelItem *item)
|
|||||||
{
|
{
|
||||||
wxASSERT(item);
|
wxASSERT(item);
|
||||||
|
|
||||||
int i = _panels.Index(item);
|
int i = m_panels.Index(item);
|
||||||
if(i != wxNOT_FOUND)
|
if(i != wxNOT_FOUND)
|
||||||
RefreshPanelsFrom(i);
|
RefreshPanelsFrom(i);
|
||||||
}
|
}
|
||||||
@@ -248,14 +258,14 @@ void wxFoldPanelBar::RefreshPanelsFrom(size_t i)
|
|||||||
// 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(m_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 < m_panels.GetCount(); j++)
|
||||||
{
|
{
|
||||||
if(_panels.Item(j)->IsExpanded())
|
if(m_panels.Item(j)->IsExpanded())
|
||||||
offset += _panels.Item(j)->Reposition(offset);
|
offset += m_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
|
||||||
@@ -265,9 +275,9 @@ void wxFoldPanelBar::RefreshPanelsFrom(size_t i)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int y = _panels.Item(i)->GetY() + _panels.Item(i)->GetPanelHeight();
|
int pos = m_panels.Item(i)->GetItemPos() + m_panels.Item(i)->GetPanelLength();
|
||||||
for(i++; i < _panels.GetCount(); i++)
|
for(i++; i < m_panels.GetCount(); i++)
|
||||||
y += _panels.Item(i)->Reposition(y);
|
pos += m_panels.Item(i)->Reposition(pos);
|
||||||
}
|
}
|
||||||
Thaw();
|
Thaw();
|
||||||
}
|
}
|
||||||
@@ -277,9 +287,9 @@ 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 < m_panels.GetCount(); i++)
|
||||||
{
|
{
|
||||||
item = _panels.Item(i);
|
item = m_panels.Item(i);
|
||||||
wxASSERT(item);
|
wxASSERT(item);
|
||||||
|
|
||||||
item->ResizePanel();
|
item->ResizePanel();
|
||||||
@@ -289,18 +299,19 @@ void wxFoldPanelBar::RedisplayFoldPanelItems()
|
|||||||
wxRect wxFoldPanelBar::RepositionCollapsedToBottom()
|
wxRect wxFoldPanelBar::RepositionCollapsedToBottom()
|
||||||
{
|
{
|
||||||
wxRect value(0,0,0,0);
|
wxRect value(0,0,0,0);
|
||||||
|
bool vertical = IsVertical();
|
||||||
|
|
||||||
// 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);
|
GetPanelsLength(collapsed, expanded);
|
||||||
|
|
||||||
// if no room stick them behind the normal ones, else
|
// if no room stick them behind the normal ones, else
|
||||||
// at the bottom
|
// at the bottom
|
||||||
|
|
||||||
if((GetSize().GetHeight() - expanded - collapsed) < 0)
|
if(((vertical ? GetSize().GetHeight() : GetSize().GetWidth()) - expanded - collapsed) < 0)
|
||||||
offset = expanded;
|
offset = expanded;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -308,43 +319,50 @@ wxRect wxFoldPanelBar::RepositionCollapsedToBottom()
|
|||||||
// I will send it back as 'slack' so it does not need to
|
// I will send it back as 'slack' so it does not need to
|
||||||
// be recalulated.
|
// be recalulated.
|
||||||
|
|
||||||
value.SetX(0);
|
value.SetHeight(GetSize().GetHeight());
|
||||||
value.SetY(expanded);
|
|
||||||
value.SetHeight(GetSize().GetHeight() - expanded);
|
|
||||||
value.SetWidth(GetSize().GetWidth());
|
value.SetWidth(GetSize().GetWidth());
|
||||||
|
|
||||||
offset = GetSize().GetHeight() - collapsed;
|
if(vertical)
|
||||||
}
|
{
|
||||||
|
value.SetY(expanded);
|
||||||
|
value.SetHeight(value.GetHeight() - expanded);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value.SetX(expanded);
|
||||||
|
value.SetWidth(value.GetWidth() - expanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = (vertical ? GetSize().GetHeight() : GetSize().GetWidth()) - collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
// go reposition
|
// go reposition
|
||||||
|
|
||||||
for(size_t i = 0; i < _panels.GetCount(); i++)
|
for(size_t i = 0; i < m_panels.GetCount(); i++)
|
||||||
{
|
{
|
||||||
if(!_panels.Item(i)->IsExpanded())
|
if(!m_panels.Item(i)->IsExpanded())
|
||||||
offset += _panels.Item(i)->Reposition(offset);
|
offset += m_panels.Item(i)->Reposition(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFoldPanelBar::GetPanelsHeight(int &collapsed, int &expanded)
|
int wxFoldPanelBar::GetPanelsLength(int &collapsed, int &expanded)
|
||||||
{
|
{
|
||||||
int value = 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 < m_panels.GetCount(); j++)
|
||||||
{
|
{
|
||||||
int offset = _panels.Item(j)->GetPanelHeight();
|
int offset = m_panels.Item(j)->GetPanelLength();
|
||||||
value += offset;
|
value += offset;
|
||||||
if(_panels.Item(j)->IsExpanded())
|
if(m_panels.Item(j)->IsExpanded())
|
||||||
expanded += offset;
|
expanded += offset;
|
||||||
else
|
else
|
||||||
collapsed += offset;
|
collapsed += offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,8 @@
|
|||||||
// Name: foldpanelitem.cpp
|
// Name: foldpanelitem.cpp
|
||||||
// Purpose:
|
// Purpose:
|
||||||
// Author: Jorgen Bodde
|
// Author: Jorgen Bodde
|
||||||
// Modified by:
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
||||||
|
// : wxWidgets coding standards
|
||||||
// Created: 22/06/2004
|
// Created: 22/06/2004
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Jorgen Bodde
|
// Copyright: (c) Jorgen Bodde
|
||||||
@@ -16,7 +17,11 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/foldbar/foldpanelitem.h"
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/wx.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/foldbar/foldpanelbar.h"
|
||||||
|
|
||||||
#include <wx/arrimpl.cpp>
|
#include <wx/arrimpl.cpp>
|
||||||
WX_DEFINE_OBJARRAY(wxFoldWindowItemArray);
|
WX_DEFINE_OBJARRAY(wxFoldWindowItemArray);
|
||||||
@@ -35,12 +40,12 @@ 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)
|
: m_controlCreated(false)
|
||||||
, _yUserSize(0)
|
, m_userSize(0)
|
||||||
, _yPanelSize(0)
|
, m_panelSize(0)
|
||||||
, _yLastInsertPos(0)
|
, m_lastInsertPos(0)
|
||||||
, _yPos(0)
|
, m_itemPos(0)
|
||||||
, _userSized(false)
|
, m_userSized(false)
|
||||||
{
|
{
|
||||||
wxCHECK2(parent, return);
|
wxCHECK2(parent, return);
|
||||||
|
|
||||||
@@ -48,20 +53,20 @@ wxFoldPanelItem::wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxI
|
|||||||
|
|
||||||
// create the caption bar, in collapsed or expanded state
|
// create the caption bar, in collapsed or expanded state
|
||||||
|
|
||||||
_captionBar = new wxCaptionBar(this, caption, icons, wxID_ANY, style, wxPoint(0,0));
|
m_captionBar = new wxCaptionBar(this, caption, icons, wxID_ANY, style, wxPoint(0,0));
|
||||||
//_captionBar->SetBoldFont();
|
//m_captionBar->SetBoldFont();
|
||||||
|
|
||||||
if(collapsedInitially)
|
if(collapsedInitially)
|
||||||
_captionBar->Collapse();
|
m_captionBar->Collapse();
|
||||||
|
|
||||||
_controlCreated = true;
|
m_controlCreated = true;
|
||||||
|
|
||||||
// make initial size for component, if collapsed, the
|
// make initial size for component, if collapsed, the
|
||||||
// size is determined on the panel height and won't change
|
// size is determined on the panel height and won't change
|
||||||
|
|
||||||
wxSize size = _captionBar->GetSize();
|
wxSize size = m_captionBar->GetSize();
|
||||||
_yPanelSize = size.GetHeight();
|
m_panelSize = IsVertical()?size.GetHeight():size.GetWidth();
|
||||||
_yLastInsertPos = _yPanelSize;
|
m_lastInsertPos = m_panelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -69,20 +74,27 @@ void wxFoldPanelItem::AddWindow(wxWindow *window, int flags, int ySpacing, int l
|
|||||||
wxASSERT(window);
|
wxASSERT(window);
|
||||||
|
|
||||||
wxFoldWindowItem *wi = new wxFoldWindowItem(window, flags, ySpacing, leftSpacing, rightSpacing);
|
wxFoldWindowItem *wi = new wxFoldWindowItem(window, flags, ySpacing, leftSpacing, rightSpacing);
|
||||||
_items.Add(wi);
|
m_items.Add(wi);
|
||||||
|
|
||||||
window->SetSize(leftSpacing, _yLastInsertPos + ySpacing, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
|
bool vertical = this->IsVertical();
|
||||||
_yLastInsertPos += wi->GetWindowHeight();
|
|
||||||
|
window->SetSize( vertical ? leftSpacing : m_lastInsertPos + ySpacing,
|
||||||
|
vertical ? m_lastInsertPos + ySpacing : leftSpacing,
|
||||||
|
wxDefaultCoord,
|
||||||
|
wxDefaultCoord,
|
||||||
|
wxSIZE_USE_EXISTING);
|
||||||
|
|
||||||
|
m_lastInsertPos += wi->GetWindowLength( vertical );
|
||||||
|
|
||||||
ResizePanel();
|
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(m_lastInsertPos, color, ySpacing, leftSpacing, rightSpacing);
|
||||||
_items.Add(wi);
|
m_items.Add(wi);
|
||||||
|
|
||||||
_yLastInsertPos += wi->GetWindowHeight();
|
m_lastInsertPos += wi->GetWindowLength( this->IsVertical() );
|
||||||
|
|
||||||
ResizePanel();
|
ResizePanel();
|
||||||
}
|
}
|
||||||
@@ -90,7 +102,7 @@ void wxFoldPanelItem::AddSeparator(const wxColour &color, int ySpacing, int left
|
|||||||
|
|
||||||
wxFoldPanelItem::~wxFoldPanelItem()
|
wxFoldPanelItem::~wxFoldPanelItem()
|
||||||
{
|
{
|
||||||
_items.Clear();
|
m_items.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFoldPanelItem::OnPressCaption(wxCaptionBarEvent &event)
|
void wxFoldPanelItem::OnPressCaption(wxCaptionBarEvent &event)
|
||||||
@@ -108,7 +120,7 @@ void wxFoldPanelItem::OnSize(wxSizeEvent &event)
|
|||||||
{
|
{
|
||||||
// deny access to pointers (yet)
|
// deny access to pointers (yet)
|
||||||
|
|
||||||
if(!_controlCreated)
|
if(!m_controlCreated)
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
return;
|
return;
|
||||||
@@ -121,11 +133,11 @@ void wxFoldPanelItem::OnSize(wxSizeEvent &event)
|
|||||||
|
|
||||||
//wxSize size(0,wxDefaultCoord);
|
//wxSize size(0,wxDefaultCoord);
|
||||||
//size.SetWidth(rect.GetWidth());
|
//size.SetWidth(rect.GetWidth());
|
||||||
//_captionBar->SetSize(size);
|
//m_captionBar->SetSize(size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFoldPanelItem::Reposition(int y)
|
int wxFoldPanelItem::Reposition(int pos)
|
||||||
{
|
{
|
||||||
// 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
|
||||||
@@ -133,16 +145,25 @@ int wxFoldPanelItem::Reposition(int y)
|
|||||||
|
|
||||||
Freeze();
|
Freeze();
|
||||||
|
|
||||||
SetSize(wxDefaultCoord, y, wxDefaultCoord, wxDefaultCoord, wxSIZE_USE_EXISTING);
|
bool vertical = this->IsVertical();
|
||||||
_yPos = y;
|
|
||||||
|
SetSize( vertical ? wxDefaultCoord : pos,
|
||||||
|
vertical ? pos : wxDefaultCoord,
|
||||||
|
wxDefaultCoord,
|
||||||
|
wxDefaultCoord,
|
||||||
|
wxSIZE_USE_EXISTING);
|
||||||
|
|
||||||
|
m_itemPos = pos;
|
||||||
|
|
||||||
Thaw();
|
Thaw();
|
||||||
|
|
||||||
return GetPanelHeight();
|
return GetPanelLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFoldPanelItem::ResizePanel()
|
void wxFoldPanelItem::ResizePanel()
|
||||||
{
|
{
|
||||||
|
bool vertical = IsVertical();
|
||||||
|
|
||||||
// prevent unnecessary updates by blocking repaints for a sec
|
// prevent unnecessary updates by blocking repaints for a sec
|
||||||
|
|
||||||
Freeze();
|
Freeze();
|
||||||
@@ -151,33 +172,42 @@ void wxFoldPanelItem::ResizePanel()
|
|||||||
// 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(m_captionBar->IsCollapsed())
|
||||||
{
|
{
|
||||||
size = _captionBar->GetSize();
|
size = m_captionBar->GetSize();
|
||||||
_yPanelSize = size.GetHeight();
|
m_panelSize = vertical ? size.GetHeight() : size.GetWidth();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size = GetBestSize();
|
size = GetBestSize();
|
||||||
_yPanelSize = size.GetHeight();
|
m_panelSize = vertical ? size.GetHeight() : size.GetWidth();
|
||||||
|
|
||||||
if(_userSized)
|
if(m_userSized)
|
||||||
size.SetHeight(_yUserSize);
|
{
|
||||||
|
if ( vertical )
|
||||||
|
size.SetHeight(m_userSize);
|
||||||
|
else
|
||||||
|
size.SetWidth(m_userSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize pnlsize = GetParent()->GetSize();
|
wxSize pnlsize = GetParent()->GetSize();
|
||||||
size.SetWidth(pnlsize.GetWidth());
|
if ( vertical )
|
||||||
|
size.SetWidth(pnlsize.GetWidth());
|
||||||
|
else
|
||||||
|
size.SetHeight(pnlsize.GetHeight());
|
||||||
|
|
||||||
// resize caption bar
|
// resize caption bar
|
||||||
_captionBar->SetSize(wxSize(size.GetWidth(), wxDefaultCoord));
|
m_captionBar->SetSize( vertical ? size.GetWidth() : wxDefaultCoord,
|
||||||
|
vertical ? wxDefaultCoord : size.GetHeight());
|
||||||
|
|
||||||
// resize the panel
|
// resize the panel
|
||||||
SetSize(size);
|
SetSize(size);
|
||||||
|
|
||||||
// go by all the controls and call Layout
|
// go by all the controls and call Layout
|
||||||
|
|
||||||
for(size_t i = 0; i < _items.GetCount(); i++)
|
for(size_t i = 0; i < m_items.GetCount(); i++)
|
||||||
_items.Item(i).ResizeItem(size.GetWidth());
|
m_items.Item(i).ResizeItem( vertical ? size.GetWidth() : size.GetHeight() , vertical );
|
||||||
|
|
||||||
// and draw all
|
// and draw all
|
||||||
|
|
||||||
@@ -187,18 +217,35 @@ void wxFoldPanelItem::ResizePanel()
|
|||||||
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);
|
||||||
|
bool vertical = IsVertical();
|
||||||
|
|
||||||
for(size_t i = 0; i < _items.GetCount(); i++)
|
for(size_t i = 0; i < m_items.GetCount(); i++)
|
||||||
{
|
{
|
||||||
wxFoldWindowItem &item = _items.Item(i);
|
wxFoldWindowItem &item = m_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(),
|
int a = item.GetLeftSpacing();
|
||||||
item.GetLineWidth() + item.GetLeftSpacing(), item.GetLineY() + item.GetYSpacing());
|
int b = item.GetLineY() + item.GetSpacing();
|
||||||
|
int c = item.GetLineLength();
|
||||||
|
int d = a + c;
|
||||||
|
if (vertical)
|
||||||
|
dc.DrawLine(a, b, d, b);
|
||||||
|
else
|
||||||
|
dc.DrawLine(b, a, b, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxFoldPanelItem::IsVertical() const
|
||||||
|
{
|
||||||
|
// grandparent of wxFoldPanelItem is wxFoldPanelBar
|
||||||
|
// default is vertical
|
||||||
|
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
|
||||||
|
wxCHECK_MSG( panel, true, _T("wrong parent") );
|
||||||
|
wxFoldPanelBar *bar = wxDynamicCast(panel->GetParent(), wxFoldPanelBar);
|
||||||
|
wxCHECK_MSG( bar, true, _T("wrong parent") );
|
||||||
|
return bar->IsVertical();
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user