Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

cellformat.h

Go to the documentation of this file.
00001 /*
00002                =.            This file is part of the Opie Project
00003              .=l.            Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org>
00004            .>+-=
00005  _;:,     .>    :=|.         This program is free software; you can
00006 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00007 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00008 .="- .-=="i,     .._         License as published by the Free Software
00009  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00010      ._= =}       :          or (at your option) any later version.
00011     .%`+i>       _;_.
00012     .i_,=:_.      -<s.       This program is distributed in the hope that
00013      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00014     : ..    .:,     . . .    without even the implied warranty of
00015     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00016   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00017 ..}^=.=       =       ;      Library General Public License for more
00018 ++=   -.     .`     .:       details.
00019  :     =  ...= . :.=-
00020  -.   .:....=;==+<;          You should have received a copy of the GNU
00021   -_. . .   )=.  =           Library General Public License along with
00022     --        :-=`           this library; see the file COPYING.LIB.
00023                              If not, write to the Free Software Foundation,
00024                              Inc., 59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
00026 
00027 */
00028 
00029 /*
00030  * Opie Sheet (formerly Sheet/Qt)
00031  * by Serdar Ozler <sozler@sitebest.com>
00032  */
00033 
00034 #ifndef CELLFORMAT_H
00035 #define CELLFORMAT_H
00036 
00037 #include "sheet.h"
00038 
00039 /* OPIE */
00040 #include <qpe/fontdatabase.h>
00041 
00042 /* QT */
00043 #include <qdialog.h>
00044 #include <qtabwidget.h>
00045 #include <qlayout.h>
00046 #include <qcombobox.h>
00047 #include <qcheckbox.h>
00048 #include <qpushbutton.h>
00049 
00050 class BorderEditor: public QFrame
00051 {
00052     Q_OBJECT
00053 
00054     // QT objects
00055     QPen penTop, penBottom, penLeft, penRight, penHorz, penVert;
00056 
00057     // Private functions
00058     void drawContents(QPainter *p);
00059 
00060     // Reimplemented QFrame functions
00061     void mouseReleaseEvent(QMouseEvent *e);
00062 
00063 public:
00064     // Definitions
00065     enum BorderArea {None, Top, Bottom, Left, Right, Horz, Vert};
00066 
00067     BorderEditor(QWidget *parent=0);
00068     ~BorderEditor();
00069 
00070     void setPen(const QPen &pen, BorderArea area);
00071     QPen getPen(BorderArea area);
00072     QPen getDefaultPen()                      { return QPen(Qt::black, 1, Qt::DotLine); }
00073 
00074 signals:
00075     void clicked(BorderEditor::BorderArea);
00076 };
00077 
00078 class CellFormat: public QDialog
00079 {
00080     Q_OBJECT
00081 
00082     enum comboType {COMBO_OTHER, COMBO_WIDTH, COMBO_FONT, COMBO_SIZE, COMBO_STYLE, COMBO_COLOR, COMBO_VALIGN, COMBO_HALIGN};
00083 
00084     // QT objects
00085     QBoxLayout *box;
00086     QTabWidget *tabs;
00087     QWidget *widgetBorders, *widgetBackground, *widgetFont, *widgetAlignment;
00088     QComboBox *comboBordersWidth, *comboBordersColor, *comboBackgroundColor, *comboBackgroundStyle, *comboFontColor, *comboFontSize, *comboFontFamily, *comboAlignmentVertical, *comboAlignmentHorizontal;
00089     QCheckBox *checkFontBold, *checkFontItalic, *checkAlignmentWrap;
00090     QPushButton *buttonBordersDefaults, *buttonBackgroundDefaults, *buttonFontDefaults, *buttonAlignmentDefaults;
00091     QFrame *frameBackground, *frameFont, *frameAlignment;
00092     QBrush brushBackground;
00093     QFont fontFont;
00094     QColor fontColor;
00095     Qt::AlignmentFlags textAlignment;
00096     FontDatabase fontDB;
00097 
00098     // Other objects & variables
00099     Sheet *sheet;
00100     BorderEditor *borderEditor;
00101     bool changedFont, changedAlign, changedBrush;
00102 
00103     // Private functions
00104     void createWidthCombo(QComboBox *combo);
00105     void createFontCombo(QComboBox *combo);
00106     void createHAlignCombo(QComboBox *combo);
00107     void createVAlignCombo(QComboBox *combo);
00108     void createStyleCombo(QComboBox *combo);
00109     void createSizeCombo(QComboBox *combo);
00110     void createColorCombo(QComboBox *combo);
00111     QComboBox *createCombo(comboType type, QWidget *parent, const QString &caption, int y);
00112 
00113     int findHAlignIndex(Qt::AlignmentFlags flag);
00114     int findVAlignIndex(Qt::AlignmentFlags flag);
00115     int findComboItemIndex(QComboBox *combo, const QString &item);
00116     int findColorIndex(const QColor &color);
00117     int findBrushStyleIndex(Qt::BrushStyle style);
00118 
00119 private slots:
00120     void borderClicked(BorderEditor::BorderArea area);
00121     void backgroundClicked(int index);
00122     void fontClicked(bool on);
00123     void fontClicked(int index);
00124     void alignClicked(bool on);
00125     void alignClicked(int index);
00126     void slotBordersDefaults();
00127     void slotBackgroundDefaults();
00128     void slotFontDefaults();
00129     void slotAlignmentDefaults();
00130 
00131 public:
00132     CellFormat(QWidget *parent=0);
00133     ~CellFormat();
00134 
00135     int exec(Sheet *s);
00136 
00137     void setTextAlign(Qt::AlignmentFlags flags);
00138     void setTextFont(const QFont &font, const QColor &color);
00139     void setBrushBackground(const QBrush &brush);
00140 };
00141 
00142 #endif

Generated on Sat Nov 5 16:17:00 2005 for OPIE by  doxygen 1.4.2