My first thought was to use events but then I thought Observer/Observable
might make better sense. Some basic sample code is below. As always, this
implementation is liable to be incomplete, and there may be better ways, but
this seems to do what I think you're asking for.
Cheese
||
{curl 3.0 applet}
{import * from CURL.UTIL.OBSERVER}
{define-class MyTable {inherits Table, Observer, Observable}
{constructor {default ...}
{construct-super.Table ...}
}
{method public {handle-observer-message source:Observable,
message:any}:void
{type-switch message
case ws:{Array-of any} do
{for i:int = 0 below ws.size do
{if i self.column-count then
|| I'm not sure, but there may be times where
|| you want to check ws[i] for null first.
set {self.get-column i}.width = ws[i]
}
}
}
}
{method public {notify message:any = null}:void
let ws:{Array-of any} = {new {Array-of any}}
{for i:int = 0 below self.column-count do
{ws.append {self.get-column i}.width}
}
{self.notify-observers message = ws}
}
}
{value
let t1:MyTable =
{MyTable
cell-border-width = 1pt,
cell-border-color = black,
A, B, C
}
let t2:MyTable =
{MyTable
cell-border-width = 1pt,
cell-border-color = black,
A, B, C
}
{t1.add-observer t2}
||--{t2.add-observer t1}
{VBox
{ScrollBox
width = 6cm,
t1
},
{ScrollBox
t2
},
{HBox
{CommandButton
label = Set,
{on Action do
set {t1.get-column 0}.width = 1cm
set {t1.get-column 1}.width = 3cm
{t1.notify}
}
},
{CommandButton
label = Reset,
{on Action do
{if-non-null tc = {t1.get-column 0} then
{unset tc.width}
}
{if-non-null tc = {t1.get-column 1} then
{unset tc.width}
}
{t1.notify}
}
}
}
}
}
- Original Message -
From: Friedger [EMAIL PROTECTED]
To: Curlbreaker-l [EMAIL PROTECTED]
Sent: Sunday, June 06, 2004 10:32 AM
Subject: Synchronize column width of two tables
Hi,
is it possible to synchronise the column widths of two different tables?
I would like to use it like the following:
{VBox
{ScrollBox
{Table A, B, C}
},
{ScrollBox
{Table A, B, C}
}
}
Any thoughts?
Cheers,
Friedger
***
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]
***
To unsubscribe from this list, send a mail to:
mailto:[EMAIL PROTECTED]
To contact a human list administrator, send a mail to:
mailto:[EMAIL PROTECTED]
To recieve a list of other options for this list, send a mail to:
mailto:[EMAIL PROTECTED]