From 58580a7e3cf744de919827f827f14e595f8231af Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 17 Aug 2000 11:53:48 +0000 Subject: [PATCH] Added gizmos hierarchy git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/gizmos/multicell.h | 167 +++++ contrib/include/wx/gizmos/splittree.h | 178 +++++ contrib/samples/gizmos/multicell/makefile.b32 | 10 + contrib/samples/gizmos/multicell/makefile.bcc | 15 + contrib/samples/gizmos/multicell/makefile.dos | 11 + contrib/samples/gizmos/multicell/makefile.g95 | 11 + contrib/samples/gizmos/multicell/makefile.sc | 39 + contrib/samples/gizmos/multicell/makefile.sl | 15 + contrib/samples/gizmos/multicell/makefile.twn | 39 + contrib/samples/gizmos/multicell/makefile.unx | 24 + contrib/samples/gizmos/multicell/makefile.vc | 19 + contrib/samples/gizmos/multicell/makefile.wat | 12 + contrib/samples/gizmos/multicell/mtest.cpp | 215 ++++++ contrib/samples/gizmos/multicell/mtest.rc | 3 + .../samples/gizmos/multicell/multicell.vpj | 18 + contrib/samples/gizmos/splittree/Makefile.in | 21 + contrib/samples/gizmos/splittree/TreeVC.dsp | 187 +++++ contrib/samples/gizmos/splittree/TreeVC.dsw | 29 + contrib/samples/gizmos/splittree/makefile.b32 | 16 + contrib/samples/gizmos/splittree/makefile.bcc | 19 + contrib/samples/gizmos/splittree/makefile.dos | 17 + contrib/samples/gizmos/splittree/makefile.g95 | 16 + contrib/samples/gizmos/splittree/makefile.sc | 36 + contrib/samples/gizmos/splittree/makefile.sl | 18 + contrib/samples/gizmos/splittree/makefile.twn | 43 ++ contrib/samples/gizmos/splittree/makefile.unx | 35 + contrib/samples/gizmos/splittree/makefile.va | 25 + contrib/samples/gizmos/splittree/makefile.vc | 19 + contrib/samples/gizmos/splittree/makefile.wat | 15 + contrib/samples/gizmos/splittree/mondrian.ico | Bin 0 -> 766 bytes contrib/samples/gizmos/splittree/mondrian.xpm | 44 ++ contrib/samples/gizmos/splittree/tree.cpp | 247 +++++++ contrib/samples/gizmos/splittree/tree.h | 107 +++ contrib/src/gizmos/GizmosVC.dsp | 106 +++ contrib/src/gizmos/GizmosVC.dsw | 29 + contrib/src/gizmos/Makefile.in | 23 + contrib/src/gizmos/makefile.b32 | 17 + contrib/src/gizmos/makefile.bcc | 21 + contrib/src/gizmos/makefile.g95 | 16 + contrib/src/gizmos/makefile.unx | 32 + contrib/src/gizmos/makefile.vc | 150 ++++ contrib/src/gizmos/makefile.wat | 22 + contrib/src/gizmos/multicell.cpp | 670 ++++++++++++++++++ contrib/src/gizmos/multicell.txt | 130 ++++ contrib/src/gizmos/multicell_todo.txt | 2 + contrib/src/gizmos/splittree.cpp | 529 ++++++++++++++ 46 files changed, 3417 insertions(+) create mode 100644 contrib/include/wx/gizmos/multicell.h create mode 100644 contrib/include/wx/gizmos/splittree.h create mode 100644 contrib/samples/gizmos/multicell/makefile.b32 create mode 100644 contrib/samples/gizmos/multicell/makefile.bcc create mode 100644 contrib/samples/gizmos/multicell/makefile.dos create mode 100644 contrib/samples/gizmos/multicell/makefile.g95 create mode 100644 contrib/samples/gizmos/multicell/makefile.sc create mode 100644 contrib/samples/gizmos/multicell/makefile.sl create mode 100644 contrib/samples/gizmos/multicell/makefile.twn create mode 100644 contrib/samples/gizmos/multicell/makefile.unx create mode 100644 contrib/samples/gizmos/multicell/makefile.vc create mode 100644 contrib/samples/gizmos/multicell/makefile.wat create mode 100644 contrib/samples/gizmos/multicell/mtest.cpp create mode 100644 contrib/samples/gizmos/multicell/mtest.rc create mode 100644 contrib/samples/gizmos/multicell/multicell.vpj create mode 100644 contrib/samples/gizmos/splittree/Makefile.in create mode 100644 contrib/samples/gizmos/splittree/TreeVC.dsp create mode 100644 contrib/samples/gizmos/splittree/TreeVC.dsw create mode 100644 contrib/samples/gizmos/splittree/makefile.b32 create mode 100644 contrib/samples/gizmos/splittree/makefile.bcc create mode 100644 contrib/samples/gizmos/splittree/makefile.dos create mode 100644 contrib/samples/gizmos/splittree/makefile.g95 create mode 100644 contrib/samples/gizmos/splittree/makefile.sc create mode 100644 contrib/samples/gizmos/splittree/makefile.sl create mode 100644 contrib/samples/gizmos/splittree/makefile.twn create mode 100644 contrib/samples/gizmos/splittree/makefile.unx create mode 100644 contrib/samples/gizmos/splittree/makefile.va create mode 100644 contrib/samples/gizmos/splittree/makefile.vc create mode 100644 contrib/samples/gizmos/splittree/makefile.wat create mode 100644 contrib/samples/gizmos/splittree/mondrian.ico create mode 100644 contrib/samples/gizmos/splittree/mondrian.xpm create mode 100644 contrib/samples/gizmos/splittree/tree.cpp create mode 100644 contrib/samples/gizmos/splittree/tree.h create mode 100644 contrib/src/gizmos/GizmosVC.dsp create mode 100644 contrib/src/gizmos/GizmosVC.dsw create mode 100644 contrib/src/gizmos/Makefile.in create mode 100644 contrib/src/gizmos/makefile.b32 create mode 100644 contrib/src/gizmos/makefile.bcc create mode 100644 contrib/src/gizmos/makefile.g95 create mode 100644 contrib/src/gizmos/makefile.unx create mode 100644 contrib/src/gizmos/makefile.vc create mode 100644 contrib/src/gizmos/makefile.wat create mode 100644 contrib/src/gizmos/multicell.cpp create mode 100644 contrib/src/gizmos/multicell.txt create mode 100644 contrib/src/gizmos/multicell_todo.txt create mode 100644 contrib/src/gizmos/splittree.cpp diff --git a/contrib/include/wx/gizmos/multicell.h b/contrib/include/wx/gizmos/multicell.h new file mode 100644 index 0000000000..b200c05155 --- /dev/null +++ b/contrib/include/wx/gizmos/multicell.h @@ -0,0 +1,167 @@ +///////////////////////////////////////////////////////////////////////////// +// 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__ + +#ifdef __GNUG__ + #pragma interface "multicell.h" +#endif + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- +// The classes are derived from wxSizer +#include "wx/sizer.h" + + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- +enum wxResizable +{ + wxNOT_RESIZABLE = 0x00, + wxHORIZENTAL_RESIZABLE = 0x01, + wxVERTICAL_RESIZABLE = 0x10, + wxRESIZABLE = 0x11 +}; + +//--------------------------------------------------------------------------- +// classes +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// wxMultiCellItemHandle +//--------------------------------------------------------------------------- + +class WXDLLEXPORT 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); + wxMultiCellItemHandle( int row, int column, int align); + int GetColumn(); + int GetRow(); + int GetWidth(); + int GetHeight(); + wxResizable GetStyle(); + wxSize GetLocalSize(); + int GetAlignment(); + wxSize GetWeight(); + +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 WXDLLEXPORT 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(wxPen *pen); + void OnPaint(wxDC& dc); + +private: + void GetMinimums(); + 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 + 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 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() + { + return m_maxRows; + }; + int MaxCols() + { + return m_maxCols; + }; + void CalculateConstraints(); + void SetMinCellSize(const wxSize size) + { + m_minCellSize = size; + }; + +private: + wxWindow *m_parent; + unsigned int m_maxRows, m_maxCols; + + wxSize m_minCellSize; + wxCell **m_cells; +}; + +#endif + + + +/*** End of File ***/ diff --git a/contrib/include/wx/gizmos/splittree.h b/contrib/include/wx/gizmos/splittree.h new file mode 100644 index 0000000000..118f0b450e --- /dev/null +++ b/contrib/include/wx/gizmos/splittree.h @@ -0,0 +1,178 @@ +///////////////////////////////////////////////////////////////////////////// +// 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_ + +#ifdef __GNUG__ + #pragma interface "splittree.h" +#endif + +// 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 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 OnPaint(wxPaintEvent& event); + void OnExpand(wxTreeEvent& event); + void OnScroll(wxScrollWinEvent& 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); + +//// Helpers + void HideVScrollbar(); + + // Calculate the tree overall size so we can set the scrollbar + // correctly + void CalcTreeSize(wxRect& rect); + void CalcTreeSize(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); + + DECLARE_EVENT_TABLE() +protected: +}; + +/* + * wxThinSplitterWindow + * + * Implements a splitter with a less obvious sash + * than the usual one. + */ + +class wxThinSplitterWindow: public wxSplitterWindow +{ +public: + DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow) + + wxThinSplitterWindow(wxWindow* parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, + long style = wxSP_3D | wxCLIP_CHILDREN); + +//// 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: + 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 wxSplitterScrolledWindow: public wxScrolledWindow +{ +public: + DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow) + + wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = -1, + 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/contrib/samples/gizmos/multicell/makefile.b32 b/contrib/samples/gizmos/multicell/makefile.b32 new file mode 100644 index 0000000000..202df2787d --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.b32 @@ -0,0 +1,10 @@ +# Purpose: makefile for multicell example (BC++ 32bit) +# Created 2000-07-28 + +WXDIR = $(WXWIN) + +TARGET=mtest +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/contrib/samples/gizmos/multicell/makefile.bcc b/contrib/samples/gizmos/multicell/makefile.bcc new file mode 100644 index 0000000000..472396d8eb --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.bcc @@ -0,0 +1,15 @@ +# Purpose: makefile for multicell example (BC++ 16bit) +# Created 2000-07-28 + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=mtest +OBJECTS=$(TARGET).obj ..\src\multicell.obj +EXTRAINC=-I..\include + +!include $(WXDIR)\src\makeprog.bcc + diff --git a/contrib/samples/gizmos/multicell/makefile.dos b/contrib/samples/gizmos/multicell/makefile.dos new file mode 100644 index 0000000000..5c5a4d82bb --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.dos @@ -0,0 +1,11 @@ +# Purpose: makefile for multicell example (VC++ 1.5x) +# Created 2000-07-28 + +WXDIR = $(WXWIN) + +TARGET=mtest +OBJECTS = $(TARGET).obj ..\src\multicell.obj +EXTRAINC=-I..\include + +!include $(WXDIR)\src\makeprog.msc + diff --git a/contrib/samples/gizmos/multicell/makefile.g95 b/contrib/samples/gizmos/multicell/makefile.g95 new file mode 100644 index 0000000000..85dabdf2c1 --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.g95 @@ -0,0 +1,11 @@ +# Purpose: makefile for multicell example (Cygwin/Mingw32) +# Created 2000-07-28 + +WXDIR = ../../../.. + +TARGET=mtest +OBJECTS = $(TARGET).o +EXTRALIBS=$(WXDIR)/lib/libgizmos.lib + +include $(WXDIR)/src/makeprog.g95 + diff --git a/contrib/samples/gizmos/multicell/makefile.sc b/contrib/samples/gizmos/multicell/makefile.sc new file mode 100644 index 0000000000..4a96edffd1 --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.sc @@ -0,0 +1,39 @@ +# Purpose: makefile for multicell example (Symantec C++) +# Created 2000-07-28 + +WXDIR = $(WXWIN) +WXLIB = $(WXDIR)\lib\wx.lib +INCDIR = $(WXDIR)\include +INCLUDE=$(INCDIR) +TARGET=mtest +OBJECTS = $(TARGET).obj ..\src\multicell.obj +EXTRAINC=-I..\include + +include $(WXDIR)\src\makesc.env + +mtest.exe: $(OBJECTS) $(DEFFILE) mtest.res + *$(CC) $(LDFLAGS) -o$@ $** $(LIBS) + *$(RC) -k mtest.res + +sc32.def: + echo EXETYPE NT > sc32.def + echo SUBSYSTEM WINDOWS >> sc32.def + +sc16.def: + echo NAME $(TARGET) > sc16.def + echo EXETYPE WINDOWS >> sc16.def + echo STUB 'WINSTUB.EXE' >> sc16.def + echo CODE PRELOAD MOVEABLE DISCARDABLE >> sc16.def + echo DATA PRELOAD MOVEABLE MULTIPLE >> sc16.def + echo HEAPSIZE 1024 >> sc16.def + echo STACKSIZE 8192 >> sc16.def + +clean: + -del *.obj + -del *.exe + -del *.res + -del *.map + -del *.rws + -del sc32.def + -del sc16.def + diff --git a/contrib/samples/gizmos/multicell/makefile.sl b/contrib/samples/gizmos/multicell/makefile.sl new file mode 100644 index 0000000000..15fbe57196 --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.sl @@ -0,0 +1,15 @@ +# Purpose: makefile for multicell example (Salford C++) +# Created 2000-07-28 + +PROGRAM = mtest +OBJECTS = $(PROGRAM).obj ..\src\multicell.obj +EXTRAINC=-I..\include + +include ..\..\src\makeprog.sl + +all: wx $(TARGET) + +wx: + cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all + cd $(WXDIR)\samples\notebook + diff --git a/contrib/samples/gizmos/multicell/makefile.twn b/contrib/samples/gizmos/multicell/makefile.twn new file mode 100644 index 0000000000..ddfcaf207b --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.twn @@ -0,0 +1,39 @@ +# Purpose: makefile for multicell example (TWIN) +# Created 2000-07-28 + +WXDIR = ../.. + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/maketwin.env + +OBJECTS = $(OBJDIR)/mtest.$(OBJSUFF) $(OBJDIR)/multicell.$(OBJSUFF) +EXTRAINC=-I../include + +all: $(OBJDIR) mtest$(GUISUFFIX)$(EXESUFF) + +wx: + +$(OBJDIR): + mkdir $(OBJDIR) + +mtest$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) + $(CC) $(LDFLAGS) -o mtest$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) + +$(OBJDIR)/mtest.$(OBJSUFF): mtest.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ mtest.$(SRCSUFF) + +$(OBJDIR)/multicell.$(OBJSUFF): multicell.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ multicell.$(SRCSUFF) + +mtest.c: mtest.rc + $(RESCOMP) $(RCINPUTSWITCH) mtest.rc $(RCOUTPUTSWITCH) mtest.c $(RESFLAGS) + +$(OBJDIR)/mtest.$(OBJSUFF): mtest.c + $(CC) -c $(CPPFLAGS) -o $@ mtest.c + +#$(OBJDIR)/mtest.o: mtest.rc +# $(RESCOMP) $(RCINPUTSWITCH) mtest.rc $(RCOUTPUTSWITCH) $(OBJDIR)/mtest.o $(RESFLAGS) + +clean: + rm -f $(OBJECTS) mtest$(GUISUFFIX).exe core *.rsc *.res diff --git a/contrib/samples/gizmos/multicell/makefile.unx b/contrib/samples/gizmos/multicell/makefile.unx new file mode 100644 index 0000000000..a83e732862 --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.unx @@ -0,0 +1,24 @@ +# Purpose: makefile for multicell example (Unix) +# Created 2000-07-28 + +CC = gcc + +PROGRAM = mtest + +OBJECTS = $(PROGRAM).o ../src/multicell.o +EXTRAINC=-I../include + +# implementation + +.SUFFIXES: .o .cpp + +.cpp.o : + $(CC) -c `wx-config --cflags` -o $@ $< + +all: $(PROGRAM) + +$(PROGRAM): $(OBJECTS) + $(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs` + +clean: + rm -f *.o $(PROGRAM) diff --git a/contrib/samples/gizmos/multicell/makefile.vc b/contrib/samples/gizmos/multicell/makefile.vc new file mode 100644 index 0000000000..ef2bac2633 --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.vc @@ -0,0 +1,19 @@ +# Makefile : Builds sample (VC++, WIN32) +# Use FINAL=1 argument to nmake to build final version with no debug info. +# Created 2000-07-28 + +# Set WXDIR for your system +WXDIR = $(WXWIN) +FINAL=0 +PROGRAM=mtest +OBJECTS = $(PROGRAM).obj + +!if "$(FINAL)" == "0" +EXTRALIBS=$(WXDIR)\lib\gizmosd.lib +!else +EXTRALIBS=$(WXDIR)\lib\gizmos.lib +!endif + +!include $(WXDIR)\src\makeprog.vc + + diff --git a/contrib/samples/gizmos/multicell/makefile.wat b/contrib/samples/gizmos/multicell/makefile.wat new file mode 100644 index 0000000000..64778d2b8f --- /dev/null +++ b/contrib/samples/gizmos/multicell/makefile.wat @@ -0,0 +1,12 @@ +# Purpose: makefile for multicell example (Watcom) +# Created 2000-07-28 + +WXDIR = $(%WXWIN) + +PROGRAM = mtest +OBJECTS = $(PROGRAM).obj ..\src\multicell.obj +EXTRAINC=-I..\include + +!include $(WXDIR)\src\makeprog.wat + + diff --git a/contrib/samples/gizmos/multicell/mtest.cpp b/contrib/samples/gizmos/multicell/mtest.cpp new file mode 100644 index 0000000000..3b1d70b993 --- /dev/null +++ b/contrib/samples/gizmos/multicell/mtest.cpp @@ -0,0 +1,215 @@ +/* + * File: mtest.cpp + * Purpose: wxMultiCellSizer and wxMultiCellCanvas test + * Author: Alex Andruschak + * Created: 2000 + * Updated: + * Copyright: + */ + +static const char sccsid[] = "%W% %G%"; + +#ifdef __GNUG__ + #pragma implementation + #pragma interface +#endif + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/gizmos/multicell.h" + +class MyApp: public wxApp +{public: + bool OnInit(void); +}; + +class MyFrame: public wxFrame +{ + +public: + MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size); + + void OnCloseWindow(wxCloseEvent& event); + void OnPaint(wxPaintEvent& event); + wxMultiCellSizer *sizer; + + DECLARE_EVENT_TABLE() +}; + +IMPLEMENT_APP(MyApp) + +bool MyApp::OnInit(void) +{ + MyFrame *frame = new MyFrame(1, (wxFrame *) NULL, (char *) "wxMultiCellSizer Sample", wxPoint(50, 50), wxDefaultSize); //, wxSize(600, 500)); + + frame->Show(TRUE); + + SetTopWindow(frame); + frame = new MyFrame(2, (wxFrame *) NULL, (char *) "wxMultiCellCanvas Sample", wxPoint(100, 100), wxSize(600, 500)); + + frame->Show(TRUE); + + SetTopWindow(frame); + return TRUE; +} + + + +MyFrame::MyFrame(int type, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size): +wxFrame(frame, -1, title, pos, size, wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL) +{ + CreateStatusBar(1); + sizer = NULL; + if (type == 1) + { + // create sizer 4 columns 5 rows + wxSize aa(4,9); + sizer = new wxMultiCellSizer(aa); + sizer->SetDefaultCellSize(wxSize(15,15)); + sizer->SetRowHeight(7,5,TRUE); + sizer->SetRowHeight(8,5,FALSE); + // add first row + sizer->Add( + new wxButton( this, -1, "B1 - 0,0, horizontal resizable" ), + 0, 0, 0, new wxMultiCellItemHandle(0,0,1,1, wxDefaultSize, wxHORIZENTAL_RESIZABLE, wxSize(2,2))); + sizer->Add( + new wxButton( this, -1, "B2 - 0,1, vertical resizable" ), + 0, 0, 0, new wxMultiCellItemHandle(0,1,1,1, wxDefaultSize, wxVERTICAL_RESIZABLE, wxSize(2, 2))); + sizer->Add( + new wxButton( this, -1, "B3 - 0,2" ), + 0, 0, 0, new wxMultiCellItemHandle(0,2,1,1, wxDefaultSize, wxNOT_RESIZABLE, wxSize(1,1), wxALIGN_CENTER_HORIZONTAL)); //, wxALIGN_CENTER)); + sizer->Add( + new wxStaticText(this, -1, "jbb 0,3, lower-right"), + 0, 0, 0, new wxMultiCellItemHandle(0,3,1,1, wxDefaultSize, wxNOT_RESIZABLE, wxSize(1,1), wxALIGN_BOTTOM | wxALIGN_RIGHT)); + + // add button for secord row + sizer->Add( + new wxTextCtrl(this, -1, "Text control - 1,0, 4 cols wide"), + 0, 0, 0, new wxMultiCellItemHandle(1,0,1,4)); + + // add buttons for next row + sizer->Add( + new wxButton( this, -1, "B6 - 2,0, 2 cols wide" ), + 0, 0, 0, new wxMultiCellItemHandle(2,0,1,2)); + sizer->Add( + new wxButton( this, -1, "B7 - 2,3" ), + 0, 0, 0, new wxMultiCellItemHandle(2,3,1,1)); + + // and last additions + sizer->Add( + new wxButton( this, -1, "B8 - 3,0, 4 rows high, vert resizable" ), + 0, 0, 0, new wxMultiCellItemHandle(3,0,4,1,wxDefaultSize, wxVERTICAL_RESIZABLE)); + sizer->Add( + new wxButton( this, -1, "B9 - 3,2, 2 cols wide, vert resizable" ), + 0, 0, 0, new wxMultiCellItemHandle(3,2,1,2,wxDefaultSize, wxVERTICAL_RESIZABLE)); + sizer->Add( + new wxButton( this, -1, "B10 - 4,1, 3 cols wide, vert resizable" ), + 0, 0, 0, new wxMultiCellItemHandle(4,1,1,3,wxDefaultSize, wxVERTICAL_RESIZABLE)); + + sizer->Add( + new wxButton( this, -1, "B11 - 5,1, 3 cols wide" ), + 0, 0, 0, new wxMultiCellItemHandle(5,1,1,3)); + + sizer->Add( + new wxButton( this, -1, "B12 - 6,1, 3 cols wide" ), + 0, 0, 0, new wxMultiCellItemHandle(6,1,1,3)); + + sizer->Add( + new wxButton( this, -1, "B13 - 7,1, 2 cols wide" ), + 0, 0, 0, new wxMultiCellItemHandle(7,1,1,2)); + + sizer->Add( + new wxButton( this, -1, "B14 - 8,1, 3 cols wide" ), + 0, 0, 0, new wxMultiCellItemHandle(8,1,1,3)); + + SetAutoLayout( TRUE ); +// sizer->SetMinSize(sizer->CalcMin()); + SetSizer( sizer ); + wxSize s = sizer->CalcMin(); + wxSize c = GetSize() - GetClientSize(); + SetSizeHints(s.GetWidth() + c.GetWidth() , s.GetHeight() + c.GetHeight()); + sizer->EnableGridLines(this); + } + else + { + // create sizer 4 columns 5 rows + wxMultiCellCanvas *sizer = new wxMultiCellCanvas(this, 5,5); + + // add first row + sizer->Add( + new wxButton( this, -1, "Button 1" ), + 0, 0); + sizer->Add( + new wxButton( this, -1, "Button 2" ), + 0, 1); + sizer->Add( + new wxButton( this, -1, "Button 3" ), + 0, 2); + sizer->Add( + new wxStaticText(this, -1, "jbb test"), + 0, 3); + + sizer->Add( + new wxStaticText(this, -1, "jbb test 2"), + 0, 4); + + // add button for secord row + sizer->Add( + new wxTextCtrl(this, -1, "Text control"), + 1, 0); + + // add buttons for next row + sizer->Add( + new wxButton( this, -1, "Button 6" ), + 2, 0); + sizer->Add( + new wxButton( this, -1, "Button 7" ), + 2, 3); + + // and last additions + sizer->Add( + new wxButton( this, -1, "Button 8" ), + 3, 0); + sizer->Add( + new wxButton( this, -1, "Button 9" ), + 3, 1); + sizer->Add( + new wxButton( this, -1, "Button 10" ), + 4, 1); + + sizer->CalculateConstraints(); + SetSizer( sizer ); + SetAutoLayout( TRUE ); + } +} +// Define the repainting behaviour + + +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_PAINT(MyFrame::OnPaint) + EVT_CLOSE(MyFrame::OnCloseWindow) + END_EVENT_TABLE() + +void MyFrame::OnPaint(wxPaintEvent& WXUNUSED(event) ) +{ + wxPaintDC dc(this); + + if (sizer) + { + sizer->OnPaint(dc); + } +} + +void MyFrame::OnCloseWindow(wxCloseEvent& event) +{ + Destroy(); +} + diff --git a/contrib/samples/gizmos/multicell/mtest.rc b/contrib/samples/gizmos/multicell/mtest.rc new file mode 100644 index 0000000000..878f3352fb --- /dev/null +++ b/contrib/samples/gizmos/multicell/mtest.rc @@ -0,0 +1,3 @@ +#include "wx/msw/wx.rc" + + diff --git a/contrib/samples/gizmos/multicell/multicell.vpj b/contrib/samples/gizmos/multicell/multicell.vpj new file mode 100644 index 0000000000..450b7bd12c --- /dev/null +++ b/contrib/samples/gizmos/multicell/multicell.vpj @@ -0,0 +1,18 @@ +[COMPILER] +version=5.0b +compile=concur|capture|:Compile:&Compile,gcc +make=concur|capture|:Build:&Build,make +rebuild=concur|capture|:Rebuild:&Rebuild, +debug=:Debug:&Debug,gdb +execute=:Execute:E&xecute, +user1=hide|:User 1:User 1, +user2=hide|:User 2:User 2, +workingdir=. +includedirs= +reffile= +MACRO=\n +[FILES] +mtest.cpp +multicell.cpp +multicell.h +[ASSOCIATION] diff --git a/contrib/samples/gizmos/splittree/Makefile.in b/contrib/samples/gizmos/splittree/Makefile.in new file mode 100644 index 0000000000..7185ea5865 --- /dev/null +++ b/contrib/samples/gizmos/splittree/Makefile.in @@ -0,0 +1,21 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 Julian Smart +# +# "%W% %G%" +# +# Makefile for minimal example (UNIX). + +top_srcdir = @top_srcdir@/.. +top_builddir = ../.. +program_dir = samples/minimal + +PROGRAM=minimal + +OBJECTS=$(PROGRAM).o + +include ../../src/makeprog.env + diff --git a/contrib/samples/gizmos/splittree/TreeVC.dsp b/contrib/samples/gizmos/splittree/TreeVC.dsp new file mode 100644 index 0000000000..1f136e2a35 --- /dev/null +++ b/contrib/samples/gizmos/splittree/TreeVC.dsp @@ -0,0 +1,187 @@ +# Microsoft Developer Studio Project File - Name="TreeVC" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=TreeVC - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "TreeVC.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "TreeVC.mak" CFG="TreeVC - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "TreeVC - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "TreeVC - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE "TreeVC - Win32 Debug DLL" (based on "Win32 (x86) Application") +!MESSAGE "TreeVC - Win32 Release DLL" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "TreeVC - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "..\..\..\..\include" /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 wx.lib xpm.lib png.lib zlib.lib jpeg.lib tiff.lib gizmos.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /nodefaultlib:"msvcrtd.lib" /out:"Release/tree.exe" /libpath:"d:\wx2\wxWindows\lib" + +!ELSEIF "$(CFG)" == "TreeVC - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\include" /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 wxd.lib xpmd.lib pngd.lib zlibd.lib jpegd.lib tiffd.lib gizmosd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /nodefaultlib:"msvcrt.lib" /out:"Debug/tree.exe" /pdbtype:sept /libpath:"d:\wx2\wxWindows\lib" + +!ELSEIF "$(CFG)" == "TreeVC - Win32 Debug DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugDLL" +# PROP BASE Intermediate_Dir "DebugDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugDLL" +# PROP Intermediate_Dir "DebugDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\..\include" /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /Yu"wx/wxprec.h" /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "_DEBUG" +# ADD RSC /l 0x809 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 wxdlld.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libcd.lib" /nodefaultlib:"libcid.lib" /out:"DebugDLL/tree.exe" /pdbtype:sept /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ELSEIF "$(CFG)" == "TreeVC - Win32 Release DLL" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseDLL" +# PROP BASE Intermediate_Dir "ReleaseDLL" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseDLL" +# PROP Intermediate_Dir "ReleaseDLL" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "..\..\..\..\include" /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D WXUSINGDLL=1 /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD BASE RSC /l 0x809 /d "NDEBUG" +# ADD RSC /l 0x809 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 wxdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib comctl32.lib rpcrt4.lib wsock32.lib winmm.lib /nologo /subsystem:windows /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libci.lib" /out:"ReleaseDLL/tree.exe" /libpath:"../../lib" /libpath:"../../contrib/lib" + +!ENDIF + +# Begin Target + +# Name "TreeVC - Win32 Release" +# Name "TreeVC - Win32 Debug" +# Name "TreeVC - Win32 Debug DLL" +# Name "TreeVC - Win32 Release DLL" +# Begin Source File + +SOURCE=.\tree.cpp + +!IF "$(CFG)" == "TreeVC - Win32 Release" + +# ADD CPP /I "..\..\..\include" +# SUBTRACT CPP /I "..\..\include" + +!ELSEIF "$(CFG)" == "TreeVC - Win32 Debug" + +# ADD CPP /I "..\..\..\include" +# SUBTRACT CPP /I "..\..\include" /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "TreeVC - Win32 Debug DLL" + +# SUBTRACT BASE CPP /YX /Yc /Yu +# ADD CPP /I "..\..\..\include" +# SUBTRACT CPP /I "..\..\include" /YX /Yc /Yu + +!ELSEIF "$(CFG)" == "TreeVC - Win32 Release DLL" + +# ADD CPP /I "..\..\..\include" +# SUBTRACT CPP /I "..\..\include" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\tree.h +# End Source File +# Begin Source File + +SOURCE=.\tree.rc +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 /i "d:\wx2\wxWindows\include" +# End Source File +# End Target +# End Project diff --git a/contrib/samples/gizmos/splittree/TreeVC.dsw b/contrib/samples/gizmos/splittree/TreeVC.dsw new file mode 100644 index 0000000000..42b347c774 --- /dev/null +++ b/contrib/samples/gizmos/splittree/TreeVC.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "TreeVC"=.\TreeVC.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/contrib/samples/gizmos/splittree/makefile.b32 b/contrib/samples/gizmos/splittree/makefile.b32 new file mode 100644 index 0000000000..d1cbad638b --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.b32 @@ -0,0 +1,16 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds sample for 32-bit BC++ + +WXDIR = $(WXWIN) + +TARGET=minimal +OBJECTS = $(TARGET).obj + +!include $(WXDIR)\src\makeprog.b32 + diff --git a/contrib/samples/gizmos/splittree/makefile.bcc b/contrib/samples/gizmos/splittree/makefile.bcc new file mode 100644 index 0000000000..705fc065bc --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.bcc @@ -0,0 +1,19 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds a BC++ 16-bit sample + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +TARGET=minimal +OBJECTS=$(TARGET).obj + +!include $(WXDIR)\src\makeprog.bcc + diff --git a/contrib/samples/gizmos/splittree/makefile.dos b/contrib/samples/gizmos/splittree/makefile.dos new file mode 100644 index 0000000000..6319446109 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.dos @@ -0,0 +1,17 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Makefile : Builds 16-bit sample, VC++ 1.5 +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +WXDIR = $(WXWIN) + +TARGET=minimal +OBJECTS=$(TARGET).obj + +!include $(WXDIR)\src\makeprog.msc + diff --git a/contrib/samples/gizmos/splittree/makefile.g95 b/contrib/samples/gizmos/splittree/makefile.g95 new file mode 100644 index 0000000000..f030c04367 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows sample (Cygwin/Mingw32). + +WXDIR = ../.. + +TARGET=minimal +OBJECTS = $(TARGET).o + +include $(WXDIR)/src/makeprog.g95 + diff --git a/contrib/samples/gizmos/splittree/makefile.sc b/contrib/samples/gizmos/splittree/makefile.sc new file mode 100644 index 0000000000..c55f65c7d7 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.sc @@ -0,0 +1,36 @@ +# Symantec C++ makefile + +WXDIR = $(WXWIN) +WXLIB = $(WXDIR)\lib\wx.lib +INCDIR = $(WXDIR)\include +INCLUDE=$(INCDIR) +TARGET=minimal + +include $(WXDIR)\src\makesc.env + +minimal.exe: minimal.obj $(DEFFILE) minimal.res + *$(CC) $(LDFLAGS) -o$@ $** $(LIBS) + *$(RC) -k minimal.res + +sc32.def: + echo EXETYPE NT > sc32.def + echo SUBSYSTEM WINDOWS >> sc32.def + +sc16.def: + echo NAME $(TARGET) > sc16.def + echo EXETYPE WINDOWS >> sc16.def + echo STUB 'WINSTUB.EXE' >> sc16.def + echo CODE PRELOAD MOVEABLE DISCARDABLE >> sc16.def + echo DATA PRELOAD MOVEABLE MULTIPLE >> sc16.def + echo HEAPSIZE 1024 >> sc16.def + echo STACKSIZE 8192 >> sc16.def + +clean: + -del *.obj + -del *.exe + -del *.res + -del *.map + -del *.rws + -del sc32.def + -del sc16.def + diff --git a/contrib/samples/gizmos/splittree/makefile.sl b/contrib/samples/gizmos/splittree/makefile.sl new file mode 100644 index 0000000000..7dd9a0b6a6 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.sl @@ -0,0 +1,18 @@ +# +# File: makefile.sl +# Author: Julian Smart +# Created: 1998 +# +# Makefile : Builds a wxWindows sample for Salford C++, WIN32 + +PROGRAM = minimal +OBJECTS = $(PROGRAM).obj + +include ..\..\src\makeprog.sl + +all: wx $(TARGET) + +wx: + cd $(WXDIR)\src\msw ^ mk32 -f makefile.sl all + cd $(WXDIR)\samples\minimal + diff --git a/contrib/samples/gizmos/splittree/makefile.twn b/contrib/samples/gizmos/splittree/makefile.twn new file mode 100644 index 0000000000..70cf377fe5 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.twn @@ -0,0 +1,43 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile for minimal example (UNIX). + +WXDIR = ../.. + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/maketwin.env + +OBJECTS = $(OBJDIR)/minimal.$(OBJSUFF) $(OBJDIR)/minimal_resources.$(OBJSUFF) + +all: $(OBJDIR) minimal$(GUISUFFIX)$(EXESUFF) + +wx: + +$(OBJDIR): + mkdir $(OBJDIR) + +minimal$(GUISUFFIX)$(EXESUFF): $(OBJECTS) $(WXLIB) + $(CC) $(LDFLAGS) -o minimal$(GUISUFFIX)$(EXESUFF) $(OBJECTS) $(LDLIBS) + +$(OBJDIR)/minimal.$(OBJSUFF): minimal.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ minimal.$(SRCSUFF) + +minimal_resources.c: minimal.rc + $(RESCOMP) $(RCINPUTSWITCH) minimal.rc $(RCOUTPUTSWITCH) minimal_resources.c $(RESFLAGS) + +$(OBJDIR)/minimal_resources.$(OBJSUFF): minimal_resources.c + $(CC) -c $(CPPFLAGS) -o $@ minimal_resources.c + +#$(OBJDIR)/minimal_resources.o: minimal.rc +# $(RESCOMP) $(RCINPUTSWITCH) minimal.rc $(RCOUTPUTSWITCH) $(OBJDIR)/minimal_resources.o $(RESFLAGS) + +clean: + rm -f $(OBJECTS) minimal$(GUISUFFIX).exe core *.rsc *.res diff --git a/contrib/samples/gizmos/splittree/makefile.unx b/contrib/samples/gizmos/splittree/makefile.unx new file mode 100644 index 0000000000..2552111590 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.unx @@ -0,0 +1,35 @@ +# +# File: Makefile for samples +# Author: Robert Roebling +# Created: 1999 +# Updated: +# Copyright: (c) 1998 Robert Roebling +# +# This makefile requires a Unix version of wxWindows +# to be installed on your system. This is most often +# done typing "make install" when using the complete +# sources of wxWindows or by installing the two +# RPM packages wxGTK.XXX.rpm and wxGTK-devel.XXX.rpm +# under Linux. +# + +CC = gcc + +PROGRAM = minimal + +OBJECTS = $(PROGRAM).o + +# implementation + +.SUFFIXES: .o .cpp + +.cpp.o : + $(CC) -c `wx-config --cflags` -o $@ $< + +all: $(PROGRAM) + +$(PROGRAM): $(OBJECTS) + $(CC) -o $(PROGRAM) $(OBJECTS) `wx-config --libs` + +clean: + rm -f *.o $(PROGRAM) diff --git a/contrib/samples/gizmos/splittree/makefile.va b/contrib/samples/gizmos/splittree/makefile.va new file mode 100644 index 0000000000..ba7f61ed13 --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.va @@ -0,0 +1,25 @@ +# +# File: makefile.va +# Author: David Webster +# Created: 1999 +# Updated: +# Copyright: (c) David Webster +# +# Makefile : Builds sample (VisualAgeC++ V3.0, OS/2 PM) +# Use FINAL=1 argument to nmake to build final version with no debug info. + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +WXUSINGDLL=0 + +!include $(WXDIR)\src\makeva.env + +PROGRAM=$D\minimal +OBJECTS = $(PROGRAM).obj + +!if [md $D] +!endif + +!include $(WXDIR)\src\makeprog.va + diff --git a/contrib/samples/gizmos/splittree/makefile.vc b/contrib/samples/gizmos/splittree/makefile.vc new file mode 100644 index 0000000000..36e00d1e7e --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.vc @@ -0,0 +1,19 @@ +# Makefile : Builds sample (VC++, WIN32) +# Use FINAL=1 argument to nmake to build final version with no debug info. +# Created 2000-07-28 + +# Set WXDIR for your system +WXDIR = $(WXWIN) +FINAL=0 +PROGRAM=tree +OBJECTS = $(PROGRAM).obj + +!if "$(FINAL)" == "0" +EXTRALIBS=$(WXDIR)\lib\gizmosd.lib +!else +EXTRALIBS=$(WXDIR)\lib\gizmos.lib +!endif + +!include $(WXDIR)\src\makeprog.vc + + diff --git a/contrib/samples/gizmos/splittree/makefile.wat b/contrib/samples/gizmos/splittree/makefile.wat new file mode 100644 index 0000000000..2b200ba7ec --- /dev/null +++ b/contrib/samples/gizmos/splittree/makefile.wat @@ -0,0 +1,15 @@ +# +# Makefile for WATCOM +# +# Created by Julian Smart, January 1999 +# +# + +WXDIR = $(%WXWIN) + +PROGRAM = minimal +OBJECTS = $(PROGRAM).obj + +!include $(WXDIR)\src\makeprog.wat + + diff --git a/contrib/samples/gizmos/splittree/mondrian.ico b/contrib/samples/gizmos/splittree/mondrian.ico new file mode 100644 index 0000000000000000000000000000000000000000..2310c5d275a87af295d5ea8dc79ea417a5e74c53 GIT binary patch literal 766 zcmZQzU<5)11px*Sc)`TLAO@s0fLH;D9e|jTfdxnc0ZShow(TRUE); + + // success: wxApp::OnRun() will be called which will enter the main message + // loop and the application will run. If we returned FALSE here, the + // application would exit immediately. + return TRUE; +} + +// ---------------------------------------------------------------------------- +// main frame +// ---------------------------------------------------------------------------- + +// frame constructor +MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) + : wxFrame((wxFrame *)NULL, idMAIN_FRAME, title, pos, size) +{ + m_splitter = NULL; + m_scrolledWindow = NULL; + m_tree = NULL; + m_valueWindow = NULL; +#ifdef __WXMAC__ + // we need this in order to allow the about menu relocation, since ABOUT is + // not the default id of the about menu + wxApp::s_macAboutMenuItemId = Minimal_About; +#endif + + m_scrolledWindow = new wxSplitterScrolledWindow(this, idSCROLLED_WINDOW, wxDefaultPosition, + wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); + m_splitter = new wxThinSplitterWindow(m_scrolledWindow, idSPLITTER_WINDOW, wxDefaultPosition, + wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */); + m_splitter->SetSashSize(2); + m_tree = new TestTree(m_splitter, idTREE_CTRL, wxDefaultPosition, + wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER ); + m_valueWindow = new TestValueWindow(m_splitter, idVALUE_WINDOW, wxDefaultPosition, + wxDefaultSize, wxNO_BORDER); + m_splitter->SplitVertically(m_tree, m_valueWindow); + //m_splitter->AdjustScrollbars(); + m_splitter->SetSashPosition(200); + m_scrolledWindow->SetTargetWindow(m_tree); + + m_scrolledWindow->EnableScrolling(FALSE, FALSE); + + // set the frame icon + SetIcon(wxICON(mondrian)); + + // create a menu bar + wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF); + + // the "About" item should be in the help menu + wxMenu *helpMenu = new wxMenu; + helpMenu->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog"); + + menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program"); + + // now append the freshly created menu to the menu bar... + wxMenuBar *menuBar = new wxMenuBar(); + menuBar->Append(menuFile, "&File"); + menuBar->Append(helpMenu, "&Help"); + + // ... and attach this menu bar to the frame + SetMenuBar(menuBar); +} + + +// event handlers + +void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) +{ + // TRUE is to force the frame to close + Close(TRUE); +} + +void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) +{ + wxString msg; + msg.Printf( _T("This is the about dialog of tree sample.\n") + _T("Welcome to %s"), wxVERSION_STRING); + + wxMessageBox(msg, "About Tree Test", wxOK | wxICON_INFORMATION, this); +} + +/* + * TesTree + */ + +IMPLEMENT_CLASS(TestTree, wxRemotelyScrolledTreeCtrl) + +BEGIN_EVENT_TABLE(TestTree, wxRemotelyScrolledTreeCtrl) +END_EVENT_TABLE() + +TestTree::TestTree(wxWindow* parent, wxWindowID id, const wxPoint& pt, + const wxSize& sz, long style): + wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style) +{ + m_imageList = new wxImageList(16, 16, TRUE); +#if !defined(__WXMSW__) // || wxUSE_XPM_IN_MSW + m_imageList->Add(wxIcon(icon1_xpm)); + m_imageList->Add(wxIcon(icon2_xpm)); + m_imageList->Add(wxIcon(icon3_xpm)); + m_imageList->Add(wxIcon(icon4_xpm)); + m_imageList->Add(wxIcon(icon5_xpm)); + m_imageList->Add(wxIcon(icon6_xpm)); + m_imageList->Add(wxIcon(icon7_xpm)); + m_imageList->Add(wxIcon(icon8_xpm)); +#elif defined(__WXMSW__) + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_CLOSED_FOLDER"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_OPEN_FOLDER"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_FILE"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_COMPUTER"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_DRIVE"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_CDROM"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_FLOPPY"), wxBITMAP_TYPE_ICO_RESOURCE)); + m_imageList->Add(wxIcon(wxT("wxICON_SMALL_REMOVEABLE"), wxBITMAP_TYPE_ICO_RESOURCE)); +#else +#error "Sorry, we don't have icons available for this platforms." +#endif + SetImageList(m_imageList); + + + // Add some dummy items + wxTreeItemId rootId = AddRoot(_("Root"), 3, -1); + int i; + for (i = 1; i <= 20; i++) + { + wxString label; + label.Printf(wxT("Item %d"), i); + wxTreeItemId id = AppendItem(rootId, label, 0); + SetItemImage( id, 1, wxTreeItemIcon_Expanded ); + + int j; + for (j = 0; j < 10; j++) + AppendItem(id, _("Child"), 2); + } + Expand(rootId); +} + +TestTree::~TestTree() +{ + SetImageList(NULL); + delete m_imageList; +} + +/* + * TestValueWindow + */ + +//IMPLEMENT_CLASS(TestValueWindow, wxWindow) + +BEGIN_EVENT_TABLE(TestValueWindow, wxWindow) + EVT_SIZE(TestValueWindow::OnSize) +END_EVENT_TABLE() + +TestValueWindow::TestValueWindow(wxWindow* parent, wxWindowID id, + const wxPoint& pos, + const wxSize& sz, + long style): + wxWindow(parent, id, pos, sz, style) +{ + SetBackgroundColour(* wxWHITE); +} + +void TestValueWindow::OnSize(wxSizeEvent& event) +{ +} diff --git a/contrib/samples/gizmos/splittree/tree.h b/contrib/samples/gizmos/splittree/tree.h new file mode 100644 index 0000000000..95f9fbbff0 --- /dev/null +++ b/contrib/samples/gizmos/splittree/tree.h @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tree.h +// Purpose: Testing tree functionality +// Author: Julian Smart +// Modified by: +// Created: 04/01/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _TREE_H_ +#define _TREE_H_ + +#include "wx/wx.h" +#include "wx/gizmos/splittree.h" + +class TestValueWindow; + +// Define a new application type, each program should derive a class from wxApp +class MyApp : public wxApp +{ +public: + // override base class virtuals + // ---------------------------- + + // this one is called on application startup and is a good place for the app + // initialization (doing it here and not in the ctor allows to have an error + // return: if OnInit() returns false, the application terminates) + virtual bool OnInit(); +}; + +// Define a new frame type: this is going to be our main frame +class MyFrame : public wxFrame +{ +public: + // ctor(s) + MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size); + + // event handlers (these functions should _not_ be virtual) + void OnQuit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + +protected: + wxRemotelyScrolledTreeCtrl* m_tree; + wxThinSplitterWindow* m_splitter; + wxSplitterScrolledWindow* m_scrolledWindow; + TestValueWindow* m_valueWindow; + +private: + // any class wishing to process wxWindows events must use this macro + DECLARE_EVENT_TABLE() +}; + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +// IDs for the controls and the menu commands +enum +{ + // menu items + Minimal_Quit = 100, + Minimal_About +}; + +#define idTREE_CTRL 2000 +#define idSPLITTER_WINDOW 2001 +#define idVALUE_WINDOW 2002 +#define idMAIN_FRAME 2003 +#define idSCROLLED_WINDOW 2004 + +class TestTree: public wxRemotelyScrolledTreeCtrl +{ + DECLARE_CLASS(TestTree) +public: + TestTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS); + ~TestTree(); + DECLARE_EVENT_TABLE() +protected: + wxImageList* m_imageList; +}; + +class TestValueWindow: public wxWindow +{ +public: + TestValueWindow(wxWindow* parent, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, + long style = 0); + +//// Overrides + +//// Events + void OnSize(wxSizeEvent& event); + +//// Data members +protected: + + DECLARE_EVENT_TABLE() +}; + + + +#endif + // _TREE_H_ diff --git a/contrib/src/gizmos/GizmosVC.dsp b/contrib/src/gizmos/GizmosVC.dsp new file mode 100644 index 0000000000..159f8f6810 --- /dev/null +++ b/contrib/src/gizmos/GizmosVC.dsp @@ -0,0 +1,106 @@ +# Microsoft Developer Studio Project File - Name="GizmosVC" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Static Library" 0x0104 + +CFG=GizmosVC - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "GizmosVC.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "GizmosVC.mak" CFG="GizmosVC - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "GizmosVC - Win32 Release" (based on "Win32 (x86) Static Library") +!MESSAGE "GizmosVC - Win32 Debug" (based on "Win32 (x86) Static Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "GizmosVC - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\..\lib\gizmos.lib" + +!ELSEIF "$(CFG)" == "GizmosVC - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D DEBUG=1 /D "__WXDEBUG__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /FD /c +# SUBTRACT CPP /YX +# ADD BASE RSC /l 0x809 +# ADD RSC /l 0x809 +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LIB32=link.exe -lib +# ADD BASE LIB32 /nologo +# ADD LIB32 /nologo /out:"..\..\lib\gizmosd.lib" + +!ENDIF + +# Begin Target + +# Name "GizmosVC - Win32 Release" +# Name "GizmosVC - Win32 Debug" +# Begin Group "Headers" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\include\wx\gizmos\multicell.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\wx\gizmos\splittree.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\multicell.cpp +# End Source File +# Begin Source File + +SOURCE=.\splittree.cpp +# End Source File +# End Target +# End Project diff --git a/contrib/src/gizmos/GizmosVC.dsw b/contrib/src/gizmos/GizmosVC.dsw new file mode 100644 index 0000000000..5e4bb0e5f6 --- /dev/null +++ b/contrib/src/gizmos/GizmosVC.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "GizmosVC"=.\GizmosVC.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/contrib/src/gizmos/Makefile.in b/contrib/src/gizmos/Makefile.in new file mode 100644 index 0000000000..72048fd583 --- /dev/null +++ b/contrib/src/gizmos/Makefile.in @@ -0,0 +1,23 @@ +# $Id$ + +top_srcdir = @top_srcdir@/.. +top_builddir = ../../.. +libsrc_dir = contrib/src/gizmos + +TARGET_LIBNAME=libgizmos + +LIBVERSION_CURRENT=1 +LIBVERSION_REVISION=0 +LIBVERSION_AGE=0 + +HEADER_PATH=$(top_srcdir)/contrib/include/wx +HEADER_SUBDIR=gizmos + +HEADERS=multicell.h gizmos.h + +OBJECTS=multicell.o gizmos.o + +APPEXTRADEFS=-I$(top_srcdir)/contrib/include + +include $(top_builddir)/src/makelib.env + diff --git a/contrib/src/gizmos/makefile.b32 b/contrib/src/gizmos/makefile.b32 new file mode 100644 index 0000000000..5d67598fa7 --- /dev/null +++ b/contrib/src/gizmos/makefile.b32 @@ -0,0 +1,17 @@ +# +# File: makefile.b32 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: +# +# Makefile : Builds Gizmos library for 32-bit BC++ + +WXDIR = $(WXWIN) + +LIBTARGET=$(WXDIR)\lib\gizmos.lib + +OBJECTS = multicell.obj splittree.obj + +!include $(WXDIR)\src\makelib.b32 + diff --git a/contrib/src/gizmos/makefile.bcc b/contrib/src/gizmos/makefile.bcc new file mode 100644 index 0000000000..21ebb33c2d --- /dev/null +++ b/contrib/src/gizmos/makefile.bcc @@ -0,0 +1,21 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1998 +# Updated: +# +# Builds Gizmos library for BC++, 16-bit + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +WXDIR = $(WXWIN) + +LIBTARGET=$(WXDIR)\lib\gizmos.lib + +OBJECTS = basic.obj basic2.obj canvas.obj ogldiag.obj lines.obj misc.obj divided.obj constrnt.obj\ + composit.obj drawn.obj bmpshape.obj mfutils.obj + +!include $(WXDIR)\src\makelib.bcc + diff --git a/contrib/src/gizmos/makefile.g95 b/contrib/src/gizmos/makefile.g95 new file mode 100644 index 0000000000..b8300a5b3c --- /dev/null +++ b/contrib/src/gizmos/makefile.g95 @@ -0,0 +1,16 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1999 +# Updated: +# Copyright: (c) Julian Smart, 1999 +# +# Makefile for wxWindows Gizmos library Cygwin/Mingw32). + +WXDIR = ../../.. + +LIBTARGET=$(WXDIR)/lib/libgizmos.a +OBJECTS = multicell.o splittree.o + +include $(WXDIR)/src/makelib.g95 + diff --git a/contrib/src/gizmos/makefile.unx b/contrib/src/gizmos/makefile.unx new file mode 100644 index 0000000000..fcf7414d1a --- /dev/null +++ b/contrib/src/gizmos/makefile.unx @@ -0,0 +1,32 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1998 +# Updated: +# Copyright: (c) 1998 +# +# +# Makefile for Gizmos library, Unix + +include ../../src/make.env + +GIZMOSLIB=$(WXDIR)/lib/libgizmos$(GUISUFFIX).a + +LIB_CPP_SRC=\ +\ + multicell.o\ + splittree.o + +all: $(GIZMOSLIB) + +# Define library objects +OBJECTS=\ + $(LIB_CPP_SRC:.cpp=.o) + +$(GIZMOSLIB) : $(OBJECTS) + ar $(AROPTIONS) $@ $(OBJECTS) + $(RANLIB) $@ + +clean: + rm -f $(OBJECTS) $(GIZMOSLIB) + diff --git a/contrib/src/gizmos/makefile.vc b/contrib/src/gizmos/makefile.vc new file mode 100644 index 0000000000..2bcb5886fa --- /dev/null +++ b/contrib/src/gizmos/makefile.vc @@ -0,0 +1,150 @@ + +# File: makefile.vc +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds OGL classes library (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + + +# Set WXDIR for your system +WXDIR = $(WXWIN) +GIZMOSDIR = $(WXDIR)\contrib\src\gizmos +GIZMOSINC = $(WXDIR)\contrib\include\wx\gizmos +THISDIR = $(WXDIR)\contrib\src\gizmos +EXTRAFLAGS=/DPROLOGIO=1 +DOCDIR=$(WXDIR)\contrib\docs +LOCALDOCDIR=$(WXDIR)\contrib\docs\latex\gizmos + +!include $(WXDIR)\src\makevc.env + +OBJECTS = $(D)\multicell.obj $(D)\splittree.obj + +LIBTARGET=$(WXDIR)\lib\gizmos$(LIBEXT).lib + +all: $(D) $(LIBTARGET) + +$(D) : + mkdir $(D) + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.vc FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.vc clean + cd $(THISDIR) + +$(LIBTARGET): $(OBJECTS) + -erase $(LIBTARGET) + $(implib) @<< +-out:$(LIBTARGET) +-machine:$(CPU) +$(OBJECTS) +<< + +$(D)\multicell.obj: multicell.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF) +<< + +$(D)\splittree.obj: splittree.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Fo$@ /Tp $(*B).$(SRCSUFF) +<< + +clean: + -erase $(D)\*.obj + -erase *.sbr + -erase *.exe + -erase *.res + -erase *.map + -erase *.pdb + -erase $(LIBTARGET) + +DOCSOURCES=$(LOCALDOCDIR)\gizmos.tex \ + $(LOCALDOCDIR)\bugs.tex $(LOCALDOCDIR)\changes.tex\ + $(LOCALDOCDIR)\classes.tex $(LOCALDOCDIR)\intro.tex\ + $(LOCALDOCDIR)\topics.tex $(LOCALDOCDIR)\sample.tex + +html: $(DOCDIR)\html\gizmos\gizmos.htm +htmlhelp: $(DOCDIR)\htmlhelp\gizmos.chm +htb: $(DOCDIR)\htb\gizmos.htb +hlp: $(DOCDIR)\winhelp\gizmos.hlp +pdfrtf: $(DOCDIR)\pdf\gizmos.rtf +ps: $(DOCDIR)\ps\gizmos.ps + +touchmanual: + touch $(LOCALDOCDIR)\gizmos.tex + + +$(DOCDIR)\winhelp\gizmos.hlp: $(LOCALDOCDIR)\gizmos.rtf $(LOCALDOCDIR)\gizmos.hpj + cd $(LOCALDOCDIR) + -erase gizmos.ph + hc gizmos + move gizmos.hlp $(DOCDIR)\winhelp\gizmos.hlp + move gizmos.cnt $(DOCDIR)\winhelp\gizmos.cnt + cd $(THISDIR) + +$(LOCALDOCDIR)\gizmos.rtf: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -start $(WAITFLAG) tex2rtf $(LOCALDOCDIR)\gizmos.tex $(LOCALDOCDIR)\gizmos.rtf -twice -winhelp + cd $(THISDIR) + +$(DOCDIR)\pdf\gizmos.rtf: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -copy *.bmp $(DOCDIR)\pdf + -start $(WAITFLAG) tex2rtf $(LOCALDOCDIR)\gizmos.tex $(DOCDIR)\pdf\gizmos.rtf -twice -rtf + cd $(THISDIR) + +$(DOCDIR)\html\gizmos\gizmos.htm: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -mkdir $(DOCDIR)\html\gizmos + copy *.gif $(DOCDIR)\html\gizmos + -start $(WAITFLAG) tex2rtf $(LOCALDOCDIR)\gizmos.tex $(DOCDIR)\html\gizmos\gizmos.htm -twice -html + -erase $(DOCDIR)\html\gizmos\*.con + -erase *.con + -erase $(DOCDIR)\html\gizmos\*.ref + cd $(THISDIR) + +$(DOCDIR)\htmlhelp\gizmos.chm: $(DOCDIR)\html\gizmos\gizmos.htm $(DOCDIR)\html\gizmos\gizmos.hhp + cd $(DOCDIR)\html\gizmos + -hhc gizmos.hhp + move gizmos.chm $(DOCDIR)\htmlhelp\gizmos.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\gizmos.htb: $(DOCDIR)\html\gizmos\gizmos.htm + cd $(DOCDIR)\html\gizmos + -erase /Y gizmos.zip gizmos.htb + zip32 gizmos.zip *.htm *.gif *.hhp *.hhc *.hhk + -mkdir $(DOCDIR)\htb + move gizmos.zip $(DOCDIR)\htb\gizmos.htb + cd $(THISDIR) + +$(LOCALDOCDIR)\gizmos.dvi: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -latex gizmos + -latex gizmos + -makeindx gizmos + -bibtex gizmos + -latex gizmos + -latex gizmos + cd $(THISDIR) + +$(WXDIR)\docs\ps\gizmos.ps: $(LOCALDOCDIR)\gizmos.dvi + cd $(LOCALDOCDIR) + -dvips32 -o gizmos.ps gizmos + move gizmos.ps $(WXDIR)\docs\ps\gizmos.ps + cd $(THISDIR) + diff --git a/contrib/src/gizmos/makefile.wat b/contrib/src/gizmos/makefile.wat new file mode 100644 index 0000000000..3d44de34ab --- /dev/null +++ b/contrib/src/gizmos/makefile.wat @@ -0,0 +1,22 @@ +# Gizmos makefile for Watcom C++ + +WXDIR = ..\..\.. + +!include $(WXDIR)\src\makewat.env + +GIZMOSLIB = $(WXDIR)\lib\gizmos.lib +THISDIR = $(WXDIR)\contrib\src\gizmos + +NAME = gizmos +LNK = $(name).lnk + +OBJECTS = multicell.obj splittree.obj + +all: $(GIZMOSLIB) + +$(GIZMOSLIB): $(OBJECTS) + *wlib /b /c /n /P=256 $(GIZMOSLIB) $(OBJECTS) + +clean: .SYMBOLIC + -erase *.obj *.bak *.err *.pch $(GIZMOSLIB) *.lbc + diff --git a/contrib/src/gizmos/multicell.cpp b/contrib/src/gizmos/multicell.cpp new file mode 100644 index 0000000000..b5c70dd8e6 --- /dev/null +++ b/contrib/src/gizmos/multicell.cpp @@ -0,0 +1,670 @@ +///////////////////////////////////////////////////////////////////////////// +// 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 + +#ifdef __GNUG__ + #pragma implementation "multicell.h" +#endif + +// 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, wxRect); + +//--------------------------------------------------------------------------- +// 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); +} +//--------------------------------------------------------------------------- +wxMultiCellItemHandle :: wxMultiCellItemHandle( int row, int column, int align) +{ + Initialize(row, column, 1, 1, wxSize(1,1), wxNOT_RESIZABLE, wxSize(1, 1), align); +} + +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetColumn() +{ + return m_column; +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetRow() +{ + return m_row; +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetWidth() +{ + return m_width; +} +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle::GetHeight() +{ + return m_height; +} +//--------------------------------------------------------------------------- +wxResizable wxMultiCellItemHandle :: GetStyle() +{ + return m_style; +}; +//--------------------------------------------------------------------------- +wxSize wxMultiCellItemHandle :: GetLocalSize() +{ + return m_fixedSize; +}; +//--------------------------------------------------------------------------- +int wxMultiCellItemHandle :: GetAlignment() +{ + return m_alignment; +}; +//--------------------------------------------------------------------------- +wxSize wxMultiCellItemHandle :: GetWeight() +{ + 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() +{ + m_children.DeleteContents(TRUE); + + 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(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; + + wxNode *current; + current = m_children.GetFirst(); + while (current != NULL) + { + wxSizerItem *item = (wxSizerItem*) current->Data(); + + 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() != wxDefaultSize.GetHeight() || + c_size.GetWidth() != wxDefaultSize.GetWidth()) + { + minSize.SetHeight(wxMax(minSize.GetHeight(), c_size.GetHeight())); + minSize.SetWidth(wxMax(minSize.GetWidth(), c_size.GetWidth())); + } + if (rect->GetStyle() & wxHORIZENTAL_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->Next(); + } +} +//--------------------------------------------------------------------------- +wxSize wxMultiCellSizer::CalcMin() +{ + if (m_children.GetCount() == 0) + return wxSize(10,10); + + int m_minWidth = 0; + int m_minHeight = 0; + + GetMinimums(); + m_minWidth = Sum(m_maxWidth, m_cell_count.GetWidth()); + 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); + } + + wxNode *node = m_children.GetFirst(); + while (node) + { + wxSizerItem *item = (wxSizerItem*) node->Data(); + 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() != wxDefaultSize.GetHeight() || + c_size.GetWidth() != wxDefaultSize.GetWidth()) + { + 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() & wxHORIZENTAL_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->Next(); + } + } +} // 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 + * + */ + +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); +} +//--------------------------------------------------------------------------- +wxString itoa(int x) +{ + char bfr[255]; + sprintf(bfr, "%d", x); + return bfr; +} +//--------------------------------------------------------------------------- +void wxMultiCellCanvas :: Add(wxWindow *win, unsigned int row, unsigned int col) +{ + wxASSERT_MSG(row >= 0 && row < m_maxRows, wxString("Row ") + itoa(row) + " out of bounds (" + itoa(m_maxRows) + ")"); + wxASSERT_MSG(col >= 0 && col < m_maxCols, wxString("Column ") + itoa(col) + " out of bounds (" + itoa(m_maxCols) + ")"); + wxASSERT_MSG(m_cells[CELL_LOC(row, col)] == NULL, "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, -1, "")); + } + wxFlexGridSizer::Add(m_cells[CELL_LOC(row, col)]->m_window); + } + } +} + +/*** End of File ***/ diff --git a/contrib/src/gizmos/multicell.txt b/contrib/src/gizmos/multicell.txt new file mode 100644 index 0000000000..5de8cb27a2 --- /dev/null +++ b/contrib/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/contrib/src/gizmos/multicell_todo.txt b/contrib/src/gizmos/multicell_todo.txt new file mode 100644 index 0000000000..8e07fdc016 --- /dev/null +++ b/contrib/src/gizmos/multicell_todo.txt @@ -0,0 +1,2 @@ +2. Documentation + diff --git a/contrib/src/gizmos/splittree.cpp b/contrib/src/gizmos/splittree.cpp new file mode 100644 index 0000000000..6d8da5bcd4 --- /dev/null +++ b/contrib/src/gizmos/splittree.cpp @@ -0,0 +1,529 @@ +///////////////////////////////////////////////////////////////////////////// +// 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 +// ---------------------------------------------------------------------------- +#ifdef __GNUG__ + #pragma interface "splittree.cpp" +#endif + +// 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" wxWindows headers) +#ifndef WX_PRECOMP + #include "wx/wx.h" +#endif + +#include "wx/generic/treectlg.h" + +#include "wx/gizmos/splittree.h" + +/* + * 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(-1, wxRemotelyScrolledTreeCtrl::OnExpand) + EVT_TREE_ITEM_COLLAPSED(-1, 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) +{ +} + +wxRemotelyScrolledTreeCtrl::~wxRemotelyScrolledTreeCtrl() +{ +} + +void wxRemotelyScrolledTreeCtrl::HideVScrollbar() +{ +#ifdef __WXMSW__ + if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + ::ShowScrollBar((HWND) GetHWND(), SB_VERT, FALSE); + } + else +#endif + { + // Implicit in overriding SetScrollbars + } +} + +// 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(int pixelsPerUnitX, int pixelsPerUnitY, + int noUnitsX, int noUnitsY, + int xPos, int yPos, + bool noRefresh) +{ + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; + win->wxGenericTreeCtrl::SetScrollbars(pixelsPerUnitX, 0, noUnitsX, 0, xPos, 0, noRefresh); + + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + if (scrolledWindow) + { + scrolledWindow->SetScrollbars(0, pixelsPerUnitY, 0, noUnitsY, 0, yPos, noRefresh); + } + } +} + +// In case we're using the generic tree control. +// Get the view start +void wxRemotelyScrolledTreeCtrl::GetViewStart(int *x, int *y) const +{ + if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + + 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; + } +} + +// In case we're using the generic tree control. +void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc) +{ + 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( m_scaleX, m_scaleY ); + } +} + +// Scroll to the given line (in scroll units where each unit is +// the height of an item) +void wxRemotelyScrolledTreeCtrl::ScrollToLine(int posHoriz, int posVert) +{ +#ifdef __WXMSW__ + if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + { + UINT sbCode = SB_THUMBPOSITION; + HWND vertScrollBar = 0; + MSWDefWindowProc((WXUINT) WM_VSCROLL, MAKELONG(sbCode, posVert), (WXHWND) vertScrollBar); + } + else +#endif + { + 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); + } + */ + } +} + +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(); +} + +// Adjust the containing wxScrolledWindow's scrollbars appropriately +void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars() +{ + // WILL THIS BE DONE AUTOMATICALLY BY THE GENERIC TREE CONTROL? +/* + +Problem with remote-scrolling the generic tree control. It relies +on PrepareDC for adjusting the device origin, which in turn takes +values from wxScrolledWindow: which we've turned off in order to use +a different scrollbar :-( So we could override PrepareDC and use +the _other_ scrolled window's position instead. +Note also ViewStart would need to be overridden. +Plus, wxGenericTreeCtrl::OnPaint will reset the device origin. + +*/ + + // Assumption: wxGenericTreeCtrl will adjust the scrollbars automatically, + // since it'll call SetScrollbars and we've defined this to Do The Right Thing. + if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) + return; + + wxScrolledWindow* scrolledWindow = GetScrolledWindow(); + if (scrolledWindow) + { + wxRect itemRect; + if (GetBoundingRect(GetRootItem(), itemRect)) + { + int itemHeight = itemRect.GetHeight(); + + int w, h; + GetClientSize(&w, &h); + + wxRect rect(0, 0, 0, 0); + CalcTreeSize(rect); + int treeViewHeight = rect.GetHeight()/itemHeight; + + 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(wxTreeItemId& id, wxRect& rect) +{ + // TODO: implement GetFirst/NextVisibleItem + // for wxGenericTreeCtrl, plus GetBoundingRect. + + // 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); + } + + long cookie; + wxTreeItemId childId = GetFirstChild(id, cookie); + while (childId != 0) + { + 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::OnPaint(wxPaintEvent& event) +{ + wxPaintDC dc(this); + + wxTreeCtrl::OnPaint(event); + + // Reset the device origin since it may have been set + dc.SetDeviceOrigin(0, 0); + + wxSize sz = GetClientSize(); + + wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID); + dc.SetPen(pen); + dc.SetBrush(* wxTRANSPARENT_BRUSH); + + wxRect itemRect; + if (GetBoundingRect(GetRootItem(), itemRect)) + { + int itemHeight = itemRect.GetHeight(); + wxRect rcClient = GetRect(); + int cy=0; + wxTreeItemId h; + for(h=GetFirstVisibleItem();h;h=GetNextVisible(h)) + { + dc.DrawLine(rcClient.x, cy, rcClient.x + rcClient.width, cy); + cy += itemHeight; + } + dc.DrawLine(rcClient.x, cy, rcClient.x + rcClient.width, cy); + } +} + +void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event) +{ + int orient = event.GetOrientation(); + if (orient == wxHORIZONTAL) + { + // Don't 'skip' or we'd get into infinite recursion + return; + } + wxScrolledWindow* scrollWin = GetScrolledWindow(); + if (!scrollWin) + return; + + int x, y; + scrollWin->GetViewStart(& x, & y); + + ScrollToLine(-1, y); +} + +/* + * 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) +{ +} + +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 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, m_sashSize, 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, m_sashSize); + } + + 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& event) +{ + wxSize sz = GetClientSize(); + if (GetChildren().First()) + { + ((wxWindow*) GetChildren().First()->Data())->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) + return; + inOnScroll = TRUE; + + int orient = event.GetOrientation(); + + int nScrollInc = CalcScrollInc(event); + if (nScrollInc == 0) + { + inOnScroll = FALSE; + return; + } + + if (orient == wxHORIZONTAL) + { + int newPos = m_xScrollPosition + nScrollInc; + SetScrollPos(wxHORIZONTAL, newPos, TRUE ); + } + 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 + wxNode* node = GetChildren().First(); + while (node) + { + wxWindow* child = (wxWindow*) node->Data(); + 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->Next(); + } + +#ifdef __WXMAC__ + m_targetWindow->MacUpdateImmediately() ; +#endif + + inOnScroll = FALSE; +} + -- 2.45.2