summaryrefslogtreecommitdiffstats
path: root/examples/i18n/mywidget.cpp
blob: 94e21144e75af87f37de0b0eb9e90dfb46bff74a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/****************************************************************************
**
** 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 <qbuttongroup.h>
#include <qradiobutton.h>
#include <qlabel.h>
#include <qlistbox.h>
#include <qcombobox.h>
#include <qlabel.h>
#include <qhbox.h>
#include <qvbox.h>
#include <qaccel.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qstatusbar.h>
#include <qapplication.h>

#include "mywidget.h"

MyWidget::MyWidget( TQWidget* parent, const char* name )
	: TQMainWindow( parent, name )
{
    TQVBox* central = new TQVBox(this);
    central->setMargin( 5 ); 
    central->setSpacing( 5 ); 
    setCentralWidget(central);

    TQPopupMenu* file = new TQPopupMenu(this);
    file->insertItem( tr("E&xit"), qApp, SLOT(tquit()),
            TQAccel::stringToKey(tr("Ctrl+Q")) );
    menuBar()->insertItem( tr("&File"), file );

    setCaption( tr( "Internationalization Example" ) ); 

    TQString l;
    statusBar()->message( tr("Language: English") );

    ( void )new TQLabel( tr( "The Main Window" ), central ); 

    TQButtonGroup* gbox = new TQButtonGroup( 1, TQGroupBox::Horizontal, 
				      tr( "View" ), central ); 
    (void)new TQRadioButton( tr( "Perspective" ), gbox ); 
    (void)new TQRadioButton( tr( "Isometric" ), gbox ); 
    (void)new TQRadioButton( tr( "Oblique" ), gbox ); 

    initChoices(central); 
}

static const char* choices[] = {
    QT_TRANSLATE_NOOP( "MyWidget", "First" ), 
    QT_TRANSLATE_NOOP( "MyWidget", "Second" ), 
    QT_TRANSLATE_NOOP( "MyWidget", "Third" ), 
    0
}; 

void MyWidget::initChoices(TQWidget* parent)
{
    TQListBox* lb = new TQListBox( parent ); 
    for ( int i = 0; choices[i]; i++ )
	lb->insertItem( tr( choices[i] ) ); 
}

void MyWidget::closeEvent(TQCloseEvent* e)
{
    TQWidget::closeEvent(e);
    emit closed();
}