Sorry -not getting anywhere with setText()

Max Samukha nospam at nospam.com
Thu May 8 03:48:10 PDT 2008


On Thu, 08 May 2008 05:53:22 -0400, June <somewhere at so.com> wrote:

>Max Samukha Wrote:
>
>> On Thu, 08 May 2008 04:35:18 -0400, June <somewhere at so.com> wrote:
>> 
>> >Max Samukha Wrote:
>> >
>> >> 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 ();
>> >> }
>> >Hi & Thanks .. I tried this and adjusted a couple of lines in Main that I had wrong . Still get a compile error related to controls?
>> 
>> The attached file is empty
>This site seems slow ,I did not check Sorry

Unlike in .NET winforms, you cannot set text for any control and
Control class does not have a setText property so if you don't plan to
use other controls than Text, declare the value type of the
associative array to be Text. Also I'm not sure that Composite has a
setTabList property. Please consult SWT reference.

And if I understand correctly you are going to use lots of textboxes.
If you are going to present a list or tabular data, it would be better
for performance and yourself to use a grid or list control whatever is
appropriate and available in DWT.  


More information about the Digitalmars-d-learn mailing list