]>
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 #if !USE_SHARED_LIBRARY
52 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
)
55 bool wxGauge::Create(wxWindow
*parent
, wxWindowID id
,
60 const wxValidator
& validator
,
63 static bool wxGaugeOS2Initialised
= FALSE
;
65 if ( !wxGaugeOS2Initialised
)
67 if (!gaugeInit((HINSTANCE
) wxGetInstance()))
68 wxFatalError("Cannot initalize Gauge library");
69 wxGaugeOS2Initialised
= TRUE
;
73 SetValidator(validator
);
74 if (parent
) parent
->AddChild(this);
78 m_windowStyle
= style
;
81 m_windowId
= (int)NewControlId();
97 long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
101 CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("zYzGauge"), NULL, msFlags,
102 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
103 wxGetInstance(), NULL);
105 m_hWnd = (WXHWND)wx_button;
107 // Subclass again for purposes of dialog editing mode
108 SubclassWin((WXHWND)wx_button);
112 if (m_windowStyle & wxGA_HORIZONTAL)
113 wOrient = ZYZG_ORIENT_LEFTTORIGHT;
115 wOrient = ZYZG_ORIENT_BOTTOMTOTOP;
117 SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0);
118 SendMessage(wx_button, ZYZG_SETRANGE, range, 0);
120 SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
121 SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
123 SetFont(parent->GetFont());
129 SetSize(x, y, width, height);
131 ShowWindow(GetHwnd(), SW_SHOW);
136 void wxGauge::SetShadowWidth(int w
)
138 // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETWIDTH3D, w, 0);
141 void wxGauge::SetBezelFace(int w
)
143 // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETBEZELFACE, w, 0);
146 void wxGauge::SetRange(int r
)
149 // TODO ::SendMessage(GetHwnd(), ZYZG_SETRANGE, r, 0);
152 void wxGauge::SetValue(int pos
)
155 // TODO ::SendMessage(GetHwnd(), ZYZG_SETPOSITION, pos, 0);
158 int wxGauge::GetShadowWidth() const
160 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETWIDTH3D, 0, 0);
164 int wxGauge::GetBezelFace() const
166 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETBEZELFACE, 0, 0);
170 int wxGauge::GetRange() const
172 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETRANGE, 0, 0);
176 int wxGauge::GetValue() const
178 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETPOSITION, 0, 0);
182 bool wxGauge::SetForegroundColour(const wxColour
& col
)
184 if ( !wxControl::SetForegroundColour(col
) )
187 // TODO ::SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
192 bool wxGauge::SetBackgroundColour(const wxColour
& col
)
194 if ( !wxControl::SetBackgroundColour(col
) )
197 // TODO ::SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
205 // * This module contains functions for creating nifty 3D borders
206 // * around controls like zYzGauge.
209 // * 3/14/91 cjp put in this comment
210 // * 6/19/92 cjp touched it a bit
215 // (C) Copyright Microsoft Corp. 1992. All rights reserved.
217 // You have a royalty-free right to use, modify, reproduce and
218 // distribute the Sample Files (and/or any modified version) in
219 // any way you find useful, provided that you agree that
220 // Microsoft has no warranty obligations or liability for any
221 // Sample Application Files which are modified.
225 ///* get the includes we need */
229 ///* misc. control flag defines */
230 //#define DRAW3D_IN 0x0001
231 //#define DRAW3D_OUT 0x0002
233 //#define DRAW3D_TOPLINE 0x0004
234 //#define DRAW3D_BOTTOMLINE 0x0008
235 //#define DRAW3D_LEFTLINE 0x0010
236 //#define DRAW3D_RIGHTLINE 0x0020
239 ///* public function prototypes */
240 //void _Optlink Draw3DFaceFrame(HDC, LPRECT, WORD);
241 //void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD);
242 //void _Optlink Draw3DLine(HDC, WORD, WORD, WORD, WORD, WORD);
245 ///** void _Optlink Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth)
248 // * This function draws a flat frame with the current button-face
252 // * HDC hdc : The DC to draw into.
254 // * LPRECT rc : The containing rect for the new frame.
256 // * WORD wWidth : The width of the frame to draw.
258 // * RETURN (void _Optlink):
259 // * The frame will have been drawn into the DC.
265 //void _Optlink Draw3DFaceFrame(HDC hdc, RECTL* rc, WORD wWidth)
270 // /* don't go through a bunch of work if we don't have to */
274 // /* set up color to be button-face color--so it may not be gray */
275 // rgbOld = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
277 // /* perform CopyRect w/o bloody windows style overhead */
281 // rc1.top = rc->top;
282 // rc1.left = rc->left;
283 // rc1.bottom = rc->top + wWidth;
284 // rc1.right = rc->right;
287 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
290 // rc1.left = rc->right - wWidth;
291 // rc1.bottom = rc->bottom;
293 /* blast this part now */
294 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
297 // rc1.left = rc->left;
298 // rc1.right = rc->left + wWidth;
300 /* and another part */
301 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
304 // rc1.right = rc->right;
305 // rc1.top = rc->bottom - wWidth;
308 // ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
310 /* restore the old bk color */
311 // SetBkColor(hdc, rgbOld);
312 //} /* Draw3DFaceFrame() */
315 ///** void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD)
318 // * Draws a 3D rectangle that is shaded. wFlags can be used to
319 // * control how the rectangle looks.
322 // * HDC hdc : Handle to the device context that will be
323 // * used to display the rectangle.
325 // * RECT rect : A rectangle describing the dimensions of
326 // * the rectangle in device coordinates.
328 // * WORD wShadowWidth : Width of the shadow in device coordinates.
330 // * WORD wFlags : The following flags may be passed to describe
331 // * the style of the rectangle:
333 // * DRAW3D_IN : The shadow is drawn such that
334 // * the box appears to be sunk in to the screen.
335 // * This is default if 0 is passed.
337 // * DRAW3D_OUT : The shadow is drawn such that
338 // * the box appears to be sticking out of the
341 // * RETURN (void _Optlink):
342 // * The 3D looking rectangle will have been drawn into the DC.
348 //void _Optlink Draw3DRect(HDC hdc, LPRECT lpRect,
349 // WORD wShadowWidth, WORD wFlags)
351 // /* sanity check--don't work if you don't have to! */
352 // if (!wShadowWidth || !RectVisible(hdc, lpRect))
355 /* draw the top line */
356 // Draw3DLine(hdc, lpRect->left, lpRect->top,
357 // lpRect->right - lpRect->left,
358 // wShadowWidth, DRAW3D_TOPLINE | wFlags);
361 // Draw3DLine(hdc, lpRect->right, lpRect->top,
362 // lpRect->bottom - lpRect->top,
363 // wShadowWidth, DRAW3D_RIGHTLINE | wFlags);
366 // Draw3DLine(hdc, lpRect->left, lpRect->bottom,
367 // lpRect->right - lpRect->left,
368 // wShadowWidth, DRAW3D_BOTTOMLINE | wFlags);
371 // Draw3DLine(hdc, lpRect->left, lpRect->top,
372 // lpRect->bottom - lpRect->top,
373 // wShadowWidth, DRAW3D_LEFTLINE | wFlags);
374 //} /* Draw3DRect() */
377 ///** void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
380 // * Draws a 3D line that can be used to make a 3D box.
383 // * HDC hdc : Handle to the device context that will be
384 // * used to display the 3D line.
386 // * WORD x, y : Coordinates of the beginning of the line.
387 // * These coordinates are in device units and
388 // * represent the _outside_ most point. Horiz-
389 // * ontal lines are drawn from left to right and
390 // * vertical lines are drawn from top to bottom.
392 // * WORD wShadowWidth : Width of the shadow in device coordinates.
394 // * WORD wFlags : The following flags may be passed to
395 // * describe the style of the 3D line:
397 // * DRAW3D_IN : The shadow is drawn such that
398 // * the box appears to be sunk in to the screen.
399 // * This is default if 0 is passed.
401 // * DRAW3D_OUT : The shadow is drawn such that
402 // * the box appears to be sticking out of the
405 // * DRAW3D_TOPLINE, _BOTTOMLINE, _LEFTLINE, and
406 // * _RIGHTLINE : Specifies that a "top",
407 // * "Bottom", "Left", or"Right" line is to be
410 // * RETURN (void _Optlink):
411 // * The line will have been drawn into the DC.
417 //void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
418 // WORD wShadowWidth, WORD wFlags)
423 // POINT Point[ 4 ]; /* define a polgon with 4 points */
425 // /* if width is zero, don't do nothin'! */
426 // if (!wShadowWidth)
429 /* define shape of polygon--origin is always the same */
433 // /* To do this we'll simply draw a polygon with four sides, using
434 // * the appropriate brush. I dare you to ask me why this isn't a
437 // if (wFlags & DRAW3D_TOPLINE)
439 // /* across to right */
440 // Point[1].x = x + nLen - (wShadowWidth == 1 ? 1 : 0);
444 // Point[2].x = x + nLen - wShadowWidth;
445 // Point[2].y = y + wShadowWidth;
447 /* accross to left */
448 // Point[3].x = x + wShadowWidth;
449 // Point[3].y = y + wShadowWidth;
451 /* select 'dark' brush if 'in'--'light' for 'out' */
452 // fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
455 /* possibly the bottom? */
456 // else if (wFlags & DRAW3D_BOTTOMLINE)
458 /* across to right */
459 // Point[1].x = x + nLen;
463 // Point[2].x = x + nLen - wShadowWidth;
464 // Point[2].y = y - wShadowWidth;
466 /* accross to left */
467 // Point[3].x = x + wShadowWidth;
468 // Point[3].y = y - wShadowWidth;
470 /* select 'light' brush if 'in' */
471 // fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
474 /* ok, it's gotta be left? */
475 // else if (wFlags & DRAW3D_LEFTLINE)
479 // Point[1].y = y + nLen - (wShadowWidth == 1 ? 1 : 0);
482 // Point[2].x = x + wShadowWidth;
483 // Point[2].y = y + nLen - wShadowWidth;
486 // Point[3].x = x + wShadowWidth;
487 // Point[3].y = y + wShadowWidth;
489 /* select 'dark' brush if 'in'--'light' for 'out' */
490 // fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
493 /* well maybe it's for the right side? */
494 // else if (wFlags & DRAW3D_RIGHTLINE)
498 // Point[1].y = y + nLen;
501 // Point[2].x = x - wShadowWidth;
502 // Point[2].y = y + nLen - wShadowWidth;
505 // Point[3].x = x - wShadowWidth;
506 // Point[3].y = y + wShadowWidth;
508 /* select 'light' brush if 'in' */
509 // fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
515 /* select NULL_PEN for no borders */
516 // hOldPen = (HPEN) SelectObject(hdc, GetStockObject(NULL_PEN));
518 /* select the appropriate color for the fill */
520 // hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(GRAY_BRUSH));
522 // hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(WHITE_BRUSH));
524 /* finally, draw the dern thing */
525 // Polygon(hdc, (LPPOINT)&Point, 4);
527 /* restore what we killed */
528 // SelectObject(hdc, hOldBrush);
529 // SelectObject(hdc, hOldPen);
530 //} /* Draw3DLine() */
537 // * Yet another 'Gas Gauge Custom Control.' This control gives you
538 // * a 'progress bar' class (named zYzGauge) for use in your applications.
539 // * You can set the range, position, font, color, orientation, and 3d
540 // * effect of the gauge by sending messages to the control.
542 // * Before you can use this control, you MUST first export the window
543 // * procedure for the control (or define it with the _export keyword):
545 // * EXPORTS gaugeWndProc
547 // * You then need initialize the class before you use it:
549 // * if (!gaugeInit(hInstance))
550 // * die a horrible death
552 // * you are good to go
554 // * The colors used by the control default to black and white if you
555 // * are running on a mono-display. They default to blue and white
556 // * if you are on a color display. You enable the 3D effect by setting
557 // * the ZYZGS_3D style flag in the styles field of the control (like
558 // * any other control).
560 // * To select your own colors, you can send the ZYZG_SETFGCOLOR and
561 // * ZYZG_SETBKCOLOR messages to set the foreground (percent done) and
562 // * background (percent not done) colors. The lParam is the RGB()
563 // * value--wParam is ignored.
565 // * In all of the following ZYZG_??? messages, the arguments are
566 // * WORDS. If you are setting parameters, the value is sent as
567 // * the wParam (lParam is ignored). If you are getting parameters,
568 // * the value is returned as a LONG and should be cast to a *signed*
571 // * To set the depth of the 3D effect (if enabled), you can send the
572 // * ZYZG_SETBEZELFACE and ZYZG_SETWIDTH3D messages. The bezel face
573 // * is the flat top on the 3D border--its color will be that of the
574 // * button-face. The 3D width is the width of the bezel itself; inside
575 // * and outside. The light color is white, the dark color is gray.
576 // * Both widths *can* be zero--both default to 2 which looks to me.
578 // * The range of the control can be set by sending the ZYZG_SETRANGE
579 // * message to the control. It can be any integer from 1 to 32767.
580 // * What this specifies is the number of pieces that create a whole.
581 // * The default is 100. You can get the current range setting by
582 // * sending the ZYZG_GETRANGE message to the control.
584 // * The position (number of pieces out of the whole have been used) is
585 // * set with the ZYZG_SETPOSITION message. It can be any integer from
586 // * 0 to the current range setting of the control--it will be clipped
587 // * if the position is out of bounds. The default position is 0. You
588 // * can get the current position at any time with the ZYZG_GETPOSITION
591 // * You can also set the range using a delta from the current range.
592 // * This is done by sending the ZYZG_SETDELTAPOS message with wParam
593 // * set to a _signed_ integer value within the range of the control.
595 // * The font used for the percentage text can be set using the standard
596 // * WM_SETFONT message. You can get the current font at any time with
597 // * the WM_GETFONT message.
599 // * The orientation can be left to right, right to left, bottom to top,
600 // * or top to bottom. Whatever suits your needs. You set this by
601 // * sending the ZYZG_ORIENTATION message to the control with one of
602 // * the following values (default is ZYZG_ORIENT_LEFTTORIGHT):
604 // * ZYZG_ORIENT_LEFTTORIGHT (0)
605 // * ZYZG_ORIENT_RIGHTTOLEFT (1)
606 // * ZYZG_ORIENT_BOTTOMTOTOP (2)
607 // * ZYZG_ORIENT_TOPTOBOTTOM (3)
610 // * 3/12/91 cjp put in this comment
611 // * 6/19/92 cjp touched it a bit
616 // (C) Copyright Microsoft Corp. 1992. All rights reserved.
618 // You have a royalty-free right to use, modify, reproduce and
619 // distribute the Sample Files (and/or any modified version) in
620 // any way you find useful, provided that you agree that
621 // Microsoft has no warranty obligations or liability for any
622 // Sample Application Files which are modified.
626 /* get the includes we need */
627 //#if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
628 //#include <malloc.h>
631 //#include <string.h>
632 //#include <stdlib.h>
633 // #include "zyz3d.h"
634 // #include "zyzgauge.h"
637 /* static global variables */
638 //static wxChar gszzYzGaugeClass[] = wxT("zYzGauge");
641 /* window word position definitions */
642 //#define ZYZG_WW_PZYZGAUGE 0
643 /* #define ZYZG_WW_EXTRABYTES 2 */
644 //#define ZYZG_WW_EXTRABYTES 4
647 /* control block structure typedef */
648 //typedef struct tZYZGAUGE
652 // WORD wOrientation;
654 // WORD wWidthBezelFace;
656 // DWORD rgbTextColor;
659 //} ZYZGAUGE, *PZYZGAUGE, FAR *LPZYZGAUGE;
662 /* some default values for the control */
663 //#define ZYZG_DEF_RANGE 100
664 //#define ZYZG_DEF_POSITION 0
665 //#define ZYZG_DEF_ORIENTATION ZYZG_ORIENT_LEFTTORIGHT
666 //#define ZYZG_DEF_WIDTH3D 2
667 //#define ZYZG_DEF_BEZELFACE 2
671 /* the default settings for drawing colors--display dependent */
672 //static DWORD rgbDefTextColor;
673 //static DWORD rgbDefBkColor;
674 //static BOOL fSupport3D;
676 //#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
677 //#define APIENTRY _Optlink
681 //#define _EXPORT /**/
683 //#define _EXPORT _export
684 //typedef signed short int SHORT ;
687 /* internal function prototypes */
688 //static void PASCAL gaugePaint(HWND, HDC);
689 /* LRESULT _Optlink */
690 //LRESULT APIENTRY _EXPORT gaugeWndProc(HWND, UINT, WPARAM, LPARAM);
694 ///** BOOL _Optlink gaugeInit(HINSTANCE hInstance)
697 // * Registers the window class for the zYzGauge control. Performs
698 // * other initialization for the zYzGauge text control. This must
699 // * be done before the zYzGauge control is used--or it will fail
700 // * and your dialog box will not open!
703 // * HINSTANCE hInstance : Instance handle to register class with.
705 // * RETURN (BOOL FAR):
706 // * The return value is TRUE if the zYzGauge class was successfully
707 // * registered. It is FALSE if the initialization fails.
713 //#pragma alloc_text(init, gaugeInit)
715 //BOOL _Optlink gaugeInit(HINSTANCE hInstance)
717 // static BOOL fRegistered = FALSE;
721 /* assume already registered if not first instance */
725 /* fill in the class structure for the zyzgauge control */
726 // wc.hCursor = LoadCursor(NULL, IDC_ARROW);
728 // wc.lpszMenuName = NULL;
729 // wc.lpszClassName = gszzYzGaugeClass;
730 // wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
731 // wc.hInstance = hInstance;
733 //#ifdef ZYZGAUGE_DLL
734 // wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
736 // wc.style = CS_HREDRAW | CS_VREDRAW;
739 // wc.lpfnWndProc = gaugeWndProc;
740 // wc.cbClsExtra = 0;
741 // wc.cbWndExtra = ZYZG_WW_EXTRABYTES;
743 /* attempt to register it--return FALSE if fail */
744 // if (!RegisterClass(&wc))
747 /* Get a DC to determine whether device is mono or not, and set
748 * default foreground/background colors as appropriate.
750 // hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0L) ;
753 /* check for mono-display */
754 // if ((GetDeviceCaps(hdc, BITSPIXEL) == 1) &&
755 // (GetDeviceCaps(hdc, PLANES) == 1))
757 /* using a mono DC--white foreground, black background */
758 // rgbDefTextColor = RGB(255, 255, 255);
759 // rgbDefBkColor = RGB(0, 0, 0);
762 /* good! we have color: blue foreground, white background */
765 // rgbDefTextColor = RGB(0, 0, 255);
766 // rgbDefBkColor = RGB(255, 255, 255);
769 /* need at _least_ 8 for two shades of gray (>=VGA) */
770 // fSupport3D = (GetDeviceCaps(hdc, NUMCOLORS) >= 8) ? TRUE : FALSE;
772 /* get rid of the DC (IC) */
776 /* uh-oh... can't get DC (IC)... fail */
779 /* unregister the class */
780 // UnregisterClass(gszzYzGaugeClass, hInstance);
785 // return (fRegistered = TRUE);
786 //} /* gaugeInit() */
789 /** static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
792 // * This function is responsible for painting the zYzGauge control.
795 // * HWND hwnd : The window handle for the gauge.
797 // * HDC hdc : The DC for the gauge's window.
800 // * The control will have been painted.
806 //static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
809 // WORD iRange, iPos;
815 // WORD dx, dy, wGomerX, wGomerY;
816 ///* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead,
817 // * which needs a SIZE* parameter */
818 //#if defined(__WIN32__)
822 // /* get pointer to the control's control block */
823 // pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
824 // pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
826 /* set the colors into for the gauge into the control */
827 // SetTextColor(hdc, pgauge->rgbTextColor);
828 // SetBkColor(hdc, pgauge->rgbBkColor);
830 /* draw black rectangle for gauge */
831 // GetClientRect(hwnd, &rc1);
833 /* draw a black border on the _outside_ */
834 // FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH));
836 /* we want to draw _just inside_ the black border */
837 // InflateRect(&rc1, -1, -1);
839 /* one line thick so far... */
840 // Offset = (WORD) 1;
842 /* for 3D stuff, we need to have at least two shades of gray */
843 // if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
845 // Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_OUT);
846 // InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
848 // Draw3DFaceFrame(hdc, &rc1, pgauge->wWidthBezelFace);
849 // InflateRect(&rc1, ~(pgauge->wWidthBezelFace), ~(pgauge->wWidthBezelFace));
851 // Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_IN);
852 // InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
854 /* draw a black border on the _inside_ */
855 // FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH));
857 /* we want to draw _just inside_ the black border */
858 // InflateRect(&rc1, -1, -1);
860 /* add all the other pixels into the border width */
861 // Offset += (2 * pgauge->wWidth3D) + pgauge->wWidthBezelFace + 1;
864 /* dup--one rc for 'how much filled', one rc for 'how much empty' */
867 /* get the range--make sure it's a valid range */
868 // if ((iRange = pgauge->wRange) <= 0)
871 /* get the position--greater than 100% would be bad */
872 // if ((iPos = pgauge->wPosition) > iRange)
875 /* compute the actual size of the gauge */
876 // dx = rc1.right - rc1.left;
877 // dy = rc1.bottom - rc1.top;
878 // wGomerX = (WORD)((DWORD)iPos * dx / iRange);
879 // wGomerY = (WORD)((DWORD)iPos * dy / iRange);
881 /* get the orientation and munge rects accordingly */
882 // switch (pgauge->wOrientation)
884 // case ZYZG_ORIENT_RIGHTTOLEFT:
885 // rc1.left = rc2.right = rc1.right - wGomerX;
888 // case ZYZG_ORIENT_BOTTOMTOTOP:
889 // rc1.top = rc2.bottom = rc1.bottom - wGomerY;
892 // case ZYZG_ORIENT_TOPTOBOTTOM:
893 // rc1.bottom = rc2.top += wGomerY;
897 // rc1.right = rc2.left += wGomerX;
901 /* select the correct font */
902 // hFont = (HFONT) SelectObject(hdc, pgauge->hFont);
904 /* build up a string to blit out--ie the meaning of life: "42%" */
905 // wsprintf(ach, wxT("%3d%%"), (WORD)((DWORD)iPos * 100 / iRange));
906 /* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead */
907 //#if defined(__WIN32__)
908 // GetTextExtentPoint(hdc, ach, wGomerX = lstrlen(ach), &size);
909 // dwExtent = size.cx;
911 // dwExtent = GetTextExtent(hdc, ach, wGomerX = lstrlen(ach));
915 /* Draw the finished (ie the percent done) side of box. If
916 * ZYZG_WW_POSITION is 42, (in range of 0 to 100) this ExtTextOut
917 * draws the meaning of life (42%) bar.
919 // ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
920 // (dy - HIWORD(dwExtent)) / 2 + Offset,
921 // ETO_OPAQUE | ETO_CLIPPED, &rc2, ach, wGomerX, NULL);
923 /* Reverse fore and back colors for drawing the undone (ie the non-
924 * finished) side of the box.
926 // SetBkColor(hdc, pgauge->rgbTextColor);
927 // SetTextColor(hdc, pgauge->rgbBkColor);
929 // ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
930 // (dy - HIWORD(dwExtent)) / 2 + Offset,
931 // ETO_OPAQUE | ETO_CLIPPED, &rc1, ach, wGomerX, NULL);
933 /* unselect the font */
934 // SelectObject(hdc, hFont);
935 //} /* gaugePaint() */
938 /** LRESULT _Optlink gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
941 // * This is the control's window procedure. Its purpose is to handle
942 // * special messages for this custom control.
944 // * The special control messages for the gauge control are:
946 // * ZYZG_SETRANGE : Sets the range of the gauge. In other
947 // * words, the number of parts that make a
950 // * ZYZG_GETRANGE : Returns the current range of the gauge.
952 // * ZYZG_SETORIENTATION : Sets the orientation of the gauge. This
953 // * can be one of the ZYZG_ORIENT_?? msgs.
955 // * ZYZG_GETORIENTATION : Gets the current orientation of the
958 // * ZYZG_SETPOSITION : Sets the current position of the gauge.
959 // * In other words, how many pieces of the
960 // * whole have been used.
962 // * ZYZG_GETPOSITION : Gets the current position of the gauge.
964 // * ZYZG_SETDELTAPOS : Sets the position of the gauge +/- the
965 // * specified amount.
967 // * ZYZG_SETFGCOLOR : Sets the foreground (percent done) color.
969 // * ZYZG_GETFGCOLOR : Gets the foreground (percent done) color.
971 // * ZYZG_SETBKCOLOR : Sets the background (percent not done)
974 // * ZYZG_GETBKCOLOR : Gets the background (percent not done)
977 // * WM_SETFONT : Sets the font to use for the percentage
978 // * text of the gauge.
980 // * WM_GETFONT : Gets the current font in use by the
987 /* LRESULT _Optlink */
989 //LRESULT APIENTRY _EXPORT gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
996 // pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
997 // pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
999 /* break to get DefWindowProc() */
1003 /* need to allocate a control block */
1004 // pgauge = (PZYZGAUGE)LocalAlloc(LPTR, sizeof(ZYZGAUGE));
1005 // pgauge = (PZYZGAUGE)malloc(sizeof(ZYZGAUGE));
1009 /* hang on to this control block */
1010 // SetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE, (WORD)pgauge);
1011 // SetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE, (LONG)pgauge);
1013 /* fill control block with defaults */
1014 // pgauge->wRange = ZYZG_DEF_RANGE;
1015 // pgauge->wPosition = ZYZG_DEF_POSITION;
1016 // pgauge->wOrientation = ZYZG_DEF_ORIENTATION;
1017 // pgauge->wWidth3D = ZYZG_DEF_WIDTH3D;
1018 // pgauge->wWidthBezelFace = ZYZG_DEF_BEZELFACE;
1019 // pgauge->rgbTextColor = rgbDefTextColor;
1020 // pgauge->rgbBkColor = rgbDefBkColor;
1022 /* use system font */
1023 // SendMessage(hwnd, WM_SETFONT, (WPARAM)NULL, 0L);
1025 /* go to DefWindowProc() to finish the job */
1029 /* get rid of the control's memory */
1031 // LocalFree((HANDLE)pgauge);
1035 // case ZYZG_GETPOSITION:
1036 // return (pgauge->wPosition);
1038 // case ZYZG_GETRANGE:
1039 // return (pgauge->wRange);
1041 // case ZYZG_GETORIENTATION:
1042 // return (pgauge->wOrientation);
1044 // case ZYZG_GETWIDTH3D:
1045 // return (pgauge->wWidth3D);
1047 // case ZYZG_GETBEZELFACE:
1048 // return (pgauge->wWidthBezelFace);
1050 // case ZYZG_GETBKCOLOR:
1051 // return (pgauge->rgbTextColor);
1053 // case ZYZG_GETFGCOLOR:
1054 // return (pgauge->rgbBkColor);
1056 // case ZYZG_SETBKCOLOR:
1057 // pgauge->rgbBkColor = lParam;
1060 // case ZYZG_SETFGCOLOR:
1061 // pgauge->rgbTextColor = lParam;
1065 // case ZYZG_SETPOSITION:
1066 // pgauge->wPosition = wParam;
1069 // GetClientRect(hwnd, &rc);
1070 // if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
1072 // wParam = (2 * pgauge->wWidth3D) +
1073 // pgauge->wWidthBezelFace + 2;
1079 // InflateRect(&rc, ~(wParam), ~(wParam));
1080 // InvalidateRect(hwnd, &rc, FALSE);
1081 // UpdateWindow(hwnd);
1084 // case ZYZG_SETRANGE:
1085 // pgauge->wRange = wParam;
1086 // goto zyzgForceRepaint;
1088 // case ZYZG_SETORIENTATION:
1089 // pgauge->wOrientation = wParam;
1090 // goto zyzgForceRepaint;
1092 // case ZYZG_SETWIDTH3D:
1093 // pgauge->wWidth3D = wParam;
1095 //zyzgForceRepaint3D:
1096 // InvalidateRect(hwnd, NULL, FALSE);
1097 // UpdateWindow(hwnd);
1100 // case ZYZG_SETBEZELFACE:
1101 // pgauge->wWidthBezelFace = wParam;
1102 // goto zyzgForceRepaint3D;
1104 // case ZYZG_SETDELTAPOS:
1105 ///* Watcom doesn't like the following line so removing typecasts */
1106 ///* (int)pgauge->wPosition += (int)wParam; */
1107 // pgauge->wPosition += wParam;
1108 // goto zyzgForceRepaint;
1111 // BeginPaint(hwnd, &ps);
1112 // gaugePaint(hwnd, ps.hdc);
1113 // EndPaint(hwnd, &ps);
1117 // hFont = pgauge->hFont;
1119 // /* if system font, then return NULL handle */
1120 // return (long)((hFont == GetStockObject(SYSTEM_FONT)) ? NULL : hFont);
1123 /* if NULL hFont, use system font */
1124 // hFont = (HFONT)wParam ;
1126 // hFont = (HFONT) GetStockObject(SYSTEM_FONT);
1128 // pgauge->hFont = hFont;
1130 /* redraw if indicated in message */
1131 // if ((BOOL)lParam)
1133 // InvalidateRect(hwnd, NULL, TRUE);
1134 // UpdateWindow(hwnd);
1137 // } /* switch () */
1139 /* let the dialog mangler take care of this message */
1140 // return (DefWindowProc(hwnd, uMsg, wParam, lParam));
1141 //} /* gaugeWndProc() */
1144 /** EOF: zyzgauge.c **/