tests/manual/repaint/widget/main.cpp
changeset 30 5dc02b23752f
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the test suite of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include <QtGui>
       
    43 #include "../shared/shared.h"
       
    44 
       
    45 class Child : public StaticWidget
       
    46 {
       
    47 Q_OBJECT
       
    48 public:
       
    49     Child(QWidget *parent)
       
    50     :StaticWidget(parent)
       
    51     {
       
    52         hue = 0;
       
    53     }
       
    54 };
       
    55 
       
    56 QWidget *c;
       
    57 
       
    58 class TopLevel : public StaticWidget
       
    59 {
       
    60 Q_OBJECT
       
    61 public:
       
    62     TopLevel()
       
    63     {
       
    64         resizeButton  = new QPushButton("resize", this);
       
    65         connect(resizeButton, SIGNAL(clicked()), SLOT(buttonResizeClicked()));
       
    66 
       
    67         movebutton  = new QPushButton("move", this);
       
    68         connect(movebutton, SIGNAL(clicked()), SLOT(buttonMoveClicked()));
       
    69         movebutton->move(70, 0);
       
    70 
       
    71         moveResizebutton  = new QPushButton("move + resize", this);
       
    72         connect(moveResizebutton, SIGNAL(clicked()), SLOT(buttonMoveResizeClicked()));
       
    73         moveResizebutton->move(150, 0);
       
    74 
       
    75         scrollbutton  = new QPushButton("scroll", this);
       
    76         connect(scrollbutton, SIGNAL(clicked()), SLOT(buttonScrollClicked()));
       
    77         scrollbutton->move(280, 0);
       
    78     }
       
    79 
       
    80 public slots:
       
    81     void buttonResizeClicked()
       
    82     {
       
    83         c->resize(c->size() + QSize(15, 15));
       
    84         qDebug() << "child new size" << c->size();
       
    85     }
       
    86 
       
    87     void buttonMoveClicked()
       
    88     {
       
    89         c->move(c->pos() + QPoint(15, 15));
       
    90         qDebug() << "child moved" << c->pos();
       
    91     }
       
    92 
       
    93     void buttonMoveResizeClicked()
       
    94     {
       
    95         QRect g = c->geometry();
       
    96         g.adjust(15,15,30,30);
       
    97         c->setGeometry(g);
       
    98         qDebug() << "child moved" << c->pos() << "rezied" << c->size();
       
    99     }
       
   100 
       
   101 
       
   102     void buttonScrollClicked()
       
   103     {
       
   104         c->scroll(10, 10);
       
   105     }
       
   106 
       
   107 protected:
       
   108     QPushButton * resizeButton;
       
   109     QPushButton * movebutton;
       
   110     QPushButton * moveResizebutton;
       
   111     QPushButton * scrollbutton;    
       
   112 };
       
   113 
       
   114 int main(int argc, char **argv)
       
   115 {
       
   116     QApplication app(argc, argv);
       
   117     
       
   118     TopLevel bc;
       
   119     bc.resize(500, 500);
       
   120 
       
   121     c = new Child(&bc);
       
   122     c->move(100, 100);
       
   123     c->resize(100, 100);
       
   124     
       
   125     QWidget *gc  = new StaticWidget(c);
       
   126     gc->move(20, 20);
       
   127     gc->resize(50,50);
       
   128     
       
   129 
       
   130     bc.show();
       
   131     return app.exec();
       
   132 }
       
   133 
       
   134 #include "main.moc"
       
   135