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

newpagedialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   DrawPad - a drawing program for Opie Environment                      *
00004  *                                                                         *
00005  *   (C) 2002 by S. Prud'homme <prudhomme@laposte.net>                     *
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  ***************************************************************************/
00013 
00014 #include "newpagedialog.h"
00015 
00016 #include <qbuttongroup.h>
00017 #include <qlabel.h>
00018 #include <qlayout.h>
00019 #include <qlineedit.h>
00020 #include <qradiobutton.h>
00021 #include <qspinbox.h>
00022 
00023 NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor,
00024                              const QColor& brushColor, QWidget* parent, const char* name)
00025     : QDialog(parent, name, true)
00026 {
00027     setCaption(tr("New Page"));
00028 
00029     m_penColor = penColor;
00030     m_brushColor = brushColor;
00031 
00032     QGroupBox* generalGroupBox = new QGroupBox(0, Qt::Vertical, tr("General"), this);
00033 
00034     QLabel* titleLabel = new QLabel(tr("Title:"), generalGroupBox);
00035     m_pTitleLineEdit = new QLineEdit(generalGroupBox);
00036 
00037     QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Size"), this);
00038 
00039     QLabel* widthLabel = new QLabel(tr("Width:"), sizeGroupBox);
00040     QLabel* heightLabel = new QLabel(tr("Height:"), sizeGroupBox);
00041 
00042     m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
00043     m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
00044 
00045     m_pWidthSpinBox->setValue(width);
00046     m_pHeightSpinBox->setValue(height);
00047 
00048     m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this);
00049 
00050     QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup);
00051     QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup);
00052     QRadioButton* brushColorRadioButton = new QRadioButton(tr("Fill Color"), m_pContentButtonGroup);
00053 
00054     m_pContentButtonGroup->setButton(0);
00055 
00056     QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
00057     generalGroupBox->layout()->setSpacing(4);
00058     sizeGroupBox->layout()->setSpacing(4);
00059     m_pContentButtonGroup->layout()->setSpacing(4);
00060     QGridLayout* generalLayout = new QGridLayout(generalGroupBox->layout(), 1, 1);
00061     QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
00062     QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout());
00063 
00064     generalLayout->addWidget(titleLabel, 0, 0);
00065     generalLayout->addWidget(m_pTitleLineEdit, 0, 1);
00066 
00067     sizeLayout->addWidget(widthLabel, 0, 0);
00068     sizeLayout->addWidget(heightLabel, 1, 0);
00069     sizeLayout->addWidget(m_pWidthSpinBox, 0, 1);
00070     sizeLayout->addWidget(m_pHeightSpinBox, 1, 1);
00071 
00072     sizeLayout->setColStretch(1, 1);
00073 
00074     contentLayout->addWidget(whiteColorRadioButton);
00075     contentLayout->addWidget(penColorRadioButton);
00076     contentLayout->addWidget(brushColorRadioButton);
00077 
00078     mainLayout->addWidget(generalGroupBox);
00079     mainLayout->addWidget(sizeGroupBox);
00080     mainLayout->addWidget(m_pContentButtonGroup);
00081 }
00082 
00083 NewPageDialog::~NewPageDialog()
00084 {
00085 }
00086 
00087 QString NewPageDialog::selectedTitle()
00088 {
00089     return (m_pTitleLineEdit->text());
00090 }
00091 
00092 uint NewPageDialog::selectedWidth()
00093 {
00094     return (m_pWidthSpinBox->value());
00095 }
00096 
00097 uint NewPageDialog::selectedHeight()
00098 {
00099     return (m_pHeightSpinBox->value());
00100 }
00101 
00102 const QColor& NewPageDialog::selectedColor()
00103 {
00104     switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) {
00105         case 0:
00106             return (Qt::white);
00107             break;
00108         case 1:
00109             return (m_penColor);
00110             break;
00111         case 2:
00112             return (m_brushColor);
00113             break;
00114         default:
00115             return (Qt::white);
00116             break;
00117     }
00118 }

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