All (GUI):
+- Support loading wxListCtrl items and image lists from XRC (Kinaou Hervé).
- wxGrid: add possibility to prevent resizing of individual rows/columns.
- wxHTML: add support for table borders width (Laurent Humbertclaude).
- Added wxMouseEventsManager.
</object>
</object>
<label>Page</label>
+ <image>0</image>
</object>
<object class="notebookpage">
<object class="wxPanel">
</object>
</object>
<label>Page 2</label>
+ <image>1</image>
</object>
<usenotebooksizer>1</usenotebooksizer>
+ <imagelist>
+ <size>16,16</size>
+ <bitmap stock_id="wxART_QUESTION"/>
+ <bitmap stock_id="wxART_WARNING"/>
+ </imagelist>
</object>
<flag>wxEXPAND</flag>
</object>
@subsubsection xrc_wxchoicebook wxChoicebook
-No additional properties.
-
A choicebook can have one or more child objects of the @c choicebookpage
pseudo-class (similarly to @ref xrc_wxnotebook "wxNotebook" and its
-@c notebookpage). @c choicebookpage objects have the following properties:
+@c notebookpage) and one child object of the @ref xrc_wximagelist class.
+@c choicebookpage objects have the following properties:
@beginTable
@hdr3col{property, type, description}
Sheet page's title (required).}
@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
Bitmap shown alongside the label (default: none).}
+@row3col{image, integer,
+ The zero-based index of the image associated with the item
+ into the image list.}
@row3col{selected, @ref overview_xrcformat_type_bool,
Is the page selected initially (only one page can be selected; default: 0)?}
@endTable
@endTable
+@subsubsection xrc_wximagelist wxImageList
+
+The imagelist can be used as a child object for the following classes:
+ - @ref xrc_wxchoicebook
+ - @ref xrc_wxlistbook
+ - @ref xrc_wxlistctrl
+ - @ref xrc_wxnotebook
+ - @ref xrc_wxtreebook
+ - @ref xrc_wxtreectrl
+
+The available properties are:
+
+@beginTable
+@hdr3col{property, type, description}
+@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
+ Adds a new image by keeping its optional mask bitmap (see below).}
+@row3col{mask, @ref overview_xrcformat_type_bool,
+ If masks should be created for all images (default: true).}
+@row3col{size, @ref overview_xrcformat_type_size,
+ The size of the images in the list (default: system default icon size)).}
+@endTable
+
+Example:
+@code
+<imagelist>
+ <size>32,32</size>
+ <bitmap stock_id="wxART_QUESTION"/>
+ <bitmap stock_id="wxART_INFORMATION"/>
+</imagelist>
+@endcode
+
+In the specific case of the @ref xrc_wxlistctrl, the tag can take the name
+@c \<imagelist-small\> to define the 'small' image list, related to the flag
+@c wxIMAGE_LIST_SMALL (see wxListCtrl documentation).
+
+
@subsubsection xrc_wxlistbox wxListBox
@beginTable
@subsubsection xrc_wxlistbook wxListbook
-No additional properties.
-
A listbook can have one or more child objects of the @c listbookpage
pseudo-class (similarly to @ref xrc_wxnotebook "wxNotebook" and its
-@c notebookpage). @c listbookpage objects have the following properties:
+@c notebookpage) and one child object of the @ref xrc_wximagelist class.
+@c listbookpage objects have the following properties:
@beginTable
@hdr3col{property, type, description}
Sheet page's title (required).}
@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
Bitmap shown alongside the label (default: none).}
+@row3col{image, integer,
+ The zero-based index of the image associated with the item
+ into the image list.}
@row3col{selected, @ref overview_xrcformat_type_bool,
Is the page selected initially (only one page can be selected; default: 0)?}
@endTable
@subsubsection xrc_wxlistctrl wxListCtrl
-No additional properties.
+A listctrl can have one or more child objects of the class @ref xrc_wxlistitem
+and one or more objects of the @ref xrc_wximagelist class. The latter is
+defined either using @c \<imagelist\> tag for the control with @c wxLC_ICON
+style or using @c \<imagelist-small\> tag for the control with @c
+wxLC_SMALL_ICON style.
+
+@subsubsection xrc_wxlistitem wxListItem
+
+The @c listitem is a child object for the class @ref xrc_wxlistctrl.
+It can have the following properties:
+
+@beginTable
+@hdr3col{property, type, description}
+@row3col{align, wxListColumnFormat,
+ The alignment for the item.
+ Can be one of @c wxLIST_FORMAT_LEFT, @c wxLIST_FORMAT_RIGHT or
+ @c wxLIST_FORMAT_CENTRE.}
+@row3col{bg, @ref overview_xrcformat_type_colour,
+ The background color for the item.}
+@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
+ Add a bitmap to the (normal) @ref xrc_wximagelist associated with the
+ @ref xrc_wxlistctrl parent and associate it with this item.
+ If the imagelist is not defined it will be created implicitly.}
+@row3col{bitmap-small, @ref overview_xrcformat_type_bitmap,
+ Add a bitmap in the 'small' @ref xrc_wximagelist associated with the
+ @ref xrc_wxlistctrl parent and associate it with this item.
+ If the 'small' imagelist is not defined it will be created implicitly.}
+@row3col{image, integer,
+ The zero-based index of the image associated with the item
+ in the (normal) image list.}
+@row3col{image-small, integer,
+ The zero-based index of the image associated with the item
+ in the 'small' image list.}
+@row3col{col, integer,
+ The zero-based column index.}
+@row3col{data, integer,
+ The client data for the item.}
+@row3col{font, @ref overview_xrcformat_type_font,
+ The font for the item.}
+@row3col{image, integer,
+ The zero-based index of the image associated with the item
+ into the image list.}
+@row3col{mask, @ref overview_xrcformat_type_style,
+ The mask indicating which fields of this class are valid.
+ Can be any combination of the following values:
+ - wxLIST_MASK_STATE: @b GetState is valid.
+ - wxLIST_MASK_TEXT: @b GetText is valid.
+ - wxLIST_MASK_IMAGE: @b GetImage is valid.
+ - wxLIST_MASK_DATA: @b GetData is valid.
+ - wxLIST_MASK_WIDTH: @b GetWidth is valid.
+ - wxLIST_MASK_FORMAT: @b GetFormat is valid. }
+@row3col{state, @ref overview_xrcformat_type_style,
+ The item state flags (note that the valid state flags are influenced
+ by the value of the @c statemask, see below).
+ Can be any combination of the following values:
+ - @c wxLIST_STATE_FOCUSED: The item has the focus.
+ - @c wxLIST_STATE_SELECTED: The item is selected.
+ - @c wxLIST_STATE_DONTCARE: Don't care what the state is. Win32 only.
+ - @c wxLIST_STATE_DROPHILITED: The item is highlighted to receive a drop event. Win32 only.
+ - @c wxLIST_STATE_CUT: The item is in the cut state. Win32 only. }
+@row3col{statemask, bitlist,
+ A mask indicating which state flags are valid. This is a bitlist of the
+ flags reported above for the item state. }
+@row3col{text, @ref overview_xrcformat_type_string,
+ The text label (or header for columns) for the item. }
+@row3col{textcolour, @ref overview_xrcformat_type_colour,
+ The text colour for the item. }
+@row3col{width, integer,
+ The column width. }
+@endTable
+
+Notice that the item position can't be specified here, the items are appended
+to the list control in order of their appearance.
@subsubsection xrc_wxmdiparentframe wxMDIParentFrame
@subsubsection xrc_wxnotebook wxNotebook
-No additional properties.
-
A notebook can have one or more child objects of the @c notebookpage
-pseudo-class. @c notebookpage objects have the following properties:
+pseudo-class and one child object of the @ref xrc_wximagelist class.
+@c notebookpage objects have the following properties:
@beginTable
@hdr3col{property, type, description}
Page's title (required).}
@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
Bitmap shown alongside the label (default: none).}
+@row3col{image, integer,
+ The zero-based index of the image associated with the item
+ into the image list.}
@row3col{selected, @ref overview_xrcformat_type_bool,
Is the page selected initially (only one page can be selected; default: 0)?}
@endTable
@subsubsection xrc_wxtreectrl wxTreeCtrl
+A treectrl can have one child object of the @ref xrc_wximagelist class.
+
No additional properties.
@subsubsection xrc_wxtreebook wxTreebook
-No additional properties.
-
A treebook can have one or more child objects of the @c treebookpage
pseudo-class (similarly to @ref xrc_wxnotebook "wxNotebook" and its
-@c notebookpage). @c treebookpage objects have the following properties:
+@c notebookpage) and one child object of the @ref xrc_wximagelist class.
+@c treebookpage objects have the following properties:
@beginTable
@hdr3col{property, type, description}
Sheet page's title (required).}
@row3col{bitmap, @ref overview_xrcformat_type_bitmap,
Bitmap shown alongside the label (default: none).}
+@row3col{image, integer,
+ The zero-based index of the image associated with the item
+ into the image list.}
@row3col{selected, @ref overview_xrcformat_type_bool,
Is the page selected initially (only one page can be selected; default: 0)?}
@endTable
#if wxUSE_XRC && wxUSE_LISTCTRL
+class WXDLLIMPEXP_FWD_CORE wxListCtrl;
+
class WXDLLIMPEXP_XRC wxListCtrlXmlHandler : public wxXmlResourceHandler
{
- DECLARE_DYNAMIC_CLASS(wxListCtrlXmlHandler)
-
public:
wxListCtrlXmlHandler();
virtual wxObject *DoCreateResource();
virtual bool CanHandle(wxXmlNode *node);
+
+private:
+ long Handle_wxListItem();
+ wxObject* Handle_wxListCtrl();
+
+ // gets the items image index in the corresponding image list (normal if
+ // which is wxIMAGE_LIST_NORMAL or small if it is wxIMAGE_LIST_SMALL)
+ long GetImageIndex(wxListCtrl *listctrl, int which);
+
+ DECLARE_DYNAMIC_CLASS(wxListCtrlXmlHandler)
};
#endif // wxUSE_XRC && wxUSE_LISTCTRL
class WXDLLIMPEXP_FWD_BASE wxFileName;
class WXDLLIMPEXP_FWD_CORE wxIconBundle;
+class WXDLLIMPEXP_FWD_CORE wxImageList;
class WXDLLIMPEXP_FWD_CORE wxMenu;
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
class WXDLLIMPEXP_FWD_CORE wxDialog;
// wxXML_ENTITY_NODE name="tag", content=""
// |-- wxXML_TEXT_NODE or
// wxXML_CDATA_SECTION_NODE name="" content="content"
- wxString GetNodeContent(wxXmlNode *node);
+ wxString GetNodeContent(const wxXmlNode *node);
// Check to see if a parameter exists.
bool HasParam(const wxString& param);
// Finds the parameter value or returns the empty string.
wxString GetParamValue(const wxString& param);
+ // Returns the parameter value from given node.
+ wxString GetParamValue(const wxXmlNode* node);
+
// Add a style flag (e.g. wxMB_DOCKABLE) to the list of flags
// understood by this handler.
void AddStyle(const wxString& name, int value);
const wxArtClient& defaultArtClient = wxART_OTHER,
wxSize size = wxDefaultSize);
+ // Gets a bitmap from an XmlNode.
+ wxBitmap GetBitmap(const wxXmlNode* node,
+ const wxArtClient& defaultArtClient = wxART_OTHER,
+ wxSize size = wxDefaultSize);
+
// Gets an icon.
wxIcon GetIcon(const wxString& param = wxT("icon"),
const wxArtClient& defaultArtClient = wxART_OTHER,
wxSize size = wxDefaultSize);
+ // Gets an icon from an XmlNode.
+ wxIcon GetIcon(const wxXmlNode* node,
+ const wxArtClient& defaultArtClient = wxART_OTHER,
+ wxSize size = wxDefaultSize);
+
// Gets an icon bundle.
wxIconBundle GetIconBundle(const wxString& param,
const wxArtClient& defaultArtClient = wxART_OTHER);
+ // Gets an image list.
+ wxImageList *GetImageList(const wxString& param = wxT("imagelist"));
+
#if wxUSE_ANIMATIONCTRL
// Gets an animation.
wxAnimation GetAnimation(const wxString& param = wxT("animation"));
wxBitmap GetBitmap(const wxString& param = "bitmap",
const wxArtClient& defaultArtClient = wxART_OTHER,
wxSize size = wxDefaultSize);
+ /**
+ Gets a bitmap from an XmlNode.
+
+ @since 2.9.1
+ */
+ wxBitmap GetBitmap(const wxXmlNode* node,
+ const wxArtClient& defaultArtClient = wxART_OTHER,
+ wxSize size = wxDefaultSize);
/**
Gets a bool flag (1, t, yes, on, true are @true, everything else is @false).
const wxArtClient& defaultArtClient = wxART_OTHER,
wxSize size = wxDefaultSize);
+ /**
+ Gets an icon from an XmlNode.
+
+ @since 2.9.1
+ */
+ wxIcon GetIcon(const wxXmlNode* node,
+ const wxArtClient& defaultArtClient = wxART_OTHER,
+ wxSize size = wxDefaultSize);
+
/**
Returns an icon bundle.
wxIconBundle GetIconBundle(const wxString& param,
const wxArtClient& defaultArtClient = wxART_OTHER);
+ /**
+ Creates an image list from the @a param markup data.
+
+ @return
+ The new instance of wxImageList or @NULL if no data is found.
+
+ @since 2.9.1
+ */
+ wxImageList *GetImageList(const wxString& param = wxT("imagelist"));
+
/**
Gets the integer value from the parameter.
*/
*/
wxString GetParamValue(const wxString& param);
+ /**
+ Returns the node parameter value.
+
+ @since 2.9.1
+ */
+ wxString GetParamValue(const wxXmlNode* node);
+
/**
Gets the position (may be in dialog units).
*/
<object class="notebookpage">
<label>wxListCtrl</label>
<object class="wxPanel" name="listctrl">
- <object class="wxFlexGridSizer">
- <cols>1</cols>
- <rows>0</rows>
- <vgap>0</vgap>
- <hgap>0</hgap>
- <growablecols>0</growablecols>
- <growablerows>0</growablerows>
+ <object class="wxBoxSizer">
<object class="sizeritem">
<flag>wxALIGN_CENTER|wxALL</flag>
<border>5</border>
<object class="wxListCtrl" name="controls_listctrl">
<size>220,160</size>
- <style>wxLC_REPORT|wxSUNKEN_BORDER</style>
+ <style>wxLC_REPORT</style>
+ <!-- this control is filled in from the code -->
+ </object>
+ </object>
+ <object class="sizeritem">
+ <flag>wxALIGN_CENTER|wxALL</flag>
+ <border>5</border>
+ <object class="wxListCtrl" name="controls_listctrl2">
+ <size>220,160</size>
+ <style>wxLC_ICON</style>
+ <object class="listitem">
+ <text>Information</text>
+ <bitmap stock_id="wxART_INFORMATION"/>
+ </object>
+ <object class="listitem">
+ <text>Question?</text>
+ <bitmap stock_id="wxART_QUESTION"/>
+ </object>
+ </object>
+ </object>
+ <object class="sizeritem">
+ <flag>wxALIGN_CENTER|wxALL</flag>
+ <border>5</border>
+ <object class="wxListCtrl" name="controls_listctrl3">
+ <size>220,160</size>
+ <style>wxLC_SMALL_ICON</style>
+ <imagelist-small>
+ <size>20,20</size>
+ <bitmap stock_id="wxART_INFORMATION"/>
+ <bitmap stock_id="wxART_QUESTION"/>
+ </imagelist-small>
+ <object class="listitem">
+ <text>Information</text>
+ <image-small>0</image-small>
+ </object>
+ <object class="listitem">
+ <text>Question?</text>
+ <image-small>1</image-small>
+ </object>
</object>
</object>
</object>
int imgIndex = imgList->Add(bmp);
m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1, imgIndex );
}
+ else if ( HasParam(wxT("image")) )
+ {
+ if ( m_choicebook->GetImageList() )
+ {
+ m_choicebook->SetPageImage(m_choicebook->GetPageCount()-1,
+ GetLong(wxT("image")) );
+ }
+ else // image without image list?
+ {
+ ReportError(n, "image can only be used in conjunction "
+ "with imagelist");
+ }
+ }
}
else
{
GetStyle(wxT("style")),
GetName());
+ wxImageList *imagelist = GetImageList();
+ if ( imagelist )
+ nb->AssignImageList(imagelist);
+
wxChoicebook *old_par = m_choicebook;
m_choicebook = nb;
bool old_ins = m_isInside;
int imgIndex = imgList->Add(bmp);
m_listbook->SetPageImage(m_listbook->GetPageCount()-1, imgIndex );
}
+ else if ( HasParam(wxT("image")) )
+ {
+ if ( m_listbook->GetImageList() )
+ {
+ m_listbook->SetPageImage(m_listbook->GetPageCount()-1,
+ GetLong(wxT("image")) );
+ }
+ else // image without image list?
+ {
+ ReportError(n, "image can only be used in conjunction "
+ "with imagelist");
+ }
+ }
}
else
{
GetStyle(wxT("style")),
GetName());
+ wxImageList *imagelist = GetImageList();
+ if ( imagelist )
+ nb->AssignImageList(imagelist);
+
wxListbook *old_par = m_listbook;
m_listbook = nb;
bool old_ins = m_isInside;
#endif
#include "wx/listctrl.h"
+#include "wx/imaglist.h"
IMPLEMENT_DYNAMIC_CLASS(wxListCtrlXmlHandler, wxXmlResourceHandler)
wxListCtrlXmlHandler::wxListCtrlXmlHandler()
: wxXmlResourceHandler()
{
+ // wxListItem styles
+ XRC_ADD_STYLE(wxLIST_FORMAT_LEFT);
+ XRC_ADD_STYLE(wxLIST_FORMAT_RIGHT);
+ XRC_ADD_STYLE(wxLIST_FORMAT_CENTRE);
+ XRC_ADD_STYLE(wxLIST_MASK_STATE);
+ XRC_ADD_STYLE(wxLIST_MASK_TEXT);
+ XRC_ADD_STYLE(wxLIST_MASK_IMAGE);
+ XRC_ADD_STYLE(wxLIST_MASK_DATA);
+ XRC_ADD_STYLE(wxLIST_MASK_WIDTH);
+ XRC_ADD_STYLE(wxLIST_MASK_FORMAT);
+ XRC_ADD_STYLE(wxLIST_STATE_DONTCARE);
+ XRC_ADD_STYLE(wxLIST_STATE_DROPHILITED);
+ XRC_ADD_STYLE(wxLIST_STATE_FOCUSED);
+ XRC_ADD_STYLE(wxLIST_STATE_SELECTED);
+ XRC_ADD_STYLE(wxLIST_STATE_CUT);
+
+ // wxListCtrl styles
XRC_ADD_STYLE(wxLC_LIST);
XRC_ADD_STYLE(wxLC_REPORT);
XRC_ADD_STYLE(wxLC_ICON);
}
wxObject *wxListCtrlXmlHandler::DoCreateResource()
+{
+ if (m_class == wxT("listitem"))
+ {
+ Handle_wxListItem();
+ return m_parentAsWindow;
+ }
+ else
+ return Handle_wxListCtrl();
+}
+
+bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
+{
+ return IsOfClass(node, wxT("wxListCtrl")) ||
+ IsOfClass(node, wxT("listitem"));
+}
+
+long wxListCtrlXmlHandler::Handle_wxListItem()
+{
+ wxListCtrl * const list = wxDynamicCast(m_parentAsWindow, wxListCtrl);
+ wxCHECK_MSG( list, -1, "must have wxListCtrl parent" );
+
+ wxListItem item;
+
+ if (HasParam(wxT("align")))
+ item.SetAlign((wxListColumnFormat)GetStyle(wxT("align")));
+ if (HasParam(wxT("bg")))
+ item.SetBackgroundColour(GetColour(wxT("bg")));
+ if (HasParam(wxT("col")))
+ item.SetColumn((int)GetLong(wxT("col")));
+ if (HasParam(wxT("data")))
+ item.SetData(GetLong(wxT("data")));
+ if (HasParam(wxT("font")))
+ item.SetFont(GetFont());
+ if (HasParam(wxT("mask")))
+ item.SetMask(GetStyle(wxT("mask")));
+ if (HasParam(wxT("state")))
+ item.SetState(GetStyle(wxT("state")));
+ if (HasParam(wxT("statemask")))
+ item.SetStateMask(GetStyle(wxT("statemask")));
+ if (HasParam(wxT("text")))
+ item.SetText(GetText(wxT("text")));
+ if (HasParam(wxT("textcolour")))
+ item.SetTextColour(GetColour(wxT("textcolour")));
+ if (HasParam(wxT("textcolor")))
+ item.SetTextColour(GetColour(wxT("textcolor")));
+ if (HasParam(wxT("width")))
+ item.SetWidth((int)GetLong(wxT("width")));
+
+ // the list control icon style, may be 0
+ int image;
+ if ( list->HasFlag(wxLC_ICON) )
+ image = GetImageIndex(list, wxIMAGE_LIST_NORMAL);
+ else if ( list->HasFlag(wxLC_SMALL_ICON) )
+ image = GetImageIndex(list, wxIMAGE_LIST_SMALL);
+ else
+ image = wxNOT_FOUND;
+
+ if ( image != wxNOT_FOUND )
+ item.SetImage(image);
+
+ // append the list item to the control
+ item.SetId(list->GetItemCount());
+
+ return list->InsertItem(item);
+}
+
+wxObject* wxListCtrlXmlHandler::Handle_wxListCtrl()
{
XRC_MAKE_INSTANCE(list, wxListCtrl)
wxDefaultValidator,
GetName());
- // FIXME: add columns definition
+ // we can optionally have normal and/or small image lists
+ wxImageList *imagelist;
+ imagelist = GetImageList(wxT("imagelist"));
+ if ( imagelist )
+ list->AssignImageList(imagelist, wxIMAGE_LIST_NORMAL);
+ imagelist = GetImageList(wxT("imagelist-small"));
+ if ( imagelist )
+ list->AssignImageList(imagelist, wxIMAGE_LIST_SMALL);
+ CreateChildrenPrivately(list);
SetupWindow(list);
return list;
}
-bool wxListCtrlXmlHandler::CanHandle(wxXmlNode *node)
+long wxListCtrlXmlHandler::GetImageIndex(wxListCtrl *listctrl, int which)
{
- return IsOfClass(node, wxT("wxListCtrl"));
+ // use different tag names depending on whether we need a normal or small
+ // image
+ wxString
+ bmpParam("bitmap"),
+ imgParam("image");
+ switch ( which )
+ {
+ case wxIMAGE_LIST_SMALL:
+ bmpParam += "-small";
+ imgParam += "-small";
+ break;
+
+ case wxIMAGE_LIST_NORMAL:
+ // nothing to do
+ break;
+
+ default:
+ wxFAIL_MSG( "unsupported image list kind" );
+ return wxNOT_FOUND;
+ }
+
+ // look for either bitmap or image tags
+ int imgIndex = wxNOT_FOUND;
+ if ( HasParam(bmpParam) )
+ {
+ // we implicitly construct an image list containing the specified
+ // bitmaps
+ wxBitmap bmp = GetBitmap(bmpParam, wxART_OTHER);
+
+ // create the image list on demand for the first bitmap
+ wxImageList *imgList = listctrl->GetImageList(which);
+ if ( !imgList )
+ {
+ imgList = new wxImageList( bmp.GetWidth(), bmp.GetHeight() );
+ listctrl->AssignImageList( imgList, which );
+ }
+
+ imgIndex = imgList->Add(bmp);
+ }
+
+ if ( HasParam(imgParam) )
+ {
+ if ( imgIndex != wxNOT_FOUND )
+ {
+ // TODO: we should really check that only bitmap or only image tags
+ // are used across all items of the control, not just in this
+ // one
+ ReportError(wxString::Format(
+ "listitem %s attribute ignored because %s is also specified",
+ bmpParam, imgParam));
+ }
+
+ // just use the specified index directly
+ imgIndex = GetLong(imgParam);
+ }
+
+ return imgIndex;
}
#endif // wxUSE_XRC && wxUSE_LISTCTRL
int imgIndex = imgList->Add(bmp);
m_notebook->SetPageImage(m_notebook->GetPageCount()-1, imgIndex );
}
+ else if ( HasParam(wxT("image")) )
+ {
+ if ( m_notebook->GetImageList() )
+ {
+ m_notebook->SetPageImage(m_notebook->GetPageCount()-1,
+ GetLong(wxT("image")) );
+ }
+ else // image without image list?
+ {
+ ReportError(n, "image can only be used in conjunction "
+ "with imagelist");
+ }
+ }
}
else
{
GetStyle(wxT("style")),
GetName());
+ wxImageList *imagelist = GetImageList();
+ if ( imagelist )
+ nb->AssignImageList(imagelist);
+
SetupWindow(nb);
wxNotebook *old_par = m_notebook;
wxDefaultValidator,
GetName());
+ wxImageList *imagelist = GetImageList();
+ if ( imagelist )
+ tree->AssignImageList(imagelist);
+
SetupWindow(tree);
return tree;
GetStyle(wxT("style")),
GetName());
+ wxImageList *imagelist = GetImageList();
+ if ( imagelist )
+ tbk->AssignImageList(imagelist);
+
wxTreebook * old_par = m_tbk;
m_tbk = tbk;
}
imgIndex = imgList->Add(bmp);
}
+ else if ( HasParam(wxT("image")) )
+ {
+ if ( m_tbk->GetImageList() )
+ {
+ imgIndex = GetLong(wxT("image"));
+ }
+ else // image without image list?
+ {
+ ReportError(n, "image can only be used in conjunction "
+ "with imagelist");
+ }
+ }
// then add the page to the corresponding parent
if( depth < m_treeContext.GetCount() )
#include "wx/fontenum.h"
#include "wx/fontmap.h"
#include "wx/artprov.h"
+#include "wx/imaglist.h"
#include "wx/dir.h"
#include "wx/xml/xml.h"
wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param,
const wxArtClient& defaultArtClient,
wxSize size)
+{
+ return GetBitmap(GetParamNode(param), defaultArtClient, size);
+}
+
+wxBitmap wxXmlResourceHandler::GetBitmap(const wxXmlNode* node,
+ const wxArtClient& defaultArtClient,
+ wxSize size)
{
/* If the bitmap is specified as stock item, query wxArtProvider for it: */
wxString art_id, art_client;
- if ( GetStockArtAttrs(GetParamNode(param), defaultArtClient,
+ if ( GetStockArtAttrs(node, defaultArtClient,
art_id, art_client) )
{
wxBitmap stockArt(wxArtProvider::GetBitmap(art_id, art_client, size));
}
/* ...or load the bitmap from file: */
- wxString name = GetParamValue(param);
+ wxString name = GetParamValue(node);
if (name.empty()) return wxNullBitmap;
#if wxUSE_FILESYSTEM
wxFSFile *fsfile = GetCurFileSystem().OpenFile(name, wxFS_READ | wxFS_SEEKABLE);
{
ReportParamError
(
- param,
+ node->GetName(),
wxString::Format("cannot open bitmap resource \"%s\"", name)
);
return wxNullBitmap;
{
ReportParamError
(
- param,
+ node->GetName(),
wxString::Format("cannot create bitmap from \"%s\"", name)
);
return wxNullBitmap;
wxIcon wxXmlResourceHandler::GetIcon(const wxString& param,
const wxArtClient& defaultArtClient,
wxSize size)
+{
+ return GetIcon(GetParamNode(param), defaultArtClient, size);
+}
+
+wxIcon wxXmlResourceHandler::GetIcon(const wxXmlNode* node,
+ const wxArtClient& defaultArtClient,
+ wxSize size)
{
wxIcon icon;
- icon.CopyFromBitmap(GetBitmap(param, defaultArtClient, size));
+ icon.CopyFromBitmap(GetBitmap(node, defaultArtClient, size));
return icon;
}
+
wxIconBundle wxXmlResourceHandler::GetIconBundle(const wxString& param,
const wxArtClient& defaultArtClient)
{
}
+wxImageList *wxXmlResourceHandler::GetImageList(const wxString& param)
+{
+ wxXmlNode * const imagelist_node = GetParamNode(param);
+ if ( !imagelist_node )
+ return NULL;
+
+ wxXmlNode * const oldnode = m_node;
+ m_node = imagelist_node;
+
+ // size
+ wxSize size = GetSize();
+ size.SetDefaults(wxSize(wxSystemSettings::GetMetric(wxSYS_ICON_X),
+ wxSystemSettings::GetMetric(wxSYS_ICON_Y)));
+
+ // mask: true by default
+ bool mask = HasParam(wxT("mask")) ? GetBool(wxT("mask"), true) : true;
+
+ // now we have everything we need to create the image list
+ wxImageList *imagelist = new wxImageList(size.x, size.y, mask);
+
+ // add images
+ wxString parambitmap = wxT("bitmap");
+ if ( HasParam(parambitmap) )
+ {
+ wxXmlNode *n = m_node->GetChildren();
+ while (n)
+ {
+ if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == parambitmap)
+ {
+ // add icon instead of bitmap to keep the bitmap mask
+ imagelist->Add(GetIcon(n));
+ }
+ n = n->GetNext();
+ }
+ }
+
+ m_node = oldnode;
+ return imagelist;
+}
+
wxXmlNode *wxXmlResourceHandler::GetParamNode(const wxString& param)
{
wxCHECK_MSG(m_node, NULL, wxT("You can't access handler data before it was initialized!"));
-wxString wxXmlResourceHandler::GetNodeContent(wxXmlNode *node)
+wxString wxXmlResourceHandler::GetNodeContent(const wxXmlNode *node)
{
- wxXmlNode *n = node;
+ const wxXmlNode *n = node;
if (n == NULL) return wxEmptyString;
n = n->GetChildren();
return GetNodeContent(GetParamNode(param));
}
+wxString wxXmlResourceHandler::GetParamValue(const wxXmlNode* node)
+{
+ return GetNodeContent(node);
+}
wxSize wxXmlResourceHandler::GetSize(const wxString& param,