www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Boxes - little boxes ,we all live in boxes

reply June <somewhere so.com> writes:
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 ();
}
May 08 2008
parent reply June <somewhere so.com> writes:
Could one of the kind gentlemen who answered previously please offer any
suggestion?
May 08 2008
parent reply Chris R. Miller <lordSaurontheGreat gmail.com> writes:
June Wrote:

 Could one of the kind gentlemen who answered previously please offer any
suggestion?

What is happening is that each composite inside the shell is managed by its own private layout manager. However, the shell itself is not managed by a layout manager, so they sorta stack on top of each other like rude people in a queue at Disneyland. Add a layout manager to your shell and you should be good to go!
May 08 2008
parent June <somewhere so.com> writes:
Chris R. Miller Wrote:

 June Wrote:
 
 Could one of the kind gentlemen who answered previously please offer any
suggestion?

What is happening is that each composite inside the shell is managed by its own private layout manager. However, the shell itself is not managed by a layout manager, so they sorta stack on top of each other like rude people in a queue at Disneyland. Add a layout manager to your shell and you should be good to go!

Thank You kind Sir. Finally got it to run
May 09 2008