wx/valnum.h \
wx/window.h \
wx/windowid.h \
+ wx/withimages.h \
wx/wrapsizer.h \
wx/wupdlock.h \
wx/accel.h \
wx/valnum.h
wx/window.h
wx/windowid.h
+ wx/withimages.h
wx/wrapsizer.h
wx/wupdlock.h
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\include\wx\withimages.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\wx\wizard.h\r
# End Source File\r
# Begin Source File\r
RelativePath="..\..\include\wx\windowid.h">\r
</File>\r
<File\r
+ RelativePath="..\..\include\wx\withimages.h">
+ </File>
+ <File
RelativePath="..\..\include\wx\wizard.h">\r
</File>\r
<File\r
>\r
</File>\r
<File\r
+ RelativePath="..\..\include\wx\withimages.h"
+ >
+ </File>
+ <File
RelativePath="..\..\include\wx\wizard.h"\r
>\r
</File>\r
>\r
</File>\r
<File\r
+ RelativePath="..\..\include\wx\withimages.h"
+ >
+ </File>
+ <File
RelativePath="..\..\include\wx\wizard.h"\r
>\r
</File>\r
#include "wx/control.h"
#include "wx/dynarray.h"
+#include "wx/withimages.h"
WX_DEFINE_EXPORTED_ARRAY_PTR(wxWindow *, wxArrayPages);
// wxBookCtrlBase
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxBookCtrlBase : public wxControl
+class WXDLLIMPEXP_CORE wxBookCtrlBase : public wxControl,
+ public wxWithImages
{
public:
// construction
long style = 0,
const wxString& name = wxEmptyString);
- // dtor
- virtual ~wxBookCtrlBase();
-
// accessors
// ---------
// images belong to the same image list)
// ---------------------------------------------------------------------
- // sets the image list to use, it is *not* deleted by the control
- virtual void SetImageList(wxImageList *imageList);
-
- // as SetImageList() but we will delete the image list ourselves
- void AssignImageList(wxImageList *imageList);
-
- // get pointer (may be NULL) to the associated image list
- wxImageList* GetImageList() const { return m_imageList; }
-
// sets/returns item's image index in the current image list
virtual int GetPageImage(size_t n) const = 0;
virtual bool SetPageImage(size_t n, int imageId) = 0;
// the array of all pages of this control
wxArrayPages m_pages;
- // the associated image list or NULL
- wxImageList *m_imageList;
-
- // true if we must delete m_imageList
- bool m_ownsImageList;
-
// get the page area
virtual wxRect GetPageRect() const;
#include "wx/weakref.h"
#include "wx/vector.h"
#include "wx/dataobj.h"
+#include "wx/withimages.h"
class WXDLLIMPEXP_FWD_CORE wxImageList;
//-----------------------------------------------------------------------------
-class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl
+class WXDLLIMPEXP_ADV wxDataViewTreeCtrl: public wxDataViewCtrl,
+ public wxWithImages
{
public:
- wxDataViewTreeCtrl() { Init(); }
+ wxDataViewTreeCtrl() { }
wxDataViewTreeCtrl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
long style = wxDV_NO_HEADER | wxDV_ROW_LINES,
const wxValidator& validator = wxDefaultValidator)
{
- Init();
-
Create(parent, id, pos, size, style, validator);
}
- virtual ~wxDataViewTreeCtrl();
-
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
bool IsContainer( const wxDataViewItem& item ) const
{ return GetStore()->IsContainer(item); }
- void SetImageList( wxImageList *imagelist );
- wxImageList* GetImageList() { return m_imageList; }
-
wxDataViewItem AppendItem( const wxDataViewItem& parent,
const wxString &text, int icon = -1, wxClientData *data = NULL );
wxDataViewItem PrependItem( const wxDataViewItem& parent,
void OnCollapsed( wxDataViewEvent &event );
void OnSize( wxSizeEvent &event );
-private:
- void Init()
- {
- m_imageList = NULL;
- }
-
- wxImageList *m_imageList;
-
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDataViewTreeCtrl)
#include "wx/propdlg.h"
#include "wx/bookctrl.h"
+#include "wx/withimages.h"
#if wxUSE_HTML
#include "wx/htmllbox.h"
#include "wx/richtext/richtextuicustomization.h"
class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFormattingDialog;
-class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxComboBox;
class WXDLLIMPEXP_FWD_CORE wxCheckBox;
* Formatting dialog for a wxRichTextCtrl
*/
-class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog: public wxPropertySheetDialog
+class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog: public wxPropertySheetDialog,
+ public wxWithImages
{
DECLARE_CLASS(wxRichTextFormattingDialog)
DECLARE_HELP_PROVISION()
void OnHelp(wxCommandEvent& event);
void OnUpdateHelp(wxUpdateUIEvent& event);
- /// Set/get image list
- void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
- wxImageList* GetImageList() const { return m_imageList; }
-
/// Get/set formatting factory object
static void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory);
static wxRichTextFormattingDialogFactory* GetFormattingDialogFactory() { return ms_FormattingDialogFactory; }
protected:
- wxImageList* m_imageList;
wxRichTextAttr m_attributes;
//wxRichTextAttr m_resetAttributes;
wxRichTextStyleDefinition* m_styleDefinition;
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: wx/withimages.h
+// Purpose: Declaration of a simple wxWithImages class.
+// Author: Vadim Zeitlin
+// Created: 2011-08-17
+// RCS-ID: $Id: wxhead.h,v 1.12 2010-04-22 12:44:51 zeitlin Exp $
+// Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_WITHIMAGES_H_
+#define _WX_WITHIMAGES_H_
+
+#include "wx/defs.h"
+#include "wx/imaglist.h"
+
+// ----------------------------------------------------------------------------
+// wxWithImages: mix-in class providing access to wxImageList.
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxWithImages
+{
+public:
+ wxWithImages()
+ {
+ m_imageList = NULL;
+ m_ownsImageList = false;
+ }
+
+ virtual ~wxWithImages()
+ {
+ FreeIfNeeded();
+ }
+
+ // Sets the image list to use, it is *not* deleted by the control.
+ virtual void SetImageList(wxImageList* imageList)
+ {
+ FreeIfNeeded();
+ m_imageList = imageList;
+ }
+
+ // As SetImageList() but we will delete the image list ourselves.
+ void AssignImageList(wxImageList* imageList)
+ {
+ SetImageList(imageList);
+ m_ownsImageList = true;
+ }
+
+ // Get pointer (may be NULL) to the associated image list.
+ wxImageList* GetImageList() const { return m_imageList; }
+
+protected:
+ // Return true if we have a valid image list.
+ bool HasImageList() const { return m_imageList != NULL; }
+
+ // Return the image with the given index from the image list.
+ //
+ // If there is no image list or if index == -1 (which traditionally means
+ // that no image should be used for the given item), silently returns
+ // wxNullIcon.
+ wxIcon GetImage(int iconIndex) const
+ {
+ return m_imageList && iconIndex != -1 ? m_imageList->GetIcon(iconIndex)
+ : wxNullIcon;
+ }
+
+private:
+ // Free the image list if necessary, i.e. if we own it.
+ void FreeIfNeeded()
+ {
+ if ( m_ownsImageList )
+ {
+ delete m_imageList;
+ m_imageList = NULL;
+
+ // We don't own it any more.
+ m_ownsImageList = false;
+ }
+ }
+
+
+ // The associated image list or NULL.
+ wxImageList* m_imageList;
+
+ // False by default, if true then we delete m_imageList.
+ bool m_ownsImageList;
+
+ wxDECLARE_NO_COPY_CLASS(wxWithImages);
+};
+
+#endif // _WX_WITHIMAGES_H_
wxImageList *ilist = new wxImageList( 16, 16 );
ilist->Add( wxIcon(wx_small_xpm) );
- tc->SetImageList( ilist );
+ tc->AssignImageList( ilist );
wxDataViewItem parent =
tc->AppendContainer( wxDataViewItem(0), "The Root", 0 );
{
m_selection = wxNOT_FOUND;
m_bookctrl = NULL;
- m_imageList = NULL;
- m_ownsImageList = false;
m_fitToCurrentPage = false;
#if defined(__WXWINCE__)
);
}
-wxBookCtrlBase::~wxBookCtrlBase()
-{
- if ( m_ownsImageList )
- {
- // may be NULL, ok
- delete m_imageList;
- }
-}
-
-// ----------------------------------------------------------------------------
-// image list
-// ----------------------------------------------------------------------------
-
-void wxBookCtrlBase::SetImageList(wxImageList *imageList)
-{
- if ( m_ownsImageList )
- {
- // may be NULL, ok
- delete m_imageList;
-
- m_ownsImageList = false;
- }
-
- m_imageList = imageList;
-}
-
-void wxBookCtrlBase::AssignImageList(wxImageList* imageList)
-{
- SetImageList(imageList);
-
- m_ownsImageList = true;
-}
-
// ----------------------------------------------------------------------------
// geometry
// ----------------------------------------------------------------------------
EVT_SIZE( wxDataViewTreeCtrl::OnSize )
END_EVENT_TABLE()
-wxDataViewTreeCtrl::~wxDataViewTreeCtrl()
-{
- delete m_imageList;
-}
-
bool wxDataViewTreeCtrl::Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator )
{
return true;
}
-void wxDataViewTreeCtrl::SetImageList( wxImageList *imagelist )
-{
- delete m_imageList;
-
- m_imageList = imagelist;
-}
-
wxDataViewItem wxDataViewTreeCtrl::AppendItem( const wxDataViewItem& parent,
const wxString &text, int iconIndex, wxClientData *data )
{
- wxIcon icon = wxNullIcon;
- if (m_imageList && (iconIndex != -1))
- icon = m_imageList->GetIcon( iconIndex );
-
- wxDataViewItem res = GetStore()->AppendItem( parent, text, icon, data );
+ wxDataViewItem res = GetStore()->
+ AppendItem( parent, text, GetImage(iconIndex), data );
GetStore()->ItemAdded( parent, res );
wxDataViewItem wxDataViewTreeCtrl::PrependItem( const wxDataViewItem& parent,
const wxString &text, int iconIndex, wxClientData *data )
{
- wxIcon icon = wxNullIcon;
- if (m_imageList && (iconIndex != -1))
- icon = m_imageList->GetIcon( iconIndex );
-
- wxDataViewItem res = GetStore()->PrependItem( parent, text, icon, data );
+ wxDataViewItem res = GetStore()->
+ PrependItem( parent, text, GetImage(iconIndex), data );
GetStore()->ItemAdded( parent, res );
wxDataViewItem wxDataViewTreeCtrl::InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
const wxString &text, int iconIndex, wxClientData *data )
{
- wxIcon icon = wxNullIcon;
- if (m_imageList && (iconIndex != -1))
- icon = m_imageList->GetIcon( iconIndex );
-
- wxDataViewItem res = GetStore()->InsertItem( parent, previous, text, icon, data );
+ wxDataViewItem res = GetStore()->
+ InsertItem( parent, previous, text, GetImage(iconIndex), data );
GetStore()->ItemAdded( parent, res );
wxDataViewItem wxDataViewTreeCtrl::PrependContainer( const wxDataViewItem& parent,
const wxString &text, int iconIndex, int expandedIndex, wxClientData *data )
{
- wxIcon icon = wxNullIcon;
- if (m_imageList && (iconIndex != -1))
- icon = m_imageList->GetIcon( iconIndex );
-
- wxIcon expanded = wxNullIcon;
- if (m_imageList && (expandedIndex != -1))
- expanded = m_imageList->GetIcon( expandedIndex );
-
- wxDataViewItem res = GetStore()->PrependContainer( parent, text, icon, expanded, data );
+ wxDataViewItem res = GetStore()->
+ PrependContainer( parent, text,
+ GetImage(iconIndex), GetImage(expandedIndex), data );
GetStore()->ItemAdded( parent, res );
wxDataViewItem wxDataViewTreeCtrl::AppendContainer( const wxDataViewItem& parent,
const wxString &text, int iconIndex, int expandedIndex, wxClientData *data )
{
- wxIcon icon = wxNullIcon;
- if (m_imageList && (iconIndex != -1))
- icon = m_imageList->GetIcon( iconIndex );
-
- wxIcon expanded = wxNullIcon;
- if (m_imageList && (expandedIndex != -1))
- expanded = m_imageList->GetIcon( expandedIndex );
-
- wxDataViewItem res = GetStore()->AppendContainer( parent, text, icon, expanded, data );
+ wxDataViewItem res = GetStore()->
+ AppendContainer( parent, text,
+ GetImage(iconIndex), GetImage(expandedIndex), data );
GetStore()->ItemAdded( parent, res );
wxDataViewItem wxDataViewTreeCtrl::InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
const wxString &text, int iconIndex, int expandedIndex, wxClientData *data )
{
- wxIcon icon = wxNullIcon;
- if (m_imageList && (iconIndex != -1))
- icon = m_imageList->GetIcon( iconIndex );
-
- wxIcon expanded = wxNullIcon;
- if (m_imageList && (expandedIndex != -1))
- expanded = m_imageList->GetIcon( expandedIndex );
-
- wxDataViewItem res = GetStore()->InsertContainer( parent, previous, text, icon, expanded, data );
+ wxDataViewItem res = GetStore()->
+ InsertContainer( parent, previous, text,
+ GetImage(iconIndex), GetImage(expandedIndex), data );
GetStore()->ItemAdded( parent, res );
void wxDataViewTreeCtrl::OnExpanded( wxDataViewEvent &event )
{
- if (m_imageList) return;
+ if (HasImageList()) return;
wxDataViewTreeStoreContainerNode* container = GetStore()->FindContainerNode( event.GetItem() );
if (!container) return;
void wxDataViewTreeCtrl::OnCollapsed( wxDataViewEvent &event )
{
- if (m_imageList) return;
+ if (HasImageList()) return;
wxDataViewTreeStoreContainerNode* container = GetStore()->FindContainerNode( event.GetItem() );
if (!container) return;
wxGtkNotebookPage* pageData = GetNotebookPage(page);
if (image >= 0)
{
- wxCHECK_MSG(m_imageList, false, "invalid notebook imagelist");
- const wxBitmap* bitmap = m_imageList->GetBitmapPtr(image);
+ wxCHECK_MSG(HasImageList(), false, "invalid notebook imagelist");
+ const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(image);
if (bitmap == NULL)
return false;
if (pageData->m_image)
pageData->m_image = NULL;
if (imageId != -1)
{
- if (m_imageList)
+ if (HasImageList())
{
- const wxBitmap* bitmap = m_imageList->GetBitmapPtr(imageId);
+ const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId);
pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
gtk_box_pack_start(GTK_BOX(pageData->m_box),
pageData->m_image, false, false, m_padding);
// common part of all ctors
void wxNotebook::Init()
{
- m_imageList = NULL;
-
#if wxUSE_UXTHEME
m_hbrBackground = NULL;
#endif // wxUSE_UXTHEME
{
wxCHECK_MSG( IS_VALID_PAGE(nPage), false,
wxT("SetPageImage: invalid notebook page") );
- wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false,
+ wxCHECK_MSG( HasImageList() && nImage < GetImageList()->GetImageCount(), false,
wxT("SetPageImage: invalid image index") );
if ( nImage != m_images[nPage] )
void wxRichTextFormattingDialog::Init()
{
- m_imageList = NULL;
m_styleDefinition = NULL;
m_styleSheet = NULL;
m_object = NULL;
wxRichTextFormattingDialog::~wxRichTextFormattingDialog()
{
- delete m_imageList;
delete m_styleDefinition;
}