doc/src/snippets/brushstyles/stylewidget.cpp
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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 documentation 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 
       
    44 #include "stylewidget.h"
       
    45 
       
    46 StyleWidget::StyleWidget(QWidget *parent)
       
    47         : QWidget(parent)
       
    48 {
       
    49     solid = new RenderArea(new QBrush(Qt::SolidPattern));
       
    50     dense1 = new RenderArea(new QBrush(Qt::Dense1Pattern));
       
    51     dense2 = new RenderArea(new QBrush(Qt::Dense2Pattern));
       
    52     dense3 = new RenderArea(new QBrush(Qt::Dense3Pattern));
       
    53     dense4 = new RenderArea(new QBrush(Qt::Dense4Pattern));
       
    54     dense5 = new RenderArea(new QBrush(Qt::Dense5Pattern));
       
    55     dense6 = new RenderArea(new QBrush(Qt::Dense6Pattern));
       
    56     dense7 = new RenderArea(new QBrush(Qt::Dense7Pattern));
       
    57     no = new RenderArea(new QBrush(Qt::NoBrush));
       
    58     hor = new RenderArea(new QBrush(Qt::HorPattern));
       
    59     ver = new RenderArea(new QBrush(Qt::VerPattern));
       
    60     cross = new RenderArea(new QBrush(Qt::CrossPattern));
       
    61     bdiag = new RenderArea(new QBrush(Qt::BDiagPattern));
       
    62     fdiag = new RenderArea(new QBrush(Qt::FDiagPattern));
       
    63     diagCross = new RenderArea(new QBrush(Qt::DiagCrossPattern));
       
    64     linear = new RenderArea(new QBrush(QLinearGradient()));
       
    65     radial = new RenderArea(new QBrush(QRadialGradient()));
       
    66     conical = new RenderArea(new QBrush(QConicalGradient()));
       
    67     texture = new RenderArea(new QBrush(QPixmap("qt-logo.png")));
       
    68 
       
    69     solidLabel = new QLabel("Qt::SolidPattern");
       
    70     dense1Label = new QLabel("Qt::Dense1Pattern");
       
    71     dense2Label = new QLabel("Qt::Dense2Pattern");
       
    72     dense3Label = new QLabel("Qt::Dense3Pattern");
       
    73     dense4Label = new QLabel("Qt::Dense4Pattern");
       
    74     dense5Label = new QLabel("Qt::Dense5Pattern");
       
    75     dense6Label = new QLabel("Qt::Dense6Pattern");
       
    76     dense7Label = new QLabel("Qt::Dense7Pattern");
       
    77     noLabel = new QLabel("Qt::NoPattern");
       
    78     horLabel = new QLabel("Qt::HorPattern");
       
    79     verLabel = new QLabel("Qt::VerPattern");
       
    80     crossLabel = new QLabel("Qt::CrossPattern");
       
    81     bdiagLabel = new QLabel("Qt::BDiagPattern");
       
    82     fdiagLabel = new QLabel("Qt::FDiagPattern");
       
    83     diagCrossLabel = new QLabel("Qt::DiagCrossPattern");
       
    84     linearLabel = new QLabel("Qt::LinearGradientPattern");
       
    85     radialLabel = new QLabel("Qt::RadialGradientPattern");
       
    86     conicalLabel = new QLabel("Qt::ConicalGradientPattern");
       
    87     textureLabel = new QLabel("Qt::TexturePattern");
       
    88 
       
    89     QGridLayout *layout = new QGridLayout;
       
    90     layout->addWidget(solid, 0, 0);
       
    91     layout->addWidget(dense1, 0, 1);
       
    92     layout->addWidget(dense2, 0, 2);
       
    93     layout->addWidget(solidLabel, 1, 0);
       
    94     layout->addWidget(dense1Label, 1, 1);
       
    95     layout->addWidget(dense2Label, 1, 2);
       
    96 
       
    97     layout->addWidget(dense3, 2, 0 );
       
    98     layout->addWidget(dense4, 2, 1);
       
    99     layout->addWidget(dense5, 2, 2);
       
   100     layout->addWidget(dense3Label, 3, 0);
       
   101     layout->addWidget(dense4Label, 3, 1);
       
   102     layout->addWidget(dense5Label, 3, 2);
       
   103 
       
   104     layout->addWidget(dense6, 4, 0);
       
   105     layout->addWidget(dense7, 4, 1);
       
   106     layout->addWidget(no, 4, 2);
       
   107     layout->addWidget(dense6Label, 5, 0);
       
   108     layout->addWidget(dense7Label, 5, 1);
       
   109     layout->addWidget(noLabel, 5, 2);
       
   110 
       
   111     layout->addWidget(hor, 6, 0);
       
   112     layout->addWidget(ver, 6, 1);
       
   113     layout->addWidget(cross, 6, 2);
       
   114     layout->addWidget(horLabel, 7, 0);
       
   115     layout->addWidget(verLabel, 7, 1);
       
   116     layout->addWidget(crossLabel, 7, 2);
       
   117 
       
   118     layout->addWidget(bdiag, 8, 0);
       
   119     layout->addWidget(fdiag, 8, 1);
       
   120     layout->addWidget(diagCross, 8, 2);
       
   121     layout->addWidget(bdiagLabel, 9, 0);
       
   122     layout->addWidget(fdiagLabel, 9, 1);
       
   123     layout->addWidget(diagCrossLabel, 9, 2);
       
   124 
       
   125     layout->addWidget(linear, 10, 0);
       
   126     layout->addWidget(radial, 10, 1);
       
   127     layout->addWidget(conical, 10, 2);
       
   128     layout->addWidget(linearLabel, 11, 0);
       
   129     layout->addWidget(radialLabel, 11, 1);
       
   130     layout->addWidget(conicalLabel, 11, 2);
       
   131 
       
   132     layout->addWidget(texture, 12, 0, 1, 3);
       
   133     layout->addWidget(textureLabel, 13, 0, 1, 3);
       
   134 
       
   135     setLayout(layout);
       
   136 
       
   137     QPalette newPalette = palette();
       
   138     newPalette.setColor(QPalette::Window, Qt::white);
       
   139     setPalette(newPalette);
       
   140 
       
   141     setWindowTitle(tr("Brush Styles"));
       
   142     resize(430, 605);
       
   143 }
       
   144 
       
   145