Class: Okayu::ColorDialog

Inherits:
Wx::Dialog
  • Object
show all
Defined in:
lib/views/color_dialog.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ ColorDialog

Returns a new instance of ColorDialog.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/views/color_dialog.rb', line 18

def initialize parent
  super(parent, :id => Wx::ID_ANY, :title => "色指定", :style => Wx::DEFAULT_DIALOG_STYLE | Wx::NO_3D)

  h_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
  h_sizer.add(create_color_buttons([:red, :pink]))
  h_sizer.add(create_color_buttons([:orange, :yellow]))
  h_sizer.add(create_color_buttons([:purple]))
  h_sizer.add(create_color_buttons([:green]))
  h_sizer.add(create_color_buttons([:blue]))
  h_sizer.add(create_color_buttons([:brown]))
  h_sizer.add(create_color_buttons([:white]))
  h_sizer.add(create_color_buttons([:grey]))

  set_sizer(h_sizer)
  h_sizer.set_size_hints(self)

  evt_button(Wx::ID_ANY){|event| on_button(event)}
end

Instance Method Details

#create_color_buttons(color_group_names) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/views/color_dialog.rb', line 37

def create_color_buttons color_group_names
  sizer = Wx::BoxSizer.new(Wx::VERTICAL)
  color_group_names.each do |color_group_name|
    sizer.add(Wx::StaticText.new(self, :id => Wx::ID_ANY, :label => "#{color_group_name.to_s.capitalize} colors"))
    COLOR_GROUPS[color_group_name].each do |color_index|
      sizer.add(ColorButton.new(self, color_index))
    end
  end
  sizer
end

#on_button(event) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/views/color_dialog.rb', line 48

def on_button event
  if event.get_id >= COLOR_BUTTON_ID_FROM && event.get_id < COLOR_BUTTON_ID_FROM + COLORS.length
    end_modal(event.get_id - COLOR_BUTTON_ID_FROM)
  else
    end_modal -1
  end
end