| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com)
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #include "qwindowsmobilestyle.h"
|
|---|
| 43 | #include "qwindowsmobilestyle_p.h"
|
|---|
| 44 |
|
|---|
| 45 | #if !defined(QT_NO_STYLE_WINDOWSMOBILE) || defined(QT_PLUGIN)
|
|---|
| 46 |
|
|---|
| 47 | #include "qpainterpath.h"
|
|---|
| 48 | #include "qapplication.h"
|
|---|
| 49 | #include "qdesktopwidget.h"
|
|---|
| 50 | #include "qwidget.h"
|
|---|
| 51 | #include "qdockwidget.h"
|
|---|
| 52 | #include "qframe.h"
|
|---|
| 53 | #include "qmenu.h"
|
|---|
| 54 | #include "qpaintengine.h"
|
|---|
| 55 | #include "qpainter.h"
|
|---|
| 56 | #include "qgroupbox.h"
|
|---|
| 57 | #include "qstyleoption.h"
|
|---|
| 58 | #include "qlistview.h"
|
|---|
| 59 | #include "qdrawutil.h"
|
|---|
| 60 | #include "qtoolbar.h"
|
|---|
| 61 | #include "qabstractscrollarea.h"
|
|---|
| 62 | #include "qabstractbutton.h"
|
|---|
| 63 | #include "qcombobox.h"
|
|---|
| 64 | #include "qabstractscrollarea.h"
|
|---|
| 65 | #include "qframe.h"
|
|---|
| 66 | #include "qscrollbar.h"
|
|---|
| 67 | #include "qabstractitemview.h"
|
|---|
| 68 | #include "qmenubar.h"
|
|---|
| 69 | #include "qtoolbutton.h"
|
|---|
| 70 | #include "qtextedit.h"
|
|---|
| 71 | #include "qdialog.h"
|
|---|
| 72 | #include "qdebug.h"
|
|---|
| 73 | #include "qtabwidget.h"
|
|---|
| 74 |
|
|---|
| 75 | #ifdef Q_OS_WINCE
|
|---|
| 76 | #include "qt_windows.h"
|
|---|
| 77 | #include "qguifunctions_wince.h"
|
|---|
| 78 | extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp
|
|---|
| 79 | extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.cpp
|
|---|
| 80 | #endif // Q_OS_WINCE
|
|---|
| 81 |
|
|---|
| 82 | QT_BEGIN_NAMESPACE
|
|---|
| 83 |
|
|---|
| 84 | static const int windowsItemFrame = 1; // menu item frame width
|
|---|
| 85 | static const int windowsItemHMargin = 2; // menu item hor text margin
|
|---|
| 86 | static const int windowsItemVMargin = 2; // menu item ver text margin
|
|---|
| 87 | static const int windowsArrowHMargin = 6; // arrow horizontal margin
|
|---|
| 88 | static const int windowsRightBorder = 15; // right border on windows
|
|---|
| 89 | static const int windowsCheckMarkWidth = 14; // checkmarks width on windows
|
|---|
| 90 |
|
|---|
| 91 | static const int windowsMobileitemViewCheckBoxSize = 13;
|
|---|
| 92 | static const int windowsMobileFrameGroupBoxOffset = 9;
|
|---|
| 93 | static const int windowsMobileIndicatorSize = 14;
|
|---|
| 94 | static const int windowsMobileExclusiveIndicatorSize = 14;
|
|---|
| 95 | static const int windowsMobileSliderThickness = 6;
|
|---|
| 96 | static const int windowsMobileIconSize = 16;
|
|---|
| 97 | static const int PE_IndicatorArrowUpBig = 0xf000101;
|
|---|
| 98 | static const int PE_IndicatorArrowDownBig = 0xf000102;
|
|---|
| 99 | static const int PE_IndicatorArrowLeftBig = 0xf000103;
|
|---|
| 100 | static const int PE_IndicatorArrowRightBig = 0xf000104;
|
|---|
| 101 |
|
|---|
| 102 | /* XPM */
|
|---|
| 103 | static const char *const radiobutton_xpm[] = {
|
|---|
| 104 | "30 30 2 1",
|
|---|
| 105 | " c None",
|
|---|
| 106 | ". c #000000",
|
|---|
| 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 | /* XPM */
|
|---|
| 139 | static const char * const radiobutton_low_xpm[] = {
|
|---|
| 140 | "15 15 2 1",
|
|---|
| 141 | " c None",
|
|---|
| 142 | ". c #000000",
|
|---|
| 143 | " ..... ",
|
|---|
| 144 | " .. .. ",
|
|---|
| 145 | " . . ",
|
|---|
| 146 | " . . ",
|
|---|
| 147 | " . . ",
|
|---|
| 148 | ". .",
|
|---|
| 149 | ". .",
|
|---|
| 150 | ". .",
|
|---|
| 151 | ". .",
|
|---|
| 152 | ". .",
|
|---|
| 153 | " . . ",
|
|---|
| 154 | " . . ",
|
|---|
| 155 | " . . ",
|
|---|
| 156 | " .. .. ",
|
|---|
| 157 | " ..... "};
|
|---|
| 158 |
|
|---|
| 159 | /* XPM */
|
|---|
| 160 | static const char * const arrowleft_big_xpm[] = {
|
|---|
| 161 | "9 17 2 1",
|
|---|
| 162 | " c None",
|
|---|
| 163 | ". c #000000",
|
|---|
| 164 | " .",
|
|---|
| 165 | " ..",
|
|---|
| 166 | " ...",
|
|---|
| 167 | " ....",
|
|---|
| 168 | " .....",
|
|---|
| 169 | " ......",
|
|---|
| 170 | " .......",
|
|---|
| 171 | " ........",
|
|---|
| 172 | ".........",
|
|---|
| 173 | " ........",
|
|---|
| 174 | " .......",
|
|---|
| 175 | " ......",
|
|---|
| 176 | " .....",
|
|---|
| 177 | " ....",
|
|---|
| 178 | " ...",
|
|---|
| 179 | " ..",
|
|---|
| 180 | " ."};
|
|---|
| 181 |
|
|---|
| 182 | /* XPM */
|
|---|
| 183 | static const char * const arrowleft_xpm[] = {
|
|---|
| 184 | "8 15 2 1",
|
|---|
| 185 | " c None",
|
|---|
| 186 | ". c #000000",
|
|---|
| 187 | " .",
|
|---|
| 188 | " ..",
|
|---|
| 189 | " ...",
|
|---|
| 190 | " ....",
|
|---|
| 191 | " .....",
|
|---|
| 192 | " ......",
|
|---|
| 193 | " .......",
|
|---|
| 194 | "........",
|
|---|
| 195 | " .......",
|
|---|
| 196 | " ......",
|
|---|
| 197 | " .....",
|
|---|
| 198 | " ....",
|
|---|
| 199 | " ...",
|
|---|
| 200 | " ..",
|
|---|
| 201 | " ."};
|
|---|
| 202 |
|
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 | /* XPM */
|
|---|
| 206 | static const char *const horlines_xpm[] = {
|
|---|
| 207 | "2 2 2 1",
|
|---|
| 208 | " c None",
|
|---|
| 209 | ". c #000000",
|
|---|
| 210 | " ",
|
|---|
| 211 | ".."};
|
|---|
| 212 |
|
|---|
| 213 | /* XPM */
|
|---|
| 214 | static const char *const vertlines_xpm[] = {
|
|---|
| 215 | "2 2 2 1",
|
|---|
| 216 | " c None",
|
|---|
| 217 | ". c #000000",
|
|---|
| 218 | ". ",
|
|---|
| 219 | ". "};
|
|---|
| 220 |
|
|---|
| 221 | /* XPM */
|
|---|
| 222 | static const char *const radiochecked_xpm[] = {
|
|---|
| 223 | "18 18 2 1",
|
|---|
| 224 | " c None",
|
|---|
| 225 | ". c #000000",
|
|---|
| 226 | " ...... ",
|
|---|
| 227 | " .......... ",
|
|---|
| 228 | " .............. ",
|
|---|
| 229 | " .............. ",
|
|---|
| 230 | " ................ ",
|
|---|
| 231 | " ................ ",
|
|---|
| 232 | "..................",
|
|---|
| 233 | "..................",
|
|---|
| 234 | "..................",
|
|---|
| 235 | "..................",
|
|---|
| 236 | "..................",
|
|---|
| 237 | "..................",
|
|---|
| 238 | " ................ ",
|
|---|
| 239 | " ................ ",
|
|---|
| 240 | " .............. ",
|
|---|
| 241 | " .............. ",
|
|---|
| 242 | " .......... ",
|
|---|
| 243 | " ...... "};
|
|---|
| 244 |
|
|---|
| 245 | /* XPM */
|
|---|
| 246 | static const char * const radiochecked_low_xpm[] = {
|
|---|
| 247 | "9 9 2 1",
|
|---|
| 248 | " c None",
|
|---|
| 249 | ". c #000000",
|
|---|
| 250 | " ... ",
|
|---|
| 251 | " ....... ",
|
|---|
| 252 | " ....... ",
|
|---|
| 253 | ".........",
|
|---|
| 254 | ".........",
|
|---|
| 255 | ".........",
|
|---|
| 256 | " ....... ",
|
|---|
| 257 | " ....... ",
|
|---|
| 258 | " ... "};
|
|---|
| 259 |
|
|---|
| 260 | static const char *const arrowdown_xpm[] = {
|
|---|
| 261 | "15 8 2 1",
|
|---|
| 262 | " c None",
|
|---|
| 263 | ". c #000000",
|
|---|
| 264 | "...............",
|
|---|
| 265 | " ............. ",
|
|---|
| 266 | " ........... ",
|
|---|
| 267 | " ......... ",
|
|---|
| 268 | " ....... ",
|
|---|
| 269 | " ..... ",
|
|---|
| 270 | " ... ",
|
|---|
| 271 | " . "};
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 | static const char *const arrowdown_big_xpm[] = {
|
|---|
| 275 | "17 9 2 1",
|
|---|
| 276 | " c None",
|
|---|
| 277 | ". c #000000",
|
|---|
| 278 | ".................",
|
|---|
| 279 | " ............... ",
|
|---|
| 280 | " ............. ",
|
|---|
| 281 | " ........... ",
|
|---|
| 282 | " ......... ",
|
|---|
| 283 | " ....... ",
|
|---|
| 284 | " ..... ",
|
|---|
| 285 | " ... ",
|
|---|
| 286 | " . "};
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 | /* XPM */
|
|---|
| 290 | static const char *const checkedlight_xpm[] = {
|
|---|
| 291 | "24 24 2 1",
|
|---|
| 292 | " c None",
|
|---|
| 293 | ". c #000000",
|
|---|
| 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 | /* XPM */
|
|---|
| 321 | static const char *const checkedbold_xpm[] = {
|
|---|
| 322 | "26 26 2 1",
|
|---|
| 323 | " c None",
|
|---|
| 324 | ". c #000000",
|
|---|
| 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 | /* XPM */
|
|---|
| 353 | static const char * const checkedbold_low_xpm[] = {
|
|---|
| 354 | "9 8 2 1",
|
|---|
| 355 | " c None",
|
|---|
| 356 | ". c #000000",
|
|---|
| 357 | " .",
|
|---|
| 358 | " ..",
|
|---|
| 359 | ". ...",
|
|---|
| 360 | ".. ... ",
|
|---|
| 361 | "... ... ",
|
|---|
| 362 | " ..... ",
|
|---|
| 363 | " ... ",
|
|---|
| 364 | " . "};
|
|---|
| 365 |
|
|---|
| 366 | /* XPM */
|
|---|
| 367 | static const char * const checkedlight_low_xpm[] = {
|
|---|
| 368 | "8 8 2 1",
|
|---|
| 369 | " c None",
|
|---|
| 370 | ". c #000000",
|
|---|
| 371 | " .",
|
|---|
| 372 | " ..",
|
|---|
| 373 | " ...",
|
|---|
| 374 | ". ... ",
|
|---|
| 375 | ".. ... ",
|
|---|
| 376 | "..... ",
|
|---|
| 377 | " ... ",
|
|---|
| 378 | " . "};
|
|---|
| 379 |
|
|---|
| 380 | /* XPM */
|
|---|
| 381 | static const char * const highlightedradiobutton_xpm[] = {
|
|---|
| 382 | "30 30 3 1",
|
|---|
| 383 | " c None",
|
|---|
| 384 | ". c #000000",
|
|---|
| 385 | "+ c #0078CC",
|
|---|
| 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 | /* XPM */
|
|---|
| 418 | static const char * const highlightedradiobutton_low_xpm[] = {
|
|---|
| 419 | "15 15 3 1",
|
|---|
| 420 | " c None",
|
|---|
| 421 | ". c #000000",
|
|---|
| 422 | "+ c #3192D6",
|
|---|
| 423 | " ..... ",
|
|---|
| 424 | " ..+++++.. ",
|
|---|
| 425 | " .++ ++. ",
|
|---|
| 426 | " .+ +. ",
|
|---|
| 427 | " .+ +. ",
|
|---|
| 428 | ".+ +.",
|
|---|
| 429 | ".+ +.",
|
|---|
| 430 | ".+ +.",
|
|---|
| 431 | ".+ +.",
|
|---|
| 432 | ".+ +.",
|
|---|
| 433 | " .+ +. ",
|
|---|
| 434 | " .+ +. ",
|
|---|
| 435 | " .++ ++. ",
|
|---|
| 436 | " ..+++++.. ",
|
|---|
| 437 | " ..... "};
|
|---|
| 438 |
|
|---|
| 439 | /* XPM */
|
|---|
| 440 | static const char * const cross_big_xpm[] = {
|
|---|
| 441 | "28 28 4 1",
|
|---|
| 442 | " c #09454A",
|
|---|
| 443 | ". c #218C98",
|
|---|
| 444 | "+ c #47D8E5",
|
|---|
| 445 | "@ c #FDFFFC",
|
|---|
| 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 | /* XPM */
|
|---|
| 476 | static const char * const cross_small_xpm[] = {
|
|---|
| 477 | "14 14 4 1",
|
|---|
| 478 | " c #09454A",
|
|---|
| 479 | ". c #218C98",
|
|---|
| 480 | "+ c #47D8E5",
|
|---|
| 481 | "@ c #FCFFFC",
|
|---|
| 482 | " ",
|
|---|
| 483 | " ++++++++++++ ",
|
|---|
| 484 | " +..........+ ",
|
|---|
| 485 | " +.@@....@@.+ ",
|
|---|
| 486 | " +.@@@..@@@.+ ",
|
|---|
| 487 | " +..@@@@@@..+ ",
|
|---|
| 488 | " +...@@@@...+ ",
|
|---|
| 489 | " +...@@@@...+ ",
|
|---|
| 490 | " +..@@@@@@..+ ",
|
|---|
| 491 | " +.@@@..@@@.+ ",
|
|---|
| 492 | " +.@@....@@.+ ",
|
|---|
| 493 | " +..........+ ",
|
|---|
| 494 | " ++++++++++++ ",
|
|---|
| 495 | " "};
|
|---|
| 496 |
|
|---|
| 497 | /* XPM */
|
|---|
| 498 | static const char * const max_big_xpm[] = {
|
|---|
| 499 | "28 28 4 1",
|
|---|
| 500 | " c #09454A",
|
|---|
| 501 | ". c #218C98",
|
|---|
| 502 | "+ c #47D8E5",
|
|---|
| 503 | "@ c #FDFFFC",
|
|---|
| 504 | " ",
|
|---|
| 505 | " ",
|
|---|
| 506 | " ++++++++++++++++++++++++ ",
|
|---|
| 507 | " ++++++++++++++++++++++++ ",
|
|---|
| 508 | " ++....................++ ",
|
|---|
| 509 | " ++....................++ ",
|
|---|
| 510 | " ++....................++ ",
|
|---|
| 511 | " ++....................++ ",
|
|---|
| 512 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 513 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 514 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 515 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 516 | " ++..@@............@@..++ ",
|
|---|
| 517 | " ++..@@............@@..++ ",
|
|---|
| 518 | " ++..@@............@@..++ ",
|
|---|
| 519 | " ++..@@............@@..++ ",
|
|---|
| 520 | " ++..@@............@@..++ ",
|
|---|
| 521 | " ++..@@............@@..++ ",
|
|---|
| 522 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 523 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 524 | " ++....................++ ",
|
|---|
| 525 | " ++....................++ ",
|
|---|
| 526 | " ++....................++ ",
|
|---|
| 527 | " ++....................++ ",
|
|---|
| 528 | " ++++++++++++++++++++++++ ",
|
|---|
| 529 | " ++++++++++++++++++++++++ ",
|
|---|
| 530 | " ",
|
|---|
| 531 | " "};
|
|---|
| 532 |
|
|---|
| 533 | /* XPM */
|
|---|
| 534 | static const char * const max_small_xpm[] = {
|
|---|
| 535 | "14 14 4 1",
|
|---|
| 536 | " c #09454A",
|
|---|
| 537 | ". c #218C98",
|
|---|
| 538 | "+ c #47D8E5",
|
|---|
| 539 | "@ c #FCFFFC",
|
|---|
| 540 | " ",
|
|---|
| 541 | " ++++++++++++ ",
|
|---|
| 542 | " +..........+ ",
|
|---|
| 543 | " +..........+ ",
|
|---|
| 544 | " +.@@@@@@@@.+ ",
|
|---|
| 545 | " +.@@@@@@@@.+ ",
|
|---|
| 546 | " +.@......@.+ ",
|
|---|
| 547 | " +.@......@.+ ",
|
|---|
| 548 | " +.@......@.+ ",
|
|---|
| 549 | " +.@@@@@@@@.+ ",
|
|---|
| 550 | " +..........+ ",
|
|---|
| 551 | " +..........+ ",
|
|---|
| 552 | " ++++++++++++ ",
|
|---|
| 553 | " "};
|
|---|
| 554 |
|
|---|
| 555 | /* XPM */
|
|---|
| 556 | static const char * const normal_big_xpm[] = {
|
|---|
| 557 | "28 28 4 1",
|
|---|
| 558 | " c #09454A",
|
|---|
| 559 | ". c #218C98",
|
|---|
| 560 | "+ c #47D8E5",
|
|---|
| 561 | "@ c #FDFFFC",
|
|---|
| 562 | " ",
|
|---|
| 563 | " ",
|
|---|
| 564 | " ++++++++++++++++++++++++ ",
|
|---|
| 565 | " ++++++++++++++++++++++++ ",
|
|---|
| 566 | " ++....................++ ",
|
|---|
| 567 | " ++....................++ ",
|
|---|
| 568 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 569 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 570 | " ++..@@............@@..++ ",
|
|---|
| 571 | " ++..@@............@@..++ ",
|
|---|
| 572 | " ++..@@............@@..++ ",
|
|---|
| 573 | " ++..@@............@@..++ ",
|
|---|
| 574 | " ++..@@............@@..++ ",
|
|---|
| 575 | " ++..@@............@@..++ ",
|
|---|
| 576 | " ++..@@............@@..++ ",
|
|---|
| 577 | " ++..@@............@@..++ ",
|
|---|
| 578 | " ++..@@............@@..++ ",
|
|---|
| 579 | " ++..@@............@@..++ ",
|
|---|
| 580 | " ++..@@............@@..++ ",
|
|---|
| 581 | " ++..@@............@@..++ ",
|
|---|
| 582 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 583 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 584 | " ++....................++ ",
|
|---|
| 585 | " ++....................++ ",
|
|---|
| 586 | " ++++++++++++++++++++++++ ",
|
|---|
| 587 | " ++++++++++++++++++++++++ ",
|
|---|
| 588 | " ",
|
|---|
| 589 | " "};
|
|---|
| 590 |
|
|---|
| 591 | /* XPM */
|
|---|
| 592 | static const char * const normal_small_xpm[] = {
|
|---|
| 593 | "14 14 4 1",
|
|---|
| 594 | " c #09454A",
|
|---|
| 595 | ". c #218C98",
|
|---|
| 596 | "+ c #47D8E5",
|
|---|
| 597 | "@ c #FCFFFC",
|
|---|
| 598 | " ",
|
|---|
| 599 | " ++++++++++++ ",
|
|---|
| 600 | " +..........+ ",
|
|---|
| 601 | " +.@@@@@@@@.+ ",
|
|---|
| 602 | " +.@......@.+ ",
|
|---|
| 603 | " +.@......@.+ ",
|
|---|
| 604 | " +.@......@.+ ",
|
|---|
| 605 | " +.@......@.+ ",
|
|---|
| 606 | " +.@......@.+ ",
|
|---|
| 607 | " +.@......@.+ ",
|
|---|
| 608 | " +.@@@@@@@@.+ ",
|
|---|
| 609 | " +..........+ ",
|
|---|
| 610 | " ++++++++++++ ",
|
|---|
| 611 | " "};
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 | /* XPM */
|
|---|
| 615 | static const char * const min_big_xpm[] = {
|
|---|
| 616 | "28 28 4 1",
|
|---|
| 617 | " c #09454A",
|
|---|
| 618 | ". c #218C98",
|
|---|
| 619 | "+ c #47D8E5",
|
|---|
| 620 | "@ c #FDFFFC",
|
|---|
| 621 | " ",
|
|---|
| 622 | " ",
|
|---|
| 623 | " ++++++++++++++++++++++++ ",
|
|---|
| 624 | " ++++++++++++++++++++++++ ",
|
|---|
| 625 | " ++....................++ ",
|
|---|
| 626 | " ++....................++ ",
|
|---|
| 627 | " ++....................++ ",
|
|---|
| 628 | " ++....................++ ",
|
|---|
| 629 | " ++....................++ ",
|
|---|
| 630 | " ++....................++ ",
|
|---|
| 631 | " ++....................++ ",
|
|---|
| 632 | " ++....................++ ",
|
|---|
| 633 | " ++....................++ ",
|
|---|
| 634 | " ++....................++ ",
|
|---|
| 635 | " ++....................++ ",
|
|---|
| 636 | " ++....................++ ",
|
|---|
| 637 | " ++....................++ ",
|
|---|
| 638 | " ++....................++ ",
|
|---|
| 639 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 640 | " ++..@@@@@@@@@@@@@@@@..++ ",
|
|---|
| 641 | " ++....................++ ",
|
|---|
| 642 | " ++....................++ ",
|
|---|
| 643 | " ++....................++ ",
|
|---|
| 644 | " ++....................++ ",
|
|---|
| 645 | " ++++++++++++++++++++++++ ",
|
|---|
| 646 | " ++++++++++++++++++++++++ ",
|
|---|
| 647 | " ",
|
|---|
| 648 | " "};
|
|---|
| 649 |
|
|---|
| 650 | /* XPM */
|
|---|
| 651 | static const char * const min_small_xpm[] = {
|
|---|
| 652 | "14 14 4 1",
|
|---|
| 653 | " c #09454A",
|
|---|
| 654 | ". c #218C98",
|
|---|
| 655 | "+ c #47D8E5",
|
|---|
| 656 | "@ c #FCFFFC",
|
|---|
| 657 | " ",
|
|---|
| 658 | " ++++++++++++ ",
|
|---|
| 659 | " +..........+ ",
|
|---|
| 660 | " +..........+ ",
|
|---|
| 661 | " +..........+ ",
|
|---|
| 662 | " +..........+ ",
|
|---|
| 663 | " +..........+ ",
|
|---|
| 664 | " +..........+ ",
|
|---|
| 665 | " +..........+ ",
|
|---|
| 666 | " +.@@@@@@@@.+ ",
|
|---|
| 667 | " +..........+ ",
|
|---|
| 668 | " +..........+ ",
|
|---|
| 669 | " ++++++++++++ ",
|
|---|
| 670 | " "};
|
|---|
| 671 |
|
|---|
| 672 |
|
|---|
| 673 |
|
|---|
| 674 | enum QSliderDirection { SliderUp, SliderDown, SliderLeft, SliderRight };
|
|---|
| 675 |
|
|---|
| 676 | QWindowsMobileStyle::QWindowsMobileStyle(QWindowsMobileStylePrivate &dd) : QWindowsStyle(dd) {
|
|---|
| 677 | qApp->setEffectEnabled(Qt::UI_FadeMenu, false);
|
|---|
| 678 | qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
|
|---|
| 679 | }
|
|---|
| 680 |
|
|---|
| 681 | QWindowsMobileStyle::QWindowsMobileStyle() : QWindowsStyle(*new QWindowsMobileStylePrivate) {
|
|---|
| 682 | qApp->setEffectEnabled(Qt::UI_FadeMenu, false);
|
|---|
| 683 | qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
|
|---|
| 684 | }
|
|---|
| 685 |
|
|---|
| 686 | QWindowsMobileStylePrivate::QWindowsMobileStylePrivate() :QWindowsStylePrivate() {
|
|---|
| 687 |
|
|---|
| 688 | #ifdef Q_OS_WINCE
|
|---|
| 689 | doubleControls = qt_wince_is_high_dpi();
|
|---|
| 690 | smartphone = qt_wince_is_smartphone();
|
|---|
| 691 | #else
|
|---|
| 692 | doubleControls = false;
|
|---|
| 693 | smartphone = false;
|
|---|
| 694 | #endif //Q_OS_WINCE
|
|---|
| 695 |
|
|---|
| 696 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
|---|
| 697 |
|
|---|
| 698 | imageArrowDown = QImage(arrowdown_xpm);
|
|---|
| 699 | imageArrowUp = QImage(arrowdown_xpm).mirrored();
|
|---|
| 700 | imageArrowLeft = QImage(arrowleft_xpm);
|
|---|
| 701 | imageArrowRight = QImage(arrowleft_xpm).mirrored(true, false);
|
|---|
| 702 | if (doubleControls) {
|
|---|
| 703 | imageRadioButton = QImage(radiobutton_xpm);
|
|---|
| 704 | imageRadioButtonChecked = QImage(radiochecked_xpm);
|
|---|
| 705 | imageChecked = QImage(checkedlight_xpm);
|
|---|
| 706 | imageCheckedBold = QImage(checkedbold_xpm);
|
|---|
| 707 | imageRadioButtonHighlighted = QImage(highlightedradiobutton_xpm);
|
|---|
| 708 | imageClose = QImage(cross_big_xpm);
|
|---|
| 709 | imageMaximize = QImage(max_big_xpm);
|
|---|
| 710 | imageMinimize = QImage(min_big_xpm);
|
|---|
| 711 | imageNormalize = QImage(normal_big_xpm);
|
|---|
| 712 | } else {
|
|---|
| 713 | imageRadioButton = QImage(radiobutton_low_xpm);
|
|---|
| 714 | imageRadioButtonChecked = QImage(radiochecked_low_xpm);
|
|---|
| 715 | imageChecked = QImage(checkedlight_low_xpm);
|
|---|
| 716 | imageCheckedBold = QImage(checkedbold_low_xpm);
|
|---|
| 717 | imageRadioButtonHighlighted = QImage(highlightedradiobutton_low_xpm);
|
|---|
| 718 | imageClose = QImage(cross_small_xpm);
|
|---|
| 719 | imageMaximize = QImage(max_small_xpm);
|
|---|
| 720 | imageMinimize = QImage(min_small_xpm);
|
|---|
| 721 | imageNormalize = QImage(normal_small_xpm);
|
|---|
| 722 | }
|
|---|
| 723 |
|
|---|
| 724 | imageArrowDownBig = QImage(arrowdown_big_xpm);
|
|---|
| 725 | imageArrowUpBig = QImage(arrowdown_big_xpm).mirrored();
|
|---|
| 726 | imageArrowLeftBig = QImage(arrowleft_big_xpm);
|
|---|
| 727 | imageArrowRightBig = QImage(arrowleft_big_xpm).mirrored(true, false);
|
|---|
| 728 |
|
|---|
| 729 | #endif
|
|---|
| 730 | }
|
|---|
| 731 |
|
|---|
| 732 | void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
|
|---|
| 733 | QPainter *painter, const QWidget *widget) const {
|
|---|
| 734 |
|
|---|
| 735 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 736 |
|
|---|
| 737 | bool doRestore = false;
|
|---|
| 738 | QRect rect = option->rect;
|
|---|
| 739 | painter->setClipping(false);
|
|---|
| 740 |
|
|---|
| 741 | switch (element) {
|
|---|
| 742 | case PE_PanelButtonTool: {
|
|---|
| 743 | int penSize = 1;
|
|---|
| 744 | if (d->doubleControls)
|
|---|
| 745 | penSize = 2;
|
|---|
| 746 | if (widget)
|
|---|
| 747 | if (QWidget *parent = widget->parentWidget())
|
|---|
| 748 | #ifndef QT_NO_TABWIDGET
|
|---|
| 749 | if (qobject_cast<QTabWidget *>(parent->parentWidget())) {
|
|---|
| 750 | #else
|
|---|
| 751 | if (false) {
|
|---|
| 752 | #endif //QT_NO_TABBAR
|
|---|
| 753 | rect.adjust(0,2*penSize,0,-1*penSize);
|
|---|
| 754 | qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.light());
|
|---|
| 755 | if (option->state & (State_Sunken))
|
|---|
| 756 | qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.shadow());
|
|---|
| 757 | }
|
|---|
| 758 | else {
|
|---|
| 759 | if (!(option->state & State_AutoRaise) || (option->state & (State_Sunken | State_On)))
|
|---|
| 760 | qDrawPlainRect(painter,option->rect.adjusted(0, penSize, 0, -1 * penSize) ,
|
|---|
| 761 | option->palette.button().color(), 0, &option->palette.button());
|
|---|
| 762 | if (option->state & (State_Sunken)) {
|
|---|
| 763 | qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.light());
|
|---|
| 764 | }
|
|---|
| 765 | if (option->state & (State_On)){
|
|---|
| 766 | QBrush fill = QBrush(option->palette.light().color());
|
|---|
| 767 | painter->fillRect(rect.adjusted(windowsItemFrame , windowsItemFrame ,
|
|---|
| 768 | -windowsItemFrame , -windowsItemFrame ), fill);
|
|---|
| 769 | qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.light());
|
|---|
| 770 | }
|
|---|
| 771 | }
|
|---|
| 772 | break; }
|
|---|
| 773 | case PE_IndicatorButtonDropDown:
|
|---|
| 774 | if (d->doubleControls)
|
|---|
| 775 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 2, &option->palette.button());
|
|---|
| 776 | else
|
|---|
| 777 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 1, &option->palette.button());
|
|---|
| 778 | break;
|
|---|
| 779 | #ifndef QT_NO_TABBAR
|
|---|
| 780 | case PE_IndicatorTabTear:
|
|---|
| 781 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
|---|
| 782 | bool rtl = tab->direction == Qt::RightToLeft;
|
|---|
| 783 | QRect rect = tab->rect;
|
|---|
| 784 | QPainterPath path;
|
|---|
| 785 | rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
|
|---|
| 786 | rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
|
|---|
| 787 | path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
|
|---|
| 788 | int count = 3;
|
|---|
| 789 | for(int jags = 1; jags <= count; ++jags, rtl = !rtl)
|
|---|
| 790 | path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
|
|---|
| 791 | painter->setPen(QPen(tab->palette.light(), qreal(.8)));
|
|---|
| 792 | painter->setBrush(tab->palette.background());
|
|---|
| 793 | painter->setRenderHint(QPainter::Antialiasing);
|
|---|
| 794 | painter->drawPath(path);
|
|---|
| 795 | }
|
|---|
| 796 | break;
|
|---|
| 797 | #endif //QT_NO_TABBAR
|
|---|
| 798 |
|
|---|
| 799 | #ifndef QT_NO_TOOLBAR
|
|---|
| 800 | case PE_IndicatorToolBarSeparator: {
|
|---|
| 801 | painter->save();
|
|---|
| 802 | QPoint p1, p2;
|
|---|
| 803 | if (option->state & State_Horizontal) {
|
|---|
| 804 | p1 = QPoint(option->rect.width()/2, 0);
|
|---|
| 805 | p2 = QPoint(p1.x(), option->rect.height());
|
|---|
| 806 | } else {
|
|---|
| 807 | p1 = QPoint(0, option->rect.height()/2);
|
|---|
| 808 | p2 = QPoint(option->rect.width(), p1.y());
|
|---|
| 809 | }
|
|---|
| 810 |
|
|---|
| 811 |
|
|---|
| 812 | painter->setPen(option->palette.mid().color());
|
|---|
| 813 | if (d->doubleControls) {
|
|---|
| 814 | QPen pen = painter->pen();
|
|---|
| 815 | pen.setWidth(2);
|
|---|
| 816 | pen.setCapStyle(Qt::FlatCap);
|
|---|
| 817 | painter->setPen(pen);
|
|---|
| 818 | }
|
|---|
| 819 | painter->drawLine(p1, p2);
|
|---|
| 820 | painter->restore();
|
|---|
| 821 | break; }
|
|---|
| 822 | #endif // QT_NO_TOOLBAR
|
|---|
| 823 | case PE_IndicatorToolBarHandle:
|
|---|
| 824 | painter->save();
|
|---|
| 825 | painter->translate(option->rect.x(), option->rect.y());
|
|---|
| 826 | if (option->state & State_Horizontal) {
|
|---|
| 827 | int x = option->rect.width() / 2 - 4;
|
|---|
| 828 | if (QApplication::layoutDirection() == Qt::RightToLeft)
|
|---|
| 829 | x -= 2;
|
|---|
| 830 | if (option->rect.height() > 4) {
|
|---|
| 831 | qDrawWinButton(painter,x-1,0,7,option->rect.height(), option->palette, false, 0);
|
|---|
| 832 |
|
|---|
| 833 | qDrawShadePanel(painter, x, 1, 3, option->rect.height() - 1,
|
|---|
| 834 | option->palette, false, 0);
|
|---|
| 835 | qDrawShadePanel(painter, x + 3, 1, 3, option->rect.height() - 1,
|
|---|
| 836 | option->palette, false, 0);
|
|---|
| 837 | painter->setPen(option->palette.button().color());
|
|---|
| 838 | }
|
|---|
| 839 | } else {
|
|---|
| 840 | if (option->rect.width() > 4) {
|
|---|
| 841 | int y = option->rect.height() / 2 - 4;
|
|---|
| 842 | qDrawShadePanel(painter, 2, y, option->rect.width() - 2, 3,
|
|---|
| 843 | option->palette, false, 0);
|
|---|
| 844 | qDrawShadePanel(painter, 2, y + 3, option->rect.width() - 2, 3,
|
|---|
| 845 | option->palette, false, 0);
|
|---|
| 846 | }
|
|---|
| 847 | }
|
|---|
| 848 | painter->restore();
|
|---|
| 849 | break;
|
|---|
| 850 |
|
|---|
| 851 | #ifndef QT_NO_PROGRESSBAR
|
|---|
| 852 | case PE_IndicatorProgressChunk: {
|
|---|
| 853 | bool vertical = false;
|
|---|
| 854 | if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option))
|
|---|
| 855 | vertical = (pb2->orientation == Qt::Vertical);
|
|---|
| 856 | if (!vertical) {
|
|---|
| 857 | painter->fillRect(option->rect.x(), option->rect.y()+2, option->rect.width(), option->rect.height()-4,
|
|---|
| 858 | option->palette.brush(QPalette::Highlight));
|
|---|
| 859 | } else {
|
|---|
| 860 | painter->fillRect(option->rect.x()+2, option->rect.y(), option->rect.width()-4, option->rect.height(),
|
|---|
| 861 | option->palette.brush(QPalette::Highlight));
|
|---|
| 862 | }
|
|---|
| 863 | }
|
|---|
| 864 | break;
|
|---|
| 865 | #endif // QT_NO_PROGRESSBAR
|
|---|
| 866 |
|
|---|
| 867 | case PE_FrameButtonTool: {
|
|---|
| 868 | #ifndef QT_NO_DOCKWIDGET
|
|---|
| 869 | if (widget && widget->inherits("QDockWidgetTitleButton")) {
|
|---|
| 870 | if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget->parent()))
|
|---|
| 871 | if (dw->isFloating()){
|
|---|
| 872 | qDrawPlainRect(painter,option->rect.adjusted(1, 1, 0, 0),
|
|---|
| 873 | option->palette.shadow().color(),1,&option->palette.button());
|
|---|
| 874 | return;
|
|---|
| 875 | }
|
|---|
| 876 | }
|
|---|
| 877 | #endif // QT_NO_DOCKWIDGET
|
|---|
| 878 | QBrush fill;
|
|---|
| 879 | bool stippled;
|
|---|
| 880 | bool panel = (element == PE_PanelButtonTool);
|
|---|
| 881 | if ((!(option->state & State_Sunken ))
|
|---|
| 882 | && (!(option->state & State_Enabled)
|
|---|
| 883 | || ((option->state & State_Enabled ) && !(option->state & State_MouseOver)))
|
|---|
| 884 | && (option->state & State_On)) {
|
|---|
| 885 | fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
|
|---|
| 886 | stippled = true;
|
|---|
| 887 | } else {
|
|---|
| 888 | fill = option->palette.brush(QPalette::Button);
|
|---|
| 889 | stippled = false;
|
|---|
| 890 | }
|
|---|
| 891 | if (option->state & (State_Raised | State_Sunken | State_On)) {
|
|---|
| 892 | if (option->state & State_AutoRaise) {
|
|---|
| 893 | if(option->state & (State_Enabled | State_Sunken | State_On)){
|
|---|
| 894 | if (panel)
|
|---|
| 895 | qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),d->doubleControls, &fill);
|
|---|
| 896 | else
|
|---|
| 897 | qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),d->doubleControls, &fill);
|
|---|
| 898 | }
|
|---|
| 899 | if (stippled) {
|
|---|
| 900 | painter->setPen(option->palette.button().color());
|
|---|
| 901 | painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
|
|---|
| 902 | }
|
|---|
| 903 | } else {
|
|---|
| 904 | qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),d->doubleControls, &fill);
|
|---|
| 905 | }
|
|---|
| 906 | } else {
|
|---|
| 907 | painter->fillRect(option->rect, fill);
|
|---|
| 908 | }
|
|---|
| 909 | break; }
|
|---|
| 910 |
|
|---|
| 911 | case PE_FrameFocusRect:
|
|---|
| 912 | if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
|
|---|
| 913 | //### check for d->alt_down
|
|---|
| 914 | int penSize;
|
|---|
| 915 | d->doubleControls ? penSize = 2 : penSize = 1;
|
|---|
| 916 | bool alternateFocusStyle = false;
|
|---|
| 917 | if (!widget)
|
|---|
| 918 | alternateFocusStyle = true;
|
|---|
| 919 | #ifndef QT_NO_COMBOBOX
|
|---|
| 920 | if (qobject_cast<const QComboBox*>(widget))
|
|---|
| 921 | alternateFocusStyle = true;
|
|---|
| 922 | #endif
|
|---|
| 923 | if (!(fropt->state & State_KeyboardFocusChange) && !styleHint(SH_UnderlineShortcut, option))
|
|---|
| 924 | return;
|
|---|
| 925 | QRect r = option->rect;
|
|---|
| 926 | painter->save();
|
|---|
| 927 | painter->setBackgroundMode(Qt::TransparentMode);
|
|---|
| 928 | if (alternateFocusStyle) {
|
|---|
| 929 | QColor bg_col = fropt->backgroundColor;
|
|---|
| 930 | if (!bg_col.isValid())
|
|---|
| 931 | bg_col = painter->background().color();
|
|---|
| 932 | // Create an "XOR" color.
|
|---|
| 933 | QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
|
|---|
| 934 | (bg_col.green() ^ 0xff) & 0xff,
|
|---|
| 935 | (bg_col.blue() ^ 0xff) & 0xff);
|
|---|
| 936 | painter->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
|
|---|
| 937 | painter->setBrushOrigin(r.topLeft());
|
|---|
| 938 | }
|
|---|
| 939 | else {
|
|---|
| 940 | painter->setPen(option->palette.highlight().color());
|
|---|
| 941 | painter->setBrush(option->palette.highlight());
|
|---|
| 942 | }
|
|---|
| 943 | painter->setPen(Qt::NoPen);
|
|---|
| 944 | painter->setBrushOrigin(r.topLeft());
|
|---|
| 945 | painter->drawRect(r.left(), r.top(), r.width(), penSize); // Top
|
|---|
| 946 | painter->drawRect(r.left(), r.bottom(), r.width() + penSize - 1, penSize); // Bottom
|
|---|
| 947 | painter->drawRect(r.left(), r.top(), penSize, r.height()); // Left
|
|---|
| 948 | painter->drawRect(r.right(), r.top(), penSize, r.height()); // Right
|
|---|
| 949 | painter->restore();
|
|---|
| 950 | }
|
|---|
| 951 | break;
|
|---|
| 952 |
|
|---|
| 953 | case PE_PanelButtonBevel: {
|
|---|
| 954 | QBrush fill;
|
|---|
| 955 | bool panel = element != PE_FrameButtonBevel;
|
|---|
| 956 | painter->setBrushOrigin(option->rect.topLeft());
|
|---|
| 957 | if (!(option->state & State_Sunken) && (option->state & State_On))
|
|---|
| 958 | fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
|
|---|
| 959 | else
|
|---|
| 960 | fill = option->palette.brush(QPalette::Button);
|
|---|
| 961 |
|
|---|
| 962 | if (option->state & (State_Raised | State_On | State_Sunken)) {
|
|---|
| 963 | if (d->doubleControls)
|
|---|
| 964 | qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),2,&fill);
|
|---|
| 965 | else
|
|---|
| 966 | qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),1,&fill);
|
|---|
| 967 | } else {
|
|---|
| 968 | if (panel)
|
|---|
| 969 | painter->fillRect(option->rect, fill);
|
|---|
| 970 | else
|
|---|
| 971 | painter->drawRect(option->rect);
|
|---|
| 972 | }
|
|---|
| 973 | break; }
|
|---|
| 974 |
|
|---|
| 975 | case PE_FrameGroupBox:
|
|---|
| 976 | if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
|
|---|
| 977 |
|
|---|
| 978 | const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(option);
|
|---|
| 979 | if (frame2 && !(frame2->features & QStyleOptionFrameV2::Flat)) {
|
|---|
| 980 | QPen oldPen = painter->pen();
|
|---|
| 981 | QRect r = frame->rect;
|
|---|
| 982 | painter->setPen(frame->palette.shadow().color());
|
|---|
| 983 | painter->fillRect(r.x(), r.y(), r.x() + r.width()-1,
|
|---|
| 984 | r.y() + r.height() - windowsMobileFrameGroupBoxOffset,
|
|---|
| 985 | frame->palette.light());
|
|---|
| 986 | painter ->drawLine(r.topLeft() + QPoint(-2, 1), r.topRight()+ QPoint(0, 1));
|
|---|
| 987 | if (d->doubleControls)
|
|---|
| 988 | painter ->drawLine(r.topLeft() + QPoint(-2, 2), r.topRight()+ QPoint(0, 2));
|
|---|
| 989 | painter->setPen(oldPen);
|
|---|
| 990 | }
|
|---|
| 991 | }
|
|---|
| 992 | break;
|
|---|
| 993 |
|
|---|
| 994 | case PE_IndicatorCheckBox: {
|
|---|
| 995 | QBrush fill;
|
|---|
| 996 | QRect r = d->doubleControls ? option->rect.adjusted(0,1,0,-1) : option->rect;
|
|---|
| 997 | if (option->state & State_NoChange)
|
|---|
| 998 | fill = QBrush(option->palette.shadow().color(), Qt::Dense4Pattern);
|
|---|
| 999 | else if (option->state & State_Sunken)
|
|---|
| 1000 | fill = option->palette.button();
|
|---|
| 1001 | else if (option->state & State_Enabled)
|
|---|
| 1002 | fill = option->palette.base();
|
|---|
| 1003 | else
|
|---|
| 1004 | fill = option->palette.background();
|
|---|
| 1005 | painter->save();
|
|---|
| 1006 | doRestore = true;
|
|---|
| 1007 | if (d->doubleControls && (option->state & State_NoChange))
|
|---|
| 1008 | painter->fillRect(r, fill);
|
|---|
| 1009 | else
|
|---|
| 1010 | painter->fillRect(option->rect, fill);
|
|---|
| 1011 | painter->setPen(option->palette.shadow().color());
|
|---|
| 1012 | painter->drawLine(r.topLeft(), r.topRight());
|
|---|
| 1013 | painter->drawLine(r.topRight(), r.bottomRight());
|
|---|
| 1014 | painter->drawLine(r.bottomLeft(), r.bottomRight());
|
|---|
| 1015 | painter->drawLine(r.bottomLeft(), r.topLeft());
|
|---|
| 1016 | if (d->doubleControls) {
|
|---|
| 1017 | QRect r0 = r.adjusted(1, 1, -1, -1);
|
|---|
| 1018 | painter->drawLine(r0.topLeft(), r0.topRight());
|
|---|
| 1019 | painter->drawLine(r0.topRight(), r0.bottomRight());
|
|---|
| 1020 | painter->drawLine(r0.bottomLeft(), r0.bottomRight());
|
|---|
| 1021 | painter->drawLine(r0.bottomLeft(), r0.topLeft());
|
|---|
| 1022 | }
|
|---|
| 1023 | if (option->state & State_HasFocus) {
|
|---|
| 1024 | painter->setPen(option->palette.highlight().color());
|
|---|
| 1025 | QRect r2 = d->doubleControls ? r.adjusted(2, 2, -2, -2) : r.adjusted(1, 1, -1, -1);
|
|---|
| 1026 | painter->drawLine(r2.topLeft(), r2.topRight());
|
|---|
| 1027 | painter->drawLine(r2.topRight(), r2.bottomRight());
|
|---|
| 1028 | painter->drawLine(r2.bottomLeft(), r2.bottomRight());
|
|---|
| 1029 | painter->drawLine(r2.bottomLeft(), r2.topLeft());
|
|---|
| 1030 | if (d->doubleControls) {
|
|---|
| 1031 | QRect r3 = r2.adjusted(1, 1, -1, -1);
|
|---|
| 1032 | painter->drawLine(r3.topLeft(), r3.topRight());
|
|---|
| 1033 | painter->drawLine(r3.topRight(), r3.bottomRight());
|
|---|
| 1034 | painter->drawLine(r3.bottomLeft(), r3.bottomRight());
|
|---|
| 1035 | painter->drawLine(r3.bottomLeft(), r3.topLeft());
|
|---|
| 1036 | }
|
|---|
| 1037 | painter->setPen(option->palette.shadow().color());
|
|---|
| 1038 | }
|
|---|
| 1039 | //fall through...
|
|---|
| 1040 | }
|
|---|
| 1041 | case PE_IndicatorViewItemCheck:
|
|---|
| 1042 | case PE_Q3CheckListIndicator: {
|
|---|
| 1043 | if (!doRestore) {
|
|---|
| 1044 | painter->save();
|
|---|
| 1045 | doRestore = true;
|
|---|
| 1046 | }
|
|---|
| 1047 | if (element == PE_Q3CheckListIndicator || element == PE_IndicatorViewItemCheck) {
|
|---|
| 1048 | painter->setPen(option->palette.shadow().color());
|
|---|
| 1049 | if (option->state & State_NoChange)
|
|---|
| 1050 | painter->setBrush(option->palette.brush(QPalette::Button));
|
|---|
| 1051 | if (d->doubleControls) {
|
|---|
| 1052 | QRect r = QRect(option->rect.x(), option->rect.y(), windowsMobileitemViewCheckBoxSize * 2, windowsMobileitemViewCheckBoxSize * 2);
|
|---|
| 1053 | qDrawPlainRect(painter, r, option->palette.shadow().color(), 2);
|
|---|
| 1054 | } else {
|
|---|
| 1055 | QRect r = QRect(option->rect.x(), option->rect.y(), windowsMobileitemViewCheckBoxSize, windowsMobileitemViewCheckBoxSize);
|
|---|
| 1056 | qDrawPlainRect(painter, r, option->palette.shadow().color(), 1);
|
|---|
| 1057 | }
|
|---|
| 1058 | if (option->state & State_Enabled)
|
|---|
| 1059 | d->imageChecked.setColor(1, option->palette.shadow().color().rgba());
|
|---|
| 1060 | else
|
|---|
| 1061 | d->imageChecked.setColor(1, option->palette.dark().color().rgba());
|
|---|
| 1062 | if (!(option->state & State_Off)) {
|
|---|
| 1063 | if (d->doubleControls)
|
|---|
| 1064 | painter->drawImage(option->rect.x(), option->rect.y(), d->imageChecked);
|
|---|
| 1065 | else
|
|---|
| 1066 | painter->drawImage(option->rect.x() + 3, option->rect.y() + 3, d->imageChecked);
|
|---|
| 1067 | }
|
|---|
| 1068 | }
|
|---|
| 1069 | else {
|
|---|
| 1070 | if (option->state & State_NoChange)
|
|---|
| 1071 | d->imageCheckedBold.setColor(1, option->palette.dark().color().rgba());
|
|---|
| 1072 | else if (option->state & State_Enabled)
|
|---|
| 1073 | d->imageCheckedBold.setColor(1, option->palette.shadow().color().rgba());
|
|---|
| 1074 | else
|
|---|
| 1075 | d->imageCheckedBold.setColor(1, option->palette.dark().color().rgba());
|
|---|
| 1076 | if (!(option->state & State_Off)) {
|
|---|
| 1077 | if (d->doubleControls)
|
|---|
| 1078 | painter->drawImage(option->rect.x() + 2, option->rect.y(), d->imageCheckedBold);
|
|---|
| 1079 | else
|
|---|
| 1080 | painter->drawImage(option->rect.x() + 3, option->rect.y() + 3, d->imageCheckedBold);
|
|---|
| 1081 | }
|
|---|
| 1082 | }
|
|---|
| 1083 | if (doRestore)
|
|---|
| 1084 | painter->restore();
|
|---|
| 1085 | break; }
|
|---|
| 1086 | case PE_IndicatorRadioButton: {
|
|---|
| 1087 | painter->save();
|
|---|
| 1088 |
|
|---|
| 1089 | if (option->state & State_HasFocus) {
|
|---|
| 1090 | d->imageRadioButtonHighlighted.setColor(1, option->palette.shadow().color().rgba());
|
|---|
| 1091 | d->imageRadioButtonHighlighted.setColor(2, option->palette.highlight().color().rgba());
|
|---|
| 1092 | painter->drawImage(option->rect.x(), option->rect.y(), d->imageRadioButtonHighlighted);
|
|---|
| 1093 | }
|
|---|
| 1094 | else {
|
|---|
| 1095 | d->imageRadioButton.setColor(1, option->palette.shadow().color().rgba());
|
|---|
| 1096 | painter->drawImage(option->rect.x(), option->rect.y(), d->imageRadioButton);
|
|---|
| 1097 | }
|
|---|
| 1098 | if (option->state & (State_Sunken | State_On)) {
|
|---|
| 1099 | if (option->state & State_Enabled)
|
|---|
| 1100 | d->imageRadioButtonChecked.setColor(1, option->palette.shadow().color().rgba());
|
|---|
| 1101 | else
|
|---|
| 1102 | d->imageRadioButtonChecked.setColor(1, option->palette.dark().color().rgba());
|
|---|
| 1103 |
|
|---|
| 1104 | static const int offset = d->doubleControls ? 6 : 3;
|
|---|
| 1105 | painter->drawImage(option->rect.x() + offset, option->rect.y() + offset, d->imageRadioButtonChecked);
|
|---|
| 1106 | }
|
|---|
| 1107 | painter->restore();
|
|---|
| 1108 | break; }
|
|---|
| 1109 | case PE_PanelButtonCommand:
|
|---|
| 1110 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 1111 | QBrush fill;
|
|---|
| 1112 | State flags = option->state;
|
|---|
| 1113 | QPalette pal = option->palette;
|
|---|
| 1114 | QRect r = option->rect;
|
|---|
| 1115 | if ((flags & State_Sunken || flags & State_On) )
|
|---|
| 1116 | fill = pal.brush(QPalette::Shadow);
|
|---|
| 1117 | else
|
|---|
| 1118 | fill = pal.brush(QPalette::Button);
|
|---|
| 1119 | int singleLine = 1;
|
|---|
| 1120 | int doubleLine = 2;
|
|---|
| 1121 | if (d->doubleControls) {
|
|---|
| 1122 | singleLine = 2;
|
|---|
| 1123 | doubleLine = 4;
|
|---|
| 1124 | }
|
|---|
| 1125 | if (button->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
|
|---|
| 1126 | if (d->doubleControls) {
|
|---|
| 1127 | qDrawPlainRect(painter, r, pal.shadow().color(), 1, &fill);
|
|---|
| 1128 | qDrawPlainRect(painter, r.adjusted(1, 1, -1, 1), pal.shadow().color(), 1, &fill);
|
|---|
| 1129 | }
|
|---|
| 1130 | else {
|
|---|
| 1131 | qDrawPlainRect(painter, r, pal.shadow().color(), 1, &fill);
|
|---|
| 1132 | }
|
|---|
| 1133 | } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
|
|---|
| 1134 | qDrawPlainRect(painter, r, pal.shadow().color(), singleLine, &fill);
|
|---|
| 1135 | } else {
|
|---|
| 1136 | painter->fillRect(r, fill);
|
|---|
| 1137 | }
|
|---|
| 1138 | }
|
|---|
| 1139 | break;
|
|---|
| 1140 | case PE_FrameDefaultButton: {
|
|---|
| 1141 | painter->save();
|
|---|
| 1142 | painter->setPen(option->palette.shadow().color());
|
|---|
| 1143 | QRect rect = option->rect;
|
|---|
| 1144 | if (d->doubleControls) {
|
|---|
| 1145 | rect.adjust(1, 1, -2, -2);
|
|---|
| 1146 | painter->drawRect(rect);
|
|---|
| 1147 | painter->drawRect(rect.adjusted(1, 1, -1, -1));
|
|---|
| 1148 | }
|
|---|
| 1149 |
|
|---|
| 1150 | else {
|
|---|
| 1151 | rect.adjust(2, 2, -3, -3);
|
|---|
| 1152 | painter->drawRect(rect);
|
|---|
| 1153 | }
|
|---|
| 1154 | painter->restore();
|
|---|
| 1155 | break; }
|
|---|
| 1156 | case PE_IndicatorSpinPlus:
|
|---|
| 1157 | case PE_IndicatorSpinMinus: {
|
|---|
| 1158 | QRect r = option->rect;
|
|---|
| 1159 | int fw = pixelMetric(PM_DefaultFrameWidth, option, widget)+2;
|
|---|
| 1160 | QRect br = r.adjusted(fw, fw, -fw, -fw);
|
|---|
| 1161 | int offset = (option->state & State_Sunken) ? 1 : 0;
|
|---|
| 1162 | int step = (br.width() + 4) / 5;
|
|---|
| 1163 | painter->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,
|
|---|
| 1164 | br.width(), step, option->palette.buttonText());
|
|---|
| 1165 | if (element == PE_IndicatorSpinPlus)
|
|---|
| 1166 | painter->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset+4,
|
|---|
| 1167 | step, br.height() - 7, option->palette.buttonText());
|
|---|
| 1168 | break; }
|
|---|
| 1169 | case PE_IndicatorSpinUp:
|
|---|
| 1170 | case PE_IndicatorSpinDown: {
|
|---|
| 1171 | painter->save();
|
|---|
| 1172 | QPoint points[7];
|
|---|
| 1173 | switch (element) {
|
|---|
| 1174 | case PE_IndicatorSpinUp:
|
|---|
| 1175 | points[0] = QPoint(-2, -4);
|
|---|
| 1176 | points[1] = QPoint(-2, 2);
|
|---|
| 1177 | points[2] = QPoint(-1, -3);
|
|---|
| 1178 | points[3] = QPoint(-1, 1);
|
|---|
| 1179 | points[4] = QPoint(0, -2);
|
|---|
| 1180 | points[5] = QPoint(0, 0);
|
|---|
| 1181 | points[6] = QPoint(1, -1);
|
|---|
| 1182 | break;
|
|---|
| 1183 | case PE_IndicatorSpinDown:
|
|---|
| 1184 | points[0] = QPoint(0, -4);
|
|---|
| 1185 | points[1] = QPoint(0, 2);
|
|---|
| 1186 | points[2] = QPoint(-1, -3);
|
|---|
| 1187 | points[3] = QPoint(-1, 1);
|
|---|
| 1188 | points[4] = QPoint(-2, -2);
|
|---|
| 1189 | points[5] = QPoint(-2, 0);
|
|---|
| 1190 | points[6] = QPoint(-3, -1);
|
|---|
| 1191 | break;
|
|---|
| 1192 | default:
|
|---|
| 1193 | break;
|
|---|
| 1194 | }
|
|---|
| 1195 | if (option->state & State_Sunken)
|
|---|
| 1196 | painter->translate(pixelMetric(PM_ButtonShiftHorizontal),
|
|---|
| 1197 | pixelMetric(PM_ButtonShiftVertical));
|
|---|
| 1198 | if (option->state & State_Enabled) {
|
|---|
| 1199 | painter->translate(option->rect.x() + option->rect.width() / 2,
|
|---|
| 1200 | option->rect.y() + option->rect.height() / 2);
|
|---|
| 1201 | painter->setPen(option->palette.buttonText().color());
|
|---|
| 1202 | painter->drawLine(points[0], points[1]);
|
|---|
| 1203 | painter->drawLine(points[2], points[3]);
|
|---|
| 1204 | painter->drawLine(points[4], points[5]);
|
|---|
| 1205 | painter->drawPoint(points[6]);
|
|---|
| 1206 | } else {
|
|---|
| 1207 | painter->translate(option->rect.x() + option->rect.width() / 2 + 1,
|
|---|
| 1208 | option->rect.y() + option->rect.height() / 2 + 1);
|
|---|
| 1209 | painter->setPen(option->palette.light().color());
|
|---|
| 1210 | painter->drawLine(points[0], points[1]);
|
|---|
| 1211 | painter->drawLine(points[2], points[3]);
|
|---|
| 1212 | painter->drawLine(points[4], points[5]);
|
|---|
| 1213 | painter->drawPoint(points[6]);
|
|---|
| 1214 | painter->translate(-1, -1);
|
|---|
| 1215 | painter->setPen(option->palette.mid().color());
|
|---|
| 1216 | painter->drawLine(points[0], points[1]);
|
|---|
| 1217 | painter->drawLine(points[2], points[3]);
|
|---|
| 1218 | painter->drawLine(points[4], points[5]);
|
|---|
| 1219 | painter->drawPoint(points[6]);
|
|---|
| 1220 | }
|
|---|
| 1221 | painter->restore();
|
|---|
| 1222 | break; }
|
|---|
| 1223 |
|
|---|
| 1224 | case PE_IndicatorArrowUpBig:
|
|---|
| 1225 | case PE_IndicatorArrowDownBig:
|
|---|
| 1226 | case PE_IndicatorArrowLeftBig:
|
|---|
| 1227 | case PE_IndicatorArrowRightBig:
|
|---|
| 1228 |
|
|---|
| 1229 | case PE_IndicatorArrowUp:
|
|---|
| 1230 | case PE_IndicatorArrowDown:
|
|---|
| 1231 | case PE_IndicatorArrowRight:
|
|---|
| 1232 | case PE_IndicatorArrowLeft: {
|
|---|
| 1233 | painter->save();
|
|---|
| 1234 |
|
|---|
| 1235 | if (d->doubleControls) {
|
|---|
| 1236 | QColor color;
|
|---|
| 1237 | if (option->state & State_Sunken)
|
|---|
| 1238 | color = option->palette.light().color();
|
|---|
| 1239 | else
|
|---|
| 1240 | color = option->palette.buttonText().color();
|
|---|
| 1241 | QImage image;
|
|---|
| 1242 | int xoffset, yoffset;
|
|---|
| 1243 | switch (element) {
|
|---|
| 1244 | case PE_IndicatorArrowUp:
|
|---|
| 1245 | image = d->imageArrowUp;
|
|---|
| 1246 | xoffset = 1;
|
|---|
| 1247 | yoffset = 12;
|
|---|
| 1248 | break;
|
|---|
| 1249 | case PE_IndicatorArrowDown:
|
|---|
| 1250 | image = d->imageArrowDown;
|
|---|
| 1251 | xoffset = 1;
|
|---|
| 1252 | yoffset =12;
|
|---|
| 1253 | break;
|
|---|
| 1254 | case PE_IndicatorArrowLeft:
|
|---|
| 1255 | image = d->imageArrowLeft;
|
|---|
| 1256 | xoffset = 8;
|
|---|
| 1257 | yoffset = 2;
|
|---|
| 1258 | break;
|
|---|
| 1259 | case PE_IndicatorArrowRight:
|
|---|
| 1260 | image = d->imageArrowRight;
|
|---|
| 1261 | xoffset = 8;
|
|---|
| 1262 | yoffset = 2;
|
|---|
| 1263 | break;
|
|---|
| 1264 | case PE_IndicatorArrowUpBig:
|
|---|
| 1265 | image = d->imageArrowUpBig;
|
|---|
| 1266 | xoffset = 3;
|
|---|
| 1267 | yoffset = 12;
|
|---|
| 1268 | break;
|
|---|
| 1269 | case PE_IndicatorArrowDownBig:
|
|---|
| 1270 | image = d->imageArrowDownBig;
|
|---|
| 1271 | xoffset = 2;
|
|---|
| 1272 | yoffset =12;
|
|---|
| 1273 | break;
|
|---|
| 1274 | case PE_IndicatorArrowLeftBig:
|
|---|
| 1275 | image = d->imageArrowLeftBig;
|
|---|
| 1276 | xoffset = 8;
|
|---|
| 1277 | yoffset = 2;
|
|---|
| 1278 | break;
|
|---|
| 1279 | case PE_IndicatorArrowRightBig:
|
|---|
| 1280 | image = d->imageArrowRightBig;
|
|---|
| 1281 | xoffset = 8;
|
|---|
| 1282 | yoffset = 2;
|
|---|
| 1283 | break;
|
|---|
| 1284 | default:
|
|---|
| 1285 | break;
|
|---|
| 1286 | }
|
|---|
| 1287 | image.setColor(1, color.rgba());
|
|---|
| 1288 | painter->drawImage(option->rect.x() + xoffset, option->rect.y() + yoffset, image);
|
|---|
| 1289 | }
|
|---|
| 1290 | else {
|
|---|
| 1291 | QPoint points[7];
|
|---|
| 1292 | switch (element) {
|
|---|
| 1293 | case PE_IndicatorArrowUp:
|
|---|
| 1294 | case PE_IndicatorArrowUpBig:
|
|---|
| 1295 | points[0] = QPoint(-3, 1);
|
|---|
| 1296 | points[1] = QPoint(3, 1);
|
|---|
| 1297 | points[2] = QPoint(-2, 0);
|
|---|
| 1298 | points[3] = QPoint(2, 0);
|
|---|
| 1299 | points[4] = QPoint(-1, -1);
|
|---|
| 1300 | points[5] = QPoint(1, -1);
|
|---|
| 1301 | points[6] = QPoint(0, -2);
|
|---|
| 1302 | break;
|
|---|
| 1303 | case PE_IndicatorArrowDown:
|
|---|
| 1304 | case PE_IndicatorArrowDownBig:
|
|---|
| 1305 | points[0] = QPoint(-3, -1);
|
|---|
| 1306 | points[1] = QPoint(3, -1);
|
|---|
| 1307 | points[2] = QPoint(-2, 0);
|
|---|
| 1308 | points[3] = QPoint(2, 0);
|
|---|
| 1309 | points[4] = QPoint(-1, 1);
|
|---|
| 1310 | points[5] = QPoint(1, 1);
|
|---|
| 1311 | points[6] = QPoint(0, 2);
|
|---|
| 1312 | break;
|
|---|
| 1313 | case PE_IndicatorArrowRight:
|
|---|
| 1314 | case PE_IndicatorArrowRightBig:
|
|---|
| 1315 | points[0] = QPoint(-2, -3);
|
|---|
| 1316 | points[1] = QPoint(-2, 3);
|
|---|
| 1317 | points[2] = QPoint(-1, -2);
|
|---|
| 1318 | points[3] = QPoint(-1, 2);
|
|---|
| 1319 | points[4] = QPoint(0, -1);
|
|---|
| 1320 | points[5] = QPoint(0, 1);
|
|---|
| 1321 | points[6] = QPoint(1, 0);
|
|---|
| 1322 | break;
|
|---|
| 1323 | case PE_IndicatorArrowLeft:
|
|---|
| 1324 | case PE_IndicatorArrowLeftBig:
|
|---|
| 1325 | points[0] = QPoint(0, -3);
|
|---|
| 1326 | points[1] = QPoint(0, 3);
|
|---|
| 1327 | points[2] = QPoint(-1, -2);
|
|---|
| 1328 | points[3] = QPoint(-1, 2);
|
|---|
| 1329 | points[4] = QPoint(-2, -1);
|
|---|
| 1330 | points[5] = QPoint(-2, 1);
|
|---|
| 1331 | points[6] = QPoint(-3, 0);
|
|---|
| 1332 | break;
|
|---|
| 1333 | default:
|
|---|
| 1334 | break;
|
|---|
| 1335 | }
|
|---|
| 1336 | if (option->state & State_Sunken)
|
|---|
| 1337 | painter->setPen(option->palette.light().color());
|
|---|
| 1338 | else
|
|---|
| 1339 | painter->setPen(option->palette.buttonText().color());
|
|---|
| 1340 | if (option->state & State_Enabled) {
|
|---|
| 1341 | painter->translate(option->rect.x() + option->rect.width() / 2,
|
|---|
| 1342 | option->rect.y() + option->rect.height() / 2 - 1);
|
|---|
| 1343 | painter->drawLine(points[0], points[1]);
|
|---|
| 1344 | painter->drawLine(points[2], points[3]);
|
|---|
| 1345 | painter->drawLine(points[4], points[5]);
|
|---|
| 1346 | painter->drawPoint(points[6]);
|
|---|
| 1347 | } else {
|
|---|
| 1348 | painter->translate(option->rect.x() + option->rect.width() / 2,
|
|---|
| 1349 | option->rect.y() + option->rect.height() / 2 - 1);
|
|---|
| 1350 | painter->setPen(option->palette.mid().color());
|
|---|
| 1351 | painter->drawLine(points[0], points[1]);
|
|---|
| 1352 | painter->drawLine(points[2], points[3]);
|
|---|
| 1353 | painter->drawLine(points[4], points[5]);
|
|---|
| 1354 | painter->drawPoint(points[6]);
|
|---|
| 1355 | }
|
|---|
| 1356 | }
|
|---|
| 1357 | painter->restore();
|
|---|
| 1358 | break; }
|
|---|
| 1359 | #ifndef QT_NO_TABWIDGET
|
|---|
| 1360 | case PE_FrameTabWidget:
|
|---|
| 1361 | if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
|
|---|
| 1362 | QRect rect = option->rect;
|
|---|
| 1363 | QPalette pal = option->palette;
|
|---|
| 1364 | painter->save();
|
|---|
| 1365 | QBrush fill = pal.light();
|
|---|
| 1366 | painter->fillRect(rect, fill);
|
|---|
| 1367 | painter->setPen(pal.shadow().color());
|
|---|
| 1368 | if (d->doubleControls) {
|
|---|
| 1369 | QPen pen = painter->pen();
|
|---|
| 1370 | pen.setWidth(2);
|
|---|
| 1371 | pen.setCapStyle(Qt::FlatCap);
|
|---|
| 1372 | painter->setPen(pen);
|
|---|
| 1373 | }
|
|---|
| 1374 | switch (tab->shape) {
|
|---|
| 1375 | case QTabBar::RoundedNorth:
|
|---|
| 1376 | if (d->doubleControls)
|
|---|
| 1377 | painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
|
|---|
| 1378 | else
|
|---|
| 1379 | painter->drawLine(rect.topLeft(), rect.topRight());
|
|---|
| 1380 | break;
|
|---|
| 1381 | case QTabBar::RoundedSouth:
|
|---|
| 1382 | if (d->doubleControls)
|
|---|
| 1383 | painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
|---|
| 1384 | else
|
|---|
| 1385 | painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
|---|
| 1386 | break;
|
|---|
| 1387 | case QTabBar::RoundedEast:
|
|---|
| 1388 | painter->drawLine(rect.topRight(), rect.bottomRight());
|
|---|
| 1389 | break;
|
|---|
| 1390 | case QTabBar::RoundedWest:
|
|---|
| 1391 | painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
|---|
| 1392 | break;
|
|---|
| 1393 | case QTabBar::TriangularWest:
|
|---|
| 1394 | case QTabBar::TriangularEast:
|
|---|
| 1395 | case QTabBar::TriangularSouth:
|
|---|
| 1396 | case QTabBar::TriangularNorth:
|
|---|
| 1397 | if (d->doubleControls)
|
|---|
| 1398 | qDrawPlainRect(painter, rect.adjusted(0,-2,0,0), option->palette.shadow().color(),2,&pal.light());
|
|---|
| 1399 | else
|
|---|
| 1400 | qDrawPlainRect(painter, rect, option->palette.shadow().color(),1,&pal.light());
|
|---|
| 1401 | break;
|
|---|
| 1402 | default:
|
|---|
| 1403 | break;
|
|---|
| 1404 | }
|
|---|
| 1405 | painter->restore();
|
|---|
| 1406 | }
|
|---|
| 1407 | break;
|
|---|
| 1408 | #endif //QT_NO_TABBAR
|
|---|
| 1409 |
|
|---|
| 1410 | case PE_FrameWindow: {
|
|---|
| 1411 | QPalette popupPal = option->palette;
|
|---|
| 1412 | popupPal.setColor(QPalette::Light, option->palette.background().color());
|
|---|
| 1413 | popupPal.setColor(QPalette::Midlight, option->palette.light().color());
|
|---|
| 1414 | if (d->doubleControls)
|
|---|
| 1415 | qDrawPlainRect(painter, option->rect, popupPal.shadow().color(),2,0);
|
|---|
| 1416 | else
|
|---|
| 1417 | qDrawPlainRect(painter, option->rect, popupPal.shadow().color(),1,0);
|
|---|
| 1418 | break; }
|
|---|
| 1419 | case PE_FrameTabBarBase: {
|
|---|
| 1420 | break; }
|
|---|
| 1421 | case PE_Widget:
|
|---|
| 1422 | break;
|
|---|
| 1423 | case PE_IndicatorMenuCheckMark: {
|
|---|
| 1424 | int markW = option->rect.width() > 7 ? 7 : option->rect.width();
|
|---|
| 1425 | int markH = markW;
|
|---|
| 1426 | if (d->doubleControls)
|
|---|
| 1427 | markW*=2;
|
|---|
| 1428 | markH*=2;
|
|---|
| 1429 | int posX = option->rect.x() + (option->rect.width() - markW)/2 + 1;
|
|---|
| 1430 | int posY = option->rect.y() + (option->rect.height() - markH)/2;
|
|---|
| 1431 |
|
|---|
| 1432 | QVector<QLineF> a;
|
|---|
| 1433 | a.reserve(markH);
|
|---|
| 1434 |
|
|---|
| 1435 | int i, xx, yy;
|
|---|
| 1436 | xx = posX;
|
|---|
| 1437 | yy = 3 + posY;
|
|---|
| 1438 | for (i = 0; i < markW/2; ++i) {
|
|---|
| 1439 | a << QLineF(xx, yy, xx, yy + 2);
|
|---|
| 1440 | ++xx;
|
|---|
| 1441 | ++yy;
|
|---|
| 1442 | }
|
|---|
| 1443 | yy -= 2;
|
|---|
| 1444 | for (; i < markH; ++i) {
|
|---|
| 1445 | a << QLineF(xx, yy, xx, yy + 2);
|
|---|
| 1446 | ++xx;
|
|---|
| 1447 | --yy;
|
|---|
| 1448 | }
|
|---|
| 1449 | if (!(option->state & State_Enabled) && !(option->state & State_On)) {
|
|---|
| 1450 | int pnt;
|
|---|
| 1451 | painter->setPen(option->palette.highlightedText().color());
|
|---|
| 1452 | QPoint offset(1, 1);
|
|---|
| 1453 | for (pnt = 0; pnt < a.size(); ++pnt)
|
|---|
| 1454 | a[pnt].translate(offset.x(), offset.y());
|
|---|
| 1455 | painter->drawLines(a);
|
|---|
| 1456 | for (pnt = 0; pnt < a.size(); ++pnt)
|
|---|
| 1457 | a[pnt].translate(offset.x(), offset.y());
|
|---|
| 1458 | }
|
|---|
| 1459 | painter->setPen(option->palette.text().color());
|
|---|
| 1460 | painter->drawLines(a);
|
|---|
| 1461 | break; }
|
|---|
| 1462 | case PE_Frame:
|
|---|
| 1463 | if (d->doubleControls)
|
|---|
| 1464 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2,&option->palette.light());
|
|---|
| 1465 | else
|
|---|
| 1466 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1,&option->palette.light());
|
|---|
| 1467 | break;
|
|---|
| 1468 | case PE_FrameLineEdit:
|
|---|
| 1469 | case PE_FrameMenu:
|
|---|
| 1470 | if (d->doubleControls)
|
|---|
| 1471 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2);
|
|---|
| 1472 | else
|
|---|
| 1473 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1);
|
|---|
| 1474 | break;
|
|---|
| 1475 | case PE_FrameStatusBar:
|
|---|
| 1476 | if (d->doubleControls)
|
|---|
| 1477 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2,0);
|
|---|
| 1478 | else
|
|---|
| 1479 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1,0);
|
|---|
| 1480 | break;
|
|---|
| 1481 |
|
|---|
| 1482 | default:
|
|---|
| 1483 | QWindowsStyle::drawPrimitive(element, option, painter, widget);
|
|---|
| 1484 | break;
|
|---|
| 1485 | }
|
|---|
| 1486 | }
|
|---|
| 1487 |
|
|---|
| 1488 | void QWindowsMobileStyle::drawControl(ControlElement element, const QStyleOption *option,
|
|---|
| 1489 | QPainter *painter, const QWidget *widget) const {
|
|---|
| 1490 |
|
|---|
| 1491 |
|
|---|
| 1492 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 1493 |
|
|---|
| 1494 |
|
|---|
| 1495 | painter->setClipping(false);
|
|---|
| 1496 | switch (element) {
|
|---|
| 1497 | case CE_MenuBarEmptyArea:
|
|---|
| 1498 | painter->setClipping(true);
|
|---|
| 1499 | QWindowsStyle::drawControl(element, option, painter, widget);
|
|---|
| 1500 | break;
|
|---|
| 1501 | case CE_PushButtonBevel:
|
|---|
| 1502 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 1503 | QRect br = button->rect;
|
|---|
| 1504 | int dbi = pixelMetric(PM_ButtonDefaultIndicator, button, widget);
|
|---|
| 1505 |
|
|---|
| 1506 | if (button->features & QStyleOptionButton::AutoDefaultButton)
|
|---|
| 1507 | br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi);
|
|---|
| 1508 | QStyleOptionButton tmpBtn = *button;
|
|---|
| 1509 | tmpBtn.rect = br;
|
|---|
| 1510 | drawPrimitive(PE_PanelButtonCommand, &tmpBtn, painter, widget);
|
|---|
| 1511 | if (button->features & QStyleOptionButton::HasMenu) {
|
|---|
| 1512 | int mbi = pixelMetric(PM_MenuButtonIndicator, button, widget);
|
|---|
| 1513 | QRect ir = button->rect;
|
|---|
| 1514 | QStyleOptionButton newButton = *button;
|
|---|
| 1515 | if (d->doubleControls)
|
|---|
| 1516 | newButton.rect = QRect(ir.right() - mbi, ir.height() - 30, mbi, ir.height() - 4);
|
|---|
| 1517 | else
|
|---|
| 1518 | newButton.rect = QRect(ir.right() - mbi, ir.height() - 20, mbi, ir.height() - 4);
|
|---|
| 1519 | drawPrimitive(PE_IndicatorArrowDown, &newButton, painter, widget);
|
|---|
| 1520 | }
|
|---|
| 1521 | if (button->features & QStyleOptionButton::DefaultButton)
|
|---|
| 1522 | drawPrimitive(PE_FrameDefaultButton, option, painter, widget);
|
|---|
| 1523 | }
|
|---|
| 1524 | break;
|
|---|
| 1525 | case CE_RadioButton:
|
|---|
| 1526 | case CE_CheckBox:
|
|---|
| 1527 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 1528 | bool isRadio = (element == CE_RadioButton);
|
|---|
| 1529 | QStyleOptionButton subopt = *button;
|
|---|
| 1530 | subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
|
|---|
| 1531 | : SE_CheckBoxIndicator, button, widget);
|
|---|
| 1532 | drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
|
|---|
| 1533 | &subopt, painter, widget);
|
|---|
| 1534 | subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
|
|---|
| 1535 | : SE_CheckBoxContents, button, widget);
|
|---|
| 1536 | drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
|
|---|
| 1537 | if (button->state & State_HasFocus) {
|
|---|
| 1538 | QStyleOptionFocusRect fropt;
|
|---|
| 1539 | fropt.QStyleOption::operator=(*button);
|
|---|
| 1540 | fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
|
|---|
| 1541 | : SE_CheckBoxFocusRect, button, widget);
|
|---|
| 1542 | drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
|
|---|
| 1543 | }
|
|---|
| 1544 | }
|
|---|
| 1545 | break;
|
|---|
| 1546 | case CE_RadioButtonLabel:
|
|---|
| 1547 | case CE_CheckBoxLabel:
|
|---|
| 1548 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 1549 | uint alignment = visualAlignment(button->direction, Qt::AlignLeft | Qt::AlignVCenter);
|
|---|
| 1550 | if (!styleHint(SH_UnderlineShortcut, button, widget))
|
|---|
| 1551 | alignment |= Qt::TextHideMnemonic;
|
|---|
| 1552 | QPixmap pix;
|
|---|
| 1553 | QRect textRect = button->rect;
|
|---|
| 1554 | if (!button->icon.isNull()) {
|
|---|
| 1555 | pix = button->icon.pixmap(button->iconSize, button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
|
|---|
| 1556 | drawItemPixmap(painter, button->rect, alignment, pix);
|
|---|
| 1557 | if (button->direction == Qt::RightToLeft)
|
|---|
| 1558 | textRect.setRight(textRect.right() - button->iconSize.width() - 4);
|
|---|
| 1559 | else
|
|---|
| 1560 | textRect.setLeft(textRect.left() + button->iconSize.width() + 4);
|
|---|
| 1561 | }
|
|---|
| 1562 | if (!button->text.isEmpty()){
|
|---|
| 1563 | if (button->state & State_Enabled)
|
|---|
| 1564 | drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic,
|
|---|
| 1565 | button->palette, false, button->text, QPalette::WindowText);
|
|---|
| 1566 | else
|
|---|
| 1567 | drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic,
|
|---|
| 1568 | button->palette, false, button->text, QPalette::Mid);
|
|---|
| 1569 | }
|
|---|
| 1570 | }
|
|---|
| 1571 | break;
|
|---|
| 1572 | #ifndef QT_NO_PROGRESSBAR
|
|---|
| 1573 | case CE_ProgressBarGroove:
|
|---|
| 1574 | if (d->doubleControls)
|
|---|
| 1575 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 2, &option->palette.brush(QPalette::Window));
|
|---|
| 1576 | else
|
|---|
| 1577 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 1, &option->palette.brush(QPalette::Window));
|
|---|
| 1578 | break;
|
|---|
| 1579 | #endif //QT_NO_PROGRESSBAR
|
|---|
| 1580 | #ifndef QT_NO_TABBAR
|
|---|
| 1581 | case CE_TabBarTab:
|
|---|
| 1582 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
|---|
| 1583 | drawControl(CE_TabBarTabShape, tab, painter, widget);
|
|---|
| 1584 | drawControl(CE_TabBarTabLabel, tab, painter, widget);
|
|---|
| 1585 | }
|
|---|
| 1586 | break;
|
|---|
| 1587 | case CE_TabBarTabShape:
|
|---|
| 1588 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
|
|---|
| 1589 | if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
|
|---|
| 1590 | tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
|
|---|
| 1591 |
|
|---|
| 1592 | painter->save();
|
|---|
| 1593 | painter->setPen(tab->palette.shadow().color());
|
|---|
| 1594 | if (d->doubleControls) {
|
|---|
| 1595 | QPen pen = painter->pen();
|
|---|
| 1596 | pen.setWidth(2);
|
|---|
| 1597 | pen.setCapStyle(Qt::FlatCap);
|
|---|
| 1598 | painter->setPen(pen);
|
|---|
| 1599 | }
|
|---|
| 1600 | if(tab->shape == QTabBar::RoundedNorth) {
|
|---|
| 1601 | if (tab->state & State_Selected) {
|
|---|
| 1602 | painter->fillRect(tab->rect, tab->palette.light());
|
|---|
| 1603 | painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
|
|---|
| 1604 | }
|
|---|
| 1605 | else {
|
|---|
| 1606 | painter->fillRect(tab->rect, tab->palette.button());
|
|---|
| 1607 | painter->drawLine(tab->rect.bottomLeft() , tab->rect.bottomRight());
|
|---|
| 1608 | painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
|
|---|
| 1609 | }
|
|---|
| 1610 | }
|
|---|
| 1611 | else if(tab->shape == QTabBar::RoundedSouth) {
|
|---|
| 1612 |
|
|---|
| 1613 | if (tab->state & State_Selected) {
|
|---|
| 1614 | painter->fillRect(tab->rect.adjusted(0,-2,0,0), tab->palette.light());
|
|---|
| 1615 | painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
|
|---|
| 1616 | }
|
|---|
| 1617 | else {
|
|---|
| 1618 | painter->fillRect(tab->rect, tab->palette.button());
|
|---|
| 1619 | if (d->doubleControls)
|
|---|
| 1620 | painter->drawLine(tab->rect.topLeft() + QPoint(0,1), tab->rect.topRight() + QPoint(0,1));
|
|---|
| 1621 | else
|
|---|
| 1622 | painter->drawLine(tab->rect.topLeft(), tab->rect.topRight());
|
|---|
| 1623 | painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
|
|---|
| 1624 | }
|
|---|
| 1625 | }
|
|---|
| 1626 | else if(tab->shape == QTabBar::RoundedEast) {
|
|---|
| 1627 | if (tab->state & State_Selected) {
|
|---|
| 1628 | painter->fillRect(tab->rect, tab->palette.light());
|
|---|
| 1629 | painter->drawLine(tab->rect.topLeft(), tab->rect.topRight());
|
|---|
| 1630 | }
|
|---|
| 1631 | else {
|
|---|
| 1632 | painter->fillRect(tab->rect, tab->palette.button());
|
|---|
| 1633 | painter->drawLine(tab->rect.topLeft(), tab->rect.bottomLeft());
|
|---|
| 1634 | painter->drawLine(tab->rect.topLeft(), tab->rect.topRight());
|
|---|
| 1635 | }
|
|---|
| 1636 | }
|
|---|
| 1637 | else if(tab->shape == QTabBar::RoundedWest) {
|
|---|
| 1638 | if (tab->state & State_Selected) {
|
|---|
| 1639 | painter->fillRect(tab->rect, tab->palette.light());
|
|---|
| 1640 | painter->drawLine(tab->rect.bottomLeft(), tab->rect.bottomRight());
|
|---|
| 1641 | }
|
|---|
| 1642 | else {
|
|---|
| 1643 | painter->fillRect(tab->rect, tab->palette.button());
|
|---|
| 1644 | painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
|
|---|
| 1645 | painter->drawLine(tab->rect.bottomLeft(), tab->rect.bottomRight());
|
|---|
| 1646 | }
|
|---|
| 1647 | }
|
|---|
| 1648 |
|
|---|
| 1649 | painter->restore();
|
|---|
| 1650 | } else {
|
|---|
| 1651 | QCommonStyle::drawControl(element, option, painter, widget);
|
|---|
| 1652 | }
|
|---|
| 1653 | break; }
|
|---|
| 1654 |
|
|---|
| 1655 | #endif // QT_NO_TABBAR
|
|---|
| 1656 |
|
|---|
| 1657 | #ifndef QT_NO_TOOLBAR
|
|---|
| 1658 | case CE_ToolBar:
|
|---|
| 1659 | if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
|
|---|
| 1660 | QRect rect = option->rect;
|
|---|
| 1661 | painter->save();
|
|---|
| 1662 | painter->setPen(option->palette.dark().color());
|
|---|
| 1663 | painter->fillRect(rect,option->palette.button());
|
|---|
| 1664 | if (d->doubleControls) {
|
|---|
| 1665 | QPen pen = painter->pen();
|
|---|
| 1666 | pen.setWidth(4);
|
|---|
| 1667 | painter->setPen(pen);
|
|---|
| 1668 | }
|
|---|
| 1669 | if (toolBar->toolBarArea == Qt::TopToolBarArea)
|
|---|
| 1670 | painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
|---|
| 1671 | else
|
|---|
| 1672 | painter->drawLine(rect.topLeft(), rect.topRight());
|
|---|
| 1673 | painter->restore();
|
|---|
| 1674 | break; }
|
|---|
| 1675 | #endif //QT_NO_TOOLBAR
|
|---|
| 1676 | case CE_Header:
|
|---|
| 1677 | if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
|---|
| 1678 | QRegion clipRegion = painter->clipRegion();
|
|---|
| 1679 | painter->setClipRect(option->rect);
|
|---|
| 1680 | drawControl(CE_HeaderSection, header, painter, widget);
|
|---|
| 1681 | QStyleOptionHeader subopt = *header;
|
|---|
| 1682 | subopt.rect = subElementRect(SE_HeaderLabel, header, widget);
|
|---|
| 1683 | if (header->state & State_Sunken)
|
|---|
| 1684 | subopt.palette.setColor(QPalette::ButtonText, header->palette.brightText().color());
|
|---|
| 1685 | subopt.state |= QStyle::State_On;
|
|---|
| 1686 | if (subopt.rect.isValid())
|
|---|
| 1687 | drawControl(CE_HeaderLabel, &subopt, painter, widget);
|
|---|
| 1688 | if (header->sortIndicator != QStyleOptionHeader::None) {
|
|---|
| 1689 | subopt.rect = subElementRect(SE_HeaderArrow, option, widget);
|
|---|
| 1690 | drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget);
|
|---|
| 1691 | }
|
|---|
| 1692 | painter->setClipRegion(clipRegion);
|
|---|
| 1693 | }
|
|---|
| 1694 | break;
|
|---|
| 1695 |
|
|---|
| 1696 | case CE_HeaderSection:
|
|---|
| 1697 | if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
|---|
| 1698 | QBrush fill;
|
|---|
| 1699 | QColor color;
|
|---|
| 1700 | QRect rect = option->rect;
|
|---|
| 1701 | painter->setPen(option->palette.shadow().color());
|
|---|
| 1702 |
|
|---|
| 1703 | int penSize = 1;
|
|---|
| 1704 |
|
|---|
| 1705 | if (d->doubleControls) {
|
|---|
| 1706 | penSize = 2;
|
|---|
| 1707 | QPen pen = painter->pen();
|
|---|
| 1708 | pen.setWidth(2);
|
|---|
| 1709 | pen.setCapStyle(Qt::FlatCap);
|
|---|
| 1710 | painter->setPen(pen);
|
|---|
| 1711 | }
|
|---|
| 1712 |
|
|---|
| 1713 | //fix Frame
|
|---|
| 1714 |
|
|---|
| 1715 | if (header->position == QStyleOptionHeader::End
|
|---|
| 1716 | || (header->position == QStyleOptionHeader::OnlyOneSection
|
|---|
| 1717 | && !header->text.isEmpty()))
|
|---|
| 1718 | if (Qt::Horizontal == header->orientation )
|
|---|
| 1719 | rect.adjust(0, 0, penSize, 0);
|
|---|
| 1720 | else
|
|---|
| 1721 | rect.adjust(0, 0, 0, penSize);
|
|---|
| 1722 |
|
|---|
| 1723 | if (option->state & State_Sunken) {
|
|---|
| 1724 | fill = option->palette.brush(QPalette::Shadow);
|
|---|
| 1725 | color = option->palette.light().color();
|
|---|
| 1726 | painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
|---|
| 1727 | painter->drawLine(rect.topRight(), rect.bottomRight());
|
|---|
| 1728 | rect.adjust(0, 0, -penSize, -penSize);
|
|---|
| 1729 | }
|
|---|
| 1730 | else {
|
|---|
| 1731 | fill = option->palette.brush(QPalette::Button);
|
|---|
| 1732 | color = option->palette.shadow().color();
|
|---|
| 1733 | if (Qt::Horizontal == header->orientation )
|
|---|
| 1734 | rect.adjust(-penSize, 0, 0, 0);
|
|---|
| 1735 | else
|
|---|
| 1736 | rect.adjust(0, -penSize, 0, 0);
|
|---|
| 1737 | }
|
|---|
| 1738 | if (Qt::Horizontal == header->orientation )
|
|---|
| 1739 | rect.adjust(0,-penSize,0,0);
|
|---|
| 1740 | else
|
|---|
| 1741 | rect.adjust(-penSize, 0, 0, 0);
|
|---|
| 1742 |
|
|---|
| 1743 | if (option->state & State_Sunken) {
|
|---|
| 1744 | qDrawPlainRect(painter, rect, color, penSize, &fill);
|
|---|
| 1745 | } else {
|
|---|
| 1746 | //Corner
|
|---|
| 1747 | rect.adjust(-penSize, 0, 0, 0);
|
|---|
| 1748 | qDrawPlainRect(painter, rect, color, penSize, &fill);
|
|---|
| 1749 | }
|
|---|
| 1750 |
|
|---|
| 1751 | //Hack to get rid of some double lines... StyleOptions need a clean flag for that
|
|---|
| 1752 | rect = option->rect;
|
|---|
| 1753 | #ifndef QT_NO_SCROLLAREA
|
|---|
| 1754 | if (const QAbstractScrollArea *abstractScrollArea = qobject_cast<const QAbstractScrollArea *> (widget) ) {
|
|---|
| 1755 | QRect rectScrollArea = abstractScrollArea->geometry();
|
|---|
| 1756 | if (Qt::Horizontal == header->orientation )
|
|---|
| 1757 | if ((rectScrollArea.right() - rect.right() ) > 1)
|
|---|
| 1758 | painter->drawLine(rect.topRight(), rect.bottomRight());
|
|---|
| 1759 | else ;
|
|---|
| 1760 | else
|
|---|
| 1761 | if ((rectScrollArea.bottom() - rect.bottom() ) > 1)
|
|---|
| 1762 | painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
|---|
| 1763 | }
|
|---|
| 1764 | #endif // QT_NO_SCROLLAREA
|
|---|
| 1765 | break; }
|
|---|
| 1766 |
|
|---|
| 1767 | #ifndef QT_NO_DOCKWIDGET
|
|---|
| 1768 | case CE_DockWidgetTitle:
|
|---|
| 1769 | if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
|
|---|
| 1770 | const QStyleOptionDockWidgetV2 *v2
|
|---|
| 1771 | = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(option);
|
|---|
| 1772 | bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
|
|---|
| 1773 |
|
|---|
| 1774 | QRect rect = dwOpt->rect;
|
|---|
| 1775 | QRect r = rect;
|
|---|
| 1776 |
|
|---|
| 1777 | if (verticalTitleBar) {
|
|---|
| 1778 | QSize s = r.size();
|
|---|
| 1779 | s.transpose();
|
|---|
| 1780 | r.setSize(s);
|
|---|
| 1781 |
|
|---|
| 1782 | painter->save();
|
|---|
| 1783 | painter->translate(r.left(), r.top() + r.width());
|
|---|
| 1784 | painter->rotate(-90);
|
|---|
| 1785 | painter->translate(-r.left(), -r.top());
|
|---|
| 1786 | }
|
|---|
| 1787 |
|
|---|
| 1788 | bool floating = false;
|
|---|
| 1789 | bool active = dwOpt->state & State_Active;
|
|---|
| 1790 | int menuOffset = 0; //used to center text when floated
|
|---|
| 1791 | QColor inactiveCaptionTextColor = option->palette.highlightedText().color();
|
|---|
| 1792 | if (dwOpt->movable) {
|
|---|
| 1793 | QColor left, right;
|
|---|
| 1794 |
|
|---|
| 1795 | //Titlebar gradient
|
|---|
| 1796 | if (widget && widget->isWindow()) {
|
|---|
| 1797 | floating = true;
|
|---|
| 1798 | if (active) {
|
|---|
| 1799 | right = option->palette.highlight().color();
|
|---|
| 1800 | left = right.lighter(125);
|
|---|
| 1801 | } else {
|
|---|
| 1802 | left = option->palette.highlight().color().lighter(125);
|
|---|
| 1803 | right = QColor(0xff, 0xff, 0xff);
|
|---|
| 1804 | }
|
|---|
| 1805 | menuOffset = 2;
|
|---|
| 1806 | QBrush fillBrush(left);
|
|---|
| 1807 | if (left != right) {
|
|---|
| 1808 | QPoint p1(r.x(), r.top() + r.height()/2);
|
|---|
| 1809 | QPoint p2(rect.right(), r.top() + r.height()/2);
|
|---|
| 1810 | QLinearGradient lg(p1, p2);
|
|---|
| 1811 | lg.setColorAt(0, left);
|
|---|
| 1812 | lg.setColorAt(1, right);
|
|---|
| 1813 | fillBrush = lg;
|
|---|
| 1814 | }
|
|---|
| 1815 | painter->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
|
|---|
| 1816 | } else {
|
|---|
| 1817 | painter->fillRect(r.adjusted(0, 0, 0, -3), option->palette.button().color());
|
|---|
| 1818 | }
|
|---|
| 1819 | painter->setPen(dwOpt->palette.color(QPalette::Light));
|
|---|
| 1820 | if (!widget || !widget->isWindow()) {
|
|---|
| 1821 | painter->drawLine(r.topLeft(), r.topRight());
|
|---|
| 1822 | painter->setPen(dwOpt->palette.color(QPalette::Dark));
|
|---|
| 1823 | painter->drawLine(r.bottomLeft(), r.bottomRight()); }
|
|---|
| 1824 | }
|
|---|
| 1825 | if (!dwOpt->title.isEmpty()) {
|
|---|
| 1826 | QFont oldFont = painter->font();
|
|---|
| 1827 | QFont newFont = oldFont;
|
|---|
| 1828 | if (newFont.pointSize() > 2)
|
|---|
| 1829 | newFont.setPointSize(newFont.pointSize() - 2);
|
|---|
| 1830 | if (floating)
|
|---|
| 1831 | newFont.setBold(true);
|
|---|
| 1832 | painter->setFont(newFont);
|
|---|
| 1833 | QPalette palette = dwOpt->palette;
|
|---|
| 1834 | palette.setColor(QPalette::Window, inactiveCaptionTextColor);
|
|---|
| 1835 | QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget);
|
|---|
| 1836 | if (verticalTitleBar) {
|
|---|
| 1837 | titleRect = QRect(r.left() + rect.bottom()
|
|---|
| 1838 | - titleRect.bottom(),
|
|---|
| 1839 | r.top() + titleRect.left() - rect.left(),
|
|---|
| 1840 | titleRect.height(), titleRect.width());
|
|---|
| 1841 | }
|
|---|
| 1842 | drawItemText(painter, titleRect,
|
|---|
| 1843 | Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
|
|---|
| 1844 | dwOpt->state & State_Enabled, dwOpt->title,
|
|---|
| 1845 | floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
|
|---|
| 1846 | painter->setFont(oldFont);
|
|---|
| 1847 | }
|
|---|
| 1848 | if (verticalTitleBar)
|
|---|
| 1849 | painter->restore();
|
|---|
| 1850 | }
|
|---|
| 1851 | return;
|
|---|
| 1852 | #endif // QT_NO_DOCKWIDGET
|
|---|
| 1853 |
|
|---|
| 1854 | case CE_PushButtonLabel:
|
|---|
| 1855 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 1856 | painter->save();
|
|---|
| 1857 | QRect ir = button->rect;
|
|---|
| 1858 | QPalette::ColorRole colorRole;
|
|---|
| 1859 | uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
|
|---|
| 1860 | if (!styleHint(SH_UnderlineShortcut, button, widget))
|
|---|
| 1861 | tf |= Qt::TextHideMnemonic;
|
|---|
| 1862 |
|
|---|
| 1863 | if (button->state & (State_On | State_Sunken))
|
|---|
| 1864 | colorRole = QPalette::Light;
|
|---|
| 1865 | else
|
|---|
| 1866 | colorRole = QPalette::ButtonText;
|
|---|
| 1867 |
|
|---|
| 1868 | if (!button->icon.isNull()) {
|
|---|
| 1869 | QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
|
|---|
| 1870 | : QIcon::Disabled;
|
|---|
| 1871 | if (mode == QIcon::Normal && button->state & State_HasFocus)
|
|---|
| 1872 | mode = QIcon::Active;
|
|---|
| 1873 | QIcon::State state = QIcon::Off;
|
|---|
| 1874 | if (button->state & State_On)
|
|---|
| 1875 | state = QIcon::On;
|
|---|
| 1876 | QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
|
|---|
| 1877 | int pixw = pixmap.width();
|
|---|
| 1878 | int pixh = pixmap.height();
|
|---|
| 1879 | //Center the icon if there is no text
|
|---|
| 1880 |
|
|---|
| 1881 | QPoint point;
|
|---|
| 1882 | if (button->text.isEmpty()) {
|
|---|
| 1883 | point = QPoint(ir.x() + ir.width() / 2 - pixw / 2,
|
|---|
| 1884 | ir.y() + ir.height() / 2 - pixh / 2);
|
|---|
| 1885 | } else {
|
|---|
| 1886 | point = QPoint(ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2);
|
|---|
| 1887 | }
|
|---|
| 1888 | if (button->direction == Qt::RightToLeft)
|
|---|
| 1889 | point.rx() += pixw;
|
|---|
| 1890 |
|
|---|
| 1891 | if ((button->state & (State_On | State_Sunken)) && button->direction == Qt::RightToLeft)
|
|---|
| 1892 | point.rx() -= pixelMetric(PM_ButtonShiftHorizontal, option, widget) * 2;
|
|---|
| 1893 |
|
|---|
| 1894 | painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
|
|---|
| 1895 |
|
|---|
| 1896 | if (button->direction == Qt::RightToLeft)
|
|---|
| 1897 | ir.translate(-4, 0);
|
|---|
| 1898 | else
|
|---|
| 1899 | ir.translate(pixw + 4, 0);
|
|---|
| 1900 | ir.setWidth(ir.width() - (pixw + 4));
|
|---|
| 1901 | // left-align text if there is
|
|---|
| 1902 | if (!button->text.isEmpty())
|
|---|
| 1903 | tf |= Qt::AlignLeft;
|
|---|
| 1904 | } else {
|
|---|
| 1905 | tf |= Qt::AlignHCenter;
|
|---|
| 1906 | }
|
|---|
| 1907 | if (button->state & State_Enabled)
|
|---|
| 1908 | drawItemText(painter, ir, tf, button->palette, true, button->text, colorRole);
|
|---|
| 1909 | else
|
|---|
| 1910 | drawItemText(painter, ir, tf, button->palette, true, button->text, QPalette::Mid);
|
|---|
| 1911 | painter->restore();
|
|---|
| 1912 | }
|
|---|
| 1913 | break;
|
|---|
| 1914 | default:
|
|---|
| 1915 | QWindowsStyle::drawControl(element, option, painter, widget);
|
|---|
| 1916 | break;
|
|---|
| 1917 | }
|
|---|
| 1918 | }
|
|---|
| 1919 |
|
|---|
| 1920 | void QWindowsMobileStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
|---|
| 1921 | QPainter *painter, const QWidget *widget) const {
|
|---|
| 1922 |
|
|---|
| 1923 | painter->setClipping(false);
|
|---|
| 1924 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 1925 |
|
|---|
| 1926 | switch (control) {
|
|---|
| 1927 | #ifndef QT_NO_SLIDER
|
|---|
| 1928 | case CC_Slider:
|
|---|
| 1929 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|---|
| 1930 | int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
|
|---|
| 1931 | int len = pixelMetric(PM_SliderLength, slider, widget);
|
|---|
| 1932 | int ticks = slider->tickPosition;
|
|---|
| 1933 | QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
|
|---|
| 1934 | QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
|
|---|
| 1935 |
|
|---|
| 1936 | if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
|
|---|
| 1937 | int mid = thickness / 2;
|
|---|
| 1938 | if (ticks & QSlider::TicksAbove)
|
|---|
| 1939 | mid += len / 8;
|
|---|
| 1940 | if (ticks & QSlider::TicksBelow)
|
|---|
| 1941 | mid -= len / 8;
|
|---|
| 1942 |
|
|---|
| 1943 | painter->setPen(slider->palette.shadow().color());
|
|---|
| 1944 | if (slider->orientation == Qt::Horizontal) {
|
|---|
| 1945 | qDrawPlainRect(painter, groove.x(), groove.y() + mid - 2,
|
|---|
| 1946 | groove.width(), 4, option->palette.shadow().color(),1,0);
|
|---|
| 1947 | } else {
|
|---|
| 1948 | qDrawPlainRect(painter, groove.x()+mid-2, groove.y(),
|
|---|
| 1949 | 4, groove.height(), option->palette.shadow().color(),1,0);
|
|---|
| 1950 | }
|
|---|
| 1951 | }
|
|---|
| 1952 | if (slider->subControls & SC_SliderTickmarks) {
|
|---|
| 1953 | QStyleOptionSlider tmpSlider = *slider;
|
|---|
| 1954 | tmpSlider.subControls = SC_SliderTickmarks;
|
|---|
| 1955 | QCommonStyle::drawComplexControl(control, &tmpSlider, painter, widget);
|
|---|
| 1956 | }
|
|---|
| 1957 |
|
|---|
| 1958 | if (slider->subControls & SC_SliderHandle) {
|
|---|
| 1959 | const QColor c0 = slider->palette.shadow().color();
|
|---|
| 1960 | const QColor c1 = slider->palette.dark().color();
|
|---|
| 1961 | const QColor c3 = slider->palette.midlight().color();
|
|---|
| 1962 | const QColor c4 = slider->palette.dark().color();
|
|---|
| 1963 | QBrush handleBrush;
|
|---|
| 1964 |
|
|---|
| 1965 | if (slider->state & State_Enabled) {
|
|---|
| 1966 | handleBrush = slider->palette.color(QPalette::Light);
|
|---|
| 1967 | } else {
|
|---|
| 1968 | handleBrush = QBrush(slider->palette.color(QPalette::Shadow),
|
|---|
| 1969 | Qt::Dense4Pattern);
|
|---|
| 1970 | }
|
|---|
| 1971 | int x = handle.x(), y = handle.y(),
|
|---|
| 1972 | wi = handle.width(), he = handle.height();
|
|---|
| 1973 | int x1 = x;
|
|---|
| 1974 | int x2 = x+wi-1;
|
|---|
| 1975 | int y1 = y;
|
|---|
| 1976 | int y2 = y+he-1;
|
|---|
| 1977 |
|
|---|
| 1978 | Qt::Orientation orient = slider->orientation;
|
|---|
| 1979 | bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
|
|---|
| 1980 | bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
|
|---|
| 1981 |
|
|---|
| 1982 | if (slider->state & State_HasFocus) {
|
|---|
| 1983 | QStyleOptionFocusRect fropt;
|
|---|
| 1984 | fropt.QStyleOption::operator=(*slider);
|
|---|
| 1985 | fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
|
|---|
| 1986 | drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
|
|---|
| 1987 | }
|
|---|
| 1988 | if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
|
|---|
| 1989 | Qt::BGMode oldMode = painter->backgroundMode();
|
|---|
| 1990 | painter->setBackgroundMode(Qt::OpaqueMode);
|
|---|
| 1991 | qDrawPlainRect(painter, QRect(x, y, wi, he)
|
|---|
| 1992 | ,slider->palette.shadow().color(),1,&handleBrush);
|
|---|
| 1993 | painter->setBackgroundMode(oldMode);
|
|---|
| 1994 | QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
|
|---|
| 1995 | if (slider->state & State_Sunken)
|
|---|
| 1996 | painter->fillRect(QRectF(x1 + 2, y1 + 2, x2 - x1 - 3, y2 - y1 - 3),fill);
|
|---|
| 1997 | return;
|
|---|
| 1998 | }
|
|---|
| 1999 | QSliderDirection dir;
|
|---|
| 2000 | if (orient == Qt::Horizontal)
|
|---|
| 2001 | if (tickAbove)
|
|---|
| 2002 | dir = SliderUp;
|
|---|
| 2003 | else
|
|---|
| 2004 | dir = SliderDown;
|
|---|
| 2005 | else
|
|---|
| 2006 | if (tickAbove)
|
|---|
| 2007 | dir = SliderLeft;
|
|---|
| 2008 | else
|
|---|
| 2009 | dir = SliderRight;
|
|---|
| 2010 | QPolygon polygon;
|
|---|
| 2011 | int d = 0;
|
|---|
| 2012 | switch (dir) {
|
|---|
| 2013 | case SliderUp:
|
|---|
| 2014 | x2++;
|
|---|
| 2015 | y1 = y1 + wi / 2;
|
|---|
| 2016 | d = (wi + 1) / 2 - 1;
|
|---|
| 2017 | polygon.setPoints(5, x1, y1, x1, y2, x2, y2, x2, y1, x1 + d,y1 - d);
|
|---|
| 2018 | break;
|
|---|
| 2019 | case SliderDown:
|
|---|
| 2020 | x2++;
|
|---|
| 2021 | y2 = y2 - wi/2;
|
|---|
| 2022 | d = (wi + 1) / 2 - 1;
|
|---|
| 2023 | polygon.setPoints(5, x1, y1, x1, y2, x1 + d,y2 + d, x2, y2, x2, y1);
|
|---|
| 2024 | break;
|
|---|
| 2025 | case SliderLeft:
|
|---|
| 2026 | d = (he + 1) / 2 - 1;
|
|---|
| 2027 | x1 = x1 + he/2;
|
|---|
| 2028 | polygon.setPoints(5, x1, y1, x1 - d, y1 + d, x1,y2, x2, y2, x2, y1);
|
|---|
| 2029 | y1--;
|
|---|
| 2030 | break;
|
|---|
| 2031 | case SliderRight:
|
|---|
| 2032 | d = (he + 1) / 2 - 1;
|
|---|
| 2033 | x2 = x2 - he/2;
|
|---|
| 2034 | polygon.setPoints(5, x1, y1, x1, y2, x2,y2, x2 + d, y1 + d, x2, y1);
|
|---|
| 2035 | y1--;
|
|---|
| 2036 | break;
|
|---|
| 2037 | }
|
|---|
| 2038 | QBrush oldBrush = painter->brush();
|
|---|
| 2039 | painter->setPen(Qt::NoPen);
|
|---|
| 2040 | painter->setBrush(handleBrush);
|
|---|
| 2041 | Qt::BGMode oldMode = painter->backgroundMode();
|
|---|
| 2042 | painter->setBackgroundMode(Qt::OpaqueMode);
|
|---|
| 2043 | painter->drawRect(x1, y1, x2-x1+1, y2-y1+1);
|
|---|
| 2044 | painter->drawPolygon(polygon);
|
|---|
| 2045 | QBrush fill = QBrush(option->palette.button().color(), Qt::Dense4Pattern);
|
|---|
| 2046 | painter->setBrush(oldBrush);
|
|---|
| 2047 | painter->setBackgroundMode(oldMode);
|
|---|
| 2048 | if (slider->state & State_Sunken)
|
|---|
| 2049 | painter->fillRect(QRectF(x1, y1, x2 - x1 + 1, y2 - y1 + 1),fill);
|
|---|
| 2050 |
|
|---|
| 2051 | if (dir != SliderUp) {
|
|---|
| 2052 | painter->setPen(c0);
|
|---|
| 2053 | painter->drawLine(x1, y1, x2, y1);
|
|---|
| 2054 | }
|
|---|
| 2055 | if (dir != SliderLeft) {
|
|---|
| 2056 | painter->setPen(c0);
|
|---|
| 2057 | painter->drawLine(x1, y1, x1, y2);
|
|---|
| 2058 | }
|
|---|
| 2059 | if (dir != SliderRight) {
|
|---|
| 2060 | painter->setPen(c0);
|
|---|
| 2061 | painter->drawLine(x2, y1, x2, y2);
|
|---|
| 2062 | }
|
|---|
| 2063 | if (dir != SliderDown) {
|
|---|
| 2064 | painter->setPen(c0);
|
|---|
| 2065 | painter->drawLine(x1, y2, x2, y2);
|
|---|
| 2066 | }
|
|---|
| 2067 | switch (dir) {
|
|---|
| 2068 | case SliderUp:
|
|---|
| 2069 | if (slider->state & State_Sunken)
|
|---|
| 2070 | painter->fillRect(QRectF(x1 + 3, y1 - d + 2, x2 - x1 - 4, y1),fill);
|
|---|
| 2071 | painter->setPen(c0);
|
|---|
| 2072 | painter->drawLine(x1, y1, x1 + d, y1 - d);
|
|---|
| 2073 | d = wi - d - 1;
|
|---|
| 2074 | painter->drawLine(x2, y1, x2 -d , y1 -d );
|
|---|
| 2075 | d--;
|
|---|
| 2076 | break;
|
|---|
| 2077 | case SliderDown:
|
|---|
| 2078 | if (slider->state & State_Sunken)
|
|---|
| 2079 | painter->fillRect(QRectF(x1+3, y2 - d, x2 - x1 -4,y2 - 8),fill);
|
|---|
| 2080 | painter->setPen(c0);
|
|---|
| 2081 | painter->drawLine(x1, y2, x1 + d, y2 + d);
|
|---|
| 2082 | d = wi - d - 1;
|
|---|
| 2083 | painter->drawLine(x2, y2, x2 - d, y2 + d);
|
|---|
| 2084 | d--;
|
|---|
| 2085 | break;
|
|---|
| 2086 | case SliderLeft:
|
|---|
| 2087 | if (slider->state & State_Sunken)
|
|---|
| 2088 | painter->fillRect(QRectF(x1 - d + 2, y1 + 2, x1, y2 - y1 - 3),fill);
|
|---|
| 2089 | painter->setPen(c0);
|
|---|
| 2090 | painter->drawLine(x1, y1, x1 - d, y1 + d);
|
|---|
| 2091 | d = he - d - 1;
|
|---|
| 2092 | painter->drawLine(x1, y2, x1 - d, y2 - d);
|
|---|
| 2093 | d--;
|
|---|
| 2094 | break;
|
|---|
| 2095 | case SliderRight:
|
|---|
| 2096 | if (slider->state & State_Sunken)
|
|---|
| 2097 | painter->fillRect(QRectF(x2 - d - 4, y1 + 2, x2 - 4, y2 - y1 - 3),fill);
|
|---|
| 2098 | painter->setPen(c0);
|
|---|
| 2099 | painter->drawLine(x2, y1, x2 + d, y1 + d);
|
|---|
| 2100 | painter->setPen(c0);
|
|---|
| 2101 | d = he - d - 1;
|
|---|
| 2102 | painter->drawLine(x2, y2, x2 + d, y2 - d);
|
|---|
| 2103 | d--;
|
|---|
| 2104 | break;
|
|---|
| 2105 | }
|
|---|
| 2106 | }
|
|---|
| 2107 | }
|
|---|
| 2108 | break;
|
|---|
| 2109 | #endif //QT_NO_SLIDER
|
|---|
| 2110 | #ifndef QT_NO_SCROLLBAR
|
|---|
| 2111 | case CC_ScrollBar:
|
|---|
| 2112 | painter->save();
|
|---|
| 2113 | painter->setPen(option->palette.shadow().color());
|
|---|
| 2114 | if (d->doubleControls) {
|
|---|
| 2115 | QPen pen = painter->pen();
|
|---|
| 2116 | pen.setWidth(2);
|
|---|
| 2117 | pen.setCapStyle(Qt::SquareCap);
|
|---|
| 2118 | painter->setPen(pen);
|
|---|
| 2119 | }
|
|---|
| 2120 | if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|---|
| 2121 | // Make a copy here and reset it for each primitive.
|
|---|
| 2122 | QBrush fill;
|
|---|
| 2123 | if (d->smartphone) {
|
|---|
| 2124 | fill = option->palette.light();
|
|---|
| 2125 | painter->fillRect(option->rect,fill);
|
|---|
| 2126 | fill = option->palette.button();
|
|---|
| 2127 | QImage image;
|
|---|
| 2128 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
|---|
| 2129 | if (scrollbar->orientation == Qt::Horizontal)
|
|---|
| 2130 | image = QImage(vertlines_xpm);
|
|---|
| 2131 | else
|
|---|
| 2132 | image = QImage(horlines_xpm);
|
|---|
| 2133 | #endif
|
|---|
| 2134 | image.setColor(1, option->palette.button().color().rgb());
|
|---|
| 2135 | fill.setTextureImage(image);
|
|---|
| 2136 | }
|
|---|
| 2137 | else {
|
|---|
| 2138 | fill = option->palette.light();
|
|---|
| 2139 | }
|
|---|
| 2140 | painter->fillRect(option->rect,fill);
|
|---|
| 2141 | QStyleOptionSlider newScrollbar = *scrollbar;
|
|---|
| 2142 | State saveFlags = scrollbar->state;
|
|---|
| 2143 | //Check if the scrollbar is part of an abstractItemView and draw the frame according
|
|---|
| 2144 | bool drawCompleteFrame = true;
|
|---|
| 2145 | bool secondScrollBar = false;
|
|---|
| 2146 | if (widget)
|
|---|
| 2147 | if (QWidget *parent = widget->parentWidget()) {
|
|---|
| 2148 | if (QAbstractScrollArea *abstractScrollArea = qobject_cast<QAbstractScrollArea *>(parent->parentWidget())) {
|
|---|
| 2149 | drawCompleteFrame = (abstractScrollArea->frameStyle() == QFrame::NoFrame) || (abstractScrollArea->frameStyle() == QFrame::StyledPanel);
|
|---|
| 2150 | secondScrollBar = (abstractScrollArea->horizontalScrollBar()->isVisible()
|
|---|
| 2151 | && abstractScrollArea->verticalScrollBar()->isVisible()) ;
|
|---|
| 2152 | }
|
|---|
| 2153 | #ifndef QT_NO_LISTVIEW
|
|---|
| 2154 | if (QListView *listView = qobject_cast<QListView *>(parent->parentWidget()))
|
|---|
| 2155 | drawCompleteFrame = false;
|
|---|
| 2156 | #endif
|
|---|
| 2157 | }
|
|---|
| 2158 | if (scrollbar->minimum == scrollbar->maximum)
|
|---|
| 2159 | saveFlags |= State_Enabled;
|
|---|
| 2160 | if (scrollbar->subControls & SC_ScrollBarSubLine) {
|
|---|
| 2161 | newScrollbar.state = saveFlags;
|
|---|
| 2162 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarSubLine, widget);
|
|---|
| 2163 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2164 | if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine))
|
|---|
| 2165 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2166 | QStyleOption arrowOpt = newScrollbar;
|
|---|
| 2167 | if (d->doubleControls)
|
|---|
| 2168 | arrowOpt.rect = newScrollbar.rect.adjusted(4, 6, -5, -3);
|
|---|
| 2169 | else
|
|---|
| 2170 | arrowOpt.rect = newScrollbar.rect.adjusted(5, 6, -4, -3);
|
|---|
| 2171 | QBrush fill = option->palette.button();
|
|---|
| 2172 | if (newScrollbar.state & State_Sunken)
|
|---|
| 2173 | fill = option->palette.shadow();
|
|---|
| 2174 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2175 | painter->fillRect(newScrollbar.rect,fill);
|
|---|
| 2176 | QRect r = newScrollbar.rect.adjusted(0,0,1,0);
|
|---|
| 2177 | painter->drawLine(r.topRight(), r.bottomRight());
|
|---|
| 2178 | if (d->doubleControls)
|
|---|
| 2179 | arrowOpt.rect.adjust(0, -2 ,0, -2);
|
|---|
| 2180 | drawPrimitive(PE_IndicatorArrowLeft, &arrowOpt, painter, widget);
|
|---|
| 2181 | }
|
|---|
| 2182 | else {
|
|---|
| 2183 | painter->fillRect(newScrollbar.rect,fill);
|
|---|
| 2184 | QRect r = newScrollbar.rect.adjusted(0, 0, 0, 1);
|
|---|
| 2185 | painter->drawLine(r.bottomLeft(), r.bottomRight());
|
|---|
| 2186 | if (drawCompleteFrame)
|
|---|
| 2187 | arrowOpt.rect.adjust(-2, 0, -2, 0);
|
|---|
| 2188 | if (d->doubleControls)
|
|---|
| 2189 | arrowOpt.rect.adjust(0, -4 , 0, -4);
|
|---|
| 2190 | if (drawCompleteFrame && d->doubleControls)
|
|---|
| 2191 | arrowOpt.rect.adjust(2, 0, 2, 0);
|
|---|
| 2192 | drawPrimitive(PE_IndicatorArrowUp, &arrowOpt, painter, widget);
|
|---|
| 2193 | }
|
|---|
| 2194 | }
|
|---|
| 2195 | }
|
|---|
| 2196 | if (scrollbar->subControls & SC_ScrollBarAddLine) {
|
|---|
| 2197 | newScrollbar.rect = scrollbar->rect;
|
|---|
| 2198 | newScrollbar.state = saveFlags;
|
|---|
| 2199 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarAddLine, widget);
|
|---|
| 2200 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2201 | if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
|
|---|
| 2202 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2203 | QStyleOption arrowOpt = newScrollbar;
|
|---|
| 2204 | if (d->doubleControls)
|
|---|
| 2205 | arrowOpt.rect = newScrollbar.rect.adjusted(4, 0, -5, 3);
|
|---|
| 2206 | else
|
|---|
| 2207 | arrowOpt.rect = newScrollbar.rect.adjusted(5, 6, -4, -3);
|
|---|
| 2208 | QBrush fill = option->palette.button();
|
|---|
| 2209 | if (newScrollbar.state & State_Sunken)
|
|---|
| 2210 | fill = option->palette.shadow();
|
|---|
| 2211 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2212 | painter->fillRect(newScrollbar.rect,fill);
|
|---|
| 2213 | QRect r = newScrollbar.rect.adjusted(0, 0, 0, 0);
|
|---|
| 2214 | painter->drawLine(r.topLeft(), r.bottomLeft());
|
|---|
| 2215 | if (secondScrollBar)
|
|---|
| 2216 | painter->drawLine(r.topRight(), r.bottomRight());
|
|---|
| 2217 | if (d->doubleControls)
|
|---|
| 2218 | arrowOpt.rect.adjust(0, 4, 0, 4 );
|
|---|
| 2219 | drawPrimitive(PE_IndicatorArrowRight, &arrowOpt, painter, widget);
|
|---|
| 2220 | }
|
|---|
| 2221 | else {
|
|---|
| 2222 | painter->fillRect(newScrollbar.rect,fill);
|
|---|
| 2223 | QRect r = newScrollbar.rect.adjusted(0, -1, 0, -1);
|
|---|
| 2224 | painter->drawLine(r.topLeft(), r.topRight());
|
|---|
| 2225 | if (secondScrollBar)
|
|---|
| 2226 | painter->drawLine(r.bottomLeft() + QPoint(0,1), r.bottomRight() + QPoint(0, 1));
|
|---|
| 2227 | if (drawCompleteFrame)
|
|---|
| 2228 | arrowOpt.rect.adjust(-2, 0, -2, 0);
|
|---|
| 2229 | if (d->doubleControls)
|
|---|
| 2230 | arrowOpt.rect.adjust(1, 0, 1, 0 );
|
|---|
| 2231 | if (drawCompleteFrame && d->doubleControls)
|
|---|
| 2232 | arrowOpt.rect.adjust(1, 0, 1, 0);
|
|---|
| 2233 | drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
|---|
| 2234 | }
|
|---|
| 2235 | }
|
|---|
| 2236 | }
|
|---|
| 2237 | if (scrollbar->subControls & SC_ScrollBarSubPage) {
|
|---|
| 2238 | newScrollbar.rect = scrollbar->rect;
|
|---|
| 2239 | newScrollbar.state = saveFlags;
|
|---|
| 2240 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarSubPage, widget);
|
|---|
| 2241 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2242 | if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage))
|
|---|
| 2243 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2244 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2245 | QRect r = newScrollbar.rect.adjusted(0, 0, 0, 0);
|
|---|
| 2246 | }
|
|---|
| 2247 | else{
|
|---|
| 2248 | QRect r = newScrollbar.rect.adjusted(0, 0, 0, 0);
|
|---|
| 2249 | }
|
|---|
| 2250 | }
|
|---|
| 2251 | }
|
|---|
| 2252 | if (scrollbar->subControls & SC_ScrollBarAddPage) {
|
|---|
| 2253 | newScrollbar.rect = scrollbar->rect;
|
|---|
| 2254 | newScrollbar.state = saveFlags;
|
|---|
| 2255 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarAddPage, widget);
|
|---|
| 2256 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2257 | if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage))
|
|---|
| 2258 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2259 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2260 | QRect r = newScrollbar.rect.adjusted(0, 0, 0, -1);
|
|---|
| 2261 | }
|
|---|
| 2262 | else {
|
|---|
| 2263 | QRect r = newScrollbar.rect.adjusted(0, 0,- 1, 0);
|
|---|
| 2264 | }
|
|---|
| 2265 | }
|
|---|
| 2266 | }
|
|---|
| 2267 | if (scrollbar->subControls & SC_ScrollBarFirst) {
|
|---|
| 2268 | newScrollbar.rect = scrollbar->rect;
|
|---|
| 2269 | newScrollbar.state = saveFlags;
|
|---|
| 2270 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarFirst, widget);
|
|---|
| 2271 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2272 | if (!(scrollbar->activeSubControls & SC_ScrollBarFirst))
|
|---|
| 2273 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2274 | QRect r = newScrollbar.rect;
|
|---|
| 2275 | }
|
|---|
| 2276 | }
|
|---|
| 2277 | if (scrollbar->subControls & SC_ScrollBarLast) {
|
|---|
| 2278 | newScrollbar.rect = scrollbar->rect;
|
|---|
| 2279 | newScrollbar.state = saveFlags;
|
|---|
| 2280 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarLast, widget);
|
|---|
| 2281 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2282 | if (!(scrollbar->activeSubControls & SC_ScrollBarLast))
|
|---|
| 2283 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2284 | QRect r = newScrollbar.rect;
|
|---|
| 2285 | }
|
|---|
| 2286 | }
|
|---|
| 2287 | if (scrollbar->subControls & SC_ScrollBarSlider) {
|
|---|
| 2288 | newScrollbar.rect = scrollbar->rect;
|
|---|
| 2289 | newScrollbar.state = saveFlags;
|
|---|
| 2290 | newScrollbar.rect = subControlRect(control, &newScrollbar, SC_ScrollBarSlider, widget);
|
|---|
| 2291 | if (newScrollbar.rect.isValid()) {
|
|---|
| 2292 | if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
|
|---|
| 2293 | newScrollbar.state &= ~(State_Sunken | State_MouseOver);
|
|---|
| 2294 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2295 | painter->fillRect(newScrollbar.rect,option->palette.button());
|
|---|
| 2296 | QRect r = newScrollbar.rect;
|
|---|
| 2297 | painter->drawLine(r.topLeft(), r.bottomLeft());
|
|---|
| 2298 | painter->drawLine(r.topRight(), r.bottomRight());
|
|---|
| 2299 | if (d->smartphone) {
|
|---|
| 2300 | painter->drawLine(r.topLeft(), r.topRight());
|
|---|
| 2301 | painter->drawLine(r.bottomLeft(), r.bottomRight());
|
|---|
| 2302 | }
|
|---|
| 2303 | }
|
|---|
| 2304 | else {
|
|---|
| 2305 | painter->fillRect(newScrollbar.rect,option->palette.button());
|
|---|
| 2306 | QRect r = newScrollbar.rect;
|
|---|
| 2307 | painter->drawLine(r.topLeft(), r.topRight());
|
|---|
| 2308 | painter->drawLine(r.bottomLeft(), r.bottomRight());
|
|---|
| 2309 | if (d->smartphone) {
|
|---|
| 2310 | painter->drawLine(r.topLeft(), r.bottomLeft());
|
|---|
| 2311 | painter->drawLine(r.topRight(), r.bottomRight());
|
|---|
| 2312 | }
|
|---|
| 2313 | }
|
|---|
| 2314 | if (scrollbar->state & State_HasFocus) {
|
|---|
| 2315 | QStyleOptionFocusRect fropt;
|
|---|
| 2316 | fropt.QStyleOption::operator=(newScrollbar);
|
|---|
| 2317 | fropt.rect.setRect(newScrollbar.rect.x() + 2, newScrollbar.rect.y() + 2,
|
|---|
| 2318 | newScrollbar.rect.width() - 5,
|
|---|
| 2319 | newScrollbar.rect.height() - 5);
|
|---|
| 2320 | }
|
|---|
| 2321 | }
|
|---|
| 2322 | }
|
|---|
| 2323 | int gripMargin = d->doubleControls ? 4 : 2;
|
|---|
| 2324 | int doubleLines = d->doubleControls ? 2 : 1;
|
|---|
| 2325 | //If there is a frame around the scrollbar (abstractScrollArea),
|
|---|
| 2326 | //then the margin is different, because of the missing frame
|
|---|
| 2327 | int gripMarginFrame = d->doubleControls ? 3 : 1;
|
|---|
| 2328 | if (drawCompleteFrame)
|
|---|
| 2329 | gripMarginFrame = 0;
|
|---|
| 2330 | //draw grips
|
|---|
| 2331 | if (!d->smartphone)
|
|---|
| 2332 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2333 | for (int i = -3; i < 3; i += 2) {
|
|---|
| 2334 | painter->drawLine(
|
|---|
| 2335 | QPoint(newScrollbar.rect.center().x() + i * doubleLines + 1,
|
|---|
| 2336 | newScrollbar.rect.top() + gripMargin +gripMarginFrame),
|
|---|
| 2337 | QPoint(newScrollbar.rect.center().x() + i * doubleLines + 1,
|
|---|
| 2338 | newScrollbar.rect.bottom() - gripMargin));
|
|---|
| 2339 | }
|
|---|
| 2340 | } else {
|
|---|
| 2341 | for (int i = -2; i < 4 ; i += 2) {
|
|---|
| 2342 | painter->drawLine(
|
|---|
| 2343 | QPoint(newScrollbar.rect.left() + gripMargin + gripMarginFrame ,
|
|---|
| 2344 | newScrollbar.rect.center().y() + 1 + i * doubleLines - 1),
|
|---|
| 2345 | QPoint(newScrollbar.rect.right() - gripMargin,
|
|---|
| 2346 | newScrollbar.rect.center().y() + 1 + i * doubleLines - 1));
|
|---|
| 2347 | }
|
|---|
| 2348 | }
|
|---|
| 2349 | if (!d->smartphone) {
|
|---|
| 2350 | QRect r;
|
|---|
| 2351 | if (d->doubleControls)
|
|---|
| 2352 | r = option->rect.adjusted(1, 1, -1, 0);
|
|---|
| 2353 | else
|
|---|
| 2354 | r = option->rect.adjusted(0, 0, -1, 0);
|
|---|
| 2355 | if (drawCompleteFrame && d->doubleControls)
|
|---|
| 2356 | r.adjust(0, 0, 0, -1);
|
|---|
| 2357 | //Check if the scrollbar is part of an abstractItemView and draw the frame according
|
|---|
| 2358 | if (drawCompleteFrame)
|
|---|
| 2359 | painter->drawRect(r);
|
|---|
| 2360 | else
|
|---|
| 2361 | if (scrollbar->orientation == Qt::Horizontal)
|
|---|
| 2362 | painter->drawLine(r.topLeft(), r.topRight());
|
|---|
| 2363 | else
|
|---|
| 2364 | painter->drawLine(r.topLeft(), r.bottomLeft());
|
|---|
| 2365 | }
|
|---|
| 2366 | }
|
|---|
| 2367 | painter->restore();
|
|---|
| 2368 | break;
|
|---|
| 2369 | #endif // QT_NO_SLIDER
|
|---|
| 2370 | case CC_ToolButton:
|
|---|
| 2371 | if (const QStyleOptionToolButton *toolbutton
|
|---|
| 2372 | = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
|
|---|
| 2373 | QRect button, menuarea;
|
|---|
| 2374 | bool isTabWidget = false;
|
|---|
| 2375 | #ifndef QT_NO_TABWIDGET
|
|---|
| 2376 | if (widget)
|
|---|
| 2377 | if (QWidget *parent = widget->parentWidget())
|
|---|
| 2378 | isTabWidget = (qobject_cast<QTabWidget *>(parent->parentWidget()));
|
|---|
| 2379 | #endif //QT_NO_TABWIDGET
|
|---|
| 2380 |
|
|---|
| 2381 | button = subControlRect(control, toolbutton, SC_ToolButton, widget);
|
|---|
| 2382 | menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
|
|---|
| 2383 | State buttonFlags = toolbutton->state;
|
|---|
| 2384 | if (buttonFlags & State_AutoRaise) {
|
|---|
| 2385 | if (!(buttonFlags & State_MouseOver)) {
|
|---|
| 2386 | buttonFlags &= ~State_Raised;
|
|---|
| 2387 | }
|
|---|
| 2388 | }
|
|---|
| 2389 | State menuFlags = buttonFlags;
|
|---|
| 2390 | if (toolbutton->activeSubControls & SC_ToolButton)
|
|---|
| 2391 | buttonFlags |= State_Sunken;
|
|---|
| 2392 | if (toolbutton->activeSubControls & SC_ToolButtonMenu)
|
|---|
| 2393 | menuFlags |= State_On;
|
|---|
| 2394 | QStyleOption tool(0);
|
|---|
| 2395 | tool.palette = toolbutton->palette;
|
|---|
| 2396 | if (toolbutton->subControls & SC_ToolButton) {
|
|---|
| 2397 | tool.rect = button;
|
|---|
| 2398 | tool.state = buttonFlags;
|
|---|
| 2399 | drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
|
|---|
| 2400 | }
|
|---|
| 2401 | if (toolbutton->subControls & SC_ToolButtonMenu) {
|
|---|
| 2402 | tool.rect = menuarea;
|
|---|
| 2403 | tool.state = buttonFlags & State_Enabled;
|
|---|
| 2404 | QStyleOption toolMenu(0);
|
|---|
| 2405 | toolMenu = *toolbutton;
|
|---|
| 2406 | toolMenu.state = menuFlags;
|
|---|
| 2407 | if (buttonFlags & State_Sunken)
|
|---|
| 2408 | drawPrimitive(PE_PanelButtonTool, &toolMenu, painter, widget);
|
|---|
| 2409 | QStyleOption arrowOpt(0);
|
|---|
| 2410 | arrowOpt.rect = tool.rect;
|
|---|
| 2411 | arrowOpt.palette = tool.palette;
|
|---|
| 2412 | State flags = State_None;
|
|---|
| 2413 | if (menuFlags & State_Enabled)
|
|---|
| 2414 | flags |= State_Enabled;
|
|---|
| 2415 | if ((menuFlags & State_On) && !(buttonFlags & State_Sunken)) {
|
|---|
| 2416 | flags |= State_Sunken;
|
|---|
| 2417 | painter->fillRect(menuarea, option->palette.shadow());
|
|---|
| 2418 | }
|
|---|
| 2419 | arrowOpt.state = flags;
|
|---|
| 2420 | drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
|---|
| 2421 | }
|
|---|
| 2422 | if (toolbutton->state & State_HasFocus) {
|
|---|
| 2423 | QStyleOptionFocusRect focusRect;
|
|---|
| 2424 | focusRect.QStyleOption::operator=(*toolbutton);
|
|---|
| 2425 | focusRect.rect.adjust(3, 3, -3, -3);
|
|---|
| 2426 | if (toolbutton->features & QStyleOptionToolButton::Menu)
|
|---|
| 2427 | focusRect.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator,
|
|---|
| 2428 | toolbutton, widget), 0);
|
|---|
| 2429 | drawPrimitive(PE_FrameFocusRect, &focusRect, painter, widget);
|
|---|
| 2430 | }
|
|---|
| 2431 | QStyleOptionToolButton label = *toolbutton;
|
|---|
| 2432 | if (isTabWidget)
|
|---|
| 2433 | label.state = toolbutton->state;
|
|---|
| 2434 | else
|
|---|
| 2435 | label.state = toolbutton->state & State_Enabled;
|
|---|
| 2436 | int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
|
|---|
| 2437 | label.rect = button.adjusted(fw, fw, -fw, -fw);
|
|---|
| 2438 | drawControl(CE_ToolButtonLabel, &label, painter, widget);
|
|---|
| 2439 | }
|
|---|
| 2440 | break;
|
|---|
| 2441 |
|
|---|
| 2442 | #ifndef QT_NO_GROUPBOX
|
|---|
| 2443 | case CC_GroupBox:
|
|---|
| 2444 | if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
|
|---|
| 2445 | // Draw frame
|
|---|
| 2446 | painter->save();
|
|---|
| 2447 | QFont font = painter->font();
|
|---|
| 2448 | font.setBold(true);
|
|---|
| 2449 | painter->setFont(font);
|
|---|
| 2450 | QStyleOptionGroupBox groupBoxFont = *groupBox;
|
|---|
| 2451 | groupBoxFont.fontMetrics = QFontMetrics(font);
|
|---|
| 2452 | QRect textRect = subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget);
|
|---|
| 2453 | QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget).adjusted(0,0,0,0);
|
|---|
| 2454 | if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
|
|---|
| 2455 | QStyleOptionFrameV2 frame;
|
|---|
| 2456 | frame.QStyleOption::operator=(*groupBox);
|
|---|
| 2457 | frame.features = groupBox->features;
|
|---|
| 2458 | frame.lineWidth = groupBox->lineWidth;
|
|---|
| 2459 | frame.midLineWidth = groupBox->midLineWidth;
|
|---|
| 2460 | frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
|
|---|
| 2461 | painter->save();
|
|---|
| 2462 | QRegion region(groupBox->rect);
|
|---|
| 2463 | if (!groupBox->text.isEmpty()) {
|
|---|
| 2464 | bool ltr = groupBox->direction == Qt::LeftToRight;
|
|---|
| 2465 | QRect finalRect = checkBoxRect.united(textRect);
|
|---|
| 2466 | if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)
|
|---|
| 2467 | finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
|
|---|
| 2468 | region -= finalRect;
|
|---|
| 2469 | }
|
|---|
| 2470 | drawPrimitive(PE_FrameGroupBox, &frame, painter, widget);
|
|---|
| 2471 | painter->restore();
|
|---|
| 2472 | }
|
|---|
| 2473 | // Draw checkbox
|
|---|
| 2474 | if (groupBox->subControls & SC_GroupBoxCheckBox) {
|
|---|
| 2475 | QStyleOptionButton box;
|
|---|
| 2476 | box.QStyleOption::operator=(*groupBox);
|
|---|
| 2477 | box.rect = checkBoxRect;
|
|---|
| 2478 | drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
|
|---|
| 2479 | }
|
|---|
| 2480 | // Draw title
|
|---|
| 2481 | if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
|
|---|
| 2482 | QColor textColor = groupBox->textColor;
|
|---|
| 2483 | if (textColor.isValid())
|
|---|
| 2484 | painter->setPen(textColor);
|
|---|
| 2485 | else
|
|---|
| 2486 | painter->setPen(groupBox->palette.link().color());
|
|---|
| 2487 | painter->setPen(groupBox->palette.link().color());
|
|---|
| 2488 |
|
|---|
| 2489 | int alignment = int(groupBox->textAlignment);
|
|---|
| 2490 | if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
|
|---|
| 2491 | alignment |= Qt::TextHideMnemonic;
|
|---|
| 2492 |
|
|---|
| 2493 | if (groupBox->state & State_Enabled)
|
|---|
| 2494 | drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
|
|---|
| 2495 | groupBox->palette, true, groupBox->text,
|
|---|
| 2496 | textColor.isValid() ? QPalette::NoRole : QPalette::Link);
|
|---|
| 2497 | else
|
|---|
| 2498 | drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
|
|---|
| 2499 | groupBox->palette, true, groupBox->text, QPalette::Mid);
|
|---|
| 2500 | if (groupBox->state & State_HasFocus) {
|
|---|
| 2501 | QStyleOptionFocusRect fropt;
|
|---|
| 2502 | fropt.QStyleOption::operator=(*groupBox);
|
|---|
| 2503 | fropt.rect = textRect;
|
|---|
| 2504 | drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
|
|---|
| 2505 | }
|
|---|
| 2506 | }
|
|---|
| 2507 | painter->restore();
|
|---|
| 2508 | }
|
|---|
| 2509 | break;
|
|---|
| 2510 | #endif //QT_NO_GROUPBOX
|
|---|
| 2511 |
|
|---|
| 2512 | #ifndef QT_NO_COMBOBOX
|
|---|
| 2513 | case CC_ComboBox:
|
|---|
| 2514 | if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
|---|
| 2515 | QBrush editBrush = cmb->palette.brush(QPalette::Base);
|
|---|
| 2516 | if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame)
|
|---|
| 2517 | qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), pixelMetric(PM_ComboBoxFrameWidth, option, widget), &editBrush);
|
|---|
| 2518 | else
|
|---|
| 2519 | painter->fillRect(option->rect, editBrush);
|
|---|
| 2520 | State flags = State_None;
|
|---|
| 2521 | QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
|
|---|
| 2522 | if ((option->state & State_On)) {
|
|---|
| 2523 | painter->fillRect(ar.adjusted(0, 0, 1, 1),cmb->palette.brush(QPalette::Shadow));
|
|---|
| 2524 | }
|
|---|
| 2525 | if (d->doubleControls)
|
|---|
| 2526 | ar.adjust(5, 0, 5, 0);
|
|---|
| 2527 | else
|
|---|
| 2528 | ar.adjust(2, 0, -2, 0);
|
|---|
| 2529 | if (option->state & State_Enabled)
|
|---|
| 2530 | flags |= State_Enabled;
|
|---|
| 2531 | if (option->state & State_On)
|
|---|
| 2532 | flags |= State_Sunken;
|
|---|
| 2533 | QStyleOption arrowOpt(0);
|
|---|
| 2534 | arrowOpt.rect = ar;
|
|---|
| 2535 | arrowOpt.palette = cmb->palette;
|
|---|
| 2536 | arrowOpt.state = flags;
|
|---|
| 2537 | drawPrimitive(PrimitiveElement(PE_IndicatorArrowDownBig), &arrowOpt, painter, widget);
|
|---|
| 2538 | if (cmb->subControls & SC_ComboBoxEditField) {
|
|---|
| 2539 | QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
|
|---|
| 2540 | if (cmb->state & State_HasFocus && !cmb->editable)
|
|---|
| 2541 | painter->fillRect(re.x(), re.y(), re.width(), re.height(),
|
|---|
| 2542 | cmb->palette.brush(QPalette::Highlight));
|
|---|
| 2543 | if (cmb->state & State_HasFocus) {
|
|---|
| 2544 | painter->setPen(cmb->palette.highlightedText().color());
|
|---|
| 2545 | painter->setBackground(cmb->palette.highlight());
|
|---|
| 2546 | } else {
|
|---|
| 2547 | painter->setPen(cmb->palette.text().color());
|
|---|
| 2548 | painter->setBackground(cmb->palette.background());
|
|---|
| 2549 | }
|
|---|
| 2550 | if (cmb->state & State_HasFocus && !cmb->editable) {
|
|---|
| 2551 | QStyleOptionFocusRect focus;
|
|---|
| 2552 | focus.QStyleOption::operator=(*cmb);
|
|---|
| 2553 | focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
|
|---|
| 2554 | focus.state |= State_FocusAtBorder;
|
|---|
| 2555 | focus.backgroundColor = cmb->palette.highlight().color();
|
|---|
| 2556 | if ((option->state & State_On))
|
|---|
| 2557 | drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
|
|---|
| 2558 | }
|
|---|
| 2559 | }
|
|---|
| 2560 | }
|
|---|
| 2561 | break;
|
|---|
| 2562 | #endif // QT_NO_COMBOBOX
|
|---|
| 2563 |
|
|---|
| 2564 |
|
|---|
| 2565 | #ifndef QT_NO_SPINBOX
|
|---|
| 2566 | case CC_SpinBox:
|
|---|
| 2567 | if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
|---|
| 2568 | QStyleOptionSpinBox copy = *spinBox;
|
|---|
| 2569 | //PrimitiveElement primitiveElement;
|
|---|
| 2570 | int primitiveElement;
|
|---|
| 2571 |
|
|---|
| 2572 | if (spinBox->frame && (spinBox->subControls & SC_SpinBoxFrame)) {
|
|---|
| 2573 | QRect r = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxFrame, widget);
|
|---|
| 2574 | qDrawPlainRect(painter, r, option->palette.shadow().color(),pixelMetric(PM_SpinBoxFrameWidth, option, widget),0);
|
|---|
| 2575 | }
|
|---|
| 2576 | QPalette shadePal(option->palette);
|
|---|
| 2577 | shadePal.setColor(QPalette::Button, option->palette.light().color());
|
|---|
| 2578 | shadePal.setColor(QPalette::Light, option->palette.base().color());
|
|---|
| 2579 | if (spinBox->subControls & SC_SpinBoxUp) {
|
|---|
| 2580 | copy.subControls = SC_SpinBoxUp;
|
|---|
| 2581 | QPalette pal2 = spinBox->palette;
|
|---|
| 2582 | if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
|
|---|
| 2583 | pal2.setCurrentColorGroup(QPalette::Disabled);
|
|---|
| 2584 | copy.state &= ~State_Enabled;
|
|---|
| 2585 | }
|
|---|
| 2586 | copy.palette = pal2;
|
|---|
| 2587 | if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) {
|
|---|
| 2588 | copy.state |= State_On;
|
|---|
| 2589 | copy.state |= State_Sunken;
|
|---|
| 2590 | } else {
|
|---|
| 2591 | copy.state |= State_Raised;
|
|---|
| 2592 | copy.state &= ~State_Sunken;
|
|---|
| 2593 | }
|
|---|
| 2594 | primitiveElement = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorArrowUpBig
|
|---|
| 2595 | : PE_IndicatorArrowUpBig);
|
|---|
| 2596 | copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget);
|
|---|
| 2597 | if (copy.state & (State_Sunken | State_On))
|
|---|
| 2598 | qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(),pixelMetric(PM_SpinBoxFrameWidth, option, widget), ©.palette.brush(QPalette::Shadow));
|
|---|
| 2599 | else
|
|---|
| 2600 | qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(),pixelMetric(PM_SpinBoxFrameWidth, option, widget), ©.palette.brush(QPalette::Base));
|
|---|
| 2601 | copy.rect.adjust(pixelMetric(PM_SpinBoxFrameWidth, option, widget), 0, -pixelMetric(PM_SpinBoxFrameWidth, option, widget), 0);
|
|---|
| 2602 | drawPrimitive(PrimitiveElement(primitiveElement), ©, painter, widget);
|
|---|
| 2603 | }
|
|---|
| 2604 | if (spinBox->subControls & SC_SpinBoxDown) {
|
|---|
| 2605 | copy.subControls = SC_SpinBoxDown;
|
|---|
| 2606 | copy.state = spinBox->state;
|
|---|
| 2607 | QPalette pal2 = spinBox->palette;
|
|---|
| 2608 | if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
|
|---|
| 2609 | pal2.setCurrentColorGroup(QPalette::Disabled);
|
|---|
| 2610 | copy.state &= ~State_Enabled;
|
|---|
| 2611 | }
|
|---|
| 2612 | copy.palette = pal2;
|
|---|
| 2613 | if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) {
|
|---|
| 2614 | copy.state |= State_On;
|
|---|
| 2615 | copy.state |= State_Sunken;
|
|---|
| 2616 | } else {
|
|---|
| 2617 | copy.state |= State_Raised;
|
|---|
| 2618 | copy.state &= ~State_Sunken;
|
|---|
| 2619 | }
|
|---|
| 2620 | primitiveElement = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorArrowDownBig
|
|---|
| 2621 | : PE_IndicatorArrowDownBig);
|
|---|
| 2622 | copy.rect = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget);
|
|---|
| 2623 | qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(),pixelMetric(PM_SpinBoxFrameWidth, option, widget), ©.palette.brush(QPalette::Base));
|
|---|
| 2624 | if (copy.state & (State_Sunken | State_On))
|
|---|
| 2625 | qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(),pixelMetric(PM_SpinBoxFrameWidth, option, widget), ©.palette.brush(QPalette::Shadow));
|
|---|
| 2626 | else
|
|---|
| 2627 | qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(),pixelMetric(PM_SpinBoxFrameWidth, option, widget), ©.palette.brush(QPalette::Base));
|
|---|
| 2628 | copy.rect.adjust(3, 0, -4, 0);
|
|---|
| 2629 | if (primitiveElement == PE_IndicatorArrowUp || primitiveElement == PE_IndicatorArrowDown) {
|
|---|
| 2630 | int frameWidth = pixelMetric(PM_SpinBoxFrameWidth, option, widget);
|
|---|
| 2631 | copy.rect = copy.rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
|
|---|
| 2632 | drawPrimitive(PrimitiveElement(primitiveElement), ©, painter, widget);
|
|---|
| 2633 | }
|
|---|
| 2634 | else {
|
|---|
| 2635 | drawPrimitive(PrimitiveElement(primitiveElement), ©, painter, widget);
|
|---|
| 2636 | }
|
|---|
| 2637 | if (spinBox->frame && (spinBox->subControls & SC_SpinBoxFrame)) {
|
|---|
| 2638 | QRect r = subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget);
|
|---|
| 2639 | }
|
|---|
| 2640 | }
|
|---|
| 2641 | }
|
|---|
| 2642 | break;
|
|---|
| 2643 | #endif // QT_NO_SPINBOX
|
|---|
| 2644 |
|
|---|
| 2645 | default:
|
|---|
| 2646 | QWindowsStyle::drawComplexControl(control, option, painter, widget);
|
|---|
| 2647 | break;
|
|---|
| 2648 | }
|
|---|
| 2649 | }
|
|---|
| 2650 |
|
|---|
| 2651 | QSize QWindowsMobileStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
|
|---|
| 2652 | const QSize &size, const QWidget *widget) const {
|
|---|
| 2653 |
|
|---|
| 2654 | QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
|
|---|
| 2655 | switch (type) {
|
|---|
| 2656 | case CT_PushButton:
|
|---|
| 2657 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 2658 | newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
|
|---|
| 2659 | int w = newSize.width(),
|
|---|
| 2660 | h = newSize.height();
|
|---|
| 2661 | int defwidth = 0;
|
|---|
| 2662 | if (button->features & QStyleOptionButton::AutoDefaultButton)
|
|---|
| 2663 | defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, button, widget);
|
|---|
| 2664 | if (w < 75 + defwidth && button->icon.isNull())
|
|---|
| 2665 | w = 75 + defwidth;
|
|---|
| 2666 | if (h < 23 + defwidth)
|
|---|
| 2667 | h = 23 + defwidth;
|
|---|
| 2668 | newSize = QSize(w + 4, h + 4);
|
|---|
| 2669 | }
|
|---|
| 2670 | break;
|
|---|
| 2671 |
|
|---|
| 2672 | #ifndef QT_NO_GROUPBOX
|
|---|
| 2673 | case CT_GroupBox:
|
|---|
| 2674 | if (const QGroupBox *grb = static_cast<const QGroupBox *>(widget)) {
|
|---|
| 2675 | newSize = size + QSize(!grb->isFlat() ? 16 : 0, !grb->isFlat() ? 16 : 0);
|
|---|
| 2676 | }
|
|---|
| 2677 | break;
|
|---|
| 2678 | #endif // QT_NO_GROUPBOX
|
|---|
| 2679 |
|
|---|
| 2680 | case CT_RadioButton:
|
|---|
| 2681 | case CT_CheckBox:
|
|---|
| 2682 | newSize = size;
|
|---|
| 2683 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
|
|---|
| 2684 | bool isRadio = (type == CT_RadioButton);
|
|---|
| 2685 | QRect irect = visualRect(button->direction, button->rect,
|
|---|
| 2686 | subElementRect(isRadio ? SE_RadioButtonIndicator
|
|---|
| 2687 | : SE_CheckBoxIndicator, button, widget));
|
|---|
| 2688 | int h = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
|
|---|
| 2689 | : PM_IndicatorHeight, button, widget);
|
|---|
| 2690 | int margins = (!button->icon.isNull() && button->text.isEmpty()) ? 0 : 10;
|
|---|
| 2691 | if (d_func()->doubleControls)
|
|---|
| 2692 | margins *= 2;
|
|---|
| 2693 | newSize += QSize(irect.right() + margins, 1);
|
|---|
| 2694 | newSize.setHeight(qMax(newSize.height(), h));
|
|---|
| 2695 | }
|
|---|
| 2696 | break;
|
|---|
| 2697 | #ifndef QT_NO_COMBOBOX
|
|---|
| 2698 | case CT_ComboBox:
|
|---|
| 2699 | if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
|---|
| 2700 | int fw = comboBox->frame ? pixelMetric(PM_ComboBoxFrameWidth, option, widget) * 2 : 0;
|
|---|
| 2701 | newSize = QSize(newSize.width() + fw + 9, newSize.height() + fw-4); //Nine is a magic Number - See CommonStyle for real magic (23)
|
|---|
| 2702 | }
|
|---|
| 2703 | break;
|
|---|
| 2704 | #endif
|
|---|
| 2705 | #ifndef QT_NO_SPINBOX
|
|---|
| 2706 | case CT_SpinBox:
|
|---|
| 2707 | if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
|---|
| 2708 | int fw = spinBox->frame ? pixelMetric(PM_SpinBoxFrameWidth, option, widget) * 2 : 0;
|
|---|
| 2709 | newSize = QSize(newSize.width() + fw-5, newSize.height() + fw-6);
|
|---|
| 2710 | }
|
|---|
| 2711 | break;
|
|---|
| 2712 | #endif
|
|---|
| 2713 | #ifndef QT_NO_LINEEDIT
|
|---|
| 2714 | case CT_LineEdit:
|
|---|
| 2715 | newSize += QSize(0,1);
|
|---|
| 2716 | break;
|
|---|
| 2717 | #endif
|
|---|
| 2718 | case CT_ToolButton:
|
|---|
| 2719 | newSize = QSize(newSize.width() + 1, newSize.height());
|
|---|
| 2720 | break;
|
|---|
| 2721 | case CT_TabBarTab:
|
|---|
| 2722 | newSize += QSize(0,0);
|
|---|
| 2723 | break;
|
|---|
| 2724 | case CT_HeaderSection:
|
|---|
| 2725 | newSize += QSize(4, 2);
|
|---|
| 2726 | break;
|
|---|
| 2727 | default:
|
|---|
| 2728 | break;
|
|---|
| 2729 | }
|
|---|
| 2730 | return newSize;
|
|---|
| 2731 | }
|
|---|
| 2732 |
|
|---|
| 2733 | QRect QWindowsMobileStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const {
|
|---|
| 2734 |
|
|---|
| 2735 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 2736 | QRect rect = QWindowsStyle::subElementRect(element, option, widget);
|
|---|
| 2737 | switch (element) {
|
|---|
| 2738 | #ifndef QT_NO_TABWIDGET
|
|---|
| 2739 | case SE_TabWidgetTabBar:
|
|---|
| 2740 | if (d->doubleControls)
|
|---|
| 2741 | rect.adjust(-2, 0, 2, 0);
|
|---|
| 2742 | else
|
|---|
| 2743 | rect.adjust(-2, 0, 2, 0);
|
|---|
| 2744 | break;
|
|---|
| 2745 | #endif //QT_NO_TABWIDGET
|
|---|
| 2746 | case SE_CheckBoxFocusRect:
|
|---|
| 2747 | rect.adjust(1,0,-2,-1);
|
|---|
| 2748 | break;
|
|---|
| 2749 | case SE_RadioButtonFocusRect:
|
|---|
| 2750 | rect.adjust(1,1,-2,-2);
|
|---|
| 2751 | break;
|
|---|
| 2752 | default:
|
|---|
| 2753 | break;
|
|---|
| 2754 | #ifndef QT_NO_SLIDER
|
|---|
| 2755 | case SE_SliderFocusRect:
|
|---|
| 2756 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|---|
| 2757 | rect = slider->rect;
|
|---|
| 2758 | }
|
|---|
| 2759 | break;
|
|---|
| 2760 | case SE_PushButtonFocusRect:
|
|---|
| 2761 | if (d->doubleControls)
|
|---|
| 2762 | rect.adjust(-1, -1, 0, 0);
|
|---|
| 2763 | break;
|
|---|
| 2764 | #endif // QT_NO_SLIDER
|
|---|
| 2765 | }
|
|---|
| 2766 | return rect;
|
|---|
| 2767 | }
|
|---|
| 2768 |
|
|---|
| 2769 | QRect QWindowsMobileStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
|---|
| 2770 | SubControl subControl, const QWidget *widget) const {
|
|---|
| 2771 |
|
|---|
| 2772 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 2773 |
|
|---|
| 2774 | QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget);
|
|---|
| 2775 | switch (control) {
|
|---|
| 2776 |
|
|---|
| 2777 | #ifndef QT_NO_SCROLLBAR
|
|---|
| 2778 | case CC_ScrollBar:
|
|---|
| 2779 | if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|---|
| 2780 | int sliderButtonExtent = pixelMetric(PM_ScrollBarExtent, scrollbar, widget);
|
|---|
| 2781 | int sliderlen;
|
|---|
| 2782 | float stretchFactor = 1.4f;
|
|---|
| 2783 | int sliderButtonExtentDir = int (sliderButtonExtent * stretchFactor);
|
|---|
| 2784 | int maxlen = ((scrollbar->orientation == Qt::Horizontal) ?
|
|---|
| 2785 | scrollbar->rect.width() : scrollbar->rect.height()) - (sliderButtonExtentDir * 2);
|
|---|
| 2786 | // calculate slider length
|
|---|
| 2787 | if (scrollbar->maximum != scrollbar->minimum) {
|
|---|
| 2788 | uint range = scrollbar->maximum - scrollbar->minimum;
|
|---|
| 2789 | sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep);
|
|---|
| 2790 |
|
|---|
| 2791 | int slidermin = pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget);
|
|---|
| 2792 | if (sliderlen < slidermin || range > INT_MAX / 2)
|
|---|
| 2793 | sliderlen = slidermin;
|
|---|
| 2794 | if (sliderlen > maxlen)
|
|---|
| 2795 | sliderlen = maxlen;
|
|---|
| 2796 | } else {
|
|---|
| 2797 | sliderlen = maxlen;
|
|---|
| 2798 | }
|
|---|
| 2799 | int sliderstart = sliderButtonExtentDir + sliderPositionFromValue(scrollbar->minimum,
|
|---|
| 2800 | scrollbar->maximum,
|
|---|
| 2801 | scrollbar->sliderPosition,
|
|---|
| 2802 | maxlen - sliderlen,
|
|---|
| 2803 | scrollbar->upsideDown);
|
|---|
| 2804 | if (d->smartphone) {
|
|---|
| 2805 | sliderstart -= sliderButtonExtentDir;
|
|---|
| 2806 | sliderlen += 2*sliderButtonExtent;
|
|---|
| 2807 | }
|
|---|
| 2808 | switch (subControl) {
|
|---|
| 2809 | case SC_ScrollBarSubLine: // top/left button
|
|---|
| 2810 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2811 | int buttonWidth = qMin(scrollbar->rect.width() / 2, sliderButtonExtentDir );
|
|---|
| 2812 | rect.setRect(0, 0, buttonWidth, sliderButtonExtent);
|
|---|
| 2813 | } else {
|
|---|
| 2814 | int buttonHeight = qMin(scrollbar->rect.height() / 2, sliderButtonExtentDir);
|
|---|
| 2815 | rect.setRect(0, 0, sliderButtonExtent, buttonHeight);
|
|---|
| 2816 | }
|
|---|
| 2817 | if (d->smartphone)
|
|---|
| 2818 | rect.setRect(0, 0, 0, 0);
|
|---|
| 2819 | break;
|
|---|
| 2820 | case SC_ScrollBarAddLine: // bottom/right button
|
|---|
| 2821 | if (scrollbar->orientation == Qt::Horizontal) {
|
|---|
| 2822 | int buttonWidth = qMin(scrollbar->rect.width()/2, sliderButtonExtentDir);
|
|---|
| 2823 | rect.setRect(scrollbar->rect.width() - buttonWidth, 0, buttonWidth, sliderButtonExtent);
|
|---|
| 2824 | } else {
|
|---|
| 2825 | int buttonHeight = qMin(scrollbar->rect.height()/2, sliderButtonExtentDir );
|
|---|
| 2826 | rect.setRect(0, scrollbar->rect.height() - buttonHeight, sliderButtonExtent, buttonHeight);
|
|---|
| 2827 | }
|
|---|
| 2828 | if (d->smartphone)
|
|---|
| 2829 | rect.setRect(0, 0, 0, 0);
|
|---|
| 2830 | break;
|
|---|
| 2831 | case SC_ScrollBarSubPage: // between top/left button and slider
|
|---|
| 2832 | if (scrollbar->orientation == Qt::Horizontal)
|
|---|
| 2833 | if (d->smartphone)
|
|---|
| 2834 | rect.setRect(0, 0, sliderstart, sliderButtonExtent);
|
|---|
| 2835 | else
|
|---|
| 2836 | rect.setRect(sliderButtonExtent, 0, sliderstart - sliderButtonExtent, sliderButtonExtent);
|
|---|
| 2837 | else
|
|---|
| 2838 | if (d->smartphone)
|
|---|
| 2839 | rect.setRect(0, 0, sliderButtonExtent, sliderstart);
|
|---|
| 2840 | else
|
|---|
| 2841 | rect.setRect(0, sliderButtonExtent, sliderButtonExtent, sliderstart - sliderButtonExtent);
|
|---|
| 2842 | break;
|
|---|
| 2843 | case SC_ScrollBarAddPage: // between bottom/right button and slider
|
|---|
| 2844 | if (scrollbar->orientation == Qt::Horizontal)
|
|---|
| 2845 | if (d->smartphone)
|
|---|
| 2846 | rect.setRect(sliderstart + sliderlen, 0,
|
|---|
| 2847 | maxlen - sliderstart - sliderlen + 2*sliderButtonExtent, sliderButtonExtent);
|
|---|
| 2848 | else
|
|---|
| 2849 | rect.setRect(sliderstart + sliderlen, 0,
|
|---|
| 2850 | maxlen - sliderstart - sliderlen + sliderButtonExtent, sliderButtonExtent);
|
|---|
| 2851 | else
|
|---|
| 2852 | if (d->smartphone)
|
|---|
| 2853 | rect.setRect(0, sliderstart + sliderlen, sliderButtonExtent,
|
|---|
| 2854 | maxlen - sliderstart - sliderlen + 2*sliderButtonExtent);
|
|---|
| 2855 | else
|
|---|
| 2856 | rect.setRect(0, sliderstart + sliderlen, sliderButtonExtent,
|
|---|
| 2857 | maxlen - sliderstart - sliderlen + sliderButtonExtent);
|
|---|
| 2858 | break;
|
|---|
| 2859 | case SC_ScrollBarGroove:
|
|---|
| 2860 | if (scrollbar->orientation == Qt::Horizontal)
|
|---|
| 2861 | rect.setRect(sliderButtonExtent, 0, scrollbar->rect.width() - sliderButtonExtent * 2,
|
|---|
| 2862 | scrollbar->rect.height());
|
|---|
| 2863 | else
|
|---|
| 2864 | rect.setRect(0, sliderButtonExtent, scrollbar->rect.width(),
|
|---|
| 2865 | scrollbar->rect.height() - sliderButtonExtent * 2);
|
|---|
| 2866 | break;
|
|---|
| 2867 | case SC_ScrollBarSlider:
|
|---|
| 2868 | if (scrollbar->orientation == Qt::Horizontal)
|
|---|
| 2869 | rect.setRect(sliderstart, 0, sliderlen, sliderButtonExtent);
|
|---|
| 2870 | else
|
|---|
| 2871 | rect.setRect(0, sliderstart, sliderButtonExtent, sliderlen);
|
|---|
| 2872 | break;
|
|---|
| 2873 | default:
|
|---|
| 2874 | break;
|
|---|
| 2875 | }
|
|---|
| 2876 | rect = visualRect(scrollbar->direction, scrollbar->rect, rect);
|
|---|
| 2877 | }
|
|---|
| 2878 | break;
|
|---|
| 2879 | #endif // QT_NO_SCROLLBAR
|
|---|
| 2880 |
|
|---|
| 2881 |
|
|---|
| 2882 |
|
|---|
| 2883 | #ifndef QT_NO_TOOLBUTTON
|
|---|
| 2884 | case CC_ToolButton:
|
|---|
| 2885 | if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
|
|---|
| 2886 | int mbi = pixelMetric(PM_MenuButtonIndicator, toolButton, widget);
|
|---|
| 2887 | rect = toolButton->rect;
|
|---|
| 2888 | switch (subControl) {
|
|---|
| 2889 | case SC_ToolButton:
|
|---|
| 2890 | if ((toolButton->features
|
|---|
| 2891 | & (QStyleOptionToolButton::Menu | QStyleOptionToolButton::PopupDelay))
|
|---|
| 2892 | == QStyleOptionToolButton::Menu)
|
|---|
| 2893 | rect.adjust(0, 0, -mbi, 0);
|
|---|
| 2894 | break;
|
|---|
| 2895 | case SC_ToolButtonMenu:
|
|---|
| 2896 | if ((toolButton->features
|
|---|
| 2897 | & (QStyleOptionToolButton::Menu | QStyleOptionToolButton::PopupDelay))
|
|---|
| 2898 | == QStyleOptionToolButton::Menu)
|
|---|
| 2899 | rect.adjust(rect.width() - mbi, 1, 0, 1);
|
|---|
| 2900 | break;
|
|---|
| 2901 | default:
|
|---|
| 2902 | break;
|
|---|
| 2903 | }
|
|---|
| 2904 | rect = visualRect(toolButton->direction, toolButton->rect, rect);
|
|---|
| 2905 | }
|
|---|
| 2906 | break;
|
|---|
| 2907 | #endif // QT_NO_TOOLBUTTON
|
|---|
| 2908 |
|
|---|
| 2909 | #ifndef QT_NO_SLIDER
|
|---|
| 2910 | case CC_Slider:
|
|---|
| 2911 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
|---|
| 2912 | int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget);
|
|---|
| 2913 | int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
|
|---|
| 2914 | switch (subControl) {
|
|---|
| 2915 | case SC_SliderHandle: {
|
|---|
| 2916 | int sliderPos = 0;
|
|---|
| 2917 | int len = pixelMetric(PM_SliderLength, slider, widget);
|
|---|
| 2918 | bool horizontal = slider->orientation == Qt::Horizontal;
|
|---|
| 2919 | sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
|
|---|
| 2920 | slider->sliderPosition,
|
|---|
| 2921 | (horizontal ? slider->rect.width()
|
|---|
| 2922 | : slider->rect.height()) - len,
|
|---|
| 2923 | slider->upsideDown);
|
|---|
| 2924 | if (horizontal)
|
|---|
| 2925 | rect.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
|
|---|
| 2926 | else
|
|---|
| 2927 | rect.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
|
|---|
| 2928 | break; }
|
|---|
| 2929 | default:
|
|---|
| 2930 | break;
|
|---|
| 2931 | }
|
|---|
| 2932 | rect = visualRect(slider->direction, slider->rect, rect);
|
|---|
| 2933 | }
|
|---|
| 2934 | break;
|
|---|
| 2935 | #endif //QT_NO_SLIDER
|
|---|
| 2936 | #ifndef QT_NO_COMBOBOX
|
|---|
| 2937 | case CC_ComboBox:
|
|---|
| 2938 | if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
|---|
| 2939 | int x = comboBox->rect.x(),
|
|---|
| 2940 | y = comboBox->rect.y(),
|
|---|
| 2941 | wi = comboBox->rect.width(),
|
|---|
| 2942 | he = comboBox->rect.height();
|
|---|
| 2943 | int xpos = x;
|
|---|
| 2944 | int margin = comboBox->frame ? (d->doubleControls ? 2 : 1) : 0;
|
|---|
| 2945 | int bmarg = comboBox->frame ? (d->doubleControls ? 2 : 1) : 0;
|
|---|
| 2946 | if (subControl == SC_ComboBoxArrow)
|
|---|
| 2947 | xpos += wi - int((he - 2*bmarg)*0.9) - bmarg;
|
|---|
| 2948 | else
|
|---|
| 2949 | xpos += wi - (he - 2*bmarg) - bmarg;
|
|---|
| 2950 | switch (subControl) {
|
|---|
| 2951 | case SC_ComboBoxArrow:
|
|---|
| 2952 | rect.setRect(xpos, y + bmarg, he - 2*bmarg, he - 2*bmarg);
|
|---|
| 2953 | rect.setRect(xpos, y + bmarg, int((he - 2*bmarg)), he - 2*bmarg);
|
|---|
| 2954 | break;
|
|---|
| 2955 | case SC_ComboBoxEditField:
|
|---|
| 2956 | rect.setRect(x + margin+4, y + margin+2, wi - 4 * margin - int((he - 2*bmarg) * 0.84f) -2, he - 2 * margin-4);
|
|---|
| 2957 | break;
|
|---|
| 2958 | case SC_ComboBoxFrame:
|
|---|
| 2959 | rect = comboBox->rect;
|
|---|
| 2960 | break;
|
|---|
| 2961 | default:
|
|---|
| 2962 | break;
|
|---|
| 2963 | }
|
|---|
| 2964 | }
|
|---|
| 2965 | #endif //QT_NO_COMBOBOX
|
|---|
| 2966 | #ifndef QT_NO_SPINBOX
|
|---|
| 2967 | case CC_SpinBox:
|
|---|
| 2968 | if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
|
|---|
| 2969 | QSize bs;
|
|---|
| 2970 | int fw = spinBox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinBox, widget) : 0;
|
|---|
| 2971 | bs.setHeight(qMax(d->doubleControls ? 28 : 14, (spinBox->rect.height())));
|
|---|
| 2972 | // 1.6 -approximate golden mean
|
|---|
| 2973 | bs.setWidth(qMax(d->doubleControls ? 28 : 14, qMin((bs.height()*7/8), (spinBox->rect.width() / 8))));
|
|---|
| 2974 | bs = bs.expandedTo(QApplication::globalStrut());
|
|---|
| 2975 | int x, lx, rx;
|
|---|
| 2976 | x = spinBox->rect.width() - bs.width()*2;
|
|---|
| 2977 | lx = fw;
|
|---|
| 2978 | rx = x - fw;
|
|---|
| 2979 | switch (subControl) {
|
|---|
| 2980 | case SC_SpinBoxUp:
|
|---|
| 2981 | rect = QRect(x+pixelMetric(PM_SpinBoxFrameWidth, option, widget), 0 , bs.width(), bs.height());
|
|---|
| 2982 | break;
|
|---|
| 2983 | case SC_SpinBoxDown:
|
|---|
| 2984 | rect = QRect(x + bs.width(), 0, bs.width(), bs.height());
|
|---|
| 2985 | break;
|
|---|
| 2986 | case SC_SpinBoxEditField:
|
|---|
| 2987 | rect = QRect(lx, fw, rx-2, spinBox->rect.height() - 2*fw);
|
|---|
| 2988 | break;
|
|---|
| 2989 | case SC_SpinBoxFrame:
|
|---|
| 2990 | rect = spinBox->rect;
|
|---|
| 2991 | default:
|
|---|
| 2992 | break;
|
|---|
| 2993 | }
|
|---|
| 2994 | rect = visualRect(spinBox->direction, spinBox->rect, rect);
|
|---|
| 2995 | }
|
|---|
| 2996 | break;
|
|---|
| 2997 | #endif // Qt_NO_SPINBOX
|
|---|
| 2998 | #ifndef QT_NO_GROUPBOX
|
|---|
| 2999 | case CC_GroupBox: {
|
|---|
| 3000 | if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
|
|---|
| 3001 | switch (subControl) {
|
|---|
| 3002 | case SC_GroupBoxFrame:
|
|---|
| 3003 | // FALL THROUGH
|
|---|
| 3004 | case SC_GroupBoxContents: {
|
|---|
| 3005 | int topMargin = 0;
|
|---|
| 3006 | int topHeight = 0;
|
|---|
| 3007 | int bottomMargin = 0;
|
|---|
| 3008 | int labelMargin = 2;
|
|---|
| 3009 |
|
|---|
| 3010 | QRect frameRect = groupBox->rect;
|
|---|
| 3011 | int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
|
|---|
| 3012 | if (groupBox->text.size()) {
|
|---|
| 3013 | topHeight = groupBox->fontMetrics.height();
|
|---|
| 3014 | if (verticalAlignment & Qt::AlignVCenter)
|
|---|
| 3015 | topMargin = topHeight+5;
|
|---|
| 3016 | else if (verticalAlignment & Qt::AlignTop)
|
|---|
| 3017 | topMargin = -topHeight+5;
|
|---|
| 3018 | }
|
|---|
| 3019 | if (subControl == SC_GroupBoxFrame) {
|
|---|
| 3020 | frameRect.setTop(topMargin);
|
|---|
| 3021 | frameRect.setBottom(frameRect.height() + bottomMargin);
|
|---|
| 3022 | rect = frameRect;
|
|---|
| 3023 | break;
|
|---|
| 3024 | }
|
|---|
| 3025 | int frameWidth = 0;
|
|---|
| 3026 | if (groupBox->text.size()) {
|
|---|
| 3027 | frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
|
|---|
| 3028 | rect = frameRect.adjusted(frameWidth, frameWidth + topHeight + labelMargin, -frameWidth, -frameWidth);
|
|---|
| 3029 | }
|
|---|
| 3030 | else {
|
|---|
| 3031 | rect = groupBox->rect;
|
|---|
| 3032 | }
|
|---|
| 3033 | break;
|
|---|
| 3034 | }
|
|---|
| 3035 | case SC_GroupBoxCheckBox:
|
|---|
| 3036 | // FALL THROUGH
|
|---|
| 3037 | case SC_GroupBoxLabel: {
|
|---|
| 3038 | QFontMetrics fontMetrics = groupBox->fontMetrics;
|
|---|
| 3039 | int h = fontMetrics.height();
|
|---|
| 3040 | int textWidth = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
|
|---|
| 3041 | int margX = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 2;
|
|---|
| 3042 | int margY = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 2;
|
|---|
| 3043 | rect = groupBox->rect.adjusted(margX, margY, -margX, 0);
|
|---|
| 3044 | if (groupBox->text.size())
|
|---|
| 3045 | rect.setHeight(h);
|
|---|
| 3046 | else
|
|---|
| 3047 | rect.setHeight(0);
|
|---|
| 3048 | int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget);
|
|---|
| 3049 | int indicatorSpace = pixelMetric(PM_CheckBoxLabelSpacing, option, widget) - 1;
|
|---|
| 3050 | bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
|
|---|
| 3051 | int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
|
|---|
| 3052 |
|
|---|
| 3053 | // Adjusted rect for label + indicatorWidth + indicatorSpace
|
|---|
| 3054 | QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
|
|---|
| 3055 | QSize(textWidth + checkBoxSize, h), rect);
|
|---|
| 3056 |
|
|---|
| 3057 | // Adjust totalRect if checkbox is set
|
|---|
| 3058 | if (hasCheckBox) {
|
|---|
| 3059 | bool ltr = groupBox->direction == Qt::LeftToRight;
|
|---|
| 3060 | int left = 2;
|
|---|
| 3061 | // Adjust for check box
|
|---|
| 3062 | if (subControl == SC_GroupBoxCheckBox) {
|
|---|
| 3063 | int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget);
|
|---|
| 3064 | left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
|
|---|
| 3065 | int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
|
|---|
| 3066 | totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
|
|---|
| 3067 | // Adjust for label
|
|---|
| 3068 | } else {
|
|---|
| 3069 | left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
|
|---|
| 3070 | totalRect.setRect(left, totalRect.top(),
|
|---|
| 3071 | totalRect.width() - checkBoxSize, totalRect.height());
|
|---|
| 3072 | }
|
|---|
| 3073 | }
|
|---|
| 3074 | if ((subControl== SC_GroupBoxLabel))
|
|---|
| 3075 | totalRect.adjust(-2,0,6,0);
|
|---|
| 3076 | rect = totalRect;
|
|---|
| 3077 | break;
|
|---|
| 3078 | }
|
|---|
| 3079 | default:
|
|---|
| 3080 | break;
|
|---|
| 3081 | }
|
|---|
| 3082 | }
|
|---|
| 3083 | break;
|
|---|
| 3084 | }
|
|---|
| 3085 | #endif // QT_NO_GROUPBOX
|
|---|
| 3086 | default:
|
|---|
| 3087 | break;
|
|---|
| 3088 | }
|
|---|
| 3089 | return rect;
|
|---|
| 3090 | }
|
|---|
| 3091 |
|
|---|
| 3092 | QPalette QWindowsMobileStyle::standardPalette() const {
|
|---|
| 3093 | QPalette palette (Qt::black,QColor(198, 195, 198), QColor(222, 223, 222 ),
|
|---|
| 3094 | QColor(132, 130, 132), QColor(198, 195, 198), Qt::black, Qt::white, Qt::white, QColor(198, 195, 198));
|
|---|
| 3095 | palette.setColor(QPalette::Window, QColor(206, 223, 239));
|
|---|
| 3096 | palette.setColor(QPalette::Link, QColor(8,77,123)); //Alternate TextColor for labels...
|
|---|
| 3097 | palette.setColor(QPalette::Base, Qt::white);
|
|---|
| 3098 | palette.setColor(QPalette::Button, QColor(206, 223, 239));
|
|---|
| 3099 | palette.setColor(QPalette::Highlight, QColor(49, 146, 214));
|
|---|
| 3100 | palette.setColor(QPalette::Light, Qt::white);
|
|---|
| 3101 | palette.setColor(QPalette::Text, Qt::black);
|
|---|
| 3102 | palette.setColor(QPalette::ButtonText, Qt::black);
|
|---|
| 3103 | palette.setColor(QPalette::Midlight, QColor(222, 223, 222 ));
|
|---|
| 3104 | palette.setColor(QPalette::Dark, QColor(132, 130, 132));
|
|---|
| 3105 | palette.setColor(QPalette::Mid, QColor(189, 190, 189));
|
|---|
| 3106 | palette.setColor(QPalette::Shadow, QColor(0, 0, 0));
|
|---|
| 3107 | palette.setColor(QPalette::BrightText, QColor(33, 162, 33)); //color for ItemView checked indicator (arrow)
|
|---|
| 3108 | return palette;
|
|---|
| 3109 | }
|
|---|
| 3110 |
|
|---|
| 3111 |
|
|---|
| 3112 | /*! \reimp */
|
|---|
| 3113 | void QWindowsMobileStyle::polish(QApplication *application) {
|
|---|
| 3114 | QWindowsStyle::polish(application);
|
|---|
| 3115 | }
|
|---|
| 3116 |
|
|---|
| 3117 | /*! \reimp */
|
|---|
| 3118 | void QWindowsMobileStyle::polish(QWidget *widget) {
|
|---|
| 3119 |
|
|---|
| 3120 | #ifndef QT_NO_TOOLBAR
|
|---|
| 3121 | if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
|
|---|
| 3122 | QPalette pal = toolBar->palette();
|
|---|
| 3123 | pal.setColor(QPalette::Background, pal.button().color());
|
|---|
| 3124 | toolBar->setPalette(pal);
|
|---|
| 3125 | }
|
|---|
| 3126 | else
|
|---|
| 3127 | #endif //QT_NO_TOOLBAR
|
|---|
| 3128 |
|
|---|
| 3129 | #ifndef QT_NO_PROPERTIES
|
|---|
| 3130 | if (QAbstractButton *pushButton = qobject_cast<QAbstractButton*>(widget)) {
|
|---|
| 3131 | QVariant oldFont = widget->property("_q_styleWindowsMobileFont");
|
|---|
| 3132 | if (!oldFont.isValid()) {
|
|---|
| 3133 | QFont f = pushButton->font();
|
|---|
| 3134 | widget->setProperty("_q_styleWindowsMobileFont", f);
|
|---|
| 3135 | f.setBold(true);
|
|---|
| 3136 | int p = f.pointSize();
|
|---|
| 3137 | if (p > 2)
|
|---|
| 3138 | f.setPointSize(p-1);
|
|---|
| 3139 | pushButton->setFont(f);
|
|---|
| 3140 | }
|
|---|
| 3141 | }
|
|---|
| 3142 | #endif
|
|---|
| 3143 | QWindowsStyle::polish(widget);
|
|---|
| 3144 | }
|
|---|
| 3145 |
|
|---|
| 3146 | void QWindowsMobileStyle::unpolish(QWidget *widget)
|
|---|
| 3147 | {
|
|---|
| 3148 | #ifndef QT_NO_PROPERTIES
|
|---|
| 3149 | if (QAbstractButton *pushButton = qobject_cast<QAbstractButton*>(widget)) {
|
|---|
| 3150 | QVariant oldFont = widget->property("_q_styleWindowsMobileFont");
|
|---|
| 3151 | if (oldFont.isValid()) {
|
|---|
| 3152 | widget->setFont(qVariantValue<QFont>(oldFont));
|
|---|
| 3153 | widget->setProperty("_q_styleWindowsMobileFont", QVariant());
|
|---|
| 3154 | }
|
|---|
| 3155 | }
|
|---|
| 3156 | #endif
|
|---|
| 3157 | QWindowsStyle::unpolish(widget);
|
|---|
| 3158 | }
|
|---|
| 3159 |
|
|---|
| 3160 | void QWindowsMobileStyle::unpolish(QApplication *app)
|
|---|
| 3161 | {
|
|---|
| 3162 | QWindowsStyle::unpolish(app);
|
|---|
| 3163 | }
|
|---|
| 3164 |
|
|---|
| 3165 | /*! \reimp */
|
|---|
| 3166 | void QWindowsMobileStyle::polish(QPalette &palette) {
|
|---|
| 3167 | QWindowsStyle::polish(palette);
|
|---|
| 3168 | }
|
|---|
| 3169 |
|
|---|
| 3170 | int QWindowsMobileStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const {
|
|---|
| 3171 |
|
|---|
| 3172 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 3173 | int ret;
|
|---|
| 3174 |
|
|---|
| 3175 | switch (pm) {
|
|---|
| 3176 | case PM_DefaultTopLevelMargin:
|
|---|
| 3177 | ret =0;
|
|---|
| 3178 | break;
|
|---|
| 3179 | case PM_DefaultLayoutSpacing:
|
|---|
| 3180 | d->doubleControls ? ret = 8 : ret = 4;
|
|---|
| 3181 | break;
|
|---|
| 3182 | case PM_HeaderMargin:
|
|---|
| 3183 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3184 | break;
|
|---|
| 3185 | case PM_DefaultChildMargin:
|
|---|
| 3186 | d->doubleControls ? ret = 10 : ret = 5;
|
|---|
| 3187 | break;
|
|---|
| 3188 | case PM_ToolBarSeparatorExtent:
|
|---|
| 3189 | d->doubleControls ? ret = 6 : ret = 3;
|
|---|
| 3190 | break;
|
|---|
| 3191 | case PM_DefaultFrameWidth:
|
|---|
| 3192 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3193 | break;
|
|---|
| 3194 | case PM_MenuVMargin:
|
|---|
| 3195 | ret = 1;
|
|---|
| 3196 | break;
|
|---|
| 3197 | case PM_MenuHMargin:
|
|---|
| 3198 | ret = 1;
|
|---|
| 3199 | break;
|
|---|
| 3200 | case PM_MenuButtonIndicator:
|
|---|
| 3201 | ret = d->doubleControls ? 24 : 14;
|
|---|
| 3202 | break;
|
|---|
| 3203 | case PM_ComboBoxFrameWidth:
|
|---|
| 3204 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3205 | break;
|
|---|
| 3206 | case PM_SpinBoxFrameWidth:
|
|---|
| 3207 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3208 | break;
|
|---|
| 3209 | case PM_ButtonDefaultIndicator:
|
|---|
| 3210 | case PM_ButtonShiftHorizontal:
|
|---|
| 3211 | case PM_ButtonShiftVertical:
|
|---|
| 3212 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3213 | break;
|
|---|
| 3214 | #ifndef QT_NO_TABBAR
|
|---|
| 3215 | case PM_TabBarTabShiftHorizontal:
|
|---|
| 3216 | ret = 0;
|
|---|
| 3217 | break;
|
|---|
| 3218 | case PM_TabBarTabShiftVertical:
|
|---|
| 3219 | ret = 0;
|
|---|
| 3220 | break;
|
|---|
| 3221 | #endif
|
|---|
| 3222 | case PM_MaximumDragDistance:
|
|---|
| 3223 | ret = 60;
|
|---|
| 3224 | break;
|
|---|
| 3225 | case PM_TabBarTabVSpace:
|
|---|
| 3226 | ret = d->doubleControls ? 12 : 6;
|
|---|
| 3227 | break;
|
|---|
| 3228 | case PM_TabBarBaseHeight:
|
|---|
| 3229 | ret = 0;
|
|---|
| 3230 | break;
|
|---|
| 3231 | case PM_IndicatorWidth:
|
|---|
| 3232 | ret = d->doubleControls ? windowsMobileIndicatorSize * 2 : windowsMobileIndicatorSize;
|
|---|
| 3233 | break;
|
|---|
| 3234 | case PM_IndicatorHeight:
|
|---|
| 3235 | ret = d->doubleControls ? windowsMobileIndicatorSize * 2 : windowsMobileIndicatorSize;
|
|---|
| 3236 | break;
|
|---|
| 3237 | case PM_ExclusiveIndicatorWidth:
|
|---|
| 3238 | ret = d->doubleControls ? windowsMobileExclusiveIndicatorSize * 2 + 4: windowsMobileExclusiveIndicatorSize + 2;
|
|---|
| 3239 | break;
|
|---|
| 3240 | case PM_ExclusiveIndicatorHeight:
|
|---|
| 3241 | ret = d->doubleControls ? windowsMobileExclusiveIndicatorSize * 2 + 4: windowsMobileExclusiveIndicatorSize + 2;
|
|---|
| 3242 | break;
|
|---|
| 3243 | #ifndef QT_NO_SLIDER
|
|---|
| 3244 | case PM_SliderLength:
|
|---|
| 3245 | ret = d->doubleControls ? 16 : 8;
|
|---|
| 3246 | break;
|
|---|
| 3247 | case PM_FocusFrameHMargin:
|
|---|
| 3248 | ret = d->doubleControls ? 1 : 2;
|
|---|
| 3249 | break;
|
|---|
| 3250 | case PM_SliderThickness:
|
|---|
| 3251 | ret = d->doubleControls ? windowsMobileSliderThickness * 2: windowsMobileSliderThickness;
|
|---|
| 3252 | break;
|
|---|
| 3253 | case PM_TabBarScrollButtonWidth:
|
|---|
| 3254 | ret = d->doubleControls ? 14 * 2 : 18;
|
|---|
| 3255 | case PM_CheckBoxLabelSpacing:
|
|---|
| 3256 | case PM_RadioButtonLabelSpacing:
|
|---|
| 3257 | ret = d->doubleControls ? 6 * 2 : 6;
|
|---|
| 3258 | break;
|
|---|
| 3259 | break;
|
|---|
| 3260 | // Returns the number of pixels to use for the business part of the
|
|---|
| 3261 | // slider (i.e., the non-tickmark portion). The remaining space is shared
|
|---|
| 3262 | // equally between the tickmark regions.
|
|---|
| 3263 | case PM_SliderControlThickness:
|
|---|
| 3264 | if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
|
|---|
| 3265 | int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
|
|---|
| 3266 | int ticks = sl->tickPosition;
|
|---|
| 3267 | int n = 0;
|
|---|
| 3268 | if (ticks & QSlider::TicksAbove)
|
|---|
| 3269 | ++n;
|
|---|
| 3270 | if (ticks & QSlider::TicksBelow)
|
|---|
| 3271 | ++n;
|
|---|
| 3272 | if (!n) {
|
|---|
| 3273 | ret = space;
|
|---|
| 3274 | break;
|
|---|
| 3275 | }
|
|---|
| 3276 | int thick = 8;
|
|---|
| 3277 | if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
|
|---|
| 3278 | thick += pixelMetric(PM_SliderLength, sl, widget) / 4;
|
|---|
| 3279 |
|
|---|
| 3280 | space -= thick;
|
|---|
| 3281 | if (space > 0)
|
|---|
| 3282 | thick += (space * 2) / (n + 2);
|
|---|
| 3283 | ret = thick;
|
|---|
| 3284 | } else {
|
|---|
| 3285 | ret = 0;
|
|---|
| 3286 | }
|
|---|
| 3287 | break;
|
|---|
| 3288 | #endif // QT_NO_SLIDER
|
|---|
| 3289 | #ifndef QT_NO_MENU
|
|---|
| 3290 | case PM_SmallIconSize:
|
|---|
| 3291 | d->doubleControls ? ret = windowsMobileIconSize * 2 : ret = windowsMobileIconSize;
|
|---|
| 3292 | break;
|
|---|
| 3293 | case PM_ButtonMargin:
|
|---|
| 3294 | d->doubleControls ? ret = 8 : ret = 4;
|
|---|
| 3295 | break;
|
|---|
| 3296 | case PM_LargeIconSize:
|
|---|
| 3297 | d->doubleControls ? ret = 64 : ret = 32;
|
|---|
| 3298 | break;
|
|---|
| 3299 | case PM_IconViewIconSize:
|
|---|
| 3300 | ret = pixelMetric(PM_LargeIconSize, opt, widget);
|
|---|
| 3301 | break;
|
|---|
| 3302 | case PM_ToolBarIconSize:
|
|---|
| 3303 | d->doubleControls ? ret = 2 * windowsMobileIconSize : ret = windowsMobileIconSize;
|
|---|
| 3304 | break;
|
|---|
| 3305 | case PM_DockWidgetTitleMargin:
|
|---|
| 3306 | ret = 2;
|
|---|
| 3307 | break;
|
|---|
| 3308 | #if defined(Q_WS_WIN)
|
|---|
| 3309 | #else
|
|---|
| 3310 | case PM_DockWidgetFrameWidth:
|
|---|
| 3311 | ret = 4;
|
|---|
| 3312 | break;
|
|---|
| 3313 | #endif // Q_WS_WIN
|
|---|
| 3314 | break;
|
|---|
| 3315 | #endif // QT_NO_MENU
|
|---|
| 3316 |
|
|---|
| 3317 | case PM_TitleBarHeight:
|
|---|
| 3318 | d->doubleControls ? ret = 42 : ret = 21;
|
|---|
| 3319 | break;
|
|---|
| 3320 | case PM_ScrollBarSliderMin:
|
|---|
| 3321 | d->doubleControls ? ret = 36 : ret = 18;
|
|---|
| 3322 | break;
|
|---|
| 3323 | case PM_ScrollBarExtent: {
|
|---|
| 3324 | //Check if the scrollbar is part of an abstractItemView and set size according
|
|---|
| 3325 | if (d->smartphone)
|
|---|
| 3326 | ret = 9;
|
|---|
| 3327 | else
|
|---|
| 3328 | d->doubleControls ? ret = 25 : ret = 13;
|
|---|
| 3329 | #ifndef QT_NO_SCROLLAREA
|
|---|
| 3330 | if (widget)
|
|---|
| 3331 | if (QWidget *parent = widget->parentWidget())
|
|---|
| 3332 | if (qobject_cast<QAbstractScrollArea *>(parent->parentWidget()))
|
|---|
| 3333 | if (d->smartphone)
|
|---|
| 3334 | ret = 8;
|
|---|
| 3335 | else
|
|---|
| 3336 | d->doubleControls ? ret = 24 : ret = 12;
|
|---|
| 3337 | #endif
|
|---|
| 3338 | }
|
|---|
| 3339 | break;
|
|---|
| 3340 | case PM_SplitterWidth:
|
|---|
| 3341 | ret = qMax(4, QApplication::globalStrut().width());
|
|---|
| 3342 | break;
|
|---|
| 3343 |
|
|---|
| 3344 | #if defined(Q_WS_WIN)
|
|---|
| 3345 | case PM_MDIFrameWidth:
|
|---|
| 3346 | ret = 1;
|
|---|
| 3347 | break;
|
|---|
| 3348 | #endif
|
|---|
| 3349 | case PM_ToolBarExtensionExtent:
|
|---|
| 3350 | d->doubleControls ? ret = 32 : ret = 16;
|
|---|
| 3351 | break;
|
|---|
| 3352 | case PM_ToolBarItemMargin:
|
|---|
| 3353 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3354 | break;
|
|---|
| 3355 | case PM_ToolBarItemSpacing:
|
|---|
| 3356 | d->doubleControls ? ret = 2 : ret = 1;
|
|---|
| 3357 | break;
|
|---|
| 3358 | case PM_ToolBarHandleExtent:
|
|---|
| 3359 | d->doubleControls ? ret = 16 : ret = 8;
|
|---|
| 3360 | break;
|
|---|
| 3361 | case PM_ButtonIconSize:
|
|---|
| 3362 | d->doubleControls ? ret = 32 : ret = 16;
|
|---|
| 3363 | break;
|
|---|
| 3364 | case PM_TextCursorWidth:
|
|---|
| 3365 | ret = 2;
|
|---|
| 3366 | break;
|
|---|
| 3367 | case PM_TabBar_ScrollButtonOverlap:
|
|---|
| 3368 | ret = 0;
|
|---|
| 3369 | break;
|
|---|
| 3370 | default:
|
|---|
| 3371 | ret = QWindowsStyle::pixelMetric(pm, opt, widget);
|
|---|
| 3372 | break;
|
|---|
| 3373 | }
|
|---|
| 3374 | return ret;
|
|---|
| 3375 | }
|
|---|
| 3376 |
|
|---|
| 3377 | int QWindowsMobileStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
|
|---|
| 3378 | QStyleHintReturn *returnData) const {
|
|---|
| 3379 |
|
|---|
| 3380 | int ret;
|
|---|
| 3381 | switch (hint) {
|
|---|
| 3382 | case SH_Menu_MouseTracking:
|
|---|
| 3383 | case SH_ComboBox_ListMouseTracking:
|
|---|
| 3384 | case SH_EtchDisabledText:
|
|---|
| 3385 | ret = 0;
|
|---|
| 3386 | break;
|
|---|
| 3387 | case SH_DitherDisabledText:
|
|---|
| 3388 | ret = 0;
|
|---|
| 3389 | break;
|
|---|
| 3390 | case SH_ItemView_ShowDecorationSelected:
|
|---|
| 3391 | ret = 0;
|
|---|
| 3392 | break;
|
|---|
| 3393 | #ifndef QT_NO_TABWIDGET
|
|---|
| 3394 | case SH_TabWidget_DefaultTabPosition:
|
|---|
| 3395 | ret = QTabWidget::South;
|
|---|
| 3396 | break;
|
|---|
| 3397 | #endif
|
|---|
| 3398 | case SH_ToolBar_Movable:
|
|---|
| 3399 | ret = false;
|
|---|
| 3400 | break;
|
|---|
| 3401 | case SH_ScrollBar_ContextMenu:
|
|---|
| 3402 | ret = false;
|
|---|
| 3403 | break;
|
|---|
| 3404 | default:
|
|---|
| 3405 | ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
|
|---|
| 3406 | break;
|
|---|
| 3407 | }
|
|---|
| 3408 | return ret;
|
|---|
| 3409 | }
|
|---|
| 3410 |
|
|---|
| 3411 | QPixmap QWindowsMobileStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
|
|---|
| 3412 | const QWidget *widget) const {
|
|---|
| 3413 |
|
|---|
| 3414 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 3415 | switch (sp) {
|
|---|
| 3416 | #ifndef QT_NO_IMAGEFORMAT_XPM
|
|---|
| 3417 | case SP_ToolBarHorizontalExtensionButton: {
|
|---|
| 3418 | QPixmap pixmap = QCommonStyle::standardPixmap(sp, option, widget);
|
|---|
| 3419 | if (d->doubleControls)
|
|---|
| 3420 | return pixmap.scaledToHeight(pixmap.height() * 2);
|
|---|
| 3421 | else
|
|---|
| 3422 | return pixmap;
|
|---|
| 3423 | }
|
|---|
| 3424 | case SP_TitleBarMaxButton:
|
|---|
| 3425 | case SP_TitleBarCloseButton:
|
|---|
| 3426 | case SP_TitleBarNormalButton:
|
|---|
| 3427 | case SP_TitleBarMinButton: {
|
|---|
| 3428 | QImage image;
|
|---|
| 3429 | switch (sp) {
|
|---|
| 3430 | case SP_TitleBarMaxButton:
|
|---|
| 3431 | image = d->imageMaximize;
|
|---|
| 3432 | break;
|
|---|
| 3433 | case SP_TitleBarCloseButton:
|
|---|
| 3434 | image = d->imageClose;
|
|---|
| 3435 | break;
|
|---|
| 3436 | case SP_TitleBarNormalButton:
|
|---|
| 3437 | image = d->imageNormalize;
|
|---|
| 3438 | break;
|
|---|
| 3439 | case SP_TitleBarMinButton:
|
|---|
| 3440 | image = d->imageMinimize;
|
|---|
| 3441 | break;
|
|---|
| 3442 | default:
|
|---|
| 3443 | break;
|
|---|
| 3444 | }
|
|---|
| 3445 | if (option) {
|
|---|
| 3446 | image.setColor(0, option->palette.shadow().color().rgba());
|
|---|
| 3447 | image.setColor(1, option->palette.highlight().color().rgba());
|
|---|
| 3448 | image.setColor(2, option->palette.highlight().color().lighter(150).rgba());
|
|---|
| 3449 | image.setColor(3, option->palette.highlightedText().color().rgba());
|
|---|
| 3450 | }
|
|---|
| 3451 |
|
|---|
| 3452 | return QPixmap::fromImage(image);
|
|---|
| 3453 | }
|
|---|
| 3454 |
|
|---|
| 3455 | #endif
|
|---|
| 3456 | default:
|
|---|
| 3457 | return QWindowsStyle::standardPixmap(sp, option, widget);
|
|---|
| 3458 | }
|
|---|
| 3459 | }
|
|---|
| 3460 |
|
|---|
| 3461 | QPixmap QWindowsMobileStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
|
|---|
| 3462 | const QStyleOption *option) const {
|
|---|
| 3463 |
|
|---|
| 3464 | switch (iconMode) {
|
|---|
| 3465 | case QIcon::Selected: {
|
|---|
| 3466 | QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
|
|---|
| 3467 | int imgh = img.height();
|
|---|
| 3468 | int imgw = img.width();
|
|---|
| 3469 | for (int y = 0; y < imgh; y += 2) {
|
|---|
| 3470 | for (int x = 0; x < imgw; x += 2) {
|
|---|
| 3471 | QColor c = option->palette.highlight().color().rgb();
|
|---|
| 3472 | c.setAlpha( qAlpha(img.pixel(x, y)));
|
|---|
| 3473 | QRgb pixel = c.rgba();
|
|---|
| 3474 | img.setPixel(x, y, pixel);
|
|---|
| 3475 | }
|
|---|
| 3476 | }
|
|---|
| 3477 | return QPixmap::fromImage(img);
|
|---|
| 3478 | }
|
|---|
| 3479 | default:
|
|---|
| 3480 | break;
|
|---|
| 3481 | }
|
|---|
| 3482 | return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, option);
|
|---|
| 3483 | }
|
|---|
| 3484 |
|
|---|
| 3485 |
|
|---|
| 3486 | bool QWindowsMobileStyle::doubleControls() const {
|
|---|
| 3487 |
|
|---|
| 3488 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 3489 |
|
|---|
| 3490 | return d->doubleControls;
|
|---|
| 3491 | }
|
|---|
| 3492 |
|
|---|
| 3493 | void QWindowsMobileStyle::setDoubleControls(bool doubleControls) {
|
|---|
| 3494 |
|
|---|
| 3495 | QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
|
|---|
| 3496 |
|
|---|
| 3497 | d->doubleControls = doubleControls;
|
|---|
| 3498 | }
|
|---|
| 3499 |
|
|---|
| 3500 | QT_END_NAMESPACE
|
|---|
| 3501 |
|
|---|
| 3502 | #endif // QT_NO_STYLE_WINDOWSMOBILE
|
|---|
| 3503 |
|
|---|