1998-06-28 11:32:14 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-07-15 19:51:35 +00:00
|
|
|
// Name: src/msw/gauge95.cpp
|
1998-06-28 11:32:14 +00:00
|
|
|
// Purpose: wxGauge95 class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 11:23:28 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2000-07-15 19:51:35 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-06-28 11:32:14 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-06-28 11:32:14 +00:00
|
|
|
#ifdef __GNUG__
|
2000-07-15 19:51:35 +00:00
|
|
|
#pragma implementation "gauge95.h"
|
1998-06-28 11:32:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
2000-07-15 19:51:35 +00:00
|
|
|
#include "wx/defs.h"
|
1998-06-28 11:32:14 +00:00
|
|
|
#endif
|
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_GAUGE && defined(__WIN95__)
|
1998-06-28 11:32:14 +00:00
|
|
|
|
|
|
|
#include "wx/msw/gauge95.h"
|
|
|
|
#include "wx/msw/private.h"
|
|
|
|
|
2003-05-23 19:16:45 +00:00
|
|
|
#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
|
2000-02-14 18:21:21 +00:00
|
|
|
#include <commctrl.h>
|
1998-06-28 11:32:14 +00:00
|
|
|
#endif
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// old commctrl.h (< 4.71) don't have those
|
|
|
|
#ifndef PBS_SMOOTH
|
|
|
|
#define PBS_SMOOTH 0x01
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PBS_VERTICAL
|
|
|
|
#define PBS_VERTICAL 0x04
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PBM_SETBARCOLOR
|
|
|
|
#define PBM_SETBARCOLOR (WM_USER+9)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PBM_SETBKCOLOR
|
|
|
|
#define PBM_SETBKCOLOR 0x2001
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxWin macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-06-28 11:32:14 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl)
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
|
|
|
|
int range,
|
1998-06-28 11:32:14 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
1998-07-04 15:17:59 +00:00
|
|
|
long style,
|
1998-06-28 11:32:14 +00:00
|
|
|
const wxValidator& validator,
|
|
|
|
const wxString& name)
|
|
|
|
{
|
|
|
|
SetName(name);
|
2000-01-06 18:23:59 +00:00
|
|
|
#if wxUSE_VALIDATORS
|
1998-06-28 11:32:14 +00:00
|
|
|
SetValidator(validator);
|
2000-01-06 18:23:59 +00:00
|
|
|
#endif // wxUSE_VALIDATORS
|
1998-06-28 11:32:14 +00:00
|
|
|
|
|
|
|
if (parent) parent->AddChild(this);
|
|
|
|
m_rangeMax = range;
|
1998-08-10 13:48:12 +00:00
|
|
|
m_gaugePos = 0;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
|
|
|
m_windowStyle = style;
|
|
|
|
|
|
|
|
if ( id == -1 )
|
1999-07-02 22:02:05 +00:00
|
|
|
m_windowId = (int)NewControlId();
|
1998-06-28 11:32:14 +00:00
|
|
|
else
|
1999-07-02 22:02:05 +00:00
|
|
|
m_windowId = id;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
|
|
|
int x = pos.x;
|
|
|
|
int y = pos.y;
|
|
|
|
int width = size.x;
|
|
|
|
int height = size.y;
|
|
|
|
|
2003-05-06 21:57:32 +00:00
|
|
|
WXDWORD exStyle = 0;
|
|
|
|
long msFlags = MSWGetStyle(style, & exStyle) ;
|
1999-05-06 08:31:56 +00:00
|
|
|
|
1999-05-05 08:57:41 +00:00
|
|
|
if (m_windowStyle & wxGA_VERTICAL)
|
|
|
|
msFlags |= PBS_VERTICAL;
|
|
|
|
|
|
|
|
if (m_windowStyle & wxGA_SMOOTH)
|
|
|
|
msFlags |= PBS_SMOOTH;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
|
|
|
HWND wx_button =
|
2003-05-06 21:57:32 +00:00
|
|
|
CreateWindowEx(exStyle, PROGRESS_CLASS, NULL, msFlags,
|
1998-06-28 11:32:14 +00:00
|
|
|
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
|
|
|
|
wxGetInstance(), NULL);
|
|
|
|
|
|
|
|
m_hWnd = (WXHWND)wx_button;
|
|
|
|
|
2001-02-07 16:12:56 +00:00
|
|
|
SetBackgroundColour(parent->GetBackgroundColour());
|
|
|
|
SetForegroundColour(parent->GetForegroundColour());
|
|
|
|
|
1998-06-28 11:32:14 +00:00
|
|
|
// Subclass again for purposes of dialog editing mode
|
|
|
|
SubclassWin((WXHWND) wx_button);
|
|
|
|
|
|
|
|
SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, range));
|
|
|
|
|
1998-12-08 23:26:18 +00:00
|
|
|
SetFont(parent->GetFont());
|
1998-06-28 11:32:14 +00:00
|
|
|
|
|
|
|
if (width == -1)
|
|
|
|
width = 50;
|
|
|
|
if (height == -1)
|
1998-12-11 15:41:28 +00:00
|
|
|
height = 28;
|
1998-06-28 11:32:14 +00:00
|
|
|
SetSize(x, y, width, height);
|
|
|
|
|
|
|
|
ShowWindow((HWND) GetHWND(), SW_SHOW);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-05-02 19:48:15 +00:00
|
|
|
void wxGauge95::SetShadowWidth(int WXUNUSED(w))
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-05-02 19:48:15 +00:00
|
|
|
void wxGauge95::SetBezelFace(int WXUNUSED(w))
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
void wxGauge95::SetRange(int r)
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
m_rangeMax = r;
|
|
|
|
|
|
|
|
SendMessage((HWND) GetHWND(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
|
|
|
|
}
|
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
void wxGauge95::SetValue(int pos)
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
m_gaugePos = pos;
|
|
|
|
|
|
|
|
SendMessage((HWND) GetHWND(), PBM_SETPOS, pos, 0);
|
|
|
|
}
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
int wxGauge95::GetShadowWidth() const
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
int wxGauge95::GetBezelFace() const
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
int wxGauge95::GetRange() const
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
return m_rangeMax;
|
|
|
|
}
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
int wxGauge95::GetValue() const
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
|
|
|
return m_gaugePos;
|
|
|
|
}
|
|
|
|
|
1999-05-10 00:42:57 +00:00
|
|
|
bool wxGauge95::SetForegroundColour(const wxColour& col)
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
1999-05-10 00:42:57 +00:00
|
|
|
if ( !wxControl::SetForegroundColour(col) )
|
|
|
|
return FALSE;
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col));
|
1999-05-10 00:42:57 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
1999-05-10 00:42:57 +00:00
|
|
|
bool wxGauge95::SetBackgroundColour(const wxColour& col)
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
1999-05-10 00:42:57 +00:00
|
|
|
if ( !wxControl::SetBackgroundColour(col) )
|
|
|
|
return FALSE;
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col));
|
1999-05-10 00:42:57 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#endif // wxUSE_GAUGE
|