- Main Page
- Packages
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# smjg.libs.sdwf.window.Window Class Reference

The smjg.libs.sdwf.window.Window class defines basic behaviour of a window. More...

Inheritance diagram for smjg.libs.sdwf.window.Window:

List of all members.

## Public Types
typedef bool(* | MouseHandler )(uint message, MK modKeys, int x, int y)
| The form of a method that receives and processes mouse messages translated into coordinate form.
typedef bool(* | CharKeyHandler )(uint message, char ch, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)
| The form of a method that receives and processes the keyboard messages that carry character codes.
typedef bool(* | VirtualKeyHandler )(uint message, VK key, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)
| The form of a method that receives and processes the keyboard messages that carry virtual key codes.
## Public Member Functions
| this (string windowTitle, WindowBase p)
| Constructs a new window as a child of another window.
| this (string windowTitle, Application a)
| Constructs a new top-level application window.
| this (Application a, HWND h)
| Constructs a Window object to interface a pre-existing window.
| this (WindowBase w, HWND h)
| Constructs a Window object to interface a pre-existing window.
override void | create ()
| Creates the Window object.
Properties
WindowClass | windowClass ()
| The window class to which this window will belong.
WindowClass | windowClass (WindowClass c)
| The window class to which this window will belong.
MouseCursor | mouseCursor ()
| The window's mouse cursor.
MouseCursor | mouseCursor (MouseCursor c)
| The window's mouse cursor.
## Public Attributes
deprecated typedef bool deprecated(* | KeyHandler )(uint message, uint keyCode, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)
| The form of a method that receives and processes all keyboard messages.
## Protected Member Functions
override void | predefCommandHandler (uint notify, uint id)
final override int | processMessage (uint message, uint wParam, int lParam, WindowBase receivedVia)
deprecated bool | selectMouseEventHandler (uint message, MK modKeys, int x, int y)
| Looks up a mouse message in Window.mouseEventHandler and calls the individual message handler.
deprecated bool | selectKeyEventHandler (uint message, uint keyCode, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)
| Looks up a keyboard message in Window.charKeyEventHandler or Window.virtualKeyEventHandler as applicable, and calls the individual message handler.
void | initListeners ()
override bool | _despatchDialogMessage (MSG *msg)
Listeners
int | selectMouseEventHandler (uint message, uint wParam, int lParam, WindowBase receivedVia, out bool swallow)
| Looks up a mouse message in Window.mouseEventHandler and calls the individual message handler.
int | setDynamicMouseCursor (uint message, uint wParam, int lParam, WindowBase receivedVia, out bool swallow)
| Responds to mouse movement by calling dynamicMouseCursor to set the mouse cursor.
int | selectKeyEventHandler (uint message, uint wParam, int lParam, WindowBase receivedVia, out bool swallow)
| Looks up a keyboard message in Window.charKeyEventHandler or Window.virtualKeyEventHandler as applicable, and calls the individual message handler.
int | oldIntermediateProcessMessage (uint message, uint wParam, int lParam, WindowBase receivedVia, out bool swallow)
int | windowPredef (uint message, uint wParam, int lParam, WindowBase receivedVia, out bool swallow)
Callback Methods
Rect | defaultSize ()
| Called by show to get a Rect defining the default size and position of the window on the screen.
void | setWindowScale ()
| Sets up a logical coordinate system.
void | paint (PaintDC dc, PAINTSTRUCT ps)
| Called in response to a WM_PAINT message, in order to repaint the contents of the window.
MouseCursor | dynamicMouseCursor (int x, int y)
| Called in response to a WM_SETCURSOR message, in order to display the correct mouse cursor.
## Protected Attributes
WindowClass | wc
MouseHandler | mouseHandler
| The method to which mouse messages will be delegated for processing.
MouseHandler[uint] | mouseEventHandler
| Associates each mouse message with an individual handler method.
KeyHandler | keyHandler
| The method to which keyboard messages will be delegated for processing.
CharKeyHandler[uint] | charKeyEventHandler
| Associates each keyboard message taking a character key code with an indvidual handler method.
VirtualKeyHandler[uint] | virtualKeyEventHandler
| Associates each keyboard message taking a virtual key code with an indvidual handler method.

## Detailed Description

The smjg.libs.sdwf.window.Window class defines basic behaviour of a window.

The programmer would define a subclass of Window to implement a window's functionality.

## Member Typedef Documentation

typedef bool(* smjg.libs.sdwf.window.Window.MouseHandler)(uint message, MK modKeys, int x, int y)

The form of a method that receives and processes mouse messages translated into coordinate form.

Parameters:

  | message | the WM_xxxx constant identifying the mouse message. This is necessary to a method used for Window.mouseHandler, and can also be interrogated by methods in Window.mouseEventHandler so that similar handlings of different mouse events can be done by a single method.
  | modKeys | a combination of MK_xxxx constants as defined in the Windows API for mouse messages, specifying which modifier keys are down at the time of the event.
  | x | the x-coordinate at which the mouse event occurred.
  | y | the y-coordinate at which the mouse event occurred. The x and y values are given in device coordinates from the upper-left corner of the window client area.

Returns:
  true to cause the message to be further handled by default processing.

See also:
  Window.mouseHandler, Window.mouseEventHandler

Status:
  done

typedef bool(* smjg.libs.sdwf.window.Window.CharKeyHandler)(uint message, char ch, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)

The form of a method that receives and processes the keyboard messages that carry character codes.

Methods of this form apply to the messages `WM_CHAR`, `WM_SYSCHAR`, `WM_DEADCHAR` and `WM_SYSDEADCHAR`.

Parameters:

  | message | the WM_xxxx constant identifying the keyboard message. It can be interrogated by methods in Window.charKeyEventHandler so that similar handlings of different keyboard events can be done by a single method.
  | ch | the character value of the key that was pressed.
  | repeatCount | the number of times the keystroke is repeated because the user held down the key. This is normally 1; it will be greater only if Windows has coalesced key events.
  | scanCode | the OEM-dependent key scan code.
  | isExtendedKey | whether the key is an extended key.
  | altKeyDown | whether the ALT key was held down at the time of the event.
  | wasDown | whether the key was down immediately before the event occurred.
  | released | whether the key is released now that the event has occurred.

Returns:
  true to cause the message to be further handled by default processing.

Since:
  0.3

Status:
  done

typedef bool(* smjg.libs.sdwf.window.Window.VirtualKeyHandler)(uint message, VK key, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)

The form of a method that receives and processes the keyboard messages that carry virtual key codes.

Methods of these form are used with the messages `WM_KEYDOWN`, `WM_SYSKEYDOWN`, `WM_KEYUP`, `WM_SYSKEYUP`. Although some of the parameter values are wholly or partly determined by the particular message received, they are all included for the sake of completeness and convenience.

Parameters:

  | message | the WM_xxxx constant identifying the keyboard message. It can be interrogated by methods in Window.virtualKeyEventHandler so that similar handlings of different keyboard events can be done by a single method.
  | virtualKey | identifies the key that was pressed or released.
  | repeatCount | the number of times the keystroke is repeated because the user held down the key. This is normally 1; it will be greater only if Windows has coalesced key events.
  | scanCode | the OEM-dependent key scan code.
  | isExtendedKey | whether the key is an extended key.
  | altKeyDown | whether the ALT key was held down at the time of the event.
  | wasDown | whether the key was down immediately before the event occurred.
  | released | whether the key is released now that the event has occurred.

Returns:
  true to cause the message to be further handled by default processing.

Since:
  0.3

Status:
  done

## Constructor & Destructor Documentation

smjg.libs.sdwf.window.Window.this | ( | string | windowTitle,
|  | WindowBase | p |
| ) |  |  |

Constructs a new window as a child of another window.

The Windows interface element itself is not yet created - this is done when Window.show is called.

Parameters:

  | windowTitle | the title bar text of the window.
  | p | the parent window.

Status:
  done

Reimplemented in smjg.libs.sdwf.framewindow.FrameWindow, and smjg.libs.sdwf.mdi.MDIFrameWindow.

smjg.libs.sdwf.window.Window.this | ( | string | windowTitle,
|  | Application | a |
| ) |  |  |

Constructs a new top-level application window.

The Windows interface element itself is not yet created - this is done when Window.show is called.

Parameters:

  | windowTitle | the title bar text of the window.
  | a | the application to which this window belongs.

Status:
  done

Reimplemented in smjg.libs.sdwf.framewindow.FrameWindow, and smjg.libs.sdwf.mdi.MDIFrameWindow.

smjg.libs.sdwf.window.Window.this | ( | Application | a,
|  | HWND | h |
| ) |  |  |

Constructs a Window object to interface a pre-existing window.

This can be used to perform operations on a window outside of SDWF's control. SDWF currently does not subclass interface elements, and so message handling will not work.

Parameters:

  | a | the application to which the window object belongs.
  | h | the Windows handle of the window.

Reimplemented from smjg.libs.sdwf.windowbase.WindowBase.

smjg.libs.sdwf.window.Window.this | ( | WindowBase | w,
|  | HWND | h |
| ) |  |  |

Constructs a Window object to interface a pre-existing window.

This can be used to perform operations on a window outside of SDWF's control. SDWF currently does not subclass interface elements, and so message handling will not work.

Parameters:

  | w | the parent window object.
  | h | the Windows handle of the window.

## Member Function Documentation

override void smjg.libs.sdwf.window.Window.create | ( |  | ) | `[virtual]`

Creates the Window object.

Precondition:
  It is illegal to call this method more than once on any Window.

Status:
  done

Implements smjg.libs.sdwf.windowbase.WindowBase.

WindowClass smjg.libs.sdwf.window.Window.windowClass | ( |  | ) |

The window class to which this window will belong.

Isn't it getting confusing? We've got the Window class in SDWF, and window classes in the Windows API. The latter is the one that this property is concerned with.

Note:
  In previous SDWF versions, windowClass was designed as a callback. This use is deprecated, but will still work as long as the application doesn't call the windowClass property.

WindowClass smjg.libs.sdwf.window.Window.windowClass | ( | WindowClass | c | ) |

The window class to which this window will belong.

Isn't it getting confusing? We've got the Window class in SDWF, and window classes in the Windows API. The latter is the one that this property is concerned with.

Since:
  0.4

MouseCursor smjg.libs.sdwf.window.Window.mouseCursor | ( |  | ) |

The window's mouse cursor.

This is the cursor that will be displayed when the mouse is in the window, if it has not been overridden by Window.dynamicMouseCursor and the window class does not specify a mouse cursor.

Since:
  0.51

MouseCursor smjg.libs.sdwf.window.Window.mouseCursor | ( | MouseCursor | c | ) |

The window's mouse cursor.

This is the cursor that will be displayed when the mouse is in the window, if it has not been overridden by Window.dynamicMouseCursor and the window class does not specify a mouse cursor.

Since:
  0.51

override void smjg.libs.sdwf.window.Window.predefCommandHandler | ( | uint | notify,
|  | uint | id |
| ) |  |  | `[protected]`

Reimplemented from smjg.libs.sdwf.windowbase.WindowBase.

Reimplemented in smjg.libs.sdwf.mdi.MDIFrameWindow.

final override int smjg.libs.sdwf.window.Window.processMessage | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia |
| ) |  |  | `[protected]`

int smjg.libs.sdwf.window.Window.selectMouseEventHandler | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia,
|  | out bool | swallow |
| ) |  |  | `[protected]`

Looks up a mouse message in Window.mouseEventHandler and calls the individual message handler.

Normally an application would not call this method directly, but add it as a listener.

Since:
  0.5

Status:
  test

int smjg.libs.sdwf.window.Window.setDynamicMouseCursor | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia,
|  | out bool | swallow |
| ) |  |  | `[protected]`

Responds to mouse movement by calling dynamicMouseCursor to set the mouse cursor.

Since:
  0.51

Status:
  done

int smjg.libs.sdwf.window.Window.selectKeyEventHandler | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia,
|  | out bool | swallow |
| ) |  |  | `[protected]`

Looks up a keyboard message in Window.charKeyEventHandler or Window.virtualKeyEventHandler as applicable, and calls the individual message handler.

Normally an application would not call this method directly, but add it as a listener.

Since:
  0.5

Status:
  test

int smjg.libs.sdwf.window.Window.oldIntermediateProcessMessage | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia,
|  | out bool | swallow |
| ) |  |  | `[protected]`

int smjg.libs.sdwf.window.Window.windowPredef | ( | uint | message,
|  | uint | wParam,
|  | int | lParam,
|  | WindowBase | receivedVia,
|  | out bool | swallow |
| ) |  |  | `[protected]`

deprecated bool smjg.libs.sdwf.window.Window.selectMouseEventHandler | ( | uint | message,
|  | MK | modKeys,
|  | int | x,
|  | int | y |
| ) |  |  | `[protected]`

Looks up a mouse message in Window.mouseEventHandler and calls the individual message handler.

Normally an application would not call this method directly, but assign it to Window.mouseHandler.

Deprecated:
  Replaced by the listener selectMouseEventHandler(uint, uint, int, WindowBase, out bool).

deprecated bool smjg.libs.sdwf.window.Window.selectKeyEventHandler | ( | uint | message,
|  | uint | keyCode,
|  | ushort | repeatCount,
|  | ubyte | scanCode,
|  | bool | isExtendedKey,
|  | bool | altKeyDown,
|  | bool | wasDown,
|  | bool | released |
| ) |  |  | `[protected]`

Looks up a keyboard message in Window.charKeyEventHandler or Window.virtualKeyEventHandler as applicable, and calls the individual message handler.

Normally an application would not call this method directly, but assign it to Window.keyHandler.

Deprecated:
  Replaced by the listener selectKeyEventHandler(uint, uint, int, WindowBase, out bool).

Rect smjg.libs.sdwf.window.Window.defaultSize | ( |  | ) | `[protected]`

Called by show to get a Rect defining the default size and position of the window on the screen.

Returns:
  the default size and position rectangle, in screen coordinates. The Window implementation returns a Rect representing a default positioning determined by Windows.

Bug:
  This function doesn't work on MDI child windows created during application startup. Moreover, such windows tend to come out at the minimum size. A workaround is demonstrated in the MDI Edit example.

void smjg.libs.sdwf.window.Window.setWindowScale | ( |  | ) | `[protected]`

Sets up a logical coordinate system.

This method is called when the window is first displayed, and when the window is resized in order to update the logical coordinates to the new window size.

The Window implementation does nothing, so that ordinary device coordinates are used.

See also:
  DC.mappingMode, DC.setScale

Status:
  done

Reimplemented in smjg.libs.sdwf.framewindow.FrameWindow.

void smjg.libs.sdwf.window.Window.paint | ( | PaintDC | dc,
|  | PAINTSTRUCT | ps |
| ) |  |  | `[protected]`

Called in response to a WM_PAINT message, in order to repaint the contents of the window.

Parameters:

  | dc | a device context with which to do the repainting.
  | ps | a Windows API structure containing information that can be used to repaint the window.

Status:
  done

MouseCursor smjg.libs.sdwf.window.Window.dynamicMouseCursor | ( | int | x,
|  | int | y |
| ) |  |  | `[protected]`

Called in response to a WM_SETCURSOR message, in order to display the correct mouse cursor.

This can be used to change the mouse cursor as the mouse moves within the window. For this to work, the window class cursor must be null, and the Window.setDynamicMouseCursor listener must be added to the window.

Parameters:

  | x | the x-coordinate of the mouse cursor.
  | y | the y-coordinate of the mouse cursor. The x and y values are given in device coordinates from the upper-left corner of the window client area.

Returns:
  the cursor image to use, or `null` to use the default cursor.

Status:
  test

void smjg.libs.sdwf.window.Window.initListeners | ( |  | ) | `[protected, virtual]`

Implements smjg.libs.sdwf.windowbase.WindowBase.

Reimplemented in smjg.libs.sdwf.framewindow.FrameWindow, and smjg.libs.sdwf.mdi.MDIFrameWindow.

override bool smjg.libs.sdwf.window.Window._despatchDialogMessage | ( | MSG * | msg | ) | `[protected]`

Reimplemented from smjg.libs.sdwf.windowbase.WindowBase.

## Member Data Documentation

deprecated typedef bool deprecated(* smjg.libs.sdwf.window.Window.KeyHandler)(uint message, uint keyCode, ushort repeatCount, ubyte scanCode, bool isExtendedKey, bool altKeyDown, bool wasDown, bool released)

The form of a method that receives and processes all keyboard messages.

Parameters:

  | message | the WM_xxxx constant identifying the keyboard message.
  | keyCode | the value of the keyboard message's wParam value, identifying the key that was pressed or released in a way dependent on the message that was received.
  | repeatCount | the number of times the keystroke is repeated because the user held down the key. This is normally 1; it will be greater only if Windows has coalesced key events.
  | scanCode | the OEM-dependent key scan code.
  | isExtendedKey | whether the key is an extended key.
  | altKeyDown | whether the ALT key was held down at the time of the event.
  | wasDown | whether the key was down immediately before the event occurred.
  | released | whether the key is released now that the event has occurred.

Returns:
  true to cause the message to be further handled by default processing.

See also:
  Window.keyHandler

Since:
  0.3

Status:
  done

WindowClass smjg.libs.sdwf.window.Window.wc`[protected]`

MouseHandler smjg.libs.sdwf.window.Window.mouseHandler`[protected]`

The method to which mouse messages will be delegated for processing.

Note:
  If Window.handler has an entry for any mouse message, then this will override Window.mouseHandler.

Deprecated:
  Superseded by listeners.

MouseHandler [uint] smjg.libs.sdwf.window.Window.mouseEventHandler`[protected]`

Associates each mouse message with an individual handler method.

The Window.selectMouseEventHandler listener must be added to the window for this to work.

Status:
  done

KeyHandler smjg.libs.sdwf.window.Window.keyHandler`[protected]`

The method to which keyboard messages will be delegated for processing.

Note:
  If Window.handler has an entry for any keyboard message, then this will override Window.keyHandler.

Deprecated:
  Superseded by listeners.

CharKeyHandler [uint] smjg.libs.sdwf.window.Window.charKeyEventHandler`[protected]`

Associates each keyboard message taking a character key code with an indvidual handler method.

The Window.selectKeyEventHandler listener must be added to the window for this to work.

Status:
  done

VirtualKeyHandler [uint] smjg.libs.sdwf.window.Window.virtualKeyEventHandler`[protected]`

Associates each keyboard message taking a virtual key code with an indvidual handler method.

The Window.selectKeyEventHandler listener must be added to the window for this to work.

Status:
  done

The documentation for this class was generated from the following file:

- window.d