Boxes - little boxes ,we all live in boxes

June somewhere at so.com
Thu May 8 18:03:32 PDT 2008


Well I have got something working at least . It builds three sets of three text boxes and puts text in them . I didnt use the AA sugested or the Controls at all yet !

Just overrode the setText() method and overloaded it also with different  parameters.

However It only shows one set of boxes,the first but I know the others are there but hidden because the tab moves through nine fields

----------------------------------------------------------------------------------------------------------------
module Box;
import dwt.DWT;
import dwt.widgets.Composite;
import dwt.widgets.Control;
import dwt.widgets.Text;
import dwt.widgets.Shell;
import dwt.widgets.Display;
import tango.io.Stdout;
import dwt.layout.GridLayout;

class Box {
    Text One; //*****I dont see that these change anything
    Text Two;
    Text Three;
    private Control[ char[]  ] names; // Use associative array *********why-doesnt do anything more that I can see but this is probably how I get boxes 2 and 3 to show
    

this (Composite parent ,int style ) {
    auto box = new Composite(parent,DWT.SINGLE);
    GridLayout layout = new GridLayout;
    parent.layout();
One = new Text(box,DWT.LEFT);
    One.setSize(50,20);
    One.setLocation(10,20);

Two = new Text(box,DWT.LEFT);
    Two.setSize(50,20);
    Two.setLocation(70,20);

Three   = new Text(box,DWT.LEFT);
    Three.setSize(50, 20);
    Three.setLocation(130,20);

    names["One"] = One;  //I'm not using this atm
    names["Two"] = Two;
    names["Three"]   = Three;

box.setSize (200,40);
box.setVisible(true);
}
  void setText(char[] text)
{ 
  setText(text);
  
}

  void setText(char[] text1, char[]text2, char[]text3 )
  {
    One.setText(text1);
    Two.setText(text2);
    Three.setText(text3);
    
   }
}

void main () {
  Display display = new Display ();
  Shell shell = new Shell (display);
  shell.setText("Boxes");
  
Box mybox1 = new Box(shell,DWT.SINGLE);
  mybox1.setText("screws","wire","bolts" );
  
  
Box mybox2 = new Box(shell,DWT.SINGLE);
  mybox2.setText("String","Fishingline","Rope");
  

Box mybox3 = new Box(shell,DWT.SINGLE);
  mybox3.setText("Tape","Glue","Spreaders");
  

  //shell.pack();
  shell.open();        
  while (!shell.isDisposed ()) {
    if (!display.readAndDispatch ()) display.sleep ();
  }
  display.dispose ();
}



More information about the Digitalmars-d-learn mailing list