[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [platform-swt-dev] Cannot layout new widgets on a non rectangular shell
|
Hi Nick,
No i just need a comp on a vertical scroll comp on a shell. This is a new pop up shell i am creating from my application. Now i needed multiple things, first is the shell which is non rectangular and has a image background which should propagate to the comp and any further widgets i lay on it, but so far it is not working. What kind of problems you had when you created multiple shells from your app.
Thanks,
abhi
On 4/2/07, nick <nick@xxxxxxxxxxxxxxxx> wrote:
You can place a Composite into a ScrolledComposite, this works for me.
Do you need
to be able to resize the ScrolledComposite? But the shell (main window)
itself is fixed since it is based on
a transparent image correct (or do you create those images on the fly
and need the window to
reflect changes done to the image?)?
Could you please explain in more detail?
/nick
PS: I had problems to use multiple shells within an application. You
might want to avoid
this.
Abhishek Misra wrote:
> Hi Carolyn,
> I was trying to create a custom widget where the shell
> could be created from a transparent image and i could at the very
> minimum layout a Composite on a ScrolledComposite which will be on the
> shell. I have so far been unable to accomplish the same probably
> because of the fact that Scrolled composite is not fixed in size. Any
> insights what is the best way to this?
>
> Thanks,
> abhi
>
>
> On 4/2/07, *Carolyn MacLeod* <Carolyn_MacLeod@xxxxxxxxxx
> <mailto:Carolyn_MacLeod@xxxxxxxxxx
>> wrote:
>
> Hi, Abhishek,
> I think it would be easier in this case to just draw your label
> text on
> the shell instead of using a control.
> For example, delete the Composite and CLabel code, and add
> something like
> the following to the Paint event, right after the drawImage:
> e.gc.drawString("Hello there", imageData.x + 10,
> imageData.y, true
> );
> Also, please note that CLabel does not support SWT.WRAP style.
>
> Nick,
> Please use SWT.NONE instead of SWT.NO <http://SWT.NO
> when
> creating a Composite or Button
> with none of their style bits set.
>
> Hope this helps,
> Carolyn
>
>
>
>
>
>
> nick <
nick@xxxxxxxxxxxxxxxx <mailto:nick@xxxxxxxxxxxxxxxx>>
> Sent by:
platform-swt-dev-bounces@xxxxxxxxxxx
> <mailto:platform-swt-dev-bounces@xxxxxxxxxxx>
> 04/02/2007 08:40 PM
> Please respond to
> "Eclipse Platform SWT component developers list."
> <platform-swt-dev@xxxxxxxxxxx <mailto:
platform-swt-dev@xxxxxxxxxxx>>
>
>
> To
> "Eclipse Platform SWT component developers list."
> <platform-swt-dev@xxxxxxxxxxx
<mailto:platform-swt-dev@xxxxxxxxxxx>>
> cc
>
> Subject
> Re: [platform-swt-dev] Cannot layout new widgets on a non rectangular
> shell
>
>
>
>
>
>
> I don't think that this is related to the non-rectangular shape
> of the
> shell. Looks
> more like a layout problem.
>
> replace
>
> -----------------------
> final Composite comp = new Composite(shell, SWT.NONE);
> comp.setBackgroundMode(SWT.INHERIT_FORCE);
> GridLayout layout = new GridLayout(1, false);
> .
> .
> -----------------------
> with
>
> -----------------------
> Composite composite = new Composite(shell, SWT.NO <
http://SWT.NO>);
> composite.setLayout(new FillLayout());
> Button button1 = new Button(shell, SWT.NO
> <
http://SWT.NO>);
> button1.setLocation(5, 5);
> button1.setSize(150, 20);
> button1.setText("hello");
> -----------------------
>
> and the button will show up
>
> /nick
>
> Abhishek Misra wrote:
>
> > Created from snippet 219.
> >
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet219.java?view=co
> <
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet219.java?view=co>
>
> > <
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet219.java?view=co
> <
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet219.java?view=co>
> >
> >
> > I changed the image in the above snippet to a bigger 500*200 image
> > which is transparent and use that.
> >
> > I am trying to create a new composite on the shell created in above
> > step and put a label on it, but it doesn't work. All that shows
> up is
> > shell with the image.
> >
> > final Display display = new Display ();
> > final Image image = ImageManager.getImage
> ("info_window.png");
> > final Shell shell = new Shell (display, SWT.NO_TRIM);
> > Region region = new Region();
> > final ImageData imageData = image.getImageData();
> > if (
imageData.alphaData != null) {
> > Rectangle pixel = new Rectangle(0, 0, 1, 1);
> > for (int y = 0; y < imageData.height; y++) {
> > for (int x = 0; x <
imageData.width ; x++) {
> > if (imageData.getAlpha(x, y) == 255) {
> > pixel.x = imageData.x + x;
> > pixel.y = imageData.y
+ y;
> > region.add(pixel);
> > }
> > }
> > }
> > } else {
> > ImageData mask =
imageData.getTransparencyMask();
> > Rectangle pixel = new Rectangle(0, 0, 1, 1);
> > for (int y = 0; y < mask.height; y++) {
> > for (int x = 0; x <
mask.width; x++) {
> > if (mask.getPixel(x, y) != 0) {
> > pixel.x = imageData.x + x;
> > pixel.y = imageData.y + y;
> > region.add(pixel);
> > }
> > }
> > }
> > }
> > shell.setRegion
(region);
> >
> > final Composite comp = new Composite(shell, SWT.NONE);
> > comp.setBackgroundMode(SWT.INHERIT_FORCE);
> > GridLayout layout = new GridLayout(1, false);
> > layout.marginRight = 10;
> > comp.setLayout(layout);
> > GridData data = "" GridData(GridData.FILL_BOTH);
> > comp.setLayoutData(data);
> > CLabel label = new CLabel(comp, SWT.WRAP);
> >
> label.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
> >
> > final GridData textData = new
> > GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL);
> > textData.horizontalIndent = 0;
> > textData.verticalIndent = 0;
> >
label.setLayoutData(textData);
> > label.setBackgroundMode(SWT.INHERIT_DEFAULT);
> >
> > Listener l = new Listener() {
> > int startX, startY;
> > public void handleEvent(Event e) {
> > if (e.type == SWT.KeyDown && e.character ==
> SWT.ESC) {
> > shell.dispose
();
> > }
> > if (e.type == SWT.MouseDown && e.button == 1) {
> > startX = e.x;
> > startY =
e.y;
> > }
> > if (e.type == SWT.MouseMove && (e.stateMask &
> > SWT.BUTTON1) != 0) {
> > Point p = shell.toDisplay
(e.x, e.y);
> > p.x -= startX;
> > p.y -= startY;
> > shell.setLocation(p);
> > }
> > if (
e.type == SWT.Paint) {
> > e.gc.drawImage(image, imageData.x, imageData.y);
> > }
> > }
> > };
> >
shell.addListener(SWT.KeyDown, l);
> > shell.addListener(SWT.MouseDown, l);
> > shell.addListener(SWT.MouseMove, l);
> > shell.addListener(SWT.Paint, l);
> >
> > shell.setSize(imageData.x + imageData.width, imageData.y +
> > imageData.height);
> > shell.layout();
> > shell.open ();
> > while (!shell.isDisposed ()) {
> > if (!display.readAndDispatch ())
> > display.sleep ();
> > }
> > region.dispose();
> > image.dispose
();
> > display.dispose ();
> > }
> >
> > Any idea what's wrong?
> >
> >
> >
> > Thanks,
> > abhi
> >
> >------------------------------------------------------------------------
>
> >
> >_______________________________________________
> >platform-swt-dev mailing list
> >platform-swt-dev@xxxxxxxxxxx <mailto:platform-swt-dev@xxxxxxxxxxx>
> >
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
> >
> >
>
> _______________________________________________
> platform-swt-dev mailing list
>
platform-swt-dev@xxxxxxxxxxx <mailto:platform-swt-dev@xxxxxxxxxxx>
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
>
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx <mailto:
platform-swt-dev@xxxxxxxxxxx>
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>platform-swt-dev mailing list
>
platform-swt-dev@xxxxxxxxxxx
>https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
>
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev