Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Custom-Drawing in first Tree-Column problem on Windows
Custom-Drawing in first Tree-Column problem on Windows [message #655126] Fri, 18 February 2011 12:28 Go to next message
Manuel Steurer is currently offline Manuel SteurerFriend
Messages: 37
Registered: July 2009
Member
This is a multipart message in MIME format

--Xananews.1.2.3

Hi,

I've modified the SWT Snippet 230 to use a Tree instead of a Table and
also mixed in the drawing logic from Jface Snippet 51 to draw an image
in the center of each column, see attached snippet. When you resize the
columns the Image moves along with it in all columns but the first.
Once you "dip" the window outside the screen and get it back it is
correctly painted.

The problem does not exist on Linux, and also not when using a Table
instead of a Tree.

Is this a known Windows bug I have to live with or is this something
that can be fixed in SWT?

Greetings,
Manuel

--Xananews.1.2.3
Content-Type: Application/Octet-Stream; name=Snippet230Tree.java
Content-Transfer-Encoding: base64

LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq KioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioNCiAqIENvcHlyaWdodCAoYykgMjAw MCwgMjAwNiBJQk0g
Q29ycG9yYXRpb24gYW5kIG90aGVycy4NCiAqIEFsbCByaWdodHMgcmVzZXJ2 ZWQuIFRoaXMgcHJv
Z3JhbSBhbmQgdGhlIGFjY29tcGFueWluZyBtYXRlcmlhbHMNCiAqIGFyZSBt YWRlIGF2YWlsYWJs
ZSB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEVjbGlwc2UgUHVibGljIExpY2Vu c2UgdjEuMA0KICog
d2hpY2ggYWNjb21wYW5pZXMgdGhpcyBkaXN0cmlidXRpb24sIGFuZCBpcyBh dmFpbGFibGUgYXQN
CiAqIGh0dHA6Ly93d3cuZWNsaXBzZS5vcmcvbGVnYWwvZXBsLXYxMC5odG1s DQogKg0KICogQ29u
dHJpYnV0b3JzOg0KICogICAgIElCTSBDb3Jwb3JhdGlvbiAtIGluaXRpYWwg QVBJ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5k
cy54ICsgYm91bmRzLndpZHRoIDogYm91bmRzLng7DQoJCQkJCWludCB5ID0g Ym91bmRzLmhlaWdo
dCA+IDAgPyBib3VuZHMueSArIGJvdW5kcy5oZWlnaHQgOiBib3VuZHMueTsN Cg0KCQkJCQlldmVu
dC5nYy5kcmF3SW1hZ2UoaW1hZ2UsIHgsIHkpOw0KCQkJCQlicmVhazsNCgkJ CQl9DQoJCQl9DQoJ
CX0NCgl9OwkJDQoJdHJlZS5hZGRMaXN0ZW5lcihTV1QuUGFpbnRJdGVtLCBw YWludExpc3RlbmVy
KTsJCQ0KDQoJZm9yKGludCBpID0gMDsgaSA8IGNvbHVtbkNvdW50OyBpKysp IHsNCgkJdHJlZS5n
ZXRDb2x1bW4oaSkucGFjaygpOw0KCX0JDQoJc2hlbGwuc2V0U2l6ZSg1MDAs IDIwMCk7DQoJc2hl
bGwub3BlbigpOw0KCXdoaWxlKCFzaGVsbC5pc0Rpc3Bvc2VkICgpKSB7DQoJ CWlmKCFkaXNwbGF5
LnJlYWRBbmREaXNwYXRjaCgpKSBkaXNwbGF5LnNsZWVwKCk7DQoJfQ0KCWlm KGltYWdlICE9IG51
bGwpIGltYWdlLmRpc3Bvc2UoKTsNCglkaXNwbGF5LmRpc3Bvc2UoKTsNCn0N Cn0=

--Xananews.1.2.3--
Re: Custom-Drawing in first Tree-Column problem on Windows [message #655817 is a reply to message #655126] Tue, 22 February 2011 16:53 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Manuel,

This is probably a bug that could be fixed in swt, so feel free to log a
report at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT
and provide the snippet from this post.

In the meantime, a workaround you could use would be to detect this case and
redraw the first column, like the lines I've pasted below. If your real
case resembles the snippet you've provided then this should work reasonably
well.

/* work around swt bug... */
if (SWT.getPlatform().equals("win32")) {
tree.getColumn(0).addListener(SWT.Resize, new Listener() {
public void handleEvent(Event event) {
tree.getDisplay().asyncExec(new Runnable() {
public void run() {
if (tree.isDisposed()) return;
/* assumes logical column 0 is also first physical
column */
tree.redraw(0, 0, tree.getColumn(0).getWidth(),
tree.getBounds().height, true);
}
});
}
});
}

HTH,
Grant


"Manuel Steurer" <manuel.steurer@quattro-soft.de> wrote in message
news:ijlom1$j40$1@news.eclipse.org...
> Hi,
>
> I've modified the SWT Snippet 230 to use a Tree instead of a Table and
> also mixed in the drawing logic from Jface Snippet 51 to draw an image
> in the center of each column, see attached snippet. When you resize the
> columns the Image moves along with it in all columns but the first.
> Once you "dip" the window outside the screen and get it back it is
> correctly painted.
>
> The problem does not exist on Linux, and also not when using a Table
> instead of a Tree.
>
> Is this a known Windows bug I have to live with or is this something
> that can be fixed in SWT?
>
> Greetings,
> Manuel
>
Re: Custom-Drawing in first Tree-Column problem on Windows [message #655977 is a reply to message #655817] Wed, 23 February 2011 15:35 Go to previous message
Manuel Steurer is currently offline Manuel SteurerFriend
Messages: 37
Registered: July 2009
Member
Hi,

thanks for your answer, I tried the workaround and it works for me.
I also logged this bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337985

Greetings,
Manuel


Grant Gayed wrote:

> Hi Manuel,
>
> This is probably a bug that could be fixed in swt, so feel free to
> log a report at
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component
> =SWT and provide the snippet from this post.
>
> In the meantime, a workaround you could use would be to detect this
> case and redraw the first column, like the lines I've pasted below.
> If your real case resembles the snippet you've provided then this
> should work reasonably well.
>
> /* work around swt bug... */
> if (SWT.getPlatform().equals("win32")) {
> tree.getColumn(0).addListener(SWT.Resize, new Listener() {
> public void handleEvent(Event event) {
> tree.getDisplay().asyncExec(new Runnable() {
> public void run() {
> if (tree.isDisposed()) return;
> /* assumes logical column 0 is also first physical
> column */ tree.redraw(0, 0,
> tree.getColumn(0).getWidth(), tree.getBounds().height, true);
> } });
> }
> });
> }
>
> HTH,
> Grant
>
>
> "Manuel Steurer" <manuel.steurer@quattro-soft.de> wrote in message
> news:ijlom1$j40$1@news.eclipse.org...
> > Hi,
> >
> > I've modified the SWT Snippet 230 to use a Tree instead of a Table
> > and also mixed in the drawing logic from Jface Snippet 51 to draw
> > an image in the center of each column, see attached snippet. When
> > you resize the columns the Image moves along with it in all columns
> > but the first. Once you "dip" the window outside the screen and
> > get it back it is correctly painted.
> >
> > The problem does not exist on Linux, and also not when using a Table
> > instead of a Tree.
> >
> > Is this a known Windows bug I have to live with or is this something
> > that can be fixed in SWT?
> >
> > Greetings,
> > Manuel
> >



--
Previous Topic:Showing log file in TextViewer
Next Topic:Running a SWT app in a different OS
Goto Forum:
  


Current Time: Sat Apr 27 01:48:14 GMT 2024

Powered by FUDForum. Page generated in 0.03550 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top