Window States solved

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

Window States solved

Jerome Chan
How to detect if a window is minimized. (Returns Boolean) shellView is
the ShellView object that represents the window.

  UserLibrary default isIconized: shellView handle

How to detect if a window is maximized. (Returns Boolean)

  UserLibrary default isZoomed: shellView handle

How to obtain the window position regardless of Zoomed or Iconized
states. I obtain this value from onPositionChanged: anEvent or
onViewClosed in my Presenter instance. savedPlacementValue is a
Placement object that represents the normal position of a window when
its not minimized or maximized.

  savedPlacementValue := shellView placement

How to set the window position
  shellView placement: savedPlacementValue

How to maximize a window.
  shellView showMaximized
or
  savedPlacementValue showCmd: SW_MAXIMIZE
  shellView placement: savedPlacementValue

How to minimize a window.
  shellView showMinimized
or
  savedPlacementValue showCmd: SW_Minimize
  shellView placement: savedPlacementValue

I put the states and placement into a model (maybe I'll change this to
an object) and then use

Presenter createOn: model

to recreate the window and its saved state. If I use showOn: the window
is set to its correct state initially but then normalized.

My presenter's onViewOpen method is something like the following:

MyPresenter>>onViewOpen

windowModel placement
  ifNotNil: [:placement |
    windowModel = maximized ifTrue: [placement showCmd: SW_MAXIMIZED].
    windowModel = minimized ifTrue: [placement showCmd: SW_MINIMIZED].
    windowModel = normal ifTrue: [placement showCmd: SW_SHOW].
    self view placement: placement
  ]
  ifNil: [
    self view show
  ]

I'm thinking perhaps I should put all of these into a subclass of
ShellView (maybe tofusoftShellView?) and post it as a goodie someplace?