Class: IconPreviewArea
- Inherits:
-
Qt::Widget
show all
- Defined in:
- ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb
Overview
** ** Copyright © 2004-2005 Trolltech AS. All rights reserved. ** ** This file is part of the example classes of the Qt Toolkit. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** self file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** www.trolltech.com/products/qt/opensource.html ** ** If you are unsure which license is appropriate for your use, please ** review the following information: ** www.trolltech.com/products/qt/licensing.html or contact the ** sales department at [email protected]. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. **
** Translated to QtRuby by Richard Dale
Constant Summary
collapse
- NumModes =
3
- NumStates =
2
Instance Method Summary
collapse
Methods inherited from Qt::Widget
#raise
Methods inherited from Qt::Base
#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~
Constructor Details
Returns a new instance of IconPreviewArea.
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb', line 31
def initialize(parent = nil)
super(parent)
mainLayout = Qt::GridLayout.new
setLayout(mainLayout)
stateLabels = []
stateLabels[0] = (tr("Off"))
stateLabels[1] = (tr("On"))
modeLabels = []
modeLabels[0] = (tr("Normal"))
modeLabels[1] = (tr("Active"))
modeLabels[2] = (tr("Disabled"))
(0...NumStates).each do |j|
mainLayout.addWidget(stateLabels[j], j + 1, 0)
end
@pixmapLabels = []
(0...NumModes).each do |i|
mainLayout.addWidget(modeLabels[i], 0, i + 1)
@pixmapLabels[i] = []
(0...NumStates).each do |j|
@pixmapLabels[i][j] = createPixmapLabel()
mainLayout.addWidget(@pixmapLabels[i][j], j + 1, i + 1)
end
end
@size = Qt::Size.new
@icon = Qt::Icon.new
end
|
Instance Method Details
76
77
78
79
80
|
# File 'ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb', line 76
def (text)
label = Qt::Label.new(tr("<b>%s</b>" % text))
label.alignment = Qt::AlignCenter.to_i
return label
end
|
#createPixmapLabel ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb', line 82
def createPixmapLabel()
label = Qt::Label.new
label.enabled = false
label.alignment = Qt::AlignCenter.to_i
label.frameShape = Qt::Frame::Box
label.setSizePolicy(Qt::SizePolicy::Expanding, Qt::SizePolicy::Expanding)
label.backgroundRole = Qt::Palette::Base
label.setMinimumSize(132, 132)
return label
end
|
#icon=(icon) ⇒ Object
64
65
66
67
|
# File 'ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb', line 64
def icon=(icon)
@icon = icon
updatePixmapLabels()
end
|
#size=(size) ⇒ Object
69
70
71
72
73
74
|
# File 'ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb', line 69
def size=(size)
if size != @size
@size = size
updatePixmapLabels()
end
end
|
#updatePixmapLabels ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'ext/ruby/qtruby/examples/widgets/icons/iconpreviewarea.rb', line 93
def updatePixmapLabels()
(0...NumModes).each do |i|
if i == 0
mode = Qt::Icon::Normal
elsif i == 1
mode = Qt::Icon::Active
else
mode = Qt::Icon::Disabled
end
(0...NumStates).each do |j|
state = (j == 0) ? Qt::Icon::Off : Qt::Icon::On
pixmap = @icon.pixmap(@size, mode, state)
@pixmapLabels[i][j].pixmap = pixmap
@pixmapLabels[i][j].enabled = !pixmap.nil?
end
end
end
|