Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Simulating native widgets by taking screen captures / screenshots / snapshots
Simulating native widgets by taking screen captures / screenshots / snapshots [message #520251] Thu, 11 March 2010 16:50 Go to next message
Bruno Medeiros is currently offline Bruno MedeirosFriend
Messages: 16
Registered: July 2009
Junior Member
Hello.

In the application I am working on, we are using a table widget (such as
NatTable, or KTable), that is a custom-drawn Canvas, for use with a very
large number of rows.
With that, we would like to have simple widgets like buttons and
checkboxes on that table, but because the table has a large dataset, we
rather not have true native widgets for every row, otherwise we might
hit OS limitations or performance problems, like Windows has.

So currently, we try to simulate the widgets by custom-drawing them
ourselves, while maintaining the native look. We do this by creating a
temporary shell, creating a real button/checkbox on the shell, and
taking a screen capture of the button/checkbox (in different states,
like selected, unselected, disabled, etc.), using an SWT GC.
The shell is created with SWT.ON_TOP, to ensure that when the screen
capture is done, no other windows are on top of the checkbox. (A problem
that occurs often otherwise, in Windows XP at least, making the
screenshot invalid.)

But this still feels like a bit of a hack, so I was wondering if anyone
had any insights on this issue, perhaps a way to improve on this
simulation technique, perhaps some problems that we haven't foreseen
yet, or perhaps another idea altogether?


Bruno Medeiros
Re: Simulating native widgets by taking screen captures / screenshots / snapshots [message #520252 is a reply to message #520251] Thu, 11 March 2010 16:58 Go to previous messageGo to next message
Christian is currently offline ChristianFriend
Messages: 72
Registered: July 2009
Member
Am 11.03.2010 17:50, schrieb Bruno Medeiros:
> Hello.
>
> In the application I am working on, we are using a table widget (such as
> NatTable, or KTable), that is a custom-drawn Canvas, for use with a very
> large number of rows.
> With that, we would like to have simple widgets like buttons and
> checkboxes on that table, but because the table has a large dataset, we
> rather not have true native widgets for every row, otherwise we might
> hit OS limitations or performance problems, like Windows has.
>
> So currently, we try to simulate the widgets by custom-drawing them
> ourselves, while maintaining the native look. We do this by creating a
> temporary shell, creating a real button/checkbox on the shell, and
> taking a screen capture of the button/checkbox (in different states,
> like selected, unselected, disabled, etc.), using an SWT GC.
> The shell is created with SWT.ON_TOP, to ensure that when the screen
> capture is done, no other windows are on top of the checkbox. (A problem
> that occurs often otherwise, in Windows XP at least, making the
> screenshot invalid.)
>
> But this still feels like a bit of a hack, so I was wondering if anyone
> had any insights on this issue, perhaps a way to improve on this
> simulation technique, perhaps some problems that we haven't foreseen
> yet, or perhaps another idea altogether?
>
>
> Bruno Medeiros

My Approach would be checking for which items are in view and creating
for them the widgets on the fly.. and disposing any which go out of view.
and using the usual methods for widgets on table .. i.e. TableEditor.
Re: Simulating native widgets by taking screen captures / screenshots / snapshots [message #520973 is a reply to message #520251] Tue, 16 March 2010 01:22 Go to previous messageGo to next message
MP Mising name is currently offline MP Mising nameFriend
Messages: 18
Registered: July 2009
Junior Member
Bruno Medeiros wrote:
> Hello.
>
> In the application I am working on, we are using a table widget (such as
> NatTable, or KTable), that is a custom-drawn Canvas, for use with a very
> large number of rows.
> With that, we would like to have simple widgets like buttons and
> checkboxes on that table, but because the table has a large dataset, we
> rather not have true native widgets for every row, otherwise we might
> hit OS limitations or performance problems, like Windows has.
>
> So currently, we try to simulate the widgets by custom-drawing them
> ourselves, while maintaining the native look. We do this by creating a
> temporary shell, creating a real button/checkbox on the shell, and
> taking a screen capture of the button/checkbox (in different states,
> like selected, unselected, disabled, etc.), using an SWT GC.
> The shell is created with SWT.ON_TOP, to ensure that when the screen
> capture is done, no other windows are on top of the checkbox. (A problem
> that occurs often otherwise, in Windows XP at least, making the
> screenshot invalid.)
>
> But this still feels like a bit of a hack, so I was wondering if anyone
> had any insights on this issue, perhaps a way to improve on this
> simulation technique, perhaps some problems that we haven't foreseen
> yet, or perhaps another idea altogether?
>
>
> Bruno Medeiros
Bruno,

How are you going about taking the screen capture? (for example, getting
the bounds of the widget whose image you want to take, thus only getting
the widget in the capture. And how are you saving it?)

LG
Re: Simulating native widgets by taking screen captures / screenshots / snapshots [message #521020 is a reply to message #520251] Tue, 16 March 2010 08:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

No using images is the only solution. Take a look here [1] on how we
used this to provide a TableViewer with native Checkboxes and futher
improvements [2].

[1] http://wiki.eclipse.org/JFaceSnippets#Snippet061FakedNativeC ellEditor
[2]https://bugs.eclipse.org/bugs/show_bug.cgi?id=301705

Tom

Am 11.03.10 17:50, schrieb Bruno Medeiros:
> Hello.
>
> In the application I am working on, we are using a table widget (such as
> NatTable, or KTable), that is a custom-drawn Canvas, for use with a very
> large number of rows.
> With that, we would like to have simple widgets like buttons and
> checkboxes on that table, but because the table has a large dataset, we
> rather not have true native widgets for every row, otherwise we might
> hit OS limitations or performance problems, like Windows has.
>
> So currently, we try to simulate the widgets by custom-drawing them
> ourselves, while maintaining the native look. We do this by creating a
> temporary shell, creating a real button/checkbox on the shell, and
> taking a screen capture of the button/checkbox (in different states,
> like selected, unselected, disabled, etc.), using an SWT GC.
> The shell is created with SWT.ON_TOP, to ensure that when the screen
> capture is done, no other windows are on top of the checkbox. (A problem
> that occurs often otherwise, in Windows XP at least, making the
> screenshot invalid.)
>
> But this still feels like a bit of a hack, so I was wondering if anyone
> had any insights on this issue, perhaps a way to improve on this
> simulation technique, perhaps some problems that we haven't foreseen
> yet, or perhaps another idea altogether?
>
>
> Bruno Medeiros
Re: Simulating native widgets by taking screen captures / screenshots / snapshots [message #521381 is a reply to message #521020] Wed, 17 March 2010 08:28 Go to previous messageGo to next message
Bruno Medeiros is currently offline Bruno MedeirosFriend
Messages: 16
Registered: July 2009
Junior Member
On 16/03/2010 08:53, Tom Schindl wrote:
> Hi,
>
> No using images is the only solution. Take a look here [1] on how we
> used this to provide a TableViewer with native Checkboxes and futher
> improvements [2].
>

Is it really the only solution? What about Christian's idea of creating
and disposing widgets on the fly, as the view is scrolled? It sounds
interesting, but does it have any problems in practice?


> [1] http://wiki.eclipse.org/JFaceSnippets#Snippet061FakedNativeC ellEditor
> [2]https://bugs.eclipse.org/bugs/show_bug.cgi?id=301705
>
> Tom
>

BTW, does it make sense for JFace to provide such a functionality
out-of-the-box, ie, something like the CheckboxImages class in that snippet?

Bruno
Re: Simulating native widgets by taking screen captures / screenshots / snapshots [message #521387 is a reply to message #521381] Wed, 17 March 2010 13:27 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Am 17.03.10 14:06, schrieb Bruno Medeiros:
> On 16/03/2010 08:53, Tom Schindl wrote:
>> Hi,
>>
>> No using images is the only solution. Take a look here [1] on how we
>> used this to provide a TableViewer with native Checkboxes and futher
>> improvements [2].
>>
>
> Is it really the only solution? What about Christian's idea of creating
> and disposing widgets on the fly, as the view is scrolled? It sounds
> interesting, but does it have any problems in practice?

Positioning is an extra task and your control will not behave as good as
it would with images beside that your need of handles will increase in
linear with the number of Widgets visible, even if all of them display
e.g. the same information whereas with images you can produce reuse.

Tom
Re: Simulating native widgets by taking screen captures / screenshots / snapshots [message #521534 is a reply to message #521387] Wed, 17 March 2010 23:22 Go to previous message
MP Mising name is currently offline MP Mising nameFriend
Messages: 18
Registered: July 2009
Junior Member
Tom Schindl wrote:
> Am 17.03.10 14:06, schrieb Bruno Medeiros:
>> On 16/03/2010 08:53, Tom Schindl wrote:
>>> Hi,
>>>
>>> No using images is the only solution. Take a look here [1] on how we
>>> used this to provide a TableViewer with native Checkboxes and futher
>>> improvements [2].
>>>
>> Is it really the only solution? What about Christian's idea of creating
>> and disposing widgets on the fly, as the view is scrolled? It sounds
>> interesting, but does it have any problems in practice?
>
> Positioning is an extra task and your control will not behave as good as
> it would with images beside that your need of handles will increase in
> linear with the number of Widgets visible, even if all of them display
> e.g. the same information whereas with images you can produce reuse.
>
> Tom

I agree with Tom that this is the best solution. That's why I was
asking how you had implemented the screen capture (or widget capture).
Making sure you have an "as optimized as possible" process to handle
that would help with performance.

The links Tom gave should be helpful.

LG
Previous Topic:Printer duplex support
Next Topic:How do I create a new Launch Configuration Tab?
Goto Forum:
  


Current Time: Thu Apr 18 04:46:22 GMT 2024

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

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

Back to the top