Page 1 of 1

StartDrawing(GadgetOutput())

Posted: Sun Jan 14, 2007 6:34 pm
by Nico
I would like this function:StartDrawing(GadgetOutput()) for use DrawAlphaImage on the gadget!

Posted: Mon Jan 15, 2007 12:47 am
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

Posted: Mon Jan 15, 2007 9:03 am
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.

Posted: Thu Jan 18, 2007 5:47 pm
by Nico
Rescator,

It's work nice, thanks!

Posted: Thu Jan 18, 2007 7:33 pm
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..

Posted: Fri Jan 19, 2007 12:07 am
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... ;)

Posted: Fri Jan 19, 2007 1:16 am
by netmaestro
There's also this interesting post, you can pass it a GadgetID():

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