StartDrawing(GadgetOutput())

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

StartDrawing(GadgetOutput())

Post by Nico »

I would like this function:StartDrawing(GadgetOutput()) for use DrawAlphaImage on the gadget!
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

Try this for now, note it's possible to draw outside/beyond the gadget.
I think it's due to some RECT not being properly changed.
But hey, it works, which means it should be possible for the PB team to add GadgetOutput() :) althought personally I'd advice using ImageOutput() instead and a imagegadget.

Code: Select all

 Procedure.l GadgetOutput(window.l,gadget.l)
  Protected wo=0
  wo=WindowOutput(window)
  PokeL(wo+4,GadgetID(gadget))
  ProcedureReturn wo
 EndProcedure


 If OpenWindow(0, 0, 0, 222, 200, "ButtonGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
   ButtonGadget(0, 10, 10, 200, 20, "Standard Button")
   ButtonGadget(1, 10, 40, 200, 20, "Left Button", #PB_Button_Left)
   ButtonGadget(2, 10, 70, 200, 20, "Right Button", #PB_Button_Right)
   ButtonGadget(3, 10,100, 200, 60, "Multiline Button  (longer text gets automatically wrapped)", #PB_Button_MultiLine)
   ButtonGadget(4, 10,170, 200, 20, "Toggle Button", #PB_Button_Toggle)
   Repeat
    StartDrawing(GadgetOutput(0,0))
    Box(0,0, 10, 10, RGB(255, 0, 0))
    StopDrawing()
    StartDrawing(WindowOutput(0))
    Box(0,0, 10, 10, RGB(0, 255, 0))
    StopDrawing()
    Delay(10)
   Until WaitWindowEvent() = #PB_Event_CloseWindow
 EndIf
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

which gadget do you like to have it for?

perhaps there are alternative workarounds.

note that Drawing is no durable action. it will be erased with the next refresh-event.
oh... and have a nice day.
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Post by Nico »

Rescator,

It's work nice, thanks!
merihevonen
Enthusiast
Enthusiast
Posts: 326
Joined: Mon Jan 01, 2007 7:20 pm

Post by merihevonen »

Kaeru Gaman wrote:which gadget do you like to have it for?

perhaps there are alternative workarounds.

note that Drawing is no durable action. it will be erased with the next refresh-event.
..if you don't have a callback which redraws the window..
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

that's right.

i've read that much "where have my circles gone"-topics the last years,
so i didn't take it for granted you would put your drawing actions into a callback... ;)
oh... and have a nice day.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

There's also this interesting post, you can pass it a GadgetID():

http://www.purebasic.fr/english/viewtop ... 73&start=3
BERESHEIT
Post Reply