}
}
+wxColour wxTreeCtrl::GetItemTextColour(const wxTreeItemId& item) const
+{
+ long id = (long)(WXHTREEITEM)item;
+ wxTreeItemAttr *attr = (wxTreeItemAttr *)m_attrs.Get(id);
+ if ( !attr )
+ {
+ return wxNullColour;
+ }
+
+ return attr->GetTextColour();
+}
+
+wxColour wxTreeCtrl::GetItemBackgroundColour(const wxTreeItemId& item) const
+{
+ long id = (long)(WXHTREEITEM)item;
+ wxTreeItemAttr *attr = (wxTreeItemAttr *)m_attrs.Get(id);
+ if ( !attr )
+ {
+ return wxNullColour;
+ }
+
+ return attr->GetBackgroundColour();
+}
+
+wxFont wxTreeCtrl::GetItemFont(const wxTreeItemId& item) const
+{
+ long id = (long)(WXHTREEITEM)item;
+ wxTreeItemAttr *attr = (wxTreeItemAttr *)m_attrs.Get(id);
+ if ( !attr )
+ {
+ return wxNullFont;
+ }
+
+ return attr->GetFont();
+}
+
void wxTreeCtrl::SetItemTextColour(const wxTreeItemId& item,
const wxColour& col)
{
bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const
{
+ if ( item == wxTreeItemId(TVI_ROOT) )
+ {
+ // virtual (hidden) root is never visible
+ return FALSE;
+ }
+
// Bug in Gnu-Win32 headers, so don't use the macro TreeView_GetItemRect
RECT rect;
switch ( nMsg )
{
+ case WM_RBUTTONDOWN:
+ // if the item we are about to right click on
+ // is not already select, remove the entire
+ // previous selection
+ if (!::IsItemSelected(GetHwnd(), htItem))
+ {
+ UnselectAll();
+ }
+
+ // select item and set the focus to the
+ // newly selected item
+ ::SelectItem(GetHwnd(), htItem);
+ ::SetFocus(GetHwnd(), htItem);
+ break;
+
#if !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
case WM_LBUTTONDOWN:
if ( htItem && isMultiple )
event.m_item = (WXHTREEITEM) info->item.hItem;
event.m_label = info->item.pszText;
+ event.m_editCancelled = FALSE;
}
break;
event.m_item = (WXHTREEITEM)info->item.hItem;
event.m_label = info->item.pszText;
if (info->item.pszText == NULL)
- return FALSE;
+ {
+ event.m_editCancelled = TRUE;
+ }
+ else
+ {
+ event.m_editCancelled = FALSE;
+ }
break;
}
break;
}
- int how = (int)hdr->code == TVN_ITEMEXPANDING ? IDX_DOING
- : IDX_DONE;
+ int how = hdr->code == TVN_ITEMEXPANDING ? IDX_DOING
+ : IDX_DONE;
eventType = gs_expandEvents[what][how];
eventType = wxEVT_COMMAND_TREE_KEY_DOWN;
TV_KEYDOWN *info = (TV_KEYDOWN *)lParam;
- // we pass 0 as 2 last CreateKeyEvent() parameters because we
- // don't have access to the real key press flags here - but as
- // it is only used to determin wxKeyEvent::m_altDown flag it's
- // not too bad
+ // fabricate the lParam and wParam parameters sufficiently
+ // similar to the ones from a "real" WM_KEYDOWN so that
+ // CreateKeyEvent() works correctly
+ WXLPARAM lParam =
+ (::GetKeyState(VK_MENU) & 0x100 ? KF_ALTDOWN : 0) << 16;
+
+ WXWPARAM wParam = info->wVKey;
+
+ int keyCode = wxCharCodeMSWToWX(info->wVKey);
+ if ( !keyCode )
+ {
+ // wxCharCodeMSWToWX() returns 0 to indicate that this is a
+ // simple ASCII key
+ keyCode = wParam;
+ }
+
event.m_evtKey = CreateKeyEvent(wxEVT_KEY_DOWN,
- wxCharCodeMSWToWX(info->wVKey));
+ keyCode,
+ lParam,
+ wParam);
// a separate event for Space/Return
if ( !wxIsCtrlDown() && !wxIsShiftDown() &&
}
break;
- case TVN_SELCHANGED:
+ // NB: MSLU is broken and sends TVN_SELCHANGEDA instead of
+ // TVN_SELCHANGEDW in Unicode mode under Win98. Therefore
+ // we have to handle both messages:
+ case TVN_SELCHANGEDA:
+ case TVN_SELCHANGEDW:
eventType = wxEVT_COMMAND_TREE_SEL_CHANGED;
// fall through
- case TVN_SELCHANGING:
+ case TVN_SELCHANGINGA:
+ case TVN_SELCHANGINGW:
{
if ( eventType == wxEVT_NULL )
eventType = wxEVT_COMMAND_TREE_SEL_CHANGING;
//else: already set above
- NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam;
-
- event.m_item = (WXHTREEITEM) tv->itemNew.hItem;
- event.m_itemOld = (WXHTREEITEM) tv->itemOld.hItem;
+ if (hdr->code == TVN_SELCHANGINGW ||
+ hdr->code == TVN_SELCHANGEDW)
+ {
+ NM_TREEVIEWW* tv = (NM_TREEVIEWW *)lParam;
+ event.m_item = (WXHTREEITEM) tv->itemNew.hItem;
+ event.m_itemOld = (WXHTREEITEM) tv->itemOld.hItem;
+ }
+ else
+ {
+ NM_TREEVIEWA* tv = (NM_TREEVIEWA *)lParam;
+ event.m_item = (WXHTREEITEM) tv->itemNew.hItem;
+ event.m_itemOld = (WXHTREEITEM) tv->itemOld.hItem;
+ }
}
break;
}
HFONT hFont;
- wxColour colText, colBack;
if ( attr->HasFont() )
{
- wxFont font = attr->GetFont();
- hFont = (HFONT)font.GetResourceHandle();
+ hFont = GetHfontOf(attr->GetFont());
}
else
{
hFont = 0;
}
+ wxColour colText;
if ( attr->HasTextColour() )
{
colText = attr->GetTextColour();
// selection colours should override ours
if ( nmcd.uItemState & CDIS_SELECTED )
{
- DWORD clrBk = ::GetSysColor(COLOR_HIGHLIGHT);
- lptvcd->clrTextBk = clrBk;
-
- // try to make the text visible
- lptvcd->clrText = wxColourToRGB(colText);
- lptvcd->clrText |= ~clrBk;
- lptvcd->clrText &= 0x00ffffff;
+ lptvcd->clrTextBk =
+ ::GetSysColor(COLOR_HIGHLIGHT);
+ lptvcd->clrText =
+ ::GetSysColor(COLOR_HIGHLIGHTTEXT);
}
- else
+ else // !selected
{
+ wxColour colBack;
if ( attr->HasBackgroundColour() )
{
colBack = attr->GetBackgroundColour();