From ea318d1431c89e647598c510c4245c6571aa5f46 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Thu, 26 Jan 2012 23:32:43 -0600 Subject: Update to latest tqt3 automated conversion --- doc/html/menu-example.html | 280 ++++++++++++++++++++++----------------------- 1 file changed, 140 insertions(+), 140 deletions(-) (limited to 'doc/html/menu-example.html') diff --git a/doc/html/menu-example.html b/doc/html/menu-example.html index d734a8531..b611166cd 100644 --- a/doc/html/menu-example.html +++ b/doc/html/menu-example.html @@ -51,16 +51,16 @@ context menu. #ifndef MENU_H #define MENU_H -#include <qwidget.h> -#include <qmenubar.h> -#include <qlabel.h> +#include <ntqwidget.h> +#include <ntqmenubar.h> +#include <ntqlabel.h> -class MenuExample : public TQWidget +class MenuExample : public TQWidget { Q_OBJECT public: - MenuExample( TQWidget *parent=0, const char *name=0 ); + MenuExample( TQWidget *parent=0, const char *name=0 ); public slots: void open(); @@ -83,14 +83,14 @@ protected: void resizeEvent( TQResizeEvent * ); signals: - void explain( const TQString& ); + void explain( const TQString& ); private: void contextMenuEvent ( TQContextMenuEvent * ); - TQMenuBar *menu; - TQLabel *label; + TQMenuBar *menu; + TQLabel *label; bool isBold; bool isUnderline; int boldID, underlineID; @@ -113,12 +113,12 @@ private: *****************************************************************************/ #include "menu.h" -#include <qcursor.h> -#include <qpopupmenu.h> -#include <qapplication.h> -#include <qmessagebox.h> -#include <qpixmap.h> -#include <qpainter.h> +#include <ntqcursor.h> +#include <ntqpopupmenu.h> +#include <ntqapplication.h> +#include <ntqmessagebox.h> +#include <ntqpixmap.h> +#include <ntqpainter.h> /* XPM */ static const char * p1_xpm[] = { @@ -198,140 +198,140 @@ static const char * p3_xpm[] = { class MyMenuItem : public TQCustomMenuItem { public: - MyMenuItem( const TQString& s, const TQFont& f ) + MyMenuItem( const TQString& s, const TQFont& f ) : string( s ), font( f ){}; ~MyMenuItem(){} - void paint( TQPainter* p, const TQColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h ) + void paint( TQPainter* p, const TQColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h ) { - p->setFont ( font ); - p->drawText( x, y, w, h, AlignLeft | AlignVCenter | DontClip | ShowPrefix, string ); + p->setFont ( font ); + p->drawText( x, y, w, h, AlignLeft | AlignVCenter | DontClip | ShowPrefix, string ); } - TQSize sizeHint() + TQSize sizeHint() { return TQFontMetrics( font ).size( AlignLeft | AlignVCenter | ShowPrefix | DontClip, string ); } private: - TQString string; - TQFont font; + TQString string; + TQFont font; }; -MenuExample::MenuExample( TQWidget *parent, const char *name ) - : TQWidget( parent, name ) +MenuExample::MenuExample( TQWidget *parent, const char *name ) + : TQWidget( parent, name ) { - TQPixmap p1( p1_xpm ); - TQPixmap p2( p2_xpm ); - TQPixmap p3( p3_xpm ); - TQPopupMenu *print = new TQPopupMenu( this ); - Q_CHECK_PTR( print ); - print->insertTearOffHandle(); - print->insertItem( "&Print to printer", this, SLOT(printer()) ); - print->insertItem( "Print to &file", this, SLOT(file()) ); - print->insertItem( "Print to fa&x", this, SLOT(fax()) ); - print->insertSeparator(); - print->insertItem( "Printer &Setup", this, SLOT(printerSetup()) ); - - TQPopupMenu *file = new TQPopupMenu( this ); - Q_CHECK_PTR( file ); - file->insertItem( p1, "&Open", this, SLOT(open()), CTRL+Key_O ); - file->insertItem( p2, "&New", this, SLOT(news()), CTRL+Key_N ); - file->insertItem( p3, "&Save", this, SLOT(save()), CTRL+Key_S ); - file->insertItem( "&Close", this, SLOT(closeDoc()), CTRL+Key_W ); - file->insertSeparator(); - file->insertItem( "&Print", print, CTRL+Key_P ); - file->insertSeparator(); - file->insertItem( "E&xit", qApp, SLOT(quit()), CTRL+Key_Q ); - - TQPopupMenu *edit = new TQPopupMenu( this ); - Q_CHECK_PTR( edit ); - int undoID = edit->insertItem( "&Undo", this, SLOT(undo()) ); - int redoID = edit->insertItem( "&Redo", this, SLOT(redo()) ); - edit->setItemEnabled( undoID, FALSE ); - edit->setItemEnabled( redoID, FALSE ); - - TQPopupMenu* options = new TQPopupMenu( this ); - Q_CHECK_PTR( options ); - options->insertTearOffHandle(); - options->setCaption("Options"); - options->insertItem( "&Normal Font", this, SLOT(normal()) ); - options->insertSeparator(); - - options->polish(); // adjust system settings - TQFont f = options->font(); - f.setBold( TRUE ); - boldID = options->insertItem( new MyMenuItem( "Bold", f ) ); - options->setAccel( CTRL+Key_B, boldID ); - options->connectItem( boldID, this, SLOT(bold()) ); - f = font(); - f.setUnderline( TRUE ); - underlineID = options->insertItem( new MyMenuItem( "Underline", f ) ); - options->setAccel( CTRL+Key_U, underlineID ); - options->connectItem( underlineID, this, SLOT(underline()) ); + TQPixmap p1( p1_xpm ); + TQPixmap p2( p2_xpm ); + TQPixmap p3( p3_xpm ); + TQPopupMenu *print = new TQPopupMenu( this ); + Q_CHECK_PTR( print ); + print->insertTearOffHandle(); + print->insertItem( "&Print to printer", this, SLOT(printer()) ); + print->insertItem( "Print to &file", this, SLOT(file()) ); + print->insertItem( "Print to fa&x", this, SLOT(fax()) ); + print->insertSeparator(); + print->insertItem( "Printer &Setup", this, SLOT(printerSetup()) ); + + TQPopupMenu *file = new TQPopupMenu( this ); + Q_CHECK_PTR( file ); + file->insertItem( p1, "&Open", this, SLOT(open()), CTRL+Key_O ); + file->insertItem( p2, "&New", this, SLOT(news()), CTRL+Key_N ); + file->insertItem( p3, "&Save", this, SLOT(save()), CTRL+Key_S ); + file->insertItem( "&Close", this, SLOT(closeDoc()), CTRL+Key_W ); + file->insertSeparator(); + file->insertItem( "&Print", print, CTRL+Key_P ); + file->insertSeparator(); + file->insertItem( "E&xit", qApp, SLOT(quit()), CTRL+Key_Q ); + + TQPopupMenu *edit = new TQPopupMenu( this ); + Q_CHECK_PTR( edit ); + int undoID = edit->insertItem( "&Undo", this, SLOT(undo()) ); + int redoID = edit->insertItem( "&Redo", this, SLOT(redo()) ); + edit->setItemEnabled( undoID, FALSE ); + edit->setItemEnabled( redoID, FALSE ); + + TQPopupMenu* options = new TQPopupMenu( this ); + Q_CHECK_PTR( options ); + options->insertTearOffHandle(); + options->setCaption("Options"); + options->insertItem( "&Normal Font", this, SLOT(normal()) ); + options->insertSeparator(); + + options->polish(); // adjust system settings + TQFont f = options->font(); + f.setBold( TRUE ); + boldID = options->insertItem( new MyMenuItem( "Bold", f ) ); + options->setAccel( CTRL+Key_B, boldID ); + options->connectItem( boldID, this, SLOT(bold()) ); + f = font(); + f.setUnderline( TRUE ); + underlineID = options->insertItem( new MyMenuItem( "Underline", f ) ); + options->setAccel( CTRL+Key_U, underlineID ); + options->connectItem( underlineID, this, SLOT(underline()) ); isBold = FALSE; isUnderline = FALSE; - options->setCheckable( TRUE ); + options->setCheckable( TRUE ); - TQPopupMenu *help = new TQPopupMenu( this ); - Q_CHECK_PTR( help ); - help->insertItem( "&About", this, SLOT(about()), CTRL+Key_H ); - help->insertItem( "About &TQt", this, SLOT(aboutTQt()) ); + TQPopupMenu *help = new TQPopupMenu( this ); + Q_CHECK_PTR( help ); + help->insertItem( "&About", this, SLOT(about()), CTRL+Key_H ); + help->insertItem( "About &TQt", this, SLOT(aboutTQt()) ); // If we used a TQMainWindow we could use its built-in menuBar(). - menu = new TQMenuBar( this ); - Q_CHECK_PTR( menu ); - menu->insertItem( "&File", file ); - menu->insertItem( "&Edit", edit ); - menu->insertItem( "&Options", options ); - menu->insertSeparator(); - menu->insertItem( "&Help", help ); - menu->setSeparator( TQMenuBar::InWindowsStyle ); - - - TQLabel *msg = new TQLabel( this ); - Q_CHECK_PTR( msg ); - msg->setText( "A context menu is available.\n" + menu = new TQMenuBar( this ); + Q_CHECK_PTR( menu ); + menu->insertItem( "&File", file ); + menu->insertItem( "&Edit", edit ); + menu->insertItem( "&Options", options ); + menu->insertSeparator(); + menu->insertItem( "&Help", help ); + menu->setSeparator( TQMenuBar::InWindowsStyle ); + + + TQLabel *msg = new TQLabel( this ); + Q_CHECK_PTR( msg ); + msg->setText( "A context menu is available.\n" "Invoke it by right-clicking or by" " pressing the 'context' button." ); - msg->setGeometry( 0, height() - 60, width(), 60 ); - msg->setAlignment( AlignCenter ); + msg->setGeometry( 0, height() - 60, width(), 60 ); + msg->setAlignment( AlignCenter ); - label = new TQLabel( this ); - Q_CHECK_PTR( label ); - label->setGeometry( 20, rect().center().y()-20, width()-40, 40 ); - label->setFrameStyle( TQFrame::Box | TQFrame::Raised ); - label->setLineWidth( 1 ); - label->setAlignment( AlignCenter ); + label = new TQLabel( this ); + Q_CHECK_PTR( label ); + label->setGeometry( 20, rect().center().y()-20, width()-40, 40 ); + label->setFrameStyle( TQFrame::Box | TQFrame::Raised ); + label->setLineWidth( 1 ); + label->setAlignment( AlignCenter ); - connect( this, SIGNAL(explain(const TQString&)), - label, SLOT(setText(const TQString&)) ); + connect( this, SIGNAL(explain(const TQString&)), + label, SLOT(setText(const TQString&)) ); - setMinimumSize( 100, 80 ); - setFocusPolicy( TQWidget::ClickFocus ); + setMinimumSize( 100, 80 ); + setFocusPolicy( TQWidget::ClickFocus ); } -void MenuExample::contextMenuEvent( TQContextMenuEvent * ) +void MenuExample::contextMenuEvent( TQContextMenuEvent * ) { - TQPopupMenu* contextMenu = new TQPopupMenu( this ); - Q_CHECK_PTR( contextMenu ); - TQLabel *caption = new TQLabel( "<font color=darkblue><u><b>" + TQPopupMenu* contextMenu = new TQPopupMenu( this ); + Q_CHECK_PTR( contextMenu ); + TQLabel *caption = new TQLabel( "<font color=darkblue><u><b>" "Context Menu</b></u></font>", this ); - caption->setAlignment( TQt::AlignCenter ); - contextMenu->insertItem( caption ); - contextMenu->insertItem( "&New", this, SLOT(news()), CTRL+Key_N ); - contextMenu->insertItem( "&Open...", this, SLOT(open()), CTRL+Key_O ); - contextMenu->insertItem( "&Save", this, SLOT(save()), CTRL+Key_S ); - TQPopupMenu *submenu = new TQPopupMenu( this ); - Q_CHECK_PTR( submenu ); - submenu->insertItem( "&Print to printer", this, SLOT(printer()) ); - submenu->insertItem( "Print to &file", this, SLOT(file()) ); - submenu->insertItem( "Print to fa&x", this, SLOT(fax()) ); - contextMenu->insertItem( "&Print", submenu ); - contextMenu->exec( TQCursor::pos() ); + caption->setAlignment( TQt::AlignCenter ); + contextMenu->insertItem( caption ); + contextMenu->insertItem( "&New", this, SLOT(news()), CTRL+Key_N ); + contextMenu->insertItem( "&Open...", this, SLOT(open()), CTRL+Key_O ); + contextMenu->insertItem( "&Save", this, SLOT(save()), CTRL+Key_S ); + TQPopupMenu *submenu = new TQPopupMenu( this ); + Q_CHECK_PTR( submenu ); + submenu->insertItem( "&Print to printer", this, SLOT(printer()) ); + submenu->insertItem( "Print to &file", this, SLOT(file()) ); + submenu->insertItem( "Print to fa&x", this, SLOT(fax()) ); + contextMenu->insertItem( "&Print", submenu ); + contextMenu->exec( TQCursor::pos() ); delete contextMenu; } @@ -375,10 +375,10 @@ void MenuExample::normal() { isBold = FALSE; isUnderline = FALSE; - TQFont font; - label->setFont( font ); - menu->setItemChecked( boldID, isBold ); - menu->setItemChecked( underlineID, isUnderline ); + TQFont font; + label->setFont( font ); + menu->setItemChecked( boldID, isBold ); + menu->setItemChecked( underlineID, isUnderline ); emit explain( "Options/Normal selected" ); } @@ -386,11 +386,11 @@ void MenuExample::normal() void MenuExample::bold() { isBold = !isBold; - TQFont font; - font.setBold( isBold ); - font.setUnderline( isUnderline ); - label->setFont( font ); - menu->setItemChecked( boldID, isBold ); + TQFont font; + font.setBold( isBold ); + font.setUnderline( isUnderline ); + label->setFont( font ); + menu->setItemChecked( boldID, isBold ); emit explain( "Options/Bold selected" ); } @@ -398,18 +398,18 @@ void MenuExample::bold() void MenuExample::underline() { isUnderline = !isUnderline; - TQFont font; - font.setBold( isBold ); - font.setUnderline( isUnderline ); - label->setFont( font ); - menu->setItemChecked( underlineID, isUnderline ); + TQFont font; + font.setBold( isBold ); + font.setUnderline( isUnderline ); + label->setFont( font ); + menu->setItemChecked( underlineID, isUnderline ); emit explain( "Options/Underline selected" ); } void MenuExample::about() { - TQMessageBox::about( this, "TQt Menu Example", + TQMessageBox::about( this, "TQt Menu Example", "This example demonstrates simple use of TQt menus.\n" "You can cut and paste lines from it to your own\n" "programs." ); @@ -418,7 +418,7 @@ void MenuExample::about() void MenuExample::aboutTQt() { - TQMessageBox::aboutTQt( this, "TQt Menu Example" ); + TQMessageBox::aboutTQt( this, "TQt Menu Example" ); } @@ -443,20 +443,20 @@ void MenuExample::printerSetup() } -void MenuExample::resizeEvent( TQResizeEvent * ) +void MenuExample::resizeEvent( TQResizeEvent * ) { - label->setGeometry( 20, rect().center().y()-20, width()-40, 40 ); + label->setGeometry( 20, rect().center().y()-20, width()-40, 40 ); } int main( int argc, char ** argv ) { - TQApplication a( argc, argv ); + TQApplication a( argc, argv ); MenuExample m; - m.setCaption("TQt Examples - Menus"); - a.setMainWidget( &m ); - m.show(); - return a.exec(); + m.setCaption("TQt Examples - Menus"); + a.setMainWidget( &m ); + m.show(); + return a.exec(); } -- cgit v1.2.3