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 MARGIN_SIZE 36              // margins, for all orientations
00052 #define PADDING_SIZE 7              // padding between the various top-level boxes
00053 #define BOX_BORDER_WIDTH 2          // width of the border of all top-level boxes
00054 #define EVENT_BORDER_WIDTH 0        // with of the border of all incidence boxes
00055 
00056 #define TIMELINE_WIDTH 50           // width of timeline (day and timetable)
00057 
00062 class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
00063 {
00064   public:
00065     enum DisplayFlags {
00066       Text=0x0001,
00067       TimeBoxes=0x0002
00068     };
00069 
00070   public:
00074     CalPrintPluginBase();
00075     virtual ~CalPrintPluginBase();
00076 
00080     virtual QWidget *createConfigWidget( QWidget * );
00081 
00089     virtual void print( QPainter &p, int width, int height ) = 0;
00093     virtual void doPrint( KPrinter *printer );
00094 
00098     virtual void loadConfig() = 0;
00102     virtual void saveConfig() = 0;
00103 
00107     void doLoadConfig();
00111     void doSaveConfig();
00112 
00114   public:
00115     void setKOrgCoreHelper( KOrg::CoreHelper*helper );
00116     bool useColors() const;
00117     void setUseColors( bool useColors );
00118     
00120     QColor categoryBgColor( Incidence *incidence );
00121     QColor textColor( const QColor &color );
00122     QTime dayStart();
00123     bool isWorkingDay( const QDate &dt );
00124     QString holidayString( const QDate &dt );
00125     Event *holiday( const QDate &dt );
00126     
00132     static int weekdayColumn( int weekday );
00133     void setCategoryColors( QPainter &p, Incidence *incidence );
00134 
00135     KPrinter::Orientation orientation() const;
00136 
00142     int headerHeight() const;
00143     void setHeaderHeight( const int height );
00144 
00145     int subHeaderHeight() const;
00146     void setSubHeaderHeight( const int height );
00147 
00148     int margin() const;
00149     void setMargin( const int margin );
00150     
00151     int padding() const;
00152     void setPadding( const int margin );
00153     
00154     int borderWidth() const;
00155     void setBorderWidth( const int border );
00156 
00157     const KCalendarSystem *calendarSystem() const;
00158     void setCalendarSystem( const KCalendarSystem *calsys );
00159 
00160 
00161   /*****************************************************************
00162    **               PRINTING HELPER FUNCTIONS                     **
00163    *****************************************************************/
00164   public: 
00171     static void drawBox( QPainter &p, int linewidth, const QRect &rect );
00179     static void drawShadedBox( QPainter &p, int linewidth, const QBrush &brush, const QRect &rect );
00180   
00188     void printEventString( QPainter &p, const QRect &box, const QString &str, int flags = -1 );
00189 
00198     void showEventBox( QPainter &p, const QRect &box, Incidence *incidence, const QString &str, int flags = -1 );
00199     
00206     void drawSubHeaderBox(QPainter &p, const QString &str, const QRect &box );
00207     
00214     void drawVerticalBox( QPainter &p, const QRect &box, const QString &str );
00215     
00236     int drawBoxWithCaption( QPainter &p, const QRect &box, const QString &caption,
00237                             const QString &contents, 
00238                             bool sameLine, bool expand, const QFont &captionFont, const QFont &textFont );
00239 
00267     int drawHeader( QPainter &p, QString title,
00268                      const QDate &month1, const QDate &month2,
00269                      const QRect &box, bool expand = false );
00277     void drawSmallMonth( QPainter &p, const QDate &qd, const QRect &box );
00278 
00288     void drawDaysOfWeek( QPainter &p,
00289                          const QDate &fromDate, const QDate &toDate,
00290                          const QRect &box );
00298     void drawDaysOfWeekBox( QPainter &p, const QDate &qd, const QRect &box );
00309     void drawTimeLine( QPainter &p,
00310                        const QTime &fromTime, const QTime &toTime,
00311                        const QRect &box );
00312   
00331     int drawAllDayBox( QPainter &p, Event::List &eventList,
00332                         const QDate &qd, bool expandable,
00333                         const QRect &box );
00353     void drawAgendaDayBox( QPainter &p, Event::List &eventList,
00354                            const QDate &qd, bool expandable,
00355                            QTime &fromTime, QTime &toTime,
00356                            const QRect &box );
00357 
00358     void drawAgendaItem( PrintCellItem *item, QPainter &p,
00359                          const QDateTime &startPrintDate,
00360                          const QDateTime &endPrintDate,
00361                          float minlen, const QRect &box );
00362   
00375     void drawDayBox( QPainter &p, const QDate &qd,
00376                      const QRect &box,
00377                      bool fullDate = false, bool printRecurDaily = true,
00378                      bool printRecurWeekly = true );
00388     void drawWeek( QPainter &p, const QDate &qd,
00389                    const QRect &box );
00405     void drawTimeTable( QPainter &p, const QDate &fromDate, const QDate &toDate,
00406                         QTime &fromTime, QTime &toTime,
00407                         const QRect &box );
00408 
00422     void drawMonthTable( QPainter &p, const QDate &qd, bool weeknumbers,
00423                     bool recurDaily, bool recurWeekly,
00424                     const QRect &box );
00440     void drawMonth( QPainter &p, const QDate &dt, const QRect &box, int maxdays = -1, int subDailyFlags = TimeBoxes, int holidaysFlags = Text );
00441 
00445     class TodoParentStart;
00446 
00469     void drawTodo( int &count, Todo *todo, QPainter &p,
00470                    TodoSortField sortField, SortDirection sortDir,
00471                    bool connectSubTodos, bool strikeoutCompleted, bool desc,
00472                    int posPriority, int posSummary, int posDueDt,
00473                    int posPercentComplete, int level, int x, int &y,
00474                    int width, int pageHeight,
00475                    const Todo::List &todoList, TodoParentStart *r = 0 );
00476 
00487     void drawJournal( Journal * journal, QPainter &p, int x, int &y,
00488                       int width, int pageHeight );
00489     void drawJournalField( QPainter &p, QString field, QString text,
00490                            int x, int &y, int width, int pageHeight );
00491 
00492     void drawSplitHeaderRight( QPainter &p, const QDate &fd, const QDate &td,
00493                                const QDate &cd, int width, int height );
00494 
00495 
00496   protected:
00497     void drawIncidence( QPainter &p, const QRect &dayBox, const QString &time,
00498                         const QString &summary, int &textY );
00499 
00500   protected:
00501     bool mUseColors;
00502     int mHeaderHeight;
00503     int mSubHeaderHeight;
00504     int mMargin;
00505     int mPadding;
00506     int mBorder;
00507     const KCalendarSystem *mCalSys;
00508 
00509   public:
00510 };
00511 
00512 #endif
00513 
00514 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys