Add wxSystemThemedControl and use it in wxMSW
wxSystemThemedControl allows to use the "system theme" (i.e. the theme used by the system applications such as file manager and which can, surprisingly, be different from the default one). Currently it is only implemented for wxMSW and does nothing under the other platforms. Use wxSystemThemedControl for wxDataViewCtrl, wxListCtrl and, optionally, if wxTR_TWIST_BUTTONS style is specified, wxTreeCtrl to give them more native appearance under MSW. Closes #16414.
This commit is contained in:
committed by
Vadim Zeitlin
parent
b7a89f8746
commit
2fff3cd29f
@@ -907,6 +907,11 @@ wxEventType wxEVT_DATAVIEW_ITEM_DROP;
|
||||
you need to handle any mouse events not covered by the ones above, consider
|
||||
using a custom renderer for the cells that must handle them.
|
||||
|
||||
@note Under wxMSW this control uses wxSystemThemedControl for an explorer
|
||||
style appearance by default since wxWidgets 3.1.0. If this is not desired,
|
||||
you can call wxSystemThemedControl::EnableSystemTheme with @c false
|
||||
argument to disable this.
|
||||
|
||||
@library{wxadv}
|
||||
@category{ctrl,dvc}
|
||||
@appearance{dataviewctrl}
|
||||
|
@@ -258,6 +258,10 @@ enum
|
||||
Processes a @c wxEVT_LIST_CACHE_HINT event type.
|
||||
@endEventTable
|
||||
|
||||
@note Under wxMSW this control uses wxSystemThemedControl for an explorer
|
||||
style appearance by default since wxWidgets 3.1.0. If this is not desired,
|
||||
you can call wxSystemThemedControl::EnableSystemTheme with @c false
|
||||
argument to disable this.
|
||||
|
||||
@library{wxcore}
|
||||
@category{ctrl}
|
||||
|
70
interface/wx/systhemectrl.h
Normal file
70
interface/wx/systhemectrl.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/systhemectrl.h
|
||||
// Purpose: Documentation for wxSystemThemedControl
|
||||
// Author: Tobias Taschner
|
||||
// Created: 2014-08-15
|
||||
// Copyright: (c) 2014 wxWidgets development team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
A helper class making it possible to use system theme for any control.
|
||||
|
||||
Under MSW, there an alternative theme available for the list and list-like
|
||||
controls since Windows Vista. This theme us used by Windows Explorer list
|
||||
and tree view and so is arguably more familiar to the users than the standard
|
||||
appearance of these controls.
|
||||
|
||||
This class is used in wxWidgets to enable this system theme in wxTreeCtrl,
|
||||
wxListCtrl and wxDataViewCtrl and thus give them the same, familiar look.
|
||||
It can also be used as a helper for implementing custom controls with the same
|
||||
appearance. Notice that when using this class it is especially important
|
||||
to use wxRendererNative::DrawItemSelectionRect() and
|
||||
wxRendererNative::DrawItemText() to draw the control items to ensure that
|
||||
they appear correctly under all platforms and Windows versions.
|
||||
|
||||
The following example shows implementation of a system theme enabled wxVListBox:
|
||||
@code
|
||||
#include <wx/systhemectrl.h>
|
||||
|
||||
class MyListCtrl : public wxSystemThemedControl<wxVListBox>
|
||||
{
|
||||
public:
|
||||
MyListCtrl(wxWindow* parent)
|
||||
{
|
||||
|
||||
...
|
||||
|
||||
EnableSystemTheme();
|
||||
}
|
||||
|
||||
void OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const wxOVERRIDE
|
||||
{
|
||||
wxRendererNative::GetDefault().DrawItemText(this, dc, "Item #x", rect);
|
||||
}
|
||||
};
|
||||
@endcode
|
||||
|
||||
On non-MSW platforms this class currently does nothing but is still
|
||||
available, so that it can be used in portable code without any conditional
|
||||
compilation directives.
|
||||
|
||||
@category{miscwnd}
|
||||
|
||||
@see wxTreeCtrl, wxListCtrl, wxDataViewCtrl, wxRendererNative
|
||||
|
||||
@since 3.1.0
|
||||
*/
|
||||
template <class C>
|
||||
class wxSystemThemedControl : public C
|
||||
{
|
||||
public:
|
||||
/// Trival default constructor.
|
||||
wxSystemThemedControl();
|
||||
|
||||
/**
|
||||
This method may be called to disable the system theme of controls
|
||||
using it by default.
|
||||
*/
|
||||
void EnableSystemTheme(bool enable = true);
|
||||
};
|
@@ -32,10 +32,8 @@
|
||||
Selects alternative style of @c +/@c - buttons and shows rotating
|
||||
("twisting") arrows instead. Currently this style is only implemented
|
||||
under Microsoft Windows Vista and later Windows versions and is ignored
|
||||
under the other platforms. Notice that under Vista this style results
|
||||
in the same appearance as used by the tree control in Explorer and
|
||||
other built-in programs and so using it may be preferable to the
|
||||
default style.
|
||||
under the other platforms as enabling it is equivalent to using
|
||||
wxSystemThemedControl::EnableSystemTheme().
|
||||
@style{wxTR_NO_LINES}
|
||||
Use this style to hide vertical level connectors.
|
||||
@style{wxTR_FULL_ROW_HIGHLIGHT}
|
||||
|
Reference in New Issue
Block a user