Class Ui::WxWidgets::Widgets::PropertiesPane
In: ui/wx/widgets/propertiespane.rb
Parent: Wx::Panel

Methods

Included Modules

Ui::PropertiesPaneInterface

Constants

EVT_PROPERTIES_APPLY = Wx::EvtHandler.register_class(Wx::CommandEvent, nil, 'evt_properties_apply', 1)

Public Class methods

=============================================== public methods

[Source]

# File ui/wx/widgets/propertiespane.rb, line 175
        def initialize(parent=nil)
          super(parent, Wx::ID_ANY, Wx::DEFAULT_POSITION, Wx::Size.new(400, 400), Wx::SUNKEN_BORDER )
          self.set_min_size(Wx::Size.new(400, 400))

          box_title = Wx::StaticBox.new(self, Wx::ID_ANY, MSG[:properties])
          box = Wx::StaticBoxSizer.new(box_title, Wx::HORIZONTAL)
          @grid = Wx::FlexGridSizer.new( 2 )
          box.add(@grid, 1, Wx::ALL, 5)

          
          @apply = Wx::Button.new(self, Wx::ID_ANY, MSG[:apply])
          @apply.disable
          
          # bubble the event as evt_properties_apply
          evt_button(@apply) do |e| 
            @apply.disable
            event = Wx::CommandEvent.new(EVT_PROPERTIES_APPLY, self.get_id)
            event.set_client_data(@node_id)
            event_handler.process_event( event ) 
          end
          
          sizer = Wx::BoxSizer.new(Wx::VERTICAL)
          sizer.add(box, 1, Wx::ALL|Wx::EXPAND, 5)
          sizer.add_spacer(10)
          sizer.add(@apply, 0, Wx::ALL|Wx::ALIGN_RIGHT|Wx::ALIGN_BOTTOM, 10 )
          
          self.set_sizer(sizer)
          
          # set the default empty view
          home()

          @skip_apply = true
        end

Public Instance methods

Returns an array of objects of Core::Model::Support::Property objects these can be marshalled into xml to be stored in a Note

[Source]

# File ui/wx/widgets/propertiespane.rb, line 227
        def get_properties()
          out = []
          label = nil
          prop = nil
          @grid.get_children.each do |item|
            if (control = item.get_window() )
              if (prop.nil? && control.instance_of?(Wx::StaticText))
                label = { :key => control.get_name, :name => control.get_label[0..-3]}
                next
              end
              case control
              when Wx::TextCtrl, Wx::SpinCtrl, Wx::CheckBox
                # key, name, value
                prop = Property.new( label[:key].to_sym, label[:name], control.get_value)
              when Wx::ListCtrl
                selections = control.get_selections#.collect do |idx| control.get_string(idx) end
                options = control.get_options #[]
                # key, name, value, options, multiple
                prop = MultipleChoiceProperty.new(
                          label[:key].to_sym, 
                          label[:name], 
                          selections, 
                          options, 
                          !control.has_flag(Wx::LC_SINGLE_SEL))
              end
              
              if !prop.nil?
                out << prop
                prop = nil
              end
            end
          end
          out
        end

See Ui::PropertiesPaneInterface#modified?

[Source]

# File ui/wx/widgets/propertiespane.rb, line 293
        def modified?
          return @apply.is_enabled()
        end

Show the properties of a speciffic node. This widget expects the properties information to be passed in an array of instances of Core::Model::Support::Property and it‘s subclasses

[Source]

# File ui/wx/widgets/propertiespane.rb, line 212
        def show_properties(node_id, properties) 
          @node_id = node_id
          @skip_apply = true
          clear_grid()
          
          populate_grid(properties)

          @grid.layout
          self.get_sizer.layout
          @apply.disable
          @skip_apply = false
        end

See Ui::PropertiesPaneInterface#update_property

[Source]

# File ui/wx/widgets/propertiespane.rb, line 269
        def update_property(property) 
          found = false
          i = 0
          begin
            # FIXME: ugly
            control = @grid.get_item(i)
            control = control.get_window unless control.nil?
            if control.instance_of?(Wx::StaticText)
              $logger.debug{ "StaticText control found, name: #{control.get_name}" }
              if control.get_name == property.key
                # FIXME: This only works for text & checkbox controls
                @grid.get_item(i+1).get_window.set_value( property.value )
                @apply.enable
                found = true
              end
            end
            i += 1
          end while(control)
          if not found
            Kernel.raise "The requested property :#{property.key} was not found"
          end
        end

not too sure about this

[Source]

# File ui/wx/widgets/propertiespane.rb, line 263
        def update_view(model=nil)
          clear_grid()
          home()
        end

[Validate]