Class: Watobo::Gui::RulesTable
- Inherits:
-
FXTable
- Object
- FXTable
- Watobo::Gui::RulesTable
- Defined in:
- lib/watobo/gui/rewrite_rules_dialog.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
- #add_rule(rule) ⇒ Object
- #current_rule ⇒ Object
- #delete_current_row ⇒ Object
- #delete_row_by_index(index) ⇒ Object
-
#initialize(owner, rules = [], opts = {}) ⇒ RulesTable
constructor
A new instance of RulesTable.
- #reset_table ⇒ Object
Constructor Details
#initialize(owner, rules = [], opts = {}) ⇒ RulesTable
Returns a new instance of RulesTable.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 190 def initialize( owner, rules=[], opts={} ) @event_dispatcher_listeners = Hash.new parms = { :opts => TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2 } parms.update opts super(owner, parms) self.extend Watobo::Subscriber self.setBackColor(FXRGB(255, 255, 255)) self.setCellColor(0, 0, FXRGB(255, 255, 255)) self.setCellColor(0, 1, FXRGB(255, 240, 240)) self.setCellColor(1, 0, FXRGB(240, 255, 240)) self.setCellColor(1, 1, FXRGB(240, 240, 255)) @columns=Hash.new @rules = [] @rules.concat rules add_column "Action", 50 add_column "Location", 80 add_column "Pattern", 80 add_column "Content", 80 add_column "Filter", 80 init_columns @rules.each do |r| add_rule_row r end adjust_cell_width self.connect(SEL_SELECTED){|sender,sel,pos| self.selectRow pos.row # notify(:rule_selected, @rules[pos.row]) } end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
154 155 156 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 154 def rules @rules end |
Instance Method Details
#add_rule(rule) ⇒ Object
155 156 157 158 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 155 def add_rule(rule) @rules << rule add_rule_row(rule) end |
#current_rule ⇒ Object
160 161 162 163 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 160 def current_rule return nil if self.currentRow < 0 return @rules[self.currentRow] end |
#delete_current_row ⇒ Object
184 185 186 187 188 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 184 def delete_current_row i = self.currentRow return false if i < 0 delete_row_by_index i end |
#delete_row_by_index(index) ⇒ Object
165 166 167 168 169 170 171 172 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 165 def delete_row_by_index(index) return false if index < 0 return false if index > self.numRows-1 @rules.delete_at index self.clearItems reset_table true end |
#reset_table ⇒ Object
174 175 176 177 178 179 180 181 182 |
# File 'lib/watobo/gui/rewrite_rules_dialog.rb', line 174 def reset_table init_columns @rules.each do |r| add_rule_row r end adjust_cell_width self.selectRow self.currentRow if self.currentRow >= 0 end |