- Added support for drop down toolbar buttons (Tim Kosse).
- Added support for labels for toolbar controls (Vince Harron).
- Added wxMessageDialog::SetMessage() and SetExtendedMessage().
+- Added XRCSIZERITEM() macro for obtaining sizers from XRC (Brian Vanderburg II)
- Added wxEventBlocker class (Francesco Montorsi)..
- Added wxFile/DirPickerCtrl::Get/SetFile/DirName() (Francesco Montorsi)..
- Added wxSizerFlags::Top() and Bottom().
Returns pointer to item or NULL.
+\membersection{wxSizer::GetItemById}\label{wxsizergetitembyid}
+
+\func{wxSizerItem *}{GetItemById}{\param{int }{id}, \param{bool }{recursive = false}}
+
+Finds item of the sizer which has the given \arg{id}. This \arg{id} is not the
+window id but the id of the wxSizerItem itself. This is mainly useful for
+retrieving the sizers created from XRC resources.
+
+Use parameter \arg{recursive} to search in subsizers too.
+
+Returns pointer to item or \NULL.
+
\membersection{wxSizer::GetSize}\label{wxsizergetsize}
Return the flags attribute.
+\membersection{wxSizerItem::GetId}\label{wxsizeritemgetid}
+
+\constfunc{int}{GetId}{\void}
+
+Return the numeric id of wxSizerItem, or \texttt{wxID\_NONE} if the id has
+not been set.
+
\membersection{wxSizerItem::GetMinSize}\label{wxsizeritemgetminsize}
Set the flag item attribute.
+\membersection{wxSizerItem::SetId}\label{wxsizeritemSetId}
+
+\func{void}{SetId}{\param{int}{id}}
+
+Sets the numeric id of the wxSizerItem to \arg{id}.
+
\membersection{wxSizerItem::SetInitSize}\label{wxsizeritemsetinitsize}
\end{verbatim}
+It is also possible to access the wxSizerItem of a sizer that is part of
+a resource. This can be done using {\tt XRCSIZERITEM} as shown. The
+resource file can have something like this for a sizer item.
+\begin{verbatim}
+<object class="spacer" name="area">
+ <size>400, 300</size>
+</object>
+\end{verbatim}
+
+The code can then access the sizer item by using {\tt XRCSIZERITEM} and
+{\tt XRCID} together.
+
+\begin{verbatim}
+wxSizerItem* item = XRCSIZERITEM(*this, XRCID("area"));
+\end{verbatim}
\subsection{Adding new resource handlers}\label{newresourcehandlers}
virtual wxRect GetRect() { return m_rect; }
+ // set a sizer item id (different from a window id, all sizer items,
+ // including spacers, can have an associated id)
+ void SetId(int id) { m_id = id; }
+ int GetId() const { return m_id; }
+
bool IsWindow() const { return m_kind == Item_Window; }
bool IsSizer() const { return m_kind == Item_Sizer; }
bool IsSpacer() const { return m_kind == Item_Spacer; }
int m_proportion;
int m_border;
int m_flag;
+ int m_id;
// on screen rectangle of this item (not including borders)
wxRect m_rect;
wxSizerItem* GetItem( wxWindow *window, bool recursive = false );
wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false );
wxSizerItem* GetItem( size_t index );
+ wxSizerItem* GetItemById( int id, bool recursive = false );
// Manage whether individual scene items are considered
// in the layout calculations or not.
#define XRCCTRL(window, id, type) \
(wxStaticCast((window).FindWindow(XRCID(id)), type))
+// This macro returns pointer to sizer item
+// Example:
+//
+// <object class="spacer" name="area">
+// <size>400, 300</size>
+// </object>
+//
+// wxSizerItem* item = XRCSIZERITEM(*this, wxT("area"))
+
+#define XRCSIZERITEM(window, id) \
+ ((window).GetSizer() ? (window).GetSizer()->GetItemById(id) : NULL)
+
// wxXmlResourceHandler is an abstract base class for resource handlers
// capable of creating a control from an XML node.
m_proportion = 0;
m_border = 0;
m_flag = 0;
+ m_id = wxID_NONE;
}
// window item
m_proportion(proportion),
m_border(border),
m_flag(flag),
+ m_id(wxID_NONE),
m_userData(userData)
{
DoSetWindow(window);
m_proportion(proportion),
m_border(border),
m_flag(flag),
+ m_id(wxID_NONE),
m_ratio(0.0),
m_userData(userData)
{
m_proportion(proportion),
m_border(border),
m_flag(flag),
+ m_id(wxID_NONE),
m_userData(userData)
{
DoSetSpacer(wxSize(width, height));
return m_children.Item( index )->GetData();
}
+wxSizerItem* wxSizer::GetItemById( int id, bool recursive )
+{
+ // This gets a sizer item by the id of the sizer item
+ // and NOT the id of a window if the item is a window.
+
+ wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
+ while (node)
+ {
+ wxSizerItem *item = node->GetData();
+
+ if (item->GetId() == id)
+ {
+ return item;
+ }
+ else if (recursive && item->IsSizer())
+ {
+ wxSizerItem *subitem = item->GetSizer()->GetItemById( id, true );
+ if (subitem)
+ return subitem;
+ }
+
+ node = node->GetNext();
+ }
+
+ return NULL;
+}
+
bool wxSizer::Show( wxWindow *window, bool show, bool recursive )
{
wxSizerItem *item = GetItem( window, recursive );
gbsitem->SetPos(GetGBPos(wxT("cellpos")));
gbsitem->SetSpan(GetGBSpan(wxT("cellspan")));
}
+
+ // record the id of the item, if any, for use by XRCSIZERITEM()
+ sitem->SetId(GetID());
}
void wxSizerXmlHandler::AddSizerItem(wxSizerItem* sitem)