korganizer

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 Qt, and distribute the resulting executable,
00023     without including the source code for Qt 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 <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    **               PRINTING HELPER FUNCTIONS                     **
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 
00199     void printEventString( QPainter &p, const QRect &box, const QString &str, int flags = -1 );
00200 
00211     void showEventBox( QPainter &p, int linewidth, const QRect &box, Incidence *incidence,
00212                        const QString &str, int flags = -1 );
00213 
00220     void drawSubHeaderBox(QPainter &p, const QString &str, const QRect &box );
00221 
00230     void drawVerticalBox( QPainter &p, int linewidth, const QRect &box, const QString &str,
00231                           int flags=-1 );
00232 
00253     int drawBoxWithCaption( QPainter &p, const QRect &box, const QString &caption,
00254                             const QString &contents,
00255                             bool sameLine, bool expand, const QFont &captionFont, const QFont &textFont );
00256 
00284     int drawHeader( QPainter &p, QString title,
00285                      const QDate &month1, const QDate &month2,
00286                      const QRect &box, bool expand = false );
00287 
00295     int drawFooter( QPainter &p, QRect &box );
00296 
00304     void drawSmallMonth( QPainter &p, const QDate &qd, const QRect &box );
00305 
00315     void drawDaysOfWeek( QPainter &p,
00316                          const QDate &fromDate, const QDate &toDate,
00317                          const QRect &box );
00325     void drawDaysOfWeekBox( QPainter &p, const QDate &qd, const QRect &box );
00336     void drawTimeLine( QPainter &p,
00337                        const QTime &fromTime, const QTime &toTime,
00338                        const QRect &box );
00339 
00358     int drawAllDayBox( QPainter &p, Event::List &eventList,
00359                         const QDate &qd, bool expandable,
00360                         const QRect &box );
00380     void drawAgendaDayBox( QPainter &p, Event::List &eventList,
00381                            const QDate &qd, bool expandable,
00382                            QTime &fromTime, QTime &toTime,
00383                            const QRect &box );
00384 
00385     void drawAgendaItem( PrintCellItem *item, QPainter &p,
00386                          const QDateTime &startPrintDate,
00387                          const QDateTime &endPrintDate,
00388                          float minlen, const QRect &box );
00389 
00403     void drawDayBox( QPainter &p, const QDate &qd,
00404                      const QRect &box,
00405                      bool fullDate = false, bool printRecurDaily = true,
00406                      bool printRecurWeekly = true,
00407                      bool singleLineLimit = true );
00418     void drawWeek( QPainter &p, const QDate &qd,
00419                    const QRect &box, bool singleLineLimit );
00420 
00436     void drawTimeTable( QPainter &p, const QDate &fromDate, const QDate &toDate,
00437                         QTime &fromTime, QTime &toTime,
00438                         const QRect &box );
00439 
00454     void drawMonthTable( QPainter &p, const QDate &qd, bool weeknumbers,
00455                          bool recurDaily, bool recurWeekly, bool singleLineLimit,
00456                          const QRect &box );
00472     void drawMonth( QPainter &p, const QDate &dt, const QRect &box, int maxdays = -1, int subDailyFlags = TimeBoxes, int holidaysFlags = Text );
00473 
00477     class TodoParentStart;
00478 
00501     void drawTodo( int &count, Todo *todo, QPainter &p,
00502                    TodoSortField sortField, SortDirection sortDir,
00503                    bool connectSubTodos, bool strikeoutCompleted, bool desc,
00504                    int posPriority, int posSummary, int posDueDt,
00505                    int posPercentComplete, int level, int x, int &y,
00506                    int width, int pageHeight,
00507                    const Todo::List &todoList, TodoParentStart *r = 0 );
00508 
00519     void drawJournal( Journal * journal, QPainter &p, int x, int &y,
00520                       int width, int pageHeight );
00521     void drawJournalField( QPainter &p, QString field, QString text,
00522                            int x, int &y, int width, int pageHeight );
00523 
00524     void drawSplitHeaderRight( QPainter &p, const QDate &fd, const QDate &td,
00525                                const QDate &cd, int width, int height );
00526 
00527 
00528   protected:
00529     void drawIncidence( QPainter &p, const QRect &dayBox, const QString &time,
00530                         const QString &summary, const QString &description,
00531                         int &textY, bool singleLineLimit );
00532     int calculateIncidenceHeight( QPainter &p, const QRect &dayBox, const QString &time,
00533                                   const QString &summary, int _textY ) const;
00534 
00535   protected:
00536     bool mUseColors;
00537     int mHeaderHeight;
00538     int mSubHeaderHeight;
00539     int mFooterHeight;
00540     int mMargin;
00541     int mPadding;
00542     int mBorder;
00543     const KCalendarSystem *mCalSys;
00544 
00545   public:
00546 };
00547 
00548 #endif
00549 
00550 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys