Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Graphics Context and Draw Object
Graphics Context and Draw Object [message #5827] Wed, 18 October 2006 14:52 Go to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

Hey, I am trying to create a version of the Scintilla control for UPP <http://www.scintilla.org/>. I have mostly finished my concept design, but have one major problem: Scintilla requires the use of a Surface Class, which has access to the Graphics Context. How do I get the Graphics Device Contexts (for both Windows and Linux) of Components in UPP? Or alternatively, how can I get the Draw objects associated with the painting of the components?
Re: Graphics Context and Draw Object [message #5828 is a reply to message #5827] Wed, 18 October 2006 15:33 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

You can get it from using Draw::GetHandle(). It returns HDC handle. I don't know about Linux.

PS: Why do you need it? HWND should be all you need I think.
Re: Graphics Context and Draw Object [message #5829 is a reply to message #5827] Wed, 18 October 2006 15:50 Go to previous messageGo to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

Scintilla comes with its own class hierarchy. The most important class that Scintilla uses is the Editor Class. To do its painting, Editor calls on the AutoSurfaace Class, which creates a surface for painting on. This Surface needs access to GCs in order to do its painting. Actually, I need to be able to create a Draw Object that is linked to the Control. Could anyone help me??
Re: Graphics Context and Draw Object [message #5842 is a reply to message #5828] Fri, 20 October 2006 15:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, in X11 there are two - X11 surface and XftDraw pointer...

Both can be accessed from Draw.

Mirek
Re: Graphics Context and Draw Object [message #5855 is a reply to message #5827] Sat, 21 October 2006 06:11 Go to previous messageGo to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

Hmm, Is there a way to create a Draw Object related to a control? That is really what I'm looking for. Is ViewDraw sufficient for the task? What is the paintqueue for ViewDraw? If I use ViewDraw to draw something on the screen, will that be erased on the next painting in the event loop?
Re: Graphics Context and Draw Object [message #5856 is a reply to message #5855] Sat, 21 October 2006 06:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
arixion wrote on Sat, 21 October 2006 00:11

Hmm, Is there a way to create a Draw Object related to a control?



Well, the standard way how to paint view content is to use Paint method. You can request refreshing the view area (or its portion) by calling Refresh. You can also force immediate repainting by Sync.

ViewDraw is helper, rarely used thing, but most likely it would do what you want. But yes, next paint would repaint the view again, OTOH perhaps you can leave it empty....

Anyway, I have a bad feeling about this Smile This is not how U++ code is supposed to work. OTOH, pushing corner limits might help to improve the U++.

Mirek
Re: Graphics Context and Draw Object [message #5876 is a reply to message #5827] Sun, 22 October 2006 03:33 Go to previous messageGo to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

If I use a Drawing Object, is there a way to erase the Drawing?
Re: Graphics Context and Draw Object [message #5878 is a reply to message #5876] Sun, 22 October 2006 04:11 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
First of all, I am not sure whether this question is related to others in this thread. If it is, then the main problem with Drawing is that it does not have any X11 handles in it (because DrawingDraw just stores all operation for later replay).

Anyway, if what you ask is how to have "background" with Drawing, just clear it with DrawRect...
Re: Graphics Context and Draw Object [message #5884 is a reply to message #5878] Mon, 23 October 2006 05:03 Go to previous messageGo to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

*Sigh*

My main problem is that I'm trying to use the Scintilla Library Classes alongside UPP classes.

Here's how a port (any port) of Scintilla is supposed to work:-

1) The port code sets up the Window on the display device.

2) The code links a customized Scintilla class to the window wrapper.

3) This customized class inherits from ScintillaBase in the Scintilla Core Library, which provides lexing and folding support. ScintillaBase in turn derives itself from an Editor Class, which provides find/ replace, basic text-editting and autocomplete. The Editor Class calls on the helper classes Window, Surface and Menu to help it do its work:-

- Menu generates the auto-complete context menu from another helper class ListBox.

- Window provides access to windowing functions like resizing, moving, minimizing/maximizing and closing. It is meant, I think, as a link between the port code and the Scintilla Library.

- Surface provides functions for painting onto specified areas in the screen.

4) Editor calls on an AutoSurface Class whenever it needs to do painting. The AutoSurface class basically generates a surface upon which painting methods are called on.

My main problem here is how to create an implementation class for Surface that can draw onto the component area with persistence, because it is useless to paint things like context menus or cursors or whatever else only for a fraction of a second before it is erased again by TimerAndPaint in the Ctrl class. So, does anyone have any suggestions on how to achieve this?

the confused programmer
Re: Graphics Context and Draw Object [message #5891 is a reply to message #5884] Mon, 23 October 2006 16:53 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
arixion wrote on Sun, 22 October 2006 23:03

*Sigh*

My main problem is that I'm trying to use the Scintilla Library Classes alongside UPP classes.

Here's how a port (any port) of Scintilla is supposed to work:-

1) The port code sets up the Window on the display device.

2) The code links a customized Scintilla class to the window wrapper.

3) This customized class inherits from ScintillaBase in the Scintilla Core Library, which provides lexing and folding support. ScintillaBase in turn derives itself from an Editor Class, which provides find/ replace, basic text-editting and autocomplete. The Editor Class calls on the helper classes Window, Surface and Menu to help it do its work:-

- Menu generates the auto-complete context menu from another helper class ListBox.

- Window provides access to windowing functions like resizing, moving, minimizing/maximizing and closing. It is meant, I think, as a link between the port code and the Scintilla Library.

- Surface provides functions for painting onto specified areas in the screen.

4) Editor calls on an AutoSurface Class whenever it needs to do painting. The AutoSurface class basically generates a surface upon which painting methods are called on.

My main problem here is how to create an implementation class for Surface that can draw onto the component area with persistence, because it is useless to paint things like context menus or cursors or whatever else only for a fraction of a second before it is erased again by TimerAndPaint in the Ctrl class. So, does anyone have any suggestions on how to achieve this?

the confused programmer


Well, even scintilla must support repaint on host platform demand (WM_PAINT, expose envent), which is exactly what "TimerAndPaint" does...

In other words, I am quite convinced that as addition to (4) there must some interface which host platform can call to redraw portion of view area. Use that in Paint and you are OK.

Mirek
Re: Graphics Context and Draw Object [message #5892 is a reply to message #5891] Mon, 23 October 2006 17:05 Go to previous messageGo to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

luzr wrote on Mon, 23 October 2006 22:53

arixion wrote on Sun, 22 October 2006 23:03

*Sigh*

My main problem is that I'm trying to use the Scintilla Library Classes alongside UPP classes.

Here's how a port (any port) of Scintilla is supposed to work:-

1) The port code sets up the Window on the display device.

2) The code links a customized Scintilla class to the window wrapper.

3) This customized class inherits from ScintillaBase in the Scintilla Core Library, which provides lexing and folding support. ScintillaBase in turn derives itself from an Editor Class, which provides find/ replace, basic text-editting and autocomplete. The Editor Class calls on the helper classes Window, Surface and Menu to help it do its work:-

- Menu generates the auto-complete context menu from another helper class ListBox.

- Window provides access to windowing functions like resizing, moving, minimizing/maximizing and closing. It is meant, I think, as a link between the port code and the Scintilla Library.

- Surface provides functions for painting onto specified areas in the screen.

4) Editor calls on an AutoSurface Class whenever it needs to do painting. The AutoSurface class basically generates a surface upon which painting methods are called on.

My main problem here is how to create an implementation class for Surface that can draw onto the component area with persistence, because it is useless to paint things like context menus or cursors or whatever else only for a fraction of a second before it is erased again by TimerAndPaint in the Ctrl class. So, does anyone have any suggestions on how to achieve this?

the confused programmer


Well, even scintilla must support repaint on host platform demand (WM_PAINT, expose envent), which is exactly what "TimerAndPaint" does...

In other words, I am quite convinced that as addition to (4) there must some interface which host platform can call to redraw portion of view area. Use that in Paint and you are OK.

Mirek



I shall look at the Scintilla Library code again. But if Scintilla has such a method, which it does seem to have, how would u synchronize it with TimerAndPaint? Or are you suggesting to use that method to send a *direct* msg to the display system? Scintilla does have a sendWndMsg function...
Re: Graphics Context and Draw Object [message #5895 is a reply to message #5892] Mon, 23 October 2006 17:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Quote:


I shall look at the Scintilla Library code again. But if Scintilla has such a method, which it does seem to have, how would u synchronize it with TimerAndPaint? Or are you suggesting to use that method to send a *direct* msg to the display system? Scintilla does have a sendWndMsg function...


Paint is called when either system or U++ widget requires so (second thing does not happen unless you call Refresh somewhere in the widget code). So in fact, you can think about Paint as "system requested repaint". Such thing can happen at any moment in both X11 and Win32, so scintilla MUST be able to handle such request.

So what you are supposed to do is to call scintilla's form of view area repaint in Paint method - then nothing can go wrong (even using the ViewDraw).

Mirek
Re: Graphics Context and Draw Object [message #5909 is a reply to message #5827] Tue, 24 October 2006 15:23 Go to previous messageGo to next message
arixion is currently offline  arixion
Messages: 27
Registered: October 2006
Location: Southeast Asia
Promising Member

Which Refresh Function links to Paint? I don't see any.
Re: Graphics Context and Draw Object [message #5910 is a reply to message #5909] Tue, 24 October 2006 15:31 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

arixion wrote on Tue, 24 October 2006 09:23

Which Refresh Function links to Paint? I don't see any.


Ctrl::Refresh(..)
Re: Graphics Context and Draw Object [message #5911 is a reply to message #5909] Tue, 24 October 2006 16:09 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
arixion wrote on Tue, 24 October 2006 09:23

Which Refresh Function links to Paint? I don't see any.


Well, what actually happens is this: When system requires repainting of area, this request is stored for further processing. When widget requires repainting of area, this request is stored for further processing. Now when input event queue is empty and all timers are processed comes the time to actually paint something. All painting requests are combined in any way system or U++ thinks is most effective. This is done to improve performance - if the Refresh is called several times during input event processing, only one repaint is actually done.
Previous Topic: GIF reader BUG? Or BUG in inserting GIF into QTF?
Next Topic: image of cursor
Goto Forum:
  


Current Time: Thu Mar 28 14:05:35 CET 2024

Total time taken to generate the page: 0.01177 seconds