kdgantt

KDGanttMinimizeSplitter.h
1/*
2 $Id$
3*/
4
5/****************************************************************************
6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 **
8 ** This file is part of the KDGantt library.
9 **
10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file.
14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements.
24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you.
27 **
28 ** As a special exception, permission is given to link this program
29 ** with any edition of TQt, and distribute the resulting executable,
30 ** without including the source code for TQt in the source distribution.
31 **
32 **********************************************************************/
33
34#ifndef KDGANTTMINIMIZESPLITTER_H
35#define KDGANTTMINIMIZESPLITTER_H
36
37#include "tqframe.h"
38#include "tqvaluelist.h"
39
40class TQSplitterData;
41class TQSplitterLayoutStruct;
42
43class KDGanttMinimizeSplitter : public TQFrame
44{
45 TQ_OBJECT
46
47 TQ_ENUMS( Direction )
48 TQ_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
50
51public:
52 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
53 enum Direction { Left, Right, Up, Down };
54
55 KDGanttMinimizeSplitter( TQWidget* parent=0, const char* name=0 );
56 KDGanttMinimizeSplitter( TQt::Orientation, TQWidget* parent=0, const char* name=0 );
58
59 virtual void setOrientation( TQt::Orientation );
60 TQt::Orientation orientation() const { return orient; }
61
64
65 virtual void setResizeMode( TQWidget *w, ResizeMode );
66 virtual void setOpaqueResize( bool = TRUE );
67 bool opaqueResize() const;
68
69 void moveToFirst( TQWidget * );
70 void moveToLast( TQWidget * );
71
72 void refresh() { recalc( TRUE ); }
73 virtual TQSize sizeHint() const;
74 virtual TQSize minimumSizeHint() const;
75
76 TQValueList<int> sizes() const;
77 void setSizes( TQValueList<int> );
78
79 void expandPos( int id, int* min, int* max );
80protected:
81 void childEvent( TQChildEvent * );
82
83 bool event( TQEvent * );
84 void resizeEvent( TQResizeEvent * );
85
86 int idAfter( TQWidget* ) const;
87
88 void moveSplitter( TQCOORD pos, int id );
89 virtual void drawSplitter( TQPainter*, TQCOORD x, TQCOORD y,
90 TQCOORD w, TQCOORD h );
91 void styleChange( TQStyle& );
92 int adjustPos( int , int );
93 virtual void setRubberband( int );
94 void getRange( int id, int*, int* );
95
96private:
97 void init();
98 void recalc( bool update = FALSE );
99 void doResize();
100 void storeSizes();
101 void processChildEvents();
102 TQSplitterLayoutStruct *addWidget( TQWidget*, bool first = FALSE );
103 void recalcId();
104 void moveBefore( int pos, int id, bool upLeft );
105 void moveAfter( int pos, int id, bool upLeft );
106 void setG( TQWidget *w, int p, int s, bool isSplitter = FALSE );
107
108 TQCOORD pick( const TQPoint &p ) const
109 { return orient == TQt::Horizontal ? p.x() : p.y(); }
110 TQCOORD pick( const TQSize &s ) const
111 { return orient == TQt::Horizontal ? s.width() : s.height(); }
112
113 TQCOORD trans( const TQPoint &p ) const
114 { return orient == TQt::Vertical ? p.x() : p.y(); }
115 TQCOORD trans( const TQSize &s ) const
116 { return orient == TQt::Vertical ? s.width() : s.height(); }
117
118 TQSplitterData *data;
119
120private:
121 TQt::Orientation orient;
122 Direction _direction;
123#ifndef DOXYGEN_SKIP_INTERNAL
124 friend class KDGanttSplitterHandle;
125#endif
126private: // Disabled copy constructor and operator=
127#if defined(TQ_DISABLE_COPY)
130#endif
131};
132
133#ifndef DOXYGEN_SKIP_INTERNAL
134// This class was continued from a verbatim copy of the
135// TQSplitterHandle pertaining to the TQt Enterprise License and the
136// GPL. It has only been renamed to KDGanttSplitterHandler in order to
137// avoid a symbol clash on some platforms.
138class KDGanttSplitterHandle : public TQWidget
139{
140 TQ_OBJECT
141
142public:
143 KDGanttSplitterHandle( TQt::Orientation o,
144 KDGanttMinimizeSplitter *parent, const char* name=0 );
145 void setOrientation( TQt::Orientation o );
146 TQt::Orientation orientation() const { return orient; }
147
148 bool opaque() const { return s->opaqueResize(); }
149
150 TQSize sizeHint() const;
151
152 int id() const { return myId; } // data->list.at(id())->wid == this
153 void setId( int i ) { myId = i; }
154
155protected:
156 TQValueList<TQPointArray> buttonRegions();
157 void paintEvent( TQPaintEvent * );
158 void mouseMoveEvent( TQMouseEvent * );
159 void mousePressEvent( TQMouseEvent * );
160 void mouseReleaseEvent( TQMouseEvent * );
161 int onButton( const TQPoint& p );
162 void updateCursor( const TQPoint& p );
163
164private:
165 TQt::Orientation orient;
166 bool opaq;
167 int myId;
168
170 int _activeButton;
171 bool _collapsed;
172 int _origPos;
173};
174#endif
175
176#endif // KDGANTTMINIMIZESPLITTER_H
The KDGanttMinimizeSplitter class implements a splitter widget with minimize buttons.
KDGanttMinimizeSplitter(TQWidget *parent=0, const char *name=0)
void setSizes(TQValueList< int >)
TQValueList< int > sizes() const
virtual void setOrientation(TQt::Orientation)
the orientation of the splitter
virtual void setOpaqueResize(bool=TRUE)
virtual void setResizeMode(TQWidget *w, ResizeMode)
void moveSplitter(TQCOORD pos, int id)
void resizeEvent(TQResizeEvent *)
virtual TQSize minimumSizeHint() const
void getRange(int id, int *, int *)
virtual void drawSplitter(TQPainter *, TQCOORD x, TQCOORD y, TQCOORD w, TQCOORD h)
TQt::Orientation orientation() const