Sorry -not getting anywhere with setText()
Max Samukha
nospam at nospam.com
Thu May 8 00:52:52 PDT 2008
On Thu, 08 May 2008 10:36:20 +0300, Max Samukha <nospam at nospam.com>
wrote:
>On Thu, 08 May 2008 02:26:27 -0400, June <somewhere at so.com> wrote:
>
>>Attach what I am trying to make work -not winning here ,round and round in loops
>>Any help appreciated
>
>You defined the setText(char[] name, char[] text) as nested function
>in Box's constructor. Move it out to the class' scope.
>
>Btw, 'public:' is not needed as class members are public by default.
>
>
The following may have typos but should demonstrate the idea described
in the previous thread:
class Box {
private Control[char[]] controls; // Use associative array
this (Composite parent ,int style ) {
auto box = new Composite(parent,DWT.SINGLE);
box.setSize(700,40);
auto No = new Text(box,DWT.LEFT);
No.setBounds(1,15,10,15);
No.setText("");
auto Date = new Text(box,DWT.LEFT);
Date.setBounds( 21, 15, 60, 15);
Date.setText("");
auto Content = new Text(box,DWT.LEFT);
Content.setBounds( 90, 15,70, 15);
Content.setText("");
box.setVisible = true;
controls["No"]=No;
controls["Date"]=Date;
controls["Content"]=Content;
box.setTabList(controls.values);
}
void setText(char[] name, char[] text)
{
controls[name].setText(text);
}
}
void main () {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setText("Boxes");
Box mybox = new Box(shell,DWT.SINGLE);
mybox.setText("No","wire");
mybox.setText("Content","Fishingline");
shell.pack();
shell.open();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
More information about the Digitalmars-d-learn
mailing list