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
40#ifndef TQT_NO_SPLITTER
41
42class TQSplitterData;
43class KDGanttSplitterLayoutStruct;
44
45class KDGanttMinimizeSplitter : public TQFrame
46{
47 TQ_OBJECT
48
49 TQ_ENUMS( Direction )
50 TQ_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
52
53public:
54 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
55 enum Direction { Left, Right, Up, Down };
56
57 KDGanttMinimizeSplitter( TQWidget* parent=0, const char* name=0 );
58 KDGanttMinimizeSplitter( Orientation, TQWidget* parent=0, const char* name=0 );
60
61 virtual void setOrientation( Orientation );
62 Orientation orientation() const { return orient; }
63
64 void setMinimizeDirection( Direction );
65 Direction minimizeDirection() const;
66
67 virtual void setResizeMode( TQWidget *w, ResizeMode );
68 virtual void setOpaqueResize( bool = true );
69 bool opaqueResize() const;
70
71 void moveToFirst( TQWidget * );
72 void moveToLast( TQWidget * );
73
74 void refresh() { recalc( true ); }
75 virtual TQSize sizeHint() const;
76 virtual TQSize minimumSizeHint() const;
77
78 TQValueList<int> sizes() const;
79 void setSizes( TQValueList<int> );
80
81 void expandPos( int id, int* min, int* max );
82protected:
83 void childEvent( TQChildEvent * );
84
85 bool event( TQEvent * );
86 void resizeEvent( TQResizeEvent * );
87
88 int idAfter( TQWidget* ) const;
89
90 void moveSplitter( TQCOORD pos, int id );
91 virtual void drawSplitter( TQPainter*, TQCOORD x, TQCOORD y,
92 TQCOORD w, TQCOORD h );
93 void styleChange( TQStyle& );
94 int adjustPos( int , int );
95 virtual void setRubberband( int );
96 void getRange( int id, int*, int* );
97
98private:
99 void init();
100 void recalc( bool update = false );
101 void doResize();
102 void storeSizes();
103 void processChildEvents();
104 KDGanttSplitterLayoutStruct *addWidget( TQWidget*, bool first = false );
105 void recalcId();
106 void moveBefore( int pos, int id, bool upLeft );
107 void moveAfter( int pos, int id, bool upLeft );
108 void setG( TQWidget *w, int p, int s, bool isSplitter = false );
109
110 TQCOORD pick( const TQPoint &p ) const
111 { return orient ==TQt::Horizontal ? p.x() : p.y(); }
112 TQCOORD pick( const TQSize &s ) const
113 { return orient ==TQt::Horizontal ? s.width() : s.height(); }
114
115 TQCOORD trans( const TQPoint &p ) const
116 { return orient ==TQt::Vertical ? p.x() : p.y(); }
117 TQCOORD trans( const TQSize &s ) const
118 { return orient ==TQt::Vertical ? s.width() : s.height(); }
119
120 TQSplitterData *data;
121
122private:
123 Orientation orient;
124 Direction _direction;
125#ifndef DOXYGEN_SKIP_INTERNAL
126 friend class KDGanttSplitterHandle;
127#endif
128private: // Disabled copy constructor and operator=
129#if defined(TQ_DISABLE_COPY)
132#endif
133};
134
135#ifndef DOXYGEN_SKIP_INTERNAL
136// This class was continued from a verbatim copy of the
137// TQSplitterHandle pertaining to the TQt Enterprise License and the
138// GPL. It has only been renamed to KDGanttSplitterHandler in order to
139// avoid a symbol clash on some platforms.
140class KDGanttSplitterHandle : public TQWidget
141{
142 TQ_OBJECT
143
144public:
145 KDGanttSplitterHandle( Orientation o,
146 KDGanttMinimizeSplitter *parent, const char* name=0 );
147 void setOrientation( Orientation o );
148 Orientation orientation() const { return orient; }
149
150 bool opaque() const { return s->opaqueResize(); }
151
152 TQSize sizeHint() const;
153
154 int id() const { return myId; } // data->list.at(id())->wid == this
155 void setId( int i ) { myId = i; }
156
157protected:
158 TQValueList<TQPointArray> buttonRegions();
159 void paintEvent( TQPaintEvent * );
160 void mouseMoveEvent( TQMouseEvent * );
161 void mousePressEvent( TQMouseEvent * );
162 void mouseReleaseEvent( TQMouseEvent * );
163 int onButton( const TQPoint& p );
164 void updateCursor( const TQPoint& p );
165
166private:
167 Orientation orient;
168 bool opaq;
169 int myId;
170
171 KDGanttMinimizeSplitter *s;
172 int _activeButton;
173 bool _collapsed;
174 int _origPos;
175};
176#endif
177
178#endif // TQT_NO_SPLITTER
179
180#endif // KDGANTTMINIMIZESPLITTER_H
KDGanttMinimizeSplitter(TQWidget *parent=0, const char *name=0)
void setSizes(TQValueList< int >)
TQValueList< int > sizes() const
virtual void setOpaqueResize(bool=true)
virtual void setResizeMode(TQWidget *w, ResizeMode)
void moveSplitter(TQCOORD pos, int id)
virtual void setOrientation(Orientation)
the orientation of the splitter
virtual TQSize minimumSizeHint() const
void getRange(int id, int *, int *)
virtual void drawSplitter(TQPainter *, TQCOORD x, TQCOORD y, TQCOORD w, TQCOORD h)