blue_shoes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +29 -0
- data/LICENSE +20 -0
- data/README.md +74 -0
- data/Rakefile +17 -0
- data/blue_shoes.gemspec +20 -0
- data/lib/blue_shoes/app.rb +777 -0
- data/lib/blue_shoes/canvas.rb +4 -0
- data/lib/blue_shoes/color.rb +707 -0
- data/lib/blue_shoes/dialog.rb +4 -0
- data/lib/blue_shoes/download.rb +4 -0
- data/lib/blue_shoes/effect.rb +4 -0
- data/lib/blue_shoes/exception.rb +14 -0
- data/lib/blue_shoes/flow.rb +11 -0
- data/lib/blue_shoes/image.rb +28 -0
- data/lib/blue_shoes/link_url.rb +4 -0
- data/lib/blue_shoes/mask.rb +4 -0
- data/lib/blue_shoes/mouse.rb +4 -0
- data/lib/blue_shoes/native.rb +242 -0
- data/lib/blue_shoes/pattern.rb +72 -0
- data/lib/blue_shoes/search.rb +4 -0
- data/lib/blue_shoes/shape.rb +4 -0
- data/lib/blue_shoes/stack.rb +19 -0
- data/lib/blue_shoes/text.rb +48 -0
- data/lib/blue_shoes/text_block.rb +66 -0
- data/lib/blue_shoes/timer_base.rb +32 -0
- data/lib/blue_shoes/version.rb +4 -0
- data/lib/blue_shoes/video.rb +39 -0
- data/lib/blue_shoes/widget.rb +4 -0
- data/lib/blue_shoes/window.rb +4 -0
- data/lib/blue_shoes.rb +31 -0
- data/samples/hello.rb +9 -0
- data/samples/simple-anim-shapes.rb +23 -0
- data/static/blue_shoes.jpg +0 -0
- metadata +113 -0
@@ -0,0 +1,777 @@
|
|
1
|
+
module Shoes
|
2
|
+
#this class represents a whole Shoes App.
|
3
|
+
class App < Qt::Application #:nodoc: all
|
4
|
+
|
5
|
+
def initialize opts = {}, blk #:nodoc:
|
6
|
+
|
7
|
+
super ARGV
|
8
|
+
|
9
|
+
#set the application icon to the shoes logo
|
10
|
+
set_window_icon(Qt::Icon.new "#{File.expand_path(File.dirname(__FILE__))}/../../static/blue_shoes.jpg")
|
11
|
+
|
12
|
+
#set up some options with defaults
|
13
|
+
height = opts[:height] || 200
|
14
|
+
width = opts[:width] || 400
|
15
|
+
resizeable = opts[:resizable].nil? ? true : false
|
16
|
+
|
17
|
+
@_main_window = Qt::Widget.new do
|
18
|
+
|
19
|
+
self.layout = Shoes::Stack.new
|
20
|
+
resize height, width
|
21
|
+
|
22
|
+
#this is the list of subwidgets we've got
|
23
|
+
@widgets = []
|
24
|
+
|
25
|
+
#we can make the window unresizable by adding a minimum and maximum
|
26
|
+
#size
|
27
|
+
unless resizeable
|
28
|
+
setMaximumSize(height,width)
|
29
|
+
setMinimumSize(height,width)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# in QT, each widget has a paint_event that gets called whenever
|
34
|
+
# it needs to be repainted.
|
35
|
+
def self.paint_event event
|
36
|
+
#we create a painter...
|
37
|
+
painter = Qt::Painter.new self
|
38
|
+
#then call it over every widget in our list
|
39
|
+
@widgets.each{|w| w.draw painter }
|
40
|
+
#and then end painting
|
41
|
+
painter.end
|
42
|
+
end
|
43
|
+
|
44
|
+
#a nice convenience function to add our widgets to the array
|
45
|
+
def add_widget widget
|
46
|
+
@widgets << widget
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
#we want to have a current widget, which starts off as the main window
|
52
|
+
@_current_widget = @_main_window
|
53
|
+
|
54
|
+
#we evaluate the block we were passed. This is pretty much the heart of
|
55
|
+
#Shoes.
|
56
|
+
instance_eval &blk
|
57
|
+
|
58
|
+
#then we show our window
|
59
|
+
@_main_window.show
|
60
|
+
#and call QT's exec to kick things off!
|
61
|
+
exec
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
|
65
|
+
#Create a new button.
|
66
|
+
def button txt, style={}, &blk
|
67
|
+
|
68
|
+
#create the button, don't forget to hook up that signal!
|
69
|
+
b = Qt::PushButton.new txt do
|
70
|
+
connect(SIGNAL :clicked) { blk.call } if blk
|
71
|
+
end
|
72
|
+
|
73
|
+
#add it to our widget list
|
74
|
+
add_widget b
|
75
|
+
|
76
|
+
#and we want to return it.
|
77
|
+
b
|
78
|
+
end
|
79
|
+
|
80
|
+
#a convenience function for adding a widget to the current widget
|
81
|
+
def add_widget widget
|
82
|
+
@_current_widget.layout.add_widget widget, 0
|
83
|
+
end
|
84
|
+
|
85
|
+
#these classes should probably be moved to Shoes::Dialog
|
86
|
+
|
87
|
+
#create an alert
|
88
|
+
class Alert < Qt::Dialog
|
89
|
+
def initialize(message, parent = nil)
|
90
|
+
super(parent)
|
91
|
+
Qt::MessageBox::information(self,"Alert!" , message)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Pops up a window containing a short message.
|
96
|
+
def alert(message)
|
97
|
+
Alert.new message
|
98
|
+
end
|
99
|
+
|
100
|
+
class Ask < Qt::Dialog
|
101
|
+
attr_accessor :text
|
102
|
+
|
103
|
+
def initialize(message, parent = nil)
|
104
|
+
super(parent)
|
105
|
+
ok = Qt::Boolean.new
|
106
|
+
self.text = Qt::InputDialog.getText(self,
|
107
|
+
"I have a Question?",
|
108
|
+
message,
|
109
|
+
Qt::LineEdit::Normal,
|
110
|
+
Qt::Dir::home().dirName(),
|
111
|
+
ok)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Pops up a window and asks a question.
|
116
|
+
def ask(message)
|
117
|
+
ask = Ask.new message
|
118
|
+
ask.text
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# Pops up a color picker window. The program will wait for a color to be picked, then gives you back a Color object. See the Color help for some ways you can use this color.
|
123
|
+
def ask_color(title)
|
124
|
+
# returns Shoes::Color
|
125
|
+
throw NotImplementedError
|
126
|
+
end
|
127
|
+
|
128
|
+
# Pops up an "Open file..." window. It's the standard window which shows all of your folders and lets you select a file to open. Hands you back the name of the file.
|
129
|
+
def ask_open_file
|
130
|
+
# returns a string
|
131
|
+
throw NotImplementedError
|
132
|
+
end
|
133
|
+
|
134
|
+
# Pops up a "Save file..." window, similiar to ask_open_file, described previously.
|
135
|
+
def ask_save_file
|
136
|
+
# returns a string
|
137
|
+
throw NotImplementedError
|
138
|
+
end
|
139
|
+
|
140
|
+
# Pops up an "Open folder..." window. It's the standard window which shows all of your folders and lets you select a folder to open. Hands you back the name of the folder.
|
141
|
+
def ask_open_folder
|
142
|
+
# returns a string
|
143
|
+
throw NotImplementedError
|
144
|
+
end
|
145
|
+
|
146
|
+
# Pops up a "Save folder..." window, similiar to ask_open_folder, described previously. On OS X, this method currently behaves like an alias of ask_open_folder.
|
147
|
+
def ask_save_folder
|
148
|
+
# returns a string
|
149
|
+
throw NotImplementedError
|
150
|
+
end
|
151
|
+
|
152
|
+
# Pops up a yes-or-no question. If the person at the computer, clicks yes, you'll get back a true. If not, you'll get back false.
|
153
|
+
def confirm(question)
|
154
|
+
# returns true or false
|
155
|
+
throw NotImplementedError
|
156
|
+
end
|
157
|
+
|
158
|
+
# Sends a debug message to the Shoes console. You can bring up the Shoes console by pressing Alt-/ on any Shoes window (or ⌘-/ on OS X.)
|
159
|
+
def debug(message)
|
160
|
+
# returns a string
|
161
|
+
throw NotImplementedError
|
162
|
+
end
|
163
|
+
|
164
|
+
# Sends an error message to the Shoes console. This method should only be used to log errors. Try the debug method for logging messages to yourself.
|
165
|
+
def error(message)
|
166
|
+
# returns nil
|
167
|
+
throw NotImplementedError
|
168
|
+
end
|
169
|
+
|
170
|
+
# Loads a TrueType (or other type of font) from a file. While TrueType is supported by all platforms, your platform may support other types of fonts. Shoes uses each operating system's built-in font system to make this work.
|
171
|
+
def font(message)
|
172
|
+
# returns an array of font family names
|
173
|
+
throw NotImplementedError
|
174
|
+
end
|
175
|
+
|
176
|
+
# Builds a linear gradient from two colors. For each color, you may pass in a Shoes::Color object or a string describing the color.
|
177
|
+
def gradient(color1, color2)
|
178
|
+
# returns Shoes::Pattern
|
179
|
+
throw NotImplementedError
|
180
|
+
end
|
181
|
+
|
182
|
+
# Create a grayscale color from a level of darkness and, optionally, an alpha level.
|
183
|
+
def gray(darkness, alpha)
|
184
|
+
# returns Shoes::Color
|
185
|
+
throw NotImplementedError
|
186
|
+
end
|
187
|
+
|
188
|
+
# Logs an informational message to the user in the Shoes console. So, where debug messages are designed to help the program figure out what's happening, info messages tell the user extra information about the program.
|
189
|
+
def info(message)
|
190
|
+
# returns nil
|
191
|
+
throw NotImplementedError
|
192
|
+
end
|
193
|
+
|
194
|
+
# Create a color from red, green and blue components. An alpha level (indicating transparency) can also be added, optionally.
|
195
|
+
# This method may also be called as Shoes.rgb.
|
196
|
+
def rgb(red, green, blue, alpha)
|
197
|
+
# returns Shoes::Color
|
198
|
+
throw NotImplementedError
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
# Logs a warning for the user. A warning is not a catastrophic error (see error for that.) It is just a notice that the program will be changing in the future or that certain parts of the program aren't reliable yet.
|
203
|
+
def warn(message)
|
204
|
+
# returns nil
|
205
|
+
throw NotImplementedError
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
# the system clipboard
|
210
|
+
attr_accessor :clipboard
|
211
|
+
|
212
|
+
# Closes the app window
|
213
|
+
def close
|
214
|
+
throw NotImplementedError
|
215
|
+
end
|
216
|
+
|
217
|
+
#starts a download thread
|
218
|
+
def download url, opts={}, &blk
|
219
|
+
throw NotImplementedError
|
220
|
+
end
|
221
|
+
|
222
|
+
# Gets a string containing the URL of the current app.
|
223
|
+
def location
|
224
|
+
throw NotImplementedError
|
225
|
+
end
|
226
|
+
|
227
|
+
# Identifies the mouse cursor's location, along with which button is being pressed.
|
228
|
+
def mouse
|
229
|
+
# an array of numbers: button, left, top
|
230
|
+
throw NotImplementedErrror
|
231
|
+
end
|
232
|
+
|
233
|
+
# Gets the app which launched this app. In most cases, this will be nil. But if this app was launched using the window method, the owner will be the app which called window.
|
234
|
+
def owner
|
235
|
+
#returns Shoes::App
|
236
|
+
throw NotImplementedError
|
237
|
+
end
|
238
|
+
|
239
|
+
# Has the window been fully constructed and displayed? This is useful for threaded code which may try to use the window before it is completely built. (Also see the start event which fires once the window is open.)
|
240
|
+
def started?
|
241
|
+
# returns true or false
|
242
|
+
throw NotImplementedError
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
# Changes the location, in order to view a different Shoes URL.
|
247
|
+
def visit url
|
248
|
+
throw NotImplementedError
|
249
|
+
end
|
250
|
+
|
251
|
+
# Draws an arc shape (a section of an oval) at coordinates (left, top). This method just give you a bit more control than oval, by offering the :angle1 and :angle2 styles. (In fact, you can mimick the oval method by setting :angle1 to 0 and :angle2 to Shoes::TWO_PI.)
|
252
|
+
def arc(left, top, width, height, angle1, angle2)
|
253
|
+
# returns Shoes::Shape
|
254
|
+
throw NotImplementedError
|
255
|
+
end
|
256
|
+
|
257
|
+
# Draws an arrow at coordinates (left, top) with a pixel width.
|
258
|
+
def arrow(left, top, width)
|
259
|
+
# returns Shoes::Shape
|
260
|
+
throw NotImplementedError
|
261
|
+
end
|
262
|
+
|
263
|
+
# Sets the line cap, which is the shape at the end of every line you draw. If set to :curve, the end is rounded. The default is :rect, a line which ends abruptly flat. The :project cap is also fat, but sticks out a bit longer.
|
264
|
+
def cap(how)
|
265
|
+
# returns self
|
266
|
+
throw NotImplementedError
|
267
|
+
end
|
268
|
+
|
269
|
+
# Sets the fill bucket to a specific color (or pattern.) Patterns can be colors, gradients or images. So, once the fill bucket is set, you can draw shapes and they will be colored in with the pattern you've chosen.
|
270
|
+
def fill(pattern)
|
271
|
+
# returns pattern
|
272
|
+
throw NotimplementedError
|
273
|
+
end
|
274
|
+
|
275
|
+
# Blanks the fill color, so that any shapes drawn will not be filled in. Instead, shapes will have only a lining, leaving the middle transparent.
|
276
|
+
def nofill
|
277
|
+
# returns self
|
278
|
+
throw NotImplementedError
|
279
|
+
end
|
280
|
+
|
281
|
+
# Empties the line color. Shapes drawn will have no outer line. If nofill is also set, shapes drawn will not be visible.
|
282
|
+
def nostroke
|
283
|
+
# returns self
|
284
|
+
throw NotImplementedError
|
285
|
+
end
|
286
|
+
|
287
|
+
# Draws a line using the current line color (aka "stroke") starting at coordinates (left, top) and ending at coordinates (x2, y2).
|
288
|
+
def line(left, top, x2, y2)
|
289
|
+
# returns Shoes::Shape
|
290
|
+
throw NotImplementedError
|
291
|
+
end
|
292
|
+
|
293
|
+
# Draws a circular form at pixel coordinates (left, top) with a width and height of radius pixels. The line and fill colors are used to draw the shape. By default, the coordinates are for the oval's leftmost, top corner, but this can be changed by calling the transform method or by using the :center style on the next method below.
|
294
|
+
def oval(left, top, radius)
|
295
|
+
# returns Shoes::Shape
|
296
|
+
throw NotImplementedError
|
297
|
+
end
|
298
|
+
|
299
|
+
# Draw circular form using a style hash.
|
300
|
+
def oval(styles)
|
301
|
+
# returns Shoes::Shape
|
302
|
+
throw NotImplementedError
|
303
|
+
end
|
304
|
+
|
305
|
+
# Draws a rectangle starting from coordinates (top, left) with dimensions of width x height. Optionally, you may give the rectangle rounded corners with a fifth argument: the radius of the corners in pixels.
|
306
|
+
def rect(top, left, width, height, corners = 0)
|
307
|
+
# returns Shoes::Shape
|
308
|
+
throw NotImplementedError
|
309
|
+
end
|
310
|
+
|
311
|
+
# Draw a rectangle using a style hash.
|
312
|
+
def rect(styles)
|
313
|
+
# returns Shoes::Shape
|
314
|
+
throw NotImplementedError
|
315
|
+
end
|
316
|
+
|
317
|
+
# Rotates the pen used for drawing by a certain number of degrees, so that any shapes will be drawn at that angle.
|
318
|
+
def rotate(degrees)
|
319
|
+
# returns self
|
320
|
+
throw NotImplementedError
|
321
|
+
end
|
322
|
+
|
323
|
+
# Describes an arbitrary shape to draw, beginning at coordinates (left, top) and continued by calls to line_to, move_to, curve_to and arc_to inside the block. You can look at it as sketching a shape with a long line that curves and arcs and bends.
|
324
|
+
def shape(left, top)
|
325
|
+
# returns Shoes::Shape
|
326
|
+
throw NotImplementedError
|
327
|
+
end
|
328
|
+
|
329
|
+
# Draws a star using the stroke and fill colors. The star is positioned with its center point at coordinates (left, top) with a certain number of points. The outer width defines the full radius of the star; the inner width specifies the radius of the star's middle, where points stem from.
|
330
|
+
def star(left, top, points = 10, outer = 100.0, inner = 50.0)
|
331
|
+
# returns Shoes::Shape
|
332
|
+
throw NotImplementedError
|
333
|
+
end
|
334
|
+
|
335
|
+
# Set the active line color for this slot. The pattern may be a color, a gradient or an image, all of which are categorized as "patterns." The line color is then used to draw the borders of any subsequent shape.
|
336
|
+
def stroke(pattern)
|
337
|
+
# returns pattern
|
338
|
+
throw NotImplementedError
|
339
|
+
end
|
340
|
+
|
341
|
+
# Sets the line size for all drawing within this slot. Whereas the stroke method alters the line color, the strokewidth method alters the line size in pixels. Calling strokewidth(4) will cause lines to be drawn 4 pixels wide.
|
342
|
+
def strokewidth(number)
|
343
|
+
# returns self
|
344
|
+
throw NotImplementedError
|
345
|
+
end
|
346
|
+
|
347
|
+
# Should transformations (such as skew and rotate) be performed around the center of the shape? Or the corner of the shape? Shoes defaults to :corner.
|
348
|
+
def transform(where)
|
349
|
+
# returns self
|
350
|
+
throw NotImplementedError
|
351
|
+
end
|
352
|
+
|
353
|
+
# Moves the starting point of the drawing pen for this slot. Normally, the pen starts at (0, 0) in the top-left corner, so that all shapes are drawn from that point. With translate, if the starting point is moved to (10, 20) and a shape is drawn at (50, 60), then the shape is actually drawn at (60, 80) on the slot.
|
354
|
+
def translate(left, top)
|
355
|
+
# returns self
|
356
|
+
throw NotImplementedError
|
357
|
+
end
|
358
|
+
|
359
|
+
# Starts an animation timer, which runs parallel to the rest of the app. The fps is a number, the frames per seconds. This number dictates how many times per second the attached block will be called.
|
360
|
+
def animate(fps)
|
361
|
+
# returns |frame| ... } » Shoes::Animation
|
362
|
+
throw NotImplementedError
|
363
|
+
end
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
# Draws a Background element with a specific color (or pattern.) Patterns can be colors, gradients or images. Colors and images will tile across the background. Gradients stretch to fill the background.
|
369
|
+
def background(pattern, style, &blk)
|
370
|
+
background = Shoes::Background.new(pattern, style)
|
371
|
+
@_main_window.add_widget background
|
372
|
+
background
|
373
|
+
end
|
374
|
+
|
375
|
+
# Creates a Banner text block. Shoes automatically styles this text to 48 pixels high.
|
376
|
+
def banner(text)
|
377
|
+
# returns Shoes::Banner
|
378
|
+
throw NotImplementedError
|
379
|
+
end
|
380
|
+
|
381
|
+
# Draws a Border element using a specific color (or pattern.) Patterns can be colors, gradients or images. Colors and images will tile across the border. Gradients stretch to fill the border.
|
382
|
+
def border(text, opts={})
|
383
|
+
# returns Shoes::Border
|
384
|
+
throw NotImplementedError
|
385
|
+
end
|
386
|
+
|
387
|
+
# Creates a Caption text block. Shoes styles this text to 14 pixels high.
|
388
|
+
def caption(text)
|
389
|
+
# returns Shoes::Caption
|
390
|
+
throw NotImplementedError
|
391
|
+
end
|
392
|
+
|
393
|
+
# Adds a check box.
|
394
|
+
def check()
|
395
|
+
# returns Shoes::Check
|
396
|
+
throw NotImplementedError
|
397
|
+
end
|
398
|
+
|
399
|
+
# Create a Code text fragment. This text defaults to a monospaced font.
|
400
|
+
def code(text)
|
401
|
+
# returns Shoes::Code
|
402
|
+
throw NotImplementedError
|
403
|
+
end
|
404
|
+
|
405
|
+
# Creates a Del text fragment (short for "deleted") which defaults to text with a single strikethrough in its middle.
|
406
|
+
def del(text)
|
407
|
+
# returns Shoes::Del
|
408
|
+
throw NotImplementedError
|
409
|
+
end
|
410
|
+
|
411
|
+
# Opens a new app window (just like the window method does,) but the window is given a dialog box look.
|
412
|
+
def dialog(styles)
|
413
|
+
# returns ... } » Shoes::App
|
414
|
+
throw NotImplementedError
|
415
|
+
end
|
416
|
+
|
417
|
+
# Adds a large, multi-line textarea to this slot. The text is optional and should be a string that will start out the box. An optional block can be attached here which is called any type the user changes the text in the box.
|
418
|
+
def edit_box(text)
|
419
|
+
# returns Shoes::EditBox
|
420
|
+
throw NotImplementedError
|
421
|
+
end
|
422
|
+
|
423
|
+
# Adds a single-line text box to this slot. The text is optional and should be a string that will start out the box. An optional block can be attached here which is called any type the user changes the text in the box.
|
424
|
+
def edit_line(text)
|
425
|
+
# returns Shoes::EditLine
|
426
|
+
throw NotImplementedError
|
427
|
+
end
|
428
|
+
|
429
|
+
# Creates an Em text fragment (short for "emphasized") which, by default, is styled with italics.
|
430
|
+
def em(text)
|
431
|
+
# returns Shoes::Em
|
432
|
+
throw NotImplementedError
|
433
|
+
end
|
434
|
+
|
435
|
+
# A timer similar to the animation method, but much slower. This timer fires a given number of seconds, running the block attached. So, for example, if you need to check a web site every five minutes, you'd call every(300) with a block containing the code to actually ping the web site.
|
436
|
+
def every(seconds)
|
437
|
+
# returns Shoes::Every
|
438
|
+
throw NotImplementedError
|
439
|
+
end
|
440
|
+
|
441
|
+
# A flow is an invisible box (or "slot") in which you place Shoes elements. Both flows and stacks are explained in great detail on the main Slots page.
|
442
|
+
def flow(style, &blk)
|
443
|
+
flow = Shoes::Flow.new(style)
|
444
|
+
add_widget flow
|
445
|
+
instance_eval &blk
|
446
|
+
flow
|
447
|
+
end
|
448
|
+
|
449
|
+
# Creates an Image element for displaying a picture. PNG, JPEG and GIF formats are allowed.
|
450
|
+
def image(path)
|
451
|
+
# returns Shoes::Image
|
452
|
+
throw NotImplementedError
|
453
|
+
end
|
454
|
+
|
455
|
+
# Quickly grab the width and height of an image. The image won't be loaded into the cache or displayed.
|
456
|
+
def imagesize(path)
|
457
|
+
# returns [width, height]
|
458
|
+
throw NotImplementedError
|
459
|
+
end
|
460
|
+
|
461
|
+
# Creates an Ins text fragment (short for "inserted") which Shoes styles with a single underline.
|
462
|
+
def ins(text)
|
463
|
+
# returns Shoes::Ins
|
464
|
+
throw NotImplementedError
|
465
|
+
end
|
466
|
+
|
467
|
+
# Creates an Inscription text block. Shoes styles this text at 10 pixels high.
|
468
|
+
def inscription(text)
|
469
|
+
# returns Shoes::Inscription
|
470
|
+
throw NotImplementedError
|
471
|
+
end
|
472
|
+
|
473
|
+
# Creates a Link text block, which Shoes styles with a single underline and colors with a #06E (blue) colored stroke.
|
474
|
+
def link(text, opts)
|
475
|
+
# returns Shoes::Link
|
476
|
+
throw NotImplementedError
|
477
|
+
end
|
478
|
+
|
479
|
+
# Adds a drop-down list box containing entries for everything in the items array. An optional block may be attached, which is called if anything in the box becomes selected by the user.
|
480
|
+
def list_box(opts)
|
481
|
+
# returns Shoes::ListBox
|
482
|
+
throw NotImplementedError
|
483
|
+
end
|
484
|
+
|
485
|
+
# Adds a progress bar.
|
486
|
+
def progress
|
487
|
+
# returns Shoes::Progress
|
488
|
+
throw NotImplementedError
|
489
|
+
end
|
490
|
+
|
491
|
+
# Create a Para text block (short for "paragraph") which Shoes styles at 12 pixels high.
|
492
|
+
def para(text)
|
493
|
+
para = Shoes::Para.new(text)
|
494
|
+
add_widget para.to_label
|
495
|
+
para
|
496
|
+
end
|
497
|
+
|
498
|
+
# Adds a radio button. If a group name is given, the radio button is considered part of a group. Among radio buttons in the same group, only one may be checked. (If no group name is given, the radio button is grouped with any other radio buttons in the same slot.)
|
499
|
+
def radio(group)
|
500
|
+
# returns Shoes::Radio
|
501
|
+
throw NotImplementedError
|
502
|
+
end
|
503
|
+
|
504
|
+
# Creates a Span text fragment, unstyled by default.
|
505
|
+
def span(text)
|
506
|
+
# returns Shoes::Span
|
507
|
+
throw NotImplementedError
|
508
|
+
end
|
509
|
+
|
510
|
+
# Creates a new stack. A stack is a type of slot. (See the main Slots page for a full explanation of both stacks and flows.)
|
511
|
+
def stack(style, &blk)
|
512
|
+
stack = Shoes::Stack.new
|
513
|
+
add_widget stack
|
514
|
+
instance_eval &blk
|
515
|
+
stack
|
516
|
+
end
|
517
|
+
|
518
|
+
# Creates a Strong text fragment, styled in bold by default.
|
519
|
+
def strong(text)
|
520
|
+
strong = Shoes::Strong.new(text)
|
521
|
+
strong
|
522
|
+
end
|
523
|
+
|
524
|
+
# Creates a Sub text fragment (short for "subscript") which defaults to lowering the text by 10 pixels and styling it in an x-small font.
|
525
|
+
def sub(text)
|
526
|
+
# returns Shoes::Sub
|
527
|
+
throw NotImplementedError
|
528
|
+
end
|
529
|
+
|
530
|
+
# Creates a Subtitle text block. Shoes styles this text to 26 pixels high.
|
531
|
+
def subtitle(text)
|
532
|
+
# returns Shoes::Subtitle
|
533
|
+
throw NotImplementedError
|
534
|
+
end
|
535
|
+
|
536
|
+
# Creates a Sup text fragment (short for "superscript") which defaults to raising the text by 10 pixels and styling it in an x-small font.
|
537
|
+
def sup(text)
|
538
|
+
# returns Shoes::Sup
|
539
|
+
throw NotImplementedError
|
540
|
+
end
|
541
|
+
|
542
|
+
# Creates a Tagline text block. Shoes styles this text to 18 pixels high.
|
543
|
+
def tagline(text)
|
544
|
+
# returns Shoes::Tagline
|
545
|
+
throw NotImplementedError
|
546
|
+
end
|
547
|
+
|
548
|
+
# A one-shot timer. If you want to schedule to run some code in a few seconds (or minutes, hours) you can attach the code as a block here.
|
549
|
+
def timer(seconds)
|
550
|
+
# returns Shoes::Timer
|
551
|
+
throw NotImplementedError
|
552
|
+
end
|
553
|
+
|
554
|
+
# Creates a Title text block. Shoes styles these elements to 34 pixels high.
|
555
|
+
def title(text)
|
556
|
+
# returns Shoes::Title
|
557
|
+
throw NotImplementedError
|
558
|
+
end
|
559
|
+
|
560
|
+
# Embeds a movie in this slot.
|
561
|
+
def video(url)
|
562
|
+
# returns Shoes::Video
|
563
|
+
throw NotImplementedError
|
564
|
+
end
|
565
|
+
|
566
|
+
# Opens a new app window. This method is almost identical to the Shoes.app method used to start an app in the first place. The difference is that the window method sets the new window's owner property. (A normal Shoes.app has its owner set to nil.)
|
567
|
+
def window(styles)
|
568
|
+
# returns Shoes::App
|
569
|
+
throw NotImplementedError
|
570
|
+
end
|
571
|
+
|
572
|
+
# The click block is called when a mouse button is clicked. The button is the number of the mouse button which has been pressed. The left and top are the mouse coordinates at which the click happened.
|
573
|
+
def click(&blk)
|
574
|
+
# returns self
|
575
|
+
throw NotImplementedError
|
576
|
+
end
|
577
|
+
|
578
|
+
# When a slot is removed, it's finish event occurs. The finish block is immediately handed self, the slot object which has been removed.
|
579
|
+
def finish(&blk)
|
580
|
+
# returns self
|
581
|
+
throw NotImplementedError
|
582
|
+
end
|
583
|
+
|
584
|
+
# The hover event happens when the mouse enters the slot. The block gets self, meaning the object which was hovered over.
|
585
|
+
def hover(&blk)
|
586
|
+
# returns self
|
587
|
+
throw NotImplementedError
|
588
|
+
end
|
589
|
+
|
590
|
+
# Whenever a key (or combination of keys) is pressed, the block gets called. The block is sent a key which is a string representing the character (such as the letter or number) on the key. For special keys and key combos, a Ruby symbol is sent, rather than a string.
|
591
|
+
def keypress(&blk)
|
592
|
+
# returns self
|
593
|
+
throw NotImplementedError
|
594
|
+
end
|
595
|
+
|
596
|
+
# The leave event takes place when the mouse cursor exits a slot. The moment it no longer is inside the slot's edges. When that takes place, the block is called with self, the slot object which is being left.
|
597
|
+
def leave(&blk)
|
598
|
+
# returns self
|
599
|
+
throw NotImplementedError
|
600
|
+
end
|
601
|
+
|
602
|
+
# The motion block gets called every time the mouse moves around inside the slot. The block is handed the cursor's left and top coordinates.
|
603
|
+
def motion(&blk)
|
604
|
+
# returns self
|
605
|
+
throw NotImplementedError
|
606
|
+
end
|
607
|
+
|
608
|
+
# The release block runs whenever the mouse is unclicked (on mouse up). When the finger is lifted. The button is the number of the button that was depressed. The left and top are the coordinates of the mouse at the time the button was released.
|
609
|
+
def release(&blk)
|
610
|
+
# returns self
|
611
|
+
throw NotImplementedError
|
612
|
+
end
|
613
|
+
|
614
|
+
# The first time the slot is drawn, the start event fires. The block is handed self, the slot object which has just been drawn.
|
615
|
+
def start(&blk)
|
616
|
+
# returns self
|
617
|
+
throw NotImplementedError
|
618
|
+
end
|
619
|
+
|
620
|
+
# Adds elements to the end of a slot.
|
621
|
+
def append(&blk)
|
622
|
+
# returns self
|
623
|
+
throw NotImplementedError
|
624
|
+
end
|
625
|
+
|
626
|
+
# Adds elements to a specific place in a slot, just after the element which is a child of the slot.
|
627
|
+
def after(&blk)
|
628
|
+
# returns self
|
629
|
+
throw NotImplementedError
|
630
|
+
end
|
631
|
+
|
632
|
+
# Adds elements to a specific place in a slot, just before the element which is a child of the slot.
|
633
|
+
def before(&blk)
|
634
|
+
# returns self
|
635
|
+
throw NotImplementedError
|
636
|
+
end
|
637
|
+
|
638
|
+
# Empties the slot of any elements, timers and nested slots. This is effectively identical to looping through the contents of the slot and calling each element's remove method.
|
639
|
+
def clear(&blk)
|
640
|
+
# returns self
|
641
|
+
throw NotImplementedError
|
642
|
+
end
|
643
|
+
|
644
|
+
# The clear method also takes an optional block. The block will be used to replace the contents of the slot.
|
645
|
+
def clear(&blk)
|
646
|
+
# returns self
|
647
|
+
throw NotImplementedError
|
648
|
+
end
|
649
|
+
|
650
|
+
# Adds elements to the beginning of a slot.
|
651
|
+
def prepend(&blk)
|
652
|
+
# returns self
|
653
|
+
throw NotImplementedError
|
654
|
+
end
|
655
|
+
|
656
|
+
# A shortcut method for setting the :displace_left and :displace_top styles. Displacing is a handy way of moving a slot without altering the layout. In fact, the top and left methods will not report displacement at all. So, generally, displacement is only for temporary animations. For example, jiggling a button in place.
|
657
|
+
def displace(left, top)
|
658
|
+
# returns self
|
659
|
+
throw NotImplementedError
|
660
|
+
end
|
661
|
+
|
662
|
+
# The size of the scrollbar area. When Shoes needs to show a scrollbar, the scrollbar may end up covering up some elements that touch the edge of the window. The gutter tells you how many pixels to expect the scrollbar to cover.
|
663
|
+
def gutter
|
664
|
+
# returns a number
|
665
|
+
throw NotImplementedError
|
666
|
+
end
|
667
|
+
|
668
|
+
# The vertical size of the viewable slot in pixels. So, if this is a scrolling slot, you'll need to use scroll_height() to get the full size of the slot.
|
669
|
+
def height
|
670
|
+
# returns a number
|
671
|
+
throw NotImplementedError
|
672
|
+
end
|
673
|
+
|
674
|
+
# Hides the slot, so that it can't be seen. See also show and toggle.
|
675
|
+
def hide
|
676
|
+
#returns self
|
677
|
+
throw NotImplementedError
|
678
|
+
end
|
679
|
+
|
680
|
+
# The left pixel location of the slot. Also known as the x-axis coordinate.
|
681
|
+
def left
|
682
|
+
# returns a number
|
683
|
+
throw NotImplementedError
|
684
|
+
end
|
685
|
+
|
686
|
+
# Moves the slot to specific coordinates, the (left, top) being the upper left hand corner of the slot.
|
687
|
+
def move(left, top)
|
688
|
+
# returns self
|
689
|
+
throw NotImplementedError
|
690
|
+
end
|
691
|
+
|
692
|
+
# Removes the slot. It will no longer be displayed and will not be listed in its parent's contents. It's gone.
|
693
|
+
def remove
|
694
|
+
# returns self
|
695
|
+
throw NotImplementedError
|
696
|
+
end
|
697
|
+
|
698
|
+
# Is this slot allowed to show a scrollbar? True or false. The scrollbar will only appear if the height of the slot is also fixed.
|
699
|
+
def scroll
|
700
|
+
# returns true or false
|
701
|
+
throw NotImplementedError
|
702
|
+
end
|
703
|
+
|
704
|
+
# The vertical size of the full slot, including any of it which is hidden by scrolling.
|
705
|
+
def scroll_height
|
706
|
+
# returns a number
|
707
|
+
throw NotImplementedError
|
708
|
+
end
|
709
|
+
|
710
|
+
# The top coordinate which this slot can be scrolled down to. The top coordinate of a scroll bar is always zero. The bottom coordinate is the full height of the slot minus one page of scrolling. This bottom coordinate is what scroll_max returns.
|
711
|
+
def scroll_max
|
712
|
+
# returns a number
|
713
|
+
throw NotImplementedError
|
714
|
+
end
|
715
|
+
|
716
|
+
# The top coordinate which this slot is scrolled down to. So, if the slot is scrolled down twenty pixels, this method will return 20.
|
717
|
+
def scroll_top
|
718
|
+
# returns a number
|
719
|
+
throw NotImplementedError
|
720
|
+
end
|
721
|
+
|
722
|
+
# Scrolls the slot to a certain coordinate. This must be between zero and scroll_max.
|
723
|
+
def scroll_top=(number)
|
724
|
+
throw NotImplementedErrror
|
725
|
+
end
|
726
|
+
|
727
|
+
# Reveals the slot, if it is hidden. See also hide and toggle.
|
728
|
+
def show
|
729
|
+
# returns self
|
730
|
+
throw NotImplementedError
|
731
|
+
end
|
732
|
+
|
733
|
+
# Calling the style method with no arguments returns a hash of the styles presently applied to this slot.
|
734
|
+
def style
|
735
|
+
# returns styles
|
736
|
+
throw NotImplementedError
|
737
|
+
end
|
738
|
+
|
739
|
+
# Alter the slot using a hash of style settings. Any of the methods on this page (aside from this method, of course) can be used as a style setting. So, for example, there is a width method, thus there is also a width style.
|
740
|
+
def style(styles)
|
741
|
+
# returns styles
|
742
|
+
throw NotImplementedError
|
743
|
+
end
|
744
|
+
|
745
|
+
# Hides the slot, if it is shown. Or shows the slot, if it is hidden.
|
746
|
+
def toggle
|
747
|
+
# returns self
|
748
|
+
throw NotImplementedError
|
749
|
+
end
|
750
|
+
|
751
|
+
# The top pixel location of the slot. Also known as the y-axis coordinate.
|
752
|
+
def top
|
753
|
+
# returns a number
|
754
|
+
throw NotImplementedError
|
755
|
+
end
|
756
|
+
|
757
|
+
# The horizontal size of the slot in pixels.
|
758
|
+
def width
|
759
|
+
# returns a number
|
760
|
+
throw NotImplementedError
|
761
|
+
end
|
762
|
+
|
763
|
+
# Lists all elements in a slot.
|
764
|
+
def contents
|
765
|
+
# returns an array of elements
|
766
|
+
throw NotImplementedError
|
767
|
+
end
|
768
|
+
|
769
|
+
# Gets the object for this element's container.
|
770
|
+
def parent
|
771
|
+
# returns a Shoes::Stack or Shoes::Flow
|
772
|
+
throw NotImplementedError
|
773
|
+
end
|
774
|
+
|
775
|
+
end
|
776
|
+
end
|
777
|
+
|