You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
494 lines
24 KiB
494 lines
24 KiB
13 years ago
|
<!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 Classes</font></a>
|
||
|
| <a href="mainclasses.html">
|
||
|
<font color="#004faf">Main Classes</font></a>
|
||
|
| <a href="annotated.html">
|
||
|
<font color="#004faf">Annotated</font></a>
|
||
|
| <a href="groups.html">
|
||
|
<font color="#004faf">Grouped 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 <<a href="qscrollview-h.html">qscrollview.h</a>>
|
||
|
#include <<a href="qapplication-h.html">qapplication.h</a>>
|
||
|
#include <<a href="qmenubar-h.html">qmenubar.h</a>>
|
||
|
#include <<a href="qpopupmenu-h.html">qpopupmenu.h</a>>
|
||
|
#include <<a href="qpushbutton-h.html">qpushbutton.h</a>>
|
||
|
#include <<a href="qpainter-h.html">qpainter.h</a>>
|
||
|
#include <<a href="qpixmap-h.html">qpixmap.h</a>>
|
||
|
#include <<a href="qmessagebox-h.html">qmessagebox.h</a>>
|
||
|
#include <<a href="qlayout-h.html">qlayout.h</a>>
|
||
|
#include <<a href="qlabel-h.html">qlabel.h</a>>
|
||
|
#include <<a href="qmultilineedit-h.html">qmultilineedit.h</a>>
|
||
|
#include <<a href="qsizegrip-h.html">qsizegrip.h</a>>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
|
||
|
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<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#tquit">tquit</a>()));
|
||
|
} else {
|
||
|
<a href="qstring.html">TQString</a> str;
|
||
|
if ( b > 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))->move(y/2,y);
|
||
|
}
|
||
|
}
|
||
|
resize(1000,2000);
|
||
|
|
||
|
startTimer(250);
|
||
|
}
|
||
|
|
||
|
void timerEvent(TQTimerEvent*)
|
||
|
{
|
||
|
int w=width();
|
||
|
int h=height();
|
||
|
if ( w > 50 ) w -= 1;
|
||
|
if ( h > 50 ) h -= 2;
|
||
|
resize(w,h);
|
||
|
}
|
||
|
|
||
|
void mouseReleaseEvent(TQMouseEvent* e)
|
||
|
{
|
||
|
emit clicked(e->x(), e->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->x(), e->y(), x, y );
|
||
|
dragging = new <a href="qmultilineedit.html">TQMultiLineEdit</a>(viewport(),"Another");
|
||
|
<a name="x657"></a> dragging-><a href="qtextedit.html#setText">setText</a>("Thanks!");
|
||
|
<a name="x650"></a> dragging-><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->x(), e->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-><a href="qtextedit.html#setText">setText</a>(msg);
|
||
|
dragging-><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<=bottomrow; r++) {
|
||
|
int py=r*rowheight;
|
||
|
for (int c=leftcol; c<=rightcol; c++) {
|
||
|
int px=c*colwidth;
|
||
|
p->drawPixmap(px, py, bg);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
p->fillRect(cx, cy, cw, ch, TQColor(240,222,208));
|
||
|
}
|
||
|
|
||
|
// The Numbers
|
||
|
{
|
||
|
<a href="qfontmetrics.html">TQFontMetrics</a> fm=p->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<=bottomrow; r++) {
|
||
|
int py=r*rowheight;
|
||
|
for (int c=leftcol; c<=rightcol; c++) {
|
||
|
int px=c*colwidth;
|
||
|
str.<a href="qstring.html#sprintf">sprintf</a>("%d,%d",c,r);
|
||
|
<a name="x619"></a> p->drawText(px+3, py+fm.<a href="qfontmetrics.html#ascent">ascent</a>(), str);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// The Big Hint
|
||
|
if (leftcol<10 && toprow<5) {
|
||
|
p->setFont(TQFont("Charter",30));
|
||
|
p->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->drawText(100,50,text);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// The Big X
|
||
|
{
|
||
|
if (cx+cw>200000 && cy+ch>100000 && cx<230000 && cy<130000) {
|
||
|
// Note that some X server cannot even handle co-ordinates
|
||
|
// beyond about 4000, so you might not see this.
|
||
|
p->drawLine(200000,100000,229999,129999);
|
||
|
p->drawLine(229999,100000,200000,129999);
|
||
|
|
||
|
// X marks the spot!
|
||
|
p->setFont(TQFont("Charter",100));
|
||
|
p->setPen(blue);
|
||
|
p->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-><a href="qmenudata.html#insertItem">insertItem</a>( "&File", file );
|
||
|
file-><a href="qmenudata.html#insertItem">insertItem</a>( "Quit", qApp, SLOT(<a href="qapplication.html#tquit">tquit</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-><a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
|
||
|
menubar-><a href="qmenudata.html#insertItem">insertItem</a>( "&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-><a href="qmenudata.html#insertItem">insertItem</a>( "Vertical Auto" );
|
||
|
vaoff_id = vp_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Vertical AlwaysOff" );
|
||
|
vaon_id = vp_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Vertical AlwaysOn" );
|
||
|
<a name="x635"></a> vp_options-><a href="qmenudata.html#insertSeparator">insertSeparator</a>();
|
||
|
hauto_id = vp_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal Auto" );
|
||
|
haoff_id = vp_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal AlwaysOff" );
|
||
|
haon_id = vp_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Horizontal AlwaysOn" );
|
||
|
vp_options-><a href="qmenudata.html#insertSeparator">insertSeparator</a>();
|
||
|
corn_id = vp_options-><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-><a href="qscrollview.html#viewport">viewport</a>());
|
||
|
<a name="x645"></a> vp-><a href="qscrollview.html#addChild">addChild</a>(bs);
|
||
|
<a name="x659"></a> bs-><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-><a href="qscrollview.html#enableClipper">enableClipper</a>(TRUE);
|
||
|
srand(1);
|
||
|
for (int i=0; i<30; i++) {
|
||
|
<a href="qmultilineedit.html">TQMultiLineEdit</a> *l = new <a href="qmultilineedit.html">TQMultiLineEdit</a>(vp-><a href="qscrollview.html#viewport">viewport</a>(),"First");
|
||
|
l-><a href="qtextedit.html#setText">setText</a>("Drag out more of these.");
|
||
|
l-><a href="qwidget.html#resize">resize</a>(100,100);
|
||
|
vp-><a href="qscrollview.html#addChild">addChild</a>(l, rand()%800, rand()%10000);
|
||
|
}
|
||
|
vp-><a href="qscrollview.html#viewport">viewport</a>()->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-><a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
|
||
|
menubar-><a href="qmenudata.html#insertItem">insertItem</a>( "F&rame", f_options );
|
||
|
connect( f_options, SIGNAL(<a href="qpopupmenu.html#activated">activated</a>(int)),
|
||
|
this, SLOT(doFMenuItem(int)) );
|
||
|
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "No Frame", style_id );
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Box", style_id|TQFrame::Box );
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Panel", style_id|TQFrame::Panel );
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "WinPanel", style_id|TQFrame::WinPanel );
|
||
|
f_options-><a href="qmenudata.html#insertSeparator">insertSeparator</a>();
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Plain", style_id|TQFrame::Plain );
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Raised", style_id|TQFrame::Raised );
|
||
|
<a name="x633"></a> f_laststyle = f_options-><a href="qmenudata.html#indexOf">indexOf</a>(
|
||
|
f_options-><a href="qmenudata.html#insertItem">insertItem</a>( "Sunken", style_id|TQFrame::Sunken ));
|
||
|
f_options-><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-><a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
|
||
|
for (int lw = 1; lw <= max_lw; lw++) {
|
||
|
<a href="qstring.html">TQString</a> str;
|
||
|
str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", lw);
|
||
|
lw_options-><a href="qmenudata.html#insertItem">insertItem</a>( str, lw_id | lw );
|
||
|
}
|
||
|
f_options-><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-><a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
|
||
|
for (int mlw = 0; mlw <= max_mlw; mlw++) {
|
||
|
<a href="qstring.html">TQString</a> str;
|
||
|
str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", mlw);
|
||
|
mlw_options-><a href="qmenudata.html#insertItem">insertItem</a>( str, mlw_id | mlw );
|
||
|
}
|
||
|
f_options-><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-><a href="qpopupmenu.html#setCheckable">setCheckable</a>( TRUE );
|
||
|
for (int mw = 0; mw <= max_mw; mw++) {
|
||
|
<a href="qstring.html">TQString</a> str;
|
||
|
str.<a href="qstring.html#sprintf">sprintf</a>("%d Pixels", mw);
|
||
|
mw_options-><a href="qmenudata.html#insertItem">insertItem</a>( str, mw_id | mw );
|
||
|
}
|
||
|
f_options-><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-><a href="qlayout.html#setMenuBar">setMenuBar</a>(menubar);
|
||
|
<a name="x632"></a> menubar-><a href="qmenubar.html#setSeparator">setSeparator</a>(TQMenuBar::InWindowsStyle);
|
||
|
vbox-><a href="qboxlayout.html#addWidget">addWidget</a>(vp);
|
||
|
<a name="x630"></a> vbox-><a href="qlayout.html#activate">activate</a>();
|
||
|
|
||
|
corner = new <a href="qsizegrip.html">TQSizeGrip</a>(this);
|
||
|
<a name="x658"></a> corner-><a href="qwidget.html#hide">hide</a>();
|
||
|
}
|
||
|
|
||
|
private slots:
|
||
|
void doVPMenuItem(int id)
|
||
|
{
|
||
|
if (id == vauto_id ) {
|
||
|
<a name="x653"></a> vp-><a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(TQScrollView::Auto);
|
||
|
} else if (id == vaoff_id) {
|
||
|
vp-><a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(TQScrollView::AlwaysOff);
|
||
|
} else if (id == vaon_id) {
|
||
|
vp-><a href="qscrollview.html#setVScrollBarMode">setVScrollBarMode</a>(TQScrollView::AlwaysOn);
|
||
|
} else if (id == hauto_id) {
|
||
|
<a name="x652"></a> vp-><a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(TQScrollView::Auto);
|
||
|
} else if (id == haoff_id) {
|
||
|
vp-><a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(TQScrollView::AlwaysOff);
|
||
|
} else if (id == haon_id) {
|
||
|
vp-><a href="qscrollview.html#setHScrollBarMode">setHScrollBarMode</a>(TQScrollView::AlwaysOn);
|
||
|
} else if (id == corn_id) {
|
||
|
<a name="x647"></a> bool corn = !vp-><a href="qscrollview.html#cornerWidget">cornerWidget</a>();
|
||
|
<a name="x651"></a> vp-><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-><a href="qscrollview.html#vScrollBarMode">vScrollBarMode</a>();
|
||
|
<a name="x636"></a> vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( vauto_id, vm == TQScrollView::Auto );
|
||
|
vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( vaoff_id, vm == TQScrollView::AlwaysOff );
|
||
|
vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( vaon_id, vm == TQScrollView::AlwaysOn );
|
||
|
|
||
|
<a name="x649"></a> TQScrollView::ScrollBarMode hm = vp-><a href="qscrollview.html#hScrollBarMode">hScrollBarMode</a>();
|
||
|
vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( hauto_id, hm == TQScrollView::Auto );
|
||
|
vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( haoff_id, hm == TQScrollView::AlwaysOff );
|
||
|
vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( haon_id, hm == TQScrollView::AlwaysOn );
|
||
|
|
||
|
vp_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( corn_id, !!vp-><a href="qscrollview.html#cornerWidget">cornerWidget</a>() );
|
||
|
}
|
||
|
|
||
|
void doFMenuItem(int id)
|
||
|
{
|
||
|
if (id & style_id) {
|
||
|
int sty;
|
||
|
|
||
|
if (id == style_id) {
|
||
|
sty = 0;
|
||
|
} else if (id & TQFrame::MShape) {
|
||
|
<a name="x622"></a> sty = vp-><a href="qframe.html#frameStyle">frameStyle</a>()&TQFrame::MShadow;
|
||
|
sty = (sty ? sty : <a href="qframe.html">TQFrame</a>::Plain) | (id&TQFrame::MShape);
|
||
|
} else {
|
||
|
sty = vp-><a href="qframe.html#frameStyle">frameStyle</a>()&TQFrame::MShape;
|
||
|
sty = (sty ? sty : <a href="qframe.html">TQFrame</a>::Box) | (id&TQFrame::MShadow);
|
||
|
}
|
||
|
<a name="x626"></a> vp-><a href="qframe.html#setFrameStyle">setFrameStyle</a>(sty);
|
||
|
} else if (id & lw_id) {
|
||
|
<a name="x627"></a> vp-><a href="qframe.html#setLineWidth">setLineWidth</a>(id&~lw_id);
|
||
|
} else if (id & mlw_id) {
|
||
|
<a name="x629"></a> vp-><a href="qframe.html#setMidLineWidth">setMidLineWidth</a>(id&~mlw_id);
|
||
|
} else {
|
||
|
<a name="x628"></a> vp-><a href="qframe.html#setMargin">setMargin</a>(id&~mw_id);
|
||
|
}
|
||
|
|
||
|
<a name="x662"></a> vp-><a href="qwidget.html#update">update</a>();
|
||
|
setFMenuItems();
|
||
|
}
|
||
|
|
||
|
void setFMenuItems()
|
||
|
{
|
||
|
int sty = vp-><a href="qframe.html#frameStyle">frameStyle</a>();
|
||
|
|
||
|
f_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( style_id, !sty );
|
||
|
|
||
|
for (int i=1; i <= f_laststyle; i++) {
|
||
|
<a name="x643"></a> int id = f_options-><a href="qpopupmenu.html#idAt">idAt</a>(i);
|
||
|
if (id & TQFrame::MShape)
|
||
|
f_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( id,
|
||
|
((id&TQFrame::MShape) == (sty&TQFrame::MShape)) );
|
||
|
else
|
||
|
f_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( id,
|
||
|
((id&TQFrame::MShadow) == (sty&TQFrame::MShadow)) );
|
||
|
}
|
||
|
|
||
|
for (int lw=1; lw<=max_lw; lw++)
|
||
|
<a name="x623"></a> lw_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( lw_id|lw, vp-><a href="qframe.html#lineWidth">lineWidth</a>() == lw );
|
||
|
|
||
|
for (int mlw=0; mlw<=max_mlw; mlw++)
|
||
|
<a name="x625"></a> mlw_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( mlw_id|mlw, vp-><a href="qframe.html#midLineWidth">midLineWidth</a>() == mlw );
|
||
|
|
||
|
for (int mw=0; mw<=max_mw; mw++)
|
||
|
<a name="x624"></a> mw_options-><a href="qmenudata.html#setItemChecked">setItemChecked</a>( mw_id|mw, vp-><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#tquit">tquit</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 © 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>
|