www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - ui.EmailForm

/******************************************************************************
 * All Right Reserved. 
 * Copyright (c) 1998, 2004 Jackwind Li Guojie
 * 
 * Created on 2004-6-13 18:19:20 by JACK
 * $Id$
 * Port to the D programming language:
 *     yidabu at gmail dot com  ( D China
http://www.d-programming-language-china.org/ ) 
 *****************************************************************************/

module ui.EmailForm;

import dwtx.jface.action.Action;
import dwtx.jface.window.ApplicationWindow;
import dwt.DWT;
import dwt.layout.FillLayout;
import dwt.layout.GridData;
import dwt.layout.GridLayout;
import dwt.widgets.Button;
import dwt.widgets.Composite;
import dwt.widgets.Control;
import dwt.widgets.Label;
import dwt.widgets.Shell;
import dwt.widgets.Text;
import dwtx.ui.forms.widgets.FormToolkit;
import dwtx.ui.forms.widgets.ScrolledForm;

import dwt.dwthelper.utils;

import tango.util.log.Trace;


void main(String[] args) {
    EmailForm emailForm = new EmailForm(null);
    emailForm.setBlockOnOpen(true);
    emailForm.open();
}   

public class EmailForm  : ApplicationWindow {

  /**
   *  param parentShell
   */
  public this(Shell parentShell) {
    super(parentShell);
  }


    /* (non-Javadoc)
    *  see dwtx.jface.window.Window#createContents(dwt.widgets.Composite)
    */
    protected Control createContents(Composite parent) {
        Composite composite = new Composite(parent, DWT.NULL);
        composite.setLayout(new FillLayout());

        // Sets up the toolkit.
        FormToolkit toolkit = new FormToolkit(getShell().getDisplay());

        // Creates a form instance.
        // Form form = toolkit.createForm(composite);
        ScrolledForm form = toolkit.createScrolledForm(composite);
        form.setLayoutData(new GridData(GridData.FILL_BOTH));

        // Sets title.
        form.setText("Composing an Email Message");

        // Adds body contents.
        form.getBody().setLayout(new GridLayout(2, false));
        Label label = toolkit.createLabel(form.getBody(), "To: ", DWT.NULL);
        Text textTo = toolkit.createText(form.getBody(), "yidabu   gmail.com");
        textTo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        label = toolkit.createLabel(form.getBody(), "Subject: ", DWT.NULL);
        Text textSubject = toolkit.createText(form.getBody(), "D China");
        textSubject.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        label = toolkit.createLabel(form.getBody(), "Message: ", DWT.NULL);
        Text textMessage = toolkit.createText(form.getBody(), "D Programming
Language China:\n  http://www.d-programming-language-china.org/    ",
DWT.MULTI|DWT.BORDER);
        textMessage.setLayoutData(new GridData(GridData.FILL_BOTH));

        label = toolkit.createLabel(form.getBody(), "Option: ", DWT.NULL);
        Button buttonOption = toolkit.createButton(form.getBody(), "save a
copy", DWT.CHECK);

        Button buttonClose = toolkit.createButton(form.getBody(), "Close",
DWT.PUSH);
        GridData gridData = new GridData();
        gridData.horizontalSpan = 2;
        gridData.horizontalAlignment = GridData.END;
        buttonClose.setLayoutData(gridData);


        // Button button = toolkit.createButton(form.getBody(), "Test",
DWT.NULL);  

        // Adds tool bar items.
        form.getToolBarManager().add(new class("Send") Action {
            this(String text) {
                super(text);
            }                
            public void run() {
                Trace.formatln("Sending email ...");
            }
        });

        form.getToolBarManager().add(new class("Cancel") Action {
            this(String text) {
                super(text);
            }            
            public void run() {
                Trace.formatln("Cancelled.");
            }
        });

        form.updateToolBar();

        return composite;
    }

}



-- 
yidabu <yidabu.spam gmail.com>
http://www.dsource.org/projects/dwin

D ÓïÑÔ-ÖÐÎÄ(D Chinese):
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/
Jun 12 2008