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:
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
|
||||
|
Reference in New Issue
Block a user