Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] 'Create' event

Hello Lakshmi,

Thanks a lot for your reply. I'm honoured that it is by the SWT Component Lead herself !

Is the snippet you pointed me to (Snippet333) referenced from http://www.eclipse.org/swt/snippets? I haven't seen it.
What is the url of the git repository of the containing Snippet333?
I have tried (failed) to clone using :
http://git.eclipse.org/gitroot/platform/eclipse.platform.swt.git

It seems that the documentation for skinning is mostly in the javadoc of the org.eclipse.swt.widgets.Widget.reskin(int flags) method :

-----------------------------------------------------
The skin event is sent to the receiver's display when appropriate (usually before the next event is handled). Widgets are automatically marked for skinning upon creation as well as when its skin id or class changes. The skin id and/or class can be changed by calling Display.setData(String, Object) with the keys SWT.SKIN_ID and/or SWT.SKIN_CLASS. Once the skin event is sent to a widget, it will not be sent again unless reskin(int) is called on the widget or on an ancestor while specifying the SWT.ALL flag.
-----------------------------------------------------

What does it mean to change the skin id/class of the display ?
Is there a link you can point me to, to understand the intended use for skin ID and CLASS ?

Thanks a lot,

Damien Dudouit


2013/12/3 Lakshmi P Shanmugam <lakshmipriya.bms@xxxxxxxxx>

Hello Damien,

There is no SWT.Create event, yet. But, if you are looking for an event to manage the styling try using the SWT.Skin event. It is sent when the widget is created and when Widget.reskin() is called. Please see Snippet333 (http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet333.java) for an example on using it.

Thanks,

Lakshmi P Shanmugam



On Mon, Dec 2, 2013 at 8:16 PM, Damien Dudouit <ddudouit@xxxxxxx> wrote:
Hello,

I have been using SWT professionally for many years, creating many custom widgets, and I'm missing the ability to do the following :

    Display.getDefault().addFilter(SWT.Create, new Listener() {
      public void handleEvent(Event event) {
        ...
      }
    });

The SWT.Create constant and event do no exist yet. It is the opposite to SWT.Dispose.

It probably doesn't make sense to notify this event at the widget level since the widget must be created/instanciated to add a listener to it but it does at the Display.addFilter level.

The main use for me would be to manage styling accross the application :

    Display.getDefault().addFilter(SWT.Create, new Listener() {
      public void handleEvent(Event event) {
        if (event.widget instanceof Control) {
          ((Control) event.widget).setFont(myDefaultFont);
        }
      }
    });

Another use could be when implementing a widgets tree inspector.


At the end of the Control constructor, it could be something like this :

public Control (Composite parent, int style) {
    super (parent, style);
    this.parent = parent;
    createWidget ();

    Event event = new Event();
    event.type = SWT.Create;
    event.widget = this;
    display.filterEvent(event);

}

In any case, it must come after the setDefaultFont () method to be useful for styling :

void createWidget () {
    state |= DRAG_DETECT;
    foreground = background = "">     checkOrientation (parent);
    createHandle ();
    checkBackground ();
    checkBuffered ();
    checkComposited ();
    register ();
    subclass ();
    setDefaultFont ();
    checkMirrored ();
    checkBorder ();
    checkGesture ();
    if ((state & PARENT_BACKGROUND) != 0) {
        setBackground ();
    }
}

Best regards,

Damien

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev




--
Lakshmi

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top