Add wxActivityIndicator control.
This is a simple animated control indicating some program activity. Provide native GTK+ (for > 2.20) and OS X implementations as well as a generic one used under MSW. Update the sample and the documentation.
This commit is contained in:
60
include/wx/activityindicator.h
Normal file
60
include/wx/activityindicator.h
Normal file
@@ -0,0 +1,60 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/activityindicator.h
|
||||
// Purpose: wxActivityIndicator declaration.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2015-03-05
|
||||
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_ACTIVITYINDICATOR_H_
|
||||
#define _WX_ACTIVITYINDICATOR_H_
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_ACTIVITYINDICATOR
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
#define wxActivityIndicatorNameStr wxS("activityindicator")
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxActivityIndicator: small animated indicator of some application activity.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxActivityIndicatorBase : public wxControl
|
||||
{
|
||||
public:
|
||||
// Start or stop the activity animation (it is stopped initially).
|
||||
virtual void Start() = 0;
|
||||
virtual void Stop() = 0;
|
||||
|
||||
// Return true if the control is currently showing activity.
|
||||
virtual bool IsRunning() const = 0;
|
||||
|
||||
// Override some base class virtual methods.
|
||||
virtual bool AcceptsFocus() const wxOVERRIDE { return false; }
|
||||
virtual bool HasTransparentBackground() wxOVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
// choose the default border for this window
|
||||
virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; }
|
||||
};
|
||||
|
||||
#ifndef __WXUNIVERSAL__
|
||||
#if defined(__WXGTK220__)
|
||||
#define wxHAS_NATIVE_ACTIVITYINDICATOR
|
||||
#include "wx/gtk/activityindicator.h"
|
||||
#elif defined(__WXOSX_COCOA__)
|
||||
#define wxHAS_NATIVE_ACTIVITYINDICATOR
|
||||
#include "wx/osx/activityindicator.h"
|
||||
#endif
|
||||
#endif // !__WXUNIVERSAL__
|
||||
|
||||
#ifndef wxHAS_NATIVE_ACTIVITYINDICATOR
|
||||
#include "wx/generic/activityindicator.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_ACTIVITYINDICATOR
|
||||
|
||||
#endif // _WX_ACTIVITYINDICATOR_H_
|
@@ -823,6 +823,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
@@ -433,6 +433,14 @@
|
||||
# endif
|
||||
#endif /* !defined(wxUSE_ADDREMOVECTRL) */
|
||||
|
||||
#ifndef wxUSE_ACTIVITYINDICATOR
|
||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||
# error "wxUSE_ACTIVITYINDICATOR must be defined, please read comment near the top of this file."
|
||||
# else
|
||||
# define wxUSE_ACTIVITYINDICATOR 0
|
||||
# endif
|
||||
#endif /* !defined(wxUSE_ACTIVITYINDICATOR) */
|
||||
|
||||
#ifndef wxUSE_ANIMATIONCTRL
|
||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||
# error "wxUSE_ANIMATIONCTRL must be defined, please read comment near the top of this file."
|
||||
|
67
include/wx/generic/activityindicator.h
Normal file
67
include/wx/generic/activityindicator.h
Normal file
@@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/generic/activityindicator.h
|
||||
// Purpose: Declaration of wxActivityIndicatorGeneric.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2015-03-06
|
||||
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GENERIC_ACTIVITYINDICATOR_H_
|
||||
#define _WX_GENERIC_ACTIVITYINDICATOR_H_
|
||||
|
||||
#ifndef wxHAS_NATIVE_ACTIVITYINDICATOR
|
||||
// This is the only implementation we have, so call it accordingly.
|
||||
#define wxActivityIndicatorGeneric wxActivityIndicator
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxActivityIndicatorGeneric: built-in generic implementation.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxActivityIndicatorGeneric : public wxActivityIndicatorBase
|
||||
{
|
||||
public:
|
||||
wxActivityIndicatorGeneric()
|
||||
{
|
||||
m_impl = NULL;
|
||||
}
|
||||
|
||||
explicit
|
||||
wxActivityIndicatorGeneric(wxWindow* parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxActivityIndicatorNameStr)
|
||||
{
|
||||
m_impl = NULL;
|
||||
|
||||
Create(parent, winid, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow* parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxActivityIndicatorNameStr);
|
||||
|
||||
virtual ~wxActivityIndicatorGeneric();
|
||||
|
||||
virtual void Start() wxOVERRIDE;
|
||||
virtual void Stop() wxOVERRIDE;
|
||||
virtual bool IsRunning() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
class wxActivityIndicatorImpl *m_impl;
|
||||
|
||||
#ifndef wxHAS_NATIVE_ACTIVITYINDICATOR
|
||||
wxDECLARE_DYNAMIC_CLASS(wxActivityIndicator);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _WX_GENERIC_ACTIVITYINDICATOR_H_
|
66
include/wx/gtk/activityindicator.h
Normal file
66
include/wx/gtk/activityindicator.h
Normal file
@@ -0,0 +1,66 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/gtk/activityindicator.h
|
||||
// Purpose: Declaration of wxActivityIndicator for wxGTK.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2015-03-05
|
||||
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GTK_ACTIVITYINDICATOR_H_
|
||||
#define _WX_GTK_ACTIVITYINDICATOR_H_
|
||||
|
||||
// With GTK+ 3 we can always be certain that this control is available, so use
|
||||
// the normal base class. With GTK+ 2 however, we may determine during run-time
|
||||
// that we need to fall back to the generic implementation because the GTK+
|
||||
// version is earlier than 2.20, so we need to inherit from the generic class.
|
||||
#ifdef __WXGTK3__
|
||||
#define wxActivityIndicatorGtkBase wxActivityIndicatorBase
|
||||
#else
|
||||
#include "wx/generic/activityindicator.h"
|
||||
|
||||
#define wxActivityIndicatorGtkBase wxActivityIndicatorGeneric
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxActivityIndicator: implementation using GtkSpinner.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxActivityIndicator : public wxActivityIndicatorGtkBase
|
||||
{
|
||||
public:
|
||||
wxActivityIndicator()
|
||||
{
|
||||
}
|
||||
|
||||
explicit
|
||||
wxActivityIndicator(wxWindow* parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxActivityIndicatorNameStr)
|
||||
{
|
||||
Create(parent, winid, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow* parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxActivityIndicatorNameStr);
|
||||
|
||||
virtual void Start() wxOVERRIDE;
|
||||
virtual void Stop() wxOVERRIDE;
|
||||
virtual bool IsRunning() const wxOVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestClientSize() const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS(wxActivityIndicator);
|
||||
wxDECLARE_NO_COPY_CLASS(wxActivityIndicator);
|
||||
};
|
||||
|
||||
#endif // _WX_GTK_ACTIVITYINDICATOR_H_
|
43
include/wx/gtk/private/value.h
Normal file
43
include/wx/gtk/private/value.h
Normal file
@@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/gtk/private/value.h
|
||||
// Purpose: Helper wrapper for working with GValue.
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2015-03-05
|
||||
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_GTK_PRIVATE_VALUE_H_
|
||||
#define _WX_GTK_PRIVATE_VALUE_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxGtkValue: RAII wrapper for GValue
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxGtkValue
|
||||
{
|
||||
public:
|
||||
// Initialize the value of the specified type.
|
||||
explicit wxGtkValue(GType gtype)
|
||||
: m_val(G_VALUE_INIT)
|
||||
{
|
||||
g_value_init(&m_val, gtype);
|
||||
}
|
||||
|
||||
~wxGtkValue()
|
||||
{
|
||||
g_value_unset(&m_val);
|
||||
}
|
||||
|
||||
// Unsafe but convenient access to the real value for GTK+ functions.
|
||||
operator GValue*() { return &m_val; }
|
||||
|
||||
private:
|
||||
GValue m_val;
|
||||
|
||||
// For now we just don't support copying at all for simplicity, it could be
|
||||
// implemented later if needed.
|
||||
wxDECLARE_NO_COPY_CLASS(wxGtkValue);
|
||||
};
|
||||
|
||||
#endif // _WX_GTK_PRIVATE_VALUE_H_
|
@@ -824,6 +824,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
@@ -824,6 +824,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
@@ -824,6 +824,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
@@ -824,6 +824,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
59
include/wx/osx/activityindicator.h
Normal file
59
include/wx/osx/activityindicator.h
Normal file
@@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/osx/activityindicator.h
|
||||
// Purpose: Declaration of wxActivityIndicator for wxOSX (Cocoa only).
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2015-03-08
|
||||
// Copyright: (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_OSX_ACTIVITYINDICATOR_H_
|
||||
#define _WX_OSX_ACTIVITYINDICATOR_H_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxActivityIndicator: implementation using GtkSpinner.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxActivityIndicator : public wxActivityIndicatorBase
|
||||
{
|
||||
public:
|
||||
wxActivityIndicator()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
explicit
|
||||
wxActivityIndicator(wxWindow* parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxActivityIndicatorNameStr)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(parent, winid, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow* parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxActivityIndicatorNameStr);
|
||||
|
||||
virtual void Start() wxOVERRIDE;
|
||||
virtual void Stop() wxOVERRIDE;
|
||||
virtual bool IsRunning() const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
// Common part of all ctors.
|
||||
void Init() { m_isRunning = false; }
|
||||
|
||||
bool m_isRunning;
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS(wxActivityIndicator);
|
||||
wxDECLARE_NO_COPY_CLASS(wxActivityIndicator);
|
||||
};
|
||||
|
||||
#endif // _WX_OSX_ACTIVITYINDICATOR_H_
|
@@ -825,6 +825,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
@@ -820,6 +820,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
@@ -823,6 +823,7 @@
|
||||
// Default is 1
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_ACTIVITYINDICATOR 1 // wxActivityIndicator
|
||||
#define wxUSE_ANIMATIONCTRL 1 // wxAnimationCtrl
|
||||
#define wxUSE_BANNERWINDOW 1 // wxBannerWindow
|
||||
#define wxUSE_BUTTON 1 // wxButton
|
||||
|
Reference in New Issue
Block a user