]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/gauge.cpp
89d6f45340423bd45441c1ac1675190558866e0c
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGauge class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
20 #include "wx/os2/private.h"
23 /* gas gauge graph control messages--class "zYzGauge" */
24 #define ZYZG_SETRANGE (WM_USER + 0)
25 #define ZYZG_GETRANGE (WM_USER + 1)
26 #define ZYZG_SETPOSITION (WM_USER + 2)
27 #define ZYZG_GETPOSITION (WM_USER + 3)
28 #define ZYZG_SETORIENTATION (WM_USER + 4)
29 #define ZYZG_GETORIENTATION (WM_USER + 5)
30 #define ZYZG_SETFGCOLOR (WM_USER + 6)
31 #define ZYZG_GETFGCOLOR (WM_USER + 7)
32 #define ZYZG_SETBKCOLOR (WM_USER + 8)
33 #define ZYZG_GETBKCOLOR (WM_USER + 9)
34 #define ZYZG_SETWIDTH3D (WM_USER + 10)
35 #define ZYZG_GETWIDTH3D (WM_USER + 11)
36 #define ZYZG_SETBEZELFACE (WM_USER + 12)
37 #define ZYZG_GETBEZELFACE (WM_USER + 13)
38 #define ZYZG_SETDELTAPOS (WM_USER + 14)
40 /* orientations for ZYZG_WW_ORIENTATION */
41 #define ZYZG_ORIENT_LEFTTORIGHT 0
42 #define ZYZG_ORIENT_RIGHTTOLEFT 1
43 #define ZYZG_ORIENT_BOTTOMTOTOP 2
44 #define ZYZG_ORIENT_TOPTOBOTTOM 3
47 #define ZYZGS_3D 0x8000L /* control will be 3D */
49 /* public function prototypes */
50 BOOL _Optlink
gaugeInit(HINSTANCE hInstance
);
52 #if !USE_SHARED_LIBRARY
53 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
)
56 bool wxGauge::Create(wxWindow
*parent
, wxWindowID id
,
61 const wxValidator
& validator
,
64 static bool wxGaugeOS2Initialised
= FALSE
;
66 if ( !wxGaugeOS2Initialised
)
68 if (!gaugeInit((HINSTANCE
) wxGetInstance()))
69 wxFatalError("Cannot initalize Gauge library");
70 wxGaugeOS2Initialised
= TRUE
;
74 SetValidator(validator
);
75 if (parent
) parent
->AddChild(this);
79 m_windowStyle
= style
;
82 m_windowId
= (int)NewControlId();
98 long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
102 CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("zYzGauge"), NULL, msFlags,
103 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
104 wxGetInstance(), NULL);
106 m_hWnd = (WXHWND)wx_button;
108 // Subclass again for purposes of dialog editing mode
109 SubclassWin((WXHWND)wx_button);
113 if (m_windowStyle & wxGA_HORIZONTAL)
114 wOrient = ZYZG_ORIENT_LEFTTORIGHT;
116 wOrient = ZYZG_ORIENT_BOTTOMTOTOP;
118 SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0);
119 SendMessage(wx_button, ZYZG_SETRANGE, range, 0);
121 SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
122 SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
124 SetFont(parent->GetFont());
130 SetSize(x, y, width, height);
132 ShowWindow(GetHwnd(), SW_SHOW);
137 void wxGauge::SetShadowWidth(int w
)
139 // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETWIDTH3D, w, 0);
142 void wxGauge::SetBezelFace(int w
)
144 // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETBEZELFACE, w, 0);
147 void wxGauge::SetRange(int r
)
150 // TODO ::SendMessage(GetHwnd(), ZYZG_SETRANGE, r, 0);
153 void wxGauge::SetValue(int pos
)
156 // TODO ::SendMessage(GetHwnd(), ZYZG_SETPOSITION, pos, 0);
159 int wxGauge::GetShadowWidth() const
161 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETWIDTH3D, 0, 0);
165 int wxGauge::GetBezelFace() const
167 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETBEZELFACE, 0, 0);
171 int wxGauge::GetRange() const
173 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETRANGE, 0, 0);
177 int wxGauge::GetValue() const
179 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETPOSITION, 0, 0);
183 bool wxGauge::SetForegroundColour(const wxColour
& col
)
185 if ( !wxControl::SetForegroundColour(col
) )
188 // TODO ::SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
193 bool wxGauge::SetBackgroundColour(const wxColour
& col
)
195 if ( !wxControl::SetBackgroundColour(col
) )
198 // TODO ::SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
206 // * This module contains functions for creating nifty 3D borders
207 // * around controls like zYzGauge.
210 // * 3/14/91 cjp put in this comment
211 // * 6/19/92 cjp touched it a bit
216 // (C) Copyright Microsoft Corp. 1992. All rights reserved.
218 // You have a royalty-free right to use, modify, reproduce and
219 // distribute the Sample Files (and/or any modified version) in
220 // any way you find useful, provided that you agree that
221 // Microsoft has no warranty obligations or liability for any
222 // Sample Application Files which are modified.
226 ///* get the includes we need */
230 ///* misc. control flag defines */
231 //#define DRAW3D_IN 0x0001
232 //#define DRAW3D_OUT 0x0002
234 //#define DRAW3D_TOPLINE 0x0004
235 //#define DRAW3D_BOTTOMLINE 0x0008
236 //#define DRAW3D_LEFTLINE 0x0010
237 //#define DRAW3D_RIGHTLINE 0x0020
240 ///* public function prototypes */
241 //void _Optlink Draw3DFaceFrame(HDC, LPRECT, WORD);
242 //void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD);
243 //void _Optlink Draw3DLine(HDC, WORD, WORD, WORD, WORD, WORD);
246 ///** void _Optlink Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth)
249 // * This function draws a flat frame with the current button-face
253 // * HDC hdc : The DC to draw into.
255 // * LPRECT rc : The containing rect for the new frame.
257 // * WORD wWidth : The width of the frame to draw.
259 // * RETURN (void _Optlink):
260 // * The frame will have been drawn into the DC.
266 //void _Optlink Draw3DFaceFrame(HDC hdc, RECTL* rc, WORD wWidth)
271 // /* don't go through a bunch of work if we don't have to */
275 // /* set up color to be button-face color--so it may not be gray */
276 // rgbOld = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
278 // /* perform CopyRect w/o bloody windows style overhead */
282 // rc1.top = rc->top;
283 // rc1.left = rc->left;
284 // rc1.bottom = rc->top + wWidth;
285 // rc1.right = rc->right;
288 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
291 // rc1.left = rc->right - wWidth;
292 // rc1.bottom = rc->bottom;
294 /* blast this part now */
295 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
298 // rc1.left = rc->left;
299 // rc1.right = rc->left + wWidth;
301 /* and another part */
302 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
305 // rc1.right = rc->right;
306 // rc1.top = rc->bottom - wWidth;
309 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
311 /* restore the old bk color */
312 // SetBkColor(hdc, rgbOld);
313 //} /* Draw3DFaceFrame() */
316 ///** void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD)
319 // * Draws a 3D rectangle that is shaded. wFlags can be used to
320 // * control how the rectangle looks.
323 // * HDC hdc : Handle to the device context that will be
324 // * used to display the rectangle.
326 // * RECT rect : A rectangle describing the dimensions of
327 // * the rectangle in device coordinates.
329 // * WORD wShadowWidth : Width of the shadow in device coordinates.
331 // * WORD wFlags : The following flags may be passed to describe
332 // * the style of the rectangle:
334 // * DRAW3D_IN : The shadow is drawn such that
335 // * the box appears to be sunk in to the screen.
336 // * This is default if 0 is passed.
338 // * DRAW3D_OUT : The shadow is drawn such that
339 // * the box appears to be sticking out of the
342 // * RETURN (void _Optlink):
343 // * The 3D looking rectangle will have been drawn into the DC.
349 //void _Optlink Draw3DRect(HDC hdc, LPRECT lpRect,
350 // WORD wShadowWidth, WORD wFlags)
352 // /* sanity check--don't work if you don't have to! */
353 // if (!wShadowWidth || !RectVisible(hdc, lpRect))
356 /* draw the top line */
357 // Draw3DLine(hdc, lpRect->left, lpRect->top,
358 // lpRect->right - lpRect->left,
359 // wShadowWidth, DRAW3D_TOPLINE | wFlags);
362 // Draw3DLine(hdc, lpRect->right, lpRect->top,
363 // lpRect->bottom - lpRect->top,
364 // wShadowWidth, DRAW3D_RIGHTLINE | wFlags);
367 // Draw3DLine(hdc, lpRect->left, lpRect->bottom,
368 // lpRect->right - lpRect->left,
369 // wShadowWidth, DRAW3D_BOTTOMLINE | wFlags);
372 // Draw3DLine(hdc, lpRect->left, lpRect->top,
373 // lpRect->bottom - lpRect->top,
374 // wShadowWidth, DRAW3D_LEFTLINE | wFlags);
375 //} /* Draw3DRect() */
378 ///** void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
381 // * Draws a 3D line that can be used to make a 3D box.
384 // * HDC hdc : Handle to the device context that will be
385 // * used to display the 3D line.
387 // * WORD x, y : Coordinates of the beginning of the line.
388 // * These coordinates are in device units and
389 // * represent the _outside_ most point. Horiz-
390 // * ontal lines are drawn from left to right and
391 // * vertical lines are drawn from top to bottom.
393 // * WORD wShadowWidth : Width of the shadow in device coordinates.
395 // * WORD wFlags : The following flags may be passed to
396 // * describe the style of the 3D line:
398 // * DRAW3D_IN : The shadow is drawn such that
399 // * the box appears to be sunk in to the screen.
400 // * This is default if 0 is passed.
402 // * DRAW3D_OUT : The shadow is drawn such that
403 // * the box appears to be sticking out of the
406 // * DRAW3D_TOPLINE, _BOTTOMLINE, _LEFTLINE, and
407 // * _RIGHTLINE : Specifies that a "top",
408 // * "Bottom", "Left", or"Right" line is to be
411 // * RETURN (void _Optlink):
412 // * The line will have been drawn into the DC.
418 //void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
419 // WORD wShadowWidth, WORD wFlags)
424 // POINT Point[ 4 ]; /* define a polgon with 4 points */
426 // /* if width is zero, don't do nothin'! */
427 // if (!wShadowWidth)
430 /* define shape of polygon--origin is always the same */
434 // /* To do this we'll simply draw a polygon with four sides, using
435 // * the appropriate brush. I dare you to ask me why this isn't a
438 // if (wFlags & DRAW3D_TOPLINE)
440 // /* across to right */
441 // Point[1].x = x + nLen - (wShadowWidth == 1 ? 1 : 0);
445 // Point[2].x = x + nLen - wShadowWidth;
446 // Point[2].y = y + wShadowWidth;
448 /* accross to left */
449 // Point[3].x = x + wShadowWidth;
450 // Point[3].y = y + wShadowWidth;
452 /* select 'dark' brush if 'in'--'light' for 'out' */
453 // fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
456 /* possibly the bottom? */
457 // else if (wFlags & DRAW3D_BOTTOMLINE)
459 /* across to right */
460 // Point[1].x = x + nLen;
464 // Point[2].x = x + nLen - wShadowWidth;
465 // Point[2].y = y - wShadowWidth;
467 /* accross to left */
468 // Point[3].x = x + wShadowWidth;
469 // Point[3].y = y - wShadowWidth;
471 /* select 'light' brush if 'in' */
472 // fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
475 /* ok, it's gotta be left? */
476 // else if (wFlags & DRAW3D_LEFTLINE)
480 // Point[1].y = y + nLen - (wShadowWidth == 1 ? 1 : 0);
483 // Point[2].x = x + wShadowWidth;
484 // Point[2].y = y + nLen - wShadowWidth;
487 // Point[3].x = x + wShadowWidth;
488 // Point[3].y = y + wShadowWidth;
490 /* select 'dark' brush if 'in'--'light' for 'out' */
491 // fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
494 /* well maybe it's for the right side? */
495 // else if (wFlags & DRAW3D_RIGHTLINE)
499 // Point[1].y = y + nLen;
502 // Point[2].x = x - wShadowWidth;
503 // Point[2].y = y + nLen - wShadowWidth;
506 // Point[3].x = x - wShadowWidth;
507 // Point[3].y = y + wShadowWidth;
509 /* select 'light' brush if 'in' */
510 // fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
516 /* select NULL_PEN for no borders */
517 // hOldPen = (HPEN) SelectObject(hdc, GetStockObject(NULL_PEN));
519 /* select the appropriate color for the fill */
521 // hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(GRAY_BRUSH));
523 // hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(WHITE_BRUSH));
525 /* finally, draw the dern thing */
526 // Polygon(hdc, (LPPOINT)&Point, 4);
528 /* restore what we killed */
529 // SelectObject(hdc, hOldBrush);
530 // SelectObject(hdc, hOldPen);
531 //} /* Draw3DLine() */
538 // * Yet another 'Gas Gauge Custom Control.' This control gives you
539 // * a 'progress bar' class (named zYzGauge) for use in your applications.
540 // * You can set the range, position, font, color, orientation, and 3d
541 // * effect of the gauge by sending messages to the control.
543 // * Before you can use this control, you MUST first export the window
544 // * procedure for the control (or define it with the _export keyword):
546 // * EXPORTS gaugeWndProc
548 // * You then need initialize the class before you use it:
550 // * if (!gaugeInit(hInstance))
551 // * die a horrible death
553 // * you are good to go
555 // * The colors used by the control default to black and white if you
556 // * are running on a mono-display. They default to blue and white
557 // * if you are on a color display. You enable the 3D effect by setting
558 // * the ZYZGS_3D style flag in the styles field of the control (like
559 // * any other control).
561 // * To select your own colors, you can send the ZYZG_SETFGCOLOR and
562 // * ZYZG_SETBKCOLOR messages to set the foreground (percent done) and
563 // * background (percent not done) colors. The lParam is the RGB()
564 // * value--wParam is ignored.
566 // * In all of the following ZYZG_??? messages, the arguments are
567 // * WORDS. If you are setting parameters, the value is sent as
568 // * the wParam (lParam is ignored). If you are getting parameters,
569 // * the value is returned as a LONG and should be cast to a *signed*
572 // * To set the depth of the 3D effect (if enabled), you can send the
573 // * ZYZG_SETBEZELFACE and ZYZG_SETWIDTH3D messages. The bezel face
574 // * is the flat top on the 3D border--its color will be that of the
575 // * button-face. The 3D width is the width of the bezel itself; inside
576 // * and outside. The light color is white, the dark color is gray.
577 // * Both widths *can* be zero--both default to 2 which looks to me.
579 // * The range of the control can be set by sending the ZYZG_SETRANGE
580 // * message to the control. It can be any integer from 1 to 32767.
581 // * What this specifies is the number of pieces that create a whole.
582 // * The default is 100. You can get the current range setting by
583 // * sending the ZYZG_GETRANGE message to the control.
585 // * The position (number of pieces out of the whole have been used) is
586 // * set with the ZYZG_SETPOSITION message. It can be any integer from
587 // * 0 to the current range setting of the control--it will be clipped
588 // * if the position is out of bounds. The default position is 0. You
589 // * can get the current position at any time with the ZYZG_GETPOSITION
592 // * You can also set the range using a delta from the current range.
593 // * This is done by sending the ZYZG_SETDELTAPOS message with wParam
594 // * set to a _signed_ integer value within the range of the control.
596 // * The font used for the percentage text can be set using the standard
597 // * WM_SETFONT message. You can get the current font at any time with
598 // * the WM_GETFONT message.
600 // * The orientation can be left to right, right to left, bottom to top,
601 // * or top to bottom. Whatever suits your needs. You set this by
602 // * sending the ZYZG_ORIENTATION message to the control with one of
603 // * the following values (default is ZYZG_ORIENT_LEFTTORIGHT):
605 // * ZYZG_ORIENT_LEFTTORIGHT (0)
606 // * ZYZG_ORIENT_RIGHTTOLEFT (1)
607 // * ZYZG_ORIENT_BOTTOMTOTOP (2)
608 // * ZYZG_ORIENT_TOPTOBOTTOM (3)
611 // * 3/12/91 cjp put in this comment
612 // * 6/19/92 cjp touched it a bit
617 // (C) Copyright Microsoft Corp. 1992. All rights reserved.
619 // You have a royalty-free right to use, modify, reproduce and
620 // distribute the Sample Files (and/or any modified version) in
621 // any way you find useful, provided that you agree that
622 // Microsoft has no warranty obligations or liability for any
623 // Sample Application Files which are modified.
627 /* get the includes we need */
628 //#if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
629 //#include <malloc.h>
632 //#include <string.h>
633 //#include <stdlib.h>
634 // #include "zyz3d.h"
635 // #include "zyzgauge.h"
638 /* static global variables */
639 //static wxChar gszzYzGaugeClass[] = wxT("zYzGauge");
642 /* window word position definitions */
643 //#define ZYZG_WW_PZYZGAUGE 0
644 /* #define ZYZG_WW_EXTRABYTES 2 */
645 //#define ZYZG_WW_EXTRABYTES 4
648 /* control block structure typedef */
649 //typedef struct tZYZGAUGE
653 // WORD wOrientation;
655 // WORD wWidthBezelFace;
657 // DWORD rgbTextColor;
660 //} ZYZGAUGE, *PZYZGAUGE, FAR *LPZYZGAUGE;
663 /* some default values for the control */
664 //#define ZYZG_DEF_RANGE 100
665 //#define ZYZG_DEF_POSITION 0
666 //#define ZYZG_DEF_ORIENTATION ZYZG_ORIENT_LEFTTORIGHT
667 //#define ZYZG_DEF_WIDTH3D 2
668 //#define ZYZG_DEF_BEZELFACE 2
672 /* the default settings for drawing colors--display dependent */
673 //static DWORD rgbDefTextColor;
674 //static DWORD rgbDefBkColor;
675 //static BOOL fSupport3D;
677 //#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
678 //#define APIENTRY _Optlink
682 //#define _EXPORT /**/
684 //#define _EXPORT _export
685 //typedef signed short int SHORT ;
688 /* internal function prototypes */
689 //static void PASCAL gaugePaint(HWND, HDC);
690 /* LRESULT _Optlink */
691 //LRESULT APIENTRY _EXPORT gaugeWndProc(HWND, UINT, WPARAM, LPARAM);
695 ///** BOOL _Optlink gaugeInit(HINSTANCE hInstance)
698 // * Registers the window class for the zYzGauge control. Performs
699 // * other initialization for the zYzGauge text control. This must
700 // * be done before the zYzGauge control is used--or it will fail
701 // * and your dialog box will not open!
704 // * HINSTANCE hInstance : Instance handle to register class with.
706 // * RETURN (BOOL FAR):
707 // * The return value is TRUE if the zYzGauge class was successfully
708 // * registered. It is FALSE if the initialization fails.
714 //#pragma alloc_text(init, gaugeInit)
716 //BOOL _Optlink gaugeInit(HINSTANCE hInstance)
718 // static BOOL fRegistered = FALSE;
722 /* assume already registered if not first instance */
726 /* fill in the class structure for the zyzgauge control */
727 // wc.hCursor = LoadCursor(NULL, IDC_ARROW);
729 // wc.lpszMenuName = NULL;
730 // wc.lpszClassName = gszzYzGaugeClass;
731 // wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
732 // wc.hInstance = hInstance;
734 //#ifdef ZYZGAUGE_DLL
735 // wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
737 // wc.style = CS_HREDRAW | CS_VREDRAW;
740 // wc.lpfnWndProc = gaugeWndProc;
741 // wc.cbClsExtra = 0;
742 // wc.cbWndExtra = ZYZG_WW_EXTRABYTES;
744 /* attempt to register it--return FALSE if fail */
745 // if (!RegisterClass(&wc))
748 /* Get a DC to determine whether device is mono or not, and set
749 * default foreground/background colors as appropriate.
751 // hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0L) ;
754 /* check for mono-display */
755 // if ((GetDeviceCaps(hdc, BITSPIXEL) == 1) &&
756 // (GetDeviceCaps(hdc, PLANES) == 1))
758 /* using a mono DC--white foreground, black background */
759 // rgbDefTextColor = RGB(255, 255, 255);
760 // rgbDefBkColor = RGB(0, 0, 0);
763 /* good! we have color: blue foreground, white background */
766 // rgbDefTextColor = RGB(0, 0, 255);
767 // rgbDefBkColor = RGB(255, 255, 255);
770 /* need at _least_ 8 for two shades of gray (>=VGA) */
771 // fSupport3D = (GetDeviceCaps(hdc, NUMCOLORS) >= 8) ? TRUE : FALSE;
773 /* get rid of the DC (IC) */
777 /* uh-oh... can't get DC (IC)... fail */
780 /* unregister the class */
781 // UnregisterClass(gszzYzGaugeClass, hInstance);
786 // return (fRegistered = TRUE);
787 //} /* gaugeInit() */
790 /** static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
793 // * This function is responsible for painting the zYzGauge control.
796 // * HWND hwnd : The window handle for the gauge.
798 // * HDC hdc : The DC for the gauge's window.
801 // * The control will have been painted.
807 //static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
810 // WORD iRange, iPos;
816 // WORD dx, dy, wGomerX, wGomerY;
817 ///* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead,
818 // * which needs a SIZE* parameter */
819 //#if defined(__WIN32__)
823 // /* get pointer to the control's control block */
824 // pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
825 // pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
827 /* set the colors into for the gauge into the control */
828 // SetTextColor(hdc, pgauge->rgbTextColor);
829 // SetBkColor(hdc, pgauge->rgbBkColor);
831 /* draw black rectangle for gauge */
832 // GetClientRect(hwnd, &rc1);
834 /* draw a black border on the _outside_ */
835 // FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH));
837 /* we want to draw _just inside_ the black border */
838 // InflateRect(&rc1, -1, -1);
840 /* one line thick so far... */
841 // Offset = (WORD) 1;
843 /* for 3D stuff, we need to have at least two shades of gray */
844 // if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
846 // Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_OUT);
847 // InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
849 // Draw3DFaceFrame(hdc, &rc1, pgauge->wWidthBezelFace);
850 // InflateRect(&rc1, ~(pgauge->wWidthBezelFace), ~(pgauge->wWidthBezelFace));
852 // Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_IN);
853 // InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
855 /* draw a black border on the _inside_ */
856 // FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH));
858 /* we want to draw _just inside_ the black border */
859 // InflateRect(&rc1, -1, -1);
861 /* add all the other pixels into the border width */
862 // Offset += (2 * pgauge->wWidth3D) + pgauge->wWidthBezelFace + 1;
865 /* dup--one rc for 'how much filled', one rc for 'how much empty' */
868 /* get the range--make sure it's a valid range */
869 // if ((iRange = pgauge->wRange) <= 0)
872 /* get the position--greater than 100% would be bad */
873 // if ((iPos = pgauge->wPosition) > iRange)
876 /* compute the actual size of the gauge */
877 // dx = rc1.right - rc1.left;
878 // dy = rc1.bottom - rc1.top;
879 // wGomerX = (WORD)((DWORD)iPos * dx / iRange);
880 // wGomerY = (WORD)((DWORD)iPos * dy / iRange);
882 /* get the orientation and munge rects accordingly */
883 // switch (pgauge->wOrientation)
885 // case ZYZG_ORIENT_RIGHTTOLEFT:
886 // rc1.left = rc2.right = rc1.right - wGomerX;
889 // case ZYZG_ORIENT_BOTTOMTOTOP:
890 // rc1.top = rc2.bottom = rc1.bottom - wGomerY;
893 // case ZYZG_ORIENT_TOPTOBOTTOM:
894 // rc1.bottom = rc2.top += wGomerY;
898 // rc1.right = rc2.left += wGomerX;
902 /* select the correct font */
903 // hFont = (HFONT) SelectObject(hdc, pgauge->hFont);
905 /* build up a string to blit out--ie the meaning of life: "42%" */
906 // wsprintf(ach, wxT("%3d%%"), (WORD)((DWORD)iPos * 100 / iRange));
907 /* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead */
908 //#if defined(__WIN32__)
909 // GetTextExtentPoint(hdc, ach, wGomerX = lstrlen(ach), &size);
910 // dwExtent = size.cx;
912 // dwExtent = GetTextExtent(hdc, ach, wGomerX = lstrlen(ach));
916 /* Draw the finished (ie the percent done) side of box. If
917 * ZYZG_WW_POSITION is 42, (in range of 0 to 100) this ExtTextOut
918 * draws the meaning of life (42%) bar.
920 // ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
921 // (dy - HIWORD(dwExtent)) / 2 + Offset,
922 // ETO_OPAQUE | ETO_CLIPPED, &rc2, ach, wGomerX, NULL);
924 /* Reverse fore and back colors for drawing the undone (ie the non-
925 * finished) side of the box.
927 // SetBkColor(hdc, pgauge->rgbTextColor);
928 // SetTextColor(hdc, pgauge->rgbBkColor);
930 // ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
931 // (dy - HIWORD(dwExtent)) / 2 + Offset,
932 // ETO_OPAQUE | ETO_CLIPPED, &rc1, ach, wGomerX, NULL);
934 /* unselect the font */
935 // SelectObject(hdc, hFont);
936 //} /* gaugePaint() */
939 /** LRESULT _Optlink gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
942 // * This is the control's window procedure. Its purpose is to handle
943 // * special messages for this custom control.
945 // * The special control messages for the gauge control are:
947 // * ZYZG_SETRANGE : Sets the range of the gauge. In other
948 // * words, the number of parts that make a
951 // * ZYZG_GETRANGE : Returns the current range of the gauge.
953 // * ZYZG_SETORIENTATION : Sets the orientation of the gauge. This
954 // * can be one of the ZYZG_ORIENT_?? msgs.
956 // * ZYZG_GETORIENTATION : Gets the current orientation of the
959 // * ZYZG_SETPOSITION : Sets the current position of the gauge.
960 // * In other words, how many pieces of the
961 // * whole have been used.
963 // * ZYZG_GETPOSITION : Gets the current position of the gauge.
965 // * ZYZG_SETDELTAPOS : Sets the position of the gauge +/- the
966 // * specified amount.
968 // * ZYZG_SETFGCOLOR : Sets the foreground (percent done) color.
970 // * ZYZG_GETFGCOLOR : Gets the foreground (percent done) color.
972 // * ZYZG_SETBKCOLOR : Sets the background (percent not done)
975 // * ZYZG_GETBKCOLOR : Gets the background (percent not done)
978 // * WM_SETFONT : Sets the font to use for the percentage
979 // * text of the gauge.
981 // * WM_GETFONT : Gets the current font in use by the
988 /* LRESULT _Optlink */
990 //LRESULT APIENTRY _EXPORT gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
997 // pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
998 // pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
1000 /* break to get DefWindowProc() */
1004 /* need to allocate a control block */
1005 // pgauge = (PZYZGAUGE)LocalAlloc(LPTR, sizeof(ZYZGAUGE));
1006 // pgauge = (PZYZGAUGE)malloc(sizeof(ZYZGAUGE));
1010 /* hang on to this control block */
1011 // SetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE, (WORD)pgauge);
1012 // SetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE, (LONG)pgauge);
1014 /* fill control block with defaults */
1015 // pgauge->wRange = ZYZG_DEF_RANGE;
1016 // pgauge->wPosition = ZYZG_DEF_POSITION;
1017 // pgauge->wOrientation = ZYZG_DEF_ORIENTATION;
1018 // pgauge->wWidth3D = ZYZG_DEF_WIDTH3D;
1019 // pgauge->wWidthBezelFace = ZYZG_DEF_BEZELFACE;
1020 // pgauge->rgbTextColor = rgbDefTextColor;
1021 // pgauge->rgbBkColor = rgbDefBkColor;
1023 /* use system font */
1024 // SendMessage(hwnd, WM_SETFONT, (WPARAM)NULL, 0L);
1026 /* go to DefWindowProc() to finish the job */
1030 /* get rid of the control's memory */
1032 // LocalFree((HANDLE)pgauge);
1036 // case ZYZG_GETPOSITION:
1037 // return (pgauge->wPosition);
1039 // case ZYZG_GETRANGE:
1040 // return (pgauge->wRange);
1042 // case ZYZG_GETORIENTATION:
1043 // return (pgauge->wOrientation);
1045 // case ZYZG_GETWIDTH3D:
1046 // return (pgauge->wWidth3D);
1048 // case ZYZG_GETBEZELFACE:
1049 // return (pgauge->wWidthBezelFace);
1051 // case ZYZG_GETBKCOLOR:
1052 // return (pgauge->rgbTextColor);
1054 // case ZYZG_GETFGCOLOR:
1055 // return (pgauge->rgbBkColor);
1057 // case ZYZG_SETBKCOLOR:
1058 // pgauge->rgbBkColor = lParam;
1061 // case ZYZG_SETFGCOLOR:
1062 // pgauge->rgbTextColor = lParam;
1066 // case ZYZG_SETPOSITION:
1067 // pgauge->wPosition = wParam;
1070 // GetClientRect(hwnd, &rc);
1071 // if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
1073 // wParam = (2 * pgauge->wWidth3D) +
1074 // pgauge->wWidthBezelFace + 2;
1080 // InflateRect(&rc, ~(wParam), ~(wParam));
1081 // InvalidateRect(hwnd, &rc, FALSE);
1082 // UpdateWindow(hwnd);
1085 // case ZYZG_SETRANGE:
1086 // pgauge->wRange = wParam;
1087 // goto zyzgForceRepaint;
1089 // case ZYZG_SETORIENTATION:
1090 // pgauge->wOrientation = wParam;
1091 // goto zyzgForceRepaint;
1093 // case ZYZG_SETWIDTH3D:
1094 // pgauge->wWidth3D = wParam;
1096 //zyzgForceRepaint3D:
1097 // InvalidateRect(hwnd, NULL, FALSE);
1098 // UpdateWindow(hwnd);
1101 // case ZYZG_SETBEZELFACE:
1102 // pgauge->wWidthBezelFace = wParam;
1103 // goto zyzgForceRepaint3D;
1105 // case ZYZG_SETDELTAPOS:
1106 ///* Watcom doesn't like the following line so removing typecasts */
1107 ///* (int)pgauge->wPosition += (int)wParam; */
1108 // pgauge->wPosition += wParam;
1109 // goto zyzgForceRepaint;
1112 // BeginPaint(hwnd, &ps);
1113 // gaugePaint(hwnd, ps.hdc);
1114 // EndPaint(hwnd, &ps);
1118 // hFont = pgauge->hFont;
1120 // /* if system font, then return NULL handle */
1121 // return (long)((hFont == GetStockObject(SYSTEM_FONT)) ? NULL : hFont);
1124 /* if NULL hFont, use system font */
1125 // hFont = (HFONT)wParam ;
1127 // hFont = (HFONT) GetStockObject(SYSTEM_FONT);
1129 // pgauge->hFont = hFont;
1131 /* redraw if indicated in message */
1132 // if ((BOOL)lParam)
1134 // InvalidateRect(hwnd, NULL, TRUE);
1135 // UpdateWindow(hwnd);
1138 // } /* switch () */
1140 /* let the dialog mangler take care of this message */
1141 // return (DefWindowProc(hwnd, uMsg, wParam, lParam));
1142 //} /* gaugeWndProc() */
1145 /** EOF: zyzgauge.c **/