Class: Fidgit::MessageDialog
- Inherits:
-
DialogState
- Object
- Chingu::GameState
- GuiState
- DialogState
- Fidgit::MessageDialog
- Defined in:
- lib/fidgit/states/message_dialog.rb
Overview
A simple dialog that manages a message with a set of buttons beneath it.
Constant Summary collapse
- VALID_TYPES =
[:ok, :ok_cancel, :yes_no, :yes_no_cancel, :quit_cancel, :quit_save_cancel]
Constants inherited from DialogState
DialogState::DEFAULT_BACKGROUND_COLOR, DialogState::DEFAULT_BORDER_COLOR, DialogState::DEFAULT_SHADOW_COLOR, DialogState::DEFAULT_SHADOW_OFFSET
Constants inherited from GuiState
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from GuiState
Instance Method Summary collapse
-
#initialize(message, options = {}) {|result| ... } ⇒ MessageDialog
constructor
A new instance of MessageDialog.
Methods inherited from DialogState
Methods inherited from GuiState
clear, #clear, #cursor, #distance, #draw, #draw_frame, #draw_rect, #file_dialog, #finalize, #flush, #hide, #hide_menu, #menu, #message, #setup, #show, #show_menu, #t, #tool_tip_delay, #unset_mouse_over, #update, #write_tree
Constructor Details
#initialize(message, options = {}) {|result| ... } ⇒ MessageDialog
Returns a new instance of MessageDialog.
22 23 24 25 26 27 28 29 30 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 |
# File 'lib/fidgit/states/message_dialog.rb', line 22 def initialize(, = {}, &block) = { type: :ok, ok_text: "OK", yes_text: "Yes", no_text: "No", quit_text: "Quit", save_text: "Save", cancel_text: "Cancel", show: true, background_color: DEFAULT_BACKGROUND_COLOR, border_color: DEFAULT_BORDER_COLOR, width: $window.width / 2 }.merge! @type = [:type] raise ArgumentError, ":type must be one of #{VALID_TYPES}, not #{@type}" unless VALID_TYPES.include? @type super() # Dialog is forced to the centre. [:align_h] = [:align_v] = :center vertical do text_area(text: , enabled: false, width: [:width] - padding_left - padding_right) horizontal align_h: :center do @type.to_s.split('_').each do |type| ([:"#{type}_text"]) do hide block.call type.to_sym if block end end end end show if [:show] end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/fidgit/states/message_dialog.rb', line 7 def type @type end |