calprintpluginbase.h
00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 1998 Preston Brown <pbrown@kde.org> 00005 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com> 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 00021 As a special exception, permission is given to link this program 00022 with any edition of TQt, and distribute the resulting executable, 00023 without including the source code for TQt in the source distribution. 00024 */ 00025 #ifndef CALPRINTPLUGINBASE_H 00026 #define CALPRINTPLUGINBASE_H 00027 // #define KORG_NOPRINTER 00028 00029 #ifndef KORG_NOPRINTER 00030 00031 #include <tqdatetime.h> 00032 #include <kprinter.h> 00033 #include <tdepimmacros.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 TQWidget; 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 TQWidget *createConfigWidget( TQWidget * ); 00083 00091 virtual void print( TQPainter &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 TQColor categoryBgColor( Incidence *incidence ); 00123 TQColor textColor( const TQColor &color ); 00124 TQTime dayStart(); 00125 bool isWorkingDay( const TQDate &dt ); 00126 TQString holidayString( const TQDate &dt ); 00127 Event *holiday( const TQDate &dt ); 00128 00134 static int weekdayColumn( int weekday ); 00135 void setCategoryColors( TQPainter &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 ** PRINTING HELPER FUNCTIONS ** 00173 *****************************************************************/ 00174 public: 00181 static void drawBox( TQPainter &p, int linewidth, const TQRect &rect ); 00189 static void drawShadedBox( TQPainter &p, int linewidth, const TQBrush &brush, const TQRect &rect ); 00190 00199 void printEventString( TQPainter &p, const TQRect &box, const TQString &str, int flags = -1 ); 00200 00211 void showEventBox( TQPainter &p, int linewidth, const TQRect &box, Incidence *incidence, 00212 const TQString &str, int flags = -1 ); 00213 00220 void drawSubHeaderBox(TQPainter &p, const TQString &str, const TQRect &box ); 00221 00230 void drawVerticalBox( TQPainter &p, int linewidth, const TQRect &box, const TQString &str, 00231 int flags=-1 ); 00232 00253 int drawBoxWithCaption( TQPainter &p, const TQRect &box, const TQString &caption, 00254 const TQString &contents, 00255 bool sameLine, bool expand, const TQFont &captionFont, const TQFont &textFont ); 00256 00284 int drawHeader( TQPainter &p, TQString title, 00285 const TQDate &month1, const TQDate &month2, 00286 const TQRect &box, bool expand = false ); 00287 00295 int drawFooter( TQPainter &p, TQRect &box ); 00296 00304 void drawSmallMonth( TQPainter &p, const TQDate &qd, const TQRect &box ); 00305 00315 void drawDaysOfWeek( TQPainter &p, 00316 const TQDate &fromDate, const TQDate &toDate, 00317 const TQRect &box ); 00325 void drawDaysOfWeekBox( TQPainter &p, const TQDate &qd, const TQRect &box ); 00336 void drawTimeLine( TQPainter &p, 00337 const TQTime &fromTime, const TQTime &toTime, 00338 const TQRect &box ); 00339 00358 int drawAllDayBox( TQPainter &p, Event::List &eventList, 00359 const TQDate &qd, bool expandable, 00360 const TQRect &box ); 00380 void drawAgendaDayBox( TQPainter &p, Event::List &eventList, 00381 const TQDate &qd, bool expandable, 00382 TQTime &fromTime, TQTime &toTime, 00383 const TQRect &box ); 00384 00385 void drawAgendaItem( PrintCellItem *item, TQPainter &p, 00386 const TQDateTime &startPrintDate, 00387 const TQDateTime &endPrintDate, 00388 float minlen, const TQRect &box ); 00389 00402 void drawDayBox( TQPainter &p, const TQDate &qd, 00403 const TQRect &box, 00404 bool fullDate = false, bool printRecurDaily = true, 00405 bool printRecurWeekly = true ); 00415 void drawWeek( TQPainter &p, const TQDate &qd, 00416 const TQRect &box ); 00432 void drawTimeTable( TQPainter &p, const TQDate &fromDate, const TQDate &toDate, 00433 TQTime &fromTime, TQTime &toTime, 00434 const TQRect &box ); 00435 00449 void drawMonthTable( TQPainter &p, const TQDate &qd, bool weeknumbers, 00450 bool recurDaily, bool recurWeekly, 00451 const TQRect &box ); 00467 void drawMonth( TQPainter &p, const TQDate &dt, const TQRect &box, int maxdays = -1, int subDailyFlags = TimeBoxes, int holidaysFlags = Text ); 00468 00472 class TodoParentStart; 00473 00496 void drawTodo( int &count, Todo *todo, TQPainter &p, 00497 TodoSortField sortField, SortDirection sortDir, 00498 bool connectSubTodos, bool strikeoutCompleted, bool desc, 00499 int posPriority, int posSummary, int posDueDt, 00500 int posPercentComplete, int level, int x, int &y, 00501 int width, int pageHeight, 00502 const Todo::List &todoList, TodoParentStart *r = 0 ); 00503 00514 void drawJournal( Journal * journal, TQPainter &p, int x, int &y, 00515 int width, int pageHeight ); 00516 void drawJournalField( TQPainter &p, TQString field, TQString text, 00517 int x, int &y, int width, int pageHeight ); 00518 00519 void drawSplitHeaderRight( TQPainter &p, const TQDate &fd, const TQDate &td, 00520 const TQDate &cd, int width, int height ); 00521 00522 00523 protected: 00524 void drawIncidence( TQPainter &p, const TQRect &dayBox, const TQString &time, 00525 const TQString &summary, int &textY ); 00526 00527 protected: 00528 bool mUseColors; 00529 int mHeaderHeight; 00530 int mSubHeaderHeight; 00531 int mFooterHeight; 00532 int mMargin; 00533 int mPadding; 00534 int mBorder; 00535 const KCalendarSystem *mCalSys; 00536 00537 public: 00538 }; 00539 00540 #endif 00541 00542 #endif