summaryrefslogtreecommitdiffstats
path: root/doc/html/scrollview-example.html
blob: 31f30e80a1c1a2b50739baaec2e92e1bdcaad2e9 (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<!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/examples/scrollview/scrollview.doc:4 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Scrollview</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>Scrollview</h1>

   
<p> 
This example shows how to use TQt's scrollview. This is a widget
optimized for very large contents. 
<p> <hr>
<p> Implementation:
<p> <pre>/****************************************************************************
** $Id: qt/scrollview.cpp   3.3.8   edited Jan 11 14:37 $
**
** Copyright (C) 1992-2007 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 &lt;<a href="qscrollview-h.html">qscrollview.h</a>&gt;
#include &lt;<a href="qapplication-h.html">qapplication.h</a>&gt;
#include &lt;<a href="qmenubar-h.html">qmenubar.h</a>&gt;
#include &lt;<a href="qpopupmenu-h.html">qpopupmenu.h</a>&gt;
#include &lt;<a href="qpushbutton-h.html">qpushbutton.h</a>&gt;
#include &lt;<a href="qpainter-h.html">qpainter.h</a>&gt;
#include &lt;<a href="qpixmap-h.html">qpixmap.h</a>&gt;
#include &lt;<a href="qmessagebox-h.html">qmessagebox.h</a>&gt;
#include &lt;<a href="qlayout-h.html">qlayout.h</a>&gt;
#include &lt;<a href="qlabel-h.html">qlabel.h</a>&gt;
#include &lt;<a href="qmultilineedit-h.html">qmultilineedit.h</a>&gt;
#include &lt;<a href="qsizegrip-h.html">qsizegrip.h</a>&gt;
#include &lt;stdlib.h&gt;


static const int style_id       = 0x1000;
static const int lw_id          = 0x2000;
static const int mlw_id         = 0x4000;
static const int mw_id          = 0x8000;
static const int max_lw         = 16;
static const int max_mlw        = 5;
static const int max_mw         = 10;


class BigShrinker : public <a href="qframe.html">TQFrame</a> {
    <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
public:
    BigShrinker(TQWidget* parent) :
        <a href="qframe.html">TQFrame</a>(parent)
    {
        setFrameStyle(TQFrame::Box|TQFrame::Sunken);
        int h=35;
        int b=0;
        for (int y=0; y&lt;2000-h; y+=h+10) {
            if (y == 0) {
                <a href="qbutton.html">TQButton</a>* q=new <a href="qpushbutton.html">TQPushButton</a>("Quit", this);
                connect(q, SIGNAL(<a href="qbutton.html#clicked">clicked</a>()), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()));
            } else {
                <a href="qstring.html">TQString</a> str;
                if ( b &gt; 0 ) {
<a name="x656"></a>                    str.<a href="qstring.html#sprintf">sprintf</a>("Button %d", b++);
                } else {
                    str = "I'm shrinking!";
                    ++b;
                }
                (new <a href="qpushbutton.html">TQPushButton</a>(str, this))-&gt;move(y/2,y);
            }
        }
        resize(1000,2000);

        startTimer(250);
    }

    void timerEvent(TQTimerEvent*)
    {
        int w=width();
        int h=height();
        if ( w &gt; 50 ) w -= 1;
        if ( h &gt; 50 ) h -= 2;
        resize(w,h);
    }

    void mouseReleaseEvent(TQMouseEvent* e)
    {
        emit clicked(e-&gt;x(), e-&gt;y());
    }

signals:
    void clicked(int,int);
};

class BigMatrix : public <a href="qscrollview.html">TQScrollView</a> {
    <a href="qmultilineedit.html">TQMultiLineEdit</a> *dragging;
public:
    BigMatrix(TQWidget* parent) :
        <a href="qscrollview.html">TQScrollView</a>(parent,"matrix", WStaticContents),
        bg("bg.ppm")
    {
<a name="x640"></a>        bg.<a href="qpixmap.html#load">load</a>("bg.ppm");
        resizeContents(400000,300000);

        dragging = 0;
    }

    void viewportMousePressEvent(TQMouseEvent* e)
    {
        int x, y;
        viewportToContents( e-&gt;x(),  e-&gt;y(), x, y );
        dragging = new <a href="qmultilineedit.html">TQMultiLineEdit</a>(viewport(),"Another");
<a name="x657"></a>        dragging-&gt;<a href="qtextedit.html#setText">setText</a>("Thanks!");
<a name="x650"></a>        dragging-&gt;<a href="qwidget.html#resize">resize</a>(100,100);
        addChild(dragging, x, y);
        showChild(dragging);
    }

    void viewportMouseReleaseEvent(TQMouseEvent*)
    {
        dragging = 0;
    }

    void viewportMouseMoveEvent(TQMouseEvent* e)
    {
        if ( dragging ) {
            int mx, my;
            viewportToContents( e-&gt;x(),  e-&gt;y(), mx, my );
            int cx = childX(dragging);
            int cy = childY(dragging);
            int w = mx - cx + 1;
            int h = my - cy + 1;
            <a href="qstring.html">TQString</a> msg;
            msg.<a href="qstring.html#sprintf">sprintf</a>("at (%d,%d) %d by %d",cx,cy,w,h);
            dragging-&gt;<a href="qtextedit.html#setText">setText</a>(msg);
            dragging-&gt;<a href="qwidget.html#resize">resize</a>(w,h);
        }
    }

protected:
    void drawContents(TQPainter* p, int cx, int cy, int cw, int ch)
    {
        // The Background
<a name="x639"></a>        if ( !bg.<a href="qpixmap.html#isNull">isNull</a>() ) {
<a name="x638"></a>            int rowheight=bg.<a href="qpixmap.html#height">height</a>();
            int toprow=cy/rowheight;
            int bottomrow=(cy+ch+rowheight-1)/rowheight;
<a name="x641"></a>            int colwidth=bg.<a href="qpixmap.html#width">width</a>();
            int leftcol=cx/colwidth;
            int rightcol=(cx+cw+colwidth-1)/colwidth;
            for (int r=toprow; r&lt;=bottomrow; r++) {
                int py=r*rowheight;
                for (int c=leftcol; c&lt;=rightcol; c++) {
                    int px=c*colwidth;
                    p-&gt;drawPixmap(px, py, bg);
                }
            }
        } else {
            p-&gt;fillRect(cx, cy, cw, ch, TQColor(240,222,208));
        }

        // The Numbers
        {
            <a href="qfontmetrics.html">TQFontMetrics</a> fm=p-&gt;fontMetrics();
<a name="x620"></a>            int rowheight=fm.<a href="qfontmetrics.html#lineSpacing">lineSpacing</a>();
            int toprow=cy/rowheight;
            int bottomrow=(cy+ch+rowheight-1)/rowheight;
<a name="x621"></a>            int colwidth=fm.<a href="qfontmetrics.html#width">width</a>("00000,000000 ")+3;
            int leftcol=cx/colwidth;
            int rightcol=(cx+cw+colwidth-1)/colwidth;
            <a href="qstring.html">TQString</a> str;
            for (int r=toprow; r&lt;=bottomrow; r++) {
                int py=r*rowheight;
                for (int c=leftcol; c&lt;=rightcol; c++) {
                    int px=c*colwidth;
                    str.<a href="qstring.html#sprintf">sprintf</a>("%d,%d",c,r);
<a name="x619"></a>                    p-&gt;drawText(px+3, py+fm.<a href="qfontmetrics.html#ascent">ascent</a>(), str);
                }
            }

            // The Big Hint
            if (leftcol&lt;10 &amp;&amp; toprow&lt;5) {
                p-&gt;setFont(TQFont("Charter",30));
                p-&gt;setPen(red);
                <a href="qstring.html">TQString</a> text;
                text.<a href="qstring.html#sprintf">sprintf</a>("HINT:  Look at %d,%d",215000/colwidth,115000/rowheight);
                p-&gt;drawText(100,50,text);
            }
        }

        // The Big X
        {
            if (cx+cw&gt;200000 &amp;&amp; cy+ch&gt;100000 &amp;&amp; cx&lt;230000 &amp;&amp; cy&lt;130000) {
                // Note that some X server cannot even handle co-ordinates
                // beyond about 4000, so you might not see this.
                p-&gt;drawLine(200000,100000,229999,129999);
                p-&gt;drawLine(229999,100000,200000,129999);

                // X marks the spot!
                p-&gt;setFont(TQFont("Charter",100));
                p-&gt;setPen(blue);
                p-&gt;drawText(215000-500,115000-100,1000,200,AlignCenter,"YOU WIN!!!!!");
            }
        }
    }

private:
    <a href="qpixmap.html">TQPixmap</a> bg;
};

class ScrollViewExample : public <a href="qwidget.html">TQWidget</a> {
    Q_OBJECT

public:
    ScrollViewExample(int technique, TQWidget* parent=0, const char* name=0) :
        <a href="qwidget.html">TQWidget</a>(parent,name)
    {
        <a href="qmenubar.html">TQMenuBar</a>* menubar = new <a href="qmenubar.html">TQMenuBar</a>(this);
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( menubar );

        <a href="qpopupmenu.html">TQPopupMenu</a>* file = new <a href="qpopupmenu.html">TQPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( file );
<a name="x634"></a>        menubar-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;File", file );
        file-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Quit", qApp,  SLOT(<a href="qapplication.html#quit">quit</a>()) );

        vp_options = new <a href="qpopupmenu.html">TQPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( vp_options );
<a name="x644"></a>        vp_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        menubar-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "&amp;ScrollView", vp_options );
<a name="x642"></a>        connect( vp_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doVPMenuItem(int)) );

        vauto_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Vertical Auto" );
        vaoff_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Vertical AlwaysOff" );
        vaon_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Vertical AlwaysOn" );
<a name="x635"></a>        vp_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        hauto_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal Auto" );
        haoff_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal AlwaysOff" );
        haon_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal AlwaysOn" );
        vp_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        corn_id = vp_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "cornerWidget" );

        if (technique == 1) {
            vp = new <a href="qscrollview.html">TQScrollView</a>(this);
<a name="x655"></a>            BigShrinker *bs = new BigShrinker(0);//(vp-&gt;<a href="qscrollview.html#viewport">viewport</a>());
<a name="x645"></a>            vp-&gt;<a href="qscrollview.html#addChild">addChild</a>(bs);
<a name="x659"></a>            bs-&gt;<a href="qwidget.html#setAcceptDrops">setAcceptDrops</a>(TRUE);
            TQObject::<a href="qobject.html#connect">connect</a>(bs, SIGNAL(clicked(int,int)),
<a name="x646"></a>                            vp, SLOT(<a href="qscrollview.html#center">center</a>(int,int)));
        } else {
            vp = new BigMatrix(this);
            if ( technique == 3 )
<a name="x648"></a>                vp-&gt;<a href="qscrollview.html#enableClipper">enableClipper</a>(TRUE);
            srand(1);
            for (int i=0; i&lt;30; i++) {
                <a href="qmultilineedit.html">TQMultiLineEdit</a> *l = new <a href="qmultilineedit.html">TQMultiLineEdit</a>(vp-&gt;<a href="qscrollview.html#viewport">viewport</a>(),"First");
                l-&gt;<a href="qtextedit.html#setText">setText</a>("Drag out more of these.");
                l-&gt;<a href="qwidget.html#resize">resize</a>(100,100);
                vp-&gt;<a href="qscrollview.html#addChild">addChild</a>(l, rand()%800, rand()%10000);
            }
            vp-&gt;<a href="qscrollview.html#viewport">viewport</a>()-&gt;setBackgroundMode(NoBackground);
        }

        f_options = new <a href="qpopupmenu.html">TQPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( f_options );
        f_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        menubar-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "F&amp;rame", f_options );
        connect( f_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );

        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "No Frame", style_id );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Box", style_id|TQFrame::Box );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Panel", style_id|TQFrame::Panel );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "WinPanel", style_id|TQFrame::WinPanel );
        f_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Plain", style_id|TQFrame::Plain );
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Raised", style_id|TQFrame::Raised );
<a name="x633"></a>        f_laststyle = f_options-&gt;<a href="qmenudata.html#indexOf">indexOf</a>(
            f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Sunken", style_id|TQFrame::Sunken ));
        f_options-&gt;<a href="qmenudata.html#insertSeparator">insertSeparator</a>();
        lw_options = new <a href="qpopupmenu.html">TQPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( lw_options );
        lw_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        for (int lw = 1; lw &lt;= max_lw; lw++) {
            <a href="qstring.html">TQString</a> str;
            str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", lw);
            lw_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( str, lw_id | lw );
        }
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Line Width", lw_options );
        connect( lw_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );
        mlw_options = new <a href="qpopupmenu.html">TQPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( mlw_options );
        mlw_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        for (int mlw = 0; mlw &lt;= max_mlw; mlw++) {
            <a href="qstring.html">TQString</a> str;
            str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", mlw);
            mlw_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( str, mlw_id | mlw );
        }
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Midline Width", mlw_options );
        connect( mlw_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );
        mw_options = new <a href="qpopupmenu.html">TQPopupMenu</a>( menubar );
        <a href="qapplication.html#Q_CHECK_PTR">Q_CHECK_PTR</a>( mw_options );
        mw_options-&gt;<a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
        for (int mw = 0; mw &lt;= max_mw; mw++) {
            <a href="qstring.html">TQString</a> str;
            str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", mw);
            mw_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( str, mw_id | mw );
        }
        f_options-&gt;<a href="qmenudata.html#insertItem">insertItem</a>( "Margin Width", mw_options );
        connect( mw_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
            this, SLOT(doFMenuItem(int)) );

        setVPMenuItems();
        setFMenuItems();

        <a href="qvboxlayout.html">TQVBoxLayout</a>* vbox = new <a href="qvboxlayout.html">TQVBoxLayout</a>(this);
<a name="x631"></a>        vbox-&gt;<a href="qlayout.html#setMenuBar">setMenuBar</a>(menubar);
<a name="x632"></a>        menubar-&gt;<a href="qmenubar.html#setSeparator">setSeparator</a>(TQMenuBar::InWindowsStyle);
        vbox-&gt;<a href="qboxlayout.html#addWidget">addWidget</a>(vp);
<a name="x630"></a>        vbox-&gt;<a href="qlayout.html#activate">activate</a>();

        corner = new <a href="qsizegrip.html">TQSizeGrip</a>(this);
<a name="x658"></a>        corner-&gt;<a href="qwidget.html#hide">hide</a>();
    }

private slots:
    void doVPMenuItem(int id)
    {
        if (id == vauto_id ) {
<a name="x653"></a>            vp-&gt;<a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(TQScrollView::Auto);
        } else if (id == vaoff_id) {
            vp-&gt;<a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(TQScrollView::AlwaysOff);
        } else if (id == vaon_id) {
            vp-&gt;<a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(TQScrollView::AlwaysOn);
        } else if (id == hauto_id) {
<a name="x652"></a>            vp-&gt;<a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(TQScrollView::Auto);
        } else if (id == haoff_id) {
            vp-&gt;<a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(TQScrollView::AlwaysOff);
        } else if (id == haon_id) {
            vp-&gt;<a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(TQScrollView::AlwaysOn);
        } else if (id == corn_id) {
<a name="x647"></a>            bool corn = !vp-&gt;<a href="qscrollview.html#cornerWidget">cornerWidget</a>();
<a name="x651"></a>            vp-&gt;<a href="qscrollview.html#setCornerWidget">setCornerWidget</a>(corn ? corner : 0);
        } else {
            return; // Not for us to process.
        }
        setVPMenuItems();
    }

    void setVPMenuItems()
    {
<a name="x654"></a>        TQScrollView::ScrollBarMode vm = vp-&gt;<a href="qscrollview.html#vScrollBarMode">vScrollBarMode</a>();
<a name="x636"></a>        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( vauto_id, vm == TQScrollView::Auto );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( vaoff_id, vm == TQScrollView::AlwaysOff );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( vaon_id, vm == TQScrollView::AlwaysOn );

<a name="x649"></a>        TQScrollView::ScrollBarMode hm = vp-&gt;<a href="qscrollview.html#hScrollBarMode">hScrollBarMode</a>();
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( hauto_id, hm == TQScrollView::Auto );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( haoff_id, hm == TQScrollView::AlwaysOff );
        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( haon_id, hm == TQScrollView::AlwaysOn );

        vp_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( corn_id, !!vp-&gt;<a href="qscrollview.html#cornerWidget">cornerWidget</a>() );
    }

    void doFMenuItem(int id)
    {
        if (id &amp; style_id) {
            int sty;

            if (id == style_id) {
                sty = 0;
            } else if (id &amp; TQFrame::MShape) {
<a name="x622"></a>                sty = vp-&gt;<a href="qframe.html#frameStyle">frameStyle</a>()&amp;TQFrame::MShadow;
                sty = (sty ? sty : <a href="qframe.html">TQFrame</a>::Plain) | (id&amp;TQFrame::MShape);
            } else {
                sty = vp-&gt;<a href="qframe.html#frameStyle">frameStyle</a>()&amp;TQFrame::MShape;
                sty = (sty ? sty : <a href="qframe.html">TQFrame</a>::Box) | (id&amp;TQFrame::MShadow);
            }
<a name="x626"></a>            vp-&gt;<a href="qframe.html#setFrameStyle">setFrameStyle</a>(sty);
        } else if (id &amp; lw_id) {
<a name="x627"></a>            vp-&gt;<a href="qframe.html#setLineWidth">setLineWidth</a>(id&amp;~lw_id);
        } else if (id &amp; mlw_id) {
<a name="x629"></a>            vp-&gt;<a href="qframe.html#setMidLineWidth">setMidLineWidth</a>(id&amp;~mlw_id);
        } else {
<a name="x628"></a>            vp-&gt;<a href="qframe.html#setMargin">setMargin</a>(id&amp;~mw_id);
        }

<a name="x662"></a>        vp-&gt;<a href="qwidget.html#update">update</a>();
        setFMenuItems();
    }

    void setFMenuItems()
    {
        int sty = vp-&gt;<a href="qframe.html#frameStyle">frameStyle</a>();

        f_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( style_id, !sty );

        for (int i=1; i &lt;= f_laststyle; i++) {
<a name="x643"></a>            int id = f_options-&gt;<a href="qpopupmenu.html#idAt">idAt</a>(i);
            if (id &amp; TQFrame::MShape)
                f_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( id,
                    ((id&amp;TQFrame::MShape) == (sty&amp;TQFrame::MShape)) );
            else
                f_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( id,
                    ((id&amp;TQFrame::MShadow) == (sty&amp;TQFrame::MShadow)) );
        }

        for (int lw=1; lw&lt;=max_lw; lw++)
<a name="x623"></a>            lw_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( lw_id|lw, vp-&gt;<a href="qframe.html#lineWidth">lineWidth</a>() == lw );

        for (int mlw=0; mlw&lt;=max_mlw; mlw++)
<a name="x625"></a>            mlw_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( mlw_id|mlw, vp-&gt;<a href="qframe.html#midLineWidth">midLineWidth</a>() == mlw );

        for (int mw=0; mw&lt;=max_mw; mw++)
<a name="x624"></a>            mw_options-&gt;<a href="qmenudata.html#setItemChecked">setItemChecked</a>( mw_id|mw, vp-&gt;<a href="qframe.html#margin">margin</a>() == mw );
    }

private:
    <a href="qscrollview.html">TQScrollView</a>* vp;
    <a href="qpopupmenu.html">TQPopupMenu</a>* vp_options;
    <a href="qpopupmenu.html">TQPopupMenu</a>* f_options;
    <a href="qpopupmenu.html">TQPopupMenu</a>* lw_options;
    <a href="qpopupmenu.html">TQPopupMenu</a>* mlw_options;
    <a href="qpopupmenu.html">TQPopupMenu</a>* mw_options;
    <a href="qsizegrip.html">TQSizeGrip</a>* corner;

    int vauto_id, vaoff_id, vaon_id,
        hauto_id, haoff_id, haon_id,
        corn_id;

    int f_laststyle;
};

int main( int argc, char **argv )
{
    <a href="qapplication.html">TQApplication</a> a( argc, argv );

    ScrollViewExample ve1(1,0,"ve1");
    ScrollViewExample ve2(2,0,"ve2");
    ScrollViewExample ve3(3,0,"ve3");
    ve1.<a href="qwidget.html#setCaption">setCaption</a>("TQt Example - Scrollviews");
    ve1.<a href="qwidget.html#show">show</a>();
    ve2.<a href="qwidget.html#setCaption">setCaption</a>("TQt Example - Scrollviews");
    ve2.<a href="qwidget.html#show">show</a>();
    ve3.<a href="qwidget.html#setCaption">setCaption</a>("TQt Example - Scrollviews");
    ve3.<a href="qwidget.html#show">show</a>();

    TQObject::<a href="qobject.html#connect">connect</a>(qApp, SIGNAL(<a href="qapplication.html#lastWindowClosed">lastWindowClosed</a>()), qApp, SLOT(<a href="qapplication.html#quit">quit</a>()));

    return a.<a href="qapplication.html#exec">exec</a>();
}

#include "scrollview.moc"
</pre>

<p>See also <a href="examples.html">Examples</a>.

<!-- 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>