Back to index

scribus-ng  1.3.4.dfsg+svn20071115
colorcombo.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /*
00008  *  sccombobox.h
00009  *  ScribusCVS
00010  *
00011  *  Created by Andreas Vox on 01.10.05.
00012  *  Copyright 2005 under GPL2. All rights reserved.
00013  *
00014  */
00015 
00016 #include <qlistbox.h>
00017 #include "colorcombo.h"
00018 #include "colorcombo.moc"
00019 #include "commonstrings.h"
00020 
00021 
00022 ColorCombo::ColorCombo( QWidget* parent, const char* name ) : QComboBox(false, parent, name)
00023 {
00024 #ifdef QT_MAC
00025        setStyle( new ColorCombo::ScMacStyle() );
00026 #endif
00027        setListBox( new ColorListBox( this, "in-combo", WType_Popup ) );
00028 }
00029 
00030 ColorCombo::ColorCombo( bool rw, QWidget* parent, const char* name ) : QComboBox(rw, parent, name)
00031 {
00032 #ifdef QT_MAC
00033        setStyle( new ColorCombo::ScMacStyle() );
00034 #endif
00035        setListBox( new ColorListBox( this, "in-combo", WType_Popup ) );
00036 }
00037 
00038 void ColorCombo::updateBox(ColorList& list, ColorCombo::PixmapType pixType , bool insertNone)
00039 {
00040        ColorListBox* clb = (ColorListBox*) listBox();
00041        if ( clb )
00042        {
00043               clb->clear();
00044               if ( insertNone )
00045                      clb->insertItem(CommonStrings::tr_NoneColor);
00046               if ( pixType == ColorCombo::fancyPixmaps )
00047                      clb->insertItems(list, ColorListBox::fancyPixmap);
00048               else if ( pixType == ColorCombo::widePixmaps )
00049                      clb->insertItems(list, ColorListBox::widePixmap);
00050               else if ( pixType == ColorCombo::smallPixmaps )
00051                      clb->insertItems(list, ColorListBox::smallPixmap);
00052        }
00053 }
00054 
00055 void ColorCombo::insertItems(ColorList& list, ColorCombo::PixmapType pixType)
00056 {
00057        ColorListBox* clb = (ColorListBox*) listBox();
00058        if ( clb )
00059        {
00060               if ( pixType == ColorCombo::fancyPixmaps )
00061                      clb->insertItems(list, ColorListBox::fancyPixmap);
00062               else if ( pixType == ColorCombo::widePixmaps )
00063                      clb->insertItems(list, ColorListBox::widePixmap);
00064               else if ( pixType == ColorCombo::smallPixmaps )
00065                      clb->insertItems(list, ColorListBox::smallPixmap);
00066        }
00067 }
00068 
00069 void ColorCombo::insertSmallItem( const ScColor& col, ScribusDoc* doc, const QString& colName )
00070 {
00071        ColorListBox* clb = (ColorListBox*) listBox();
00072        if ( clb )
00073               clb->insertItem( new ColorSmallPixmapItem(col, doc, colName) );
00074 }
00075 
00076 void ColorCombo::insertWideItem ( const ScColor& col, ScribusDoc* doc, const QString& colName )
00077 {
00078        ColorListBox* clb = (ColorListBox*) listBox();
00079        if ( clb )
00080               clb->insertItem( new ColorWidePixmapItem(col, doc, colName) );
00081 }
00082 
00083 void ColorCombo::insertFancyItem( const ScColor& col, ScribusDoc* doc, const QString& colName )
00084 {
00085        ColorListBox* clb = (ColorListBox*) listBox();
00086        if ( clb )
00087               clb->insertItem( new ColorFancyPixmapItem(col, doc, colName) );
00088 }
00089