]> git.saurik.com Git - wxWidgets.git/blame - src/os2/gauge.cpp
Process/thread work and API fix into network APIs
[wxWidgets.git] / src / os2 / gauge.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: gauge.cpp
3// Purpose: wxGauge class
0371a691 4// Author: David Webster
0e320a79 5// Modified by:
0371a691 6// Created: 10/06/99
0e320a79 7// RCS-ID: $Id$
0371a691
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
0371a691
DW
12#include "wx/wxprec.h"
13
14#ifndef WX_PRECOMP
15#include "wx/defs.h"
16#include "wx/utils.h"
0e320a79
DW
17#endif
18
0371a691 19#include "wx/os2/private.h"
0e320a79
DW
20#include "wx/gauge.h"
21
0371a691
DW
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)
38
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
44
45/* gauge styles */
46#define ZYZGS_3D 0x8000L /* control will be 3D */
47
48/* public function prototypes */
e6ebb514 49// BOOL _Optlink gaugeInit(HINSTANCE hInstance);
0371a691 50
0e320a79
DW
51#if !USE_SHARED_LIBRARY
52IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
53#endif
54
55bool wxGauge::Create(wxWindow *parent, wxWindowID id,
56 int range,
57 const wxPoint& pos,
58 const wxSize& size,
59 long style,
60 const wxValidator& validator,
61 const wxString& name)
62{
0371a691
DW
63 static bool wxGaugeOS2Initialised = FALSE;
64
65 if ( !wxGaugeOS2Initialised )
66 {
e6ebb514
DW
67//TODO:
68/*
0371a691
DW
69 if (!gaugeInit((HINSTANCE) wxGetInstance()))
70 wxFatalError("Cannot initalize Gauge library");
e6ebb514 71*/
0371a691
DW
72 wxGaugeOS2Initialised = TRUE;
73 }
74
0e320a79
DW
75 SetName(name);
76 SetValidator(validator);
0371a691 77 if (parent) parent->AddChild(this);
0e320a79 78 m_rangeMax = range;
0371a691 79 m_gaugePos = 0;
0e320a79 80
0371a691 81 m_windowStyle = style;
0e320a79
DW
82
83 if ( id == -1 )
0371a691 84 m_windowId = (int)NewControlId();
0e320a79 85 else
0371a691 86 m_windowId = id;
0e320a79 87
0371a691
DW
88 int x = pos.x;
89 int y = pos.y;
90 int width = size.x;
91 int height = size.y;
0e320a79
DW
92
93 // TODO
0371a691
DW
94/*
95 int x = pos.x;
96 int y = pos.y;
97 int width = size.x;
98 int height = size.y;
0e320a79 99
0371a691
DW
100 long msFlags = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
101 msFlags |= ZYZGS_3D;
102
103 HWND wx_button =
223d09f6 104 CreateWindowEx(MakeExtendedStyle(m_windowStyle), wxT("zYzGauge"), NULL, msFlags,
0371a691
DW
105 0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
106 wxGetInstance(), NULL);
107
108 m_hWnd = (WXHWND)wx_button;
109
110 // Subclass again for purposes of dialog editing mode
111 SubclassWin((WXHWND)wx_button);
112
113 int wOrient = 0;
114
115 if (m_windowStyle & wxGA_HORIZONTAL)
116 wOrient = ZYZG_ORIENT_LEFTTORIGHT;
117 else
118 wOrient = ZYZG_ORIENT_BOTTOMTOTOP;
119
120 SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0);
121 SendMessage(wx_button, ZYZG_SETRANGE, range, 0);
122
123 SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
124 SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
125
126 SetFont(parent->GetFont());
127
128 if (width == -1)
129 width = 50;
130 if (height == -1)
131 height = 50;
132 SetSize(x, y, width, height);
133
134 ShowWindow(GetHwnd(), SW_SHOW);
135*/
136 return TRUE;
0e320a79
DW
137}
138
139void wxGauge::SetShadowWidth(int w)
140{
0371a691 141 // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETWIDTH3D, w, 0);
0e320a79
DW
142}
143
144void wxGauge::SetBezelFace(int w)
145{
0371a691 146 // TODO optional ::SendMessage(GetHwnd(), ZYZG_SETBEZELFACE, w, 0);
0e320a79
DW
147}
148
149void wxGauge::SetRange(int r)
150{
151 m_rangeMax = r;
0371a691 152 // TODO ::SendMessage(GetHwnd(), ZYZG_SETRANGE, r, 0);
0e320a79
DW
153}
154
155void wxGauge::SetValue(int pos)
156{
157 m_gaugePos = pos;
0371a691 158 // TODO ::SendMessage(GetHwnd(), ZYZG_SETPOSITION, pos, 0);
0e320a79
DW
159}
160
161int wxGauge::GetShadowWidth() const
162{
0371a691 163 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETWIDTH3D, 0, 0);
0e320a79
DW
164 return 0;
165}
166
167int wxGauge::GetBezelFace() const
168{
0371a691 169 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETBEZELFACE, 0, 0);
0e320a79
DW
170 return 0;
171}
172
173int wxGauge::GetRange() const
174{
0371a691 175 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETRANGE, 0, 0);
0e320a79
DW
176 return m_rangeMax;
177}
178
179int wxGauge::GetValue() const
180{
0371a691 181 // TODO return (int) ::SendMessage(GetHwnd(), ZYZG_GETPOSITION, 0, 0);
0e320a79
DW
182 return m_gaugePos;
183}
184
0371a691
DW
185bool wxGauge::SetForegroundColour(const wxColour& col)
186{
187 if ( !wxControl::SetForegroundColour(col) )
188 return FALSE;
189
190 // TODO ::SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
191
192 return TRUE;
193}
194
195bool wxGauge::SetBackgroundColour(const wxColour& col)
196{
197 if ( !wxControl::SetBackgroundColour(col) )
198 return FALSE;
199
200 // TODO ::SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
201
202 return TRUE;
203}
204
205///** zyz3d.c
206// *
207// * DESCRIPTION:
208// * This module contains functions for creating nifty 3D borders
209// * around controls like zYzGauge.
210// *
211// * HISTORY:
212// * 3/14/91 cjp put in this comment
213// * 6/19/92 cjp touched it a bit
214// *
215// ** cjp */
216// COPYRIGHT:
217//
218// (C) Copyright Microsoft Corp. 1992. All rights reserved.
219//
220// You have a royalty-free right to use, modify, reproduce and
221// distribute the Sample Files (and/or any modified version) in
222// any way you find useful, provided that you agree that
223// Microsoft has no warranty obligations or liability for any
224// Sample Application Files which are modified.
225//
226
227
228///* get the includes we need */
229//#define INCL_PM
230//#include <os2.h>
231
232///* misc. control flag defines */
233//#define DRAW3D_IN 0x0001
234//#define DRAW3D_OUT 0x0002
235
236//#define DRAW3D_TOPLINE 0x0004
237//#define DRAW3D_BOTTOMLINE 0x0008
238//#define DRAW3D_LEFTLINE 0x0010
239//#define DRAW3D_RIGHTLINE 0x0020
240
241
242///* public function prototypes */
243//void _Optlink Draw3DFaceFrame(HDC, LPRECT, WORD);
244//void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD);
245//void _Optlink Draw3DLine(HDC, WORD, WORD, WORD, WORD, WORD);
246
247
248///** void _Optlink Draw3DFaceFrame(HDC hdc, LPRECT rc, WORD wWidth)
249// *
250// * DESCRIPTION:
251// * This function draws a flat frame with the current button-face
252// * color.
253// *
254// * ARGUMENTS:
255// * HDC hdc : The DC to draw into.
256// *
257// * LPRECT rc : The containing rect for the new frame.
258// *
259// * WORD wWidth : The width of the frame to draw.
260// *
261// * RETURN (void _Optlink):
262// * The frame will have been drawn into the DC.
263// *
264// * NOTES:
265// *
266// ** cjp */
267
268//void _Optlink Draw3DFaceFrame(HDC hdc, RECTL* rc, WORD wWidth)
269//{
270// RECTL rc1;
271// DWORD rgbOld;
272
273// /* don't go through a bunch of work if we don't have to */
274// if (!wWidth)
275// return;
276
277// /* set up color to be button-face color--so it may not be gray */
278// rgbOld = SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
279
280// /* perform CopyRect w/o bloody windows style overhead */
281// rc1 = *rc;
282
283 /* top */
284// rc1.top = rc->top;
285// rc1.left = rc->left;
286// rc1.bottom = rc->top + wWidth;
287// rc1.right = rc->right;
288
289 /* blast it out */
290// ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
291
292 /* right */
293// rc1.left = rc->right - wWidth;
294// rc1.bottom = rc->bottom;
295
296 /* blast this part now */
297// ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
298
299 /* left */
300// rc1.left = rc->left;
301// rc1.right = rc->left + wWidth;
302
303 /* and another part */
304// ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
305
306 /* bottom */
307// rc1.right = rc->right;
308// rc1.top = rc->bottom - wWidth;
309
310 /* finish it off */
311// ExtTextOut(hdc, rc1.left, rc1.top, ETO_OPAQUE, &rc1, NULL, 0, NULL);
312
313 /* restore the old bk color */
314// SetBkColor(hdc, rgbOld);
315//} /* Draw3DFaceFrame() */
316
317
318///** void _Optlink Draw3DRect(HDC, LPRECT, WORD, WORD)
319// *
320// * DESCRIPTION:
321// * Draws a 3D rectangle that is shaded. wFlags can be used to
322// * control how the rectangle looks.
323// *
324// * ARGUMENTS:
325// * HDC hdc : Handle to the device context that will be
326// * used to display the rectangle.
327// *
328// * RECT rect : A rectangle describing the dimensions of
329// * the rectangle in device coordinates.
330// *
331// * WORD wShadowWidth : Width of the shadow in device coordinates.
332// *
333// * WORD wFlags : The following flags may be passed to describe
334// * the style of the rectangle:
335// *
336// * DRAW3D_IN : The shadow is drawn such that
337// * the box appears to be sunk in to the screen.
338// * This is default if 0 is passed.
339// *
340// * DRAW3D_OUT : The shadow is drawn such that
341// * the box appears to be sticking out of the
342// * screen.
343// *
344// * RETURN (void _Optlink):
345// * The 3D looking rectangle will have been drawn into the DC.
346// *
347// * NOTES:
348// *
349// ** cjp */
350
351//void _Optlink Draw3DRect(HDC hdc, LPRECT lpRect,
352// WORD wShadowWidth, WORD wFlags)
353//{
354// /* sanity check--don't work if you don't have to! */
355// if (!wShadowWidth || !RectVisible(hdc, lpRect))
356// return;
357
358 /* draw the top line */
359// Draw3DLine(hdc, lpRect->left, lpRect->top,
360// lpRect->right - lpRect->left,
361// wShadowWidth, DRAW3D_TOPLINE | wFlags);
362
363 /* right line */
364// Draw3DLine(hdc, lpRect->right, lpRect->top,
365// lpRect->bottom - lpRect->top,
366// wShadowWidth, DRAW3D_RIGHTLINE | wFlags);
367
368 /* bottom line */
369// Draw3DLine(hdc, lpRect->left, lpRect->bottom,
370// lpRect->right - lpRect->left,
371// wShadowWidth, DRAW3D_BOTTOMLINE | wFlags);
372
373 /* left line */
374// Draw3DLine(hdc, lpRect->left, lpRect->top,
375// lpRect->bottom - lpRect->top,
376// wShadowWidth, DRAW3D_LEFTLINE | wFlags);
377//} /* Draw3DRect() */
378
379
380///** void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
381// *
382// * DESCRIPTION:
383// * Draws a 3D line that can be used to make a 3D box.
384// *
385// * ARGUMENTS:
386// * HDC hdc : Handle to the device context that will be
387// * used to display the 3D line.
388// *
389// * WORD x, y : Coordinates of the beginning of the line.
390// * These coordinates are in device units and
391// * represent the _outside_ most point. Horiz-
392// * ontal lines are drawn from left to right and
393// * vertical lines are drawn from top to bottom.
394// *
395// * WORD wShadowWidth : Width of the shadow in device coordinates.
396// *
397// * WORD wFlags : The following flags may be passed to
398// * describe the style of the 3D line:
399// *
400// * DRAW3D_IN : The shadow is drawn such that
401// * the box appears to be sunk in to the screen.
402// * This is default if 0 is passed.
403// *
404// * DRAW3D_OUT : The shadow is drawn such that
405// * the box appears to be sticking out of the
406// * screen.
407// *
408// * DRAW3D_TOPLINE, _BOTTOMLINE, _LEFTLINE, and
409// * _RIGHTLINE : Specifies that a "top",
410// * "Bottom", "Left", or"Right" line is to be
411// * drawn.
412// *
413// * RETURN (void _Optlink):
414// * The line will have been drawn into the DC.
415// *
416// * NOTES:
417// *
418// ** cjp */
419
420//void _Optlink Draw3DLine(HDC hdc, WORD x, WORD y, WORD nLen,
421// WORD wShadowWidth, WORD wFlags)
422//{
423// HBRUSH hOldBrush;
424// HPEN hOldPen;
425// BOOL fDark;
426// POINT Point[ 4 ]; /* define a polgon with 4 points */
427
428// /* if width is zero, don't do nothin'! */
429// if (!wShadowWidth)
430// return;
431
432 /* define shape of polygon--origin is always the same */
433// Point[0].x = x;
434// Point[0].y = y;
435
436// /* To do this we'll simply draw a polygon with four sides, using
437// * the appropriate brush. I dare you to ask me why this isn't a
438// * switch/case!
439// */
440// if (wFlags & DRAW3D_TOPLINE)
441// {
442// /* across to right */
443// Point[1].x = x + nLen - (wShadowWidth == 1 ? 1 : 0);
444// Point[1].y = y;
445
446 /* down/left */
447// Point[2].x = x + nLen - wShadowWidth;
448// Point[2].y = y + wShadowWidth;
449
450 /* accross to left */
451// Point[3].x = x + wShadowWidth;
452// Point[3].y = y + wShadowWidth;
453
454 /* select 'dark' brush if 'in'--'light' for 'out' */
455// fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
456// }
457
458 /* possibly the bottom? */
459// else if (wFlags & DRAW3D_BOTTOMLINE)
460// {
461 /* across to right */
462// Point[1].x = x + nLen;
463// Point[1].y = y;
464
465 /* up/left */
466// Point[2].x = x + nLen - wShadowWidth;
467// Point[2].y = y - wShadowWidth;
468
469 /* accross to left */
470// Point[3].x = x + wShadowWidth;
471// Point[3].y = y - wShadowWidth;
472
473 /* select 'light' brush if 'in' */
474// fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
475// }
476
477 /* ok, it's gotta be left? */
478// else if (wFlags & DRAW3D_LEFTLINE)
479// {
480 /* down */
481// Point[1].x = x;
482// Point[1].y = y + nLen - (wShadowWidth == 1 ? 1 : 0);
483
484 /* up/right */
485// Point[2].x = x + wShadowWidth;
486// Point[2].y = y + nLen - wShadowWidth;
487
488 /* down */
489// Point[3].x = x + wShadowWidth;
490// Point[3].y = y + wShadowWidth;
491
492 /* select 'dark' brush if 'in'--'light' for 'out' */
493// fDark = (wFlags & DRAW3D_IN) ? TRUE : FALSE;
494// }
495
496 /* well maybe it's for the right side? */
497// else if (wFlags & DRAW3D_RIGHTLINE)
498// {
499 /* down */
500// Point[1].x = x;
501// Point[1].y = y + nLen;
502
503 /* up/left */
504// Point[2].x = x - wShadowWidth;
505// Point[2].y = y + nLen - wShadowWidth;
506
507 /* up */
508// Point[3].x = x - wShadowWidth;
509// Point[3].y = y + wShadowWidth;
510
511 /* select 'light' brush if 'in' */
512// fDark = (wFlags & DRAW3D_IN) ? FALSE : TRUE;
513// }
514
515 /* bad drugs? */
516// else return;
517
518 /* select NULL_PEN for no borders */
519// hOldPen = (HPEN) SelectObject(hdc, GetStockObject(NULL_PEN));
520
521 /* select the appropriate color for the fill */
522// if (fDark)
523// hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(GRAY_BRUSH));
524// else
525// hOldBrush = (HBRUSH) SelectObject(hdc, GetStockObject(WHITE_BRUSH));
526
527 /* finally, draw the dern thing */
528// Polygon(hdc, (LPPOINT)&Point, 4);
529
530 /* restore what we killed */
531// SelectObject(hdc, hOldBrush);
532// SelectObject(hdc, hOldPen);
533//} /* Draw3DLine() */
534
535/** EOF: zyz3d.c **/
536
537///** zyzgauge.c
538// *
539// * DESCRIPTION:
540// * Yet another 'Gas Gauge Custom Control.' This control gives you
541// * a 'progress bar' class (named zYzGauge) for use in your applications.
542// * You can set the range, position, font, color, orientation, and 3d
543// * effect of the gauge by sending messages to the control.
544// *
545// * Before you can use this control, you MUST first export the window
546// * procedure for the control (or define it with the _export keyword):
547// *
548// * EXPORTS gaugeWndProc
549// *
550// * You then need initialize the class before you use it:
551// *
552// * if (!gaugeInit(hInstance))
553// * die a horrible death
554// * else
555// * you are good to go
556// *
557// * The colors used by the control default to black and white if you
558// * are running on a mono-display. They default to blue and white
559// * if you are on a color display. You enable the 3D effect by setting
560// * the ZYZGS_3D style flag in the styles field of the control (like
561// * any other control).
562// *
563// * To select your own colors, you can send the ZYZG_SETFGCOLOR and
564// * ZYZG_SETBKCOLOR messages to set the foreground (percent done) and
565// * background (percent not done) colors. The lParam is the RGB()
566// * value--wParam is ignored.
567// *
568// * In all of the following ZYZG_??? messages, the arguments are
569// * WORDS. If you are setting parameters, the value is sent as
570// * the wParam (lParam is ignored). If you are getting parameters,
571// * the value is returned as a LONG and should be cast to a *signed*
572// * integer.
573// *
574// * To set the depth of the 3D effect (if enabled), you can send the
575// * ZYZG_SETBEZELFACE and ZYZG_SETWIDTH3D messages. The bezel face
576// * is the flat top on the 3D border--its color will be that of the
577// * button-face. The 3D width is the width of the bezel itself; inside
578// * and outside. The light color is white, the dark color is gray.
579// * Both widths *can* be zero--both default to 2 which looks to me.
580// *
581// * The range of the control can be set by sending the ZYZG_SETRANGE
582// * message to the control. It can be any integer from 1 to 32767.
583// * What this specifies is the number of pieces that create a whole.
584// * The default is 100. You can get the current range setting by
585// * sending the ZYZG_GETRANGE message to the control.
586// *
587// * The position (number of pieces out of the whole have been used) is
588// * set with the ZYZG_SETPOSITION message. It can be any integer from
589// * 0 to the current range setting of the control--it will be clipped
590// * if the position is out of bounds. The default position is 0. You
591// * can get the current position at any time with the ZYZG_GETPOSITION
592// * message.
593// *
594// * You can also set the range using a delta from the current range.
595// * This is done by sending the ZYZG_SETDELTAPOS message with wParam
596// * set to a _signed_ integer value within the range of the control.
597// *
598// * The font used for the percentage text can be set using the standard
599// * WM_SETFONT message. You can get the current font at any time with
600// * the WM_GETFONT message.
601// *
602// * The orientation can be left to right, right to left, bottom to top,
603// * or top to bottom. Whatever suits your needs. You set this by
604// * sending the ZYZG_ORIENTATION message to the control with one of
605// * the following values (default is ZYZG_ORIENT_LEFTTORIGHT):
606// *
607// * ZYZG_ORIENT_LEFTTORIGHT (0)
608// * ZYZG_ORIENT_RIGHTTOLEFT (1)
609// * ZYZG_ORIENT_BOTTOMTOTOP (2)
610// * ZYZG_ORIENT_TOPTOBOTTOM (3)
611// *
612// * HISTORY:
613// * 3/12/91 cjp put in this comment
614// * 6/19/92 cjp touched it a bit
615// *
616// ** cjp */
617// COPYRIGHT:
618//
619// (C) Copyright Microsoft Corp. 1992. All rights reserved.
620//
621// You have a royalty-free right to use, modify, reproduce and
622// distribute the Sample Files (and/or any modified version) in
623// any way you find useful, provided that you agree that
624// Microsoft has no warranty obligations or liability for any
625// Sample Application Files which are modified.
626//
627
628
629/* get the includes we need */
630//#if !defined(__GNUWIN32__) && !defined(__SALFORDC__)
631//#include <malloc.h>
632//#endif
633//#include <stdio.h>
634//#include <string.h>
635//#include <stdlib.h>
636// #include "zyz3d.h"
637// #include "zyzgauge.h"
638
639
640/* static global variables */
223d09f6 641//static wxChar gszzYzGaugeClass[] = wxT("zYzGauge");
0371a691
DW
642
643
644/* window word position definitions */
645//#define ZYZG_WW_PZYZGAUGE 0
646/* #define ZYZG_WW_EXTRABYTES 2 */
647//#define ZYZG_WW_EXTRABYTES 4
648
649
650/* control block structure typedef */
651//typedef struct tZYZGAUGE
652//{
653// WORD wRange;
654// WORD wPosition;
655// WORD wOrientation;
656// WORD wWidth3D;
657// WORD wWidthBezelFace;
658// HFONT hFont;
659// DWORD rgbTextColor;
660// DWORD rgbBkColor;
661
662//} ZYZGAUGE, *PZYZGAUGE, FAR *LPZYZGAUGE;
663
664
665/* some default values for the control */
666//#define ZYZG_DEF_RANGE 100
667//#define ZYZG_DEF_POSITION 0
668//#define ZYZG_DEF_ORIENTATION ZYZG_ORIENT_LEFTTORIGHT
669//#define ZYZG_DEF_WIDTH3D 2
670//#define ZYZG_DEF_BEZELFACE 2
671
672
673
674/* the default settings for drawing colors--display dependent */
675//static DWORD rgbDefTextColor;
676//static DWORD rgbDefBkColor;
677//static BOOL fSupport3D;
678
679//#if !defined(APIENTRY) // NT defines APIENTRY, 3.x not
680//#define APIENTRY _Optlink
681//#endif
682
683//#ifdef __WIN32__
684//#define _EXPORT /**/
685//#else
686//#define _EXPORT _export
687//typedef signed short int SHORT ;
688//#endif
689
690/* internal function prototypes */
691//static void PASCAL gaugePaint(HWND, HDC);
692/* LRESULT _Optlink */
693//LRESULT APIENTRY _EXPORT gaugeWndProc(HWND, UINT, WPARAM, LPARAM);
694
695
696
697///** BOOL _Optlink gaugeInit(HINSTANCE hInstance)
698// *
699// * DESCRIPTION:
700// * Registers the window class for the zYzGauge control. Performs
701// * other initialization for the zYzGauge text control. This must
702// * be done before the zYzGauge control is used--or it will fail
703// * and your dialog box will not open!
704// *
705// * ARGUMENTS:
706// * HINSTANCE hInstance : Instance handle to register class with.
707// *
708// * RETURN (BOOL FAR):
709// * The return value is TRUE if the zYzGauge class was successfully
710// * registered. It is FALSE if the initialization fails.
711// *
712// * NOTES:
713// *
714// ** cjp */
715
716//#pragma alloc_text(init, gaugeInit)
717
718//BOOL _Optlink gaugeInit(HINSTANCE hInstance)
719//{
720// static BOOL fRegistered = FALSE;
721// WNDCLASS wc;
722// HDC hdc;
723
724 /* assume already registered if not first instance */
725// if (fRegistered)
726// return (TRUE);
727
728 /* fill in the class structure for the zyzgauge control */
729// wc.hCursor = LoadCursor(NULL, IDC_ARROW);
730// wc.hIcon = NULL;
731// wc.lpszMenuName = NULL;
732// wc.lpszClassName = gszzYzGaugeClass;
733// wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
734// wc.hInstance = hInstance;
735
736//#ifdef ZYZGAUGE_DLL
737// wc.style = CS_GLOBALCLASS | CS_HREDRAW | CS_VREDRAW;
738//#else
739// wc.style = CS_HREDRAW | CS_VREDRAW;
740//#endif
741
742// wc.lpfnWndProc = gaugeWndProc;
743// wc.cbClsExtra = 0;
744// wc.cbWndExtra = ZYZG_WW_EXTRABYTES;
745
746 /* attempt to register it--return FALSE if fail */
747// if (!RegisterClass(&wc))
748// return (FALSE);
749
750 /* Get a DC to determine whether device is mono or not, and set
751 * default foreground/background colors as appropriate.
752 */
223d09f6 753// hdc = CreateIC(wxT("DISPLAY"), NULL, NULL, 0L) ;
0371a691
DW
754// if (hdc)
755// {
756 /* check for mono-display */
757// if ((GetDeviceCaps(hdc, BITSPIXEL) == 1) &&
758// (GetDeviceCaps(hdc, PLANES) == 1))
759// {
760 /* using a mono DC--white foreground, black background */
761// rgbDefTextColor = RGB(255, 255, 255);
762// rgbDefBkColor = RGB(0, 0, 0);
763// }
764
765 /* good! we have color: blue foreground, white background */
766// else
767// {
768// rgbDefTextColor = RGB(0, 0, 255);
769// rgbDefBkColor = RGB(255, 255, 255);
770// }
771
772 /* need at _least_ 8 for two shades of gray (>=VGA) */
773// fSupport3D = (GetDeviceCaps(hdc, NUMCOLORS) >= 8) ? TRUE : FALSE;
774
775 /* get rid of the DC (IC) */
776// DeleteDC(hdc);
777// }
778
779 /* uh-oh... can't get DC (IC)... fail */
780// else
781// {
782 /* unregister the class */
783// UnregisterClass(gszzYzGaugeClass, hInstance);
784// return (FALSE);
785// }
786
787 /* return success */
788// return (fRegistered = TRUE);
789//} /* gaugeInit() */
790
791
792/** static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
793// *
794// * DESCRIPTION:
795// * This function is responsible for painting the zYzGauge control.
796// *
797// * ARGUMENTS:
798// * HWND hwnd : The window handle for the gauge.
799// *
800// * HDC hdc : The DC for the gauge's window.
801// *
802// * RETURN (void):
803// * The control will have been painted.
804// *
805// * NOTES:
806// *
807// ** cjp */
808
809//static void PASCAL gaugePaint(HWND hwnd, HDC hdc)
810//{
811// PZYZGAUGE pgauge;
812// WORD iRange, iPos;
813// WORD Offset = 1;
814// DWORD dwExtent;
815// RECT rc1, rc2;
816// HFONT hFont;
817// wxChar ach[ 6 ];
818// WORD dx, dy, wGomerX, wGomerY;
819///* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead,
820// * which needs a SIZE* parameter */
821//#if defined(__WIN32__)
822// SIZE size;
823//#endif
824
825// /* get pointer to the control's control block */
826// pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
827// pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
828
829 /* set the colors into for the gauge into the control */
830// SetTextColor(hdc, pgauge->rgbTextColor);
831// SetBkColor(hdc, pgauge->rgbBkColor);
832
833 /* draw black rectangle for gauge */
834// GetClientRect(hwnd, &rc1);
835
836 /* draw a black border on the _outside_ */
837// FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH));
838
839 /* we want to draw _just inside_ the black border */
840// InflateRect(&rc1, -1, -1);
841
842 /* one line thick so far... */
843// Offset = (WORD) 1;
844
845 /* for 3D stuff, we need to have at least two shades of gray */
846// if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
847// {
848// Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_OUT);
849// InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
850
851// Draw3DFaceFrame(hdc, &rc1, pgauge->wWidthBezelFace);
852// InflateRect(&rc1, ~(pgauge->wWidthBezelFace), ~(pgauge->wWidthBezelFace));
853
854// Draw3DRect(hdc, &rc1, pgauge->wWidth3D, DRAW3D_IN);
855// InflateRect(&rc1, ~(pgauge->wWidth3D), ~(pgauge->wWidth3D));
856
857 /* draw a black border on the _inside_ */
858// FrameRect(hdc, &rc1, (HBRUSH) GetStockObject(BLACK_BRUSH));
859
860 /* we want to draw _just inside_ the black border */
861// InflateRect(&rc1, -1, -1);
862
863 /* add all the other pixels into the border width */
864// Offset += (2 * pgauge->wWidth3D) + pgauge->wWidthBezelFace + 1;
865// }
866
867 /* dup--one rc for 'how much filled', one rc for 'how much empty' */
868// rc2 = rc1;
869
870 /* get the range--make sure it's a valid range */
871// if ((iRange = pgauge->wRange) <= 0)
872// iRange = 1;
873
874 /* get the position--greater than 100% would be bad */
875// if ((iPos = pgauge->wPosition) > iRange)
876// iPos = iRange;
877
878 /* compute the actual size of the gauge */
879// dx = rc1.right - rc1.left;
880// dy = rc1.bottom - rc1.top;
881// wGomerX = (WORD)((DWORD)iPos * dx / iRange);
882// wGomerY = (WORD)((DWORD)iPos * dy / iRange);
883
884 /* get the orientation and munge rects accordingly */
885// switch (pgauge->wOrientation)
886// {
887// case ZYZG_ORIENT_RIGHTTOLEFT:
888// rc1.left = rc2.right = rc1.right - wGomerX;
889// break;
890
891// case ZYZG_ORIENT_BOTTOMTOTOP:
892// rc1.top = rc2.bottom = rc1.bottom - wGomerY;
893// break;
894
895// case ZYZG_ORIENT_TOPTOBOTTOM:
896// rc1.bottom = rc2.top += wGomerY;
897// break;
898
899// default:
900// rc1.right = rc2.left += wGomerX;
901// break;
902// } /* switch () */
903
904 /* select the correct font */
905// hFont = (HFONT) SelectObject(hdc, pgauge->hFont);
906
907 /* build up a string to blit out--ie the meaning of life: "42%" */
223d09f6 908// wsprintf(ach, wxT("%3d%%"), (WORD)((DWORD)iPos * 100 / iRange));
0371a691
DW
909/* Win32s has no GetTextExtent(); let's try GetTextExtentPoint() instead */
910//#if defined(__WIN32__)
911// GetTextExtentPoint(hdc, ach, wGomerX = lstrlen(ach), &size);
912// dwExtent = size.cx;
913//#else
914// dwExtent = GetTextExtent(hdc, ach, wGomerX = lstrlen(ach));
915//#endif
916
917
918 /* Draw the finished (ie the percent done) side of box. If
919 * ZYZG_WW_POSITION is 42, (in range of 0 to 100) this ExtTextOut
920 * draws the meaning of life (42%) bar.
921 */
922// ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
923// (dy - HIWORD(dwExtent)) / 2 + Offset,
924// ETO_OPAQUE | ETO_CLIPPED, &rc2, ach, wGomerX, NULL);
925
926 /* Reverse fore and back colors for drawing the undone (ie the non-
927 * finished) side of the box.
928 */
929// SetBkColor(hdc, pgauge->rgbTextColor);
930// SetTextColor(hdc, pgauge->rgbBkColor);
931
932// ExtTextOut(hdc, (dx - LOWORD(dwExtent)) / 2 + Offset,
933// (dy - HIWORD(dwExtent)) / 2 + Offset,
934// ETO_OPAQUE | ETO_CLIPPED, &rc1, ach, wGomerX, NULL);
935
936 /* unselect the font */
937// SelectObject(hdc, hFont);
938//} /* gaugePaint() */
939
940
941/** LRESULT _Optlink gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
942// *
943// * DESCRIPTION:
944// * This is the control's window procedure. Its purpose is to handle
945// * special messages for this custom control.
946// *
947// * The special control messages for the gauge control are:
948// *
949// * ZYZG_SETRANGE : Sets the range of the gauge. In other
950// * words, the number of parts that make a
951// * whole.
952// *
953// * ZYZG_GETRANGE : Returns the current range of the gauge.
954// *
955// * ZYZG_SETORIENTATION : Sets the orientation of the gauge. This
956// * can be one of the ZYZG_ORIENT_?? msgs.
957// *
958// * ZYZG_GETORIENTATION : Gets the current orientation of the
959// * gauge.
960// *
961// * ZYZG_SETPOSITION : Sets the current position of the gauge.
962// * In other words, how many pieces of the
963// * whole have been used.
964// *
965// * ZYZG_GETPOSITION : Gets the current position of the gauge.
966// *
967// * ZYZG_SETDELTAPOS : Sets the position of the gauge +/- the
968// * specified amount.
969// *
970// * ZYZG_SETFGCOLOR : Sets the foreground (percent done) color.
971// *
972// * ZYZG_GETFGCOLOR : Gets the foreground (percent done) color.
973// *
974// * ZYZG_SETBKCOLOR : Sets the background (percent not done)
975// * color.
976// *
977// * ZYZG_GETBKCOLOR : Gets the background (percent not done)
978// * color.
979// *
980// * WM_SETFONT : Sets the font to use for the percentage
981// * text of the gauge.
982// *
983// * WM_GETFONT : Gets the current font in use by the
984// * gauge.
985// *
986// * NOTES:
987// *
988// ** cjp */
989
990/* LRESULT _Optlink */
991
992//LRESULT APIENTRY _EXPORT gaugeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
993//{
994// HFONT hFont;
995// PAINTSTRUCT ps;
996// PZYZGAUGE pgauge;
997// RECT rc;
998
999// pgauge = (PZYZGAUGE)GetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE);
1000// pgauge = (PZYZGAUGE)GetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE);
1001
1002 /* break to get DefWindowProc() */
1003// switch (uMsg)
1004// {
1005// case WM_CREATE:
1006 /* need to allocate a control block */
1007// pgauge = (PZYZGAUGE)LocalAlloc(LPTR, sizeof(ZYZGAUGE));
1008// pgauge = (PZYZGAUGE)malloc(sizeof(ZYZGAUGE));
1009// if (!pgauge)
1010// return (0L);
1011
1012 /* hang on to this control block */
1013// SetWindowWord(hwnd, ZYZG_WW_PZYZGAUGE, (WORD)pgauge);
1014// SetWindowLong(hwnd, ZYZG_WW_PZYZGAUGE, (LONG)pgauge);
1015
1016 /* fill control block with defaults */
1017// pgauge->wRange = ZYZG_DEF_RANGE;
1018// pgauge->wPosition = ZYZG_DEF_POSITION;
1019// pgauge->wOrientation = ZYZG_DEF_ORIENTATION;
1020// pgauge->wWidth3D = ZYZG_DEF_WIDTH3D;
1021// pgauge->wWidthBezelFace = ZYZG_DEF_BEZELFACE;
1022// pgauge->rgbTextColor = rgbDefTextColor;
1023// pgauge->rgbBkColor = rgbDefBkColor;
1024
1025 /* use system font */
1026// SendMessage(hwnd, WM_SETFONT, (WPARAM)NULL, 0L);
1027
1028 /* go to DefWindowProc() to finish the job */
1029// break;
1030
1031// case WM_DESTROY:
1032 /* get rid of the control's memory */
1033// if (pgauge)
1034// LocalFree((HANDLE)pgauge);
1035// free(pgauge);
1036// break;
1037
1038// case ZYZG_GETPOSITION:
1039// return (pgauge->wPosition);
1040
1041// case ZYZG_GETRANGE:
1042// return (pgauge->wRange);
1043
1044// case ZYZG_GETORIENTATION:
1045// return (pgauge->wOrientation);
1046
1047// case ZYZG_GETWIDTH3D:
1048// return (pgauge->wWidth3D);
1049
1050// case ZYZG_GETBEZELFACE:
1051// return (pgauge->wWidthBezelFace);
1052
1053// case ZYZG_GETBKCOLOR:
1054// return (pgauge->rgbTextColor);
1055
1056// case ZYZG_GETFGCOLOR:
1057// return (pgauge->rgbBkColor);
1058
1059// case ZYZG_SETBKCOLOR:
1060// pgauge->rgbBkColor = lParam;
1061// return (0L);
1062
1063// case ZYZG_SETFGCOLOR:
1064// pgauge->rgbTextColor = lParam;
1065// return (0L);
1066
1067
1068// case ZYZG_SETPOSITION:
1069// pgauge->wPosition = wParam;
1070
1071//zyzgForceRepaint:
1072// GetClientRect(hwnd, &rc);
1073// if ((GetWindowLong(hwnd, GWL_STYLE) & ZYZGS_3D) && fSupport3D)
1074// {
1075// wParam = (2 * pgauge->wWidth3D) +
1076// pgauge->wWidthBezelFace + 2;
1077// }
1078
1079// else
1080// wParam = 1;
1081
1082// InflateRect(&rc, ~(wParam), ~(wParam));
1083// InvalidateRect(hwnd, &rc, FALSE);
1084// UpdateWindow(hwnd);
1085// return (0L);
1086
1087// case ZYZG_SETRANGE:
1088// pgauge->wRange = wParam;
1089// goto zyzgForceRepaint;
1090
1091// case ZYZG_SETORIENTATION:
1092// pgauge->wOrientation = wParam;
1093// goto zyzgForceRepaint;
1094
1095// case ZYZG_SETWIDTH3D:
1096// pgauge->wWidth3D = wParam;
1097
1098//zyzgForceRepaint3D:
1099// InvalidateRect(hwnd, NULL, FALSE);
1100// UpdateWindow(hwnd);
1101// return (0L);
1102
1103// case ZYZG_SETBEZELFACE:
1104// pgauge->wWidthBezelFace = wParam;
1105// goto zyzgForceRepaint3D;
1106
1107// case ZYZG_SETDELTAPOS:
1108///* Watcom doesn't like the following line so removing typecasts */
1109///* (int)pgauge->wPosition += (int)wParam; */
1110// pgauge->wPosition += wParam;
1111// goto zyzgForceRepaint;
1112
1113// case WM_PAINT:
1114// BeginPaint(hwnd, &ps);
1115// gaugePaint(hwnd, ps.hdc);
1116// EndPaint(hwnd, &ps);
1117// return (0L);
1118
1119// case WM_GETFONT:
1120// hFont = pgauge->hFont;
1121
1122// /* if system font, then return NULL handle */
1123// return (long)((hFont == GetStockObject(SYSTEM_FONT)) ? NULL : hFont);
1124
1125// case WM_SETFONT:
1126 /* if NULL hFont, use system font */
1127// hFont = (HFONT)wParam ;
1128// if (!hFont)
1129// hFont = (HFONT) GetStockObject(SYSTEM_FONT);
1130
1131// pgauge->hFont = hFont;
1132
1133 /* redraw if indicated in message */
1134// if ((BOOL)lParam)
1135// {
1136// InvalidateRect(hwnd, NULL, TRUE);
1137// UpdateWindow(hwnd);
1138// }
1139// return (0L);
1140// } /* switch () */
1141
1142 /* let the dialog mangler take care of this message */
1143// return (DefWindowProc(hwnd, uMsg, wParam, lParam));
1144//} /* gaugeWndProc() */
1145
1146
1147/** EOF: zyzgauge.c **/
1148
1149