umbrello API Documentation

umlwidgetcolorpage.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #include "umlwidgetcolorpage.h"
00013 #include "../optionstate.h"
00014 #include "../umlview.h"
00015 #include "../umlwidget.h"
00016 #include <klocale.h>
00017 #include <qlayout.h>
00018 #include <qgroupbox.h>
00019 #include <qlabel.h>
00020 #include <qpushbutton.h>
00021 #include <qcheckbox.h>
00022 
00023 #include <kcolorbutton.h>
00024 
00025 UMLWidgetColorPage::UMLWidgetColorPage( QWidget *pParent, UMLWidget *pWidget ) : QWidget( pParent )
00026 {
00027     m_pUMLWidget = pWidget;
00028     m_options = 0;
00029     init();
00030     m_pLineColorB->setColor( pWidget->getLineColor() );
00031     m_pFillColorB->setColor( pWidget->getFillColour() );
00032     m_pUseFillColorCB->setChecked( pWidget -> getUseFillColour() );
00033 }
00034 
00035 UMLWidgetColorPage::UMLWidgetColorPage( QWidget * pParent, Settings::OptionState *options ) : QWidget( pParent )
00036 {
00037     m_options = options;
00038     m_pUMLWidget = 0;
00039     init();
00040     m_pLineColorB->setColor( m_options->uiState.lineColor );
00041     m_pFillColorB->setColor( m_options->uiState.fillColor );
00042     m_pUseFillColorCB->setChecked( m_options->uiState.useFillColor );
00043 }
00044 
00045 void UMLWidgetColorPage::init()
00046 {
00047     int margin = fontMetrics().height();
00048 
00049     //setup GUI
00050     QVBoxLayout * topLayout = new QVBoxLayout( this );
00051     topLayout -> setSpacing( 6 );
00052 
00053     m_pColorGB = new QGroupBox( i18n( "Color" ), this );
00054     topLayout -> addWidget( m_pColorGB );
00055     QGridLayout * colorLayout = new QGridLayout( m_pColorGB, 3, 3 );
00056     colorLayout -> setMargin( margin );
00057 
00058     m_pLineColorL = new QLabel( i18n( "&Line:" ), m_pColorGB );
00059     colorLayout -> addWidget( m_pLineColorL, 0, 0 );
00060 
00061     m_pLineColorB = new KColorButton( m_pColorGB );
00062     colorLayout -> addWidget( m_pLineColorB, 0, 1 );
00063     m_pLineColorL->setBuddy(m_pLineColorB);
00064 
00065     m_pLineDefaultB = new QPushButton( i18n( "&Default" ), m_pColorGB) ;
00066     colorLayout -> addWidget( m_pLineDefaultB, 0, 2 );
00067 
00068     m_pFillColorL = new QLabel( i18n( "&Fill:" ), m_pColorGB );
00069     colorLayout -> addWidget( m_pFillColorL, 1, 0 );
00070 
00071     m_pFillColorB = new KColorButton( m_pColorGB );
00072     colorLayout -> addWidget( m_pFillColorB, 1, 1 );
00073     m_pFillColorL->setBuddy(m_pFillColorB);
00074 
00075     m_pFillDefaultB = new QPushButton( i18n( "D&efault" ), m_pColorGB );
00076     colorLayout -> addWidget( m_pFillDefaultB, 1, 2 );
00077 
00078     m_pUseFillColorCB = new QCheckBox( i18n( "&Use fill" ), m_pColorGB );
00079     colorLayout -> setRowStretch( 2, 2 );
00080     colorLayout -> addWidget( m_pUseFillColorCB, 2, 0 );
00081 
00082     //connect button signals up
00083     connect( m_pLineDefaultB, SIGNAL( clicked() ), this, SLOT( slotLineButtonClicked() )) ;
00084     connect( m_pFillDefaultB, SIGNAL( clicked() ), this, SLOT( slotFillButtonClicked() ) );
00085 }
00086 
00087 UMLWidgetColorPage::~UMLWidgetColorPage() {}
00088 
00089 void UMLWidgetColorPage::slotLineButtonClicked() {
00090     //  UMLView * pView = dynamic_cast<UMLView *>( m_pUMLWidget -> parent() );
00091     m_pLineColorB -> setColor( Settings::getOptionState().uiState.lineColor );
00092 }
00093 
00094 void UMLWidgetColorPage::slotFillButtonClicked() {
00095     //  UMLView * pView = dynamic_cast<UMLView *>( m_pUMLWidget -> parent() );
00096     m_pFillColorB -> setColor( Settings::getOptionState().uiState.fillColor );
00097 }
00098 
00099 void UMLWidgetColorPage::updateUMLWidget() {
00100     if(m_pUMLWidget)
00101     {
00102         m_pUMLWidget->setUseFillColour( m_pUseFillColorCB -> isChecked() );
00103         m_pUMLWidget->setLineColor( m_pLineColorB -> color() );
00104         m_pUMLWidget->setFillColour( m_pFillColorB -> color() );
00105     }
00106     else if(m_options)
00107     {
00108         m_options->uiState.useFillColor = m_pUseFillColorCB -> isChecked();
00109         m_options->uiState.lineColor = m_pLineColorB -> color();
00110         m_options->uiState.fillColor = m_pFillColorB -> color();
00111     }
00112 }
00113 
00114 #include "umlwidgetcolorpage.moc"
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:02 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003