Class: Studium::GUI::Gtk::Frame
- Inherits:
-
Gtk::Frame
- Object
- Gtk::Frame
- Studium::GUI::Gtk::Frame
show all
- Includes:
- Gtk::BaseModule, Colours
- Defined in:
- lib/studium/gui/gtk2/frame.rb
Overview
Constant Summary
collapse
- CLOSE_TAB_ON_RIGHTCLICK =
#
CLOSE_TAB_ON_RIGHTCLICK
If the following constant is true then we will close on right-button click.
#
true
Constants included
from Colours
Colours::COLOURS
Instance Method Summary
collapse
Methods included from Colours
#bold_blue, #bold_red, #bold_yellow, #cadetblue, #chartreuse, crimson, #darkgray, darkgreen, darkseagreen, deepskyblue, #deepskyblue, default_colour, #dimgray, disable_colours, #dodgerblue, e, #efancy, enable_colours, #ewarn, #forestgreen, gold, #grey, lightblue, lightgreen, #lightslategray, #lightsteelblue, #mediumorchid, #mediumseagreen, #oldlace, #olivedrab, orange, orangered, #orchid, palevioletred, #papayawhip, rev, royalblue, sdir, #sdir, sfancy, #sfancy, sfile, #sfile, simp, #simp, slateblue, steelblue, #steelblue, #swarn, swarn, #teal, turquoise, use_colours?, use_this_colour_for_exam_answers, use_this_colour_for_exam_questions, #yellow
Constructor Details
#initialize(use_this_for_the_child_widget = ::Studium::GUI::Gtk::VBox.new(self)) ⇒ Frame
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/studium/gui/gtk2/frame.rb', line 51
def initialize(
use_this_for_the_child_widget = ::Studium::GUI::Gtk::VBox.new(self)
)
super(title?)
@child = use_this_for_the_child_widget add_notebook
title = 'Prüfungsfragen'
label = ::Gtk::Label.new.set_markup(
%Q(<span weight="bold">#{title}</span>)
)
@notebook.set_tab_label(@child, label)
@label_2 = gtk_label('(Waiting for Input)')
@frame = gtk_frame('Misc')
@label_3 = gtk_label(return_how_many_questions_were_already_solved)
@vbox_for_second_frame = ::Gtk.create_vbox
@vbox_for_second_frame.add @label_3
@frame.add(@vbox_for_second_frame)
try_to_add_a_clock @frame.show_all
@notebook.append_page(@frame, @label_2)
@notebook.set_tab_reorderable(@frame, true)
@label_4 = gtk_label('Misc')
another_frame = gtk_frame
another_vbox = gtk_vbox
combo_box = ::Gtk::ComboBox.new(true)
::Studium.available_topics?.each {|val|
combo_box.append_text(val.to_s.tr('_',' ').capitalize)
}
combo_box.active = 0
another_vbox.add(combo_box)
@button_check_reveal_answer_after_a_delay = ::Gtk::CheckButton.new(
'Reveal Answer after a delay', false
)
modify_frame
@button_check_reveal_answer_after_a_delay.set_active(false)
name_tip = 'This check-button, when checked, will reveal '+
'the answer to the question after a delay of 6 seconds.'
::Gtk.set_tooltip_for(@button_check_reveal_answer_after_a_delay, name_tip)
hbox = ::Gtk.create_hbox
hbox.add @button_check_reveal_answer_after_a_delay
hbox.add gtk_label(
'We have n questions available in total: '+
n_questions_in_total?.to_s
)
another_vbox.pack_start(hbox, false, false, 0)
another_frame.add(another_vbox)
@notebook.append_page(another_frame, @label_4)
@notebook.set_tab_reorderable(another_frame, true)
@textarea_for_statistics = ::Gtk.return_textarea
scroll_widget = ::Gtk.return_scrolled_window(@textarea_for_statistics)
scroll_widget.set_policy(::Gtk::POLICY_NEVER, ::Gtk::POLICY_ALWAYS)
@label_statistics = gtk_label('Statistics')
@notebook.append_page(scroll_widget, @label_statistics)
@notebook.signal_connect(:event) { |widget, event|
if event.event_type.name == 'GDK_BUTTON_PRESS'
if (event.button == 2) and @label_statistics.text == 'Statistics'
update_statistics_tab
end
end
}
@notebook.set_tab_reorderable(scroll_widget, true)
update_statistics_tab
label_ten_questions = gtk_label('Top 10 questions')
require 'roebe/gui/gtk/show_ten_aliases/show_ten_aliases.rb'
show_ten_aliases = ::Gtk::ShowTenAliases.new
@notebook.append_page(show_ten_aliases, label_ten_questions)
@notebook.set_tab_reorderable(show_ten_aliases, true)
add(@notebook)
show_all
end
|
Instance Method Details
#add_notebook ⇒ Object
#
add_notebook (notebook tag)
We make use of Gtk::Notebook to put down our widgets.
#
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
|
# File 'lib/studium/gui/gtk2/frame.rb', line 275
def add_notebook
@notebook = ::Gtk::Notebook.new
@notebook.scrollable = true
@notebook.show_border = true
@notebook.modify_bg(::Gtk::STATE_NORMAL,
Gdk::Color.parse('#cbcbcb')) @notebook.add @child
@notebook.set_tab_reorderable(@child, true)
if CLOSE_TAB_ON_RIGHTCLICK
@notebook.signal_connect(:event) { |widget, event|
_ = event.event_type.name
case _
when 'GDK_BUTTON_PRESS'
if event.button == 3 current_tab = @notebook.page
@notebook.remove_page(current_tab)
end
end
}
end
end
|
174
175
176
|
# File 'lib/studium/gui/gtk2/frame.rb', line 174
def check_button_reveal_answer_after_a_delay?
@button_check_reveal_answer_after_a_delay
end
|
#child? ⇒ Boolean
Also known as:
child
#
child?
Contains the GtkExams widget.
#
211
212
213
|
# File 'lib/studium/gui/gtk2/frame.rb', line 211
def child?
@child
end
|
#frame? ⇒ Boolean
Also known as:
frame
188
189
190
|
# File 'lib/studium/gui/gtk2/frame.rb', line 188
def frame?
@frame
end
|
#height? ⇒ Boolean
324
325
326
|
# File 'lib/studium/gui/gtk2/frame.rb', line 324
def height?
800
end
|
#label? ⇒ Boolean
195
196
197
|
# File 'lib/studium/gui/gtk2/frame.rb', line 195
def label?
@label_3
end
|
#modify_frame ⇒ Object
218
219
220
221
222
223
|
# File 'lib/studium/gui/gtk2/frame.rb', line 218
def modify_frame
markup = %Q(
<span size="xx-large" weight="bold" foreground="#665200"> #{title?} </span>
)
label_widget.set_markup(markup)
end
|
#n_questions_in_total? ⇒ Boolean
#
n_questions_in_total?
#
#notebook? ⇒ Boolean
Also known as:
notebook
181
182
183
|
# File 'lib/studium/gui/gtk2/frame.rb', line 181
def notebook?
@notebook
end
|
#return_how_many_questions_were_already_solved ⇒ Object
#
return_how_many_questions_were_already_solved
This is the method that will be used to tell us how many questions were already solved, in total.
#
#set_n_exam_questions(i = '10', n_of_them_are_answered = nil) ⇒ Object
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
# File 'lib/studium/gui/gtk2/frame.rb', line 228
def set_n_exam_questions(
i = '10',
n_of_them_are_answered = nil
)
i = i.to_s+' Questions are available'
if n_of_them_are_answered
i << ' / '+n_of_them_are_answered.to_s+' of them are already answered'
percentage = (n_of_them_are_answered.to_f * 100) / i.to_i
percentage = ' '+(percentage.round(2)).to_s+'%'
i << '<span foreground="red">'+percentage+'</span>'
end
@label_2.set_markup(
%Q(<span size="xx-small" weight="bold">#{i}</span>)
)
end
|
#title? ⇒ Boolean
160
161
162
|
# File 'lib/studium/gui/gtk2/frame.rb', line 160
def title?
Gtk.title?
end
|
#try_to_add_a_clock ⇒ Object
262
263
264
265
266
267
268
|
# File 'lib/studium/gui/gtk2/frame.rb', line 262
def try_to_add_a_clock
begin
require 'x/GUI/gtk/clock/simple_clock.rb'
clock = SimpleClock.new
@vbox_for_second_frame.pack_start(clock, false, true, 2)
rescue LoadError; end
end
|
#update_label_showing_how_many_exams_were_already_answered ⇒ Object
#
update_label_showing_how_many_exams_were_already_answered
#
202
203
204
|
# File 'lib/studium/gui/gtk2/frame.rb', line 202
def update_label_showing_how_many_exams_were_already_answered
label?.set_text(return_how_many_questions_were_already_solved)
end
|
#update_statistics_tab ⇒ Object
#
update_statistics_tab
#
303
304
305
306
307
308
309
310
311
312
|
# File 'lib/studium/gui/gtk2/frame.rb', line 303
def update_statistics_tab
@stats_object = Studium::Statistics::ReportHowManyExamQuestionsWereAnswered.new(
'be_quiet_and_no_colours'
)
_ = @stats_object.text?
@textarea_for_statistics.buffer.set_text(_)
end
|
#width? ⇒ Boolean
317
318
319
|
# File 'lib/studium/gui/gtk2/frame.rb', line 317
def width?
1000
end
|