// -----------------------------------------------------------------------------
// array types
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// array types
// -----------------------------------------------------------------------------
void SetImage(int image, wxTreeItemIcon which) { m_images[which] = image; }
void SetData(wxTreeItemData *data) { m_data = data; }
void SetImage(int image, wxTreeItemIcon which) { m_images[which] = image; }
void SetData(wxTreeItemData *data) { m_data = data; }
void DeleteChildren(wxGenericTreeCtrl *tree = NULL);
// get count of all children (and grand children if 'recursively')
void DeleteChildren(wxGenericTreeCtrl *tree = NULL);
// get count of all children (and grand children if 'recursively')
void Insert(wxGenericTreeItem *child, size_t index)
{ m_children.Insert(child, index); }
void Insert(wxGenericTreeItem *child, size_t index)
{ m_children.Insert(child, index); }
void GetSize( int &x, int &y, const wxGenericTreeCtrl* );
// return the item at given position (or NULL if no item), onButton is
void GetSize( int &x, int &y, const wxGenericTreeCtrl* );
// return the item at given position (or NULL if no item), onButton is
// on the item's label
wxGenericTreeItem *HitTest( const wxPoint& point,
const wxGenericTreeCtrl *,
int &flags,
int level );
// on the item's label
wxGenericTreeItem *HitTest( const wxPoint& point,
const wxGenericTreeCtrl *,
int &flags,
int level );
int w = m_itemEdited->GetWidth(),
h = m_itemEdited->GetHeight();
int w = m_itemEdited->GetWidth(),
h = m_itemEdited->GetHeight();
if ( value == m_startValue )
{
// nothing changed, always accept
if ( value == m_startValue )
{
// nothing changed, always accept
}
// accepted, do rename the item
m_owner->SetItemText(m_itemEdited, value);
}
// accepted, do rename the item
m_owner->SetItemText(m_itemEdited, value);
EVT_CHAR (wxGenericTreeCtrl::OnChar)
EVT_SET_FOCUS (wxGenericTreeCtrl::OnSetFocus)
EVT_KILL_FOCUS (wxGenericTreeCtrl::OnKillFocus)
EVT_CHAR (wxGenericTreeCtrl::OnChar)
EVT_SET_FOCUS (wxGenericTreeCtrl::OnSetFocus)
EVT_KILL_FOCUS (wxGenericTreeCtrl::OnKillFocus)
void wxGenericTreeCtrl::Init()
{
m_current = m_key_current = m_anchor = m_select_me = (wxGenericTreeItem *) NULL;
void wxGenericTreeCtrl::Init()
{
m_current = m_key_current = m_anchor = m_select_me = (wxGenericTreeItem *) NULL;
m_imageListNormal = m_imageListButtons =
m_imageListState = (wxImageList *) NULL;
m_ownsImageListNormal = m_ownsImageListButtons =
m_imageListNormal = m_imageListButtons =
m_imageListState = (wxImageList *) NULL;
m_ownsImageListNormal = m_ownsImageListButtons =
- wxVisualAttributes attr = GetDefaultAttributes();
- SetDefaultForegroundColour( attr.colFg );
- SetDefaultBackgroundColour( attr.colBg );
- SetDefaultFont(attr.font);
+ wxVisualAttributes attr = GetDefaultAttributes();
+ SetOwnForegroundColour( attr.colFg );
+ SetOwnBackgroundColour( attr.colBg );
+ if (!m_hasFont)
+ SetOwnFont(attr.font);
// m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86
m_dottedPen = wxPen( wxT("grey"), 0, 0 );
SetBestSize(size);
// m_dottedPen = wxPen( "grey", 0, wxDOT ); too slow under XFree86
m_dottedPen = wxPen( wxT("grey"), 0, 0 );
SetBestSize(size);
// want to update the inherited styles, but right now
// none of the parents has updatable styles
m_windowStyle = styles;
// want to update the inherited styles, but right now
// none of the parents has updatable styles
m_windowStyle = styles;
m_normalFont.GetFaceName(),
m_normalFont.GetEncoding());
m_normalFont.GetFaceName(),
m_normalFont.GetEncoding());
// An item is only visible if it's not a descendant of a collapsed item
wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem;
// An item is only visible if it's not a descendant of a collapsed item
wxGenericTreeItem *pItem = (wxGenericTreeItem*) item.m_pItem;
// consider that the item does have children if it has the "+" button: it
// might not have them (if it had never been expanded yet) but then it
// consider that the item does have children if it has the "+" button: it
// might not have them (if it had never been expanded yet) but then it
return ((wxGenericTreeItem*) item.m_pItem)->IsExpanded();
}
bool wxGenericTreeCtrl::IsSelected(const wxTreeItemId& item) const
{
return ((wxGenericTreeItem*) item.m_pItem)->IsExpanded();
}
bool wxGenericTreeCtrl::IsSelected(const wxTreeItemId& item) const
{
return ((wxGenericTreeItem*) item.m_pItem)->IsSelected();
}
bool wxGenericTreeCtrl::IsBold(const wxTreeItemId& item) const
{
return ((wxGenericTreeItem*) item.m_pItem)->IsSelected();
}
bool wxGenericTreeCtrl::IsBold(const wxTreeItemId& item) const
{
return AddRoot(text, image, selImage, data);
}
return AddRoot(text, image, selImage, data);
}
wxGenericTreeItem *item =
new wxGenericTreeItem( parent, text, image, selImage, data );
wxGenericTreeItem *item =
new wxGenericTreeItem( parent, text, image, selImage, data );
// Don't silently change the selection:
// do it properly in idle time, so event
// handlers get called.
// Don't silently change the selection:
// do it properly in idle time, so event
// handlers get called.
// Don't silently change the selection:
// do it properly in idle time, so event
// handlers get called.
// Don't silently change the selection:
// do it properly in idle time, so event
// handlers get called.
for ( size_t n = 0; n < count; ++n )
{
if (TagAllChildrenUntilLast(children[n], last_item, select))
for ( size_t n = 0; n < count; ++n )
{
if (TagAllChildrenUntilLast(children[n], last_item, select))
bool is_single=!(GetWindowStyleFlag() & wxTR_MULTIPLE);
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
bool is_single=!(GetWindowStyleFlag() & wxTR_MULTIPLE);
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
wxCHECK_RET( item, wxT("SelectItem(): invalid tree item") );
wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem;
wxCHECK_RET( item, wxT("SelectItem(): invalid tree item") );
// We have to call this here because the label in
// question might just have been added and no screen
// update taken place.
// We have to call this here because the label in
// question might just have been added and no screen
// update taken place.
// Don't do any drawing if we're setting the list to NULL,
// since we may be in the process of deleting the tree control.
if (imageList)
// Don't do any drawing if we're setting the list to NULL,
// since we may be in the process of deleting the tree control.
if (imageList)
}
void wxGenericTreeCtrl::SetButtonsImageList(wxImageList *imageList)
{
if (m_ownsImageListButtons) delete m_imageListButtons;
m_imageListButtons = imageList;
}
void wxGenericTreeCtrl::SetButtonsImageList(wxImageList *imageList)
{
if (m_ownsImageListButtons) delete m_imageListButtons;
m_imageListButtons = imageList;
}
void wxGenericTreeCtrl::AssignButtonsImageList(wxImageList *imageList)
{
SetButtonsImageList(imageList);
}
void wxGenericTreeCtrl::AssignButtonsImageList(wxImageList *imageList)
{
SetButtonsImageList(imageList);
int flag = 0;
if (item->IsExpanded())
flag |= wxCONTROL_EXPANDED;
if (item == m_underMouse)
flag |= wxCONTROL_CURRENT;
int flag = 0;
if (item->IsExpanded())
flag |= wxCONTROL_EXPANDED;
if (item == m_underMouse)
flag |= wxCONTROL_CURRENT;
if (HasButtons()) y_mid += 5;
// Only draw the portion of the line that is visible, in case it is huge
if (HasButtons()) y_mid += 5;
// Only draw the portion of the line that is visible, in case it is huge
- wxCoord xOrigin=0, yOrigin=0, width, height;
+ wxCoord xOrigin=0, yOrigin=0, width, height;
dc.GetDeviceOrigin(&xOrigin, &yOrigin);
yOrigin = abs(yOrigin);
GetClientSize(&width, &height);
dc.GetDeviceOrigin(&xOrigin, &yOrigin);
yOrigin = abs(yOrigin);
GetClientSize(&width, &height);
// -----------------------------------------------------------------------------
void wxGenericTreeCtrl::OnPaint( wxPaintEvent &WXUNUSED(event) )
// -----------------------------------------------------------------------------
void wxGenericTreeCtrl::OnPaint( wxPaintEvent &WXUNUSED(event) )
// it may happen if the item was expanded but then all of
// its children have been deleted - so IsExpanded() returned
// it may happen if the item was expanded but then all of
// its children have been deleted - so IsExpanded() returned
// Is the mouse over a tree item button?
int flags = 0;
wxGenericTreeItem *thisItem = m_anchor->HitTest(pt, this, flags, 0);
// Is the mouse over a tree item button?
int flags = 0;
wxGenericTreeItem *thisItem = m_anchor->HitTest(pt, this, flags, 0);
// we process left mouse up event (enables in-place edit), right down
// (pass to the user code), left dbl click (activate item) and
// dragging/moving events for items drag-and-drop
// we process left mouse up event (enables in-place edit), right down
// (pass to the user code), left dbl click (activate item) and
// dragging/moving events for items drag-and-drop
if ( GetEventHandler()->ProcessEvent(nevent) && nevent.IsAllowed() )
{
// we're going to drag this item
if ( GetEventHandler()->ProcessEvent(nevent) && nevent.IsAllowed() )
{
// we're going to drag this item
// send activate event first
wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
// send activate event first
wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
// Check if we need to select the root item
// because nothing else has been selected.
// Delaying it means that we can invoke event handlers
// Check if we need to select the root item
// because nothing else has been selected.
// Delaying it means that we can invoke event handlers
// TODO: this is awfully inefficient, we should keep the list of all
// selected items internally, should be much faster
if ( m_anchor )
// TODO: this is awfully inefficient, we should keep the list of all
// selected items internally, should be much faster
if ( m_anchor )
void wxGenericTreeCtrl::Thaw()
{
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") );
void wxGenericTreeCtrl::Thaw()
{
wxCHECK_RET( m_freezeCount > 0, _T("thawing unfrozen tree control?") );
bool wxGenericTreeCtrl::SetBackgroundColour(const wxColour& colour)
{
if ( !wxWindow::SetBackgroundColour(colour) )
bool wxGenericTreeCtrl::SetBackgroundColour(const wxColour& colour)
{
if ( !wxWindow::SetBackgroundColour(colour) )
}
bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour)
{
if ( !wxWindow::SetForegroundColour(colour) )
}
bool wxGenericTreeCtrl::SetForegroundColour(const wxColour& colour)
{
if ( !wxWindow::SetForegroundColour(colour) )