1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
/* -*- Mode: C++ -*-
$Id$
KDGantt - a multi-platform charting engine
*/
/****************************************************************************
** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
**
** This file is part of the KDGantt library.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid commercial KDGantt licenses may use this file in
** accordance with the KDGantt Commercial License Agreement provided with
** the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
** information about KDGantt Commercial License Agreements.
**
** Contact info@klaralvdalens-datakonsult.se if any conditions of this
** licensing are not clear to you.
**
** As a special exception, permission is given to link this program
** with any edition of TQt, and distribute the resulting executable,
** without including the source code for TQt in the source distribution.
**
**********************************************************************/
#ifndef KDGANTTVIEWSUBWIDGETS_H
#define KDGANTTVIEWSUBWIDGETS_H
#include <tqwidget.h>
#include <tqlistview.h>
#include <tqsplitter.h>
#include <tqevent.h>
#include <tqvaluelist.h>
#include <tqcanvas.h>
#include <tqwhatsthis.h>
#include <tqpopupmenu.h>
#include <tqtooltip.h>
#include <tqtimer.h>
#include <tqgroupbox.h>
#include <tqvgroupbox.h>
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqbrush.h>
#include <tqvbox.h>
#include <tqdockwindow.h>
#include <tqtimer.h>
#include "KDGanttView.h"
#include "KDGanttViewTaskLink.h"
#include "KDGanttViewTaskLinkGroup.h"
#include "KDGanttViewSummaryItem.h"
#include "KDGanttSemiSizingControl.h"
#include "KDGanttViewItemDrag.h"
#define Type_is_KDGanttGridItem 1
#define Type_is_KDGanttViewItem 2
#define Type_is_KDGanttTaskLink 3
class KDIntervalColorRectangle;
class KDCanvasWhatsThis;
class KDToolTip;
class KDCanvasRectangle;
class KDTimeHeaderToolTip;
class KDTimeHeaderWidget : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
typedef KDGanttView::Scale Scale;
typedef KDGanttView::YearFormat YearFormat;
typedef KDGanttView::HourFormat HourFormat;
struct DateTimeColor {
TQDateTime datetime;
TQDateTime end;
TQColor color;
Scale minScaleView;
Scale maxScaleView;
//KDCanvasLine* canvasLine;
KDCanvasRectangle* canvasRect;
};
typedef TQValueList<DateTimeColor> ColumnColorList;
typedef TQValueList<KDIntervalColorRectangle *> IntervalColorList;
/*
enum Scale { Minute, Hour, Day, Week, Month, Auto };
enum YearFormat { FourDigit, TwoDigit, TwoDigitApostrophe };
enum HourFormat { Hour_24, Hour_12 };
*/
KDTimeHeaderWidget (TQWidget* tqparent,KDGanttView* gant);
~KDTimeHeaderWidget();
TQString getToolTipText(TQPoint p);
void zoomToFit();
void zoom(double, bool absolute = true);
void zoomToSelection( TQDateTime startTime, TQDateTime endTime);
double zoomFactor();
void setAutoScaleMinorTickCount( int count );
int autoScaleMinorTickCount();
void setHorizonStart( const TQDateTime& start );
TQDateTime horizonStart() const;
void setHorizonEnd( const TQDateTime& start );
TQDateTime horizonEnd() const;
void setMaximumScale( Scale );
KDTimeHeaderWidget::Scale maximumScale() const;
void setMinimumScale( Scale );
KDTimeHeaderWidget::Scale minimumScale() const;
KDTimeHeaderWidget::Scale scale() const;
void setMajorScaleCount( int count );
int majorScaleCount() const;
void setMinorScaleCount( int count );
int minorScaleCount() const;
void setMinimumColumnWidth( int width );
int minimumColumnWidth() const;
void setYearFormat( YearFormat format );
KDTimeHeaderWidget::YearFormat yearFormat() const;
void setHourFormat( HourFormat format );
KDTimeHeaderWidget::HourFormat hourFormat() const;
void setShowMajorTicks( bool );
bool showMajorTicks() const;
void setShowMinorTicks( bool );
void setScale( Scale unit);
bool showMinorTicks() const;
void setColumnBackgroundColor( const TQDateTime& column,
const TQColor& color,
Scale mini = KDGanttView::Minute ,
Scale maxi = KDGanttView::Month);
#if 0
// This API has been replaced with KDIntervalColorRectangle and addIntervalBackgroundColor
void setIntervalBackgroundColor( const TQDateTime& start,
const TQDateTime& end,
const TQColor& color,
Scale mini = KDGanttView::Minute ,
Scale maxi = KDGanttView::Month);
bool changeBackgroundInterval( const TQDateTime& oldstart,
const TQDateTime& oldend,
const TQDateTime& newstart,
const TQDateTime& newend );
bool deleteBackgroundInterval( const TQDateTime& start,
const TQDateTime& end );
#endif
void addIntervalBackgroundColor( KDIntervalColorRectangle* newItem );
void clearBackgroundColor();
TQColor columnBackgroundColor( const TQDateTime& column ) const;
void setWeekendBackgroundColor( const TQColor& color );
TQColor weekendBackgroundColor() const;
void setWeekdayBackgroundColor( const TQColor& color, int weekday );
TQColor weekdayBackgroundColor(int weekday) const;
void setWeekendDays( int start, int end );
void weekendDays( int& start, int& end ) const;
void computeTicks(bool doNotComputeRealScale = false);
void paintEvent(TQPaintEvent *);
int getCoordX(TQDate);
int getCoordX(TQDateTime);
TQDateTime getDateTimeForIndex(int coordX, bool local = true );
void setShowPopupMenu( bool show, bool showZoom, bool showScale,bool showTime,
bool showYear,bool showGrid, bool showPrint);
bool registerStartTime();
bool registerEndTime();
bool showPopupMenu() const;
ColumnColorList columnBackgroundColorList() const {
return ccList;
}
TQColor weekdayColor[8];
void repaintMe(int left, int wid, TQPainter *p = 0);
void centerDateTime( const TQDateTime& center );
public slots:
void setSettings(int);
void checkWidth( int );
void addTickRight( int num = 1 );
void addTickLeft( int num = 1 );
void preparePopupMenu();
signals:
void sizeChanged( int );
private:
friend class KDTimeTableWidget;
friend class KDGanttViewItem;
friend class KDGanttView;
friend class KDGanttCanvasView; // calls computeIntervals
virtual void mousePressEvent ( TQMouseEvent * e );
virtual void mouseReleaseEvent ( TQMouseEvent * e );
virtual void mouseDoubleClickEvent ( TQMouseEvent * e );
virtual void mouseMoveEvent ( TQMouseEvent * e );
double secsFromTo( TQDateTime begin, TQDateTime end );
void updateTimeTable();
void computeIntervals( int height );
bool getColumnColor(TQColor& col,int coordLow, int coordHigh);
void moveTimeLineTo(int x);
//void mousePressEvent ( TQMouseEvent * ) ;
void resizeEvent ( TQResizeEvent * ) ;
TQValueList<int> majorTicks;
TQValueList<TQString> minorText;
TQValueList<TQString> majorText;
TQDateTime myHorizonStart, myHorizonEnd, myRealEnd,myRealStart;
TQDateTime myCenterDateTime;
void saveCenterDateTime();
Scale myScale,myRealScale,myMaxScale,myMinScale;
YearFormat myYearFormat;
HourFormat myHourFormat;
int myMinimumColumWidth;
bool flagShowMajorTicks, flagShowMinorTicks, flagShowPopupMenu;
bool flagShowZoom, flagShowScale ,flagShowTime ,flagShowYear;
bool flagShowGrid ,flagShowPrint;
bool flagStartTimeSet,flagEndTimeSet;
TQColor myWeekendBackgroundColor;
int myWeekendDaysStart, myWeekendDaysEnd;
ColumnColorList ccList;
IntervalColorList icList;
int myMinorScaleCount,myMajorScaleCount;
int myRealMinorScaleCount,myRealMajorScaleCount;
bool flagDoNotRecomputeAfterChange,flagDoNotRepaintAfterChange;
TQString getYear(TQDate);
TQString getHour(TQTime);
TQDateTime getEvenTimeDate(TQDateTime ,Scale);
void computeRealScale(TQDateTime start);
int myGridMinorWidth;
int myMajorGridHeight;
TQPopupMenu * myPopupMenu, *scalePopupMenu, *timePopupMenu;
TQPopupMenu * yearPopupMenu, *gridPopupMenu;
KDGanttView* myGanttView;
double myZoomFactor;
int myAutoScaleMinorTickcount;
bool flagZoomToFit;
int mySizeHint;
int myMinimumWidth;
int getTickTime();
KDTimeHeaderToolTip* myToolTip;
bool mouseDown;
int beginMouseDown;
int endMouseDown;
bool autoComputeTimeLine;
TQPixmap paintPix;
};
/* KDTimeTableWidget */
class KDListView ;
class KDTimeTableWidget : public TQCanvas
{
Q_OBJECT
TQ_OBJECT
public:
KDTimeTableWidget (TQWidget* tqparent,KDGanttView* my);
void setBlockUpdating( bool block = true );
bool blockUpdating();
void inc_blockUpdating();
void dec_blockUpdating();
void setShowTaskLinks( bool show );
bool showTaskLinks();
TQPtrList<KDGanttViewTaskLink>taskLinks();
void clearTaskLinks();
void updateMyContent();
void removeItemFromTasklinks( KDGanttViewItem * );
void setHorBackgroundLines( int count, TQBrush brush );
int horBackgroundLines( TQBrush& brush );
void setNoInformationBrush( const TQBrush& brush );
TQBrush noInformationBrush() const;
int getCoordX( TQDateTime dt );
signals:
void heightComputed( int );
public slots:
void expandItem(TQListViewItem * );
void collapseItem(TQListViewItem * );
void highlightItem(TQListViewItem * );
void resetWidth( int );
void checkHeight( int );
private:
friend class KDGanttViewTaskLink;
friend class KDTimeHeaderWidget;
friend class KDGanttView;
friend class KDGanttViewTaskItem;
KDGanttView* myGanttView;
bool taskLinksVisible;
TQPtrList<KDGanttViewTaskLink> myTaskLinkList;
TQPtrList<KDCanvasLine> verGridList;
TQPtrList<KDCanvasLine> horGridList;
TQPtrList<KDCanvasRectangle> horDenseList;
TQPtrList<KDCanvasRectangle> showNoInfoList;
int denseLineCount;
TQBrush denseLineBrush, noInfoLineBrush;
TQPtrList<KDCanvasRectangle> columnColorList;
int computeHeight();
void computeVerticalGrid();
void computeHorizontalGrid();
void computeDenseLines();
void computeShowNoInformation();
void computeTaskLinks();
void computeMinorGrid();
void computeMajorGrid();
void showMajorGrid();
void showMinorGrid();
void hideGrid();
TQPen gridPen;
int maximumComputedGridHeight;
int minimumHeight;
int int_blockUpdating;
bool flag_blockUpdating;
int pendingHeight;
int pendingWidth;
};
class KDLegendWidget : public KDGanttSemiSizingControl
{
Q_OBJECT
TQ_OBJECT
public:
KDLegendWidget ( TQWidget* tqparent, KDGanttMinimizeSplitter* legendParent );
void showMe(bool);
bool isShown();
void addLegendItem( KDGanttViewItem::Shape tqshape, const TQColor& tqshapeColor, const TQString& text );
void clearLegend();
void setFont( TQFont );
void drawToPainter( TQPainter *p );
void setAsDockwindow( bool dockwin );
bool asDockwindow();
TQDockWindow* dockwindow();
TQSize legendSize();
TQSize legendSizeHint();
private:
TQGroupBox * myLegend;
TQLabel* myLabel;
TQScrollView * scroll;
TQDockWindow* dock;
KDGanttMinimizeSplitter* myLegendParent;
};
class KDGanttView;
class KDListView : public TQListView
{
Q_OBJECT
TQ_OBJECT
public:
KDListView (TQWidget* tqparent,KDGanttView* gv );
KDGanttView* myGanttView;
void drawToPainter( TQPainter *p, bool drawHeader=false );
void setCalendarMode( bool mode );
bool calendarMode() { return _calendarMode; };
TQString getWhatsThisText(TQPoint p);
void setOpen ( TQListViewItem * item, bool open );
void dragEnterEvent ( TQDragEnterEvent * );
void dragMoveEvent ( TQDragMoveEvent * );
void dragLeaveEvent ( TQDragLeaveEvent * );
void dropEvent ( TQDropEvent * );
TQDragObject * dragObject ();
void startDrag ();
void paintemptyarea ( TQPainter * p, const TQRect & rect ){ TQListView::paintEmptyArea( p, rect );};
public:
class DrawableItem {
public:
DrawableItem(int level, int ypos, TQListViewItem *item ) { y = ypos; l = level; i = item; };
int y;
int l;
TQListViewItem * i;
};
protected:
void drawAllContents(TQPainter * p, int cx, int cy, int cw, int ch);
int buildDrawables(TQPtrList<KDListView::DrawableItem> &lst, int level, int ypos, TQListViewItem *item, int ymin, int ymax) const;
private slots:
void dragItem( TQListViewItem * );
private:
void resizeEvent ( TQResizeEvent * ) ;
void contentsMouseDoubleClickEvent ( TQMouseEvent * e );
bool _calendarMode;
};
class KDCanvasText : public TQCanvasText
{
public:
KDCanvasText( KDTimeTableWidget* canvas, void* parentItem, int type );
int myParentType;
void* myParentItem;
};
class KDCanvasLine : public TQCanvasLine
{
public:
KDCanvasLine( KDTimeTableWidget* canvas, void* parentItem, int type );
int myParentType;
void* myParentItem;
};
class KDCanvasPolygonItem: public TQCanvasPolygonalItem
{
public:
KDCanvasPolygonItem( KDTimeTableWidget* canvas, void* parentItem,
int type );
int myParentType;
void* myParentItem;
};
class KDCanvasPolygon: public TQCanvasPolygon
{
public:
KDCanvasPolygon( KDTimeTableWidget* canvas, void* parentItem, int type );
int myParentType;
void* myParentItem;
};
class KDCanvasEllipse: public TQCanvasEllipse
{
public:
KDCanvasEllipse( KDTimeTableWidget* canvas, void* parentItem, int type );
int myParentType;
void* myParentItem;
};
class KDCanvasRectangle: public TQCanvasRectangle
{
public:
KDCanvasRectangle( KDTimeTableWidget* canvas, void* parentItem, int type );
int myParentType;
void* myParentItem;
};
// Interval-color-rectangle, such as the one used in the freebusy view for the current event
class KDIntervalColorRectangle: public KDCanvasRectangle
{
public:
KDIntervalColorRectangle( KDGanttView* view );
void setDateTimes( const TQDateTime& start,
const TQDateTime& end );
TQDateTime start() const { return mStart; }
TQDateTime end() const { return mEnd; }
void setColor( const TQColor& color );
enum HitTest { Start, Middle, End };
HitTest hitTest( KDTimeHeaderWidget* timeHeader, const TQPoint& pos ) const;
void tqlayout( KDTimeHeaderWidget* timeHeader, int height );
static const int RTTI = 0x0c58;
/*reimp*/ int rtti() const { return RTTI; }
private:
TQColor mColor;
TQDateTime mStart;
TQDateTime mEnd;
};
class KDCanvasToolTip;
class KDGanttCanvasView : public TQCanvasView
{
Q_OBJECT
TQ_OBJECT
public:
KDGanttCanvasView(KDGanttView* sender, TQCanvas* canvas = 0, TQWidget* tqparent = 0, const char* name = 0 );
~KDGanttCanvasView();
TQString getToolTipText(TQPoint p);
TQString getWhatsThisText(TQPoint p);
void drawToPainter ( TQPainter * p );
void resetCutPaste( KDGanttViewItem* );
void setShowPopupMenu( bool show );
bool showPopupMenu();
void cutItem ( KDGanttViewItem* );
void insertItemAsRoot( KDGanttViewItem* );
void insertItemAsChild( KDGanttViewItem* , KDGanttViewItem* );
void insertItemAfter( KDGanttViewItem* , KDGanttViewItem* );
protected:
friend class KDGanttView;
friend class KDListView;
virtual void contentsMousePressEvent ( TQMouseEvent * ) ;
virtual void contentsMouseReleaseEvent ( TQMouseEvent * );
virtual void contentsMouseDoubleClickEvent ( TQMouseEvent * );
virtual void contentsMouseMoveEvent ( TQMouseEvent * ) ;
virtual void viewportPaintEvent ( TQPaintEvent * pe );
void resizeEvent ( TQResizeEvent * ) ;
void set_MouseTracking(bool on);
int getType(TQCanvasItem*);
KDGanttViewItem* getItem(TQCanvasItem*);
KDGanttViewTaskLink* getLink(TQCanvasItem*);
int getItemArea(KDGanttViewItem *item, int x);
int getLinkType(int from, int to);
KDGanttView* mySignalSender;
KDGanttViewItem* currentItem, *lastClickedItem, *cuttedItem;
TQCanvasRectangle* movingItem;
KDGanttViewTaskItem* movingGVItem;
TQPoint movingStart;
TQDateTime movingStartDate;
enum MovingOperation { Moving, ResizingLeft, ResizingRight };
MovingOperation movingOperation;
KDGanttViewTaskLink* currentLink;
KDCanvasWhatsThis* myWhatsThis;
TQPopupMenu* onItem;
bool _showItemAddPopupMenu;
int myMyContentsHeight;
KDGanttViewItem *fromItem;
bool linkItemsEnabled;
TQCanvasLine *linkLine;
int fromArea;
bool autoScrollEnabled;
bool mouseDown;
signals:
void heightResized( int );
void widthResized( int );
public slots:
void set_Mouse_Tracking(bool on);
void moveMyContent( int, int );
void setMyContentsHeight( int );
void updateHorScrollBar();
private slots:
void cutItem();
void pasteItem( int );
void newRootItem( int );
void newChildItem( int );
void slotScrollTimer();
void myUpdateScrollBars();
private:
MovingOperation gvItemHitTest( KDGanttViewItem *item, KDTimeHeaderWidget* timeHeader, const TQPoint &pos );
private:
KDCanvasToolTip* myToolTip;
TQTimer *myScrollTimer;
TQPoint mousePos;
TQTimer scrollBarTimer;
};
class KDTimeHeaderToolTip :public TQToolTip
{
public:
KDTimeHeaderToolTip( TQWidget *wid, KDTimeHeaderWidget* header ) : TQToolTip( wid ), _wid(wid),_header (header) {
};
protected:
virtual void maybeTip( const TQPoint& p)
{
static bool ishidden = true;
if (TQToolTip::isGloballyEnabled () ) {
if (ishidden) {
tip( TQRect( p.x(),p.y(),5,5), _header->getToolTipText(p));
}
else
hide();
ishidden = !ishidden;
}
}
private:
TQWidget* _wid;
KDTimeHeaderWidget * _header;
};
class KDCanvasToolTip :public TQToolTip
{
public:
KDCanvasToolTip( TQWidget *wid, KDGanttCanvasView* canview ) : TQToolTip( wid ), _wid(wid),_canview (canview) {
};
protected:
virtual void maybeTip( const TQPoint& p)
{
static bool ishidden = true;
if (TQToolTip::isGloballyEnabled () ) {
if (ishidden) {
tip( TQRect( p.x()-2,p.y()-2,5,5), _canview->getToolTipText(p));
}
else
hide();
ishidden = !ishidden;
}
}
private:
TQWidget* _wid;
KDGanttCanvasView * _canview;
};
class KDCanvasWhatsThis :public TQWhatsThis
{
public:
KDCanvasWhatsThis( TQWidget *wid, KDGanttCanvasView* canview ) : TQWhatsThis( wid ), _wid(wid),_canview (canview) { };
protected:
virtual TQString text( const TQPoint& p)
{
return _canview->getWhatsThisText(p) ;
}
private:
TQWidget* _wid;
KDGanttCanvasView * _canview;
};
class KDListViewWhatsThis :public TQWhatsThis
{
public:
KDListViewWhatsThis( TQWidget *wid, KDListView* view ) : TQWhatsThis( wid ), _wid(wid),_view (view) { };
protected:
virtual TQString text( const TQPoint& p)
{
return _view->getWhatsThisText(p) ;
}
private:
TQWidget* _wid;
KDListView * _view;
};
#endif
|