From: Robin Dunn Date: Mon, 2 Apr 2007 21:19:13 +0000 (+0000) Subject: Gizmos has been moved to wxCode. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/828ed945a74d91121c9ba631cf29957fd5edc70a Gizmos has been moved to wxCode. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45221 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/dynamicsash.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/dynamicsash.h new file mode 100644 index 0000000000..2d5da5c8b0 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/dynamicsash.h @@ -0,0 +1,207 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dynamicsash.h +// Purpose: A window which can be dynamically split to an arbitrary depth +// and later reunified through the user interface +// Author: Matt Kimball +// Modified by: +// Created: 7/15/2001 +// RCS-ID: $Id$ +// Copyright: (c) 2001 Matt Kimball +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DYNAMICSASH_H_ +#define _WX_DYNAMICSASH_H_ + +#include "wx/gizmos/gizmos.h" + +#if !wxUSE_MDI +# error "wxUSE_MDI must be defined for gizmos to compile." +#endif /* !wxUSE_MDI */ + + +/* + + wxDynamicSashWindow + + wxDynamicSashWindow widgets manages the way other widgets are viewed. + When a wxDynamicSashWindow is first shown, it will contain one child + view, a viewport for that child, and a pair of scrollbars to allow the + user to navigate the child view area. Next to each scrollbar is a small + tab. By clicking on either tab and dragging to the appropriate spot, a + user can split the view area into two smaller views separated by a + draggable sash. Later, when the user wishes to reunify the two subviews, + the user simply drags the sash to the side of the window. + wxDynamicSashWindow will automatically reparent the appropriate child + view back up the window hierarchy, and the wxDynamicSashWindow will have + only one child view once again. + + As an application developer, you will simply create a wxDynamicSashWindow + using either the Create() function or the more complex constructor + provided below, and then create a view window whose parent is the + wxDynamicSashWindow. The child should respond to + wxDynamicSashSplitEvents -- perhaps with an OnSplit() event handler -- by + constructing a new view window whose parent is also the + wxDynamicSashWindow. That's it! Now your users can dynamically split + and reunify the view you provided. + + If you wish to handle the scrollbar events for your view, rather than + allowing wxDynamicSashWindow to do it for you, things are a bit more + complex. (You might want to handle scrollbar events yourself, if, + for instance, you wish to scroll a subwindow of the view you add to + your wxDynamicSashWindow object, rather than scrolling the whole view.) + In this case, you will need to construct your wxDynamicSashWindow without + the wxDS_MANAGE_SCROLLBARS style and you will need to use the + GetHScrollBar() and GetVScrollBar() methods to retrieve the scrollbar + controls and call SetEventHanler() on them to redirect the scrolling + events whenever your window is reparented by wxDyanmicSashWindow. + You will need to set the scrollbars' event handler at three times: + + * When your view is created + * When your view receives a wxDynamicSashSplitEvent + * When your view receives a wxDynamicSashUnifyEvent + + See the dynsash_switch sample application for an example which does this. + +*/ + + +#include "wx/event.h" +#include "wx/window.h" + +class WXDLLIMPEXP_CORE wxScrollBar; + +// ---------------------------------------------------------------------------- +// dynamic sash styles +// ---------------------------------------------------------------------------- + +/* + wxDS_MANAGE_SCROLLBARS is a default style of wxDynamicSashWindow which + will cause it to respond to scrollbar events for your application by + automatically scrolling the child view. +*/ +#define wxDS_MANAGE_SCROLLBARS 0x0010 + + +/* + wxDS_DRAG_CORNER style indicates that the views can also be resized by + dragging the corner piece between the scrollbars, and which is reflected up + to the frame if necessary. +*/ +#define wxDS_DRAG_CORNER 0x0020 + +/* + Default style for wxDynamicSashWindow. + */ +#define wxDS_DEFAULT wxDS_MANAGE_SCROLLBARS | wxDS_DRAG_CORNER + +// ---------------------------------------------------------------------------- +// dynamic sash events +// ---------------------------------------------------------------------------- + +extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_SPLIT; +extern WXDLLIMPEXP_GIZMOS const wxEventType wxEVT_DYNAMIC_SASH_UNIFY; + +#define EVT_DYNAMIC_SASH_SPLIT(id, func) \ + wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_SPLIT, id, \ + wxDynamicSashSplitEventHandler(func)) + +#define EVT_DYNAMIC_SASH_UNIFY(id, func) \ + wx__DECLARE_EVT1(wxEVT_DYNAMIC_SASH_UNIFY, id, \ + wxDynamicSashUnifyEventHandler(func)) + + +/* + wxDynamicSashSplitEvents are sent to your view by wxDynamicSashWindow + whenever your view is being split by the user. It is your + responsibility to handle this event by creating a new view window as + a child of the wxDynamicSashWindow. wxDynamicSashWindow will + automatically reparent it to the proper place in its window hierarchy. +*/ +class WXDLLIMPEXP_GIZMOS wxDynamicSashSplitEvent : public wxCommandEvent +{ +public: + wxDynamicSashSplitEvent(); + wxDynamicSashSplitEvent(const wxDynamicSashSplitEvent& event) + : wxCommandEvent(event) { } + wxDynamicSashSplitEvent(wxObject *target); + + virtual wxEvent* Clone() const { return new wxDynamicSashSplitEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS(wxDynamicSashSplitEvent) +}; + +/* + wxDynamicSashUnifyEvents are sent to your view by wxDynamicSashWindow + whenever the sash which splits your view and its sibling is being + reunified such that your view is expanding to replace its sibling. + You needn't do anything with this event if you are allowing + wxDynamicSashWindow to manage your view's scrollbars, but it is useful + if you are managing the scrollbars yourself so that you can keep + the scrollbars' event handlers connected to your view's event handler + class. +*/ +class WXDLLIMPEXP_GIZMOS wxDynamicSashUnifyEvent : public wxCommandEvent +{ +public: + wxDynamicSashUnifyEvent(); + wxDynamicSashUnifyEvent(const wxDynamicSashUnifyEvent& event): wxCommandEvent(event) {} + wxDynamicSashUnifyEvent(wxObject *target); + + virtual wxEvent* Clone() const { return new wxDynamicSashUnifyEvent(*this); } + +private: + DECLARE_DYNAMIC_CLASS(wxDynamicSashUnifyEvent) +}; + +typedef void (wxEvtHandler::*wxDynamicSashSplitEventFunction)(wxDynamicSashSplitEvent&); +typedef void (wxEvtHandler::*wxDynamicSashUnifyEventFunction)(wxDynamicSashUnifyEvent&); + +#define wxDynamicSashSplitEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction) \ + wxStaticCastEvent(wxDynamicSashSplitEventFunction, &func) + +#define wxDynamicSashUnifyEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction) \ + wxStaticCastEvent(wxDynamicSashUnifyEventFunction, &func) + +#define wx__DECLARE_TREEEVT(evt, id, fn) \ + wx__DECLARE_EVT1(wxEVT_COMMAND_TREE_ ## evt, id, wxTreeEventHandler(fn)) + +// ---------------------------------------------------------------------------- +// wxDynamicSashWindow itself +// ---------------------------------------------------------------------------- + +WXDLLIMPEXP_GIZMOS extern const wxChar* wxDynamicSashWindowNameStr; + +class WXDLLIMPEXP_GIZMOS wxDynamicSashWindow : public wxWindow +{ +public: + wxDynamicSashWindow(); + wxDynamicSashWindow(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxDS_DEFAULT, + const wxString& name = wxDynamicSashWindowNameStr); + virtual ~wxDynamicSashWindow(); + + virtual bool Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDS_DEFAULT, + const wxString& name = wxDynamicSashWindowNameStr); + virtual wxScrollBar *GetHScrollBar(const wxWindow *child) const; + virtual wxScrollBar *GetVScrollBar(const wxWindow *child) const; + + /* This is overloaded from wxWindowBase. It's not here for you to + call directly. */ + virtual void AddChild(wxWindowBase *child); + +private: + class wxDynamicSashWindowImpl *m_impl; + + DECLARE_DYNAMIC_CLASS(wxDynamicSashWindow) +}; + +#endif // _WX_DYNAMICSASH_H_ + diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/editlbox.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/editlbox.h new file mode 100644 index 0000000000..e0206d1cd9 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/editlbox.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: editlbox.h +// Purpose: ListBox with editable items +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + + +#ifndef __WX_EDITLBOX_H__ +#define __WX_EDITLBOX_H__ + +#include "wx/panel.h" +#include "wx/gizmos/gizmos.h" + +class WXDLLEXPORT wxBitmapButton; +class WXDLLEXPORT wxListCtrl; +class WXDLLEXPORT wxListEvent; + +#define wxEL_ALLOW_NEW 0x0100 +#define wxEL_ALLOW_EDIT 0x0200 +#define wxEL_ALLOW_DELETE 0x0400 +#define wxEL_NO_REORDER 0x0800 + +// This class provides a composite control that lets the +// user easily enter list of strings + +class WXDLLIMPEXP_GIZMOS wxEditableListBox : public wxPanel +{ + DECLARE_CLASS(wxEditableListBox) + +public: + wxEditableListBox(wxWindow *parent, wxWindowID id, + const wxString& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxEL_ALLOW_NEW | wxEL_ALLOW_EDIT | wxEL_ALLOW_DELETE, + const wxString& name = wxT("editableListBox")); + + void SetStrings(const wxArrayString& strings); + void GetStrings(wxArrayString& strings) const; + + wxListCtrl* GetListCtrl() { return m_listCtrl; } + wxBitmapButton* GetDelButton() { return m_bDel; } + wxBitmapButton* GetNewButton() { return m_bNew; } + wxBitmapButton* GetUpButton() { return m_bUp; } + wxBitmapButton* GetDownButton() { return m_bDown; } + wxBitmapButton* GetEditButton() { return m_bEdit; } + +protected: + wxBitmapButton *m_bDel, *m_bNew, *m_bUp, *m_bDown, *m_bEdit; + wxListCtrl *m_listCtrl; + int m_selection; + long m_style; + + void OnItemSelected(wxListEvent& event); + void OnEndLabelEdit(wxListEvent& event); + void OnNewItem(wxCommandEvent& event); + void OnDelItem(wxCommandEvent& event); + void OnEditItem(wxCommandEvent& event); + void OnUpItem(wxCommandEvent& event); + void OnDownItem(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +#endif diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/gizmos.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/gizmos.h new file mode 100644 index 0000000000..d7cec4442b --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/gizmos.h @@ -0,0 +1,23 @@ +#ifndef _WX_GIZMOS_H_ +#define _WX_GIZMOS_H_ + +// #ifdef WXMAKINGDLL_GIZMOS +// #define WXDLLIMPEXP_GIZMOS WXEXPORT +// #elif defined(WXUSINGDLL) +// #define WXDLLIMPEXP_GIZMOS WXIMPORT +// #else // not making nor using DLL +// #define WXDLLIMPEXP_GIZMOS +// #endif + +// #ifdef WXMAKINGDLL_GIZMOS_XRC +// #define WXDLLIMPEXP_GIZMOS_XRC WXEXPORT +// #elif defined(WXUSINGDLL) +// #define WXDLLIMPEXP_GIZMOS_XRC WXIMPORT +// #else // not making nor using DLL +// #define WXDLLIMPEXP_GIZMOS_XRC +// #endif + +#define WXDLLIMPEXP_GIZMOS +#define WXDLLIMPEXP_GIZMOS_XRC + +#endif diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/ledctrl.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/ledctrl.h new file mode 100644 index 0000000000..b3421f7c3e --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/ledctrl.h @@ -0,0 +1,80 @@ +#ifndef _WX_LEDNUMBERCTRL_H_ +#define _WX_LEDNUMBERCTRL_H_ + +#include "wx/gizmos/gizmos.h" + +#include +#include + +class wxEraseEvent; +class wxPaintEvent; +class wxSizeEvent; + +// ---------------------------------------------------------------------------- +// enum and styles +// ---------------------------------------------------------------------------- + +enum wxLEDValueAlign +{ + wxLED_ALIGN_LEFT = 0x01, + wxLED_ALIGN_RIGHT = 0x02, + wxLED_ALIGN_CENTER = 0x04, + + wxLED_ALIGN_MASK = 0x07 +}; + +#define wxLED_DRAW_FADED 0x08 + +// ---------------------------------------------------------------------------- +// wxLEDNumberCtrl +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_GIZMOS wxLEDNumberCtrl : public wxControl +{ +public: + // Constructors. + wxLEDNumberCtrl(); + wxLEDNumberCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxLED_ALIGN_LEFT | wxLED_DRAW_FADED); + + // Create functions. + bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0); + + wxLEDValueAlign GetAlignment() const { return m_Alignment; } + bool GetDrawFaded() const { return m_DrawFaded; } + const wxString &GetValue() const { return m_Value; } + + void SetAlignment(wxLEDValueAlign Alignment, bool Redraw = true); + void SetDrawFaded(bool DrawFaded, bool Redraw = true); + void SetValue(const wxString &Value, bool Redraw = true); + +private: + // Members. + wxString m_Value; + wxLEDValueAlign m_Alignment; + + int m_LineMargin; + int m_DigitMargin; + int m_LineLength; + int m_LineWidth; + bool m_DrawFaded; + int m_LeftStartPos; + + // Functions. + void DrawDigit(wxDC &Dc, int Digit, int Column); + void RecalcInternals(const wxSize &CurrentSize); + + // Events. + DECLARE_EVENT_TABLE() + + void OnEraseBackground(wxEraseEvent &Event); + void OnPaint(wxPaintEvent &Event); + void OnSize(wxSizeEvent &Event); +}; + +#endif diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/multicell.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/multicell.h new file mode 100644 index 0000000000..6e44285488 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/multicell.h @@ -0,0 +1,174 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: multicell.h +// Purpose: provide two new classes for layout, wxMultiCellSizer and wxMultiCellCanvas +// Author: Jonathan Bayer +// Modified by: +// Created: +// RCS-ID: $Id$ +// Copyright: (c) Jonathan Bayer +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// This was inspired by the gbsizer class written by Alex Andruschak + + +#ifndef __WX_MULTICELL_H__ +#define __WX_MULTICELL_H__ + +#include "wx/gizmos/gizmos.h" + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- +// The classes are derived from wxSizer +#include "wx/sizer.h" + + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- +enum wxResizable +{ + wxNOT_RESIZABLE = 0x00, + wxHORIZONTAL_RESIZABLE = 0x01, + wxVERTICAL_RESIZABLE = 0x10, + wxRESIZABLE = 0x11 +}; + +//--------------------------------------------------------------------------- +// classes +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// wxMultiCellItemHandle +//--------------------------------------------------------------------------- + +class WXDLLIMPEXP_GIZMOS wxMultiCellItemHandle: public wxObject +{ + DECLARE_CLASS(wxMultiCellItemHandle) +protected: + int m_column; + int m_row; + int m_width; + int m_height; + wxResizable m_style; + wxSize m_fixedSize; + int m_alignment; + wxSize m_weight; + +public: + wxMultiCellItemHandle( int row, int column, int height = 1, int width = 1, wxSize size = wxDefaultSize, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT); + wxMultiCellItemHandle( int row, int column, wxSize size, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT); + wxMultiCellItemHandle( int row, int column, wxResizable style, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT); + int GetColumn() const; + int GetRow() const; + int GetWidth() const; + int GetHeight() const; + wxResizable GetStyle() const; + wxSize GetLocalSize() const; + int GetAlignment() const; + wxSize GetWeight() const; + +private: + void Initialize( int row, int column, int height = 1, int width = 1, wxSize size = wxDefaultSize, wxResizable style = wxNOT_RESIZABLE, wxSize weight = wxSize(1,1), int align = wxALIGN_NOT); + +}; + +//--------------------------------------------------------------------------- +// wxMultiCellSizer +//--------------------------------------------------------------------------- + +class WXDLLIMPEXP_GIZMOS wxMultiCellSizer : virtual public wxSizer +{ + DECLARE_CLASS(wxMultiCellSizer) + +protected: + wxSize m_cell_count; + +public: + wxMultiCellSizer(wxSize & size); + wxMultiCellSizer(int rows, int cols); + ~wxMultiCellSizer(); + + virtual void RecalcSizes(); + virtual wxSize CalcMin(); + bool SetDefaultCellSize(wxSize size); + bool SetColumnWidth(int column, int colSize = 5, bool expandable = false); + bool SetRowHeight(int row, int rowSize = 5, bool expandable = false); + bool EnableGridLines(wxWindow *win); + bool SetGridPen(const wxPen *pen); + void OnPaint(wxDC& dc); + +private: + void GetMinimums(); + static int Sum(int *array, int x); + +private: + int *m_maxHeight; + int *m_maxWidth; + int *m_rowStretch; + int *m_colStretch; + wxSize **m_weights; + wxSize **m_minSizes; + int m_maxWeights; + wxSize m_defaultCellSize; + wxWindow *m_win; // usually used for debugging + const wxPen *m_pen; + + void DrawGridLines(wxDC& dc); + void Initialize(wxSize size); +}; + + +// wxCell is used internally, so we don't need to declare it here + +class wxCell; + +//--------------------------------------------------------------------------- +// wxMultiCellCanvas +//--------------------------------------------------------------------------- + +class WXDLLIMPEXP_GIZMOS wxMultiCellCanvas : public wxFlexGridSizer +{ +public: + wxMultiCellCanvas(wxWindow *parent, int numRows = 2, int numCols = 2); + void Add(wxWindow *win, unsigned int row, unsigned int col); + + void Resize(int numRows, int numCols); + int MaxRows() const + { + return m_maxRows; + }; + int MaxCols() const + { + return m_maxCols; + }; + void CalculateConstraints(); + void SetMinCellSize(const wxSize size) + { + m_minCellSize = size; + }; + + /* These are to hide Add() method of parents and to avoid Borland warning about hiding virtual functions */ + void Add( wxWindow *window, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ) + { wxFlexGridSizer::Add( window, proportion, flag, border, userData); } + void Add( wxSizer *sizer, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ) + { wxFlexGridSizer::Add( sizer, proportion, flag, border, userData); } + void Add( int width, int height, int proportion = 0, int flag = 0, int border = 0, wxObject* userData = NULL ) + { wxFlexGridSizer::Add( width, height, proportion, flag, border, userData); } + void Add( wxSizerItem *item ) + { wxFlexGridSizer::Add( item); } + +private: + wxWindow *m_parent; + unsigned int m_maxRows, m_maxCols; + + wxSize m_minCellSize; + wxCell **m_cells; +}; + +#endif + + + +/*** End of File ***/ diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/splittree.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/splittree.h new file mode 100644 index 0000000000..c6cd5896ad --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/splittree.h @@ -0,0 +1,231 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: splittree.h +// Purpose: Classes to achieve a remotely-scrolled tree in a splitter +// window that can be scrolled by a scrolled window higher in the +// hierarchy +// Author: Julian Smart +// Modified by: +// Created: 8/7/2000 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_SPLITTREE_H_ +#define _WX_SPLITTREE_H_ + +#include "wx/gizmos/gizmos.h" + +// Set this to 1 to use generic tree control (doesn't yet work properly) +#define USE_GENERIC_TREECTRL 0 + +#include "wx/wx.h" +#include "wx/treectrl.h" +#include "wx/splitter.h" +#include "wx/scrolwin.h" + +#if USE_GENERIC_TREECTRL +#include "wx/generic/treectlg.h" +#ifndef wxTreeCtrl +#define wxTreeCtrl wxGenericTreeCtrl +#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl +#endif +#endif + +class wxRemotelyScrolledTreeCtrl; +class wxThinSplitterWindow; +class wxSplitterScrolledWindow; + +/* + * wxRemotelyScrolledTreeCtrl + * + * This tree control disables its vertical scrollbar and catches scroll + * events passed by a scrolled window higher in the hierarchy. + * It also updates the scrolled window vertical scrollbar as appropriate. + */ + +class WXDLLIMPEXP_GIZMOS wxRemotelyScrolledTreeCtrl: public wxTreeCtrl +{ + DECLARE_CLASS(wxRemotelyScrolledTreeCtrl) +public: + wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS); + ~wxRemotelyScrolledTreeCtrl(); + +//// Events + void OnSize(wxSizeEvent& event); + void OnExpand(wxTreeEvent& event); + void OnScroll(wxScrollWinEvent& event); + void OnPaint(wxPaintEvent& event); + +//// Overrides + // Override this in case we're using the generic tree control. + // Calls to this should disable the vertical scrollbar. + + // Number of pixels per user unit (0 or -1 for no scrollbar) + // Length of virtual canvas in user units + // Length of page in user units + virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, + int noUnitsX, int noUnitsY, + int xPos = 0, int yPos = 0, + bool noRefresh = false ); + + // In case we're using the generic tree control. + // Get the view start + virtual void GetViewStart(int *x, int *y) const; + + // In case we're using the generic tree control. + virtual void PrepareDC(wxDC& dc); + + // In case we're using the generic tree control. + virtual int GetScrollPos(int orient) const; + +//// Helpers + void HideVScrollbar(); + + // Calculate the tree overall size so we can set the scrollbar + // correctly + void CalcTreeSize(wxRect& rect); + void CalcTreeSize(const wxTreeItemId& id, wxRect& rect); + + // Adjust the containing wxScrolledWindow's scrollbars appropriately + void AdjustRemoteScrollbars(); + + // Find the scrolled window that contains this control + wxScrolledWindow* GetScrolledWindow() const; + + // Scroll to the given line (in scroll units where each unit is + // the height of an item) + void ScrollToLine(int posHoriz, int posVert); + +//// Accessors + + // The companion window is one which will get notified when certain + // events happen such as node expansion + void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; } + wxWindow* GetCompanionWindow() const { return m_companionWindow; } + + + DECLARE_EVENT_TABLE() +protected: + wxWindow* m_companionWindow; + bool m_drawRowLines; +}; + +/* + * wxTreeCompanionWindow + * + * A window displaying values associated with tree control items. + */ + +class WXDLLIMPEXP_GIZMOS wxTreeCompanionWindow: public wxWindow +{ +public: + DECLARE_CLASS(wxTreeCompanionWindow) + + wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, + long style = 0); + +//// Overrides + virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect); + +//// Events + void OnPaint(wxPaintEvent& event); + void OnScroll(wxScrollWinEvent& event); + void OnExpand(wxTreeEvent& event); + +//// Operations + +//// Accessors + wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; }; + void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; } + +//// Data members +protected: + wxRemotelyScrolledTreeCtrl* m_treeCtrl; + + DECLARE_EVENT_TABLE() +}; + + +/* + * wxThinSplitterWindow + * + * Implements a splitter with a less obvious sash + * than the usual one. + */ + +class WXDLLIMPEXP_GIZMOS wxThinSplitterWindow: public wxSplitterWindow +{ +public: + DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow) + + wxThinSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, + long style = wxSP_3D | wxCLIP_CHILDREN); + ~wxThinSplitterWindow(); + +//// Overrides + + void SizeWindows(); + // Tests for x, y over sash. Overriding this allows us to increase + // the tolerance. + bool SashHitTest(int x, int y, int tolerance = 2); + void DrawSash(wxDC& dc); + +//// Events + + void OnSize(wxSizeEvent& event); + +//// Operations + +//// Accessors + +//// Data members +protected: + wxPen* m_facePen; + wxBrush* m_faceBrush; + + DECLARE_EVENT_TABLE() +}; + +/* + * wxSplitterScrolledWindow + * + * This scrolled window is aware of the fact that one of its + * children is a splitter window. It passes on its scroll events + * (after some processing) to both splitter children for them + * scroll appropriately. + */ + +class WXDLLIMPEXP_GIZMOS wxSplitterScrolledWindow: public wxScrolledWindow +{ +public: + DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow) + + wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, + long style = 0); + +//// Overrides + +//// Events + + void OnScroll(wxScrollWinEvent& event); + void OnSize(wxSizeEvent& event); + +//// Operations + +//// Accessors + +//// Data members +public: + DECLARE_EVENT_TABLE() +}; + +#endif + // _SPLITTREE_H_ diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/statpict.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/statpict.h new file mode 100644 index 0000000000..fd8633dbe6 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/statpict.h @@ -0,0 +1,138 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: statpict.h +// Purpose: wxStaticPicture class +// Author: Wade Brainerd +// Modified by: +// Created: 2003-05-01 +// RCS-ID: +// Copyright: (c) Wade Brainerd +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_STATPICT_H_ +#define _WX_STATPICT_H_ + +#include "wx/control.h" + +#include "wx/icon.h" +#include "wx/bitmap.h" +#include "wx/image.h" + +#include "wx/gizmos/gizmos.h" + +enum +{ + wxSCALE_HORIZONTAL = 0x1, + wxSCALE_VERTICAL = 0x2, + wxSCALE_UNIFORM = 0x4, + wxSCALE_CUSTOM = 0x8 +}; + +WXDLLIMPEXP_GIZMOS extern const wxChar* wxStaticPictureNameStr; + +class WXDLLIMPEXP_GIZMOS wxStaticPicture : public wxControl +{ + DECLARE_DYNAMIC_CLASS(wxStaticPicture) + +public: + wxStaticPicture() {} + + wxStaticPicture( wxWindow* parent, wxWindowID id, + const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticPictureNameStr ) + { + Create( parent, id, label, pos, size, style, name ); + } + + bool Create( wxWindow* parent, wxWindowID id, + const wxBitmap& label, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0, + const wxString& name = wxStaticPictureNameStr ); + + virtual void Command(wxCommandEvent& WXUNUSED(event)) {} + virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event)) {return true;} + void OnPaint(wxPaintEvent& event); + + void SetBitmap( const wxBitmap& bmp ); + + wxBitmap GetBitmap() const + { + return Bitmap; + } + + // Icon interface for compatibility with wxStaticBitmap. + void SetIcon( const wxIcon& icon ) + { + wxBitmap bmp; + bmp.CopyFromIcon( icon ); + SetBitmap( bmp ); + } + + wxIcon GetIcon() const + { + wxIcon icon; + icon.CopyFromBitmap( Bitmap ); + return icon; + } + + void SetAlignment( int align ) + { + Align = align; + } + + int GetAlignment() const + { + return Align; + } + + void SetScale( int scale ) + { + Scale = scale; + } + + int GetScale() const + { + return Scale; + } + + void SetCustomScale( float sx, float sy ) + { + ScaleX = sx; + ScaleY = sy; + } + + void GetCustomScale( float* sx, float* sy ) const + { + *sx = ScaleX; + *sy = ScaleY; + } + +protected: + wxBitmap Bitmap; + + int Align; + + int Scale; + float ScaleX; + float ScaleY; + +#ifndef __WXMSW__ + // When scaling is enabled, measures are taken to improve performance on non-Windows platforms. + // - The original bitmap is stored as a wxImage, because conversion from wxBitmap to wxImage is slow. + // - The latest scaled bitmap is cached, this improves performance when the control is repainted + // but the size hasn't changed (overlapping windows, movement, etc). + wxImage OriginalImage; + float LastScaleX; + float LastScaleY; + wxBitmap ScaledBitmap; +#endif + + DECLARE_EVENT_TABLE() +}; + +#endif // #ifndef _WX_STATPICT_H_ diff --git a/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/xh_statpict.h b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/xh_statpict.h new file mode 100644 index 0000000000..a5ff3b4354 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/include/wx/gizmos/xh_statpict.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_statpict.h +// Purpose: XRC resource handler for wxStaticPicture +// Author: David A. Norris +// Created: 2005/03/13 +// RCS-ID: $Id$ +// Copyright: David A. Norris +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_STATPICT_H +#define _WX_XH_STATPICT_H + +#include "wx/xrc/xmlres.h" +#include "wx/gizmos/gizmos.h" + +// +// XML resource handler for the wxStaticPicture class in wxContrib. +// + +class WXDLLIMPEXP_GIZMOS_XRC wxStaticPictureXmlHandler + : public wxXmlResourceHandler +{ +public: + + // Constructor. + wxStaticPictureXmlHandler(); + + // Creates the control and returns a pointer to it. + virtual wxObject *DoCreateResource(); + + // Returns true if we know how to create a control for the given node. + virtual bool CanHandle(wxXmlNode *node); + + // Register with wxWindows' dynamic class subsystem. + DECLARE_DYNAMIC_CLASS(wxStaticPictureXmlHandler) +}; + +#endif diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/Makefile.in b/wxPython/contrib/gizmos/wxCode/src/gizmos/Makefile.in new file mode 100644 index 0000000000..4ce41afff1 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/Makefile.in @@ -0,0 +1,463 @@ +# ========================================================================= +# This makefile was generated by +# Bakefile 0.2.1 (http://bakefile.sourceforge.net) +# Do not modify, all changes will be overwritten! +# ========================================================================= + + +@MAKE_SET@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +INSTALL = @INSTALL@ +SHARED_LD_CXX = @SHARED_LD_CXX@ +LIBEXT = @LIBEXT@ +LIBPREFIX = @LIBPREFIX@ +SO_SUFFIX = @SO_SUFFIX@ +DLLIMP_SUFFIX = @DLLIMP_SUFFIX@ +LN_S = @LN_S@ +WINDRES = @WINDRES@ +PIC_FLAG = @PIC_FLAG@ +SONAME_FLAG = @SONAME_FLAG@ +STRIP = @STRIP@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_DIR = @INSTALL_DIR@ +BK_DEPS = @BK_DEPS@ +BK_MAKE_PCH = @BK_MAKE_PCH@ +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +libdir = @libdir@ +includedir = @includedir@ +DLLPREFIX = @DLLPREFIX@ +LIBS = @LIBS@ +AR = @AR@ +AROPTIONS = @AROPTIONS@ +RANLIB = @RANLIB@ +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +VENDOR = @VENDOR@ +WX_FLAVOUR = @WX_FLAVOUR@ +WX_LIB_FLAVOUR = @WX_LIB_FLAVOUR@ +TOOLKIT = @TOOLKIT@ +TOOLKIT_LOWERCASE = @TOOLKIT_LOWERCASE@ +TOOLKIT_VERSION = @TOOLKIT_VERSION@ +TOOLCHAIN_FULLNAME = @TOOLCHAIN_FULLNAME@ +EXTRALIBS = @EXTRALIBS@ +EXTRALIBS_XML = @EXTRALIBS_XML@ +EXTRALIBS_GUI = @EXTRALIBS_GUI@ +HOST_SUFFIX = @HOST_SUFFIX@ +wx_top_builddir = @wx_top_builddir@ + +### Variables: ### + +DESTDIR = +WX_RELEASE = 2.9 +WX_RELEASE_NODOT = 29 +WX_VERSION_NODOT = $(WX_RELEASE_NODOT)0 +LIBDIRNAME = $(wx_top_builddir)/lib +GIZMOSDLL_CXXFLAGS = $(__gizmosdll_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ + $(__THREAD_DEFINE_p) -I$(srcdir)/../../include -DWXUSINGDLL \ + -DWXMAKINGDLL_GIZMOS $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS) +GIZMOSDLL_OBJECTS = \ + $(__gizmosdll___win32rc) \ + gizmosdll_dynamicsash.o \ + gizmosdll_editlbox.o \ + gizmosdll_ledctrl.o \ + gizmosdll_multicell.o \ + gizmosdll_splittree.o \ + gizmosdll_statpict.o +GIZMOSDLL_ODEP = $(___pch_wxprec_gizmosdll_wx_wxprec_h_gch___depname) +GIZMOS_XRCDLL_CXXFLAGS = $(__gizmos_xrcdll_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ + $(__THREAD_DEFINE_p) -I$(srcdir)/../../include -DWXUSINGDLL \ + -DWXMAKINGDLL_GIZMOS_XRC $(PIC_FLAG) $(CPPFLAGS) $(CXXFLAGS) +GIZMOS_XRCDLL_OBJECTS = \ + $(__gizmos_xrcdll___win32rc) \ + gizmos_xrcdll_xh_statpict.o +GIZMOS_XRCDLL_ODEP = \ + $(___pch_wxprec_gizmos_xrcdll_wx_wxprec_h_gch___depname) +GIZMOSLIB_CXXFLAGS = $(__gizmoslib_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ + $(__THREAD_DEFINE_p) -I$(srcdir)/../../include $(CPPFLAGS) $(CXXFLAGS) +GIZMOSLIB_OBJECTS = \ + gizmoslib_dynamicsash.o \ + gizmoslib_editlbox.o \ + gizmoslib_ledctrl.o \ + gizmoslib_multicell.o \ + gizmoslib_splittree.o \ + gizmoslib_statpict.o +GIZMOSLIB_ODEP = $(___pch_wxprec_gizmoslib_wx_wxprec_h_gch___depname) +GIZMOS_XRCLIB_CXXFLAGS = $(__gizmos_xrclib_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ + $(__THREAD_DEFINE_p) -I$(srcdir)/../../include $(CPPFLAGS) $(CXXFLAGS) +GIZMOS_XRCLIB_OBJECTS = \ + gizmos_xrclib_xh_statpict.o +GIZMOS_XRCLIB_ODEP = \ + $(___pch_wxprec_gizmos_xrclib_wx_wxprec_h_gch___depname) + +### Conditionally set variables: ### + +@COND_DEPS_TRACKING_0@CXXC = $(CXX) +@COND_DEPS_TRACKING_1@CXXC = $(BK_DEPS) $(CXX) +@COND_PLATFORM_MACOSX_1@WXMACVERSION_CMD = \ +@COND_PLATFORM_MACOSX_1@ -compatibility_version 1.0 -current_version 1.0 +@COND_USE_GUI_0@PORTNAME = base +@COND_USE_GUI_1@PORTNAME = $(TOOLKIT_LOWERCASE)$(TOOLKIT_VERSION) +@COND_TOOLKIT_MAC@WXBASEPORT = _carbon +@COND_PLATFORM_WIN32_1@WXCOMPILER = _gcc +@COND_OFFICIAL_BUILD_0_PLATFORM_WIN32_1@VENDORTAG = _$(VENDOR) +@COND_OFFICIAL_BUILD_1_PLATFORM_WIN32_1@VENDORTAG = +@COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT@WXDEBUGFLAG = d +@COND_DEBUG_FLAG_1@WXDEBUGFLAG = d +@COND_UNICODE_1@WXUNICODEFLAG = u +@COND_WXUNIV_1@WXUNIVNAME = univ +@COND_PLATFORM_WIN32_0@WXDLLNAMEPREFIXGUI = wx_$(PORTNAME)$(WXUNIVNAME) +@COND_PLATFORM_WIN32_1@WXDLLNAMEPREFIXGUI = \ +@COND_PLATFORM_WIN32_1@ wx$(PORTNAME)$(WXUNIVNAME)$(WX_VERSION_NODOT) +@COND_PLATFORM_WIN32_0@WXDLLVERSIONTAG = -$(WX_RELEASE) +@COND_PLATFORM_WIN32_1@WXDLLVERSIONTAG = +@COND_MONOLITHIC_0@EXTRALIBS_FOR_BASE = $(EXTRALIBS) +@COND_MONOLITHIC_1@EXTRALIBS_FOR_BASE = $(EXTRALIBS) $(EXTRALIBS_GUI) +@COND_MONOLITHIC_0@EXTRALIBS_FOR_GUI = $(EXTRALIBS_GUI) +@COND_MONOLITHIC_1@EXTRALIBS_FOR_GUI = +COND_SHARED_1___gizmosdll___depname = \ + $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) +@COND_SHARED_1@__gizmosdll___depname = $(COND_SHARED_1___gizmosdll___depname) +@COND_SHARED_1@__install_gizmosdll___depname = install_gizmosdll +@COND_SHARED_1@__uninstall_gizmosdll___depname = uninstall_gizmosdll +COND_PLATFORM_MACOSX_1___gizmosdll___macinstnamecmd = -install_name \ + $(libdir)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) +@COND_PLATFORM_MACOSX_1@__gizmosdll___macinstnamecmd = $(COND_PLATFORM_MACOSX_1___gizmosdll___macinstnamecmd) +COND_PLATFORM_OS2_1___gizmosdll___importlib = -import \ + $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_PLATFORM_OS2_1@__gizmosdll___importlib = $(COND_PLATFORM_OS2_1___gizmosdll___importlib) +COND_WINDOWS_IMPLIB_1___gizmosdll___importlib = \ + -Wl,--out-implib=$(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_WINDOWS_IMPLIB_1@__gizmosdll___importlib = $(COND_WINDOWS_IMPLIB_1___gizmosdll___importlib) +@COND_GCC_PCH_1@__gizmosdll_PCH_INC = -I.pch/wxprec_gizmosdll +@COND_ICC_PCH_1@__gizmosdll_PCH_INC = -use_pch \ +@COND_ICC_PCH_1@ .pch/wxprec_gizmosdll/wx/wxprec.h.gch +@COND_USE_PCH_1@___pch_wxprec_gizmosdll_wx_wxprec_h_gch___depname \ +@COND_USE_PCH_1@ = .pch/wxprec_gizmosdll/wx/wxprec.h.gch +COND_USE_SOVERLINUX_1___gizmosdll___soname_flags = \ + $(SONAME_FLAG)$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) +@COND_USE_SOVERLINUX_1@__gizmosdll___soname_flags = $(COND_USE_SOVERLINUX_1___gizmosdll___soname_flags) +COND_USE_SOVERSOLARIS_1___gizmosdll___soname_flags = \ + $(SONAME_FLAG)$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) +@COND_USE_SOVERSOLARIS_1@__gizmosdll___soname_flags = $(COND_USE_SOVERSOLARIS_1___gizmosdll___soname_flags) +COND_USE_SOSYMLINKS_1___gizmosdll___so_symlinks_cmd = (cd $(LIBDIRNAME)/; rm -f \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX)) +@COND_USE_SOSYMLINKS_1@__gizmosdll___so_symlinks_cmd = $(COND_USE_SOSYMLINKS_1___gizmosdll___so_symlinks_cmd) +COND_USE_SOSYMLINKS_1___gizmosdll___so_symlinks_inst_cmd = rm -f \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_USE_SOSYMLINKS_1@__gizmosdll___so_symlinks_inst_cmd = $(COND_USE_SOSYMLINKS_1___gizmosdll___so_symlinks_inst_cmd) +COND_USE_SOSYMLINKS_1___gizmosdll___so_symlinks_uninst_cmd = rm -f \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_USE_SOSYMLINKS_1@__gizmosdll___so_symlinks_uninst_cmd = $(COND_USE_SOSYMLINKS_1___gizmosdll___so_symlinks_uninst_cmd) +@COND_PLATFORM_WIN32_1@__gizmosdll___win32rc = gizmosdll_version_rc.o +COND_SHARED_1_USE_XRC_1___gizmos_xrcdll___depname = \ + $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) +@COND_SHARED_1_USE_XRC_1@__gizmos_xrcdll___depname = $(COND_SHARED_1_USE_XRC_1___gizmos_xrcdll___depname) +@COND_SHARED_1_USE_XRC_1@__install_gizmos_xrcdll___depname \ +@COND_SHARED_1_USE_XRC_1@ = install_gizmos_xrcdll +@COND_SHARED_1_USE_XRC_1@__uninstall_gizmos_xrcdll___depname \ +@COND_SHARED_1_USE_XRC_1@ = uninstall_gizmos_xrcdll +COND_PLATFORM_MACOSX_1___gizmos_xrcdll___macinstnamecmd = -install_name \ + $(libdir)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) +@COND_PLATFORM_MACOSX_1@__gizmos_xrcdll___macinstnamecmd = $(COND_PLATFORM_MACOSX_1___gizmos_xrcdll___macinstnamecmd) +COND_PLATFORM_OS2_1___gizmos_xrcdll___importlib = -import \ + $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_PLATFORM_OS2_1@__gizmos_xrcdll___importlib = $(COND_PLATFORM_OS2_1___gizmos_xrcdll___importlib) +COND_WINDOWS_IMPLIB_1___gizmos_xrcdll___importlib = \ + -Wl,--out-implib=$(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_WINDOWS_IMPLIB_1@__gizmos_xrcdll___importlib = $(COND_WINDOWS_IMPLIB_1___gizmos_xrcdll___importlib) +@COND_GCC_PCH_1@__gizmos_xrcdll_PCH_INC = -I.pch/wxprec_gizmos_xrcdll +@COND_ICC_PCH_1@__gizmos_xrcdll_PCH_INC = -use_pch \ +@COND_ICC_PCH_1@ .pch/wxprec_gizmos_xrcdll/wx/wxprec.h.gch +@COND_USE_PCH_1@___pch_wxprec_gizmos_xrcdll_wx_wxprec_h_gch___depname \ +@COND_USE_PCH_1@ = .pch/wxprec_gizmos_xrcdll/wx/wxprec.h.gch +COND_USE_SOVERLINUX_1___gizmos_xrcdll___soname_flags = \ + $(SONAME_FLAG)$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) +@COND_USE_SOVERLINUX_1@__gizmos_xrcdll___soname_flags = $(COND_USE_SOVERLINUX_1___gizmos_xrcdll___soname_flags) +COND_USE_SOVERSOLARIS_1___gizmos_xrcdll___soname_flags = \ + $(SONAME_FLAG)$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) +@COND_USE_SOVERSOLARIS_1@__gizmos_xrcdll___soname_flags = $(COND_USE_SOVERSOLARIS_1___gizmos_xrcdll___soname_flags) +COND_USE_SOSYMLINKS_1___gizmos_xrcdll___so_symlinks_cmd = (cd $(LIBDIRNAME)/; \ + rm -f \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX)) +@COND_USE_SOSYMLINKS_1@__gizmos_xrcdll___so_symlinks_cmd = $(COND_USE_SOSYMLINKS_1___gizmos_xrcdll___so_symlinks_cmd) +COND_USE_SOSYMLINKS_1___gizmos_xrcdll___so_symlinks_inst_cmd = rm -f \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos); \ + $(LN_S) \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_USE_SOSYMLINKS_1@__gizmos_xrcdll___so_symlinks_inst_cmd = $(COND_USE_SOSYMLINKS_1___gizmos_xrcdll___so_symlinks_inst_cmd) +COND_USE_SOSYMLINKS_1___gizmos_xrcdll___so_symlinks_uninst_cmd = rm -f \ + $(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) \ + $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_USE_SOSYMLINKS_1@__gizmos_xrcdll___so_symlinks_uninst_cmd = $(COND_USE_SOSYMLINKS_1___gizmos_xrcdll___so_symlinks_uninst_cmd) +@COND_PLATFORM_WIN32_1@__gizmos_xrcdll___win32rc = \ +@COND_PLATFORM_WIN32_1@ gizmos_xrcdll_version_rc.o +COND_MONOLITHIC_0___WXLIB_XRC_p = \ + -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xrc-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0@__WXLIB_XRC_p = $(COND_MONOLITHIC_0___WXLIB_XRC_p) +COND_MONOLITHIC_0___WXLIB_XML_p = \ + -lwx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xml-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0@__WXLIB_XML_p = $(COND_MONOLITHIC_0___WXLIB_XML_p) +COND_SHARED_0___gizmoslib___depname = \ + $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) +@COND_SHARED_0@__gizmoslib___depname = $(COND_SHARED_0___gizmoslib___depname) +@COND_SHARED_0@__install_gizmoslib___depname = install_gizmoslib +@COND_SHARED_0@__uninstall_gizmoslib___depname = uninstall_gizmoslib +@COND_GCC_PCH_1@__gizmoslib_PCH_INC = -I.pch/wxprec_gizmoslib +@COND_ICC_PCH_1@__gizmoslib_PCH_INC = -use_pch \ +@COND_ICC_PCH_1@ .pch/wxprec_gizmoslib/wx/wxprec.h.gch +@COND_USE_PCH_1@___pch_wxprec_gizmoslib_wx_wxprec_h_gch___depname \ +@COND_USE_PCH_1@ = .pch/wxprec_gizmoslib/wx/wxprec.h.gch +COND_SHARED_0_USE_XRC_1___gizmos_xrclib___depname = \ + $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) +@COND_SHARED_0_USE_XRC_1@__gizmos_xrclib___depname = $(COND_SHARED_0_USE_XRC_1___gizmos_xrclib___depname) +@COND_SHARED_0_USE_XRC_1@__install_gizmos_xrclib___depname \ +@COND_SHARED_0_USE_XRC_1@ = install_gizmos_xrclib +@COND_SHARED_0_USE_XRC_1@__uninstall_gizmos_xrclib___depname \ +@COND_SHARED_0_USE_XRC_1@ = uninstall_gizmos_xrclib +@COND_GCC_PCH_1@__gizmos_xrclib_PCH_INC = -I.pch/wxprec_gizmos_xrclib +@COND_ICC_PCH_1@__gizmos_xrclib_PCH_INC = -use_pch \ +@COND_ICC_PCH_1@ .pch/wxprec_gizmos_xrclib/wx/wxprec.h.gch +@COND_USE_PCH_1@___pch_wxprec_gizmos_xrclib_wx_wxprec_h_gch___depname \ +@COND_USE_PCH_1@ = .pch/wxprec_gizmos_xrclib/wx/wxprec.h.gch +@COND_WXUNIV_1@__WXUNIV_DEFINE_p_0 = --define __WXUNIVERSAL__ +@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p_0 = --define wxNO_EXCEPTIONS +@COND_USE_RTTI_0@__RTTI_DEFINE_p_0 = --define wxNO_RTTI +@COND_USE_THREADS_0@__THREAD_DEFINE_p_0 = --define wxNO_THREADS +@COND_PLATFORM_MACOSX_0_USE_SOVERSION_1@__gizmos = .$(SO_SUFFIX).0 +@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@__gizmos = .0.$(SO_SUFFIX) +@COND_USE_SOVERSION_0@__gizmos = .$(SO_SUFFIX) +@COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1@__gizmos_0 \ +@COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1@ = \ +@COND_PLATFORM_MACOSX_0_USE_SOVERCYGWIN_0_USE_SOVERSION_1@ .$(SO_SUFFIX).0.0.0 +@COND_PLATFORM_MACOSX_1_USE_SOVERSION_1@__gizmos_0 = .0.0.0.$(SO_SUFFIX) +@COND_USE_SOVERCYGWIN_1_USE_SOVERSION_1@__gizmos_0 = -0.$(SO_SUFFIX) +@COND_USE_SOVERSION_0@__gizmos_0 = .$(SO_SUFFIX) +@COND_TOOLKIT_MSW@__RCDEFDIR_p = --include-dir \ +@COND_TOOLKIT_MSW@ $(LIBDIRNAME)/wx/include/$(TOOLCHAIN_FULLNAME) +COND_MONOLITHIC_1___WXLIB_MONO_p = \ + -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_1@__WXLIB_MONO_p = $(COND_MONOLITHIC_1___WXLIB_MONO_p) +@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@__LIB_TIFF_p \ +@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@ = \ +@COND_USE_GUI_1_WXUSE_LIBTIFF_BUILTIN@ -lwxtiff$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@__LIB_JPEG_p \ +@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@ = \ +@COND_USE_GUI_1_WXUSE_LIBJPEG_BUILTIN@ -lwxjpeg$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@__LIB_PNG_p \ +@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@ = \ +@COND_USE_GUI_1_WXUSE_LIBPNG_BUILTIN@ -lwxpng$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_WXUSE_ZLIB_BUILTIN@__LIB_ZLIB_p = \ +@COND_WXUSE_ZLIB_BUILTIN@ -lwxzlib$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_WXUSE_ODBC_BUILTIN@__LIB_ODBC_p = \ +@COND_WXUSE_ODBC_BUILTIN@ -lwxodbc$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +COND_WXUSE_REGEX_BUILTIN___LIB_REGEX_p = \ + -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_WXUSE_REGEX_BUILTIN@__LIB_REGEX_p = $(COND_WXUSE_REGEX_BUILTIN___LIB_REGEX_p) +@COND_WXUSE_EXPAT_BUILTIN@__LIB_EXPAT_p = \ +@COND_WXUSE_EXPAT_BUILTIN@ -lwxexpat$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +COND_MONOLITHIC_0___WXLIB_CORE_p = \ + -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0@__WXLIB_CORE_p = $(COND_MONOLITHIC_0___WXLIB_CORE_p) +COND_MONOLITHIC_0___WXLIB_BASE_p = \ + -lwx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0@__WXLIB_BASE_p = $(COND_MONOLITHIC_0___WXLIB_BASE_p) +@COND_WXUNIV_1@__WXUNIV_DEFINE_p = -D__WXUNIVERSAL__ +@COND_USE_EXCEPTIONS_0@__EXCEPTIONS_DEFINE_p = -DwxNO_EXCEPTIONS +@COND_USE_RTTI_0@__RTTI_DEFINE_p = -DwxNO_RTTI +@COND_USE_THREADS_0@__THREAD_DEFINE_p = -DwxNO_THREADS + +### Targets: ### + +all: $(__gizmosdll___depname) $(__gizmos_xrcdll___depname) $(__gizmoslib___depname) $(__gizmos_xrclib___depname) + +install: all $(__install_gizmosdll___depname) $(__install_gizmos_xrcdll___depname) $(__install_gizmoslib___depname) $(__install_gizmos_xrclib___depname) + $(INSTALL_DIR) $(DESTDIR)$(includedir)/wx-$(WX_RELEASE)$(WX_FLAVOUR) + for f in wx/gizmos/dynamicsash.h wx/gizmos/editlbox.h wx/gizmos/ledctrl.h wx/gizmos/multicell.h wx/gizmos/splittree.h wx/gizmos/statpict.h wx/gizmos/gizmos.h wx/gizmos/xh_statpict.h; do \ + if test ! -d $(DESTDIR)$(includedir)/wx-$(WX_RELEASE)$(WX_FLAVOUR)/`dirname $$f` ; then \ + $(INSTALL_DIR) $(DESTDIR)$(includedir)/wx-$(WX_RELEASE)$(WX_FLAVOUR)/`dirname $$f`; \ + fi; \ + $(INSTALL_DATA) $(srcdir)/../../include//$$f $(DESTDIR)$(includedir)/wx-$(WX_RELEASE)$(WX_FLAVOUR)/$$f; \ + done + +uninstall: $(__uninstall_gizmosdll___depname) $(__uninstall_gizmos_xrcdll___depname) $(__uninstall_gizmoslib___depname) $(__uninstall_gizmos_xrclib___depname) + for f in wx/gizmos/dynamicsash.h wx/gizmos/editlbox.h wx/gizmos/ledctrl.h wx/gizmos/multicell.h wx/gizmos/splittree.h wx/gizmos/statpict.h wx/gizmos/gizmos.h wx/gizmos/xh_statpict.h; do \ + rm -f $(DESTDIR)$(includedir)/wx-$(WX_RELEASE)$(WX_FLAVOUR)/$$f; \ + done + +install-strip: install + $(STRIP) $(DESTDIR)$(libdir)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) + $(STRIP) $(DESTDIR)$(libdir)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) + +clean: + rm -rf ./.deps ./.pch + rm -f ./*.o + rm -f $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) + rm -f $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) + rm -f $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) + rm -f $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) + rm -f $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) + rm -f $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos) + rm -f $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) + rm -f $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) + +distclean: clean + rm -f config.cache config.log config.status bk-deps bk-make-pch shared-ld-sh Makefile + +@COND_SHARED_1@$(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0): $(GIZMOSDLL_OBJECTS) $(__gizmosdll___win32rc) +@COND_SHARED_1@ $(SHARED_LD_CXX) $@ $(GIZMOSDLL_OBJECTS) $(LDFLAGS) -L$(LIBDIRNAME) $(__gizmosdll___macinstnamecmd) $(__gizmosdll___importlib) $(__gizmosdll___soname_flags) $(WXMACVERSION_CMD) $(LIBS) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_ODBC_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) +@COND_SHARED_1@ +@COND_SHARED_1@ $(__gizmosdll___so_symlinks_cmd) + +@COND_SHARED_1@install_gizmosdll: +@COND_SHARED_1@ $(INSTALL_DIR) $(DESTDIR)$(libdir) +@COND_SHARED_1@ $(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir) +@COND_SHARED_1@ $(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) $(DESTDIR)$(libdir) +@COND_SHARED_1@ (cd $(DESTDIR)$(libdir) ; $(__gizmosdll___so_symlinks_inst_cmd)) + +@COND_SHARED_1@uninstall_gizmosdll: +@COND_SHARED_1@ rm -f $(DESTDIR)$(libdir)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_SHARED_1@ rm -f $(DESTDIR)$(libdir)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) +@COND_SHARED_1@ (cd $(DESTDIR)$(libdir) ; $(__gizmosdll___so_symlinks_uninst_cmd)) + +@COND_USE_PCH_1@.pch/wxprec_gizmosdll/wx/wxprec.h.gch: +@COND_USE_PCH_1@ $(BK_MAKE_PCH) .pch/wxprec_gizmosdll/wx/wxprec.h.gch wx/wxprec.h $(CXX) $(GIZMOSDLL_CXXFLAGS) + +@COND_SHARED_1_USE_XRC_1@$(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0): $(GIZMOS_XRCDLL_OBJECTS) $(__gizmos_xrcdll___win32rc) $(__gizmosdll___depname) +@COND_SHARED_1_USE_XRC_1@ $(SHARED_LD_CXX) $@ $(GIZMOS_XRCDLL_OBJECTS) -L$(LIBDIRNAME) $(LDFLAGS) -L$(LIBDIRNAME) $(__gizmos_xrcdll___macinstnamecmd) $(__gizmos_xrcdll___importlib) $(__gizmos_xrcdll___soname_flags) $(WXMACVERSION_CMD) $(LIBS) $(__WXLIB_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_ODBC_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(EXTRALIBS_XML) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) +@COND_SHARED_1_USE_XRC_1@ +@COND_SHARED_1_USE_XRC_1@ $(__gizmos_xrcdll___so_symlinks_cmd) + +@COND_SHARED_1_USE_XRC_1@install_gizmos_xrcdll: +@COND_SHARED_1_USE_XRC_1@ $(INSTALL_DIR) $(DESTDIR)$(libdir) +@COND_SHARED_1_USE_XRC_1@ $(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir) +@COND_SHARED_1_USE_XRC_1@ $(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) $(DESTDIR)$(libdir) +@COND_SHARED_1_USE_XRC_1@ (cd $(DESTDIR)$(libdir) ; $(__gizmos_xrcdll___so_symlinks_inst_cmd)) + +@COND_SHARED_1_USE_XRC_1@uninstall_gizmos_xrcdll: +@COND_SHARED_1_USE_XRC_1@ rm -f $(DESTDIR)$(libdir)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) +@COND_SHARED_1_USE_XRC_1@ rm -f $(DESTDIR)$(libdir)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(__gizmos_0) +@COND_SHARED_1_USE_XRC_1@ (cd $(DESTDIR)$(libdir) ; $(__gizmos_xrcdll___so_symlinks_uninst_cmd)) + +@COND_USE_PCH_1@.pch/wxprec_gizmos_xrcdll/wx/wxprec.h.gch: +@COND_USE_PCH_1@ $(BK_MAKE_PCH) .pch/wxprec_gizmos_xrcdll/wx/wxprec.h.gch wx/wxprec.h $(CXX) $(GIZMOS_XRCDLL_CXXFLAGS) + +@COND_SHARED_0@$(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT): $(GIZMOSLIB_OBJECTS) +@COND_SHARED_0@ rm -f $@ +@COND_SHARED_0@ $(AR) $(AROPTIONS) $@ $(GIZMOSLIB_OBJECTS) +@COND_SHARED_0@ $(RANLIB) $@ + +@COND_SHARED_0@install_gizmoslib: +@COND_SHARED_0@ $(INSTALL_DIR) $(DESTDIR)$(libdir) +@COND_SHARED_0@ $(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) $(DESTDIR)$(libdir) + +@COND_SHARED_0@uninstall_gizmoslib: +@COND_SHARED_0@ rm -f $(DESTDIR)$(libdir)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) + +@COND_USE_PCH_1@.pch/wxprec_gizmoslib/wx/wxprec.h.gch: +@COND_USE_PCH_1@ $(BK_MAKE_PCH) .pch/wxprec_gizmoslib/wx/wxprec.h.gch wx/wxprec.h $(CXX) $(GIZMOSLIB_CXXFLAGS) + +@COND_SHARED_0_USE_XRC_1@$(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT): $(GIZMOS_XRCLIB_OBJECTS) +@COND_SHARED_0_USE_XRC_1@ rm -f $@ +@COND_SHARED_0_USE_XRC_1@ $(AR) $(AROPTIONS) $@ $(GIZMOS_XRCLIB_OBJECTS) +@COND_SHARED_0_USE_XRC_1@ $(RANLIB) $@ + +@COND_SHARED_0_USE_XRC_1@install_gizmos_xrclib: +@COND_SHARED_0_USE_XRC_1@ $(INSTALL_DIR) $(DESTDIR)$(libdir) +@COND_SHARED_0_USE_XRC_1@ $(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) $(DESTDIR)$(libdir) + +@COND_SHARED_0_USE_XRC_1@uninstall_gizmos_xrclib: +@COND_SHARED_0_USE_XRC_1@ rm -f $(DESTDIR)$(libdir)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) + +@COND_USE_PCH_1@.pch/wxprec_gizmos_xrclib/wx/wxprec.h.gch: +@COND_USE_PCH_1@ $(BK_MAKE_PCH) .pch/wxprec_gizmos_xrclib/wx/wxprec.h.gch wx/wxprec.h $(CXX) $(GIZMOS_XRCLIB_CXXFLAGS) + +gizmosdll_version_rc.o: $(srcdir)/../../../src/msw/version.rc $(GIZMOSDLL_ODEP) + $(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include + +gizmosdll_dynamicsash.o: $(srcdir)/dynamicsash.cpp $(GIZMOSDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOSDLL_CXXFLAGS) $(srcdir)/dynamicsash.cpp + +gizmosdll_editlbox.o: $(srcdir)/editlbox.cpp $(GIZMOSDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOSDLL_CXXFLAGS) $(srcdir)/editlbox.cpp + +gizmosdll_ledctrl.o: $(srcdir)/ledctrl.cpp $(GIZMOSDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOSDLL_CXXFLAGS) $(srcdir)/ledctrl.cpp + +gizmosdll_multicell.o: $(srcdir)/multicell.cpp $(GIZMOSDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOSDLL_CXXFLAGS) $(srcdir)/multicell.cpp + +gizmosdll_splittree.o: $(srcdir)/splittree.cpp $(GIZMOSDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOSDLL_CXXFLAGS) $(srcdir)/splittree.cpp + +gizmosdll_statpict.o: $(srcdir)/statpict.cpp $(GIZMOSDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOSDLL_CXXFLAGS) $(srcdir)/statpict.cpp + +gizmos_xrcdll_version_rc.o: $(srcdir)/../../../src/msw/version.rc $(GIZMOS_XRCDLL_ODEP) + $(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_0) $(__EXCEPTIONS_DEFINE_p_0) $(__RTTI_DEFINE_p_0) $(__THREAD_DEFINE_p_0) --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gizmos_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include + +gizmos_xrcdll_xh_statpict.o: $(srcdir)/xh_statpict.cpp $(GIZMOS_XRCDLL_ODEP) + $(CXXC) -c -o $@ $(GIZMOS_XRCDLL_CXXFLAGS) $(srcdir)/xh_statpict.cpp + +gizmoslib_dynamicsash.o: $(srcdir)/dynamicsash.cpp $(GIZMOSLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOSLIB_CXXFLAGS) $(srcdir)/dynamicsash.cpp + +gizmoslib_editlbox.o: $(srcdir)/editlbox.cpp $(GIZMOSLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOSLIB_CXXFLAGS) $(srcdir)/editlbox.cpp + +gizmoslib_ledctrl.o: $(srcdir)/ledctrl.cpp $(GIZMOSLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOSLIB_CXXFLAGS) $(srcdir)/ledctrl.cpp + +gizmoslib_multicell.o: $(srcdir)/multicell.cpp $(GIZMOSLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOSLIB_CXXFLAGS) $(srcdir)/multicell.cpp + +gizmoslib_splittree.o: $(srcdir)/splittree.cpp $(GIZMOSLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOSLIB_CXXFLAGS) $(srcdir)/splittree.cpp + +gizmoslib_statpict.o: $(srcdir)/statpict.cpp $(GIZMOSLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOSLIB_CXXFLAGS) $(srcdir)/statpict.cpp + +gizmos_xrclib_xh_statpict.o: $(srcdir)/xh_statpict.cpp $(GIZMOS_XRCLIB_ODEP) + $(CXXC) -c -o $@ $(GIZMOS_XRCLIB_CXXFLAGS) $(srcdir)/xh_statpict.cpp + + +# Include dependency info, if present: +@IF_GNU_MAKE@-include .deps/*.d + +.PHONY: all install uninstall clean distclean install_gizmosdll uninstall_gizmosdll install_gizmos_xrcdll uninstall_gizmos_xrcdll install_gizmoslib uninstall_gizmoslib install_gizmos_xrclib uninstall_gizmos_xrclib diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/dynamicsash.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/dynamicsash.cpp new file mode 100644 index 0000000000..ed9548212f --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/dynamicsash.cpp @@ -0,0 +1,1471 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dynamicsash.cpp +// Purpose: A window which can be dynamically split to an arbitrary depth +// and later reunified through the user interface +// Author: Matt Kimball +// Modified by: +// Created: 7/15/2001 +// RCS-ID: $Id$ +// Copyright: (c) 2001 Matt Kimball +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#ifdef __WXMSW__ +#include "wx/mdi.h" +#endif + +#include "wx/gizmos/dynamicsash.h" + + +const wxChar* wxDynamicSashWindowNameStr = wxT("dynamicSashWindow"); + + +/* + wxDynamicSashWindow works by internally storing a tree of Implementation + objects (wxDynamicSsahWindowImpl) and Leaf objects + (wxDynamicSashWindowLeaf). The wxDynamicSashWindow has a pointer to one + implementation, and each implementation either has a pointer to a one + leaf (m_leaf) or a pointer to two children implementation objects + (m_child). The leaves each are responsible for drawing the frame and + decorations around one user-provided views and for responding to mouse + and scrollbar events. + + A resulting tree might look something like this: + + wxDynamicSashWindow + | + +- wxDynamicSashWindowImpl + | + +- wxDynamicSashWindowLeaf + | | + | +- user view window + | + +- wxDynamicSashWindowImpl + | + +- wxDynamicSashWindowLeaf + | | + | +- user view window + | + +- wxDynamicSashWindowLeaf + | + +- user view window + + Each time a split occurs, one of the implementation objects removes its + leaf, generates two new implementation object children, each with a new + leaf, and reparents the user view which was connected to its old leaf + to be one of the new leaf's user view, and sends a Split event to the + user view in the hopes that it will generate a new user view for the + other new leaf. + + When a unification ocurrs, an implementation object is replaced by one + of its children, and the tree of its other child is pruned. + + One quirk is that the top-level implementation object (m_top) always + keeps a pointer to the implementation object where a new child is needed. + (m_add_child_target). This is so that when a new uesr view is added + to the hierarchy, AddChild() is able to reparent the new user view to + the correct implementation object's leaf. + +*/ + +#include "wx/dcmemory.h" +#include "wx/dcscreen.h" +#include "wx/layout.h" +#include "wx/scrolbar.h" +#include "wx/settings.h" + + +const wxEventType wxEVT_DYNAMIC_SASH_SPLIT = wxNewEventType(); +const wxEventType wxEVT_DYNAMIC_SASH_UNIFY = wxNewEventType(); +const wxEventType wxEVT_DYNAMIC_SASH_REPARENT = wxNewEventType(); + +enum DynamicSashRegion +{ + DSR_NONE, + DSR_VERTICAL_TAB, + DSR_HORIZONTAL_TAB, + DSR_CORNER, + DSR_LEFT_EDGE, + DSR_TOP_EDGE, + DSR_RIGHT_EDGE, + DSR_BOTTOM_EDGE +}; + + +/* + wxDynamicSashReparentEvent is generated by the AddChild() method of + wxDynamicSashWindow when it wants a Leaf to reparent a user view window + to its viewport at some time in the future. We can't reparent the window + immediately, because switching parents in AddChild() confuses the wxWindow + class. Instead, we queue up this event, and the window is actually + reparented the next time we process events in the idle loop. +*/ +class wxDynamicSashReparentEvent : public wxEvent +{ +public: + wxDynamicSashReparentEvent(); + wxDynamicSashReparentEvent(wxObject *object); + wxDynamicSashReparentEvent(const wxDynamicSashReparentEvent& evt); + + virtual wxEvent* Clone() const { return new wxDynamicSashReparentEvent(*this); } + + DECLARE_DYNAMIC_CLASS(wxDynamicSashReparentEvent) +}; + + +class wxDynamicSashWindowImpl : public wxEvtHandler +{ +public: + wxDynamicSashWindowImpl(wxDynamicSashWindow *window); + ~wxDynamicSashWindowImpl(); + + bool Create(); + void AddChild(wxWindow *window); + void DrawSash(int x, int y) const; + void ConstrainChildren(int px, int py); + void Split(int x, int y); + void Unify(int panel); + void Resize(int x, int y); + wxDynamicSashWindowImpl *FindParent(DynamicSashRegion side) const; + wxDynamicSashWindowImpl *FindUpperParent(wxDynamicSashWindowImpl *sash_a, + wxDynamicSashWindowImpl *sash_b) const; + wxWindow *FindFrame() const; + wxScrollBar *FindScrollBar(const wxWindow *child, int vert) const; + + void OnSize(wxSizeEvent &event); + void OnPaint(wxPaintEvent &event); + void OnMouseMove(wxMouseEvent &event); + void OnLeave(wxMouseEvent &event); + void OnPress(wxMouseEvent &event); + void OnRelease(wxMouseEvent &event); + + wxDynamicSashWindow *m_window; + wxDynamicSashWindowImpl *m_add_child_target; + + /* This is the window we are responsible for managing. Either of + leaf or our children are in this window. For the top level + implementation object, this is the same as m_window. + Otherwise it is a window we've created an will destroy when we + are deleted. */ + wxWindow *m_container; + + wxDynamicSashWindowImpl *m_parent; + wxDynamicSashWindowImpl *m_top; + wxDynamicSashWindowImpl *m_child[2]; + + class wxDynamicSashWindowLeaf *m_leaf; + + /* If the implementation is split horizontally or vertically, m_split + is set to DSR_HORIZONTAL_TAB or DSR_VERTICAL_TAB, respectively. + Otherwise it is set to DSR_NONE. */ + DynamicSashRegion m_split; + + /* These are used to keep track of a sash as it is being dragged, for + drawing the user interface correctly. */ + DynamicSashRegion m_dragging; + int m_drag_x, m_drag_y; +}; + +class wxDynamicSashWindowLeaf : public wxEvtHandler +{ +public: + wxDynamicSashWindowLeaf(wxDynamicSashWindowImpl *impl); + ~wxDynamicSashWindowLeaf(); + + bool Create(); + void AddChild(wxWindow *window); + DynamicSashRegion GetRegion(int x, int y); + void ResizeChild(const wxSize& size); + wxScrollBar *FindScrollBar(const wxWindow *child, int vert) const; + + void OnSize(wxSizeEvent &event); + void OnViewSize(wxSizeEvent &event); + void OnPaint(wxPaintEvent &event); + void OnScroll(wxScrollEvent &event); + void OnFocus(wxFocusEvent &event); + void OnMouseMove(wxMouseEvent &event); + void OnLeave(wxMouseEvent &event); + void OnPress(wxMouseEvent &event); + void OnRelease(wxMouseEvent &event); + void OnReparent(wxEvent &event); + + wxDynamicSashWindowImpl *m_impl; + + wxScrollBar *m_vscroll, + *m_hscroll; + + /* m_child is the window provided to us by the application developer. + m_viewport is a window we've created, and it is the immediately + parent of m_child. We scroll m_child by moving it around within + m_viewport. */ + wxWindow *m_viewport, + *m_child; +}; + + +// ============================================================================ +// wxDynamicSashWindow +// ============================================================================ + +wxDynamicSashWindow::wxDynamicSashWindow() +{ + m_impl = NULL; +} + +wxDynamicSashWindow::wxDynamicSashWindow(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + m_impl = NULL; + Create(parent, id, pos, size, style, name); +} + +wxDynamicSashWindow::~wxDynamicSashWindow() +{ + SetEventHandler(this); + delete m_impl; +} + +bool wxDynamicSashWindow::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + if (m_impl) + return false; + + if (!wxWindow::Create(parent, id, pos, size, style, name)) + return false; + + m_impl = new wxDynamicSashWindowImpl(this); + if (!m_impl) + return false; + + if (!m_impl->Create()) + { + delete m_impl; + m_impl = NULL; + return false; + } + + return true; +} + +void wxDynamicSashWindow::AddChild(wxWindowBase *child) +{ + wxWindow::AddChild(child); + + m_impl->AddChild(wxDynamicCast(child, wxWindow)); +} + +wxScrollBar *wxDynamicSashWindow::GetHScrollBar(const wxWindow *child) const +{ + return m_impl->FindScrollBar(child, 0); +} + +wxScrollBar *wxDynamicSashWindow::GetVScrollBar(const wxWindow *child) const +{ + return m_impl->FindScrollBar(child, 1); +} + +IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashWindow, wxWindow) + + +// ============================================================================ +// wxDynamicSashWindowImpl +// ============================================================================ + +wxDynamicSashWindowImpl::wxDynamicSashWindowImpl(wxDynamicSashWindow *window) +{ + m_window = window; + m_add_child_target = this; + + m_container = NULL; + m_parent = NULL; + m_top = this; + m_child[0] = + m_child[1] = NULL; + m_leaf = NULL; + m_dragging = DSR_NONE; + m_split = DSR_NONE; +} + +wxDynamicSashWindowImpl::~wxDynamicSashWindowImpl() +{ + delete m_leaf; + delete m_child[0]; + m_child[0] = NULL; + delete m_child[1]; + m_child[1] = NULL; + m_leaf = NULL; + + if (m_container != m_window && m_container) + { + m_container->SetEventHandler(m_container); + m_container->Destroy(); + } +} + +bool wxDynamicSashWindowImpl::Create() +{ + if (!m_container) + m_container = m_window; + + wxCursor cursor(wxCURSOR_ARROW); + m_container->SetCursor(cursor); + + m_leaf = new wxDynamicSashWindowLeaf(this); + if (!m_leaf) + return false; + + if (!m_leaf->Create()) + { + delete m_leaf; + m_leaf = NULL; + return false; + } + + m_container->SetEventHandler(this); + + Connect(wxEVT_SIZE, wxSizeEventHandler(wxDynamicSashWindowImpl::OnSize)); + Connect(wxEVT_PAINT, wxPaintEventHandler(wxDynamicSashWindowImpl::OnPaint)); + Connect(wxEVT_MOTION, + wxMouseEventHandler(wxDynamicSashWindowImpl::OnMouseMove)); + Connect(wxEVT_ENTER_WINDOW, + wxMouseEventHandler(wxDynamicSashWindowImpl::OnMouseMove)); + Connect(wxEVT_LEAVE_WINDOW, + wxMouseEventHandler(wxDynamicSashWindowImpl::OnLeave)); + Connect(wxEVT_LEFT_DOWN, + wxMouseEventHandler(wxDynamicSashWindowImpl::OnPress)); + Connect(wxEVT_LEFT_UP, + wxMouseEventHandler(wxDynamicSashWindowImpl::OnRelease)); + + return true; +} + +void wxDynamicSashWindowImpl::AddChild(wxWindow *window) +{ + if (m_add_child_target && m_add_child_target->m_leaf) + m_add_child_target->m_leaf->AddChild(window); +} + +void wxDynamicSashWindowImpl::DrawSash(int x, int y) const +{ + int i, j; + + wxScreenDC dc; + dc.StartDrawingOnTop(m_container); + + wxBitmap bmp(8, 8); + wxMemoryDC bdc; + bdc.SelectObject(bmp); + bdc.DrawRectangle(-1, -1, 10, 10); + for (i = 0; i < 8; i++) + { + for (j = 0; j < 8; j++) + { + if ((i + j) & 1) + bdc.DrawPoint(i, j); + } + } + + wxBrush brush(bmp); + dc.SetBrush(brush); + dc.SetLogicalFunction(wxXOR); + + if ((m_dragging == DSR_CORNER) && + (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) + { + int cx = 0; + int cy = 0; + + m_container->ClientToScreen(&cx, &cy); + m_container->ClientToScreen(&x, &y); + + if (cx < x && cy < y) + { + dc.DrawRectangle(cx - 2, cy - 2, x - cx + 4, 4); + dc.DrawRectangle(x - 2, cy + 2, 4, y - cy); + dc.DrawRectangle(cx - 2, cy + 2, 4, y - cy); + dc.DrawRectangle(cx + 2, y - 2, x - cx - 4, 4); + } + } + else + { + int body_w, body_h; + m_container->GetClientSize(&body_w, &body_h); + + if (y < 0) + y = 0; + if (y > body_h) + y = body_h; + if (x < 0) + x = 0; + if (x > body_w) + x = body_w; + + if (m_dragging == DSR_HORIZONTAL_TAB) + x = 0; + else + y = 0; + + m_container->ClientToScreen(&x, &y); + + int w, h; + w = body_w; h = body_h; + + if (m_dragging == DSR_HORIZONTAL_TAB) + dc.DrawRectangle(x, y - 2, w, 4); + else + dc.DrawRectangle(x - 2, y, 4, h); + } + + dc.EndDrawingOnTop(); +} + +wxDynamicSashWindowImpl * +wxDynamicSashWindowImpl::FindParent(DynamicSashRegion side) const +{ + if (m_parent == NULL) + return NULL; + + if (m_parent->m_split == DSR_HORIZONTAL_TAB) + { + if (side == DSR_TOP_EDGE && m_parent->m_child[1] == this) + return m_parent; + if (side == DSR_BOTTOM_EDGE && m_parent->m_child[0] == this) + return m_parent; + } + else if (m_parent->m_split == DSR_VERTICAL_TAB) + { + if (side == DSR_LEFT_EDGE && m_parent->m_child[1] == this) + return m_parent; + if (side == DSR_RIGHT_EDGE && m_parent->m_child[0] == this) + return m_parent; + } + + return m_parent->FindParent(side); +} + +wxDynamicSashWindowImpl * +wxDynamicSashWindowImpl::FindUpperParent(wxDynamicSashWindowImpl *sash_a, + wxDynamicSashWindowImpl *sash_b) const +{ + wxWindow *win; + win = sash_a->m_container->GetParent(); + while (win && !win->IsTopLevel()) + { + if (win == sash_b->m_container) + return sash_b; + + win = win->GetParent(); + } + + return sash_a; +} + + +wxWindow *wxDynamicSashWindowImpl::FindFrame() const +{ + wxWindow *win; + + win = m_window->GetParent(); + while (win && !win->IsTopLevel() +#if defined(__WXMSW__) && wxUSE_MDI + && ! wxIsKindOf(win, wxMDIChildFrame) // not top-level but still a frame +#endif + ) + { + win = win->GetParent(); + } + + return win; +} + +wxScrollBar * +wxDynamicSashWindowImpl::FindScrollBar(const wxWindow *child, int vert) const +{ + if (m_child[0] == NULL && m_leaf == NULL) + return NULL; + + if (!m_child[0]) + { + return m_leaf->FindScrollBar(child, vert); + } + + wxScrollBar *ret = m_child[0]->FindScrollBar(child, vert); + if (!ret) + ret = m_child[1]->FindScrollBar(child, vert); + + return ret; +} + +void wxDynamicSashWindowImpl::ConstrainChildren(int px, int py) +{ + wxLayoutConstraints *layout = new wxLayoutConstraints(); + layout->left.SameAs(m_container, wxLeft); + layout->top.SameAs(m_container, wxTop); + if (m_split == DSR_HORIZONTAL_TAB) + { + layout->right.SameAs(m_container, wxRight); + layout->height.PercentOf(m_container, wxHeight, py); + } + else + { + layout->bottom.SameAs(m_container, wxBottom); + layout->width.PercentOf(m_container, wxWidth, px); + } + m_child[0]->m_container->SetConstraints(layout); + + layout = new wxLayoutConstraints(); + layout->right.SameAs(m_container, wxRight); + layout->bottom.SameAs(m_container, wxBottom); + if (m_split == DSR_HORIZONTAL_TAB) + { + layout->top.Below(m_child[0]->m_container, 1); + layout->left.SameAs(m_container, wxLeft); + } + else + { + layout->left.RightOf(m_child[0]->m_container, 1); + layout->top.SameAs(m_container, wxTop); + } + m_child[1]->m_container->SetConstraints(layout); +} + +void wxDynamicSashWindowImpl::Unify(int panel) +{ + int other = panel == 0 ? 1 : 0; + + if (m_child[panel]->m_leaf) + { + wxDynamicSashWindowImpl *child[2]; + + child[0] = m_child[0]; + child[1] = m_child[1]; + + m_child[0] = m_child[1] = NULL; + + m_leaf = new wxDynamicSashWindowLeaf(this); + m_leaf->Create(); + m_leaf->m_child = child[panel]->m_leaf->m_child; + + m_leaf->m_vscroll->SetScrollbar(child[panel]->m_leaf->m_vscroll->GetThumbPosition(), + child[panel]->m_leaf->m_vscroll->GetThumbSize(), + child[panel]->m_leaf->m_vscroll->GetRange(), + child[panel]->m_leaf->m_vscroll->GetPageSize()); + m_leaf->m_hscroll->SetScrollbar(child[panel]->m_leaf->m_hscroll->GetThumbPosition(), + child[panel]->m_leaf->m_hscroll->GetThumbSize(), + child[panel]->m_leaf->m_hscroll->GetRange(), + child[panel]->m_leaf->m_hscroll->GetPageSize()); + m_add_child_target = NULL; + wxDynamicSashReparentEvent event(m_leaf); + m_leaf->ProcessEvent(event); + + delete child[0]; + delete child[1]; + + m_split = DSR_NONE; + + wxDynamicSashUnifyEvent unify(m_leaf->m_child); + m_leaf->m_child->ProcessEvent(unify); + } + else + { + m_split = m_child[panel]->m_split; + + delete m_child[other]; + + wxDynamicSashWindowImpl *child_panel = m_child[panel]; + m_child[0] = child_panel->m_child[0]; + m_child[1] = child_panel->m_child[1]; + + m_child[0]->m_parent = this; + m_child[1]->m_parent = this; + + m_add_child_target = NULL; + m_child[0]->m_container->Reparent(m_container); + m_child[1]->m_container->Reparent(m_container); + + child_panel->m_child[0] = child_panel->m_child[1] = NULL; + delete child_panel; + + wxSize size = m_container->GetSize(); + wxSize child_size = m_child[0]->m_container->GetSize(); + + ConstrainChildren(child_size.GetWidth() * 100 / size.GetWidth(), + child_size.GetHeight() * 100 / size.GetHeight()); + + m_container->Layout(); + } +} + +void wxDynamicSashWindowImpl::Split(int px, int py) +{ + + m_add_child_target = NULL; + + m_child[0] = new wxDynamicSashWindowImpl(m_window); + m_child[0]->m_container = new wxWindow(m_container, wxID_ANY); + m_child[0]->m_parent = this; + m_child[0]->m_top = m_top; + m_child[0]->Create(); + if (m_leaf->m_child) + { + m_leaf->m_child->Reparent(m_container); + m_child[0]->AddChild(m_leaf->m_child); + } + + m_child[1] = new wxDynamicSashWindowImpl(m_window); + m_child[1]->m_container = new wxWindow(m_container, wxID_ANY); + m_child[1]->m_parent = this; + m_child[1]->m_top = m_top; + m_child[1]->Create(); + + m_split = m_dragging; + ConstrainChildren(px, py); + + m_top->m_add_child_target = m_child[1]; + wxDynamicSashSplitEvent split(m_child[0]->m_leaf->m_child); + m_child[0]->m_leaf->m_child->ProcessEvent(split); + + m_child[0]->m_leaf->m_vscroll->SetScrollbar(m_leaf->m_vscroll->GetThumbPosition(), + m_leaf->m_vscroll->GetThumbSize(), + m_leaf->m_vscroll->GetRange(), + m_leaf->m_vscroll->GetPageSize()); + m_child[0]->m_leaf->m_hscroll->SetScrollbar(m_leaf->m_hscroll->GetThumbPosition(), + m_leaf->m_hscroll->GetThumbSize(), + m_leaf->m_hscroll->GetRange(), + m_leaf->m_hscroll->GetPageSize()); + m_child[1]->m_leaf->m_vscroll->SetScrollbar(m_leaf->m_vscroll->GetThumbPosition(), + m_leaf->m_vscroll->GetThumbSize(), + m_leaf->m_vscroll->GetRange(), + m_leaf->m_vscroll->GetPageSize()); + m_child[1]->m_leaf->m_hscroll->SetScrollbar(m_leaf->m_hscroll->GetThumbPosition(), + m_leaf->m_hscroll->GetThumbSize(), + m_leaf->m_hscroll->GetRange(), + m_leaf->m_hscroll->GetPageSize()); + delete m_leaf; + m_leaf = NULL; + + m_container->Layout(); +} + + +/* This code is called when you finish resizing a view by dragging the + corner tab, but I think this implementation is lousy and will surprise + the user more often than it will do what they are trying to do. What + I really need to be doing here is do a rewrite such that *no* sashes + move except the ones immediately to the bottom and right of this window, + and handle the case where you resize a window larger than it's neighbors + by destroying the neighbors. + + But this will do for now. */ +void wxDynamicSashWindowImpl::Resize(int x, int y) +{ + wxDynamicSashWindowImpl *h_parent = FindParent(DSR_BOTTOM_EDGE); + wxDynamicSashWindowImpl *v_parent = FindParent(DSR_RIGHT_EDGE); + int h_unify = -1; + int v_unify = -1; + wxWindow *frame = FindFrame(); + + if (x < 0) + x = 0; + if (y < 0) + y = 0; + + if (h_parent) + { + m_container->ClientToScreen(NULL, &y); + h_parent->m_container->ScreenToClient(NULL, &y); + + int py = (int)((y * 100) / h_parent->m_container->GetSize().GetHeight() + 0.5); + + if (py < 10) + { + wxDynamicSashWindowImpl *ho_parent = FindParent(DSR_TOP_EDGE); + + if (ho_parent) + { + if (FindUpperParent(h_parent, ho_parent) == ho_parent) + { + h_unify = 1; + } + else + { + py = (int)((ho_parent->m_child[0]->m_container->GetSize().GetHeight() * 100) + / h_parent->m_container->GetSize().GetHeight() + 0.5); + h_parent->m_child[0]->m_container->GetConstraints()->height.PercentOf( + h_parent->m_container, wxHeight, py); + + h_parent = ho_parent; + h_unify = 0; + } + } + else + { + h_unify = 1; + } + } + else if (py > 90) + { + h_unify = 0; + } + else + { + h_parent->m_child[0]->m_container->GetConstraints()->height.PercentOf( + h_parent->m_container, wxHeight, py); + h_parent->m_container->Layout(); + } + } + else + { + int do_resize = 1; + h_parent = FindParent(DSR_TOP_EDGE); + + if (h_parent) + { + int py = (int)((y * 100) / + (h_parent->m_container->GetSize().GetHeight() + + y - m_container->GetSize().GetHeight()) + 0.5); + + if (py < 10) + h_unify = 0; + } + else if (y < 64) + { + do_resize = 0; + } + + if (do_resize) + { + wxSize size = frame->GetSize(); + frame->SetSize(size.GetWidth(), size.GetHeight() + y - m_container->GetSize().GetHeight()); + } + } + + if (v_parent) + { + m_container->ClientToScreen(&x, NULL); + v_parent->m_container->ScreenToClient(&x, NULL); + + int px = (int)((x * 100) / v_parent->m_container->GetSize().GetWidth() + 0.5); + + if (px < 10) + { + wxDynamicSashWindowImpl *vo_parent = FindParent(DSR_LEFT_EDGE); + + if (vo_parent) + { + if (FindUpperParent(v_parent, vo_parent) == vo_parent) + { + v_unify = 1; + } + else + { + px = (int)((vo_parent->m_child[0]->m_container->GetSize().GetWidth() * 100) + / v_parent->m_container->GetSize().GetWidth() + 0.5); + v_parent->m_child[0]->m_container->GetConstraints()->width.PercentOf( + v_parent->m_container, wxWidth, px); + + v_parent = vo_parent; + v_unify = 0; + } + } + else + { + v_unify = 1; + } + } + else if (px > 90) + { + v_unify = 0; + } + else + { + v_parent->m_child[0]->m_container->GetConstraints()->width.PercentOf( + v_parent->m_container, wxWidth, px); + v_parent->m_container->Layout(); + } + } + else + { + int do_resize = 1; + v_parent = FindParent(DSR_LEFT_EDGE); + + if (v_parent) + { + int px = (int)((x * 100) / + (v_parent->m_container->GetSize().GetWidth() + + x - m_container->GetSize().GetWidth()) + 0.5); + + if (px < 10) + v_unify = 0; + } + else if (x < 64) + { + do_resize = 0; + } + + if (do_resize) + { + wxSize size = frame->GetSize(); + frame->SetSize(size.GetWidth() + x - m_container->GetSize().GetWidth(), size.GetHeight()); + } + } + + if (h_unify != -1 && v_unify != -1) + { + wxDynamicSashWindowImpl *parent = FindUpperParent(h_parent, v_parent); + + if (parent == h_parent) + { + h_parent->Unify(h_unify); + } + else + { + v_parent->Unify(v_unify); + } + } + else if (h_unify != -1) + { + h_parent->Unify(h_unify); + } + else if (v_unify != -1) + { + v_parent->Unify(v_unify); + } +} + + +void wxDynamicSashWindowImpl::OnSize(wxSizeEvent &event) +{ + m_container->Layout(); + + if (m_leaf) + m_leaf->OnSize(event); +} + +void wxDynamicSashWindowImpl::OnPaint(wxPaintEvent &event) +{ + if (m_leaf) + m_leaf->OnPaint(event); + else + { + wxPaintDC dc(m_container); + dc.SetBackground(wxBrush(m_container->GetBackgroundColour(), wxSOLID)); + dc.Clear(); + } +} + +void wxDynamicSashWindowImpl::OnMouseMove(wxMouseEvent &event) +{ + if (m_dragging) + { + DrawSash(m_drag_x, m_drag_y); + m_drag_x = event.m_x; m_drag_y = event.m_y; + DrawSash(m_drag_x, m_drag_y); + } + else if (m_leaf) + { + m_leaf->OnMouseMove(event); + } +} + +void wxDynamicSashWindowImpl::OnLeave(wxMouseEvent &event) +{ + if (m_leaf) + m_leaf->OnLeave(event); +} + +void wxDynamicSashWindowImpl::OnPress(wxMouseEvent &event) +{ + if (m_leaf) + { + m_leaf->OnPress(event); + } + else + { + m_dragging = m_split; + m_drag_x = event.m_x; + m_drag_y = event.m_y; + DrawSash(m_drag_x, m_drag_y); + m_container->CaptureMouse(); + } +} + +void wxDynamicSashWindowImpl::OnRelease(wxMouseEvent &event) +{ + if ((m_dragging == DSR_CORNER) && + (m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) + { + DrawSash(m_drag_x, m_drag_y); + m_container->ReleaseMouse(); + + Resize(event.m_x, event.m_y); + + m_dragging = DSR_NONE; + } + else if (m_dragging) + { + DrawSash(m_drag_x, m_drag_y); + m_container->ReleaseMouse(); + + wxSize size = m_container->GetSize(); + int px = (int)((event.m_x * 100) / size.GetWidth() + 0.5); + int py = (int)((event.m_y * 100) / size.GetHeight() + 0.5); + + if ((m_dragging == DSR_HORIZONTAL_TAB && py >= 10 && py <= 90) + || (m_dragging == DSR_VERTICAL_TAB && px >= 10 && px <= 90)) + { + if (m_child[0] == NULL) + { + Split(px, py); + } + else + { + /* It would be nice if moving *this* sash didn't implicitly move + the sashes of our children (if any). But this will do. */ + wxLayoutConstraints *layout = m_child[0]->m_container->GetConstraints(); + if (m_split == DSR_HORIZONTAL_TAB) + { + layout->height.PercentOf(m_container, wxHeight, py); + } + else + { + layout->width.PercentOf(m_container, wxWidth, px); + } + m_container->Layout(); + } + } + else + { + if (m_child[0] != NULL) + { + if ((m_dragging == DSR_HORIZONTAL_TAB && py <= 10) + || (m_dragging == DSR_VERTICAL_TAB && px <= 10)) + { + Unify(1); + } + else + { + Unify(0); + } + } + } + + wxCursor cursor; + if (m_split == DSR_HORIZONTAL_TAB) + cursor = wxCursor(wxCURSOR_SIZENS); + else if (m_split == DSR_VERTICAL_TAB) + cursor = wxCursor(wxCURSOR_SIZEWE); + else + cursor = wxCursor(wxCURSOR_ARROW); + + m_container->SetCursor(cursor); + + m_dragging = DSR_NONE; + } + else if (m_leaf) + { + m_leaf->OnRelease(event); + } +} + +// ============================================================================ +// wxDynamicSashWindowLeaf +// ============================================================================ + +wxDynamicSashWindowLeaf::wxDynamicSashWindowLeaf(wxDynamicSashWindowImpl *impl) +{ + m_impl = impl; + + m_hscroll = + m_vscroll = NULL; + + m_child = NULL; +} + +wxDynamicSashWindowLeaf::~wxDynamicSashWindowLeaf() +{ + m_hscroll->SetEventHandler(m_hscroll); + m_vscroll->SetEventHandler(m_vscroll); + + m_hscroll->Destroy(); + m_vscroll->Destroy(); + m_viewport->Destroy(); +} + +bool wxDynamicSashWindowLeaf::Create() +{ + m_hscroll = new wxScrollBar(); + m_vscroll = new wxScrollBar(); + m_viewport = new wxWindow(); + + wxDynamicSashWindowImpl *add_child_target = m_impl->m_add_child_target; + m_impl->m_add_child_target = NULL; + + bool success = m_hscroll->Create(m_impl->m_container, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxSB_HORIZONTAL); + if ( success ) + success = m_vscroll->Create(m_impl->m_container, wxID_ANY, + wxDefaultPosition, wxDefaultSize, + wxSB_VERTICAL); + if ( success ) + success = m_viewport->Create(m_impl->m_container, wxID_ANY); + if ( !success ) + return false; + + m_impl->m_add_child_target = add_child_target; + + wxCursor cursor(wxCURSOR_ARROW); + m_hscroll->SetCursor(cursor); + m_vscroll->SetCursor(cursor); + m_viewport->SetCursor(cursor); + + // the viewport must resize its child when it is itself resized, but it's + // more convenient to do it in our own method instead of deriving a new + // class just for this: this is why we pass this as last Connect() argument + m_viewport->Connect(wxEVT_SIZE, + wxSizeEventHandler(wxDynamicSashWindowLeaf::OnViewSize), + NULL, this); + + Connect(wxEVT_DYNAMIC_SASH_REPARENT, + wxEventHandler(wxDynamicSashWindowLeaf::OnReparent)); + + if (m_impl->m_window->GetWindowStyle() & wxDS_MANAGE_SCROLLBARS) + { + m_hscroll->SetEventHandler(this); + m_vscroll->SetEventHandler(this); + + Connect(wxEVT_SET_FOCUS, + wxFocusEventHandler(wxDynamicSashWindowLeaf::OnFocus)); + Connect(wxEVT_SCROLL_TOP, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_BOTTOM, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_LINEUP, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_LINEDOWN, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_PAGEUP, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_PAGEDOWN, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_THUMBTRACK, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + Connect(wxEVT_SCROLL_THUMBRELEASE, + wxScrollEventHandler(wxDynamicSashWindowLeaf::OnScroll)); + } + + wxLayoutConstraints *layout = new wxLayoutConstraints(); + if (!layout) + return false; + + wxSize size = m_hscroll->GetBestSize(); + + layout->left.SameAs(m_impl->m_container, wxLeft, 10); + layout->right.LeftOf(m_vscroll); + layout->bottom.SameAs(m_impl->m_container, wxBottom, 3); + layout->height.Absolute(size.GetHeight()); + m_hscroll->SetConstraints(layout); + + layout = new wxLayoutConstraints(); + if (!layout) + return false; + + size = m_vscroll->GetBestSize(); + + layout->top.SameAs(m_impl->m_container, wxTop, 10); + layout->bottom.Above(m_hscroll); + layout->right.SameAs(m_impl->m_container, wxRight, 3); + layout->width.Absolute(size.GetWidth()); + m_vscroll->SetConstraints(layout); + + layout = new wxLayoutConstraints(); + if (!layout) + return false; + layout->left.SameAs(m_impl->m_container, wxLeft, 3); + layout->right.LeftOf(m_vscroll); + layout->top.SameAs(m_impl->m_container, wxTop, 3); + layout->bottom.Above(m_hscroll); + m_viewport->SetConstraints(layout); + + m_impl->m_container->Layout(); + + return true; +} + +void wxDynamicSashWindowLeaf::AddChild(wxWindow *window) +{ + if (m_child) + m_child->Destroy(); + + m_child = window; + + wxDynamicSashReparentEvent event(this); + AddPendingEvent(event); +} + +DynamicSashRegion wxDynamicSashWindowLeaf::GetRegion(int x, int y) +{ + wxSize size = m_impl->m_container->GetSize(); + int w = size.GetWidth(); + int h = size.GetHeight(); + size = m_hscroll->GetSize(); + int sh = size.GetHeight(); + size = m_vscroll->GetSize(); + int sw = size.GetWidth(); + + if (x >= w - sw - 3 && x < w && y >= h - sh - 3 && y < h) + return DSR_CORNER; + if (x >= 3 && x < 10 && y >= h - sh - 3 && y < h - 2) + return DSR_VERTICAL_TAB; + if (x >= w - sw - 3 && x < w - 2 && y >= 3 && y < 10) + return DSR_HORIZONTAL_TAB; + if (x < 3) + return DSR_LEFT_EDGE; + if (y < 3) + return DSR_TOP_EDGE; + if (x >= w - 2) + return DSR_RIGHT_EDGE; + if (y >= h - 2) + return DSR_BOTTOM_EDGE; + + return DSR_NONE; +} + +void wxDynamicSashWindowLeaf::ResizeChild(const wxSize& size) +{ + if (m_child) + { + if (m_impl->m_window->HasFlag(wxDS_MANAGE_SCROLLBARS)) + { + wxSize best_size = m_child->GetBestSize(); + if (best_size.GetWidth() < size.GetWidth()) + best_size.SetWidth(size.GetWidth()); + if (best_size.GetHeight() < size.GetHeight()) + best_size.SetHeight(size.GetHeight()); + m_child->SetSize(best_size); + + int hpos = m_hscroll->GetThumbPosition(); + int vpos = m_vscroll->GetThumbPosition(); + + if (hpos < 0) + hpos = 0; + if (vpos < 0) + vpos = 0; + if (hpos > best_size.GetWidth() - size.GetWidth()) + hpos = best_size.GetWidth() - size.GetWidth(); + if (vpos > best_size.GetHeight() - size.GetHeight()) + vpos = best_size.GetHeight() - size.GetHeight(); + + m_hscroll->SetScrollbar(hpos, size.GetWidth(), + best_size.GetWidth(), size.GetWidth()); + m_vscroll->SetScrollbar(vpos, size.GetHeight(), + best_size.GetHeight(), size.GetHeight()); + + // Umm, the scrollbars are doing something insane under GTK+ and subtracting + // one from the position I pass in. This works around that. + m_hscroll->SetThumbPosition(hpos + hpos - m_hscroll->GetThumbPosition()); + m_vscroll->SetThumbPosition(vpos + vpos - m_vscroll->GetThumbPosition()); + + wxPoint pos = m_child->GetPosition(); + m_viewport->ScrollWindow(-hpos - pos.x, -vpos - pos.y); + } + else // !wxDS_MANAGE_SCROLLBARS + { + m_child->SetSize(size); + } + } +} + +wxScrollBar * +wxDynamicSashWindowLeaf::FindScrollBar(const wxWindow *child, int vert) const +{ + if (m_child == child) + { + return vert ? m_vscroll : m_hscroll; + } + + return NULL; +} + +void wxDynamicSashWindowLeaf::OnSize(wxSizeEvent &WXUNUSED(event)) +{ + m_impl->m_container->Refresh(); +} + +void wxDynamicSashWindowLeaf::OnViewSize(wxSizeEvent &WXUNUSED(event)) +{ + if ( m_viewport ) + ResizeChild(m_viewport->GetSize()); +} + +void wxDynamicSashWindowLeaf::OnPaint(wxPaintEvent &WXUNUSED(event)) +{ + wxPaintDC dc(m_impl->m_container); + dc.SetBackground(wxBrush(m_impl->m_container->GetBackgroundColour(), wxSOLID)); + dc.Clear(); + + wxPen highlight(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT), 1, wxSOLID); + wxPen shadow(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW), 1, wxSOLID); + wxPen black(*wxBLACK, 1, wxSOLID); + + wxSize size = m_impl->m_container->GetSize(); + int w = size.GetWidth(); + int h = size.GetHeight(); + size = m_hscroll->GetSize(); + int sh = size.GetHeight(); + size = m_vscroll->GetSize(); + int sw = size.GetWidth(); + + dc.SetPen(shadow); + dc.DrawLine(1, 1, 1, h - 2); + dc.DrawLine(1, 1, w - 2, 1); + dc.SetPen(black); + dc.DrawLine(2, 2, 2, h - 3); + dc.DrawLine(2, 2, w - 3, 2); + dc.SetPen(highlight); + dc.DrawLine(w - 2, 2, w - 2, h - sh - 2); + dc.DrawLine(w - 2, h - sh - 2, w - sw - 2, h - sh - 2); + dc.DrawLine(w - sw - 2, h - sh - 2, w - sw - 2, h - 2); + dc.DrawLine(w - sw - 2, h - 2, 2, h - 2); + + dc.SetPen(highlight); + dc.DrawLine(w - sw - 2, 8, w - sw - 2, 4); + dc.DrawLine(w - sw - 2, 4, w - 5, 4); + dc.SetPen(shadow); + dc.DrawLine(w - 5, 4, w - 5, 8); + dc.DrawLine(w - 5, 8, w - sw - 2, 8); + dc.SetPen(black); + dc.DrawLine(w - 4, 3, w - 4, 9); + dc.DrawLine(w - 4, 9, w - sw - 3, 9); + + dc.SetPen(highlight); + dc.DrawLine(4, h - 5, 4, h - sh - 2); + dc.DrawLine(4, h - sh - 2, 8, h - sh - 2); + dc.SetPen(shadow); + dc.DrawLine(8, h - sh - 2, 8, h - 5); + dc.DrawLine(8, h - 5, 4, h - 5); + dc.SetPen(black); + dc.DrawLine(9, h - sh - 3, 9, h - 4); + dc.DrawLine(9, h - 4, 3, h - 4); + + int cy = (h - sh + h - 6) / 2 + 1; + int cx = (w - sw + w - 6) / 2 + 1; + int sy = cy; + while (sy > h - sh) + sy -= 4; + int sx = cx; + while (sx > w - sw) + sx -= 4; + + int x, y; + for (y = sy; y < h - 2; y += 4) + { + for (x = sx; x < w - 2; x += 4) + { + if (x - cx >= -(y - cy)) + { + dc.SetPen(highlight); + dc.DrawPoint(x, y); + dc.SetPen(shadow); + dc.DrawPoint(x + 1, y + 1); + } + } + } +} + +void wxDynamicSashWindowLeaf::OnScroll(wxScrollEvent &WXUNUSED(event)) +{ + int nx = -m_hscroll->GetThumbPosition(); + int ny = -m_vscroll->GetThumbPosition(); + + if (m_child) + { + wxPoint pos = m_child->GetPosition(); + + m_viewport->ScrollWindow(nx - pos.x, ny - pos.y); + } +} + +void wxDynamicSashWindowLeaf::OnFocus(wxFocusEvent &event) +{ + if ( event.GetEventObject() == m_hscroll || + event.GetEventObject() == m_vscroll ) + { + m_child->SetFocus(); + } +} + + +void wxDynamicSashWindowLeaf::OnMouseMove(wxMouseEvent &event) +{ + if (m_impl->m_dragging) + return; + + DynamicSashRegion region = GetRegion(event.m_x, event.m_y); + + wxCursor cursor(wxCURSOR_ARROW); + if (region == DSR_HORIZONTAL_TAB) + { + cursor = wxCursor(wxCURSOR_SIZENS); + } + else if (region == DSR_VERTICAL_TAB) + { + cursor = wxCursor(wxCURSOR_SIZEWE); + } + else if ((region == DSR_CORNER) && + (m_impl->m_window->GetWindowStyle() & wxDS_DRAG_CORNER) != 0) + { + cursor = wxCursor(wxCURSOR_SIZENWSE); + } + else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE + || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE) + { + if (m_impl->FindParent(region)) + { + if (region == DSR_LEFT_EDGE || region == DSR_RIGHT_EDGE) + { + cursor = wxCursor(wxCURSOR_SIZEWE); + } + else + { + cursor = wxCursor(wxCURSOR_SIZENS); + } + } + } + + m_impl->m_container->SetCursor(cursor); +} + +void wxDynamicSashWindowLeaf::OnLeave(wxMouseEvent &WXUNUSED(event)) +{ + wxCursor cursor(wxCURSOR_ARROW); + m_impl->m_container->SetCursor(cursor); +} + + +void wxDynamicSashWindowLeaf::OnPress(wxMouseEvent &event) +{ + DynamicSashRegion region = GetRegion(event.m_x, event.m_y); + + if ((region == DSR_CORNER) && (m_impl->m_window->GetWindowStyle() & wxDS_DRAG_CORNER) == 0) + return; + + if (region == DSR_HORIZONTAL_TAB || region == DSR_VERTICAL_TAB || region == DSR_CORNER) + { + m_impl->m_dragging = region; + m_impl->m_drag_x = event.m_x; + m_impl->m_drag_y = event.m_y; + m_impl->DrawSash(event.m_x, event.m_y); + m_impl->m_container->CaptureMouse(); + } + else if (region == DSR_LEFT_EDGE || region == DSR_TOP_EDGE + || region == DSR_RIGHT_EDGE || region == DSR_BOTTOM_EDGE) + { + wxDynamicSashWindowImpl *parent = m_impl->FindParent(region); + + if (parent) + { + int x = event.m_x; + int y = event.m_y; + + m_impl->m_container->ClientToScreen(&x, &y); + parent->m_container->ScreenToClient(&x, &y); + + parent->m_dragging = parent->m_split; + parent->m_drag_x = x; + parent->m_drag_y = y; + parent->DrawSash(x, y); + parent->m_container->CaptureMouse(); + } + } +} + +void wxDynamicSashWindowLeaf::OnRelease(wxMouseEvent &WXUNUSED(event)) +{ +} + +void wxDynamicSashWindowLeaf::OnReparent(wxEvent &WXUNUSED(event)) +{ + if (m_child) + { + m_child->Reparent(m_viewport); + } + + ResizeChild(m_viewport->GetSize()); +} + +// ============================================================================ +// events +// ============================================================================ + +wxDynamicSashSplitEvent::wxDynamicSashSplitEvent() +{ + m_eventObject = NULL; + m_eventType = wxEVT_DYNAMIC_SASH_SPLIT; +} + +wxDynamicSashSplitEvent::wxDynamicSashSplitEvent(wxObject *object) +{ + m_eventObject = object; + m_eventType = wxEVT_DYNAMIC_SASH_SPLIT; +} + +IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashSplitEvent, wxCommandEvent) + +wxDynamicSashUnifyEvent::wxDynamicSashUnifyEvent() +{ + m_eventObject = NULL; + m_eventType = wxEVT_DYNAMIC_SASH_UNIFY; +} + +wxDynamicSashUnifyEvent::wxDynamicSashUnifyEvent(wxObject *object) +{ + m_eventObject = object; + m_eventType = wxEVT_DYNAMIC_SASH_UNIFY; +} + +IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashUnifyEvent, wxCommandEvent) + + +wxDynamicSashReparentEvent::wxDynamicSashReparentEvent() +{ + m_eventObject = NULL; + m_eventType = wxEVT_DYNAMIC_SASH_REPARENT; +} + +wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(wxObject *object) +{ + m_eventObject = object; + m_eventType = wxEVT_DYNAMIC_SASH_REPARENT; +} + +wxDynamicSashReparentEvent::wxDynamicSashReparentEvent(const wxDynamicSashReparentEvent& evt) + : wxEvent(evt) +{ +} + +IMPLEMENT_DYNAMIC_CLASS(wxDynamicSashReparentEvent, wxEvent) + diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/editlbox.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/editlbox.cpp new file mode 100644 index 0000000000..38fd1429e2 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/editlbox.cpp @@ -0,0 +1,277 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: editlbox.cpp +// Purpose: ListBox with editable items +// Author: Vaclav Slavik +// RCS-ID: $Id$ +// Copyright: (c) Vaclav Slavik +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/gizmos/editlbox.h" +#include "wx/sizer.h" +#include "wx/listctrl.h" + + + + +// list control with auto-resizable column: +class CleverListCtrl : public wxListCtrl +{ +public: + CleverListCtrl(wxWindow *parent, + wxWindowID id = wxID_ANY, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = wxLC_ICON, + const wxValidator& validator = wxDefaultValidator, + const wxString &name = wxListCtrlNameStr) + : wxListCtrl(parent, id, pos, size, style, validator, name) + { + CreateColumns(); + } + + void CreateColumns() + { + InsertColumn(0, _T("item")); + SizeColumns(); + } + + void SizeColumns() + { + int w = GetSize().x; +#ifdef __WXMSW__ + w -= wxSystemSettings::GetMetric(wxSYS_VSCROLL_X) + 6; +#else + w -= 2*wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); +#endif + SetColumnWidth(0, w); + } + +private: + DECLARE_EVENT_TABLE() + void OnSize(wxSizeEvent& event) + { + SizeColumns(); + event.Skip(); + } +}; + +BEGIN_EVENT_TABLE(CleverListCtrl, wxListCtrl) + EVT_SIZE(CleverListCtrl::OnSize) +END_EVENT_TABLE() + +#include "eldel.xpm" +#include "eldown.xpm" +#include "eledit.xpm" +#include "elnew.xpm" +#include "elup.xpm" + +IMPLEMENT_CLASS(wxEditableListBox, wxPanel) + +// NB: generate the IDs at runtime to avoid conflict with XRCID values, +// they could cause XRCCTRL() failures in XRC-based dialogs +const int wxID_ELB_DELETE = wxNewId(); +const int wxID_ELB_EDIT = wxNewId(); +const int wxID_ELB_NEW = wxNewId(); +const int wxID_ELB_UP = wxNewId(); +const int wxID_ELB_DOWN = wxNewId(); +const int wxID_ELB_LISTCTRL = wxNewId(); + +BEGIN_EVENT_TABLE(wxEditableListBox, wxPanel) + EVT_LIST_ITEM_SELECTED(wxID_ELB_LISTCTRL, wxEditableListBox::OnItemSelected) + EVT_LIST_END_LABEL_EDIT(wxID_ELB_LISTCTRL, wxEditableListBox::OnEndLabelEdit) + EVT_BUTTON(wxID_ELB_NEW, wxEditableListBox::OnNewItem) + EVT_BUTTON(wxID_ELB_UP, wxEditableListBox::OnUpItem) + EVT_BUTTON(wxID_ELB_DOWN, wxEditableListBox::OnDownItem) + EVT_BUTTON(wxID_ELB_EDIT, wxEditableListBox::OnEditItem) + EVT_BUTTON(wxID_ELB_DELETE, wxEditableListBox::OnDelItem) +END_EVENT_TABLE() + +wxEditableListBox::wxEditableListBox(wxWindow *parent, wxWindowID id, + const wxString& label, + const wxPoint& pos, const wxSize& size, + long style, + const wxString& name) + : wxPanel(parent, id, pos, size, wxTAB_TRAVERSAL, name) +{ + m_style = style; + m_bEdit = m_bNew = m_bDel = m_bUp = m_bDown = NULL; + + wxSizer *sizer = new wxBoxSizer(wxVERTICAL); + + wxPanel *subp = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxSUNKEN_BORDER | wxTAB_TRAVERSAL); + wxSizer *subsizer = new wxBoxSizer(wxHORIZONTAL); + subsizer->Add(new wxStaticText(subp, wxID_ANY, label), 1, wxALIGN_CENTRE_VERTICAL | wxLEFT, 4); + +#ifdef __WXMSW__ + #define BTN_BORDER 4 + // FIXME - why is this needed? There's some reason why sunken border is + // ignored by sizers in wxMSW but not in wxGTK that I can't + // figure out... +#else + #define BTN_BORDER 0 +#endif + + if ( m_style & wxEL_ALLOW_EDIT ) + { + m_bEdit = new wxBitmapButton(subp, wxID_ELB_EDIT, wxBitmap(eledit_xpm)); + subsizer->Add(m_bEdit, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + } + + if ( m_style & wxEL_ALLOW_NEW ) + { + m_bNew = new wxBitmapButton(subp, wxID_ELB_NEW, wxBitmap(elnew_xpm)); + subsizer->Add(m_bNew, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + } + + if ( m_style & wxEL_ALLOW_DELETE ) + { + m_bDel = new wxBitmapButton(subp, wxID_ELB_DELETE, wxBitmap(eldel_xpm)); + subsizer->Add(m_bDel, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + } + + if (!(m_style & wxEL_NO_REORDER)) + { + m_bUp = new wxBitmapButton(subp, wxID_ELB_UP, wxBitmap(elup_xpm)); + subsizer->Add(m_bUp, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + + m_bDown = new wxBitmapButton(subp, wxID_ELB_DOWN, wxBitmap(eldown_xpm)); + subsizer->Add(m_bDown, 0, wxALIGN_CENTRE_VERTICAL | wxTOP | wxBOTTOM, BTN_BORDER); + } + +#if wxUSE_TOOLTIPS + if ( m_bEdit ) m_bEdit->SetToolTip(_("Edit item")); + if ( m_bNew ) m_bNew->SetToolTip(_("New item")); + if ( m_bDel ) m_bDel->SetToolTip(_("Delete item")); + if ( m_bUp ) m_bUp->SetToolTip(_("Move up")); + if ( m_bDown ) m_bDown->SetToolTip(_("Move down")); +#endif + + subp->SetSizer(subsizer); + subsizer->Fit(subp); + + sizer->Add(subp, 0, wxEXPAND); + + long st = wxLC_REPORT | wxLC_NO_HEADER | wxLC_SINGLE_SEL | wxSUNKEN_BORDER; + if ( style & wxEL_ALLOW_EDIT ) + st |= wxLC_EDIT_LABELS; + m_listCtrl = new CleverListCtrl(this, wxID_ELB_LISTCTRL, + wxDefaultPosition, wxDefaultSize, st); + wxArrayString empty_ar; + SetStrings(empty_ar); + + sizer->Add(m_listCtrl, 1, wxEXPAND); + + SetSizer(sizer); + Layout(); +} + +void wxEditableListBox::SetStrings(const wxArrayString& strings) +{ + m_listCtrl->DeleteAllItems(); + size_t i; + + for (i = 0; i < strings.GetCount(); i++) + m_listCtrl->InsertItem(i, strings[i]); + + m_listCtrl->InsertItem(strings.GetCount(), wxEmptyString); + m_listCtrl->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); +} + +void wxEditableListBox::GetStrings(wxArrayString& strings) const +{ + strings.Clear(); + + for (int i = 0; i < m_listCtrl->GetItemCount()-1; i++) + strings.Add(m_listCtrl->GetItemText(i)); +} + +void wxEditableListBox::OnItemSelected(wxListEvent& event) +{ + m_selection = event.GetIndex(); + if (!(m_style & wxEL_NO_REORDER)) + { + m_bUp->Enable(m_selection != 0 && m_selection < m_listCtrl->GetItemCount()-1); + m_bDown->Enable(m_selection < m_listCtrl->GetItemCount()-2); + } + + if (m_style & wxEL_ALLOW_EDIT) + m_bEdit->Enable(m_selection < m_listCtrl->GetItemCount()-1); + if (m_style & wxEL_ALLOW_DELETE) + m_bDel->Enable(m_selection < m_listCtrl->GetItemCount()-1); +} + +void wxEditableListBox::OnNewItem(wxCommandEvent& WXUNUSED(event)) +{ + m_listCtrl->SetItemState(m_listCtrl->GetItemCount()-1, + wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); + m_listCtrl->EditLabel(m_selection); +} + +void wxEditableListBox::OnEndLabelEdit(wxListEvent& event) +{ + if ( event.GetIndex() == m_listCtrl->GetItemCount()-1 && + !event.GetText().empty() ) + { + // The user edited last (empty) line, i.e. added new entry. We have to + // add new empty line here so that adding one more line is still + // possible: + m_listCtrl->InsertItem(m_listCtrl->GetItemCount(), wxEmptyString); + + // Simulate a wxEVT_COMMAND_LIST_ITEM_SELECTED event for the new item, + // so that the buttons are enabled/disabled properly + wxListEvent selectionEvent(wxEVT_COMMAND_LIST_ITEM_SELECTED, m_listCtrl->GetId()); + selectionEvent.m_itemIndex = event.GetIndex(); + m_listCtrl->GetEventHandler()->ProcessEvent(selectionEvent); + } +} + +void wxEditableListBox::OnDelItem(wxCommandEvent& WXUNUSED(event)) +{ + m_listCtrl->DeleteItem(m_selection); + m_listCtrl->SetItemState(m_selection, + wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); +} + +void wxEditableListBox::OnEditItem(wxCommandEvent& WXUNUSED(event)) +{ + m_listCtrl->EditLabel(m_selection); +} + +void wxEditableListBox::OnUpItem(wxCommandEvent& WXUNUSED(event)) +{ + wxString t1, t2; + + t1 = m_listCtrl->GetItemText(m_selection - 1); + t2 = m_listCtrl->GetItemText(m_selection); + m_listCtrl->SetItemText(m_selection - 1, t2); + m_listCtrl->SetItemText(m_selection, t1); + m_listCtrl->SetItemState(m_selection - 1, + wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); +} + +void wxEditableListBox::OnDownItem(wxCommandEvent& WXUNUSED(event)) +{ + wxString t1, t2; + + t1 = m_listCtrl->GetItemText(m_selection + 1); + t2 = m_listCtrl->GetItemText(m_selection); + m_listCtrl->SetItemText(m_selection + 1, t2); + m_listCtrl->SetItemText(m_selection, t1); + m_listCtrl->SetItemState(m_selection + 1, + wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); +} diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/eldel.xpm b/wxPython/contrib/gizmos/wxCode/src/gizmos/eldel.xpm new file mode 100644 index 0000000000..9b83bb0441 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/eldel.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * eldel_xpm[] = { +"16 16 3 1", +" c None", +". c #7F0000", +"+ c #FFFFFF", +" ", +" ", +" ", +" ..+ ..+ ", +" ....+ ..+ ", +" ....+ ..+ ", +" ...+ .+ ", +" .....+ ", +" ...+ ", +" .....+ ", +" ...+ ..+ ", +" ...+ ..+ ", +" ...+ .+ ", +" ...+ .+ ", +" . . ", +" "}; diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/eldown.xpm b/wxPython/contrib/gizmos/wxCode/src/gizmos/eldown.xpm new file mode 100644 index 0000000000..656cb9c4f1 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/eldown.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * eldown_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ........... ", +" ......... ", +" ....... ", +" ..... ", +" ... ", +" . ", +" ", +" "}; diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/eledit.xpm b/wxPython/contrib/gizmos/wxCode/src/gizmos/eledit.xpm new file mode 100644 index 0000000000..4cbd05eafd --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/eledit.xpm @@ -0,0 +1,22 @@ +/* XPM */ +static char * eledit_xpm[] = { +"16 16 3 1", +" c None", +". c #000000", +"+ c #00007F", +" ", +" ", +" .. .. ", +" . ", +" . ", +" ++++ . ++++ ", +" ++ . ++ ++", +" +++++ . ++++++", +" ++ ++ . ++ ", +" ++ ++ . ++ ++", +" +++++ . ++++ ", +" . ", +" . ", +" .. .. ", +" ", +" "}; diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/elnew.xpm b/wxPython/contrib/gizmos/wxCode/src/gizmos/elnew.xpm new file mode 100644 index 0000000000..3d0d67f4ac --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/elnew.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char * elnew_xpm[] = { +"16 16 5 1", +" c None", +". c #7F7F7F", +"+ c #FFFFFF", +"@ c #FFFF00", +"# c #000000", +" ", +" ", +" . .+ .@ ", +" . .@.@# # # ", +" @.@+.... # ", +" ... @@ ", +" @ . @. # ", +" .# .@ ", +" . # ", +" # ", +" # ", +" # ", +" # ", +" # # # # # # ", +" ", +" "}; diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/elup.xpm b/wxPython/contrib/gizmos/wxCode/src/gizmos/elup.xpm new file mode 100644 index 0000000000..01193ed821 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/elup.xpm @@ -0,0 +1,21 @@ +/* XPM */ +static char * elup_xpm[] = { +"16 16 2 1", +" c None", +". c #000000", +" ", +" . ", +" ... ", +" ..... ", +" ....... ", +" ......... ", +" ........... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ", +" ", +" "}; diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/ledctrl.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/ledctrl.cpp new file mode 100644 index 0000000000..458af3f4cc --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/ledctrl.cpp @@ -0,0 +1,392 @@ +// ============================================================================ +// headers +// ============================================================================ + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif //__BORLANDC__ + +#ifndef WX_PRECOMP + #include "wx/dcclient.h" + #include "wx/dcmemory.h" + #include "wx/intl.h" +#endif + +#include "wx/gizmos/ledctrl.h" + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +// A LED digit is build up like this, with maximum 7 Lines : +// +// 111 +// 6 2 +// 777 +// 5 3 +// 444 +// +// Each number contains combinations of the lines, and they are set up below. + +const int LINE1 = 1; +const int LINE2 = 2; +const int LINE3 = 4; +const int LINE4 = 8; +const int LINE5 = 16; +const int LINE6 = 32; +const int LINE7 = 64; +const int DECIMALSIGN = 128; + +const int DIGIT0 = LINE1 | LINE2 | LINE3 | LINE4 | LINE5 | LINE6; +const int DIGIT1 = LINE2 | LINE3; +const int DIGIT2 = LINE1 | LINE2 | LINE4 | LINE5 | LINE7; +const int DIGIT3 = LINE1 | LINE2 | LINE3 | LINE4 | LINE7; +const int DIGIT4 = LINE2 | LINE3 | LINE6 | LINE7; +const int DIGIT5 = LINE1 | LINE3 | LINE4 | LINE6 | LINE7; +const int DIGIT6 = LINE1 | LINE3 | LINE4 | LINE5 | LINE6 | LINE7; +const int DIGIT7 = LINE1 | LINE2 | LINE3; +const int DIGIT8 = LINE1 | LINE2 | LINE3 | LINE4 | LINE5 | LINE6 | LINE7; +const int DIGIT9 = LINE1 | LINE2 | LINE3 | LINE6 | LINE7; +const int DASH = LINE7; + +const int DIGITALL = -1; + +// ============================================================================ +// wxLEDNumberCtrl class implementation +// ============================================================================ + +wxLEDNumberCtrl::wxLEDNumberCtrl() +: m_Alignment(wxLED_ALIGN_LEFT), + m_LineMargin(-1), + m_DigitMargin(-1), + m_LineLength(-1), + m_LineWidth(-1), + m_DrawFaded(false), + m_LeftStartPos(-1) +{ +} + + +wxLEDNumberCtrl::wxLEDNumberCtrl(wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style) +: m_Alignment(wxLED_ALIGN_LEFT), + m_LineMargin(-1), + m_DigitMargin(-1), + m_LineLength(-1), + m_LineWidth(-1), + m_DrawFaded(false), + m_LeftStartPos(-1) +{ + Create(parent, id, pos, size, style); +} + + +bool wxLEDNumberCtrl::Create(wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style) +{ + bool RetVal = wxControl::Create(parent, id, pos, size, style); + + if ((style & wxLED_DRAW_FADED) != 0) + SetDrawFaded(true); + if ((style & wxLED_ALIGN_MASK) != 0) + SetAlignment((wxLEDValueAlign)(style & wxLED_ALIGN_MASK)); + + SetBackgroundColour(*wxBLACK); + SetForegroundColour(*wxGREEN); + + return RetVal; +} + + +void wxLEDNumberCtrl::SetAlignment(wxLEDValueAlign Alignment, bool Redraw) +{ + if (Alignment != m_Alignment) + { + m_Alignment = Alignment; + RecalcInternals(GetClientSize()); + + if (Redraw) + Refresh(false); + } +} + + +void wxLEDNumberCtrl::SetDrawFaded(bool DrawFaded, bool Redraw) +{ + if (DrawFaded != m_DrawFaded) + { + m_DrawFaded = DrawFaded; + + if (Redraw) + Refresh(false); + } +} + + +void wxLEDNumberCtrl::SetValue(wxString const &Value, bool Redraw) +{ + if (Value != m_Value) + { +#ifdef __WXDEBUG__ + if (!Value.empty()) + { + for(size_t i=0; i='0' && ch<='9') || ch=='-' || ch==' ' || ch=='.', + wxT("wxLEDNumberCtrl can only display numeric string values.")); + } + } +#endif + + m_Value = Value; + RecalcInternals(GetClientSize()); + + if (Redraw) + Refresh(false); + } +} + + +BEGIN_EVENT_TABLE(wxLEDNumberCtrl, wxControl) + EVT_ERASE_BACKGROUND(wxLEDNumberCtrl::OnEraseBackground) + EVT_PAINT(wxLEDNumberCtrl::OnPaint) + EVT_SIZE(wxLEDNumberCtrl::OnSize) +END_EVENT_TABLE() + + +void wxLEDNumberCtrl::OnEraseBackground(wxEraseEvent &WXUNUSED(event)) +{ +} + + +void wxLEDNumberCtrl::OnPaint(wxPaintEvent &WXUNUSED(event)) +{ + wxPaintDC Dc(this); + + int Width, Height; + GetClientSize(&Width, &Height); + + wxBitmap *pMemoryBitmap = new wxBitmap(Width, Height); + wxMemoryDC MemDc; + + MemDc.SelectObject(*pMemoryBitmap); + + // Draw background. + MemDc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID)); + MemDc.DrawRectangle(wxRect(0, 0, Width, Height)); + MemDc.SetBrush(wxNullBrush); + + // Iterate each digit in the value, and draw. + const int DigitCount = m_Value.Len(); + for (int offset=0, i = 0; offset < DigitCount; ++offset, ++i) + { + wxChar c = m_Value.GetChar(offset); + + // Draw faded lines if wanted. + if (m_DrawFaded && (c != _T('.'))) + DrawDigit(MemDc, DIGITALL, i); + + // Draw the digits. + switch (c) + { + case _T('0') : + DrawDigit(MemDc, DIGIT0, i); + break; + case _T('1') : + DrawDigit(MemDc, DIGIT1, i); + break; + case _T('2') : + DrawDigit(MemDc, DIGIT2, i); + break; + case _T('3') : + DrawDigit(MemDc, DIGIT3, i); + break; + case _T('4') : + DrawDigit(MemDc, DIGIT4, i); + break; + case _T('5') : + DrawDigit(MemDc, DIGIT5, i); + break; + case _T('6') : + DrawDigit(MemDc, DIGIT6, i); + break; + case _T('7') : + DrawDigit(MemDc, DIGIT7, i); + break; + case _T('8') : + DrawDigit(MemDc, DIGIT8, i); + break; + case _T('9') : + DrawDigit(MemDc, DIGIT9, i); + break; + case _T('-') : + DrawDigit(MemDc, DASH, i); + break; + case _T('.') : + // Display the decimal in the previous segment + i--; + DrawDigit(MemDc, DECIMALSIGN, i); + break; + case _T(' ') : + // just skip it + break; + default : + wxFAIL_MSG(wxT("Unknown digit value")); + break; + } + } + + // Blit the memory dc to screen. + Dc.Blit(0, 0, Width, Height, &MemDc, 0, 0, wxCOPY); + delete pMemoryBitmap; +} + + +void wxLEDNumberCtrl::DrawDigit(wxDC &Dc, int Digit, int Column) +{ + wxColour LineColor(GetForegroundColour()); + + if (Digit == DIGITALL) + { + const unsigned char R = (unsigned char)(LineColor.Red() / 16); + const unsigned char G = (unsigned char)(LineColor.Green() / 16); + const unsigned char B = (unsigned char)(LineColor.Blue() / 16); + + LineColor.Set(R, G, B); + } + + int XPos = m_LeftStartPos + Column * (m_LineLength + m_DigitMargin); + + // Create a pen and draw the lines. + wxPen Pen(LineColor, m_LineWidth, wxSOLID); + Dc.SetPen(Pen); + + if ((Digit & LINE1)) + { + Dc.DrawLine(XPos + m_LineMargin*2, m_LineMargin, + XPos + m_LineLength + m_LineMargin*2, m_LineMargin); + } + + if (Digit & LINE2) + { + Dc.DrawLine(XPos + m_LineLength + m_LineMargin*3, m_LineMargin*2, + XPos + m_LineLength + m_LineMargin*3, m_LineLength + (m_LineMargin*2)); + } + + if (Digit & LINE3) + { + Dc.DrawLine(XPos + m_LineLength + m_LineMargin*3, m_LineLength + (m_LineMargin*4), + XPos + m_LineLength + m_LineMargin*3, m_LineLength*2 + (m_LineMargin*4)); + } + + if (Digit & LINE4) + { + Dc.DrawLine(XPos + m_LineMargin*2, m_LineLength*2 + (m_LineMargin*5), + XPos + m_LineLength + m_LineMargin*2, m_LineLength*2 + (m_LineMargin*5)); + } + + if (Digit & LINE5) + { + Dc.DrawLine(XPos + m_LineMargin, m_LineLength + (m_LineMargin*4), + XPos + m_LineMargin, m_LineLength*2 + (m_LineMargin*4)); + } + + if (Digit & LINE6) + { + Dc.DrawLine(XPos + m_LineMargin, m_LineMargin*2, + XPos + m_LineMargin, m_LineLength + (m_LineMargin*2)); + } + + if (Digit & LINE7) + { + Dc.DrawLine(XPos + m_LineMargin*2, m_LineLength + (m_LineMargin*3), + XPos + m_LineMargin*2 + m_LineLength, m_LineLength + (m_LineMargin*3)); + } + + if (Digit & DECIMALSIGN) + { + Dc.DrawLine(XPos + m_LineLength + m_LineMargin*4, m_LineLength*2 + (m_LineMargin*5), + XPos + m_LineLength + m_LineMargin*4, m_LineLength*2 + (m_LineMargin*5)); + } + + Dc.SetPen(wxNullPen); +} + + +void wxLEDNumberCtrl::RecalcInternals(const wxSize &CurrentSize) +{ + // Dimensions of LED segments + // + // Size of character is based on the HEIGH of the widget, NOT the width. + // Segment height is calculated as follows: + // Each segment is m_LineLength pixels long. + // There is m_LineMargin pixels at the top and bottom of each line segment + // There is m_LineMargin pixels at the top and bottom of each digit + // + // Therefore, the heigth of each character is: + // m_LineMargin : Top digit boarder + // m_LineMargin+m_LineLength+m_LineMargin : Top half of segment + // m_LineMargin+m_LineLength+m_LineMargin : Bottom half of segment + // m_LineMargin : Bottom digit boarder + // ---------------------- + // m_LineMargin*6 + m_LineLength*2 == Total height of digit. + // Therefore, (m_LineMargin*6 + m_LineLength*2) must equal Height + // + // Spacing between characters can then be calculated as follows: + // m_LineMargin : before the digit, + // m_LineMargin+m_LineLength+m_LineMargin : for the digit width + // m_LineMargin : after the digit + // = m_LineMargin*4 + m_LineLength + const int Height = CurrentSize.GetHeight(); + + if ((Height * 0.075) < 1) + m_LineMargin = 1; + else + m_LineMargin = (int)(Height * 0.075); + + if ((Height * 0.275) < 1) + m_LineLength = 1; + else + m_LineLength = (int)(Height * 0.275); + + m_LineWidth = m_LineMargin; + + m_DigitMargin = m_LineMargin * 4; + + // Count the number of characters in the string; '.' characters are not + // included because they do not take up space in the display + int count = 0; + for (unsigned int i = 0; i < m_Value.Len(); i++) + if (m_Value.GetChar(i) != '.') + count++; + const int ValueWidth = (m_LineLength + m_DigitMargin) * count; + const int ClientWidth = CurrentSize.GetWidth(); + + switch (m_Alignment) + { + case wxLED_ALIGN_LEFT : + m_LeftStartPos = m_LineMargin; + break; + case wxLED_ALIGN_RIGHT : + m_LeftStartPos = ClientWidth - ValueWidth - m_LineMargin; + break; + case wxLED_ALIGN_CENTER : + m_LeftStartPos = (ClientWidth - ValueWidth) / 2; + break; + default : + wxFAIL_MSG(wxT("Unknown alignent value for wxLEDNumberCtrl.")); + break; + } +} + + +void wxLEDNumberCtrl::OnSize(wxSizeEvent &Event) +{ + RecalcInternals(Event.GetSize()); + + Event.Skip(); +} diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/makedocs.vc b/wxPython/contrib/gizmos/wxCode/src/gizmos/makedocs.vc new file mode 100644 index 0000000000..94d50692a6 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/makedocs.vc @@ -0,0 +1,107 @@ +# +# File: makefile.vc +WXDIR=$(WXWIN) + +NAME=gizmos +WAITFLAG=/WAIT +DOCSOURCEDIR=$(WXDIR)\contrib\docs\latex\$(NAME) +DOCDIR=$(WXDIR)\docs +THISDIR = $(WXDIR)\contrib\src\$(NAME) +DOCSOURCES=$(DOCSOURCEDIR)\manual.tex \ + $(DOCSOURCEDIR)\classes.tex $(DOCSOURCEDIR)\topics.tex + +alldocs: mkdirs html htmlhelp htb hlp pdfrtf +html: touchmanual $(DOCDIR)\html\$(NAME)\$(NAME).htm +htmlhelp: touchmanual $(DOCDIR)\htmlhelp\$(NAME).chm +htb: $(DOCDIR)\htb\$(NAME).htb +hlp: touchmanual $(DOCDIR)\winhelp\$(NAME).hlp +pdfrtf: $(DOCDIR)\pdf\$(NAME).rtf +ps: $(DOCDIR)\ps\$(NAME).ps + +touchmanual: + touch $(DOCSOURCEDIR)\manual.tex + +$(DOCDIR)\winhelp\$(NAME).hlp: $(DOCSOURCEDIR)\$(NAME).rtf $(DOCSOURCEDIR)\$(NAME).hpj + cd $(DOCSOURCEDIR) + -erase $(NAME).ph + hcw /c /e $(NAME) + move $(NAME).hlp $(DOCDIR)\winhelp\$(NAME).hlp + move $(NAME).cnt $(DOCDIR)\winhelp\$(NAME).cnt + cd $(THISDIR) + +$(DOCSOURCEDIR)\$(NAME).hpj: + echo [OPTIONS] > $(DOCSOURCEDIR)\$(NAME).hpj + echo BMROOT=$(WXDIR)\contrib\docs\latex\$(NAME) >> $(DOCSOURCEDIR)\$(NAME).hpj + echo TITLE=OGL Manual >> $(DOCSOURCEDIR)\$(NAME).hpj + echo CONTENTS=Contents >> $(DOCSOURCEDIR)\$(NAME).hpj + echo COMPRESS=HIGH >> $(DOCSOURCEDIR)\$(NAME).hpj + echo "" >> $(DOCSOURCEDIR)\$(NAME).hpj + echo [FILES] >> $(DOCSOURCEDIR)\$(NAME).hpj + echo $(NAME).rtf >> $(DOCSOURCEDIR)\$(NAME).hpj + echo "" >> $(DOCSOURCEDIR)\$(NAME).hpj + echo [CONFIG] >> $(DOCSOURCEDIR)\$(NAME).hpj + echo CreateButton("Up", "&Up", "JumpId(`$(NAME).hlp', `Contents')") >> $(DOCSOURCEDIR)\$(NAME).hpj + echo BrowseButtons() >> $(DOCSOURCEDIR)\$(NAME).hpj + echo "" >> $(DOCSOURCEDIR)\$(NAME).hpj + echo [MAP] >> $(DOCSOURCEDIR)\$(NAME).hpj + echo "" >> $(DOCSOURCEDIR)\$(NAME).hpj + echo [BITMAPS] >> $(DOCSOURCEDIR)\$(NAME).hpj + +$(DOCSOURCEDIR)\$(NAME).rtf: $(DOCSOURCES) + cd $(DOCSOURCEDIR) + -start $(WAITFLAG) tex2rtf $(DOCSOURCEDIR)\manual.tex $(DOCSOURCEDIR)\$(NAME).rtf -twice -winhelp + cd $(THISDIR) + +$(DOCDIR)\pdf\$(NAME).rtf: $(DOCSOURCES) + cd $(DOCSOURCEDIR) + -copy *.bmp $(DOCDIR)\pdf + -start $(WAITFLAG) tex2rtf $(DOCSOURCEDIR)\manual.tex $(DOCDIR)\pdf\$(NAME).rtf -twice -rtf + cd $(THISDIR) + +$(DOCDIR)\html\$(NAME)\$(NAME).htm: $(DOCSOURCES) + cd $(DOCSOURCEDIR) + -mkdir $(DOCDIR)\html\$(NAME) + copy *.gif $(DOCDIR)\html\$(NAME) + -start $(WAITFLAG) tex2rtf $(DOCSOURCEDIR)\manual.tex $(DOCDIR)\html\$(NAME)\$(NAME) -html -twice + -erase $(DOCDIR)\html\$(NAME)\*.con + -erase *.con + -erase $(DOCDIR)\html\$(NAME)\*.ref + cd $(THISDIR) + +$(DOCDIR)\htmlhelp\$(NAME).chm: $(DOCDIR)\html\$(NAME)\$(NAME).htm $(DOCDIR)\html\$(NAME)\$(NAME).hhp + cd $(DOCDIR)\html\$(NAME) + -hhc $(NAME).hhp + -erase $(DOCDIR)\htmlhelp\$(NAME).chm + move $(NAME).chm $(DOCDIR)\htmlhelp\$(NAME).chm + cd $(THISDIR) + +# An htb file is a zip file containing the .htm, .gif, .hhp, .hhc and .hhk +# files, renamed to htb. +# This can then be used with e.g. helpview. +# Optionally, a cached version of the .hhp file can be generated with hhp2cached. +$(DOCDIR)\htb\$(NAME).htb: $(DOCDIR)\html\$(NAME)\$(NAME).htm + cd $(DOCDIR)\html\$(NAME) + -erase $(NAME).zip $(NAME).htb + zip $(NAME).zip *.htm *.gif *.hhp *.hhc *.hhk + -mkdir $(DOCDIR)\htb + -erase $(DOCDIR)\htb\$(NAME).htb + -erase $(DOCDIR)\htb\$(NAME).htb + move $(NAME).zip $(DOCDIR)\htb\$(NAME).htb + cd $(THISDIR) + +$(DOCSOURCEDIR)\$(NAME).dvi: $(DOCSOURCES) + cd $(DOCSOURCEDIR) + -latex $(NAME) + -latex $(NAME) + -makeindx $(NAME) + -bibtex $(NAME) + -latex $(NAME) + -latex $(NAME) + cd $(THISDIR) + +$(WXDIR)\docs\ps\$(NAME).ps: $(DOCSOURCEDIR)\$(NAME).dvi + cd $(DOCSOURCEDIR) + -dvips32 -o $(NAME).ps $(NAME) + move $(NAME).ps $(WXDIR)\docs\ps\$(NAME).ps + cd $(THISDIR) + diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell.cpp new file mode 100644 index 0000000000..555bc6f659 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell.cpp @@ -0,0 +1,653 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: multicell.cpp +// Purpose: provide two new classes for layout, wxMultiCellSizer and wxMultiCellCanvas +// Author: Jonathan Bayer +// Modified by: +// Created: +// RCS-ID: $Id$ +// Copyright: (c) Jonathan Bayer +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// This was inspired by the gbsizer class written by Alex Andruschak + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/gizmos/multicell.h" + + + + +//--------------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(wxMultiCellSizer, wxSizer); +IMPLEMENT_ABSTRACT_CLASS(wxMultiCellItemHandle, wxObject); + +//--------------------------------------------------------------------------- +// wxMultiCellItemHandle +//--------------------------------------------------------------------------- +/* + *Function Name: wxMultiCellItemHandle :: wxMultiCellItemHandle + * + *Parameters: int row + * int column + * int height + * int width + * wxSize size + * wxResizable Style + * wxSize weight + * int align + * + *Description: This is the constructor for the class. + * + */ + +void wxMultiCellItemHandle :: Initialize( int row, int column, int height, int width, wxSize size, wxResizable Style, wxSize weight, int align) +{ + m_column = column; + m_row = row; + m_width = width; + m_height = height; + + m_style = Style; + m_fixedSize = size; + m_alignment = align; + m_weight = weight; +} +//--------------------------------------------------------------------------- +wxMultiCellItemHandle :: wxMultiCellItemHandle( int row, int column, int height, int width, wxSize size, wxResizable Style, wxSize weight, int align) +{ + Initialize(row, column,height, width, size, Style, weight, align); +} +//--------------------------------------------------------------------------- +wxMultiCellItemHandle :: wxMultiCellItemHandle( int row, int column, wxSize size, wxResizable style, wxSize weight, int align) +{ + Initialize(row, column,1, 1, size, style, weight, align); +} +//--------------------------------------------------------------------------- +wxMultiCellItemHandle :: wxMultiCellItemHandle( int row, int column, wxResizable style, wxSize weight, int align) +{ + Initialize(row, column, 1, 1, wxSize(1, 1), style, weight, align); +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetColumn() const +{ + return m_column; +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetRow() const +{ + return m_row; +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetWidth() const +{ + return m_width; +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetHeight() const +{ + return m_height; +} +//--------------------------------------------------------------------------- +wxResizable wxMultiCellItemHandle :: GetStyle() const +{ + return m_style; +}; +//--------------------------------------------------------------------------- +wxSize wxMultiCellItemHandle :: GetLocalSize() const +{ + return m_fixedSize; +}; +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle :: GetAlignment() const +{ + return m_alignment; +}; +//--------------------------------------------------------------------------- +wxSize wxMultiCellItemHandle :: GetWeight() const +{ + return m_weight; +}; + + + +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// wxMultiCellSizer +//--------------------------------------------------------------------------- + +/* + *Function Name: wxMultiCellSizer::Initialize + * + *Parameters: wxsize Initial size of sizer + * + *Description: This is a common function to initialize all the members of + * this class. It is only called from the constructors + * + */ + +void wxMultiCellSizer::Initialize( wxSize size ) +{ + m_cell_count = size; + m_maxHeight = (int *)malloc((1 + m_cell_count.GetHeight()) * sizeof(int)); + m_maxWidth = (int *)malloc( (1 + m_cell_count.GetWidth()) * sizeof(int)); + m_rowStretch = (int *)malloc( (1 + m_cell_count.GetHeight()) * sizeof(int)); + m_colStretch = (int *)malloc((1 + m_cell_count.GetWidth()) * sizeof(int)); + + m_weights = (wxSize **)malloc((1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth())) * sizeof(wxSize *)); + m_minSizes = (wxSize **)malloc((1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth())) * sizeof(wxSize *)); + for (int x = 0; x < 1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); x++) + { + m_weights[x] = new wxSize(0,0); + m_minSizes[x] = new wxSize(0,0); + } + + m_maxWeights = 1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); + m_defaultCellSize = wxSize(5, 5); + m_win = NULL; + m_pen = wxRED_PEN; +} +//--------------------------------------------------------------------------- +wxMultiCellSizer::wxMultiCellSizer( wxSize & size ) +{ + Initialize(size); +} +//--------------------------------------------------------------------------- +wxMultiCellSizer::wxMultiCellSizer( int rows, int cols) +{ + wxSize size(cols, rows); + Initialize(size); +} +//--------------------------------------------------------------------------- +wxMultiCellSizer::~wxMultiCellSizer() +{ + WX_CLEAR_LIST(wxSizerItemList, m_children); + + free(m_maxHeight); + free(m_maxWidth); + free(m_rowStretch); + free(m_colStretch); + + for (int x = 0; x < 1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); x++) + { + delete m_weights[x]; + delete m_minSizes[x]; + } + free(m_weights); + free(m_minSizes); +} +//--------------------------------------------------------------------------- +bool wxMultiCellSizer::EnableGridLines(wxWindow *win) +{ + m_win = win; + return true; +} +//--------------------------------------------------------------------------- +bool wxMultiCellSizer::SetGridPen(const wxPen *pen) +{ + m_pen = pen; + return true; +} + +//--------------------------------------------------------------------------- +bool wxMultiCellSizer::SetDefaultCellSize(wxSize size) +{ + m_defaultCellSize = size; + return true; +} +//--------------------------------------------------------------------------- +bool wxMultiCellSizer::SetColumnWidth(int column, int colSize, bool expandable) +{ + if (expandable) + { + m_minSizes[column]->SetWidth(-colSize); + } + else + { + m_minSizes[column]->SetWidth(colSize); + } + return true; +} +//--------------------------------------------------------------------------- +bool wxMultiCellSizer::SetRowHeight(int row, int rowSize, bool expandable) +{ + if (expandable) + { + m_minSizes[row]->SetHeight(-rowSize); + } + else + { + m_minSizes[row]->SetHeight(rowSize); + } + return true; +} +//--------------------------------------------------------------------------- +void wxMultiCellSizer::RecalcSizes() +{ + if (m_children.GetCount() == 0) + return; + wxSize size = GetSize(); + wxPoint pos = GetPosition(); + + GetMinimums(); + + // We need to take the unused space and equally give it out to all the rows/columns + // which are stretchable + + int unUsedWidth = size.GetWidth() - Sum(m_maxWidth, m_cell_count.GetWidth()); + int unUsedHeight = size.GetHeight() - Sum(m_maxHeight, m_cell_count.GetHeight()); + int totalWidthWeight = 0; + int totalHeightWeight = 0; + int x; + + for (x = 0; x < wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); x++) + { + if (m_rowStretch[x]) + { + totalHeightWeight += m_weights[x]->GetHeight(); + } + if (x < m_cell_count.GetWidth() && m_colStretch[x]) + { + totalWidthWeight += m_weights[x]->GetWidth(); + } + } + for (x = 0; x < wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); x++) + { + if (x < m_cell_count.GetHeight() && m_rowStretch[x]) + { + m_maxHeight[x] += unUsedHeight * m_weights[x]->GetHeight() / totalHeightWeight; + } + if (x < m_cell_count.GetWidth() && m_colStretch[x]) + { + m_maxWidth[x] += unUsedWidth * m_weights[x]->GetWidth() / totalWidthWeight; + } + } + // We now have everything we need to figure each cell position and size + // The arrays m_maxHeight and m_maxWidth now contain the final widths and height of + // each row and column. + + double cell_width = (double)size.GetWidth() / (double)m_cell_count.GetWidth(); + double cell_height = (double)size.GetHeight() / (double)m_cell_count.GetHeight(); + wxPoint c_point; + wxSize c_size; + + wxSizerItemList::compatibility_iterator current = m_children.GetFirst(); + while (current) + { + wxSizerItem *item = current->GetData(); + + wxMultiCellItemHandle *rect; + if (item != NULL && + (rect = (wxMultiCellItemHandle *)item->GetUserData()) != NULL) + { + c_point.x = pos.x + (int)(rect->GetColumn() * cell_width); + c_point.y = pos.y + (int)(rect->GetRow() * cell_height); + + c_point.x = pos.x + Sum(m_maxWidth, rect->GetColumn()); + c_point.y = pos.y + Sum(m_maxHeight, rect->GetRow()); + + + c_size = rect->GetLocalSize(); + wxSize minSize( item->CalcMin() ); + if (c_size.GetHeight() != wxDefaultCoord || + c_size.GetWidth() != wxDefaultCoord) + { + minSize.SetHeight(wxMax(minSize.GetHeight(), c_size.GetHeight())); + minSize.SetWidth(wxMax(minSize.GetWidth(), c_size.GetWidth())); + } + if (rect->GetStyle() & wxHORIZONTAL_RESIZABLE || + rect->GetWidth() > 1 + || m_minSizes[rect->GetColumn()]->GetWidth() < 0) + { + int w = 0; + for (int x = 0; x < rect->GetWidth(); x++) + { + w += m_maxWidth[rect->GetColumn() + x]; + } + c_size.SetWidth(w); + } + else + { + c_size.SetWidth(minSize.GetWidth() ); + } + if (rect->GetStyle() & wxVERTICAL_RESIZABLE || + rect->GetHeight() > 1 || + m_minSizes[rect->GetRow()]->GetHeight() < 0) + { + int h = 0; + for (int x = 0; x < rect->GetHeight(); x++) + { + h += m_maxHeight[rect->GetRow() + x]; + } + c_size.SetHeight(h); + } + else + { + c_size.SetHeight(minSize.GetHeight()); + } + int extraHeight = (m_maxHeight[rect->GetRow()] - c_size.GetHeight()); + int extraWidth = (m_maxWidth[rect->GetColumn()] - c_size.GetWidth()); + + if (rect->GetWidth() == 1 && rect->GetAlignment() & wxALIGN_CENTER_HORIZONTAL) + { + c_point.x += extraWidth / 2; + } + if (rect->GetWidth() == 1 && rect->GetAlignment() & wxALIGN_RIGHT) + { + c_point.x += extraWidth; + } + if (rect->GetHeight() == 1 && rect->GetAlignment() & wxALIGN_CENTER_VERTICAL) + { + c_point.y += extraHeight / 2; + } + if (rect->GetHeight() == 1 && rect->GetAlignment() & wxALIGN_BOTTOM) + { + c_point.y += extraHeight; + } + item->SetDimension(c_point, c_size); + } + current = current->GetNext(); + } +} +//--------------------------------------------------------------------------- +wxSize wxMultiCellSizer::CalcMin() +{ + if (m_children.GetCount() == 0) + return wxSize(10,10); + + GetMinimums(); + int m_minWidth = Sum(m_maxWidth, m_cell_count.GetWidth()); + int m_minHeight = Sum(m_maxHeight, m_cell_count.GetHeight()); + return wxSize( m_minWidth, m_minHeight ); +} +//--------------------------------------------------------------------------- +void wxMultiCellSizer :: GetMinimums() +{ + // We first initial all the arrays EXCEPT for the m_minsizes array. + + memset(m_maxHeight, 0, sizeof(int) * m_cell_count.GetHeight()); + memset(m_maxWidth, 0, sizeof(int) * m_cell_count.GetWidth()); + memset(m_rowStretch, 0, sizeof(int) * m_cell_count.GetHeight()); + memset(m_colStretch, 0, sizeof(int) * m_cell_count.GetWidth()); + for (int x = 0; x < 1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); x++) + { + m_weights[x]->SetHeight(0); + m_weights[x]->SetWidth(0); + } + + wxSizerItemList::compatibility_iterator node = m_children.GetFirst(); + while (node) + { + wxSizerItem *item = node->GetData(); + wxMultiCellItemHandle *rect; + if (item != NULL && + (rect = (wxMultiCellItemHandle *)item->GetUserData()) != NULL) + { + int row = rect->GetRow(); + int col = rect->GetColumn(); + + // First make sure that the control knows about the max rows and columns + + int changed = false; + if (row + 1 > m_cell_count.GetHeight()) + { + changed++; + m_maxHeight = (int *)realloc(m_maxHeight, (1 + row) * sizeof(int)); + m_rowStretch = (int *)realloc(m_rowStretch, (1 + row) * sizeof(int)); + for (int x = m_cell_count.GetHeight(); x < row + 1; x++) + { + m_maxHeight[x - 1] = 0; + m_rowStretch[x - 1] = 0; + } + m_cell_count.SetHeight(row + 1); + } + if (col + 1 > m_cell_count.GetWidth()) + { + changed++; + m_maxWidth = (int *)realloc(m_maxWidth, (1 + col) * sizeof(int)); + m_colStretch = (int *)realloc(m_colStretch, ( 1 + col) * sizeof(int)); + for (int x = m_cell_count.GetWidth(); x < col + 1; x++) + { + m_maxWidth[x - 1] = 0; + m_colStretch[x - 1] = 0; + } + m_cell_count.SetWidth(col + 1); + } + if (changed) + { + m_weights = (wxSize **)realloc(m_weights, (1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth())) * sizeof(wxSize *)); + m_minSizes = (wxSize **)realloc(m_minSizes, (1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth())) * sizeof(wxSize *)); + for (int x = m_maxWeights; x < 1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); x++) + { + m_weights[x - 1] = new wxSize(0,0); + m_minSizes[x - 1] = new wxSize(0,0); + } + m_maxWeights = 1 + wxMax(m_cell_count.GetHeight(), m_cell_count.GetWidth()); + } + + // Sum the m_weights for each row/column, but only if they are resizable + + wxSize minSize( item->CalcMin() ); + wxSize c_size = rect->GetLocalSize(); + if (c_size.GetHeight() != wxDefaultCoord || + c_size.GetWidth() != wxDefaultCoord) + { + minSize.SetHeight(wxMax(minSize.GetHeight(), c_size.GetHeight())); + minSize.SetWidth(wxMax(minSize.GetWidth(), c_size.GetWidth())); + } + + // For each row, calculate the max height for those fields which are not + // resizable in the vertical pane + + if (!(rect->GetStyle() & wxVERTICAL_RESIZABLE || m_minSizes[row]->GetHeight() < 0)) + { + m_maxHeight[row] = wxMax(m_maxHeight[row], minSize.GetHeight() / rect->GetHeight()); + } + else + { + m_rowStretch[row] = 1; + if (m_minSizes[row]->GetHeight()) + { + m_maxHeight[row] = abs(m_minSizes[row]->GetHeight()); + } + else + { + m_maxHeight[row] = wxMax(m_maxHeight[row], m_defaultCellSize.GetHeight()); + } + m_weights[row]->SetHeight(wxMax(m_weights[row]->GetHeight(), rect->GetWeight().GetHeight())); + } + + // For each column, calculate the max width for those fields which are not + // resizable in the horizontal pane + + if (!(rect->GetStyle() & wxHORIZONTAL_RESIZABLE || m_minSizes[col]->GetWidth() < 0)) + { + if (m_minSizes[col]->GetWidth()) + { + m_maxWidth[col] = abs(m_minSizes[col]->GetWidth()); + } + else + { + m_maxWidth[col] = wxMax(m_maxWidth[col], minSize.GetWidth() / rect->GetWidth()); + } + } + else + { + m_colStretch[col] = 1; + m_maxWidth[col] = wxMax(m_maxWidth[col], m_defaultCellSize.GetWidth()); + m_weights[col]->SetWidth(wxMax(m_weights[col]->GetWidth(), rect->GetWeight().GetWidth())); + } + node = node->GetNext(); + } + } +} // wxMultiCellSizer :: GetMinimums +//--------------------------------------------------------------------------- +/* + *Function Name: wxMultiCellSizer :: Sum + * + *Parameters: int* pointer to array of ints + * int Number of cells to sum up + * + *Description: This member function sums up all the elements of the array which + * preceed the specified cell. + * + *Returns: int Sum + * + */ + +/* static */ int wxMultiCellSizer :: Sum(int *array, int x) +{ + int sum = 0; + while (x--) + { + sum += array[x]; + } + return sum; +} +//--------------------------------------------------------------------------- +/* + *Function Name: wxMultiCellSizer :: DrawGridLines + * + *Parameters: wxDC Device context + * + *Description: This function draws the grid lines in the specified device context. + * + */ + +void wxMultiCellSizer :: DrawGridLines(wxDC& dc) +{ + RecalcSizes(); + int maxW = Sum(m_maxWidth, m_cell_count.GetWidth()); + int maxH = Sum(m_maxHeight, m_cell_count.GetHeight()); + int x; + + // Draw the columns + dc.SetPen(* m_pen); + for (x = 1; x < m_cell_count.GetWidth(); x++) + { + int colPos = Sum(m_maxWidth, x) ; + dc.DrawLine(colPos, 0, colPos, maxH); + } + + // Draw the rows + for (x = 1; x < m_cell_count.GetHeight(); x++) + { + int rowPos = Sum(m_maxHeight, x); + dc.DrawLine(0, rowPos, maxW, rowPos); + } +} +//--------------------------------------------------------------------------- +// Define the repainting behaviour +/* + *Function Name: wxMultiCellSizer::OnPaint + * + *Parameters: wxDC Device context + * + *Description: This function calls the DrawGridLines() member if a window + * has been previously specified. This functions MUST be called + * from an OnPaint member belonging to the window which the sizer + * is attached to. + * + */ + +void wxMultiCellSizer::OnPaint(wxDC& dc ) +{ + if (m_win) + { + DrawGridLines(dc); + } +} + + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- + + + + +#define CELL_LOC(row, col) ((row) * m_maxCols + col) + +//--------------------------------------------------------------------------- +// wxCell +//--------------------------------------------------------------------------- +/* + *Function Name: wxCell : wxLayoutConstraints + * + *Description: This class is used by wxMultiCellCanvas for internal storage + * + */ + +class wxCell : public wxLayoutConstraints +{ +public: + wxCell(wxWindow *win) + { + m_window = win; + }; + + wxWindow *m_window; +}; + + + +//--------------------------------------------------------------------------- +// wxMultiCellCanvas +//--------------------------------------------------------------------------- +wxMultiCellCanvas :: wxMultiCellCanvas(wxWindow *par, int numRows, int numCols) + : wxFlexGridSizer(numRows, numCols, 0, 0) +{ + m_cells = (wxCell **)calloc(numRows * numCols, sizeof(wxCell *)); + + m_parent = par; + m_maxRows = numRows; + m_maxCols = numCols; + m_minCellSize = wxSize(5, 5); +} +//--------------------------------------------------------------------------- +void wxMultiCellCanvas :: Add(wxWindow *win, unsigned int row, unsigned int col) +{ + // thanks to unsigned data row and col are always >= 0 + wxASSERT_MSG( /* row >= 0 && */ row < m_maxRows, + wxString::Format(_T("Row %d out of bounds (0..%d)"), row, m_maxRows) ); + wxASSERT_MSG( /* col >= 0 && */ col < m_maxCols, + wxString::Format(_T("Column %d out of bounds (0..%d)"), col, m_maxCols) ); + + wxASSERT_MSG(m_cells[CELL_LOC(row, col)] == NULL, wxT("Cell already occupied")); + + wxCell *newCell = new wxCell(win); + m_cells[CELL_LOC(row,col)] = newCell; +} +//--------------------------------------------------------------------------- +void wxMultiCellCanvas :: CalculateConstraints() +{ + unsigned int row, col; + for (row = 0; row < m_maxRows; row++) + { + for (col = 0; col < m_maxCols; col++) + { + if (!m_cells[CELL_LOC(row, col)]) + { + // Create an empty static text field as a placeholder + m_cells[CELL_LOC(row, col)] = new wxCell(new wxStaticText(m_parent, wxID_ANY, wxEmptyString)); + } + wxFlexGridSizer::Add(m_cells[CELL_LOC(row, col)]->m_window); + } + } +} + +/*** End of File ***/ diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell.txt b/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell.txt new file mode 100644 index 0000000000..5de8cb27a2 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell.txt @@ -0,0 +1,130 @@ +These two classes make it easier to lay objects out on a screen. The +first class is the wxMultiCellCanvas, which uses the wxFlexGridSizer +control, so it is subject to the same limitations of that control. Among +them is the fact that if the window is resized smaller than the control, +then some of the objects will be obscured by the window edge. + +The second class is the wxMultiCellSizer, which is significantly more +powerful than the wxMultiCell Canvas. This control supports resizing of +objects on the fly, objects spanning cells, etc. + +Use the wxMultiCellCanvas when you have a simple layout which won't resize +and doesn't have any unusual requirements. Use the wxMultiCellSizer when +your needs are greater + + +wxMultiCellCanvas +================= + +The wxMultiCellCanvas class allows you to add objects to a wxFlexGridSizer +by specifying a row and a column location. When all objects have been +added, you need to call a member function CalculateConstraints(), which +will insert the objects into the wxFlexGridSizer. If there are empty +cells the canvas will insert empty wxStaticText objects as placeholders. + +Upon creation of the canvas the size of the canvas needs to be specified. +Attempting to insert a cell outside those limits will cause an assertion +error. + +When adding cells, the cell locations are specified as a row,column +location, both being zero-based. 0,0 is the upper left corner of the +canvas. + + +wxMultiCellSizer +================ + +The wxMultiCellSizer class manages a collection of child windows in a way +similar to that of data stored in a spreadsheet. A multicell canvas is a +two-dimensional array of cells with an origin of (0,0) in the upper-left +corner. Windows are added to a multicell sizer by first creating a +wxMultiCellItemHandle object which specifies a starting cell and, +optionally, a number of contiguous columns, rows, or a combination +thereof, and then adding it to the sizer. + +This class bases the initial cell sizes on the minimum sizes returned by +each child window of the sizer. You can override the minimum sizes +provided by the wxWindows Class Library by doing either of the following: + + o Specifying the size when creating the wxMultiCellItemHandle object + o Creating a derived class and implementing a CalcMin function + +The wxMultiCellItemHandle must be passed the row and column of the item, +at a minimum. Optionally, more information can be passed: + + int row Row position, zero based + int column Column position, zero based + int height Number of rows this cell will occupy, default is 1 + int width Number of columns this cell will occupy, default is 1 + + Note that if the height or width is greater than one that + dimension is assumed to be resizable because it is spanning + multiple cells. + + wxSize minSize Minimum size of the object. + wxResizable Style Is this object resizable, and if so, how. Allowable styles are: + wxNOT_RESIZABLE + wxHORIZENTAL_RESIZABLE + wxVERTICAL_RESIZABLE + wxRESIZABLE + wxSize weight If this is a resizable object, the weight applied to the specific dimension. + This is useful if you have several resizable rows and/or columns, and you want + one to get more of the available space than the others. + int align This is a wxAlignment value, it is an integer so you can 'or multiple + values together. The acceptable values are: + wxALIGN_NOT + wxALIGN_CENTER_HORIZONTAL + wxALIGN_CENTRE_HORIZONTAL + wxALIGN_LEFT + wxALIGN_TOP + wxALIGN_RIGHT + wxALIGN_BOTTOM + wxALIGN_CENTER_VERTICAL + wxALIGN_CENTRE_VERTICAL + wxALIGN_CENTER + wxALIGN_CENTRE + Note that some combinations of these make no sense, for example wxALIGN_LEFT | wxALIGN_RIGHT. + See the definition of wxAlignment for more information + + +Other functions are: + +void RecalcSizes() Should not be called by the user, needed by the wxSizer class +wxSize CalcMin() Should not be called by the user, needed by the wxSizer class +bool SetDefaultCellSize Set the default cell size of an empty cell +bool SetColumnWidth Set the width of a column, optionally specifying it as resizable +bool SetRowHeight Set the height of a row, optionally specifying it as resizable + +Sometimes it can be very confusing to determine the relationship between rows, columns, and +which ones are resizable or not. Three functions are supplied to make this easier: + +bool EnableGridLines(wxWindow *win); Call this to either enable or disable the grid lines. + Pass the window the sizer is on, or NULL to disable. + Currently the window is not used, but it may be in the + future. +bool SetGridPen(wxPen *pen); Set the pen color, the default pen color is red +void OnPaint(wxDC& dc); Call this from an OnPaint function associated with the + window the sizer is attached to. See the example program + mtest.cpp for specific details on how to do this. + + +Files Description +===== =========== +docs.txt This file + +// wxMultiCellCanvas and wxMultiCellSizer +makefile Makefile for the MingW32 compiler +multicell.cpp Class source code file +multicell.h Class header file + +//Sample +mtest.cpp Example program, demonstrates both classes +mtest.rc +mtest.gif +makefile + +Acknowledgments +=============== +This was inspired by the gbsizer class written by Alex Andruschak, and the IMultiCellCanvas +class in the IBM Class Libraries in the VisualeAge C++ compilers. + diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell_todo.txt b/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell_todo.txt new file mode 100644 index 0000000000..8e07fdc016 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/multicell_todo.txt @@ -0,0 +1,2 @@ +2. Documentation + diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/splittree.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/splittree.cpp new file mode 100644 index 0000000000..0eaed896c2 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/splittree.cpp @@ -0,0 +1,745 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: splittree.cpp +// Purpose: Classes to achieve a remotely-scrolled tree in a splitter +// window that can be scrolled by a scrolled window higher in the +// hierarchy +// Author: Julian Smart +// Modified by: +// Created: 8/7/2000 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +// for all others, include the necessary headers (this file is usually all you +// need because it includes almost all "standard" wxWidgets headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#ifdef __WXMSW__ +#include +#include "wx/msw/winundef.h" +#endif + +#include "wx/gizmos/splittree.h" +#include + +/* + * wxRemotelyScrolledTreeCtrl + */ + +#if USE_GENERIC_TREECTRL +IMPLEMENT_CLASS(wxRemotelyScrolledTreeCtrl, wxGenericTreeCtrl) +#else +IMPLEMENT_CLASS(wxRemotelyScrolledTreeCtrl, wxTreeCtrl) +#endif + +#if USE_GENERIC_TREECTRL +BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxGenericTreeCtrl) +#else +BEGIN_EVENT_TABLE(wxRemotelyScrolledTreeCtrl, wxTreeCtrl) +#endif + EVT_SIZE(wxRemotelyScrolledTreeCtrl::OnSize) + EVT_PAINT(wxRemotelyScrolledTreeCtrl::OnPaint) + EVT_TREE_ITEM_EXPANDED(wxID_ANY, wxRemotelyScrolledTreeCtrl::OnExpand) + EVT_TREE_ITEM_COLLAPSED(wxID_ANY, wxRemotelyScrolledTreeCtrl::OnExpand) + EVT_SCROLLWIN(wxRemotelyScrolledTreeCtrl::OnScroll) +END_EVENT_TABLE() + +wxRemotelyScrolledTreeCtrl::wxRemotelyScrolledTreeCtrl( + wxWindow* parent, wxWindowID id, const wxPoint& pt, + const wxSize& sz, long style) + : wxTreeCtrl(parent, id, pt, sz, style & ~wxTR_ROW_LINES) +{ + m_companionWindow = NULL; + + // We draw the row lines ourself so they match what's done + // by the companion window. That is why the flag is turned + // off above, so wxGenericTreeCtrl doesn't draw them in a + // different colour. + m_drawRowLines = (style & wxTR_ROW_LINES) != 0; +} + +wxRemotelyScrolledTreeCtrl::~wxRemotelyScrolledTreeCtrl() +{ +} + +void wxRemotelyScrolledTreeCtrl::HideVScrollbar() +{ +#if defined(__WXMSW__) +#if USE_GENERIC_TREECTRL + if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) +#endif + { + ::ShowScrollBar((HWND) GetHWND(), SB_VERT, false); + } +#if USE_GENERIC_TREECTRL + else + { + // Implicit in overriding SetScrollbars + } +#endif +#endif +} + +// Number of pixels per user unit (0 or -1 for no scrollbar) +// Length of virtual canvas in user units +// Length of page in user units +void wxRemotelyScrolledTreeCtrl::SetScrollbars( + #if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + int pixelsPerUnitX, int pixelsPerUnitY, + int noUnitsX, int noUnitsY, + int xPos, int yPos, + bool noRefresh + #else + int WXUNUSED(pixelsPerUnitX), int WXUNUSED(pixelsPerUnitY), + int WXUNUSED(noUnitsX), int WXUNUSED(noUnitsY), + int WXUNUSED(xPos), int WXUNUSED(yPos), + bool WXUNUSED(noRefresh) + #endif + ) +{ +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; + win->wxGenericTreeCtrl::SetScrollbars(pixelsPerUnitX, pixelsPerUnitY, noUnitsX, 0, xPos, 0, /* noRefresh */ true); + + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + if (scrolledWindow) + { + scrolledWindow->SetScrollbars(0, pixelsPerUnitY, 0, noUnitsY, 0, yPos, noRefresh); + } + } +#endif +} + +// In case we're using the generic tree control. +int wxRemotelyScrolledTreeCtrl::GetScrollPos( + #if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + int orient + #else + int WXUNUSED(orient) + #endif + ) const +{ + +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + // this condition fixes extsitence of warning but + wxScrolledWindow* scrolledWindow = + // but GetScrolledWindow is still executed in case internally does something +#endif + GetScrolledWindow(); + +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; + + if (orient == wxHORIZONTAL) + return win->wxGenericTreeCtrl::GetScrollPos(orient); + else + { + return scrolledWindow->GetScrollPos(orient); + } + } +#endif + return 0; +} + + +// In case we're using the generic tree control. +// Get the view start +void wxRemotelyScrolledTreeCtrl::GetViewStart(int *x, int *y) const +{ + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + + wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; + int x1, y1, x2, y2; + win->wxGenericTreeCtrl::GetViewStart(& x1, & y1); + * x = x1; * y = y1; + if (!scrolledWindow) + return; + + scrolledWindow->GetViewStart(& x2, & y2); + * y = y2; + } + else +#endif + { + // x is wrong since the horizontal scrollbar is controlled by the + // tree control, but we probably don't need it. + scrolledWindow->GetViewStart(x, y); + } +} + +// In case we're using the generic tree control. +void wxRemotelyScrolledTreeCtrl::PrepareDC( + #if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + wxDC& dc + #else + wxDC& WXUNUSED(dc) + #endif + ) +{ +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + + wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; + + int startX, startY; + GetViewStart(& startX, & startY); + + int xppu1, yppu1, xppu2, yppu2; + win->wxGenericTreeCtrl::GetScrollPixelsPerUnit(& xppu1, & yppu1); + scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2); + + dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 ); + // dc.SetUserScale( win->GetScaleX(), win->GetScaleY() ); + } +#endif +} + +// Scroll to the given line (in scroll units where each unit is +// the height of an item) +void wxRemotelyScrolledTreeCtrl::ScrollToLine(int WXUNUSED(posHoriz), int posVert) +{ +#ifdef __WXMSW__ +#if USE_GENERIC_TREECTRL + if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) +#endif // USE_GENERIC_TREECTRL + { + UINT sbCode = SB_THUMBPOSITION; + HWND vertScrollBar = 0; + MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXLPARAM) vertScrollBar); + } +#if USE_GENERIC_TREECTRL + else +#endif // USE_GENERIC_TREECTRL +#endif // __WXMSW__ +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + { + wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; + win->Refresh(); + /* Doesn't work yet because scrolling is ignored by Scroll + int xppu, yppu; + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + if (scrolledWindow) + { + scrolledWindow->GetScrollPixelsPerUnit(& xppu, & yppu); + win->Scroll(-1, posVert*yppu); + } + */ + } +#endif // USE_GENERIC_TREECTRL || !defined(__WXMSW__) + wxUnusedVar(posVert); +} + +void wxRemotelyScrolledTreeCtrl::OnSize(wxSizeEvent& event) +{ + HideVScrollbar(); + AdjustRemoteScrollbars(); + event.Skip(); +} + +void wxRemotelyScrolledTreeCtrl::OnExpand(wxTreeEvent& event) +{ + AdjustRemoteScrollbars(); + event.Skip(); + + // If we don't have this, we get some bits of lines still remaining + if (event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_COLLAPSED) + Refresh(); + + // Pass on the event + if (m_companionWindow) + m_companionWindow->GetEventHandler()->ProcessEvent(event); +} + +void wxRemotelyScrolledTreeCtrl::OnPaint(wxPaintEvent& event) +{ + wxPaintDC dc(this); + + wxTreeCtrl::OnPaint(event); + + if (! m_drawRowLines) + return; + + // Reset the device origin since it may have been set + dc.SetDeviceOrigin(0, 0); + + wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + wxSize clientSize = GetClientSize(); + wxRect itemRect; + wxTreeItemId h, lastH; + for (h=GetFirstVisibleItem(); + h.IsOk(); + h=GetNextVisible(h)) + { + if (GetBoundingRect(h, itemRect)) + { + int cy = itemRect.GetTop(); + dc.DrawLine(0, cy, clientSize.x, cy); + lastH = h; + } + if (! IsVisible(h)) + break; + } + if (lastH.IsOk() && GetBoundingRect(lastH, itemRect)) + { + int cy = itemRect.GetBottom(); + dc.DrawLine(0, cy, clientSize.x, cy); + } +} + + +// Adjust the containing wxScrolledWindow's scrollbars appropriately +void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars() +{ +#if USE_GENERIC_TREECTRL || !defined(__WXMSW__) + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + // This is for the generic tree control. + // It calls SetScrollbars which has been overridden + // to adjust the parent scrolled window vertical + // scrollbar. + ((wxGenericTreeCtrl*) this)->AdjustMyScrollbars(); + return; + } + else +#endif + { + // This is for the wxMSW tree control + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + if (scrolledWindow) + { + wxRect itemRect; + if (GetBoundingRect(GetFirstVisibleItem(), itemRect)) + { + // Actually, the real height seems to be 1 less than reported + // (e.g. 16 instead of 16) + int itemHeight = itemRect.GetHeight() - 1; + + int w, h; + GetClientSize(&w, &h); + + wxRect rect(0, 0, 0, 0); + CalcTreeSize(rect); + + double f = ((double) (rect.GetHeight()) / (double) itemHeight) ; + int treeViewHeight = (int) ceil(f); + + int scrollPixelsPerLine = itemHeight; + int scrollPos = - (itemRect.y / itemHeight); + + scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos); + + // Ensure that when a scrollbar becomes hidden or visible, + // the contained window sizes are right. + // Problem: this is called too early (?) + wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId()); + scrolledWindow->GetEventHandler()->ProcessEvent(event); + } + } + } +} + + +// Calculate the area that contains both rectangles +static wxRect CombineRectangles(const wxRect& rect1, const wxRect& rect2) +{ + wxRect rect; + + int right1 = rect1.GetRight(); + int bottom1 = rect1.GetBottom(); + int right2 = rect2.GetRight(); + int bottom2 = rect2.GetBottom(); + + wxPoint topLeft = wxPoint(wxMin(rect1.x, rect2.x), wxMin(rect1.y, rect2.y)); + wxPoint bottomRight = wxPoint(wxMax(right1, right2), wxMax(bottom1, bottom2)); + + rect.x = topLeft.x; rect.y = topLeft.y; + rect.SetRight(bottomRight.x); + rect.SetBottom(bottomRight.y); + + return rect; +} + + +// Calculate the tree overall size so we can set the scrollbar +// correctly +void wxRemotelyScrolledTreeCtrl::CalcTreeSize(wxRect& rect) +{ + CalcTreeSize(GetRootItem(), rect); +} + +void wxRemotelyScrolledTreeCtrl::CalcTreeSize(const wxTreeItemId& id, wxRect& rect) +{ + // More efficient implementation would be to find the last item (but how?) + // Q: is the bounding rect relative to the top of the virtual tree workspace + // or the top of the window? How would we convert? + wxRect itemSize; + if (GetBoundingRect(id, itemSize)) + { + rect = CombineRectangles(rect, itemSize); + } + + wxTreeItemIdValue cookie; + wxTreeItemId childId = GetFirstChild(id, cookie); + while (childId) + { + CalcTreeSize(childId, rect); + childId = GetNextChild(childId, cookie); + } +} + +// Find the scrolled window that contains this control +wxScrolledWindow* wxRemotelyScrolledTreeCtrl::GetScrolledWindow() const +{ + wxWindow* parent = wxWindow::GetParent(); + while (parent) + { + if (parent->IsKindOf(CLASSINFO(wxScrolledWindow))) + return (wxScrolledWindow*) parent; + parent = parent->GetParent(); + } + return NULL; +} + +void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event) +{ + int orient = event.GetOrientation(); + if (orient == wxHORIZONTAL) + { + event.Skip(); + return; + } + wxScrolledWindow* scrollWin = GetScrolledWindow(); + if (!scrollWin) + return; + + int x, y; + scrollWin->GetViewStart(& x, & y); + + ScrollToLine(-1, y); +} + +/* + * wxTreeCompanionWindow + * + * A window displaying values associated with tree control items. + */ + +IMPLEMENT_CLASS(wxTreeCompanionWindow, wxWindow) + +BEGIN_EVENT_TABLE(wxTreeCompanionWindow, wxWindow) + EVT_PAINT(wxTreeCompanionWindow::OnPaint) + EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll) + EVT_TREE_ITEM_EXPANDED(-1, wxTreeCompanionWindow::OnExpand) + EVT_TREE_ITEM_COLLAPSED(-1, wxTreeCompanionWindow::OnExpand) +END_EVENT_TABLE() + +wxTreeCompanionWindow::wxTreeCompanionWindow(wxWindow* parent, wxWindowID id, + const wxPoint& pos, + const wxSize& sz, + long style): + wxWindow(parent, id, pos, sz, style) +{ + m_treeCtrl = NULL; +} + +void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) +{ + // TEST CODE +#if 1 + if (m_treeCtrl) + { + wxString text = m_treeCtrl->GetItemText(id); + dc.SetTextForeground(* wxBLACK); + dc.SetBackgroundMode(wxTRANSPARENT); + + int textW, textH; + dc.GetTextExtent(text, & textW, & textH); + + int x = 5; + int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2); + + dc.DrawText(text, x, y); + } +#endif +} + +void wxTreeCompanionWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) +{ + wxPaintDC dc(this); + + if (!m_treeCtrl) + return; + + wxPen pen(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + wxFont font(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); + dc.SetFont(font); + + wxSize clientSize = GetClientSize(); + wxRect itemRect; + wxTreeItemId h, lastH; + for (h=m_treeCtrl->GetFirstVisibleItem(); + h.IsOk(); + h=m_treeCtrl->GetNextVisible(h)) + { + if (m_treeCtrl->GetBoundingRect(h, itemRect)) + { + int cy = itemRect.GetTop(); + wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight()); + + lastH = h; + + // Draw the actual item + DrawItem(dc, h, drawItemRect); + dc.DrawLine(0, cy, clientSize.x, cy); + } + if (! m_treeCtrl->IsVisible(h)) + break; + } + if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect)) + { + int cy = itemRect.GetBottom(); + dc.DrawLine(0, cy, clientSize.x, cy); + } +} + +void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event) +{ + int orient = event.GetOrientation(); + if (orient == wxHORIZONTAL) + { + event.Skip(); + return; + } + if (!m_treeCtrl) + return; + + // TODO: scroll the window physically instead of just refreshing. + Refresh(true); +} + +void wxTreeCompanionWindow::OnExpand(wxTreeEvent& WXUNUSED(event)) +{ + // TODO: something more optimized than simply refresh the whole + // window when the tree is expanded/collapsed. Tricky. + Refresh(); +} + +/* + * wxThinSplitterWindow + */ + +IMPLEMENT_CLASS(wxThinSplitterWindow, wxSplitterWindow) + +BEGIN_EVENT_TABLE(wxThinSplitterWindow, wxSplitterWindow) + EVT_SIZE(wxThinSplitterWindow::OnSize) +END_EVENT_TABLE() + +wxThinSplitterWindow::wxThinSplitterWindow(wxWindow* parent, wxWindowID id, + const wxPoint& pos, + const wxSize& sz, + long style): + wxSplitterWindow(parent, id, pos, sz, style) +{ + wxColour faceColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)); + m_facePen = new wxPen(faceColour, 1, wxSOLID); + m_faceBrush = new wxBrush(faceColour, wxSOLID); +} + +wxThinSplitterWindow::~wxThinSplitterWindow() +{ + delete m_facePen; + delete m_faceBrush; +} + + +void wxThinSplitterWindow::SizeWindows() +{ + // The client size may have changed inbetween + // the sizing of the first window and the sizing of + // the second. So repeat SizeWindows. + wxSplitterWindow::SizeWindows(); + wxSplitterWindow::SizeWindows(); +} + +// Tests for x, y over sash +bool wxThinSplitterWindow::SashHitTest(int x, int y, int WXUNUSED(tolerance)) +{ + return wxSplitterWindow::SashHitTest(x, y, 4); +} + +void wxThinSplitterWindow::DrawSash(wxDC& dc) +{ + if ( m_sashPosition == 0 || !m_windowTwo) + return; + if (GetWindowStyle() & wxSP_NOSASH) + return; + + int w, h; + GetClientSize(&w, &h); + + if ( m_splitMode == wxSPLIT_VERTICAL ) + { + dc.SetPen(* m_facePen); + dc.SetBrush(* m_faceBrush); + int h1 = h-1; + int y1 = 0; + if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER ) + h1 += 1; // Not sure why this is necessary... + if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER) + { + y1 = 2; h1 -= 3; + } + dc.DrawRectangle(m_sashPosition, y1, GetSashSize(), h1); + } + else + { + dc.SetPen(* m_facePen); + dc.SetBrush(* m_faceBrush); + int w1 = w-1; + int x1 = 0; + if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER ) + w1 ++; + if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER) + { + x1 = 2; w1 -= 3; + } + dc.DrawRectangle(x1, m_sashPosition, w1, GetSashSize()); + } + + dc.SetPen(wxNullPen); + dc.SetBrush(wxNullBrush); +} + +void wxThinSplitterWindow::OnSize(wxSizeEvent& event) +{ + wxSplitterWindow::OnSize(event); +} + +/* + * wxSplitterScrolledWindow + */ + +IMPLEMENT_CLASS(wxSplitterScrolledWindow, wxScrolledWindow) + +BEGIN_EVENT_TABLE(wxSplitterScrolledWindow, wxScrolledWindow) + EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll) + EVT_SIZE(wxSplitterScrolledWindow::OnSize) +END_EVENT_TABLE() + +wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id, + const wxPoint& pos, + const wxSize& sz, + long style): + wxScrolledWindow(parent, id, pos, sz, style) +{ +} + +void wxSplitterScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event)) +{ + wxSize sz = GetClientSize(); + if (GetChildren().GetFirst()) + { + ((wxWindow*) GetChildren().GetFirst()->GetData())->SetSize(0, 0, sz.x, sz.y); + } +} + +void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event) +{ + // Ensure that events being propagated back up the window hierarchy + // don't cause an infinite loop + static bool inOnScroll = false; + if (inOnScroll) + { + event.Skip(); + return; + } + inOnScroll = true; + + int orient = event.GetOrientation(); + + int nScrollInc = CalcScrollInc(event); + if (nScrollInc == 0) + { + inOnScroll = false; + return; + } + + if (orient == wxHORIZONTAL) + { + inOnScroll = false; + event.Skip(); + return; +#if 0 + int newPos = m_xScrollPosition + nScrollInc; + SetScrollPos(wxHORIZONTAL, newPos, true ); +#endif + } + else + { + int newPos = m_yScrollPosition + nScrollInc; + SetScrollPos(wxVERTICAL, newPos, true ); + } + + if (orient == wxHORIZONTAL) + { + m_xScrollPosition += nScrollInc; + } + else + { + m_yScrollPosition += nScrollInc; + } + + // Find targets in splitter window and send the event to them + wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); + while (node) + { + wxWindow* child = (wxWindow*) node->GetData(); + if (child->IsKindOf(CLASSINFO(wxSplitterWindow))) + { + wxSplitterWindow* splitter = (wxSplitterWindow*) child; + if (splitter->GetWindow1()) + splitter->GetWindow1()->ProcessEvent(event); + if (splitter->GetWindow2()) + splitter->GetWindow2()->ProcessEvent(event); + break; + } + node = node->GetNext(); + } + + m_targetWindow->Update() ; + + inOnScroll = false; +} diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/statpict.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/statpict.cpp new file mode 100644 index 0000000000..b8c1cdf99d --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/statpict.cpp @@ -0,0 +1,148 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: statpict.cpp +// Purpose: wxStaticPicture +// Author: Wade Brainerd (wadeb@wadeb.com) +// Modified by: +// Created: 2003-05-01 +// RCS-ID: +// Copyright: (c) Wade Brainerd +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" +#include "wx/defs.h" + +#include "wx/gizmos/statpict.h" +#include "wx/dcclient.h" + +IMPLEMENT_DYNAMIC_CLASS(wxStaticPicture, wxControl) +WXDLLIMPEXP_GIZMOS const wxChar * wxStaticPictureNameStr = wxT("staticPicture"); + +/* + * wxStaticPicture + */ + +BEGIN_EVENT_TABLE(wxStaticPicture, wxControl) + EVT_PAINT(wxStaticPicture::OnPaint) +END_EVENT_TABLE() + +bool wxStaticPicture::Create(wxWindow *parent, wxWindowID id, + const wxBitmap& bitmap, + const wxPoint& pos, + const wxSize& s, + long style, + const wxString& name) +{ + SetName(name); + + wxSize size = s ; + if ( bitmap.Ok() ) + { + if ( size.x == wxDefaultCoord ) + size.x = bitmap.GetWidth() ; + if ( size.y == wxDefaultCoord ) + size.y = bitmap.GetHeight() ; + } + + m_backgroundColour = parent->GetBackgroundColour() ; + m_foregroundColour = parent->GetForegroundColour() ; + + Bitmap = bitmap; + Align = 0; + Scale = 0; + ScaleX = ScaleY = 1; + +#ifndef __WXMSW__ + LastScaleX = LastScaleY = -1; + if ( Bitmap.Ok() ) + OriginalImage = Bitmap.ConvertToImage(); +#endif + + if ( id == wxID_ANY ) + m_windowId = (int)NewControlId(); + else + m_windowId = id; + + m_windowStyle = style; + + bool ret = wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ); + + SetInitialSize( size ) ; + + return ret; +} + +void wxStaticPicture::SetBitmap( const wxBitmap& bmp ) +{ + Bitmap = bmp; +#ifndef __WXMSW__ + if ( Bitmap.Ok() ) + OriginalImage = Bitmap.ConvertToImage(); + LastScaleX = LastScaleY = -1; +#endif +} + +void wxStaticPicture::OnPaint(wxPaintEvent& WXUNUSED(event)) +{ + if ( !Bitmap.Ok() ) + return; + + wxPaintDC dc( this ); + PrepareDC( dc ); + + wxSize sz = GetSize(); + wxSize bmpsz( Bitmap.GetWidth(), Bitmap.GetHeight() ); + float sx = 1.0f, sy = 1.0f; + + if ( Scale & wxSCALE_UNIFORM ) + { + float _sx = (float)sz.GetWidth() / (float)bmpsz.GetWidth(); + float _sy = (float)sz.GetHeight() / (float)bmpsz.GetHeight(); + sx = sy = _sx < _sy ? _sx : _sy; + } + else + if ( Scale & wxSCALE_CUSTOM ) + { + sx = ScaleX; + sy = ScaleY; + } + else + { + if ( Scale & wxSCALE_HORIZONTAL ) + sx = (float)sz.x/(float)bmpsz.x; + if ( Scale & wxSCALE_VERTICAL ) + sy = (float)sz.y/(float)bmpsz.y; + } + + bmpsz = wxSize( (int)(bmpsz.x*sx), (int)(bmpsz.y*sy) ); + + wxPoint pos( 0, 0 ); + + if ( Align & wxALIGN_CENTER_HORIZONTAL ) pos.x = (sz.x-bmpsz.x)/2; + else if ( Align & wxALIGN_RIGHT ) pos.x = sz.x-bmpsz.x; + + if ( Align & wxALIGN_CENTER_VERTICAL ) pos.y = (sz.y-bmpsz.y)/2; + else if ( Align & wxALIGN_BOTTOM ) pos.y = sz.y-bmpsz.y; + + if ( Scale ) + { +#ifdef __WXMSW__ + double ux, uy; + dc.GetUserScale( &ux, &uy ); + dc.SetUserScale( ux*sx, uy*sy ); + dc.DrawBitmap( Bitmap, (int)((float)pos.x/sx), (int)((float)pos.y/sy) ); + dc.SetUserScale( ux, uy ); +#else + if ( LastScaleX != sx || LastScaleY != sy ) + { + LastScaleX = sx; + LastScaleY = sy; + ScaledBitmap = wxBitmap( OriginalImage.Scale( bmpsz.x, bmpsz.y ) ); + } + dc.DrawBitmap( ScaledBitmap, pos.x, pos.y ); +#endif + } + else + dc.DrawBitmap( Bitmap, pos.x, pos.y ); +} + diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/statpict.txt b/wxPython/contrib/gizmos/wxCode/src/gizmos/statpict.txt new file mode 100644 index 0000000000..9a263285fb --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/statpict.txt @@ -0,0 +1,34 @@ +wxStaticPicture class +by Wade Brainerd (wadeb@wadeb.com) + +Description: + +This class is an improved version of wxStaticBitmap. + +Rather than using a native bitmap control, it uses DC operations to draw the +control. This makes its appearance more consistent across platforms, and +allows for additional features. + +Features include: + + wxStaticBitmap compatible API - drop-in replacement. Image alignment - top, + left, bottom, right, center vertical and/or horizontal. + Image scaling - scale horizontally and/or vertically, justified scaling + (maintains image aspect ratio). + +Platforms tested: + + wxMSW + wxGTK + wxMac + +Implementation notes: + +Under MSW wxWindows uses the operating system to do an optimized (potentially +hardware accelerated) blit in wxDC::DrawBitmap. This is usually fast enough to +do image scaling without affecting the program's interactivity. + +On wxMac and wxGTK however, wxDC::DrawBitmap implicitly calls wxImage::Scale +which is a much slower operation. Therefore, on these platforms wxStaticPicture +caches the scaled image to make updates that don't change the image (overlapping +windows, etc.) faster. diff --git a/wxPython/contrib/gizmos/wxCode/src/gizmos/xh_statpict.cpp b/wxPython/contrib/gizmos/wxCode/src/gizmos/xh_statpict.cpp new file mode 100644 index 0000000000..d537261fa7 --- /dev/null +++ b/wxPython/contrib/gizmos/wxCode/src/gizmos/xh_statpict.cpp @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_statpict.cpp +// Purpose: XRC resource handler for wxStaticPicture +// Author: David A. Norris +// Created: 2005/03/13 +// RCS-ID: $Id$ +// Copyright: David A. Norris +// Licence: wxWindows Licence +///////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_XRC + +#include "wx/gizmos/statpict.h" +#include "wx/gizmos/xh_statpict.h" + +// Register with wxWindows' dynamic class subsystem. +IMPLEMENT_DYNAMIC_CLASS(wxStaticPictureXmlHandler, wxXmlResourceHandler) + +// Constructor. +wxStaticPictureXmlHandler::wxStaticPictureXmlHandler() +{ + AddWindowStyles(); +} + +// Creates the control and returns a pointer to it. +wxObject *wxStaticPictureXmlHandler::DoCreateResource() +{ + XRC_MAKE_INSTANCE(control, wxStaticPicture) + + control->Create(m_parentAsWindow, GetID(), + GetBitmap(wxT("bitmap"), wxART_OTHER, GetSize()), + GetPosition(), GetSize(), GetStyle(), GetName()); + + SetupWindow(control); + + return control; +} + +// Returns true if we know how to create a control for the given node. +bool wxStaticPictureXmlHandler::CanHandle(wxXmlNode *node) +{ + return IsOfClass(node, wxT("wxStaticPicture")); +} + +#endif // wxUSE_XRC diff --git a/wxPython/distrib/msw/.make b/wxPython/distrib/msw/.make index 3625f944e5..b5639999dc 100644 --- a/wxPython/distrib/msw/.make +++ b/wxPython/distrib/msw/.make @@ -92,12 +92,12 @@ $WXWIN/build/msw/.mymake $BUILD_TYPE $@ if [ ! $? = 0 ]; then error 2; fi -echo ------------------ -echo cd ../../contrib/build/gizmos -cd ../../contrib/build/gizmos -$WXWIN/build/msw/.mymake $BUILD_TYPE $@ -if [ ! $? = 0 ]; then error 2; fi -cd - +# echo ------------------ +# echo cd ../../contrib/build/gizmos +# cd ../../contrib/build/gizmos +# $WXWIN/build/msw/.mymake $BUILD_TYPE $@ +# if [ ! $? = 0 ]; then error 2; fi +# cd - # echo ------------------ diff --git a/wxPython/distrib/msw/.make.btm b/wxPython/distrib/msw/.make.btm index 594a4135ad..973bae21ab 100644 --- a/wxPython/distrib/msw/.make.btm +++ b/wxPython/distrib/msw/.make.btm @@ -77,12 +77,12 @@ call %WXWIN%\build\msw\.mymake.btm %BUILD_TYPE% %$ if %? != 0 goto done -echo ------------------ -echo cd ..\..\contrib\build\gizmos -cd ..\..\contrib\build\gizmos -call %WXWIN%\build\msw\.mymake.btm %BUILD_TYPE% %$ -if %? != 0 goto done -cd - +REM echo ------------------ +REM echo cd ..\..\contrib\build\gizmos +REM cd ..\..\contrib\build\gizmos +REM call %WXWIN%\build\msw\.mymake.btm %BUILD_TYPE% %$ +REM if %? != 0 goto done +REM cd - REM echo ------------------ REM echo cd ..\..\contrib\build\animate diff --git a/wxPython/docs/BUILD.txt b/wxPython/docs/BUILD.txt index 6c055b18cf..6c5692821d 100644 --- a/wxPython/docs/BUILD.txt +++ b/wxPython/docs/BUILD.txt @@ -145,7 +145,6 @@ place, then do the same for wxPython. like:: make $* \ - && make -C contrib/src/gizmos $* \ && make -C contrib/src/stc $* So you just use .make as if it where make, but don't forget to set diff --git a/wxPython/setup.py b/wxPython/setup.py index 6413627345..f3bbe0f260 100755 --- a/wxPython/setup.py +++ b/wxPython/setup.py @@ -718,13 +718,19 @@ if BUILD_GIZMOS: [ '%s/_treelist.i' % location]) ext = Extension('_gizmos', - [ '%s/treelistctrl.cpp' % opj(location, 'wxCode/src') ] + swig_sources, + [ '%s/treelistctrl.cpp' % opj(location, 'wxCode/src'), + '%s/gizmos/dynamicsash.cpp' % opj(location, 'wxCode/src'), + '%s/gizmos/editlbox.cpp' % opj(location, 'wxCode/src'), + '%s/gizmos/ledctrl.cpp' % opj(location, 'wxCode/src'), + '%s/gizmos/splittree.cpp' % opj(location, 'wxCode/src'), + '%s/gizmos/statpict.cpp' % opj(location, 'wxCode/src'), + ] + swig_sources, include_dirs = includes + [ location, opj(location, 'wxCode/include') ] + CONTRIBS_INC, define_macros = defines, library_dirs = libdirs, - libraries = libs + makeLibName('gizmos'), + libraries = libs, extra_compile_args = cflags, extra_link_args = lflags,