summaryrefslogtreecommitdiffstats
path: root/doc/html/chart-optionsform-cpp.html
blob: a380618517de63e5afaa59d33e94754487cd18cd (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/doc/tutorial2.doc:13 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>chart/optionsform.cpp Example File</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>chart/optionsform.cpp Example File</h1>

 
<pre>#include "optionsform.h"

#include &lt;<a href="qbuttongroup-h.html">ntqbuttongroup.h</a>&gt;
#include &lt;<a href="qcombobox-h.html">ntqcombobox.h</a>&gt;
#include &lt;<a href="tqfontdialog-h.html">tqfontdialog.h</a>&gt;
#include &lt;<a href="qframe-h.html">ntqframe.h</a>&gt;
#include &lt;<a href="tqimage-h.html">tqimage.h</a>&gt;
#include &lt;<a href="tqlabel-h.html">tqlabel.h</a>&gt;
#include &lt;<a href="qlayout-h.html">ntqlayout.h</a>&gt;
#include &lt;<a href="qpushbutton-h.html">ntqpushbutton.h</a>&gt;
#include &lt;<a href="qradiobutton-h.html">ntqradiobutton.h</a>&gt;
#include &lt;<a href="qspinbox-h.html">ntqspinbox.h</a>&gt;

#include "images/options_horizontalbarchart.xpm"
#include "images/options_piechart.xpm"
#include "images/options_verticalbarchart.xpm"


<a name="f176"></a>OptionsForm::OptionsForm( <a href="tqwidget.html">TQWidget</a>* parent, const char* name,
                          bool modal, WFlags f )
    : <a href="ntqdialog.html">TQDialog</a>( parent, name, modal, f )
{
    <a href="tqwidget.html#setCaption">setCaption</a>( "Chart -- Options" );
    <a href="tqwidget.html#resize">resize</a>( 320, 290 );

    optionsFormLayout = new <a href="qvboxlayout.html">TQVBoxLayout</a>( this, 11, 6 );

    chartTypeLayout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( 0, 0, 6 );

    chartTypeTextLabel = new <a href="tqlabel.html">TQLabel</a>( "&amp;Chart Type", this );
    chartTypeLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( chartTypeTextLabel );

    chartTypeComboBox = new <a href="ntqcombobox.html">TQComboBox</a>( FALSE, this );
    chartTypeComboBox-&gt;<a href="ntqcombobox.html#insertItem">insertItem</a>( TQPixmap( options_piechart ), "Pie Chart" );
    chartTypeComboBox-&gt;<a href="ntqcombobox.html#insertItem">insertItem</a>( TQPixmap( options_verticalbarchart ),
                                   "Vertical Bar Chart" );
    chartTypeComboBox-&gt;<a href="ntqcombobox.html#insertItem">insertItem</a>( TQPixmap( options_horizontalbarchart ),
                                   "Horizontal Bar Chart" );
    chartTypeLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( chartTypeComboBox );
    optionsFormLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( chartTypeLayout );

    fontLayout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( 0, 0, 6 );

    fontPushButton = new <a href="ntqpushbutton.html">TQPushButton</a>( "&amp;Font...", this );
    fontLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( fontPushButton );
    <a href="qspaceritem.html">TQSpacerItem</a>* spacer = new <a href="qspaceritem.html">TQSpacerItem</a>( 0, 0,
                                           TQSizePolicy::Expanding,
                                           TQSizePolicy::Minimum );
    fontLayout-&gt;<a href="qboxlayout.html#addItem">addItem</a>( spacer );

    fontTextLabel = new <a href="tqlabel.html">TQLabel</a>( this ); // Must be set by caller via setFont()
    fontLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( fontTextLabel );
    optionsFormLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( fontLayout );

    addValuesFrame = new <a href="ntqframe.html">TQFrame</a>( this );
    addValuesFrame-&gt;<a href="ntqframe.html#setFrameShape">setFrameShape</a>( TQFrame::StyledPanel );
    addValuesFrame-&gt;<a href="ntqframe.html#setFrameShadow">setFrameShadow</a>( TQFrame::Sunken );
    addValuesFrameLayout = new <a href="qvboxlayout.html">TQVBoxLayout</a>( addValuesFrame, 11, 6 );

    addValuesButtonGroup = new <a href="ntqbuttongroup.html">TQButtonGroup</a>( "Show Values", addValuesFrame );
    addValuesButtonGroup-&gt;<a href="ntqgroupbox.html#setColumnLayout">setColumnLayout</a>(0, TQt::Vertical );
    addValuesButtonGroup-&gt;<a href="tqwidget.html#layout">layout</a>()-&gt;setSpacing( 6 );
    addValuesButtonGroup-&gt;<a href="tqwidget.html#layout">layout</a>()-&gt;setMargin( 11 );
    addValuesButtonGroupLayout = new <a href="qvboxlayout.html">TQVBoxLayout</a>(
                                        addValuesButtonGroup-&gt;<a href="tqwidget.html#layout">layout</a>() );
    addValuesButtonGroupLayout-&gt;<a href="qlayoutitem.html#setAlignment">setAlignment</a>( TQt::AlignTop );

    noRadioButton = new <a href="ntqradiobutton.html">TQRadioButton</a>( "&amp;No", addValuesButtonGroup );
    noRadioButton-&gt;<a href="ntqradiobutton.html#setChecked">setChecked</a>( TRUE );
    addValuesButtonGroupLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( noRadioButton );

    yesRadioButton = new <a href="ntqradiobutton.html">TQRadioButton</a>( "&amp;Yes", addValuesButtonGroup );
    addValuesButtonGroupLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( yesRadioButton );

    asPercentageRadioButton = new <a href="ntqradiobutton.html">TQRadioButton</a>( "As &amp;Percentage",
                                                addValuesButtonGroup );
    addValuesButtonGroupLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( asPercentageRadioButton );
    addValuesFrameLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( addValuesButtonGroup );

    decimalPlacesLayout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( 0, 0, 6 );

    decimalPlacesTextLabel = new <a href="tqlabel.html">TQLabel</a>( "&amp;Decimal Places", addValuesFrame );
    decimalPlacesLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( decimalPlacesTextLabel );

    decimalPlacesSpinBox = new <a href="ntqspinbox.html">TQSpinBox</a>( addValuesFrame );
    decimalPlacesSpinBox-&gt;<a href="ntqspinbox.html#setMinValue">setMinValue</a>( 0 );
    decimalPlacesSpinBox-&gt;<a href="ntqspinbox.html#setMaxValue">setMaxValue</a>( 9 );
    decimalPlacesLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( decimalPlacesSpinBox );

    addValuesFrameLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( decimalPlacesLayout );

    optionsFormLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( addValuesFrame );

    buttonsLayout = new <a href="qhboxlayout.html">TQHBoxLayout</a>( 0, 0, 6 );
    spacer = new <a href="qspaceritem.html">TQSpacerItem</a>( 0, 0,
                              TQSizePolicy::Expanding, TQSizePolicy::Minimum );
    buttonsLayout-&gt;<a href="qboxlayout.html#addItem">addItem</a>( spacer );

    okPushButton = new <a href="ntqpushbutton.html">TQPushButton</a>( "OK", this );
    okPushButton-&gt;<a href="ntqpushbutton.html#setDefault">setDefault</a>( TRUE );
    buttonsLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( okPushButton );

    cancelPushButton = new <a href="ntqpushbutton.html">TQPushButton</a>( "Cancel", this );
    buttonsLayout-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>( cancelPushButton );
    optionsFormLayout-&gt;<a href="qboxlayout.html#addLayout">addLayout</a>( buttonsLayout );

    <a href="tqobject.html#connect">connect</a>( fontPushButton, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( chooseFont() ) );
    <a href="tqobject.html#connect">connect</a>( okPushButton, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( <a href="ntqdialog.html#accept">accept</a>() ) );
    <a href="tqobject.html#connect">connect</a>( cancelPushButton, TQ_SIGNAL( <a href="ntqbutton.html#clicked">clicked</a>() ), this, TQ_SLOT( <a href="ntqdialog.html#reject">reject</a>() ) );

    chartTypeTextLabel-&gt;<a href="tqlabel.html#setBuddy">setBuddy</a>( chartTypeComboBox );
    decimalPlacesTextLabel-&gt;<a href="tqlabel.html#setBuddy">setBuddy</a>( decimalPlacesSpinBox );
}


void <a name="f177"></a>OptionsForm::chooseFont()
{
    bool ok;
    <a href="tqfont.html">TQFont</a> font = TQFontDialog::<a href="tqfontdialog.html#getFont">getFont</a>( &amp;ok, m_font, this );
    if ( ok )
        <a href="tqwidget.html#setFont">setFont</a>( font );
}


void OptionsForm::<a href="tqwidget.html#setFont">setFont</a>( <a href="tqfont.html">TQFont</a> font )
{
    <a href="tqstring.html">TQString</a> label = font.<a href="tqfont.html#family">family</a>() + " " +
                    TQString::<a href="tqstring.html#number">number</a>( font.<a href="tqfont.html#pointSize">pointSize</a>() ) + "pt";
    if ( font.<a href="tqfont.html#bold">bold</a>() )
        label += " Bold";
    if ( font.<a href="tqfont.html#italic">italic</a>() )
        label += " Italic";
    fontTextLabel-&gt;<a href="tqlabel.html#setText">setText</a>( label );
    m_font = font;
}
</pre><!-- eof -->
<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>