kword

KWTableTemplateSelector.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; using
00007    version 2 of the License.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef kwtabletemplateselector_h
00021 #define kwtabletemplateselector_h
00022 
00023 #include <qwidget.h>
00024 #include <qgroupbox.h>
00025 #include <qptrlist.h>
00026 
00027 #include <qlabel.h>
00028 #include <qpushbutton.h>
00029 /*#include <qlayout.h>
00030 #include <qfont.h>
00031 #include <qbrush.h>
00032 */
00033 
00034 class QListBox;
00035 class QCheckBox;
00036 class QButtonGroup;
00037 class QGroupBox;
00038 class QRect;
00039 
00040 class KWTableTemplate;
00041 class KWTableTemplateCollection;
00042 class KoRect;
00043 class KoTextZoomHandler;
00044 class KWTextDocument;
00045 class KWDocument;
00046 class KWTableFrameSet;
00047 class KWTableStyle;
00048 
00049 /******************************************************************/
00050 /* Class: KWTableTemplatePreview                                  */
00051 /******************************************************************/
00052 
00053 class KWTableTemplatePreview : public QGroupBox
00054 {
00055     Q_OBJECT
00056 
00057 public:
00058     KWTableTemplatePreview( const QString& title, KWTableStyle *_emptyStyle, QWidget* parent, const char* name=0L );
00059     ~KWTableTemplatePreview();
00060     void setTableTemplate(KWTableTemplate *_tableTemplate);
00061     KWTableTemplate *getTableTemplate()const ;
00062     void disableRepaint(bool _b) { m_disableRepaint =_b;}
00063 public slots:
00064     void cbFirstRowChanged( bool );
00065     void cbFirstColChanged( bool );
00066     void cbLastRowChanged( bool );
00067     void cbLastColChanged( bool );
00068     void cbBodyChanged( bool );
00069 
00070 protected:
00071     int bottomBorder(const int rows, const int cols, const int rowpos, const int colpos);
00072     int rightBorder(const int rows, const int cols, const int rowpos, const int colpos);
00073     void drawCell( QPainter *p, const KWTableStyle *ts, const QRect globalRect,
00074                    const int rows, int cols, int rowpos, int colpos, const QString & txt);
00075     void drawPreviewTable(QPainter *p, int rows, int cols, QRect globalRect);
00076     void drawContents( QPainter *p );
00077     void setSpecialCells(KWTableTemplate *);
00078 
00079     KWTableStyle *m_emptyStyle;
00080     KWTextDocument *m_textdoc;
00081     KoTextZoomHandler *m_zoomHandler;
00082     KWTableTemplate *tableTemplate;
00083     KWTableTemplate *origTableTemplate;
00084     //necessary when we init preview
00085     bool m_disableRepaint;
00086 private:
00087     QString m_contents[2][5];
00088 
00089     void fillContents();
00090 };
00091 
00092 /******************************************************************/
00093 /* Class: KWTableTemplateSelector                                    */
00094 /******************************************************************/
00095 
00096 class KWTableTemplateSelector : public QWidget
00097 {
00098     Q_OBJECT
00099 
00100 public:
00101     enum FormatType { FirstRow = 1 , FirstColumn = 2, LastRow = 4, LastCol =8, Body =16 };
00102     KWTableTemplateSelector( KWDocument *_doc, QWidget * _parent, const QString & _tableTemplate, int _type = 31 , const char * _name = 0 );
00103 
00104     KWTableTemplate *getTableTemplate()const ;
00105     int getFormatType() const ;
00106 protected:
00107     KWDocument *m_doc;
00108 
00109     KWTableTemplatePreview *preview;
00110     QLabel *lTemplates;
00111     QListBox *lbTemplates;
00112     QPushButton *pbCustomize;
00113 
00114     QButtonGroup *bgCustomize;
00115     QCheckBox *cbFirstRow, *cbFirstCol, *cbLastRow, *cbLastCol, *cbBody;
00116 
00117     int selectedTableTemplate;
00118     void initFormat( int format);
00119     void initPreview();
00120 protected slots:
00121     void changeTableTemplate();
00122 };
00123 
00124 #endif
00125 
00126 
KDE Home | KDE Accessibility Home | Description of Access Keys