#endif
// verify that the item is ok and insult the user if it is not
-#define CHECK_ITEM( item ) if ( !item.IsOk() ) { \
- wxMessageBox("Please select some item first!", \
- "Tree sample error", \
- wxOK | wxICON_EXCLAMATION, \
- this); \
- return; \
+#define CHECK_ITEM( item ) if ( !item.IsOk() ) { \
+ wxMessageBox(wxT("Please select some item first!"), \
+ wxT("Tree sample error"), \
+ wxOK | wxICON_EXCLAMATION, \
+ this); \
+ return; \
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
bool MyApp::OnInit()
{
// Create the main frame window
- MyFrame *frame = new MyFrame("wxTreeCtrl Test", 50, 50, 450, 600);
+ MyFrame *frame = new MyFrame(wxT("wxTreeCtrl Test"), 50, 50, 450, 600);
// Show the frame
frame->Show(TRUE);
*tree_menu = new wxMenu,
*item_menu = new wxMenu;
- file_menu->Append(TreeTest_About, "&About...");
+ file_menu->Append(TreeTest_About, wxT("&About..."));
file_menu->AppendSeparator();
- file_menu->Append(TreeTest_Quit, "E&xit\tAlt-X");
+ file_menu->Append(TreeTest_Quit, wxT("E&xit\tAlt-X"));
style_menu->Append(TreeTest_TogButtons, "Toggle &normal buttons");
style_menu->Append(TreeTest_TogTwist, "Toggle &twister buttons");
style_menu->Append(TreeTest_TogBorder, "Toggle &item border");
style_menu->Append(TreeTest_TogEdit, "Toggle &edit mode");
#ifndef NO_MULTIPLE_SELECTION
- style_menu->Append(TreeTest_ToggleSel, "Toggle &selection mode");
+ style_menu->Append(TreeTest_ToggleSel, wxT("Toggle &selection mode"));
#endif // NO_MULTIPLE_SELECTION
- style_menu->Append(TreeTest_ToggleImages, "Toggle show ima&ges");
- style_menu->Append(TreeTest_SetImageSize, "Set image si&ze...");
+ style_menu->Append(TreeTest_ToggleImages, wxT("Toggle show ima&ges"));
+ style_menu->Append(TreeTest_SetImageSize, wxT("Set image si&ze..."));
tree_menu->Append(TreeTest_Recreate, "&Recreate the tree");
tree_menu->Append(TreeTest_CollapseAndReset, "C&ollapse and reset");
for ( size_t n = 0; n < count; n++ )
{
- wxLogMessage("\t%s", m_treeCtrl->GetItemText(array.Item(n)).c_str());
+ wxLogMessage(wxT("\t%s"), m_treeCtrl->GetItemText(array.Item(n)).c_str());
}
}
void MyFrame::OnToggleButtons(wxCommandEvent& event)
{
+#if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
if ( wxGetApp().ShowButtons() )
{
m_treeCtrl->CreateButtonsImageList(-1);
m_treeCtrl->CreateButtonsImageList(15);
wxGetApp().SetShowButtons(TRUE);
}
+#endif
}
void MyFrame::OnCollapseAndReset(wxCommandEvent& event)
static int s_num = 0;
wxString text;
- text.Printf("Item #%d", ++s_num);
+ text.Printf(wxT("Item #%d"), ++s_num);
m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(),
text /*,
void MyTreeCtrl::CreateButtonsImageList(int size)
{
+#if USE_GENERIC_TREECTRL || !defined(__WXMSW__)
if ( size == -1 )
{
SetButtonsImageList(NULL);
#endif // MSW/!MSW
AssignButtonsImageList(images);
+#endif
}
MyTreeCtrl::~MyTreeCtrl()
{
// at depth 1 elements won't have any more children
if ( hasChildren )
- str.Printf("%s child %d", "Folder", n + 1);
+ str.Printf(wxT("%s child %d"), wxT("Folder"), n + 1);
else
- str.Printf("%s child %d.%d", "File", folder, n + 1);
+ str.Printf(wxT("%s child %d.%d"), wxT("File"), folder, n + 1);
// here we pass to AppendItem() normal and selected item images (we
// suppose that selected image follows the normal one in the enum)
// avoid repetition
-#define TREE_EVENT_HANDLER(name) \
-void MyTreeCtrl::name(wxTreeEvent& event) \
-{ \
- wxLogMessage(#name); \
- event.Skip(); \
+#define TREE_EVENT_HANDLER(name) \
+void MyTreeCtrl::name(wxTreeEvent& event) \
+{ \
+ wxLogMessage(wxT(#name)); \
+ event.Skip(); \
}
TREE_EVENT_HANDLER(OnBeginRDrag)
{
m_draggedItem = event.GetItem();
- wxLogMessage("OnBeginDrag: started dragging %s",
+ wxLogMessage(wxT("OnBeginDrag: started dragging %s"),
GetItemText(m_draggedItem).c_str());
event.Allow();
}
else
{
- wxLogMessage("OnBeginDrag: this item can't be dragged.");
+ wxLogMessage(wxT("OnBeginDrag: this item can't be dragged."));
}
}
if ( !itemDst.IsOk() )
{
- wxLogMessage("OnEndDrag: can't drop here.");
+ wxLogMessage(wxT("OnEndDrag: can't drop here."));
return;
}
wxString text = GetItemText(itemSrc);
- wxLogMessage("OnEndDrag: '%s' copied to '%s'.",
+ wxLogMessage(wxT("OnEndDrag: '%s' copied to '%s'."),
text.c_str(), GetItemText(itemDst).c_str());
// just do append here - we could also insert it just before/after the item
void MyTreeCtrl::OnBeginLabelEdit(wxTreeEvent& event)
{
- wxLogMessage("OnBeginLabelEdit");
+ wxLogMessage(wxT("OnBeginLabelEdit"));
// for testing, prevent this item's label editing
wxTreeItemId itemId = event.GetItem();
if ( IsTestItem(itemId) )
{
- wxMessageBox("You can't edit this item.");
+ wxMessageBox(wxT("You can't edit this item."));
event.Veto();
}
void MyTreeCtrl::OnEndLabelEdit(wxTreeEvent& event)
{
- wxLogMessage("OnEndLabelEdit");
+ wxLogMessage(wxT("OnEndLabelEdit"));
// don't allow anything except letters in the labels
if ( !event.GetLabel().IsWord() )
{
- wxMessageBox("The label should contain only letters.");
+ wxMessageBox(wxT("The label should contain only letters."));
event.Veto();
}
void MyTreeCtrl::OnItemCollapsing(wxTreeEvent& event)
{
- wxLogMessage("OnItemCollapsing");
+ wxLogMessage(wxT("OnItemCollapsing"));
// for testing, prevent the user from collapsing the first child folder
wxTreeItemId itemId = event.GetItem();
if ( IsTestItem(itemId) )
{
- wxMessageBox("You can't collapse this item.");
+ wxMessageBox(wxT("You can't collapse this item."));
event.Veto();
}
item->ShowInfo(this);
}
- wxLogMessage("OnItemActivated");
+ wxLogMessage(wxT("OnItemActivated"));
}
void MyTreeCtrl::OnItemRightClick(wxTreeEvent& event)
{
wxTreeItemId id = HitTest(event.GetPosition());
if ( !id )
- wxLogMessage("No item under mouse");
+ wxLogMessage(wxT("No item under mouse"));
else
{
MyTreeItemData *item = (MyTreeItemData *)GetItemData(id);
if ( item )
- wxLogMessage("Item '%s' under mouse", item->GetDesc());
+ wxLogMessage(wxT("Item '%s' under mouse"), item->GetDesc());
}
}
-static inline const char *Bool2String(bool b)
+static inline const wxChar *Bool2String(bool b)
{
- return b ? "" : "not ";
+ return b ? wxT("") : wxT("not ");
}
void MyTreeItemData::ShowInfo(wxTreeCtrl *tree)
{
- wxLogMessage("Item '%s': %sselected, %sexpanded, %sbold,\n"
- "%u children (%u immediately under this item).",
+ wxLogMessage(wxT("Item '%s': %sselected, %sexpanded, %sbold,\n")
+ wxT("%u children (%u immediately under this item)."),
m_desc.c_str(),
Bool2String(tree->IsSelected(GetId())),
Bool2String(tree->IsExpanded(GetId())),