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
|
2004-05-23 20:53:33 +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
|
|
|
// 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
|
|
|
|
|
2006-04-18 09:56:17 +00:00
|
|
|
#if wxUSE_GAUGE
|
|
|
|
|
2006-06-06 22:02:01 +00:00
|
|
|
#include "wx/gauge.h"
|
|
|
|
|
1998-06-28 11:32:14 +00:00
|
|
|
#ifndef WX_PRECOMP
|
2006-09-07 19:01:45 +00:00
|
|
|
#include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
|
1998-06-28 11:32:14 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/msw/private.h"
|
|
|
|
|
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
|
|
|
|
|
2006-09-09 13:36:54 +00:00
|
|
|
#ifndef PBS_MARQUEE
|
|
|
|
#define PBS_MARQUEE 0x08
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PBM_SETMARQUEE
|
|
|
|
#define PBM_SETMARQUEE (WM_USER+10)
|
|
|
|
#endif
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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)
|
2004-08-26 08:46:18 +00:00
|
|
|
|
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)
|
2006-04-14 17:01:16 +00:00
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
2003-09-04 01:19:40 +00:00
|
|
|
wxFLAGS_MEMBER(wxGA_PROGRESSBAR)
|
2006-04-14 17:01:16 +00:00
|
|
|
#endif // WXWIN_COMPATIBILITY_2_6
|
2003-09-04 01:19:40 +00:00
|
|
|
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
|
|
|
|
2004-08-26 08:46:18 +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
|
|
|
|
2006-09-09 13:36:54 +00:00
|
|
|
// in case we need to emulate indeterminate mode...
|
|
|
|
m_nDirection = wxRIGHT;
|
|
|
|
|
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-05-04 02:38:09 +00:00
|
|
|
if (HasFlag(wxGA_VERTICAL))
|
|
|
|
return wxSize(28, 100);
|
2004-04-17 02:00:24 +00:00
|
|
|
else
|
2004-05-04 02:38:09 +00:00
|
|
|
return wxSize(100, 28);
|
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
|
|
|
{
|
2006-09-09 13:36:54 +00:00
|
|
|
// switch to determinate mode if required
|
|
|
|
SetDeterminateMode();
|
|
|
|
|
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
|
|
|
{
|
2006-09-09 13:36:54 +00:00
|
|
|
// switch to determinate mode if required
|
|
|
|
SetDeterminateMode();
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-09-09 13:36:54 +00:00
|
|
|
void wxGauge95::SetIndeterminateMode()
|
|
|
|
{
|
|
|
|
// add the PBS_MARQUEE style to the progress bar
|
|
|
|
LONG style = ::GetWindowLong(GetHwnd(), GWL_STYLE);
|
|
|
|
if ((style & PBS_MARQUEE) == 0)
|
|
|
|
::SetWindowLong(GetHwnd(), GWL_STYLE, style|PBS_MARQUEE);
|
|
|
|
|
|
|
|
// now the control can only run in indeterminate mode
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxGauge95::SetDeterminateMode()
|
|
|
|
{
|
|
|
|
// remove the PBS_MARQUEE style to the progress bar
|
|
|
|
LONG style = ::GetWindowLong(GetHwnd(), GWL_STYLE);
|
|
|
|
if ((style & PBS_MARQUEE) != 0)
|
|
|
|
::SetWindowLong(GetHwnd(), GWL_STYLE, style & ~PBS_MARQUEE);
|
|
|
|
|
|
|
|
// now the control can only run in determinate mode
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxGauge95::Pulse()
|
|
|
|
{
|
|
|
|
if (wxApp::GetComCtl32Version() >= 600)
|
|
|
|
{
|
|
|
|
// switch to indeterminate mode if required
|
|
|
|
SetIndeterminateMode();
|
|
|
|
|
|
|
|
// NOTE: when in indeterminate mode, the PBM_SETPOS message will just make
|
|
|
|
// the bar's blocks move a bit and the WPARAM value is just ignored
|
|
|
|
// so that we can safely use zero
|
|
|
|
SendMessage(GetHwnd(), (UINT) PBM_SETPOS, (WPARAM)0, (LPARAM)0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// emulate indeterminate mode
|
|
|
|
wxGaugeBase::Pulse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#endif // wxUSE_GAUGE
|