Class: Shoes

Inherits:
Object
  • Object
show all
Extended by:
BuiltinMethods, Common::Registration
Defined in:
shoes-core/lib/shoes/ui/picker.rb,
shoes-core/lib/shoes/app.rb,
shoes-core/lib/shoes/arc.rb,
shoes-core/lib/shoes/dsl.rb,
shoes-core/lib/shoes/dsl.rb,
shoes-core/lib/shoes/url.rb,
shoes-core/lib/shoes/font.rb,
shoes-core/lib/shoes/line.rb,
shoes-core/lib/shoes/link.rb,
shoes-core/lib/shoes/mock.rb,
shoes-core/lib/shoes/oval.rb,
shoes-core/lib/shoes/rect.rb,
shoes-core/lib/shoes/slot.rb,
shoes-core/lib/shoes/span.rb,
shoes-core/lib/shoes/star.rb,
shoes-core/lib/shoes/text.rb,
shoes-core/lib/shoes/arrow.rb,
shoes-core/lib/shoes/color.rb,
shoes-core/lib/shoes/image.rb,
shoes-core/lib/shoes/point.rb,
shoes-core/lib/shoes/radio.rb,
shoes-core/lib/shoes/shape.rb,
shoes-core/lib/shoes/sound.rb,
shoes-core/lib/shoes/timer.rb,
shoes-core/lib/shoes/border.rb,
shoes-core/lib/shoes/button.rb,
shoes-core/lib/shoes/dialog.rb,
shoes-core/lib/shoes/ui/cli.rb,
shoes-core/lib/shoes/widget.rb,
shoes-core/lib/shoes/window.rb,
shoes-core/lib/shoes/console.rb,
shoes-core/lib/shoes/dsl/art.rb,
shoes-core/lib/shoes/version.rb,
shoes-core/lib/shoes/download.rb,
shoes-core/lib/shoes/dsl/text.rb,
shoes-core/lib/shoes/gradient.rb,
shoes-core/lib/shoes/list_box.rb,
shoes-core/lib/shoes/mock/app.rb,
shoes-core/lib/shoes/mock/arc.rb,
shoes-core/lib/shoes/packager.rb,
shoes-core/lib/shoes/progress.rb,
shoes-core/lib/shoes/animation.rb,
shoes-core/lib/shoes/color/dsl.rb,
shoes-core/lib/shoes/dimension.rb,
shoes-core/lib/shoes/dsl/media.rb,
shoes-core/lib/shoes/dsl/setup.rb,
shoes-core/lib/shoes/dsl/style.rb,
shoes-core/lib/shoes/input_box.rb,
shoes-core/lib/shoes/key_event.rb,
shoes-core/lib/shoes/mock/font.rb,
shoes-core/lib/shoes/mock/line.rb,
shoes-core/lib/shoes/mock/link.rb,
shoes-core/lib/shoes/mock/oval.rb,
shoes-core/lib/shoes/mock/rect.rb,
shoes-core/lib/shoes/mock/slot.rb,
shoes-core/lib/shoes/mock/star.rb,
shoes-core/lib/shoes/background.rb,
shoes-core/lib/shoes/dimensions.rb,
shoes-core/lib/shoes/mock/arrow.rb,
shoes-core/lib/shoes/mock/check.rb,
shoes-core/lib/shoes/mock/image.rb,
shoes-core/lib/shoes/mock/radio.rb,
shoes-core/lib/shoes/mock/shape.rb,
shoes-core/lib/shoes/mock/sound.rb,
shoes-core/lib/shoes/mock/timer.rb,
shoes-core/lib/shoes/text_block.rb,
shoes-core/lib/shoes/common/fill.rb,
shoes-core/lib/shoes/dsl/animate.rb,
shoes-core/lib/shoes/dsl/element.rb,
shoes-core/lib/shoes/mock/border.rb,
shoes-core/lib/shoes/mock/button.rb,
shoes-core/lib/shoes/mock/dialog.rb,
shoes-core/lib/shoes/check_button.rb,
shoes-core/lib/shoes/common/focus.rb,
shoes-core/lib/shoes/common/hover.rb,
shoes-core/lib/shoes/common/state.rb,
shoes-core/lib/shoes/common/style.rb,
shoes-core/lib/shoes/core/version.rb,
shoes-core/lib/shoes/http_request.rb,
shoes-core/lib/shoes/internal_app.rb,
shoes-core/lib/shoes/common/remove.rb,
shoes-core/lib/shoes/common/rotate.rb,
shoes-core/lib/shoes/common/stroke.rb,
shoes-core/lib/shoes/configuration.rb,
shoes-core/lib/shoes/image_pattern.rb,
shoes-core/lib/shoes/mock/download.rb,
shoes-core/lib/shoes/mock/keypress.rb,
shoes-core/lib/shoes/mock/list_box.rb,
shoes-core/lib/shoes/mock/packager.rb,
shoes-core/lib/shoes/mock/progress.rb,
shoes-core/lib/shoes/slot_contents.rb,
shoes-core/lib/shoes/common/inspect.rb,
shoes-core/lib/shoes/mock/animation.rb,
shoes-core/lib/shoes/mock/clickable.rb,
shoes-core/lib/shoes/mock/input_box.rb,
shoes-core/lib/shoes/builtin_methods.rb,
shoes-core/lib/shoes/dsl/interaction.rb,
shoes-core/lib/shoes/mock/background.rb,
shoes-core/lib/shoes/mock/keyrelease.rb,
shoes-core/lib/shoes/mock/text_block.rb,
shoes-core/lib/shoes/standard_logger.rb,
shoes-core/lib/shoes/common/clickable.rb,
shoes-core/lib/shoes/common/translate.rb,
shoes-core/lib/shoes/color/dsl_helpers.rb,
shoes-core/lib/shoes/common/attachable.rb,
shoes-core/lib/shoes/common/changeable.rb,
shoes-core/lib/shoes/common/ui_element.rb,
shoes-core/lib/shoes/common/visibility.rb,
shoes-core/lib/shoes/logger_collection.rb,
shoes-core/lib/shoes/common/art_element.rb,
shoes-core/lib/shoes/common/link_finder.rb,
shoes-core/lib/shoes/common/positioning.rb,
shoes-core/lib/shoes/mock/image_pattern.rb,
shoes-core/lib/shoes/color/hex_converter.rb,
shoes-core/lib/shoes/common/registration.rb,
shoes-core/lib/shoes/mock/common_methods.rb,
shoes-core/lib/shoes/ui/cli/base_command.rb,
shoes-core/lib/shoes/ui/cli/help_command.rb,
shoes-core/lib/shoes/file_not_found_error.rb,
shoes-core/lib/shoes/common/image_handling.rb,
shoes-core/lib/shoes/not_implemented_error.rb,
shoes-core/lib/shoes/text_block_dimensions.rb,
shoes-core/lib/shoes/ui/cli/manual_command.rb,
shoes-core/lib/shoes/common/safely_evaluate.rb,
shoes-core/lib/shoes/ui/cli/default_command.rb,
shoes-core/lib/shoes/ui/cli/package_command.rb,
shoes-core/lib/shoes/ui/cli/samples_command.rb,
shoes-core/lib/shoes/ui/cli/version_command.rb,
shoes-core/lib/shoes/common/style_normalizer.rb,
shoes-core/lib/shoes/common/background_element.rb,
shoes-core/lib/shoes/ui/cli/select_backend_command.rb,
shoes-package/lib/shoes/package.rb,
shoes-package/lib/shoes/package/version.rb,
shoes-package/lib/shoes/package/configuration.rb,
shoes-swt/lib/shoes/swt.rb,
shoes-swt/lib/shoes/swt/app.rb,
shoes-swt/lib/shoes/swt/arc.rb,
shoes-swt/lib/shoes/swt/font.rb,
shoes-swt/lib/shoes/swt/line.rb,
shoes-swt/lib/shoes/swt/link.rb,
shoes-swt/lib/shoes/swt/oval.rb,
shoes-swt/lib/shoes/swt/rect.rb,
shoes-swt/lib/shoes/swt/slot.rb,
shoes-swt/lib/shoes/swt/star.rb,
shoes-swt/lib/shoes/swt/arrow.rb,
shoes-swt/lib/shoes/swt/check.rb,
shoes-swt/lib/shoes/swt/color.rb,
shoes-swt/lib/shoes/swt/image.rb,
shoes-swt/lib/shoes/swt/radio.rb,
shoes-swt/lib/shoes/swt/shape.rb,
shoes-swt/lib/shoes/swt/sound.rb,
shoes-swt/lib/shoes/swt/timer.rb,
shoes-swt/lib/shoes/swt/border.rb,
shoes-swt/lib/shoes/swt/button.rb,
shoes-swt/lib/shoes/swt/dialog.rb,
shoes-swt/lib/shoes/swt/version.rb,
shoes-swt/lib/shoes/swt/download.rb,
shoes-swt/lib/shoes/swt/gradient.rb,
shoes-swt/lib/shoes/swt/list_box.rb,
shoes-swt/lib/shoes/swt/packager.rb,
shoes-swt/lib/shoes/swt/progress.rb,
shoes-swt/lib/shoes/swt/animation.rb,
shoes-swt/lib/shoes/swt/input_box.rb,
shoes-swt/lib/shoes/swt/background.rb,
shoes-swt/lib/shoes/swt/swt_button.rb,
shoes-swt/lib/shoes/swt/text_block.rb,
shoes-swt/lib/shoes/swt/arc_painter.rb,
shoes-swt/lib/shoes/swt/common/fill.rb,
shoes-swt/lib/shoes/swt/radio_group.rb,
shoes-swt/lib/shoes/swt/check_button.rb,
shoes-swt/lib/shoes/swt/common/focus.rb,
shoes-swt/lib/shoes/swt/key_listener.rb,
shoes-swt/lib/shoes/swt/line_painter.rb,
shoes-swt/lib/shoes/swt/link_segment.rb,
shoes-swt/lib/shoes/swt/oval_painter.rb,
shoes-swt/lib/shoes/swt/rect_painter.rb,
shoes-swt/lib/shoes/swt/shoes_layout.rb,
shoes-swt/lib/shoes/swt/star_painter.rb,
shoes-swt/lib/shoes/swt/arrow_painter.rb,
shoes-swt/lib/shoes/swt/color_factory.rb,
shoes-swt/lib/shoes/swt/common/remove.rb,
shoes-swt/lib/shoes/swt/common/stroke.rb,
shoes-swt/lib/shoes/swt/image_painter.rb,
shoes-swt/lib/shoes/swt/image_pattern.rb,
shoes-swt/lib/shoes/swt/shape_painter.rb,
shoes-swt/lib/shoes/swt/click_listener.rb,
shoes-swt/lib/shoes/swt/common/painter.rb,
shoes-swt/lib/shoes/swt/common/resource.rb,
shoes-swt/lib/shoes/swt/common/clickable.rb,
shoes-swt/lib/shoes/swt/common/container.rb,
shoes-swt/lib/shoes/swt/common/translate.rb,
shoes-swt/lib/shoes/swt/generate_backend.rb,
shoes-swt/lib/shoes/swt/redrawing_aspect.rb,
shoes-swt/lib/shoes/swt/common/visibility.rb,
shoes-swt/lib/shoes/swt/text_block/fitter.rb,
shoes-swt/lib/shoes/swt/text_block/painter.rb,
shoes-swt/lib/shoes/swt/disposed_protection.rb,
shoes-swt/lib/shoes/swt/mouse_move_listener.rb,
shoes-swt/lib/shoes/swt/common/image_handling.rb,
shoes-swt/lib/shoes/swt/common/update_position.rb,
shoes-swt/lib/shoes/swt/text_block/text_segment.rb,
shoes-swt/lib/shoes/swt/common/selection_listener.rb,
shoes-swt/lib/shoes/swt/text_block/cursor_painter.rb,
shoes-swt/lib/shoes/swt/text_block/text_font_factory.rb,
shoes-swt/lib/shoes/swt/text_block/text_style_factory.rb,
shoes-swt/lib/shoes/swt/common/painter_updates_position.rb,
shoes-swt/lib/shoes/swt/text_block/centered_text_segment.rb,
shoes-swt/lib/shoes/swt/text_block/text_segment_collection.rb

Overview

This file uses the after_do gem, which you probably haven’t heard of (yet) It basically works like Class.after :method do … end So for every instance of Class, after method is executed the block you gave it is executed. Here it is used to redraw the application, after specific methods are called. So that everything belonging to the aspect of redrawing is in one file. There is more documentation up here: github.com/PragTob/after_do

Defined Under Namespace

Modules: BuiltinMethods, Common, Core, DSL, Font, Mock, Package, SelectedBackend, Swt, TextBlockDimensionsDelegations, UI, URL, URLDefiner Classes: AbsoluteDimensions, Animation, App, Arc, Arrow, Background, Border, Button, Check, CheckButton, Color, Configuration, Console, Dialog, Dimension, Dimensions, Download, EditBox, EditLine, FileNotFoundError, Flow, Gradient, HttpRequest, HttpResponse, Image, ImagePattern, InputBox, InternalApp, KeyEvent, Keypress, Keyrelease, Line, Link, ListBox, LoggerCollection, NotImplementedError, Oval, Packager, ParentDimension, ParentDimensions, Point, Progress, ProxyArray, Radio, Rect, Shape, Slot, SlotContents, Sound, Span, Stack, StandardLogger, Star, Text, TextBlock, TextBlockDimensions, Timer, Widget, Window

Constant Summary collapse

ICON =
File.join(DIR, 'static/shoes-icon.png').freeze
PI =
Math::PI
TWO_PI =
2 * PI
HALF_PI =
0.5 * PI
DIR =
Pathname.new(__FILE__).parent.parent.parent.to_s
LEFT_MOUSE_BUTTON =
1
MIDDLE_MOUSE_BUTTON =
2
RIGHT_MOUSE_BUTTON =
3
FONT_DIR =
DIR + "/fonts/"
FONTS =
[]
VERSION =
"4.0.0.rc1"
COLORS =

Create all of the built-in Shoes colors

{}
CENTER =
"center"
DEFAULT_TEXTBLOCK_FONT =
"Arial"
FONT_ALIASES =
{
  "Monospace" => "Fira Mono",
  "Sans Serif" => "Lucida console",
}.freeze

Instance Attribute Summary

Attributes included from Common::Registration

#main_app

Class Method Summary collapse

Methods included from Common::Registration

apps, register, register_main_app, unregister, unregister_all

Methods included from BuiltinMethods

alert, ask, ask_color, ask_open_file, ask_open_folder, ask_save_file, ask_save_folder, confirm, font

Methods included from Color::DSLHelpers

#color, #gradient, #gray, #pattern, #rgb

Methods included from Common::ImageHandling

#absolute_file_path, #default_search_paths, #search_for

Class Method Details

.app(opts = {}, &blk) ⇒ Object

Instantiates a new Shoes app.

Examples:

Shoes.app(title: "Chunky") do
  para "Bacon is awesome!"
end

Parameters:

  • opts (Hash) (defaults to: {})

    A hash of options used instantiate the Shoes::App object with.

  • blk (Proc)

    The block containing the DSL instructions for the actual app.

Returns:

  • A new instance of Shoes::App

See Also:



20
21
22
# File 'shoes-core/lib/shoes/app.rb', line 20

def self.app(opts = {}, &blk)
  Shoes::App.new(opts, &blk)
end

.backendObject



98
99
100
# File 'shoes-core/lib/shoes/configuration.rb', line 98

def Shoes.backend
  Shoes.configuration.backend
end

.backend_for(shoes_object, *args, &blk) ⇒ Object



94
95
96
# File 'shoes-core/lib/shoes/configuration.rb', line 94

def Shoes.backend_for(shoes_object, *args, &blk)
  Shoes::Configuration.backend_for(shoes_object, *args, &blk)
end

.configurationObject



90
91
92
# File 'shoes-core/lib/shoes/configuration.rb', line 90

def Shoes.configuration
  Shoes::Configuration
end

.consoleObject



23
24
25
# File 'shoes-core/lib/shoes/dsl.rb', line 23

def console
  @console ||= Shoes::Console.new
end

.inherited(base_class) ⇒ Object

Backwards compatibility, kind of likely to be removed



5
6
7
# File 'shoes-core/lib/shoes/url.rb', line 5

def self.inherited(base_class)
  base_class.send :include, URL # include is private, therefore send
end

.load_backend(name) ⇒ Object

Load the backend in memory. This does not set any configuration.

Parameters:

  • name (String, Symbol)

    The name, such as :swt or :mock

Returns:

  • The backend



27
28
29
30
31
32
# File 'shoes-core/lib/shoes/dsl/setup.rb', line 27

def load_backend(name)
  require "shoes/#{name.to_s.downcase}"
  Shoes.const_get(name.to_s.capitalize)
rescue LoadError => e
  raise LoadError, "Couldn't load backend Shoes::#{name.capitalize}'. Error: #{e.message}\n#{e.backtrace.join("\n")}"
end

.loggerObject



27
28
29
30
31
32
33
# File 'shoes-core/lib/shoes/dsl.rb', line 27

def logger
  return @logger if defined?(@logger)

  @logger ||= Shoes::LoggerCollection.new
  @logger << Shoes::StandardLogger.new
  @logger << console
end

.p(message) ⇒ Object



7
8
9
# File 'shoes-core/lib/shoes/builtin_methods.rb', line 7

def self.p(message)
  Shoes.logger.debug(message.inspect)
end

.setup(&block) ⇒ Object

Deprecated.

To ease the upgrade path from Shoes 3 we warn users they need to install and require gems themselves.

Examples:

Shoes.setup do
  # This runs, but gem doesn't do anything anymore!
  gem 'bluecloth =2.0.6'
  gem 'metaid'
end

Parameters:

  • block (Proc)

    The block that describes the gems that are needed



17
18
19
20
21
# File 'shoes-core/lib/shoes/dsl/setup.rb', line 17

def setup(&block)
  Shoes.logger.warn "The Shoes.setup method is deprecated, you need to install gems yourself.\n" \
                    "You can do this using the 'gem install' command or bundler and a Gemfile."
  DeprecatedShoesGemSetup.new.instance_eval(&block)
end