Can I draw a line on a PanelGadget?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
What Lines do you want to draw?
To draw horizontal lines i do something like this:
Can also be done vertically by setting width to 2 and increasing height.
If you want to preform real Drawing actions, you should draw to an Image using 'StartDrawing(ImageOutput())' after 'CreateImage()' and then display that image as an ImageGadget.
You have to use Gadgets here becourse with a PanelGadget drawing with WindowOutput() doesn't work.
Hope this helps a bit...
Timo
--------------------------------
Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.
...So far, the universe is winning.
What Lines do you want to draw?
To draw horizontal lines i do something like this:
Code: Select all
Frame3DGadget(1, 10, 10, 300, 2, "", 2)
If you want to preform real Drawing actions, you should draw to an Image using 'StartDrawing(ImageOutput())' after 'CreateImage()' and then display that image as an ImageGadget.
You have to use Gadgets here becourse with a PanelGadget drawing with WindowOutput() doesn't work.
Hope this helps a bit...
Timo
--------------------------------
Programming today is a race between software engineers striving to build bigger and
better idiot-proof programs and the universe trying to produce bigger and better idiots.
...So far, the universe is winning.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TerryHough.
Unfortunately, so far I have only been able to get the image
drawn to WindowOutput(). When I draw to an image and then
try to display on the PanelGadget it doesn't work. I am sure
it is just my poor code or I have totally misread something.
Terry
Thanks, I believe this is the approach I will need to take.Originally posted by freak
If you want to preform real Drawing actions, you should draw to an Image using 'StartDrawing(ImageOutput())' after 'CreateImage()' and then display that image as an ImageGadget.
You have to use Gadgets here becourse with a PanelGadget drawing with WindowOutput() doesn't work.
Unfortunately, so far I have only been able to get the image
drawn to WindowOutput(). When I draw to an image and then
try to display on the PanelGadget it doesn't work. I am sure
it is just my poor code or I have totally misread something.
Terry
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
> Unfortunately, so far I have only been able to get the image
> drawn to WindowOutput(). When I draw to an image and then
> try to display on the PanelGadget it doesn't work. I am sure
> it is just my poor code or I have totally misread something.
To make it easyer for you to solve the problem, i've coded a short
example, and commented it as best as i could.
Maybe you'll then see, where the problem is...
---------
Hope this helps a bit...
Timo
> Unfortunately, so far I have only been able to get the image
> drawn to WindowOutput(). When I draw to an image and then
> try to display on the PanelGadget it doesn't work. I am sure
> it is just my poor code or I have totally misread something.
To make it easyer for you to solve the problem, i've coded a short
example, and commented it as best as i could.
Maybe you'll then see, where the problem is...
Code: Select all
#Image = 1 ; just to make more clear, which values mean the same thing...
#PanelGadget = 1
#ImageGadget = 2
If OpenWindow(0, 0, 0, 640, 480, #PB_Window_SystemMenu, "CreateImage / Imagegadget Example") = 0 ; open window
MessageRequester("","Window Error!",0) ; some error
End
EndIf
If CreateImage(#Image, 300, 300) = 0 ; create image to draw on
MessageRequester("","Image Error!",0) ; some error
End
EndIf
back.l = GetSysColor_(#COLOR_BTNFACE) ; gets the background color for Windows (to draw the image background)
UseImage(#Image) ; this one is only needed, if you did stuff with other Images after
; the CreateImage() command.
StartDrawing(ImageOutput()) ; Start Drawing on the Image
FrontColor(Red(back), Green(back), Blue(back)) ; Set the Background Color
Box(0, 0, 300, 300) ; draw background
FrontColor(0, 0, 0) ; just some drawing action
DrawingMode(1 | 4)
Circle(150, 150, 100)
Box(100, 100, 100, 100)
Line(50, 50, 200, 200)
Locate(10, 10)
DrawText("Hello World!")
StopDrawing() ; drawing ends here. (the drawing stuff must be done before the
; ImageGadget() command
CreateGadgetList(WindowID()) ; create GadgetList
PanelGadget(#PanelGadget, 20, 20, 600, 440) ; Panelgadget
AddGadgetItem(#PanelGadget, -1, "Panel 1") ; First Panel
UseImage(#Image) ; again, only needed if you used some other Images before
ImageGadget(#ImageGadget, 50, 50, 300, 300, ImageID()) ; create the Imagegadget using the current Image
AddGadgetItem(#PanelGadget, -1, "Panel 2") ; some other Panels
AddGadgetItem(#PanelGadget, -1, "Panel 3")
ClosePanelGadget() ; close PanelGadget
SetGadgetState(#PanelGadget, 0) ; otherwise the drawings are not visible at the beginning
; Thanks to Franco for the hint
Repeat ; Main loop, only waits for close of Window
Event.l = WaitWindowEvent()
Until Event = #PB_EventCloseWindow
End
Hope this helps a bit...
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
@Freak
added:
before the main loop, because the drawings & text aren't visible on my machine (w2k-Sp3)
Otherwise it's only visible after activating another Item and switch back to the first Item...
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
@Freak
added:
Code: Select all
SetGadgetState(#PanelGadget, 0) ; otherwise the drawings are not visible at the beginning
Otherwise it's only visible after activating another Item and switch back to the first Item...
Have a nice day...
Franco
Sometimes you have to go a lonely way to accomplish genius things.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TerryHough.
My problem seems to be located between my ears today!
Terry
No, I am on Win98SE and your example worked great for me.Originally posted by freak
I dodn't know that, here (Win98se) everythin worked fine.
Maybe this is Terry's problem, too?
My problem seems to be located between my ears today!
Terry
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TerryHough.
Thanks Freak and Franco, that got me rolling.
One other question on this subject...
Is it possible to create an area within a PanelGadget that can be
vertically scrolled? My "forms" are too large (long actually) to
fit in the largest panels I can create, so I need to draw on a scrollable area, drop string gadgets on it, etc. and then be able
vertically scroll up and down through the area. (Hope that explains
it).
The Panel concept is perfect for the application for selecting the
various "forms" if I can create the above ability.
Thanks again for your help.
Terry
Thanks Freak and Franco, that got me rolling.
One other question on this subject...
Is it possible to create an area within a PanelGadget that can be
vertically scrolled? My "forms" are too large (long actually) to
fit in the largest panels I can create, so I need to draw on a scrollable area, drop string gadgets on it, etc. and then be able
vertically scroll up and down through the area. (Hope that explains
it).
The Panel concept is perfect for the application for selecting the
various "forms" if I can create the above ability.
Thanks again for your help.
Terry
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
> Is it possible to create an area within a PanelGadget that can be
> vertically scrolled?
Well, nothing's impossible
, i posted a solution to
the Tips&Tricks Section.
You'll find it, here:
viewtopic.php?t=2012
You'll need to do some trick to use it in a PanelGadget, but that
is also explained there.
Timo
> Is it possible to create an area within a PanelGadget that can be
> vertically scrolled?
Well, nothing's impossible
the Tips&Tricks Section.
You'll find it, here:
viewtopic.php?t=2012
You'll need to do some trick to use it in a PanelGadget, but that
is also explained there.
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TerryHough.

I will have to study this carefully.
I must admit that I haven't learned the "trick" to make it work
in a PanelGadget. It looks like it is going to, but never shows
the scrollbars at all. The other gadgets appear, but not the
scrollbars.
I'm lost.
Terry
Wow! really nice work.Well, nothing's impossible, i posted a solution to
the Tips&Tricks Section.
You'll find it, here:
viewtopic.php?t=2012
You'll need to do some trick to use it in a PanelGadget, but that
is also explained there.
I must admit that I haven't learned the "trick" to make it work
in a PanelGadget. It looks like it is going to, but never shows
the scrollbars at all. The other gadgets appear, but not the
scrollbars.
Terry
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by freak.
Update!!
Sorry, there were some bugs in the code, that caused your problem.
Please, get the fixed code again:
viewtopic.php?t=2012
There's also a second example showing the Panelgadget stuff.
(please read also my instructions on top of the new code, since
the PanelGadget trick has changed now a bit.)
Timo
Update!!
Sorry, there were some bugs in the code, that caused your problem.
Please, get the fixed code again:
viewtopic.php?t=2012
There's also a second example showing the Panelgadget stuff.
(please read also my instructions on top of the new code, since
the PanelGadget trick has changed now a bit.)
Timo
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by TerryHough.
@freak
Thanks Timo! The bug fix took care of one of my problems and
the PanelGadget example confirmed I was using it correctly.
Still had a problem that took me a while to track down. I was
using the variables Height and Width as globals in my code.
That caused problems for your procedures and so the scroll bars
just didn't appear. Simple fix, I didn't really need the
variables to be global so I just removed the definition, and
everything worked perfectly.
One note: The ScrollGadget has to be 20 pixels less in width than
the FrameGadget and 40 pixels less in heigth for me to see
both scroll bars. This was easily accomplished using the GadgetWidth()
and GadgetHeight() commands
Thanks again for your marvelous idea and code examples.
Terry
@freak
Thanks Timo! The bug fix took care of one of my problems and
the PanelGadget example confirmed I was using it correctly.
Still had a problem that took me a while to track down. I was
using the variables Height and Width as globals in my code.
That caused problems for your procedures and so the scroll bars
just didn't appear. Simple fix, I didn't really need the
variables to be global so I just removed the definition, and
everything worked perfectly.
One note: The ScrollGadget has to be 20 pixels less in width than
the FrameGadget and 40 pixels less in heigth for me to see
both scroll bars. This was easily accomplished using the GadgetWidth()
and GadgetHeight() commands
Code: Select all
; code snippet allowing the entire panel to scroll
AddGadgetItem(1,100, "Panel Info")
gWidth = GadgetWidth(1)
gHeight = GadgetHeight(1)
hFrame.l = Frame3DGadget(9,0,0,gWidth,gHeight,"",1); Create a scrollable area
hScr.l = OpenScrollGadget(0, 0, gWidth-20, gHeight-40, 800, 800,#ScrollBar_
; end code snippet
Terry