36 #ifndef KDGANTTVIEWSUBWIDGETS_H
37 #define KDGANTTVIEWSUBWIDGETS_H
41 #include <tqlistview.h>
42 #include <tqsplitter.h>
44 #include <tqvaluelist.h>
46 #include <tqwhatsthis.h>
47 #include <tqpopupmenu.h>
48 #include <tqtooltip.h>
50 #include <tqgroupbox.h>
51 #include <tqvgroupbox.h>
56 #include <tqdockwindow.h>
59 #include "KDGanttView.h"
60 #include "KDGanttViewTaskLink.h"
61 #include "KDGanttViewTaskLinkGroup.h"
62 #include "KDGanttViewSummaryItem.h"
63 #include "KDGanttSemiSizingControl.h"
64 #include "KDGanttViewItemDrag.h"
66 #define Type_is_KDGanttGridItem 1
67 #define Type_is_KDGanttViewItem 2
68 #define Type_is_KDGanttTaskLink 3
70 class KDIntervalColorRectangle;
71 class KDCanvasWhatsThis;
73 class KDCanvasRectangle;
74 class KDTimeHeaderToolTip;
76 class KDTimeHeaderWidget :
public TQWidget
85 struct DateTimeColor {
92 KDCanvasRectangle* canvasRect;
94 typedef TQValueList<DateTimeColor> ColumnColorList;
95 typedef TQValueList<KDIntervalColorRectangle *> IntervalColorList;
102 KDTimeHeaderWidget (TQWidget* parent,
KDGanttView* gant);
103 ~KDTimeHeaderWidget();
105 TQString getToolTipText(TQPoint p);
107 void zoom(
double,
bool absolute =
true);
108 void zoomToSelection( TQDateTime startTime, TQDateTime endTime);
110 void setAutoScaleMinorTickCount(
int count );
111 int autoScaleMinorTickCount();
112 void setHorizonStart(
const TQDateTime& start );
113 TQDateTime horizonStart()
const;
114 void setHorizonEnd(
const TQDateTime& start );
115 TQDateTime horizonEnd()
const;
117 void setMaximumScale( Scale );
119 void setMinimumScale( Scale );
122 void setMajorScaleCount(
int count );
123 int majorScaleCount()
const;
124 void setMinorScaleCount(
int count );
125 int minorScaleCount()
const;
126 void setMinimumColumnWidth(
int width );
127 int minimumColumnWidth()
const;
128 void setYearFormat( YearFormat format );
130 void setHourFormat( HourFormat format );
132 void setShowMajorTicks(
bool );
133 bool showMajorTicks()
const;
134 void setShowMinorTicks(
bool );
135 void setScale( Scale unit);
136 bool showMinorTicks()
const;
137 void setColumnBackgroundColor(
const TQDateTime& column,
138 const TQColor& color,
139 Scale mini = KDGanttView::Minute ,
140 Scale maxi = KDGanttView::Month);
143 void setIntervalBackgroundColor(
const TQDateTime& start,
144 const TQDateTime& end,
145 const TQColor& color,
146 Scale mini = KDGanttView::Minute ,
147 Scale maxi = KDGanttView::Month);
148 bool changeBackgroundInterval(
const TQDateTime& oldstart,
149 const TQDateTime& oldend,
150 const TQDateTime& newstart,
151 const TQDateTime& newend );
152 bool deleteBackgroundInterval(
const TQDateTime& start,
153 const TQDateTime& end );
155 void addIntervalBackgroundColor( KDIntervalColorRectangle* newItem );
156 void clearBackgroundColor();
157 TQColor columnBackgroundColor(
const TQDateTime& column )
const;
158 void setWeekendBackgroundColor(
const TQColor& color );
159 TQColor weekendBackgroundColor()
const;
160 void setWeekdayBackgroundColor(
const TQColor& color,
int weekday );
161 TQColor weekdayBackgroundColor(
int weekday)
const;
162 void setWeekendDays(
int start,
int end );
163 void weekendDays(
int& start,
int& end )
const;
164 void computeTicks(
bool doNotComputeRealScale =
false);
165 void paintEvent(TQPaintEvent *);
166 int getCoordX(TQDate);
167 int getCoordX(TQDateTime);
168 TQDateTime getDateTimeForIndex(
int coordX,
bool local =
true );
169 void setShowPopupMenu(
bool show,
bool showZoom,
bool showScale,
bool showTime,
170 bool showYear,
bool showGrid,
bool showPrint);
171 bool registerStartTime();
172 bool registerEndTime();
173 bool showPopupMenu()
const;
174 ColumnColorList columnBackgroundColorList()
const {
177 TQColor weekdayColor[8];
178 void repaintMe(
int left,
int wid, TQPainter *p = 0);
180 void centerDateTime(
const TQDateTime& center );
183 void setSettings(
int);
184 void checkWidth(
int );
185 void addTickRight(
int num = 1 );
186 void addTickLeft(
int num = 1 );
187 void preparePopupMenu();
189 void sizeChanged(
int );
192 friend class KDTimeTableWidget;
195 friend class KDGanttCanvasView;
196 virtual void mousePressEvent ( TQMouseEvent * e );
197 virtual void mouseReleaseEvent ( TQMouseEvent * e );
198 virtual void mouseDoubleClickEvent ( TQMouseEvent * e );
199 virtual void mouseMoveEvent ( TQMouseEvent * e );
200 double secsFromTo( TQDateTime begin, TQDateTime end );
201 void updateTimeTable();
202 void computeIntervals(
int height );
203 bool getColumnColor(TQColor& col,
int coordLow,
int coordHigh);
204 void moveTimeLineTo(
int x);
206 void resizeEvent ( TQResizeEvent * ) ;
207 TQValueList<int> majorTicks;
208 TQValueList<TQString> minorText;
209 TQValueList<TQString> majorText;
210 TQDateTime myHorizonStart, myHorizonEnd, myRealEnd,myRealStart;
211 TQDateTime myCenterDateTime;
212 void saveCenterDateTime();
213 Scale myScale,myRealScale,myMaxScale,myMinScale;
214 YearFormat myYearFormat;
215 HourFormat myHourFormat;
216 int myMinimumColumWidth;
217 bool flagShowMajorTicks, flagShowMinorTicks, flagShowPopupMenu;
218 bool flagShowZoom, flagShowScale ,flagShowTime ,flagShowYear;
219 bool flagShowGrid ,flagShowPrint;
220 bool flagStartTimeSet,flagEndTimeSet;
221 TQColor myWeekendBackgroundColor;
222 int myWeekendDaysStart, myWeekendDaysEnd;
223 ColumnColorList ccList;
224 IntervalColorList icList;
225 int myMinorScaleCount,myMajorScaleCount;
226 int myRealMinorScaleCount,myRealMajorScaleCount;
227 bool flagDoNotRecomputeAfterChange,flagDoNotRepaintAfterChange;
228 TQString getYear(TQDate);
229 TQString getHour(TQTime);
230 TQDateTime getEvenTimeDate(TQDateTime ,Scale);
231 void computeRealScale(TQDateTime start);
232 int myGridMinorWidth;
233 int myMajorGridHeight;
234 TQPopupMenu * myPopupMenu, *scalePopupMenu, *timePopupMenu;
235 TQPopupMenu * yearPopupMenu, *gridPopupMenu;
238 int myAutoScaleMinorTickcount;
243 KDTimeHeaderToolTip* myToolTip;
247 bool autoComputeTimeLine;
254 class KDTimeTableWidget :
public TQCanvas
260 KDTimeTableWidget (TQWidget* parent,
KDGanttView* my);
262 void setBlockUpdating(
bool block =
true );
263 bool blockUpdating();
264 void inc_blockUpdating();
265 void dec_blockUpdating();
266 void setShowTaskLinks(
bool show );
267 bool showTaskLinks();
268 TQPtrList<KDGanttViewTaskLink>taskLinks();
269 void clearTaskLinks();
270 void updateMyContent();
272 void setHorBackgroundLines(
int count, TQBrush brush );
273 int horBackgroundLines( TQBrush& brush );
275 void setNoInformationBrush(
const TQBrush& brush );
276 TQBrush noInformationBrush()
const;
278 int getCoordX( TQDateTime dt );
281 void heightComputed(
int );
284 void expandItem(TQListViewItem * );
285 void collapseItem(TQListViewItem * );
286 void highlightItem(TQListViewItem * );
287 void resetWidth(
int );
288 void checkHeight(
int );
291 friend class KDTimeHeaderWidget;
296 bool taskLinksVisible;
298 TQPtrList<KDGanttViewTaskLink> myTaskLinkList;
300 TQPtrList<KDCanvasLine> verGridList;
301 TQPtrList<KDCanvasLine> horGridList;
302 TQPtrList<KDCanvasRectangle> horDenseList;
303 TQPtrList<KDCanvasRectangle> showNoInfoList;
305 TQBrush denseLineBrush, noInfoLineBrush;
306 TQPtrList<KDCanvasRectangle> columnColorList;
309 void computeVerticalGrid();
310 void computeHorizontalGrid();
311 void computeDenseLines();
312 void computeShowNoInformation();
313 void computeTaskLinks();
314 void computeMinorGrid();
315 void computeMajorGrid();
317 void showMajorGrid();
318 void showMinorGrid();
322 int maximumComputedGridHeight;
324 int int_blockUpdating;
325 bool flag_blockUpdating;
342 void setFont( TQFont );
343 void drawToPainter( TQPainter *p );
344 void setAsDoctwindow(
bool dockwin );
346 TQDockWindow* dockwindow();
348 TQSize legendSizeHint();
350 TQGroupBox * myLegend;
352 TQScrollView * scroll;
358 class KDListView :
public TQListView
366 void drawToPainter( TQPainter *p,
bool drawHeader=
false );
367 void setCalendarMode(
bool mode );
368 bool calendarMode() {
return _calendarMode; };
369 TQString getWhatsThisText(TQPoint p);
370 void setOpen ( TQListViewItem * item,
bool open );
371 void dragEnterEvent ( TQDragEnterEvent * );
372 void dragMoveEvent ( TQDragMoveEvent * );
373 void dragLeaveEvent ( TQDragLeaveEvent * );
374 void dropEvent ( TQDropEvent * );
375 TQDragObject * dragObject ();
377 void paintemptyarea ( TQPainter * p,
const TQRect & rect ){ TQListView::paintEmptyArea( p, rect );};
382 DrawableItem(
int level,
int ypos, TQListViewItem *item ) { y = ypos; l = level; i = item; };
388 void drawAllContents(TQPainter * p,
int cx,
int cy,
int cw,
int ch);
389 int buildDrawables(TQPtrList<KDListView::DrawableItem> &lst,
int level,
int ypos, TQListViewItem *item,
int ymin,
int ymax)
const;
392 void dragItem( TQListViewItem * );
394 void resizeEvent ( TQResizeEvent * ) ;
395 void contentsMouseDoubleClickEvent ( TQMouseEvent * e );
403 class KDCanvasText :
public TQCanvasText
406 KDCanvasText( KDTimeTableWidget* canvas,
void* parentItem,
int type );
412 class KDCanvasLine :
public TQCanvasLine
415 KDCanvasLine( KDTimeTableWidget* canvas,
void* parentItem,
int type );
421 class KDCanvasPolygonItem:
public TQCanvasPolygonalItem
424 KDCanvasPolygonItem( KDTimeTableWidget* canvas,
void* parentItem,
431 class KDCanvasPolygon:
public TQCanvasPolygon
434 KDCanvasPolygon( KDTimeTableWidget* canvas,
void* parentItem,
int type );
440 class KDCanvasEllipse:
public TQCanvasEllipse
443 KDCanvasEllipse( KDTimeTableWidget* canvas,
void* parentItem,
int type );
449 class KDCanvasRectangle:
public TQCanvasRectangle
452 KDCanvasRectangle( KDTimeTableWidget* canvas,
void* parentItem,
int type );
459 class KDIntervalColorRectangle:
public KDCanvasRectangle
464 void setDateTimes(
const TQDateTime& start,
465 const TQDateTime& end );
466 TQDateTime start()
const {
return mStart; }
467 TQDateTime end()
const {
return mEnd; }
469 void setColor(
const TQColor& color );
471 enum HitTest { Start, Middle, End };
472 HitTest hitTest( KDTimeHeaderWidget* timeHeader,
const TQPoint& pos )
const;
474 void layout( KDTimeHeaderWidget* timeHeader,
int height );
476 static const int RTTI = 0x0c58;
477 int rtti()
const {
return RTTI; }
485 class KDCanvasToolTip;
487 class KDGanttCanvasView :
public TQCanvasView
493 KDGanttCanvasView(
KDGanttView* sender, TQCanvas* canvas = 0, TQWidget* parent = 0,
const char* name = 0 );
494 ~KDGanttCanvasView();
495 TQString getToolTipText(TQPoint p);
496 TQString getWhatsThisText(TQPoint p);
497 void drawToPainter ( TQPainter * p );
499 void setShowPopupMenu(
bool show );
500 bool showPopupMenu();
507 friend class KDListView;
508 virtual void contentsMousePressEvent ( TQMouseEvent * ) ;
509 virtual void contentsMouseReleaseEvent ( TQMouseEvent * );
510 virtual void contentsMouseDoubleClickEvent ( TQMouseEvent * );
511 virtual void contentsMouseMoveEvent ( TQMouseEvent * ) ;
512 virtual void viewportPaintEvent ( TQPaintEvent * pe );
513 void resizeEvent ( TQResizeEvent * ) ;
514 void set_MouseTracking(
bool on);
515 int getType(TQCanvasItem*);
519 int getLinkType(
int from,
int to);
523 TQCanvasRectangle* movingItem;
526 TQDateTime movingStartDate;
527 enum MovingOperation { Moving, ResizingLeft, ResizingRight };
528 MovingOperation movingOperation;
530 KDCanvasWhatsThis* myWhatsThis;
532 bool _showItemAddPopupMenu;
533 int myMyContentsHeight;
535 bool linkItemsEnabled;
536 TQCanvasLine *linkLine;
538 bool autoScrollEnabled;
542 void heightResized(
int );
543 void widthResized(
int );
546 void set_Mouse_Tracking(
bool on);
547 void moveMyContent(
int,
int );
548 void setMyContentsHeight(
int );
549 void updateHorScrollBar();
552 void pasteItem(
int );
553 void newRootItem(
int );
554 void newChildItem(
int );
555 void slotScrollTimer();
556 void myUpdateScrollBars();
559 MovingOperation gvItemHitTest(
KDGanttViewItem *item, KDTimeHeaderWidget* timeHeader,
const TQPoint &pos );
561 KDCanvasToolTip* myToolTip;
562 TQTimer *myScrollTimer;
564 TQTimer scrollBarTimer;
567 class KDTimeHeaderToolTip :
public TQToolTip
571 KDTimeHeaderToolTip( TQWidget *wid, KDTimeHeaderWidget* header ) : TQToolTip( wid ), _wid(wid),_header (header) {
576 virtual void maybeTip(
const TQPoint& p)
578 static bool ishidden =
true;
579 if (TQToolTip::isGloballyEnabled () ) {
581 tip( TQRect( p.x(),p.y(),5,5), _header->getToolTipText(p));
585 ishidden = !ishidden;
590 KDTimeHeaderWidget * _header;
593 class KDCanvasToolTip :
public TQToolTip
597 KDCanvasToolTip( TQWidget *wid, KDGanttCanvasView* canview ) : TQToolTip( wid ), _wid(wid),_canview (canview) {
602 virtual void maybeTip(
const TQPoint& p)
604 static bool ishidden =
true;
605 if (TQToolTip::isGloballyEnabled () ) {
607 tip( TQRect( p.x()-2,p.y()-2,5,5), _canview->getToolTipText(p));
611 ishidden = !ishidden;
616 KDGanttCanvasView * _canview;
619 class KDCanvasWhatsThis :
public TQWhatsThis
622 KDCanvasWhatsThis( TQWidget *wid, KDGanttCanvasView* canview ) : TQWhatsThis( wid ), _wid(wid),_canview (canview) { };
625 virtual TQString text(
const TQPoint& p)
627 return _canview->getWhatsThisText(p) ;
631 KDGanttCanvasView * _canview;
634 class KDListViewWhatsThis :
public TQWhatsThis
637 KDListViewWhatsThis( TQWidget *wid, KDListView* view ) : TQWhatsThis( wid ), _wid(wid),_view (view) { };
640 virtual TQString text(
const TQPoint& p)
642 return _view->getWhatsThisText(p) ;
The KDGanttMinimizeSplitter class implements a splitter widget with minimize buttons.
KDGanttView * myGanttView