statusbar objects

From: Rick VanNorman <rick_at_forth.com>
Date: Tue, 09 Apr 2002 22:15:28 -0700

Dear Constant Reader,

Another tidbit; this one is a simple class-based status
bar object. Both single and multi pane versions are given.

Enjoy,
Rick

{ ====================================================================
status.f

Copyright (C) 2001 FORTH, Inc. <br> Rick VanNorman rvn_at_forth.com
==================================================================== }

OPTIONAL STATUSBAR Single and multipane general purpose status bars classes.

ABSENT oSTAT [IF] 0 VALUE oSTAT [THEN]
ABSENT hSTAT [IF] 0 VALUE hSTAT [THEN]

\ we derrive our simplestat class from the existing windows statusbar
\ object.

DERRIVEDWINDOW SUBCLASS SIMPLESTAT

   0 WS_CHILD OR
     WS_VISIBLE OR
     WS_CLIPSIBLINGS OR
     CCS_BOTTOM OR
   CONSTANT STYLE

   : MyWindow_Style STYLE ;

   : MyWindow_ClassName Z" msctls_statusbar32" ;

   : MyWindow_WindowName 0 ;

   \ hosting application may call HIGH to discover how high
   \ windows decided to make the status bar. nice for window
   \ resizing calculations

   : HIGH ( -- n )
      [OBJECTS RECT MAKES AREA OBJECTS]
      mHWND AREA ADDR :: GetWindowRect DROP
      AREA bottom @ AREA top @ - ;

   : PostConstruct ( -- )
      ADDR TO oSTAT mHWND TO hSTAT ;

   \ the hosting application can set the default font for the status
   \ bar to the system fixed font instead of the system default
   \ proportional font.

   : FIXED-FONT ( -- )
      mHWND WM_SETFONT ANSI_FIXED_FONT :: GetStockObject 1
      :: SendMessage DROP ;

END-CLASS

{ --------------------------------------------------------------------
-------------------------------------------------------------------- }

SIMPLESTAT SUBCLASS MULTISTAT

   \ how many parts to divide the status bar into

   5 CONSTANT PARTS

   \ map of pixel widths for division. -1 fills to right.

   CREATE PANEMAP
     50 , 100 , 250 , 525 , -1 ,

   \ create multiple panes

   : DIVIDES ( -- )
      mHWND SB_SETPARTS PARTS PANEMAP :: SendMessage DROP ;

   \ after construction, divide the control

   : PostConstruct ( -- ) DIVIDES
      ADDR TO oSTAT mHWND TO hSTAT ;

   \ output text to a particular pane

   : PANE-TYPE ( addr n pane -- ) -ROT R-BUF S" " R@ ZPLACE
      R@ ZAPPEND mHWND SB_SETTEXTA ROT R> :: SendMessage DROP ;

END-CLASS

\ assuming that your application only has one status bar, whose
\ object address is held in oSTAT and whose handle is held in
\ hSTAT, you may use PANE-TYPE to display messages on the various
\ panes of the status bar without needing to reference the actual
\ objects.

: PANE-TYPE ( addr n pane -- )
   hSTAT IF
      oSTAT [OBJECTS MULTISTAT NAMES STAT OBJECTS]
      STAT PANE-TYPE
   ELSE DROP 2DROP THEN ;

----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Tue Apr 09 2002 - 22:15:13 PDT


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.