How to draw from a SheduledWindow inerithed class?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to draw from a SheduledWindow inerithed class?

LBerendsen
Hello,

My plan is to write a Kaleidoscope application. I made a KaleidoscopeApp class derived from SheduledWindow, set a title and a minimum size and open the window. It works fine and elegant.

Smalltalk defineClass: #KaleidoscopeApp
        superclass: #{UI.ScheduledWindow}
        indexedType: #none
        private: false
        instanceVariableNames: ''
        classInstanceVariableNames: ''
        imports: ''
        category: ''

initialize

        super initialize.
        label := 'Kaleidoscope'.
        minimumSize := 100 @ 100.
        super open.
        ^self

But how can I draw a line on it now? I simply cannot access a valid graphicsContext to use.

All examples in the Application Development Guide and in the Visual Works Application Programming Guide works very well in a direct codification in the Transcript.

But I can't aceess the graphicsContext from the ScheduledWindow class inerithed from inside the KaleidoscopeApp.

Any idea?

Thank's.
Lorenzo.
Reply | Threaded
Open this post in threaded view
|

Re: How to draw from a SheduledWindow inerithed class?

Karsten Kusche
  Hi Lorenzo,

please add a view to the window and do your drawing in the window's
view. You can add views in the UIPainter, there's a ViewHolder widget
that you should use. See the GuiDevGuide for info on how to use the
ViewHolder and a Custom View.

Kind Regards
Karsten



Am 03.08.10 18:59, schrieb LBerendsen:

> Hello,
>
> My plan is to write a Kaleidoscope application. I made a KaleidoscopeApp
> class derived from SheduledWindow, set a title and a minimum size and open
> the window. It works fine and elegant.
>
> Smalltalk defineClass: #KaleidoscopeApp
> superclass: #{UI.ScheduledWindow}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> initialize
>
> super initialize.
> label := 'Kaleidoscope'.
> minimumSize := 100 @ 100.
> super open.
> ^self
>
> But how can I draw a line on it now? I simply cannot access a valid
> graphicsContext to use.
>
> All examples in the Application Development Guide and in the Visual Works
> Application Programming Guide works very well in a direct codification in
> the Transcript.
>
> But I can't aceess the graphicsContext from the ScheduledWindow class
> inerithed from inside the KaleidoscopeApp.
>
> Any idea?
>
> Thank's.
> Lorenzo.

--
Karsten Kusche - Dipl. Inf. - [hidden email]
Georg Heeg eK - Köthen
Handelsregister: Amtsgericht Dortmund A 12812

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: How to draw from a SheduledWindow inerithed class?

LBerendsen
Hi,
 
I studied the Examples package and the ScratchWindow source code.
This is what I discovered:
Smalltalk defineClass: #KaleidoscopeApp
 superclass: #{UI.ScheduledWindow}
 indexedType: #none
 private: false
 instanceVariableNames: 'gc '                 <-- to work with the graphicsContext
 classInstanceVariableNames: ''
 imports: ''
 category: ''
 
initialize
 "Initialize a newly created instance. This method must answer the receiver."
 
 super initialize.
 label := 'Kaleidoscope'.
 minimumSize := 280 @ 140.
 super component: ComposingComposite new.      <-- Add a drawing space.
 super sensor skipNextDamage.                              <-- Don't understood, but works!
 super open.
 gc := ScheduledControllers activeController view graphicsContext.   <-- get a valid graphicsContext
      gc displayLineFrom: 10 @ 20 to: 150 @ 50.    <-- draw the line
 ^self
The ComposingComposite window is a space area that automatically use the window bounds to size it self.
 
I didn't understood what the skipNextDamage do, but makes the difference. Without it, I can't draw anything.
 
Finnaly, get a valid graphicsContext from active window.
I don't like this approach, it is not elegant.
But is a resonable assumption. Running the initialization method, Kaleidoscope window is the active window.
 
Regards,
Lorenzo.
 
 

Sent: Wednesday, August 04, 2010 3:35 AM
Subject: Re: How to draw from a SheduledWindow inerithed class?

  Hi Lorenzo,

please add a view to the window and do your drawing in the window's
view. You can add views in the UIPainter, there's a ViewHolder widget
that you should use. See the GuiDevGuide for info on how to use the
ViewHolder and a Custom View.

Kind Regards
Karsten



Am 03.08.10 18:59, schrieb LBerendsen:

> Hello,
>
> My plan is to write a Kaleidoscope application. I made a KaleidoscopeApp
> class derived from SheduledWindow, set a title and a minimum size and open
> the window. It works fine and elegant.
>
> Smalltalk defineClass: #KaleidoscopeApp
> superclass: #{UI.ScheduledWindow}
> indexedType: #none
> private: false
> instanceVariableNames: ''
> classInstanceVariableNames: ''
> imports: ''
> category: ''
>
> initialize
>
> super initialize.
> label := 'Kaleidoscope'.
> minimumSize := 100 @ 100.
> super open.
> ^self
>
> But how can I draw a line on it now? I simply cannot access a valid
> graphicsContext to use.
>
> All examples in the Application Development Guide and in the Visual Works
> Application Programming Guide works very well in a direct codification in
> the Transcript.
>
> But I can't aceess the graphicsContext from the ScheduledWindow class
> inerithed from inside the KaleidoscopeApp.
>
> Any idea?
>
> Thank's.
> Lorenzo.
--
Karsten Kusche - Dipl. Inf. - [hidden email]
Georg Heeg eK - Köthen
Handelsregister: Amtsgericht Dortmund A 12812

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



View message @ http://forum.world.st/How-to-draw-from-a-SheduledWindow-inerithed-class-tp2312231p2312995.html
To unsubscribe from How to draw from a SheduledWindow inerithed class?, click here.