| 1 | #cxx . . $ `<file>/src/FlagsViewer.cpp`/include "FlagsViewer.h"cxx . . $ `<file>/src/FlagsViewer.h`/ |
| 2 | #include <QPainter> |
| 3 | #include <QPaintEvent> |
| 4 | |
| 5 | |
| 6 | FlagsViewercxx . . $ FlagsViewer#::FlagsViewercxx . . $ FlagsViewer#FlagsViewer(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) |
| 7 | : QFramecxx . . $ QFrame#(parent) |
| 8 | { |
| 9 | flagscxx . . $ FlagsViewer#flags. = flagsChangedcxx . . $ FlagsViewer#flagsChanged. = 0; // avoid UMR |
| 10 | |
| 11 | setFrameStylecxx . . $ QFrame#setFrameStyle(d4f767463ce0a6b3).(WinPanelcxx . . $ QFrame#WinPanel. |cxx . . $ `operator|`(44af6e16e9fc6bb). Sunkencxx . . $ QFrame#Sunken.); |
| 12 | setFocusPolicycxx . . $ QWidget#setFocusPolicy(84f385f4ea7c1696).(Qtcxx . . $ Qt/::StrongFocuscxx . . $ Qt/StrongFocus.); |
| 13 | setBackgroundRolecxx . . $ QWidget#setBackgroundRole(656661f550a99654).(QPalettecxx . . $ QPalette#::Basecxx . . $ QPalette#Base.); |
| 14 | setSizePolicycxx . . $ QWidget#setSizePolicy(41340f53ecd443dd).(QSizePolicycxx . . $ QSizePolicy#QSizePolicy(dc90913e2b9d0ddb).(QSizePolicycxx . . $ QSizePolicy#::Fixedcxx . . $ QSizePolicy#Fixed., QSizePolicycxx . . $ QSizePolicy#::Fixedcxx . . $ QSizePolicy#Fixed.)); |
| 15 | |
| 16 | frameRcxx . . $ FlagsViewer#frameR. = frameLcxx . . $ FlagsViewer#frameL. = frameTcxx . . $ FlagsViewer#frameT. = frameBcxx . . $ FlagsViewer#frameB. = frameWidthcxx . . $ QFrame#frameWidth(455f465bc33b4cdf).(); |
| 17 | } |
| 18 | |
| 19 | void FlagsViewercxx . . $ FlagsViewer#::resizeEventcxx . . $ FlagsViewer#resizeEvent(eeeec21cf8dc0387).(QResizeEventcxx . . $ QResizeEvent#* e) |
| 20 | { |
| 21 | QFramecxx . . $ QFrame#::resizeEventcxx . . $ QWidget#resizeEvent(eeeec21cf8dc0387).(e); |
| 22 | } |
| 23 | |
| 24 | void FlagsViewercxx . . $ FlagsViewer#::paintEventcxx . . $ FlagsViewer#paintEvent(f239c9e85d61a220).(QPaintEventcxx . . $ QPaintEvent#* e) |
| 25 | { |
| 26 | const char* const flagNames[8] = |
| 27 | { "C" , "N", "P" , "", "H", "", "Z" , "S" }; |
| 28 | const char* const flagOn[8] = |
| 29 | { "(C)" , "" , "(PE)", "", "", "", "(Z)" , "(M)" }; |
| 30 | const char* const flagOff[8] = |
| 31 | { "(NC)", "" , "(PO)", "", "", "", "(NZ)", "(P)" }; |
| 32 | |
| 33 | // call parent for drawing the actual frame |
| 34 | QFramecxx . . $ QFrame#::paintEventcxx . . $ QFrame#paintEvent(f239c9e85d61a220).(e); |
| 35 | |
| 36 | QPaintercxx . . $ QPainter# pcxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(this); |
| 37 | p.setPencxx . . $ QPainter#setPen(129a55e114526ad3).(palettecxx . . $ QWidget#palette(a7bd6a16d2c88209).().colorcxx . . $ QPalette#color(a08a5ea14130e12).(QPalettecxx . . $ QPalette#::Textcxx . . $ QPalette#Text.)); |
| 38 | |
| 39 | // calc and set drawing bounds |
| 40 | QRectcxx . . $ QRect# r(e->rectcxx . . $ QPaintEvent#rect(f4023511c62cad66).()); |
| 41 | if (r.leftcxx . . $ QRect#left(ea6fe5115c70a13f).() < frameLcxx . . $ FlagsViewer#frameL.) r.setLeftcxx . . $ QRect#setLeft(f349c77f591a7878).(frameLcxx . . $ FlagsViewer#frameL.); |
| 42 | if (r.topcxx . . $ QRect#top(ea6fe5115c70a13f).() < frameTcxx . . $ FlagsViewer#frameT.) r.setTopcxx . . $ QRect#setTop(f349c77f591a7878). (frameTcxx . . $ FlagsViewer#frameT.); |
| 43 | if (r.rightcxx . . $ QRect#right(ea6fe5115c70a13f).() > widthcxx . . $ QWidget#width(455f465bc33b4cdf).() - frameRcxx . . $ FlagsViewer#frameR. - 1) r.setRightcxx . . $ QRect#setRight(f349c77f591a7878). (widthcxx . . $ QWidget#width(455f465bc33b4cdf).() - frameRcxx . . $ FlagsViewer#frameR. - 1); |
| 44 | if (r.bottomcxx . . $ QRect#bottom(ea6fe5115c70a13f).() > heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - frameBcxx . . $ FlagsViewer#frameB. - 1) r.setBottomcxx . . $ QRect#setBottom(f349c77f591a7878).(heightcxx . . $ QWidget#height(455f465bc33b4cdf).() - frameBcxx . . $ FlagsViewer#frameB. - 1); |
| 45 | p.setClipRectcxx . . $ QPainter#setClipRect(2f5004bd5eb598d2).(r); |
| 46 | |
| 47 | // redraw background |
| 48 | p.fillRectcxx . . $ QPainter#fillRect(b5c43933f089f858).(r, palettecxx . . $ QWidget#palette(a7bd6a16d2c88209).().colorcxx . . $ QPalette#color(a08a5ea14130e12).(QPalettecxx . . $ QPalette#::Basecxx . . $ QPalette#Base.)); |
| 49 | |
| 50 | int h = fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).(); |
| 51 | int flagWidth = fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().horizontalAdvancecxx . . $ QFontMetrics#horizontalAdvance(91f46685ef4c12b5).("ZW"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 52 | int valWidth = fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().horizontalAdvancecxx . . $ QFontMetrics#horizontalAdvance(91f46685ef4c12b5).("0 "cxx . . $ QString#QString(85c52e162fed56f9).); |
| 53 | int d = fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().descentcxx . . $ QFontMetrics#descent(455f465bc33b4cdf).(); |
| 54 | int y = frameTcxx . . $ FlagsViewer#frameT. + h - 1 - d; |
| 55 | for (int flag = 7; flag >= 0; --flag) { |
| 56 | int x = frameLcxx . . $ FlagsViewer#frameL. + 4; |
| 57 | p.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(x, y, flagNamescxx . . $ QString#QString(85c52e162fed56f9).[flag]); |
| 58 | x += flagWidth; |
| 59 | int bit = 1 << flag; |
| 60 | drawValuecxx . . $ FlagsViewer#drawValue(29641a206c80c394).(p, x, y, (cxx . . $ QString#QString(85c52e162fed56f9).flagscxx . . $ FlagsViewer#flags. & bit) ? "1" : "0", flagsChangedcxx . . $ FlagsViewer#flagsChanged. & bit); |
| 61 | x += valWidth; |
| 62 | p.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(x, y, (cxx . . $ QString#QString(85c52e162fed56f9).flagscxx . . $ FlagsViewer#flags. & bit) ? flagOn[flag] : flagOff[flag]); |
| 63 | y += h; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | QSizecxx . . $ QSize# FlagsViewercxx . . $ FlagsViewer#::sizeHintcxx . . $ FlagsViewer#sizeHint(4b3b776e5ee2b367).() const |
| 68 | { |
| 69 | return {cxx . . $ QSize#QSize(c0d38f4800714fae).frameLcxx . . $ FlagsViewer#frameL. + 4 + fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().horizontalAdvancecxx . . $ QFontMetrics#horizontalAdvance(91f46685ef4c12b5).("ZW0 (PE) "cxx . . $ QString#QString(85c52e162fed56f9).) + 4 + frameRcxx . . $ FlagsViewer#frameR., |
| 70 | frameTcxx . . $ FlagsViewer#frameT. + 8 * fontMetricscxx . . $ QWidget#fontMetrics(ee264e9e8967f9a7).().heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).() + frameBcxx . . $ FlagsViewer#frameB.}; |
| 71 | } |
| 72 | |
| 73 | void FlagsViewercxx . . $ FlagsViewer#::drawValuecxx . . $ FlagsViewer#drawValue(29641a206c80c394).(QPaintercxx . . $ QPainter#& p, int x, int y, const QStringcxx . . $ QString#& str, |
| 74 | bool changed) |
| 75 | { |
| 76 | if (changed) { |
| 77 | p.setPencxx . . $ QPainter#setPen(129a55e114526ad3).(Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::redcxx . . $ Qt/red.); |
| 78 | } |
| 79 | p.drawTextcxx . . $ QPainter#drawText(c89d651b24440698).(x, y, str); |
| 80 | if (changed) { |
| 81 | p.setPencxx . . $ QPainter#setPen(129a55e114526ad3).(palettecxx . . $ QWidget#palette(a7bd6a16d2c88209).().colorcxx . . $ QPalette#color(a08a5ea14130e12).(QPalettecxx . . $ QPalette#::Textcxx . . $ QPalette#Text.)); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | void FlagsViewercxx . . $ FlagsViewer#::setFlagscxx . . $ FlagsViewer#setFlags(ac50b47256ae7414).(quint8cxx . . $ quint8# newFlags) |
| 86 | { |
| 87 | flagsChangedcxx . . $ FlagsViewer#flagsChanged. = flagscxx . . $ FlagsViewer#flags. ^ newFlags; |
| 88 | flagscxx . . $ FlagsViewer#flags. = newFlags; |
| 89 | updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).(); |
| 90 | } |