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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-08-09 12:46:53 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
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__
|
2003-09-22 12:31:58 +00:00
|
|
|
#pragma hdrstop
|
1998-06-28 11:32:14 +00:00
|
|
|
#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
|
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
#if wxUSE_GAUGE
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-28 13:57:52 +00:00
|
|
|
#include "wx/gauge.h"
|
1998-06-28 11:32:14 +00:00
|
|
|
#include "wx/msw/private.h"
|
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
#if !(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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-08-14 18:05:30 +00:00
|
|
|
#if wxUSE_EXTENDED_RTTI
|
2003-08-24 11:35:44 +00:00
|
|
|
WX_DEFINE_FLAGS( wxGaugeStyle )
|
|
|
|
|
2003-09-04 01:19:40 +00:00
|
|
|
wxBEGIN_FLAGS( wxGaugeStyle )
|
2003-08-24 11:35:44 +00:00
|
|
|
// new style border flags, we put them first to
|
|
|
|
// use them for streaming out
|
2003-09-04 01:19:40 +00:00
|
|
|
wxFLAGS_MEMBER(wxBORDER_SIMPLE)
|
|
|
|
wxFLAGS_MEMBER(wxBORDER_SUNKEN)
|
|
|
|
wxFLAGS_MEMBER(wxBORDER_DOUBLE)
|
|
|
|
wxFLAGS_MEMBER(wxBORDER_RAISED)
|
|
|
|
wxFLAGS_MEMBER(wxBORDER_STATIC)
|
|
|
|
wxFLAGS_MEMBER(wxBORDER_NONE)
|
2003-08-24 11:35:44 +00:00
|
|
|
|
|
|
|
// old style border flags
|
2003-09-04 01:19:40 +00:00
|
|
|
wxFLAGS_MEMBER(wxSIMPLE_BORDER)
|
|
|
|
wxFLAGS_MEMBER(wxSUNKEN_BORDER)
|
|
|
|
wxFLAGS_MEMBER(wxDOUBLE_BORDER)
|
|
|
|
wxFLAGS_MEMBER(wxRAISED_BORDER)
|
|
|
|
wxFLAGS_MEMBER(wxSTATIC_BORDER)
|
2003-09-24 00:41:06 +00:00
|
|
|
wxFLAGS_MEMBER(wxBORDER)
|
2003-08-24 11:35:44 +00:00
|
|
|
|
|
|
|
// standard window styles
|
2003-09-04 01:19:40 +00:00
|
|
|
wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
|
|
|
|
wxFLAGS_MEMBER(wxCLIP_CHILDREN)
|
|
|
|
wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
|
|
|
|
wxFLAGS_MEMBER(wxWANTS_CHARS)
|
2003-09-24 00:41:06 +00:00
|
|
|
wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
|
2003-09-04 01:19:40 +00:00
|
|
|
wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
|
|
|
|
wxFLAGS_MEMBER(wxVSCROLL)
|
|
|
|
wxFLAGS_MEMBER(wxHSCROLL)
|
|
|
|
|
|
|
|
wxFLAGS_MEMBER(wxGA_HORIZONTAL)
|
|
|
|
wxFLAGS_MEMBER(wxGA_VERTICAL)
|
|
|
|
wxFLAGS_MEMBER(wxGA_PROGRESSBAR)
|
|
|
|
wxFLAGS_MEMBER(wxGA_SMOOTH)
|
|
|
|
|
|
|
|
wxEND_FLAGS( wxGaugeStyle )
|
2003-08-24 11:35:44 +00:00
|
|
|
|
2003-08-19 16:44:01 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl,"wx/gauge.h")
|
2003-08-14 18:05:30 +00:00
|
|
|
|
2003-09-04 01:19:40 +00:00
|
|
|
wxBEGIN_PROPERTIES_TABLE(wxGauge95)
|
2003-09-22 12:31:58 +00:00
|
|
|
wxPROPERTY( Value , int , SetValue, GetValue, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
|
|
|
|
wxPROPERTY( Range , int , SetRange, GetRange, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
|
|
|
|
wxPROPERTY( ShadowWidth , int , SetShadowWidth, GetShadowWidth, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
|
|
|
|
wxPROPERTY( BezelFace , int , SetBezelFace, GetBezelFace, 0 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
|
2004-04-15 22:51:57 +00:00
|
|
|
wxPROPERTY_FLAGS( WindowStyle , wxGaugeStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
|
2003-09-04 01:19:40 +00:00
|
|
|
wxEND_PROPERTIES_TABLE()
|
2003-08-14 18:05:30 +00:00
|
|
|
|
2003-09-04 01:19:40 +00:00
|
|
|
wxBEGIN_HANDLERS_TABLE(wxGauge95)
|
|
|
|
wxEND_HANDLERS_TABLE()
|
2003-08-14 18:05:30 +00:00
|
|
|
|
2003-09-04 01:19:40 +00:00
|
|
|
wxCONSTRUCTOR_6( wxGauge95 , wxWindow* , Parent , wxWindowID , Id , int , Range , wxPoint , Position , wxSize , Size , long , WindowStyle )
|
2003-08-14 18:05:30 +00:00
|
|
|
#else
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxGauge95, wxControl)
|
|
|
|
#endif
|
2003-08-05 17:30:46 +00:00
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ============================================================================
|
2003-09-22 12:31:58 +00:00
|
|
|
// wxGauge95 implementation
|
2000-07-15 19:51:35 +00:00
|
|
|
// ============================================================================
|
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGauge95 creation
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
bool wxGauge95::Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
int range,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style,
|
|
|
|
const wxValidator& validator,
|
|
|
|
const wxString& name)
|
|
|
|
{
|
|
|
|
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
|
|
|
|
return false;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
if ( !MSWCreateControl(PROGRESS_CLASS, wxEmptyString, pos, size) )
|
|
|
|
return false;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
SetRange(range);
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
WXDWORD wxGauge95::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|
|
|
{
|
|
|
|
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
if ( style & wxGA_VERTICAL )
|
|
|
|
msStyle |= PBS_VERTICAL;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
if ( style & wxGA_SMOOTH )
|
|
|
|
msStyle |= PBS_SMOOTH;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
return msStyle;
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGauge95 geometry
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
wxSize wxGauge95::DoGetBestSize() const
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
2003-09-22 12:31:58 +00:00
|
|
|
// VZ: no idea where does 28 come from, it was there before my changes and
|
|
|
|
// as nobody ever complained I guess we can leave it...
|
2004-04-17 02:00:24 +00:00
|
|
|
if (HasFlag(wxGA_HORIZONTAL))
|
|
|
|
return wxSize(100, 28);
|
|
|
|
else
|
|
|
|
return wxSize(28,100);
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGauge95 setters
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
void wxGauge95::SetRange(int r)
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
2003-09-22 12:31:58 +00:00
|
|
|
m_rangeMax = r;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 11:36:48 +00:00
|
|
|
#ifdef PBM_SETRANGE32
|
2003-09-22 12:31:58 +00:00
|
|
|
::SendMessage(GetHwnd(), PBM_SETRANGE32, 0, r);
|
2003-09-22 11:36:48 +00:00
|
|
|
#else // !PBM_SETRANGE32
|
2003-09-22 12:31:58 +00:00
|
|
|
// fall back to PBM_SETRANGE (limited to 16 bits)
|
|
|
|
::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
|
2003-09-22 11:36:48 +00:00
|
|
|
#endif // PBM_SETRANGE32/!PBM_SETRANGE32
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
void wxGauge95::SetValue(int pos)
|
1998-06-28 11:32:14 +00:00
|
|
|
{
|
2003-09-22 12:31:58 +00:00
|
|
|
m_gaugePos = pos;
|
1998-06-28 11:32:14 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0);
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
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) )
|
2003-09-22 12:31:58 +00:00
|
|
|
return false;
|
1999-05-10 00:42:57 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
::SendMessage(GetHwnd(), PBM_SETBARCOLOR, 0, (LPARAM)wxColourToRGB(col));
|
1999-05-10 00:42:57 +00:00
|
|
|
|
2003-09-22 12:31:58 +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) )
|
2003-09-22 12:31:58 +00:00
|
|
|
return false;
|
1999-05-10 00:42:57 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
::SendMessage(GetHwnd(), PBM_SETBKCOLOR, 0, (LPARAM)wxColourToRGB(col));
|
1999-05-10 00:42:57 +00:00
|
|
|
|
2003-09-22 12:31:58 +00:00
|
|
|
return true;
|
1998-06-28 11:32:14 +00:00
|
|
|
}
|
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#endif // wxUSE_GAUGE
|
2003-09-22 12:31:58 +00:00
|
|
|
|