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 » How to Draw a couple of lines over an ArrayCtrl
How to Draw a couple of lines over an ArrayCtrl [message #4130] Mon, 24 July 2006 05:23 Go to next message
Ordog is currently offline  Ordog
Messages: 13
Registered: July 2006
Promising Member
At a button triggered situation during runtime id like to Draw some Lines forming a graph over an ArrayCtrl.
From other posts in this forum i assume that can be done.
Im assuming that when i omit the DrawRect(rectwithsizeofwindow, color) that is used in the examples paint method that gives me a transparent "canvas" over my mainwindow.

My question now is how do i accomplish that?
First i need a Drawing overlaying my arrayCtrl.
so my headerfile holds
Drawing dw;

From this point im a bit lost in the black magic done by the Draw package Razz
So what exactly does the Paint() method ?
I assume it holds initial values for the canvas. So i defined my Paint method as follows:
void myguiclass::Paint(Draw& w) {
w.DrawDrawing(8, 90, 600, 460, dw); 
}

which is (startx, starty, widthx, widthy, thedrawing)
now i got the canvas positioned over my ArrayCtrl... i guess.

Within my triggered function to draw the graph i introduce the drawing by using
DrawingDraw w(600, 460);

where the arguments correlate with the size of my canvas.

from here on i should be able to use
w.DrawLine(int x1¸ int y1¸ int x2¸ int y2¸ int width = 0¸ Color color = SBlack)(

to form my graph linebyline from the coordinates extracted from my dataholding structure and apply the changes by using
dw = w;

right?

Meanwhile i implemented the above and surprisingly (for me ^^) it compiles.
The Applications Gui got some artifacts though, e.g.
-no background of the main window
So i put in the white rectangle of the example and it shows that the canvas is behind the widgets.
When i trigger the function that initializes the DrawingDraw and uses DrawLine the line is drawn but behind the widgets as expected.

Before i tinker around with this id be pleased if somebody could point me into the right direction Smile

PS: im using a layoutfile can i represent the drawing there somehow? should i use another layout when triggering the draw process?

PPS: i find it a bit confusing that 0,0 is at the upper left corner (i supposed to draw in a carthesian coordinate system so is there a better way to draw my chart in the Draw or some other package?)

[Updated on: Mon, 24 July 2006 05:56]

Report message to a moderator

Re: How to Draw a couple of lines over an ArrayCtrl [message #4134 is a reply to message #4130] Mon, 24 July 2006 11:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
To draw something "over" some other widget is always a bit tricky solution - so the first question is "why?".

If you insist on doing so, in this situation probably the simplest solution is to use "Picture" static Ctrl - this is a simple Ctrl that displays the Drawing. Simply add it to layout (it is not yet predefined in .usc, so you have to add it as user class) AFTER the ArrayCtrl so that it will be painted over it.

To answer some other question:

- Of course, parent background has to painted behind all child widgets.

- Paint method is responsible for redrawing widget upon system request. In other words, this is where you draw the visual content of the widget.

- "Drawing" is a container that stores recording of Draw operations. You can think about it as of vector image. DrawDrawing replays those operations.

- [0, 0] at upper left corner is quite common solution for GUI... It is definitely better for most widgets (e.g. lines in editors or grids are counted from top to bottom).

Mirek
Re: How to Draw a couple of lines over an ArrayCtrl [message #4138 is a reply to message #4130] Tue, 25 July 2006 00:05 Go to previous messageGo to next message
Ordog is currently offline  Ordog
Messages: 13
Registered: July 2006
Promising Member
ok about the why:
i thought that would be wasier than adding another layout with the painting instead of the table.
The table is the initial thing to show, the graph should only be visible after triggering and i have to be able to remove it on another trigger of course.
So i guess you would recommend using another layout?
and about the after (after the array ctrl in the list of widgets to the left?

[Updated on: Tue, 25 July 2006 02:31]

Report message to a moderator

Re: How to Draw a couple of lines over an ArrayCtrl [message #4145 is a reply to message #4138] Tue, 25 July 2006 15:03 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
No, that is not necessary. Keep the same layout, use Show and Hide to make visible the widget you need.

Mirek
Previous Topic: How to display an icon on the right side of a label/button
Next Topic: Pdf export
Goto Forum:
  


Current Time: Tue Apr 16 14:18:58 CEST 2024

Total time taken to generate the page: 0.00811 seconds