]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/gauge.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxGauge class 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 #include "wx/wxprec.h" 
  19 #include "wx/os2/private.h" 
  22 /* gas gauge graph control messages--class "zYzGauge" */ 
  23 #define ZYZG_SETRANGE       (WM_USER + 0) 
  24 #define ZYZG_GETRANGE       (WM_USER + 1) 
  25 #define ZYZG_SETPOSITION    (WM_USER + 2) 
  26 #define ZYZG_GETPOSITION    (WM_USER + 3) 
  27 #define ZYZG_SETORIENTATION (WM_USER + 4) 
  28 #define ZYZG_GETORIENTATION (WM_USER + 5) 
  29 #define ZYZG_SETFGCOLOR     (WM_USER + 6) 
  30 #define ZYZG_GETFGCOLOR     (WM_USER + 7) 
  31 #define ZYZG_SETBKCOLOR     (WM_USER + 8) 
  32 #define ZYZG_GETBKCOLOR     (WM_USER + 9) 
  33 #define ZYZG_SETWIDTH3D     (WM_USER + 10) 
  34 #define ZYZG_GETWIDTH3D     (WM_USER + 11) 
  35 #define ZYZG_SETBEZELFACE   (WM_USER + 12) 
  36 #define ZYZG_GETBEZELFACE   (WM_USER + 13) 
  37 #define ZYZG_SETDELTAPOS    (WM_USER + 14) 
  39 /* orientations for ZYZG_WW_ORIENTATION */ 
  40 #define ZYZG_ORIENT_LEFTTORIGHT     0 
  41 #define ZYZG_ORIENT_RIGHTTOLEFT     1 
  42 #define ZYZG_ORIENT_BOTTOMTOTOP     2 
  43 #define ZYZG_ORIENT_TOPTOBOTTOM     3 
  46 #define ZYZGS_3D        0x8000L     /* control will be 3D       */ 
  48 /* public function prototypes */ 
  49 // BOOL _Optlink gaugeInit(HINSTANCE hInstance); 
  51 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
) 
  53 bool wxGauge::Create(wxWindow 
*parent
, wxWindowID id
, 
  59            const wxValidator
& validator
, 
  63     static bool wxGaugeOS2Initialised 
= FALSE
; 
  65     if ( !wxGaugeOS2Initialised 
) 
  69       if (!gaugeInit((HINSTANCE) wxGetInstance())) 
  70           wxFatalError("Cannot initalize Gauge library"); 
  72       wxGaugeOS2Initialised 
= TRUE
; 
  77     SetValidator(validator
); 
  79     if (parent
) parent
->AddChild(this); 
  83     m_windowStyle 
= style
; 
  86        m_windowId 
= (int)NewControlId(); 
 102   long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP; 
 106       CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("zYzGauge"), NULL, msFlags, 
 107                     0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId, 
 108                     wxGetInstance(), NULL); 
 110   m_hWnd = (WXHWND)wx_button; 
 112   // Subclass again for purposes of dialog editing mode 
 113   SubclassWin((WXHWND)wx_button); 
 117   if (m_windowStyle & wxGA_HORIZONTAL) 
 118     wOrient = ZYZG_ORIENT_LEFTTORIGHT; 
 120     wOrient = ZYZG_ORIENT_BOTTOMTOTOP; 
 122   SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0); 
 123   SendMessage(wx_button, ZYZG_SETRANGE, range, 0); 
 125   SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue())); 
 126   SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue())); 
 128   SetFont(parent->GetFont()); 
 134   SetSize(x, y, width, height); 
 136   ShowWindow(GetHwnd(), SW_SHOW); 
 141 void wxGauge::SetShadowWidth(int w
) 
 143     // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETWIDTH3D, w, 0); 
 146 void wxGauge::SetBezelFace(int w
) 
 148     // TODO optional  ::SendMessage(GetHwnd(), ZYZG_SETBEZELFACE, w, 0); 
 151 void wxGauge::SetRange(int r
) 
 154     // TODO ::SendMessage(GetHwnd(), ZYZG_SETRANGE, r, 0); 
 157 void wxGauge::SetValue(int pos
) 
 160     // TODO ::SendMessage(GetHwnd(), ZYZG_SETPOSITION, pos, 0); 
 163 int wxGauge::GetShadowWidth() const 
 165     // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETWIDTH3D, 0, 0); 
 169 int wxGauge::GetBezelFace() const 
 171     // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETBEZELFACE, 0, 0); 
 175 int wxGauge::GetRange() const 
 177     // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETRANGE, 0, 0); 
 181 int wxGauge::GetValue() const 
 183     // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETPOSITION, 0, 0); 
 187 bool wxGauge::SetForegroundColour(const wxColour
& col
) 
 189     if ( !wxControl::SetForegroundColour(col
) ) 
 192     // TODO ::SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue())); 
 197 bool wxGauge::SetBackgroundColour(const wxColour
& col
) 
 199     if ( !wxControl::SetBackgroundColour(col
) ) 
 202     // TODO ::SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue())); 
 210 // *      This module contains functions for creating nifty 3D borders 
 211 // *      around controls like zYzGauge. 
 214 // *      3/14/91     cjp     put in this comment 
 215 // *      6/19/92     cjp     touched it a bit 
 220 //   (C) Copyright Microsoft Corp. 1992.  All rights reserved. 
 222 //   You have a royalty-free right to use, modify, reproduce and 
 223 //   distribute the Sample Files (and/or any modified version) in 
 224 //   any way you find useful, provided that you agree that 
 225 //   Microsoft has no warranty obligations or liability for any 
 226 //   Sample Application Files which are modified. 
 230 ///* get the includes we need */ 
 234 ///* misc. control flag defines */ 
 235 //#define DRAW3D_IN           0x0001 
 236 //#define DRAW3D_OUT          0x0002 
 238 //#define DRAW3D_TOPLINE      0x0004 
 239 //#define DRAW3D_BOTTOMLINE   0x0008 
 240 //#define DRAW3D_LEFTLINE     0x0010 
 241 //#define DRAW3D_RIGHTLINE    0x0020 
 244 ///* public function prototypes */ 
 245 //void _Optlink Draw3DFaceFrame(HDC, LPRECT, WORD); 
 246 //void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD); 
 247 //void _Optlink Draw3DLine(HDC, WORD, WORD, WORD, WORD, WORD); 
 250 ///** void _Optlink Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth) 
 253 // *      This function draws a flat frame with the current button-face 
 257 // *      HDC hdc     :   The DC to draw into. 
 259 // *      LPRECT rc   :   The containing rect for the new frame. 
 261 // *      WORD wWidth :   The width of the frame to draw. 
 263 // *  RETURN (void _Optlink): 
 264 // *      The frame will have been drawn into the DC. 
 270 //void _Optlink Draw3DFaceFrame(HDC hdc, RECTL* rc, WORD wWidth) 
 275 //    /* don't go through a bunch of work if we don't have to */ 
 279 //    /* set up color to be button-face color--so it may not be gray */ 
 280 //    rgbOld = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE)); 
 282 //    /* perform CopyRect w/o bloody windows style overhead */ 
 286 //    rc1.top = rc->top; 
 287 //    rc1.left = rc->left; 
 288 //    rc1.bottom = rc->top + wWidth; 
 289 //    rc1.right = rc->right; 
 292 //    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL); 
 295 //    rc1.left = rc->right - wWidth; 
 296 //    rc1.bottom = rc->bottom; 
 298     /* blast this part now */ 
 299 //    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL); 
 302 //    rc1.left = rc->left; 
 303 //    rc1.right = rc->left + wWidth; 
 305     /* and another part */ 
 306 //    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL); 
 309 //    rc1.right = rc->right; 
 310 //    rc1.top = rc->bottom - wWidth; 
 313 //    ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL); 
 315     /* restore the old bk color */ 
 316 //    SetBkColor(hdc, rgbOld); 
 317 //} /* Draw3DFaceFrame() */ 
 320 ///** void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD) 
 323 // *      Draws a 3D rectangle that is shaded.  wFlags can be used to 
 324 // *      control how the rectangle looks. 
 327 // *      HDC hdc             :   Handle to the device context that will be 
 328 // *                              used to display the rectangle. 
 330 // *      RECT rect           :   A rectangle describing the dimensions of 
 331 // *                              the rectangle in device coordinates. 
 333 // *      WORD wShadowWidth   :   Width of the shadow in device coordinates. 
 335 // *      WORD wFlags         :   The following flags may be passed to describe 
 336 // *                              the style of the rectangle: 
 338 // *                              DRAW3D_IN   :   The shadow is drawn such that 
 339 // *                              the box appears to be sunk in to the screen. 
 340 // *                              This is default if 0 is passed. 
 342 // *                              DRAW3D_OUT  :   The shadow is drawn such that 
 343 // *                              the box appears to be sticking out of the 
 346 // *  RETURN (void _Optlink): 
 347 // *      The 3D looking rectangle will have been drawn into the DC. 
 353 //void _Optlink Draw3DRect(HDC hdc, LPRECT lpRect, 
 354 //                               WORD wShadowWidth, WORD wFlags) 
 356 //    /* sanity check--don't work if you don't have to! */ 
 357 //    if (!wShadowWidth || !RectVisible(hdc, lpRect)) 
 360     /* draw the top line */ 
 361 //    Draw3DLine(hdc, lpRect->left, lpRect->top, 
 362 //                    lpRect->right - lpRect->left, 
 363 //                    wShadowWidth, DRAW3D_TOPLINE | wFlags); 
 366 //    Draw3DLine(hdc, lpRect->right, lpRect->top, 
 367 //                    lpRect->bottom - lpRect->top, 
 368 //                    wShadowWidth, DRAW3D_RIGHTLINE | wFlags); 
 371 //    Draw3DLine(hdc, lpRect->left, lpRect->bottom, 
 372 //                    lpRect->right - lpRect->left, 
 373 //                    wShadowWidth, DRAW3D_BOTTOMLINE | wFlags); 
 376 //    Draw3DLine(hdc, lpRect->left, lpRect->top, 
 377 //                    lpRect->bottom - lpRect->top, 
 378 //                    wShadowWidth, DRAW3D_LEFTLINE | wFlags); 
 379 //} /* Draw3DRect() */ 
 382 ///** void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen, 
 385 // *      Draws a 3D line that can be used to make a 3D box. 
 388 // *      HDC hdc             :   Handle to the device context that will be 
 389 // *                              used to display the 3D line. 
 391 // *      WORD x, y           :   Coordinates of the beginning of the line. 
 392 // *                              These coordinates are in device units and 
 393 // *                              represent the _outside_ most point. Horiz- 
 394 // *                              ontal lines are drawn from left to right and 
 395 // *                              vertical lines are drawn from top to bottom. 
 397 // *      WORD wShadowWidth   :   Width of the shadow in device coordinates. 
 399 // *      WORD  wFlags        :   The following flags may be passed to 
 400 // *                              describe the style of the 3D line: 
 402 // *                              DRAW3D_IN   :   The shadow is drawn such that 
 403 // *                              the box appears to be sunk in to the screen. 
 404 // *                              This is default if 0 is passed. 
 406 // *                              DRAW3D_OUT  :   The shadow is drawn such that 
 407 // *                              the box appears to be sticking out of the 
 410 // *                              DRAW3D_TOPLINE, _BOTTOMLINE, _LEFTLINE, and 
 411 // *                              _RIGHTLINE  :   Specifies that a "top", 
 412 // *                              "Bottom", "Left", or"Right" line is to be 
 415 // *  RETURN (void _Optlink): 
 416 // *      The line will have been drawn into the DC. 
 422 //void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen, 
 423 //                               WORD wShadowWidth, WORD wFlags) 
 428 //    POINT   Point[ 4 ];         /* define a polgon with 4 points    */ 
 430 //    /* if width is zero, don't do nothin'! */ 
 431 //    if (!wShadowWidth) 
 434     /* define shape of polygon--origin is always the same */ 
 438 //    /*  To do this we'll simply draw a polygon with four sides, using 
 439 //     *  the appropriate brush.  I dare you to ask me why this isn't a 
 442 //    if (wFlags & DRAW3D_TOPLINE) 
 444 //        /* across to right */ 
 445 //        Point[1].x = x + nLen - (wShadowWidth == 1 ? 1 : 0); 
 449 //        Point[2].x = x + nLen - wShadowWidth; 
 450 //        Point[2].y = y + wShadowWidth; 
 452         /* accross to left */ 
 453 //        Point[3].x = x + wShadowWidth; 
 454 //        Point[3].y = y + wShadowWidth; 
 456         /* select 'dark' brush if 'in'--'light' for 'out' */ 
 457 //        fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE; 
 460     /* possibly the bottom? */ 
 461 //    else if (wFlags & DRAW3D_BOTTOMLINE) 
 463         /* across to right */ 
 464 //        Point[1].x = x + nLen; 
 468 //        Point[2].x = x + nLen - wShadowWidth; 
 469 //        Point[2].y = y - wShadowWidth; 
 471         /* accross to left */ 
 472 //        Point[3].x = x + wShadowWidth; 
 473 //        Point[3].y = y - wShadowWidth; 
 475         /* select 'light' brush if 'in' */ 
 476 //        fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE; 
 479     /* ok, it's gotta be left? */ 
 480 //    else if (wFlags & DRAW3D_LEFTLINE) 
 484 //        Point[1].y = y + nLen - (wShadowWidth == 1 ? 1 : 0); 
 487 //        Point[2].x = x + wShadowWidth; 
 488 //        Point[2].y = y + nLen - wShadowWidth; 
 491 //        Point[3].x = x + wShadowWidth; 
 492 //        Point[3].y = y + wShadowWidth; 
 494         /* select 'dark' brush if 'in'--'light' for 'out' */ 
 495 //        fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE; 
 498     /* well maybe it's for the right side? */ 
 499 //    else if (wFlags & DRAW3D_RIGHTLINE) 
 503 //        Point[1].y = y + nLen; 
 506 //        Point[2].x = x - wShadowWidth; 
 507 //        Point[2].y = y + nLen - wShadowWidth; 
 510 //        Point[3].x = x - wShadowWidth; 
 511 //        Point[3].y = y + wShadowWidth; 
 513         /* select 'light' brush if 'in' */ 
 514 //        fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE; 
 520     /* select NULL_PEN for no borders */ 
 521 //    hOldPen = (HPEN) SelectObject(hdc, GetStockObject(NULL_PEN)); 
 523     /* select the appropriate color for the fill */ 
 525 //        hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(GRAY_BRUSH)); 
 527 //        hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(WHITE_BRUSH)); 
 529     /* finally, draw the dern thing */ 
 530 //    Polygon(hdc, (LPPOINT)&Point, 4); 
 532     /* restore what we killed */ 
 533 //    SelectObject(hdc, hOldBrush); 
 534 //    SelectObject(hdc, hOldPen); 
 535 //} /* Draw3DLine() */ 
 542 // *      Yet another 'Gas Gauge Custom Control.'  This control gives you 
 543 // *      a 'progress bar' class (named zYzGauge) for use in your applications. 
 544 // *      You can set the range, position, font, color, orientation, and 3d 
 545 // *      effect of the gauge by sending messages to the control. 
 547 // *      Before you can use this control, you MUST first export the window 
 548 // *      procedure for the control (or define it with the _export keyword): 
 550 // *          EXPORTS     gaugeWndProc 
 552 // *      You then need initialize the class before you use it: 
 554 // *          if (!gaugeInit(hInstance)) 
 555 // *              die a horrible death 
 557 // *              you are good to go 
 559 // *      The colors used by the control default to black and white if you 
 560 // *      are running on a mono-display.  They default to blue and white 
 561 // *      if you are on a color display.  You enable the 3D effect by setting 
 562 // *      the ZYZGS_3D style flag in the styles field of the control (like 
 563 // *      any other control). 
 565 // *      To select your own colors, you can send the ZYZG_SETFGCOLOR and 
 566 // *      ZYZG_SETBKCOLOR messages to set the foreground (percent done) and 
 567 // *      background (percent not done) colors.  The lParam is the RGB() 
 568 // *      value--wParam is ignored. 
 570 // *      In all of the following ZYZG_??? messages, the arguments are 
 571 // *      WORDS.  If you are setting parameters, the value is sent as 
 572 // *      the wParam (lParam is ignored).  If you are getting parameters, 
 573 // *      the value is returned as a LONG and should be cast to a *signed* 
 576 // *      To set the depth of the 3D effect (if enabled), you can send the 
 577 // *      ZYZG_SETBEZELFACE and ZYZG_SETWIDTH3D messages.  The bezel face 
 578 // *      is the flat top on the 3D border--its color will be that of the 
 579 // *      button-face.  The 3D width is the width of the bezel itself; inside 
 580 // *      and outside.  The light color is white, the dark color is gray. 
 581 // *      Both widths *can* be zero--both default to 2 which looks to me. 
 583 // *      The range of the control can be set by sending the ZYZG_SETRANGE 
 584 // *      message to the control.  It can be any integer from 1 to 32767. 
 585 // *      What this specifies is the number of pieces that create a whole. 
 586 // *      The default is 100.  You can get the current range setting by 
 587 // *      sending the ZYZG_GETRANGE message to the control. 
 589 // *      The position (number of pieces out of the whole have been used) is 
 590 // *      set with the ZYZG_SETPOSITION message.  It can be any integer from 
 591 // *      0 to the current range setting of the control--it will be clipped 
 592 // *      if the position is out of bounds.  The default position is 0.  You 
 593 // *      can get the current position at any time with the ZYZG_GETPOSITION 
 596 // *      You can also set the range using a delta from the current range. 
 597 // *      This is done by sending the ZYZG_SETDELTAPOS message with wParam 
 598 // *      set to a _signed_ integer value within the range of the control. 
 600 // *      The font used for the percentage text can be set using the standard 
 601 // *      WM_SETFONT message.  You can get the current font at any time with 
 602 // *      the WM_GETFONT message. 
 604 // *      The orientation can be left to right, right to left, bottom to top, 
 605 // *      or top to bottom.  Whatever suits your needs.  You set this by 
 606 // *      sending the ZYZG_ORIENTATION message to the control with one of 
 607 // *      the following values (default is ZYZG_ORIENT_LEFTTORIGHT): 
 609 // *          ZYZG_ORIENT_LEFTTORIGHT (0) 
 610 // *          ZYZG_ORIENT_RIGHTTOLEFT (1) 
 611 // *          ZYZG_ORIENT_BOTTOMTOTOP (2) 
 612 // *          ZYZG_ORIENT_TOPTOBOTTOM (3) 
 615 // *      3/12/91     cjp     put in this comment 
 616 // *      6/19/92     cjp     touched it a bit 
 621 //   (C) Copyright Microsoft Corp. 1992.  All rights reserved. 
 623 //   You have a royalty-free right to use, modify, reproduce and 
 624 //   distribute the Sample Files (and/or any modified version) in 
 625 //   any way you find useful, provided that you agree that 
 626 //   Microsoft has no warranty obligations or liability for any 
 627 //   Sample Application Files which are modified. 
 631 /* get the includes we need */ 
 632 //#if !defined(__GNUWIN32__) && !defined(__SALFORDC__) 
 633 //#include <malloc.h> 
 636 //#include <string.h> 
 637 //#include <stdlib.h> 
 638 // #include "zyz3d.h" 
 639 // #include "zyzgauge.h" 
 642 /* static global variables */ 
 643 //static wxChar gszzYzGaugeClass[] = wxT("zYzGauge"); 
 646 /* window word position definitions */ 
 647 //#define ZYZG_WW_PZYZGAUGE   0 
 648 /* #define ZYZG_WW_EXTRABYTES  2 */ 
 649 //#define ZYZG_WW_EXTRABYTES  4 
 652 /* control block structure typedef */ 
 653 //typedef struct tZYZGAUGE 
 657 //    WORD    wOrientation; 
 659 //    WORD    wWidthBezelFace; 
 661 //    DWORD   rgbTextColor; 
 664 //} ZYZGAUGE, *PZYZGAUGE, FAR *LPZYZGAUGE; 
 667 /* some default values for the control */ 
 668 //#define ZYZG_DEF_RANGE          100 
 669 //#define ZYZG_DEF_POSITION       0 
 670 //#define ZYZG_DEF_ORIENTATION    ZYZG_ORIENT_LEFTTORIGHT 
 671 //#define ZYZG_DEF_WIDTH3D        2 
 672 //#define ZYZG_DEF_BEZELFACE      2 
 676 /* the default settings for drawing colors--display dependent */ 
 677 //static DWORD    rgbDefTextColor; 
 678 //static DWORD    rgbDefBkColor; 
 679 //static BOOL     fSupport3D; 
 681 //#if !defined(APIENTRY)    // NT defines APIENTRY, 3.x not 
 682 //#define APIENTRY _Optlink 
 686 //#define _EXPORT /**/ 
 688 //#define _EXPORT _export 
 689 //typedef signed short int SHORT ; 
 692 /* internal function prototypes */ 
 693 //static void PASCAL gaugePaint(HWND, HDC); 
 694 /* LRESULT _Optlink */ 
 695 //LRESULT APIENTRY _EXPORT gaugeWndProc(HWND, UINT, WPARAM, LPARAM); 
 699 ///** BOOL _Optlink gaugeInit(HINSTANCE hInstance) 
 702 // *      Registers the window class for the zYzGauge control.  Performs 
 703 // *      other initialization for the zYzGauge text control.  This must 
 704 // *      be done before the zYzGauge control is used--or it will fail 
 705 // *      and your dialog box will not open! 
 708 // *      HINSTANCE hInstance :   Instance handle to register class with. 
 710 // *  RETURN (BOOL FAR): 
 711 // *      The return value is TRUE if the zYzGauge class was successfully 
 712 // *      registered.  It is FALSE if the initialization fails. 
 718 //#pragma alloc_text(init, gaugeInit) 
 720 //BOOL _Optlink gaugeInit(HINSTANCE hInstance) 
 722 //    static BOOL fRegistered = FALSE; 
 726     /* assume already registered if not first instance */ 
 730     /* fill in the class structure for the zyzgauge control */ 
 731 //    wc.hCursor          = LoadCursor(NULL, IDC_ARROW); 
 733 //    wc.lpszMenuName     = NULL; 
 734 //    wc.lpszClassName    = gszzYzGaugeClass; 
 735 //    wc.hbrBackground    = (HBRUSH)(COLOR_WINDOW + 1); 
 736 //    wc.hInstance        = hInstance; 
 738 //#ifdef ZYZGAUGE_DLL 
 739 //    wc.style            = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW; 
 741 //    wc.style            = CS_HREDRAW | CS_VREDRAW; 
 744 //    wc.lpfnWndProc      = gaugeWndProc; 
 745 //    wc.cbClsExtra       = 0; 
 746 //    wc.cbWndExtra       = ZYZG_WW_EXTRABYTES; 
 748     /* attempt to register it--return FALSE if fail */ 
 749 //    if (!RegisterClass(&wc)) 
 752     /*  Get a DC to determine whether device is mono or not, and set 
 753      *  default foreground/background colors as appropriate. 
 755 //    hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0L) ; 
 758         /* check for mono-display */ 
 759 //        if ((GetDeviceCaps(hdc, BITSPIXEL) == 1) && 
 760 //             (GetDeviceCaps(hdc, PLANES) == 1)) 
 762             /* using a mono DC--white foreground, black background */ 
 763 //            rgbDefTextColor = RGB(255, 255, 255); 
 764 //            rgbDefBkColor = RGB(0, 0, 0); 
 767         /* good! we have color: blue foreground, white background */ 
 770 //            rgbDefTextColor = RGB(0, 0, 255); 
 771 //            rgbDefBkColor = RGB(255, 255, 255); 
 774         /* need at _least_ 8 for two shades of gray (>=VGA) */ 
 775 //        fSupport3D = (GetDeviceCaps(hdc, NUMCOLORS) >= 8) ? TRUE : FALSE; 
 777         /* get rid of the DC (IC) */ 
 781     /* uh-oh... can't get DC (IC)... fail */ 
 784         /* unregister the class */ 
 785 //        UnregisterClass(gszzYzGaugeClass, hInstance); 
 790 //    return (fRegistered = TRUE); 
 791 //} /* gaugeInit() */ 
 794 /** static void PASCAL gaugePaint(HWND hwnd, HDC hdc) 
 797 // *      This function is responsible for painting the zYzGauge control. 
 800 // *      HWND hwnd   :   The window handle for the gauge. 
 802 // *      HDC hdc     :   The DC for the gauge's window. 
 805 // *      The control will have been painted. 
 811 //static void PASCAL gaugePaint(HWND hwnd, HDC hdc) 
 814 //    WORD        iRange, iPos; 
 820 //    WORD        dx, dy, wGomerX, wGomerY; 
 821 ///* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead, 
 822 // * which needs a SIZE* parameter */ 
 823 //#if defined(__WIN32__) 
 827 //    /* get pointer to the control's control block */ 
 828 //    pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE); 
 829 //    pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE); 
 831     /* set the colors into for the gauge into the control */ 
 832 //    SetTextColor(hdc, pgauge->rgbTextColor); 
 833 //    SetBkColor(hdc, pgauge->rgbBkColor); 
 835     /* draw black rectangle for gauge */ 
 836 //    GetClientRect(hwnd, &rc1); 
 838     /* draw a black border on the _outside_ */ 
 839 //    FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH)); 
 841     /* we want to draw _just inside_ the black border */ 
 842 //    InflateRect(&rc1, -1, -1); 
 844     /* one line thick so far... */ 
 845 //    Offset = (WORD) 1; 
 847     /* for 3D stuff, we need to have at least two shades of gray */ 
 848 //    if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D) 
 850 //        Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_OUT); 
 851 //    InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D)); 
 853 //        Draw3DFaceFrame(hdc, &rc1, pgauge->wWidthBezelFace); 
 854 //    InflateRect(&rc1, ~(pgauge->wWidthBezelFace), ~(pgauge->wWidthBezelFace)); 
 856 //        Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_IN); 
 857 //    InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D)); 
 859         /* draw a black border on the _inside_ */ 
 860 //        FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH)); 
 862         /* we want to draw _just inside_ the black border */ 
 863 //        InflateRect(&rc1, -1, -1); 
 865         /* add all the other pixels into the border width */ 
 866 //        Offset += (2 * pgauge->wWidth3D) + pgauge->wWidthBezelFace + 1; 
 869     /* dup--one rc for 'how much filled', one rc for 'how much empty' */ 
 872     /* get the range--make sure it's a valid range */ 
 873 //    if ((iRange = pgauge->wRange) <= 0) 
 876     /* get the position--greater than 100% would be bad */ 
 877 //    if ((iPos = pgauge->wPosition) > iRange) 
 880     /* compute the actual size of the gauge */ 
 881 //    dx = rc1.right - rc1.left; 
 882 //    dy = rc1.bottom - rc1.top; 
 883 //    wGomerX = (WORD)((DWORD)iPos * dx / iRange); 
 884 //    wGomerY = (WORD)((DWORD)iPos * dy / iRange); 
 886     /* get the orientation and munge rects accordingly */ 
 887 //    switch (pgauge->wOrientation) 
 889 //        case ZYZG_ORIENT_RIGHTTOLEFT: 
 890 //            rc1.left = rc2.right = rc1.right - wGomerX; 
 893 //        case ZYZG_ORIENT_BOTTOMTOTOP: 
 894 //            rc1.top = rc2.bottom = rc1.bottom - wGomerY; 
 897 //        case ZYZG_ORIENT_TOPTOBOTTOM: 
 898 //            rc1.bottom = rc2.top += wGomerY; 
 902 //            rc1.right = rc2.left += wGomerX; 
 906     /* select the correct font */ 
 907 //    hFont = (HFONT) SelectObject(hdc, pgauge->hFont); 
 909     /* build up a string to blit out--ie the meaning of life: "42%" */ 
 910 //    wsprintf(ach, wxT("%3d%%"), (WORD)((DWORD)iPos * 100 / iRange)); 
 911 /* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead */ 
 912 //#if defined(__WIN32__) 
 913 //    GetTextExtentPoint(hdc, ach, wGomerX = lstrlen(ach), &size); 
 914 //    dwExtent = size.cx; 
 916 //    dwExtent = GetTextExtent(hdc, ach, wGomerX = lstrlen(ach)); 
 920     /*  Draw the finished (ie the percent done) side of box.  If 
 921      *  ZYZG_WW_POSITION is 42, (in range of 0 to 100) this ExtTextOut 
 922      *  draws the meaning of life (42%) bar. 
 924 //    ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset, 
 925 //                    (dy - HIWORD(dwExtent)) / 2 + Offset, 
 926 //                    ETO_OPAQUE | ETO_CLIPPED, &rc2, ach, wGomerX, NULL); 
 928     /*  Reverse fore and back colors for drawing the undone (ie the non- 
 929      *  finished) side of the box. 
 931 //    SetBkColor(hdc, pgauge->rgbTextColor); 
 932 //    SetTextColor(hdc, pgauge->rgbBkColor); 
 934 //    ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset, 
 935 //                    (dy - HIWORD(dwExtent)) / 2 + Offset, 
 936 //                    ETO_OPAQUE | ETO_CLIPPED, &rc1, ach, wGomerX, NULL); 
 938     /* unselect the font */ 
 939 //    SelectObject(hdc, hFont); 
 940 //} /* gaugePaint() */ 
 943 /** LRESULT _Optlink gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
 946 // *      This is the control's window procedure.  Its purpose is to handle 
 947 // *      special messages for this custom control. 
 949 // *      The special control messages for the gauge control are: 
 951 // *          ZYZG_SETRANGE       :   Sets the range of the gauge.  In other 
 952 // *                                  words, the number of parts that make a 
 955 // *          ZYZG_GETRANGE       :   Returns the current range of the gauge. 
 957 // *          ZYZG_SETORIENTATION :   Sets the orientation of the gauge.  This 
 958 // *                                  can be one of the ZYZG_ORIENT_?? msgs. 
 960 // *          ZYZG_GETORIENTATION :   Gets the current orientation of the 
 963 // *          ZYZG_SETPOSITION    :   Sets the current position of the gauge. 
 964 // *                                  In other words, how many pieces of the 
 965 // *                                  whole have been used. 
 967 // *          ZYZG_GETPOSITION    :   Gets the current position of the gauge. 
 969 // *          ZYZG_SETDELTAPOS    :   Sets the position of the gauge +/- the 
 970 // *                                  specified amount. 
 972 // *          ZYZG_SETFGCOLOR     :   Sets the foreground (percent done) color. 
 974 // *          ZYZG_GETFGCOLOR     :   Gets the foreground (percent done) color. 
 976 // *          ZYZG_SETBKCOLOR     :   Sets the background (percent not done) 
 979 // *          ZYZG_GETBKCOLOR     :   Gets the background (percent not done) 
 982 // *          WM_SETFONT          :   Sets the font to use for the percentage 
 983 // *                                  text of the gauge. 
 985 // *          WM_GETFONT          :   Gets the current font in use by the 
 992 /* LRESULT _Optlink */ 
 994 //LRESULT APIENTRY _EXPORT gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
1001 //    pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE); 
1002 //    pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE); 
1004     /* break to get DefWindowProc() */ 
1008             /* need to allocate a control block */ 
1009 //            pgauge = (PZYZGAUGE)LocalAlloc(LPTR, sizeof(ZYZGAUGE)); 
1010 //            pgauge = (PZYZGAUGE)malloc(sizeof(ZYZGAUGE)); 
1014             /* hang on to this control block */ 
1015 //            SetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE, (WORD)pgauge); 
1016 //            SetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE, (LONG)pgauge); 
1018             /* fill control block with defaults */ 
1019 //            pgauge->wRange           = ZYZG_DEF_RANGE; 
1020 //            pgauge->wPosition        = ZYZG_DEF_POSITION; 
1021 //            pgauge->wOrientation     = ZYZG_DEF_ORIENTATION; 
1022 //            pgauge->wWidth3D         = ZYZG_DEF_WIDTH3D; 
1023 //            pgauge->wWidthBezelFace  = ZYZG_DEF_BEZELFACE; 
1024 //            pgauge->rgbTextColor     = rgbDefTextColor; 
1025 //            pgauge->rgbBkColor       = rgbDefBkColor; 
1027             /* use system font */ 
1028 //            SendMessage(hwnd, WM_SETFONT, (WPARAM)NULL, 0L); 
1030             /* go to DefWindowProc() to finish the job */ 
1034             /* get rid of the control's memory */ 
1036 //                LocalFree((HANDLE)pgauge); 
1040 //        case ZYZG_GETPOSITION: 
1041 //            return (pgauge->wPosition); 
1043 //        case ZYZG_GETRANGE: 
1044 //            return (pgauge->wRange); 
1046 //        case ZYZG_GETORIENTATION: 
1047 //            return (pgauge->wOrientation); 
1049 //        case ZYZG_GETWIDTH3D: 
1050 //            return (pgauge->wWidth3D); 
1052 //        case ZYZG_GETBEZELFACE: 
1053 //            return (pgauge->wWidthBezelFace); 
1055 //        case ZYZG_GETBKCOLOR: 
1056 //            return (pgauge->rgbTextColor); 
1058 //        case ZYZG_GETFGCOLOR: 
1059 //            return (pgauge->rgbBkColor); 
1061 //        case ZYZG_SETBKCOLOR: 
1062 //            pgauge->rgbBkColor = lParam; 
1065 //        case ZYZG_SETFGCOLOR: 
1066 //            pgauge->rgbTextColor = lParam; 
1070 //        case ZYZG_SETPOSITION: 
1071 //            pgauge->wPosition = wParam; 
1074 //            GetClientRect(hwnd, &rc); 
1075 //            if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D) 
1077 //                wParam = (2 * pgauge->wWidth3D) + 
1078 //                            pgauge->wWidthBezelFace + 2; 
1084 //        InflateRect(&rc, ~(wParam), ~(wParam)); 
1085 //            InvalidateRect(hwnd, &rc, FALSE); 
1086 //            UpdateWindow(hwnd); 
1089 //        case ZYZG_SETRANGE: 
1090 //            pgauge->wRange = wParam; 
1091 //            goto zyzgForceRepaint; 
1093 //        case ZYZG_SETORIENTATION: 
1094 //            pgauge->wOrientation = wParam; 
1095 //            goto zyzgForceRepaint; 
1097 //        case ZYZG_SETWIDTH3D: 
1098 //            pgauge->wWidth3D = wParam; 
1100 //zyzgForceRepaint3D: 
1101 //            InvalidateRect(hwnd, NULL, FALSE); 
1102 //            UpdateWindow(hwnd); 
1105 //        case ZYZG_SETBEZELFACE: 
1106 //            pgauge->wWidthBezelFace = wParam; 
1107 //            goto zyzgForceRepaint3D; 
1109 //        case ZYZG_SETDELTAPOS: 
1110 ///* Watcom doesn't like the following line so removing typecasts */ 
1111 ///*            (int)pgauge->wPosition += (int)wParam; */ 
1112 //            pgauge->wPosition += wParam; 
1113 //            goto zyzgForceRepaint; 
1116 //            BeginPaint(hwnd, &ps); 
1117 //            gaugePaint(hwnd, ps.hdc); 
1118 //            EndPaint(hwnd, &ps); 
1122 //            hFont = pgauge->hFont; 
1124 //            /* if system font, then return NULL handle */ 
1125 //            return (long)((hFont == GetStockObject(SYSTEM_FONT)) ? NULL : hFont); 
1128             /* if NULL hFont, use system font */ 
1129 //            hFont = (HFONT)wParam ; 
1131 //                hFont = (HFONT) GetStockObject(SYSTEM_FONT); 
1133 //            pgauge->hFont = hFont; 
1135             /* redraw if indicated in message */ 
1136 //            if ((BOOL)lParam) 
1138 //                InvalidateRect(hwnd, NULL, TRUE); 
1139 //                UpdateWindow(hwnd); 
1142 //    } /* switch () */ 
1144     /* let the dialog mangler take care of this message */ 
1145 //    return (DefWindowProc(hwnd, uMsg, wParam, lParam)); 
1146 //} /* gaugeWndProc() */ 
1149 /** EOF: zyzgauge.c **/