00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef CALPRINTPLUGINBASE_H
00026 #define CALPRINTPLUGINBASE_H
00027
00028
00029 #ifndef KORG_NOPRINTER
00030
00031 #include <qdatetime.h>
00032 #include <kprinter.h>
00033 #include <kdepimmacros.h>
00034 #include <libkcal/calendar.h>
00035 #include <libkcal/event.h>
00036 #include <libkcal/todo.h>
00037 #include "korganizer/printplugin.h"
00038 #include "korganizer/corehelper.h"
00039
00040
00041 class PrintCellItem;
00042
00043 class QWidget;
00044
00045 using namespace KCal;
00046
00047
00048 #define PORTRAIT_HEADER_HEIGHT 72 // header height, for portrait orientation
00049 #define LANDSCAPE_HEADER_HEIGHT 54 // header height, for landscape orientation
00050 #define SUBHEADER_HEIGHT 20 // subheader height, for all orientations
00051 #define PORTRAIT_FOOTER_HEIGHT 16 // footer height, for portrait orientation
00052 #define LANDSCAPE_FOOTER_HEIGHT 14 // footer height, for landscape orientation
00053 #define MARGIN_SIZE 36 // margins, for all orientations
00054 #define PADDING_SIZE 7 // padding between the various top-level boxes
00055 #define BOX_BORDER_WIDTH 2 // width of the border of all top-level boxes
00056 #define EVENT_BORDER_WIDTH 0 // with of the border of all incidence boxes
00057
00058 #define TIMELINE_WIDTH 50 // width of timeline (day and timetable)
00059
00064 class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
00065 {
00066 public:
00067 enum DisplayFlags {
00068 Text=0x0001,
00069 TimeBoxes=0x0002
00070 };
00071
00072 public:
00076 CalPrintPluginBase();
00077 virtual ~CalPrintPluginBase();
00078
00082 virtual QWidget *createConfigWidget( QWidget * );
00083
00091 virtual void print( QPainter &p, int width, int height ) = 0;
00095 virtual void doPrint( KPrinter *printer );
00096
00100 virtual void loadConfig() = 0;
00104 virtual void saveConfig() = 0;
00105
00109 void doLoadConfig();
00113 void doSaveConfig();
00114
00116 public:
00117 void setKOrgCoreHelper( KOrg::CoreHelper*helper );
00118 bool useColors() const;
00119 void setUseColors( bool useColors );
00120
00122 QColor categoryBgColor( Incidence *incidence );
00123 QColor textColor( const QColor &color );
00124 QTime dayStart();
00125 bool isWorkingDay( const QDate &dt );
00126 QString holidayString( const QDate &dt );
00127 Event *holiday( const QDate &dt );
00128
00134 static int weekdayColumn( int weekday );
00135 void setCategoryColors( QPainter &p, Incidence *incidence );
00136
00137 KPrinter::Orientation orientation() const;
00138
00144 int headerHeight() const;
00145 void setHeaderHeight( const int height );
00146
00147 int subHeaderHeight() const;
00148 void setSubHeaderHeight( const int height );
00149
00155 int footerHeight() const;
00156 void setFooterHeight( const int height );
00157
00158 int margin() const;
00159 void setMargin( const int margin );
00160
00161 int padding() const;
00162 void setPadding( const int margin );
00163
00164 int borderWidth() const;
00165 void setBorderWidth( const int border );
00166
00167 const KCalendarSystem *calendarSystem() const;
00168 void setCalendarSystem( const KCalendarSystem *calsys );
00169
00170
00171
00172
00173
00174 public:
00181 static void drawBox( QPainter &p, int linewidth, const QRect &rect );
00189 static void drawShadedBox( QPainter &p, int linewidth, const QBrush &brush, const QRect &rect );
00190
00198 void printEventString( QPainter &p, const QRect &box, const QString &str, int flags = -1 );
00199
00208 void showEventBox( QPainter &p, const QRect &box, Incidence *incidence, const QString &str, int flags = -1 );
00209
00216 void drawSubHeaderBox(QPainter &p, const QString &str, const QRect &box );
00217
00224 void drawVerticalBox( QPainter &p, const QRect &box, const QString &str );
00225
00246 int drawBoxWithCaption( QPainter &p, const QRect &box, const QString &caption,
00247 const QString &contents,
00248 bool sameLine, bool expand, const QFont &captionFont, const QFont &textFont );
00249
00277 int drawHeader( QPainter &p, QString title,
00278 const QDate &month1, const QDate &month2,
00279 const QRect &box, bool expand = false );
00280
00288 int drawFooter( QPainter &p, QRect &box );
00289
00297 void drawSmallMonth( QPainter &p, const QDate &qd, const QRect &box );
00298
00308 void drawDaysOfWeek( QPainter &p,
00309 const QDate &fromDate, const QDate &toDate,
00310 const QRect &box );
00318 void drawDaysOfWeekBox( QPainter &p, const QDate &qd, const QRect &box );
00329 void drawTimeLine( QPainter &p,
00330 const QTime &fromTime, const QTime &toTime,
00331 const QRect &box );
00332
00351 int drawAllDayBox( QPainter &p, Event::List &eventList,
00352 const QDate &qd, bool expandable,
00353 const QRect &box );
00373 void drawAgendaDayBox( QPainter &p, Event::List &eventList,
00374 const QDate &qd, bool expandable,
00375 QTime &fromTime, QTime &toTime,
00376 const QRect &box );
00377
00378 void drawAgendaItem( PrintCellItem *item, QPainter &p,
00379 const QDateTime &startPrintDate,
00380 const QDateTime &endPrintDate,
00381 float minlen, const QRect &box );
00382
00395 void drawDayBox( QPainter &p, const QDate &qd,
00396 const QRect &box,
00397 bool fullDate = false, bool printRecurDaily = true,
00398 bool printRecurWeekly = true );
00408 void drawWeek( QPainter &p, const QDate &qd,
00409 const QRect &box );
00425 void drawTimeTable( QPainter &p, const QDate &fromDate, const QDate &toDate,
00426 QTime &fromTime, QTime &toTime,
00427 const QRect &box );
00428
00442 void drawMonthTable( QPainter &p, const QDate &qd, bool weeknumbers,
00443 bool recurDaily, bool recurWeekly,
00444 const QRect &box );
00460 void drawMonth( QPainter &p, const QDate &dt, const QRect &box, int maxdays = -1, int subDailyFlags = TimeBoxes, int holidaysFlags = Text );
00461
00465 class TodoParentStart;
00466
00489 void drawTodo( int &count, Todo *todo, QPainter &p,
00490 TodoSortField sortField, SortDirection sortDir,
00491 bool connectSubTodos, bool strikeoutCompleted, bool desc,
00492 int posPriority, int posSummary, int posDueDt,
00493 int posPercentComplete, int level, int x, int &y,
00494 int width, int pageHeight,
00495 const Todo::List &todoList, TodoParentStart *r = 0 );
00496
00507 void drawJournal( Journal * journal, QPainter &p, int x, int &y,
00508 int width, int pageHeight );
00509 void drawJournalField( QPainter &p, QString field, QString text,
00510 int x, int &y, int width, int pageHeight );
00511
00512 void drawSplitHeaderRight( QPainter &p, const QDate &fd, const QDate &td,
00513 const QDate &cd, int width, int height );
00514
00515
00516 protected:
00517 void drawIncidence( QPainter &p, const QRect &dayBox, const QString &time,
00518 const QString &summary, int &textY );
00519
00520 protected:
00521 bool mUseColors;
00522 int mHeaderHeight;
00523 int mSubHeaderHeight;
00524 int mFooterHeight;
00525 int mMargin;
00526 int mPadding;
00527 int mBorder;
00528 const KCalendarSystem *mCalSys;
00529
00530 public:
00531 };
00532
00533 #endif
00534
00535 #endif