diff options
author | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/themes/themes.cpp | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/themes/themes.cpp')
-rw-r--r-- | examples/themes/themes.cpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/examples/themes/themes.cpp b/examples/themes/themes.cpp new file mode 100644 index 000000000..6e5b95bb9 --- /dev/null +++ b/examples/themes/themes.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of an example program for TQt. This example +** program may be used, distributed and modified without limitation. +** +*****************************************************************************/ + +#include "themes.h" +#include "wood.h" +#include "metal.h" + +#include "../buttongroups/buttongroups.h" +#include "../lineedits/lineedits.h" +#include "../listboxcombo/listboxcombo.h" +#include "../checklists/checklists.h" +#include "../progressbar/progressbar.h" +#include "../rangecontrols/rangecontrols.h" +#include "../richtext/richtext.h" + +#include <qtabwidget.h> +#include <qapplication.h> +#include <qpopupmenu.h> +#include <qmenubar.h> +#include <qmessagebox.h> +#include <qfont.h> +#include <qstylefactory.h> +#include <qaction.h> +#include <qsignalmapper.h> +#include <qdict.h> + +Themes::Themes( TQWidget *parent, const char *name, WFlags f ) + : TQMainWindow( parent, name, f ) +{ + appFont = TQApplication::font(); + tabwidget = new TQTabWidget( this ); + + tabwidget->addTab( new ButtonsGroups( tabwidget ), "Buttons/Groups" ); + TQHBox *hbox = new TQHBox( tabwidget ); + hbox->setMargin( 5 ); + (void)new LineEdits( hbox ); + (void)new ProgressBar( hbox ); + tabwidget->addTab( hbox, "Lineedits/Progressbar" ); + tabwidget->addTab( new ListBoxCombo( tabwidget ), "Listboxes/Comboboxes" ); + tabwidget->addTab( new CheckLists( tabwidget ), "Listviews" ); + tabwidget->addTab( new RangeControls( tabwidget ), "Rangecontrols" ); + tabwidget->addTab( new MyRichText( tabwidget ), "Fortune" ); + + setCentralWidget( tabwidget ); + + TQPopupMenu *style = new TQPopupMenu( this ); + style->setCheckable( TRUE ); + menuBar()->insertItem( "&Style" , style ); + + style->setCheckable( TRUE ); + TQActionGroup *ag = new TQActionGroup( this, 0 ); + ag->setExclusive( TRUE ); + TQSignalMapper *styleMapper = new TQSignalMapper( this ); + connect( styleMapper, SIGNAL( mapped( const TQString& ) ), this, SLOT( makeStyle( const TQString& ) ) ); + TQStringList list = TQStyleFactory::keys(); + list.sort(); +#ifndef QT_NO_STYLE_WINDOWS + list.insert(list.begin(), "Norwegian Wood"); + list.insert(list.begin(), "Metal"); +#endif + TQDict<int> stylesDict( 17, FALSE ); + for ( TQStringList::Iterator it = list.begin(); it != list.end(); ++it ) { + TQString styleStr = *it; + TQString styleAccel = styleStr; + if ( stylesDict[styleAccel.left(1)] ) { + for ( uint i = 0; i < styleAccel.length(); i++ ) { + if ( !stylesDict[styleAccel.mid( i, 1 )] ) { + stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1); + styleAccel = styleAccel.insert( i, '&' ); + break; + } + } + } else { + stylesDict.insert(styleAccel.left(1), (const int *)1); + styleAccel = "&"+styleAccel; + } + TQAction *a = new TQAction( styleStr, TQIconSet(), styleAccel, 0, ag, 0, ag->isExclusive() ); + connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) ); + styleMapper->setMapping( a, a->text() ); + } + ag->addTo(style); + style->insertSeparator(); + style->insertItem("&Quit", qApp, SLOT( tquit() ), CTRL | Key_Q ); + + TQPopupMenu * help = new TQPopupMenu( this ); + menuBar()->insertSeparator(); + menuBar()->insertItem( "&Help", help ); + help->insertItem( "&About", this, SLOT(about()), Key_F1); + help->insertItem( "About &TQt", this, SLOT(aboutTQt())); + +#ifndef QT_NO_STYLE_WINDOWS + qApp->setStyle( new NorwegianWoodStyle ); +#endif +} + +void Themes::makeStyle(const TQString &style) +{ + if(style == "Norwegian Wood") { +#ifndef QT_NO_STYLE_WINDOWS + qApp->setStyle( new NorwegianWoodStyle ); +#endif + } else if( style == "Metal" ) { +#ifndef QT_NO_STYLE_WINDOWS + qApp->setStyle( new MetalStyle ); +#endif + } else { + qApp->setStyle(style); + if(style == "Platinum") { + TQPalette p( TQColor( 239, 239, 239 ) ); + qApp->setPalette( p, TRUE ); + qApp->setFont( appFont, TRUE ); + } else if(style == "Windows") { + qApp->setFont( appFont, TRUE ); + } else if(style == "CDE") { + TQPalette p( TQColor( 75, 123, 130 ) ); + p.setColor( TQPalette::Active, TQColorGroup::Base, TQColor( 55, 77, 78 ) ); + p.setColor( TQPalette::Inactive, TQColorGroup::Base, TQColor( 55, 77, 78 ) ); + p.setColor( TQPalette::Disabled, TQColorGroup::Base, TQColor( 55, 77, 78 ) ); + p.setColor( TQPalette::Active, TQColorGroup::Highlight, TQt::white ); + p.setColor( TQPalette::Active, TQColorGroup::HighlightedText, TQColor( 55, 77, 78 ) ); + p.setColor( TQPalette::Inactive, TQColorGroup::Highlight, TQt::white ); + p.setColor( TQPalette::Inactive, TQColorGroup::HighlightedText, TQColor( 55, 77, 78 ) ); + p.setColor( TQPalette::Disabled, TQColorGroup::Highlight, TQt::white ); + p.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, TQColor( 55, 77, 78 ) ); + p.setColor( TQPalette::Active, TQColorGroup::Foreground, TQt::white ); + p.setColor( TQPalette::Active, TQColorGroup::Text, TQt::white ); + p.setColor( TQPalette::Active, TQColorGroup::ButtonText, TQt::white ); + p.setColor( TQPalette::Inactive, TQColorGroup::Foreground, TQt::white ); + p.setColor( TQPalette::Inactive, TQColorGroup::Text, TQt::white ); + p.setColor( TQPalette::Inactive, TQColorGroup::ButtonText, TQt::white ); + p.setColor( TQPalette::Disabled, TQColorGroup::Foreground, TQt::lightGray ); + p.setColor( TQPalette::Disabled, TQColorGroup::Text, TQt::lightGray ); + p.setColor( TQPalette::Disabled, TQColorGroup::ButtonText, TQt::lightGray ); + qApp->setPalette( p, TRUE ); + qApp->setFont( TQFont( "times", appFont.pointSize() ), TRUE ); + } else if(style == "Motif" || style == "MotifPlus") { + TQPalette p( TQColor( 192, 192, 192 ) ); + qApp->setPalette( p, TRUE ); + qApp->setFont( appFont, TRUE ); + } + } +} + +void Themes::about() +{ + TQMessageBox::about( this, "TQt Themes Example", + "<p>This example demonstrates the concept of " + "<b>generalized GUI styles </b> first introduced " + " with the 2.0 release of TQt.</p>" ); +} + + +void Themes::aboutTQt() +{ + TQMessageBox::aboutTQt( this, "TQt Themes Example" ); +} + + |