Class: RubyCurses::DefaultTableColumnModel
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
#bind, #fire_handler, #fire_property_change
#total_column_width
Constructor Details
takes a column names array
1358
1359
1360
1361
1362
1363
1364
1365
|
# File 'lib/rbcurse/rtable.rb', line 1358
def initialize cols=[]
@columns = []
@total_column_width= -1
cols.each_with_index {|c, index| add_column(TableColumn.new(index, c, c, 10)) }
@selected_columns = []
@_events = [:TABLE_COLUMN_MODEL_EVENT, :PROPERTY_CHANGE]
end
|
Instance Attribute Details
#column_selection_allowed ⇒ Object
Returns the value of attribute column_selection_allowed.
1354
1355
1356
|
# File 'lib/rbcurse/rtable.rb', line 1354
def column_selection_allowed
@column_selection_allowed
end
|
Instance Method Details
#add_column(tc) ⇒ Object
1404
1405
1406
1407
1408
1409
|
# File 'lib/rbcurse/rtable.rb', line 1404
def add_column tc
@columns << tc
tc.bind(:PROPERTY_CHANGE){|e| column_property_changed(e)}
tmce = TableColumnModelEvent.new(nil, @columns.length-1, self, :INSERT)
fire_handler :TABLE_COLUMN_MODEL_EVENT, tmce
end
|
#clear_selection ⇒ Object
1387
1388
1389
|
# File 'lib/rbcurse/rtable.rb', line 1387
def clear_selection
@selected_columns = []
end
|
#column(ix) ⇒ Object
1366
1367
1368
1369
|
# File 'lib/rbcurse/rtable.rb', line 1366
def column ix
raise "Invalid arg #{ix}" if ix < 0 or ix > (@columns.length() -1)
@columns[ix]
end
|
#column_count ⇒ Object
1378
1379
1380
|
# File 'lib/rbcurse/rtable.rb', line 1378
def column_count
@columns.length
end
|
#column_index(identifier) ⇒ Object
return index of column identified with identifier
1430
1431
1432
1433
|
# File 'lib/rbcurse/rtable.rb', line 1430
def column_index identifier
@columns.each_with_index {|c, i| return i if c.identifier == identifier }
return nil
end
|
#column_property_changed(evt) ⇒ Object
1410
1411
1412
1413
1414
|
# File 'lib/rbcurse/rtable.rb', line 1410
def column_property_changed evt
$log.debug "DTCM def column_property_changed #{evt} "
fire_handler :PROPERTY_CHANGE, self
end
|
1370
|
# File 'lib/rbcurse/rtable.rb', line 1370
def columns; @columns; end
|
1373
1374
1375
1376
1377
|
# File 'lib/rbcurse/rtable.rb', line 1373
def each
@columns.each { |c|
yield c
}
end
|
#get_selection_model ⇒ Object
TODO - if we get into column selection somewhen
1435
1436
1437
|
# File 'lib/rbcurse/rtable.rb', line 1435
def get_selection_model
@lsm
end
|
#get_total_column_width ⇒ Object
1392
1393
1394
1395
1396
1397
1398
1399
1400
|
# File 'lib/rbcurse/rtable.rb', line 1392
def get_total_column_width
@total_column_width = -1 if @total_column_width == -1
total = 0
each { |c| total += c.width ; $log.debug "get_total_column_width: #{c.width}"}
@total_column_width = total
end
return @total_column_width
end
|
#move_column(ix, newix) ⇒ Object
1421
1422
1423
1424
1425
1426
1427
|
# File 'lib/rbcurse/rtable.rb', line 1421
def move_column ix, newix
acol = @columns.delete_at ix
@columns.insert newix, acol
tmce = TableColumnModelEvent.new(ix, newix, self, :MOVE)
fire_handler :TABLE_COLUMN_MODEL_EVENT, tmce
end
|
#remove_column(tc) ⇒ Object
1415
1416
1417
1418
1419
1420
|
# File 'lib/rbcurse/rtable.rb', line 1415
def remove_column tc
ix = @columns.index tc
@columns.delete tc
tmce = TableColumnModelEvent.new(ix, nil, self, :DELETE)
fire_handler :TABLE_COLUMN_MODEL_EVENT, tmce
end
|
#selected_column_count ⇒ Object
1381
1382
1383
|
# File 'lib/rbcurse/rtable.rb', line 1381
def selected_column_count
@selected_columns.length
end
|
#selected_columns ⇒ Object
1384
1385
1386
|
# File 'lib/rbcurse/rtable.rb', line 1384
def selected_columns
@selected_columns
end
|
#set_selection_model(lsm) ⇒ Object
1401
1402
1403
|
# File 'lib/rbcurse/rtable.rb', line 1401
def set_selection_model lsm
@column_selection_model = lsm
end
|