X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fbfb8bcc3fa17e079d4219655b173f8ed2ccc65a..85b1997c095b18cd5e9e54e9d39feaa71c5ffa06:/samples/regtest/regtest.cpp diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index dd05152ec7..3baae4694f 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -233,7 +233,7 @@ enum Menu_Delete, Menu_Info, - Ctrl_RegTree = 200, + Ctrl_RegTree = 200 }; // ---------------------------------------------------------------------------- @@ -259,9 +259,10 @@ END_EVENT_TABLE() #if DO_REGTEST BEGIN_EVENT_TABLE(RegTreeCtrl, wxTreeCtrl) - EVT_TREE_DELETE_ITEM (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem) - EVT_TREE_ITEM_EXPANDING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) - EVT_TREE_SEL_CHANGED (Ctrl_RegTree, RegTreeCtrl::OnSelChanged) + EVT_TREE_DELETE_ITEM (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem) + EVT_TREE_ITEM_EXPANDING (Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) + EVT_TREE_ITEM_COLLAPSING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) + EVT_TREE_SEL_CHANGED (Ctrl_RegTree, RegTreeCtrl::OnSelChanged) EVT_TREE_BEGIN_LABEL_EDIT(Ctrl_RegTree, RegTreeCtrl::OnBeginEdit) EVT_TREE_END_LABEL_EDIT (Ctrl_RegTree, RegTreeCtrl::OnEndEdit) @@ -289,23 +290,23 @@ END_EVENT_TABLE() wxMenu *CreateRegistryMenu() { wxMenu *pMenuNew = new wxMenu; - pMenuNew->Append(Menu_NewKey, _T("&Key"), _T("Create a new key")); + pMenuNew->Append(Menu_NewKey, wxT("&Key"), wxT("Create a new key")); pMenuNew->AppendSeparator(); - pMenuNew->Append(Menu_NewText, _T("&Text value"), _T("Create a new text value")); - pMenuNew->Append(Menu_NewBinary, _T("&Binary value"), _T("Create a new binary value")); + pMenuNew->Append(Menu_NewText, wxT("&Text value"), wxT("Create a new text value")); + pMenuNew->Append(Menu_NewBinary, wxT("&Binary value"), wxT("Create a new binary value")); wxMenu *pMenuReg = new wxMenu; - pMenuReg->Append(Menu_New, _T("&New"), pMenuNew); - pMenuReg->Append(Menu_Delete, _T("&Delete..."), _T("Delete selected key/value")); + pMenuReg->Append(Menu_New, wxT("&New"), pMenuNew); + pMenuReg->Append(Menu_Delete, wxT("&Delete..."), wxT("Delete selected key/value")); pMenuReg->AppendSeparator(); - pMenuReg->Append(Menu_GoTo, _T("&Go to...\tCtrl-G"), _T("Go to registry key")); - pMenuReg->Append(Menu_Expand, _T("&Expand"), _T("Expand current key")); - pMenuReg->Append(Menu_Collapse, _T("&Collapse"), _T("Collapse current key")); - pMenuReg->Append(Menu_Toggle, _T("&Toggle"), _T("Toggle current key")); + pMenuReg->Append(Menu_GoTo, wxT("&Go to...\tCtrl-G"), wxT("Go to registry key")); + pMenuReg->Append(Menu_Expand, wxT("&Expand"), wxT("Expand current key")); + pMenuReg->Append(Menu_Collapse, wxT("&Collapse"), wxT("Collapse current key")); + pMenuReg->Append(Menu_Toggle, wxT("&Toggle"), wxT("Toggle current key")); pMenuReg->AppendSeparator(); - pMenuReg->Append(Menu_Refresh, _T("&Refresh"), _T("Refresh the subtree")); + pMenuReg->Append(Menu_Refresh, wxT("&Refresh"), wxT("Refresh the subtree")); pMenuReg->AppendSeparator(); - pMenuReg->Append(Menu_Info, _T("&Properties"),_T("Information about current selection")); + pMenuReg->Append(Menu_Info, wxT("&Properties"),wxT("Information about current selection")); return pMenuReg; } @@ -318,8 +319,11 @@ IMPLEMENT_APP(RegApp) // `Main program' equivalent, creating windows and returning main app frame bool RegApp::OnInit() { + if ( !wxApp::OnInit() ) + return false; + // create the main frame window and show it - RegFrame *frame = new RegFrame(NULL, _T("wxRegTest"), 50, 50, 600, 350); + RegFrame *frame = new RegFrame(NULL, wxT("wxRegTest"), 50, 50, 600, 350); frame->Show(true); SetTopWindow(frame); @@ -339,20 +343,20 @@ RegFrame::RegFrame(wxFrame *parent, const wxChar *title, int x, int y, int w, in // set the icon // ------------ - SetIcon(wxIcon(_T("app_icon"))); + SetIcon(wxIcon(wxT("app_icon"))); // create menu // ----------- wxMenu *pMenuFile = new wxMenu; - pMenuFile->Append(Menu_Test, _T("Te&st"), _T("Test key creation")); + pMenuFile->Append(Menu_Test, wxT("Te&st"), wxT("Test key creation")); pMenuFile->AppendSeparator(); - pMenuFile->Append(Menu_About, _T("&About..."), _T("Show an extraordinarly beautiful dialog")); + pMenuFile->Append(Menu_About, wxT("&About..."), wxT("Show an extraordinarly beautiful dialog")); pMenuFile->AppendSeparator(); - pMenuFile->Append(Menu_Quit, _T("E&xit"), _T("Quit this program")); + pMenuFile->Append(Menu_Quit, wxT("E&xit"), wxT("Quit this program")); wxMenuBar *pMenu = new wxMenuBar; - pMenu->Append(pMenuFile, _T("&File")); - pMenu->Append(CreateRegistryMenu(), _T("&Registry")); + pMenu->Append(pMenuFile, wxT("&File")); + pMenu->Append(CreateRegistryMenu(), wxT("&Registry")); SetMenuBar(pMenu); #if DO_REGTEST @@ -384,9 +388,9 @@ void RegFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void RegFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxMessageDialog dialog(this, - _T("wxRegistry sample\n") - _T("(c) 1998, 2000 Vadim Zeitlin"), - _T("About wxRegTest"), wxOK); + wxT("wxRegistry sample\n") + wxT("(c) 1998, 2000 Vadim Zeitlin"), + wxT("About wxRegTest"), wxOK); dialog.ShowModal(); } @@ -400,11 +404,11 @@ void RegFrame::OnTest(wxCommandEvent& WXUNUSED(event)) void RegFrame::OnGoTo(wxCommandEvent& WXUNUSED(event)) { - static wxString s_location = _T("HKEY_CURRENT_USER\\Software\\wxWidgets"); + static wxString s_location = wxT("HKEY_CURRENT_USER\\Software\\wxWidgets"); wxString location = wxGetTextFromUser( - _T("Enter the location to go to:"), - _T("wxRegTest question"), + wxT("Enter the location to go to:"), + wxT("wxRegTest question"), s_location, this); @@ -458,7 +462,7 @@ void RegFrame::OnNewKey(wxCommandEvent& WXUNUSED(event)) if ( m_treeCtrl->IsKeySelected() ) { m_treeCtrl->CreateNewKey( - wxGetTextFromUser(_T("Enter the name of the new key"))); + wxGetTextFromUser(wxT("Enter the name of the new key"))); } #endif } @@ -469,7 +473,7 @@ void RegFrame::OnNewText(wxCommandEvent& WXUNUSED(event)) if ( m_treeCtrl->IsKeySelected() ) { m_treeCtrl->CreateNewTextValue( - wxGetTextFromUser(_T("Enter the name for the new text value"))); + wxGetTextFromUser(wxT("Enter the name for the new text value"))); } #endif } @@ -480,7 +484,7 @@ void RegFrame::OnNewBinary(wxCommandEvent& WXUNUSED(event)) if ( m_treeCtrl->IsKeySelected() ) { m_treeCtrl->CreateNewBinaryValue( - wxGetTextFromUser(_T("Enter the name for the new binary value"))); + wxGetTextFromUser(wxT("Enter the name for the new binary value"))); } #endif } @@ -498,8 +502,8 @@ void RegFrame::OnInfo(wxCommandEvent& WXUNUSED(event)) RegImageList::RegImageList() : wxImageList(16, 16, true) { // should be in sync with enum RegImageList::RegIcon - static const wxChar *aszIcons[] = { _T("key1"),_T("key2"),_T("key3"),_T("value1"),_T("value2") }; - wxString str = _T("icon_"); + static const wxChar *aszIcons[] = { wxT("key1"),wxT("key2"),wxT("key3"),wxT("value1"),wxT("value2") }; + wxString str = wxT("icon_"); for ( unsigned int n = 0; n < WXSIZEOF(aszIcons); n++ ) { Add(wxIcon(str + aszIcons[n], wxBITMAP_TYPE_ICO_RESOURCE)); @@ -578,7 +582,7 @@ RegTreeCtrl::RegTreeCtrl(wxWindow *parent, wxWindowID id) // create root keys // ---------------- - m_pRoot = InsertNewTreeNode(NULL, _T("Registry Root"), RegImageList::Root); + m_pRoot = InsertNewTreeNode(NULL, wxT("Registry Root"), RegImageList::Root); // create popup menu // ----------------- @@ -655,16 +659,16 @@ void RegTreeCtrl::OnMenuTest() return; } - wxRegKey key1(pNode->Key(), _T("key1")); + wxRegKey key1(pNode->Key(), wxT("key1")); if ( key1.Create() ) { - wxRegKey key2a(key1, _T("key2a")), key2b(key1, _T("key2b")); + wxRegKey key2a(key1, wxT("key2a")), key2b(key1, wxT("key2b")); if ( key2a.Create() && key2b.Create() ) { // put some values under the newly created keys - key1.SetValue(wxT("first_term"), _T("10")); - key1.SetValue(wxT("second_term"), _T("7")); - key2a = _T("this is the unnamed value"); + key1.SetValue(wxT("first_term"), wxT("10")); + key1.SetValue(wxT("second_term"), wxT("7")); + key2a = wxT("this is the unnamed value"); key2b.SetValue(wxT("sum"), 17); // refresh tree @@ -710,7 +714,7 @@ void RegTreeCtrl::OnSelChanged(wxTreeEvent& event) void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event) { TreeNode *pNode = GetNode(event); - bool bExpanding = event.GetKeyCode() == wxTREE_EXPAND_EXPAND; + bool bExpanding = event.GetEventType() == wxEVT_COMMAND_TREE_ITEM_EXPANDING; // expansion might take some time wxSetCursor(*wxHOURGLASS_CURSOR); @@ -739,7 +743,7 @@ void RegTreeCtrl::OnBeginEdit(wxTreeEvent& event) TreeNode *pNode = GetNode(event); if ( pNode->IsRoot() || pNode->Parent()->IsRoot() ) { - wxLogStatus(_T("This registry key can't be renamed.")); + wxLogStatus(wxT("This registry key can't be renamed.")); event.Veto(); } @@ -771,7 +775,7 @@ void RegTreeCtrl::OnEndEdit(wxTreeEvent& event) if ( !ok ) { - wxLogError(_T("Failed to rename '%s' to '%s'."), + wxLogError(wxT("Failed to rename '%s' to '%s'."), m_nameOld.c_str(), name.c_str()); } #if 0 // MSW tree ctrl doesn't like this at all, it hangs @@ -841,8 +845,8 @@ void RegTreeCtrl::OnEndDrag(wxTreeEvent& event) nameDst << wxString(dst->FullName()).AfterFirst('\\') << '\\' << wxString(src->FullName()).AfterLast('\\'); - wxString verb = m_copyOnDrop ? _T("copy") : _T("move"); - wxString what = isKey ? _T("key") : _T("value"); + wxString verb = m_copyOnDrop ? wxT("copy") : wxT("move"); + wxString what = isKey ? wxT("key") : wxT("value"); if ( wxMessageBox(wxString::Format ( @@ -852,7 +856,7 @@ void RegTreeCtrl::OnEndDrag(wxTreeEvent& event) nameSrc.c_str(), nameDst.c_str() ), - _T("RegTest Confirm"), + wxT("RegTest Confirm"), wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) { return; } @@ -965,10 +969,10 @@ bool RegTreeCtrl::TreeNode::OnExpand() { wxString strItem; if (str.empty()) - strItem = _T(""); + strItem = wxT(""); else strItem = str; - strItem += _T(" = "); + strItem += wxT(" = "); // determine the appropriate icon RegImageList::Icon icon; @@ -1125,7 +1129,7 @@ const wxChar *RegTreeCtrl::TreeNode::FullName() const void RegTreeCtrl::GoTo(const wxString& location) { - wxStringTokenizer tk(location, _T("\\")); + wxStringTokenizer tk(location, wxT("\\")); wxTreeItemId id = GetRootItem(); @@ -1168,7 +1172,7 @@ void RegTreeCtrl::GoTo(const wxString& location) if ( !id.IsOk() ) { - wxLogError(_T("No such key '%s'."), location.c_str()); + wxLogError(wxT("No such key '%s'."), location.c_str()); return; } @@ -1200,13 +1204,13 @@ void RegTreeCtrl::DeleteSelected() return; } - wxString what = pCurrent->IsKey() ? _T("key") : _T("value"); + wxString what = pCurrent->IsKey() ? wxT("key") : wxT("value"); if ( wxMessageBox(wxString::Format ( wxT("Do you really want to delete this %s?"), what.c_str() ), - _T("Confirmation"), + wxT("Confirmation"), wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) { return;