korganizer

calprintpluginbase.h
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5  Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of TQt, and distribute the resulting executable,
23  without including the source code for TQt in the source distribution.
24 */
25 #ifndef CALPRINTPLUGINBASE_H
26 #define CALPRINTPLUGINBASE_H
27 // #define KORG_NOPRINTER
28 
29 #ifndef KORG_NOPRINTER
30 
31 #include <tqdatetime.h>
32 #include <kprinter.h>
33 #include <kdemacros.h>
34 #include <libkcal/calendar.h>
35 #include <libkcal/event.h>
36 #include <libkcal/todo.h>
37 #include "korganizer/printplugin.h"
38 #include "korganizer/corehelper.h"
39 
40 
41 class PrintCellItem;
42 
43 class TQWidget;
44 
45 using namespace KCal;
46 
47 
48 #define PORTRAIT_HEADER_HEIGHT 72 // header height, for portrait orientation
49 #define LANDSCAPE_HEADER_HEIGHT 54 // header height, for landscape orientation
50 #define SUBHEADER_HEIGHT 20 // subheader height, for all orientations
51 #define PORTRAIT_FOOTER_HEIGHT 16 // footer height, for portrait orientation
52 #define LANDSCAPE_FOOTER_HEIGHT 14 // footer height, for landscape orientation
53 #define MARGIN_SIZE 36 // margins, for all orientations
54 #define PADDING_SIZE 7 // padding between the various top-level boxes
55 #define BOX_BORDER_WIDTH 2 // width of the border of all top-level boxes
56 #define EVENT_BORDER_WIDTH 0 // with of the border of all incidence boxes
57 
58 #define TIMELINE_WIDTH 50 // width of timeline (day and timetable)
59 
64 class TDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
65 {
66  public:
67  enum DisplayFlags {
68  Text=0x0001,
69  TimeBoxes=0x0002
70  };
71 
72  public:
77  virtual ~CalPrintPluginBase();
78 
82  virtual TQWidget *createConfigWidget( TQWidget * );
83 
91  virtual void print( TQPainter &p, int width, int height ) = 0;
95  virtual void doPrint( KPrinter *printer );
96 
100  virtual void loadConfig() = 0;
104  virtual void saveConfig() = 0;
105 
109  void doLoadConfig();
113  void doSaveConfig();
114 
116  public:
117  void setKOrgCoreHelper( KOrg::CoreHelper*helper );
118  bool useColors() const;
119  void setUseColors( bool useColors );
120 
122  TQColor categoryBgColor( Incidence *incidence );
123  TQColor textColor( const TQColor &color );
124  TQTime dayStart();
125  bool isWorkingDay( const TQDate &dt );
126  TQString holidayString( const TQDate &dt );
127  Event *holiday( const TQDate &dt );
128 
134  static int weekdayColumn( int weekday );
135  void setCategoryColors( TQPainter &p, Incidence *incidence );
136 
137  KPrinter::Orientation orientation() const;
138 
144  int headerHeight() const;
145  void setHeaderHeight( const int height );
146 
147  int subHeaderHeight() const;
148  void setSubHeaderHeight( const int height );
149 
155  int footerHeight() const;
156  void setFooterHeight( const int height );
157 
158  int margin() const;
159  void setMargin( const int margin );
160 
161  int padding() const;
162  void setPadding( const int margin );
163 
164  int borderWidth() const;
165  void setBorderWidth( const int border );
166 
167  const KCalendarSystem *calendarSystem() const;
168  void setCalendarSystem( const KCalendarSystem *calsys );
169 
170 
171  /*****************************************************************
172  ** PRINTING HELPER FUNCTIONS **
173  *****************************************************************/
174  public:
181  static void drawBox( TQPainter &p, int linewidth, const TQRect &rect );
189  static void drawShadedBox( TQPainter &p, int linewidth, const TQBrush &brush, const TQRect &rect );
190 
199  void printEventString( TQPainter &p, const TQRect &box, const TQString &str, int flags = -1 );
200 
211  void showEventBox( TQPainter &p, int linewidth, const TQRect &box, Incidence *incidence,
212  const TQString &str, int flags = -1 );
213 
220  void drawSubHeaderBox(TQPainter &p, const TQString &str, const TQRect &box );
221 
230  void drawVerticalBox( TQPainter &p, int linewidth, const TQRect &box, const TQString &str,
231  int flags=-1 );
232 
253  int drawBoxWithCaption( TQPainter &p, const TQRect &box, const TQString &caption,
254  const TQString &contents,
255  bool sameLine, bool expand, const TQFont &captionFont, const TQFont &textFont );
256 
284  int drawHeader( TQPainter &p, TQString title,
285  const TQDate &month1, const TQDate &month2,
286  const TQRect &box, bool expand = false );
287 
295  int drawFooter( TQPainter &p, TQRect &box );
296 
304  void drawSmallMonth( TQPainter &p, const TQDate &qd, const TQRect &box );
305 
315  void drawDaysOfWeek( TQPainter &p,
316  const TQDate &fromDate, const TQDate &toDate,
317  const TQRect &box );
325  void drawDaysOfWeekBox( TQPainter &p, const TQDate &qd, const TQRect &box );
336  void drawTimeLine( TQPainter &p,
337  const TQTime &fromTime, const TQTime &toTime,
338  const TQRect &box );
339 
358  int drawAllDayBox( TQPainter &p, Event::List &eventList,
359  const TQDate &qd, bool expandable,
360  const TQRect &box );
380  void drawAgendaDayBox( TQPainter &p, Event::List &eventList,
381  const TQDate &qd, bool expandable,
382  TQTime &fromTime, TQTime &toTime,
383  const TQRect &box );
384 
385  void drawAgendaItem( PrintCellItem *item, TQPainter &p,
386  const TQDateTime &startPrintDate,
387  const TQDateTime &endPrintDate,
388  float minlen, const TQRect &box );
389 
402  void drawDayBox( TQPainter &p, const TQDate &qd,
403  const TQRect &box,
404  bool fullDate = false, bool printRecurDaily = true,
405  bool printRecurWeekly = true );
415  void drawWeek( TQPainter &p, const TQDate &qd,
416  const TQRect &box );
432  void drawTimeTable( TQPainter &p, const TQDate &fromDate, const TQDate &toDate,
433  TQTime &fromTime, TQTime &toTime,
434  const TQRect &box );
435 
449  void drawMonthTable( TQPainter &p, const TQDate &qd, bool weeknumbers,
450  bool recurDaily, bool recurWeekly,
451  const TQRect &box );
467  void drawMonth( TQPainter &p, const TQDate &dt, const TQRect &box, int maxdays = -1, int subDailyFlags = TimeBoxes, int holidaysFlags = Text );
468 
472  class TodoParentStart;
473 
496  void drawTodo( int &count, Todo *todo, TQPainter &p,
497  TodoSortField sortField, SortDirection sortDir,
498  bool connectSubTodos, bool strikeoutCompleted, bool desc,
499  int posPriority, int posSummary, int posDueDt,
500  int posPercentComplete, int level, int x, int &y,
501  int width, int pageHeight,
502  const Todo::List &todoList, TodoParentStart *r = 0 );
503 
514  void drawJournal( Journal * journal, TQPainter &p, int x, int &y,
515  int width, int pageHeight );
516  void drawJournalField( TQPainter &p, TQString field, TQString text,
517  int x, int &y, int width, int pageHeight );
518 
519  void drawSplitHeaderRight( TQPainter &p, const TQDate &fd, const TQDate &td,
520  const TQDate &cd, int width, int height );
521 
522 
523  protected:
524  void drawIncidence( TQPainter &p, const TQRect &dayBox, const TQString &time,
525  const TQString &summary, int &textY );
526 
527  protected:
528  bool mUseColors;
529  int mHeaderHeight;
530  int mSubHeaderHeight;
531  int mFooterHeight;
532  int mMargin;
533  int mPadding;
534  int mBorder;
535  const KCalendarSystem *mCalSys;
536 
537  public:
538 };
539 
540 #endif
541 
542 #endif
Base class for KOrganizer printing classes.
virtual void loadConfig()=0
Load print format configuration from config file.
virtual void print(TQPainter &p, int width, int height)=0
Actually do the printing.
virtual void saveConfig()=0
Write print format configuration to config file.
Base class for KOrganizer printing classes.
Definition: printplugin.h:52
TodoSortField
SortDirection