2004-08-03 07:18:36 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2004-08-03 07:55:18 -04:00
|
|
|
// Name: foldpanelitem.h
|
|
|
|
// Purpose: wxFoldPanel
|
|
|
|
// Author: Jorgen Bodde
|
2004-12-10 07:01:04 -05:00
|
|
|
// Modified by: ABX - 19/12/2004 : possibility of horizontal orientation
|
|
|
|
// : wxWidgets coding standards
|
2004-08-03 07:55:18 -04:00
|
|
|
// Created: 22/06/2004
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Jorgen Bodde
|
|
|
|
// Licence: wxWindows licence
|
2004-08-03 07:18:36 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __WXFOLDPANELITEM_H__
|
|
|
|
#define __WXFOLDPANELITEM_H__
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
#include "wx/foldbar/captionbar.h"
|
2004-08-03 07:18:36 -04:00
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
#define wxFPB_ALIGN_LEFT 0
|
2004-08-03 07:18:36 -04:00
|
|
|
#define wxFPB_ALIGN_WIDTH 1
|
|
|
|
|
|
|
|
#define wxFPB_DEFAULT_LEFTSPACING 5
|
|
|
|
#define wxFPB_DEFAULT_RIGHTSPACING 10
|
2004-12-10 07:01:04 -05:00
|
|
|
#define wxFPB_DEFAULT_SPACING 8
|
2004-08-03 07:18:36 -04:00
|
|
|
|
|
|
|
#define wxFPB_DEFAULT_LEFTLINESPACING 2
|
|
|
|
#define wxFPB_DEFAULT_RIGHTLINESPACING 2
|
|
|
|
|
|
|
|
class wxFoldWindowItem
|
|
|
|
{
|
|
|
|
private:
|
2004-12-10 07:01:04 -05:00
|
|
|
wxWindow *m_wndItem;
|
|
|
|
int m_type, m_flags;
|
|
|
|
int m_leftSpacing,
|
|
|
|
m_rightSpacing,
|
|
|
|
m_Spacing;
|
|
|
|
int m_lineLength, m_lineY;
|
|
|
|
wxColour m_sepLineColour;
|
2004-08-03 07:18:36 -04:00
|
|
|
|
|
|
|
public:
|
2004-12-10 07:01:04 -05:00
|
|
|
enum
|
2004-08-03 07:55:18 -04:00
|
|
|
{
|
|
|
|
WINDOW = 0,
|
|
|
|
SEPARATOR
|
|
|
|
};
|
|
|
|
|
|
|
|
// wxWindow constructor. This initialises the class as a wxWindow type
|
2004-12-10 07:01:04 -05:00
|
|
|
wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH, int Spacing = wxFPB_DEFAULT_SPACING,
|
|
|
|
int leftSpacing = wxFPB_DEFAULT_LEFTSPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING)
|
|
|
|
: m_wndItem(wnd)
|
|
|
|
, m_type(WINDOW)
|
|
|
|
, m_flags(flags)
|
|
|
|
, m_leftSpacing(leftSpacing)
|
|
|
|
, m_rightSpacing(rightSpacing)
|
|
|
|
, m_Spacing(Spacing)
|
|
|
|
, m_lineLength(0)
|
|
|
|
, m_lineY(0)
|
2004-08-03 07:55:18 -04:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
// separator constructor. This initialises the class as a separator type
|
2004-12-10 07:01:04 -05:00
|
|
|
wxFoldWindowItem(int y, const wxColour &lineColor = *wxBLACK, int Spacing = wxFPB_DEFAULT_SPACING,
|
|
|
|
int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING,
|
|
|
|
int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING)
|
|
|
|
: m_wndItem(NULL)
|
|
|
|
, m_type(SEPARATOR)
|
|
|
|
, m_flags(wxFPB_ALIGN_WIDTH)
|
|
|
|
, m_leftSpacing(leftSpacing)
|
|
|
|
, m_rightSpacing(rightSpacing)
|
|
|
|
, m_Spacing(Spacing)
|
|
|
|
, m_lineLength(0)
|
|
|
|
, m_lineY(y)
|
|
|
|
, m_sepLineColour(lineColor)
|
2004-08-03 07:55:18 -04:00
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Make a c'tor for a captioned splitter
|
|
|
|
|
|
|
|
int GetType() const {
|
2004-12-10 07:01:04 -05:00
|
|
|
return m_type;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
int GetLineY() const {
|
2004-12-10 07:01:04 -05:00
|
|
|
return m_lineY;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
int GetLineLength() const {
|
|
|
|
return m_lineLength;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const wxColour &GetLineColour() const {
|
2004-12-10 07:01:04 -05:00
|
|
|
return m_sepLineColour;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
int GetLeftSpacing() const {
|
2004-12-10 07:01:04 -05:00
|
|
|
return m_leftSpacing;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
int GetRightSpacing() const {
|
2004-12-10 07:01:04 -05:00
|
|
|
return m_rightSpacing;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
int GetSpacing() const {
|
|
|
|
return m_Spacing;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
// returns space needed by the window if type is wxFoldWindowItem::WINDOW
|
2004-08-03 07:55:18 -04:00
|
|
|
// and returns the total size plus the extra spacing
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
int GetWindowLength(bool vertical) const {
|
2004-08-03 07:55:18 -04:00
|
|
|
int value = 0;
|
2004-12-10 07:01:04 -05:00
|
|
|
if(m_type == WINDOW)
|
2004-08-03 07:55:18 -04:00
|
|
|
{
|
2004-12-10 07:01:04 -05:00
|
|
|
wxCHECK(m_wndItem, 0);
|
|
|
|
wxSize size = m_wndItem->GetSize();
|
|
|
|
value = ( vertical ? size.GetHeight() : size.GetWidth() ) + m_Spacing;
|
2004-08-03 07:55:18 -04:00
|
|
|
}
|
2004-12-10 07:01:04 -05:00
|
|
|
else if(m_type == SEPARATOR)
|
|
|
|
value = 1 + m_Spacing;
|
2004-08-03 07:55:18 -04:00
|
|
|
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
|
|
|
|
// resize the element, whatever it is. A separator or
|
2005-05-31 05:20:43 -04:00
|
|
|
// line will be always aligned by width or height
|
2004-12-10 07:01:04 -05:00
|
|
|
// depending on orientation of the whole panel
|
2004-08-03 07:55:18 -04:00
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
void ResizeItem(int size, bool vertical) {
|
|
|
|
if(m_flags & wxFPB_ALIGN_WIDTH)
|
2004-08-03 07:55:18 -04:00
|
|
|
{
|
2005-05-31 05:20:43 -04:00
|
|
|
// align by taking full width
|
2004-12-10 07:01:04 -05:00
|
|
|
int mySize = size - m_leftSpacing - m_rightSpacing;
|
2004-08-03 07:55:18 -04:00
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
if(mySize < 0)
|
|
|
|
mySize = 10; // can't have negative width
|
2004-08-03 07:55:18 -04:00
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
if(m_type == SEPARATOR)
|
|
|
|
m_lineLength = mySize;
|
2004-08-03 07:55:18 -04:00
|
|
|
else
|
|
|
|
{
|
2004-12-10 07:01:04 -05:00
|
|
|
wxCHECK2(m_wndItem, return);
|
|
|
|
m_wndItem->SetSize(vertical?mySize:wxDefaultCoord, vertical?wxDefaultCoord:mySize);
|
2004-08-03 07:55:18 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2004-08-03 07:18:36 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#include <wx/dynarray.h>
|
2005-07-28 19:23:27 -04:00
|
|
|
WX_DECLARE_OBJARRAY_WITH_DECL(wxFoldWindowItem, wxFoldWindowItemArray, class WXDLLIMPEXP_FOLDBAR);
|
2004-08-03 07:18:36 -04:00
|
|
|
|
|
|
|
#ifndef _NO_DOXYGEN_
|
|
|
|
|
|
|
|
/** \wxFoldPanelItem
|
|
|
|
This class is a child sibling of the wxFoldPanelBar class. It will be containing a wxCaptionBar class
|
2004-12-10 07:01:04 -05:00
|
|
|
for receiving of events, and a the rest of the area can be populated by a wxPanel derived class.
|
2004-08-03 07:18:36 -04:00
|
|
|
*/
|
|
|
|
|
2004-08-12 06:18:47 -04:00
|
|
|
class WXDLLIMPEXP_FOLDBAR wxFoldPanelItem: public wxPanel
|
2004-08-03 07:18:36 -04:00
|
|
|
{
|
|
|
|
private:
|
2004-12-10 07:01:04 -05:00
|
|
|
wxCaptionBar *m_captionBar;
|
2004-08-03 07:18:36 -04:00
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
bool m_controlCreated;
|
|
|
|
int m_userSize,
|
|
|
|
m_panelSize,
|
|
|
|
m_lastInsertPos;
|
|
|
|
int m_itemPos;
|
|
|
|
bool m_userSized;
|
2004-08-03 07:18:36 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_CLASS( wxFoldPanelItem )
|
|
|
|
DECLARE_EVENT_TABLE()
|
2004-12-10 07:01:04 -05:00
|
|
|
|
2004-08-03 07:18:36 -04:00
|
|
|
private:
|
2004-12-10 07:01:04 -05:00
|
|
|
wxFoldWindowItemArray m_items;
|
2004-08-03 07:18:36 -04:00
|
|
|
|
2004-08-03 07:55:18 -04:00
|
|
|
void OnSize(wxSizeEvent &event);
|
|
|
|
void OnPressCaption(wxCaptionBarEvent &event);
|
|
|
|
void OnPaint(wxPaintEvent &event);
|
2004-08-03 07:18:36 -04:00
|
|
|
|
|
|
|
public:
|
|
|
|
// constructors and destructors
|
2004-12-10 07:01:04 -05:00
|
|
|
wxFoldPanelItem( wxWindow *parent, const wxString &caption, wxImageList *icons = 0, bool collapsedInitially = false,
|
2004-08-03 07:55:18 -04:00
|
|
|
const wxCaptionBarStyle &style = wxEmptyCaptionBarStyle);
|
2004-08-03 07:18:36 -04:00
|
|
|
virtual ~wxFoldPanelItem();
|
2004-12-10 07:01:04 -05:00
|
|
|
|
2004-08-03 07:55:18 -04:00
|
|
|
/** Add a window item to the list of items on this panel. The flags are wxFPB_ALIGN_LEFT for a non sizing
|
2005-05-31 05:20:43 -04:00
|
|
|
window element, and wxFPB_ALIGN_WIDTH for a width aligned item. The ySpacing parameter reserves a number
|
2004-08-03 07:55:18 -04:00
|
|
|
of pixels before the window element, and leftSpacing is an indent. rightSpacing is only relevant when the
|
|
|
|
style wxFPB_ALIGN_WIDTH is chosen. */
|
|
|
|
void AddWindow(wxWindow *window, int flags, int ySpacing, int leftSpacing, int rightSpacing);
|
2004-12-10 07:01:04 -05:00
|
|
|
|
2004-08-03 07:55:18 -04:00
|
|
|
void AddSeparator(const wxColour &color, int ySpacing, int leftSpacing, int rightSpacing);
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
/** Repositions this wxFoldPanelBar and reports the length occupied for the next wxFoldPanelBar in the
|
2004-08-03 07:55:18 -04:00
|
|
|
list */
|
2004-12-10 07:01:04 -05:00
|
|
|
int Reposition(int pos);
|
2004-08-03 07:55:18 -04:00
|
|
|
|
|
|
|
void ResizePanel();
|
|
|
|
|
|
|
|
/** Return expanded or collapsed status. If the panel is expanded, true is returned */
|
|
|
|
bool IsExpanded() const {
|
2004-12-10 07:01:04 -05:00
|
|
|
return !m_captionBar->IsCollapsed();
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Return Y pos */
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
int GetItemPos() const {
|
|
|
|
return m_itemPos;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
// this should not be called by the user, because it doesn't trigger the parent
|
2004-08-03 07:55:18 -04:00
|
|
|
// to tell it that we are collapsed or expanded, it only changes visual state
|
|
|
|
void Collapse() {
|
2004-12-10 07:01:04 -05:00
|
|
|
m_captionBar->Collapse();
|
2004-08-03 07:55:18 -04:00
|
|
|
ResizePanel();
|
|
|
|
};
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
// this should not be called by the user, because it doesn't trigger the parent
|
2004-08-03 07:55:18 -04:00
|
|
|
// to tell it that we are collapsed or expanded, it only changes visual state
|
|
|
|
void Expand() {
|
2004-12-10 07:01:04 -05:00
|
|
|
m_captionBar->Expand();
|
2004-08-03 07:55:18 -04:00
|
|
|
ResizePanel();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Return size of panel */
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
int GetPanelLength() const {
|
|
|
|
if(m_captionBar->IsCollapsed())
|
|
|
|
return GetCaptionLength();
|
|
|
|
else if(m_userSized)
|
|
|
|
return m_userSize;
|
|
|
|
return m_panelSize;
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
bool IsVertical() const;
|
|
|
|
|
|
|
|
// returns space of caption only. This is for folding calulation
|
2004-08-03 07:55:18 -04:00
|
|
|
// purposes
|
|
|
|
|
2004-12-10 07:01:04 -05:00
|
|
|
int GetCaptionLength() const {
|
|
|
|
wxSize size = m_captionBar->GetSize();
|
|
|
|
return IsVertical() ? size.GetHeight() : size.GetWidth();
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
void ApplyCaptionStyle(const wxCaptionBarStyle &style) {
|
2004-12-10 07:01:04 -05:00
|
|
|
wxCHECK2(m_captionBar, return);
|
|
|
|
m_captionBar->SetCaptionStyle(false, style);
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
wxCaptionBarStyle GetCaptionStyle() {
|
2004-12-10 07:01:04 -05:00
|
|
|
wxCHECK(m_captionBar, wxEmptyCaptionBarStyle);
|
|
|
|
return m_captionBar->GetCaptionStyle();
|
2004-08-03 07:55:18 -04:00
|
|
|
};
|
2004-08-03 07:18:36 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _NO_DOXYGEN_
|
|
|
|
|
|
|
|
#endif // __WXFOLDPANELITEM_H__
|