X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c74caa095c12410bd6a555df248699cb35821a8d..b388e8cdec4f45124f31525e651a5e335965e4be:/contrib/utils/wxrcedit/propframe.cpp?ds=sidebyside diff --git a/contrib/utils/wxrcedit/propframe.cpp b/contrib/utils/wxrcedit/propframe.cpp index 1e160c67e7..b31b83425c 100644 --- a/contrib/utils/wxrcedit/propframe.cpp +++ b/contrib/utils/wxrcedit/propframe.cpp @@ -38,52 +38,52 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl PropsTree(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS) : wxRemotelyScrolledTreeCtrl(parent, id, pt, sz, style), - m_EditCtrl(NULL) - { + m_EditCtrl(NULL) + { #if 0 // VS: Don't do it, it is *extremely* ugly. // FIXME: find a better solution. - //make text larger so controls will fit properly - wxFont font = GetFont(); - font.SetPointSize(font.GetPointSize()*1.5); - SetFont(font); + //make text larger so controls will fit properly + wxFont font = GetFont(); + font.SetPointSize(font.GetPointSize()*1.5); + SetFont(font); #endif } - void OnPaint(wxPaintEvent& event) + void OnPaint(wxPaintEvent& event) { - wxPaintDC dc(this); + wxPaintDC dc(this); - wxTreeCtrl::OnPaint(event); + wxTreeCtrl::OnPaint(event); // Reset the device origin since it may have been set dc.SetDeviceOrigin(0, 0); - wxPen pen(wxColour(_T("BLACK")), 1, wxSOLID); - dc.SetPen(pen); + wxPen pen(*wxBLACK, 1, wxSOLID); + dc.SetPen(pen); - dc.SetBrush(* wxTRANSPARENT_BRUSH); + dc.SetBrush(*wxTRANSPARENT_BRUSH); wxSize clientSize = GetClientSize(); - wxRect itemRect; - int cy=0; - wxTreeItemId h, lastH; - for(h=GetFirstVisibleItem();h;h=GetNextVisible(h)) - { - if (h.IsOk() && GetBoundingRect(h, itemRect)) - { - cy = itemRect.GetTop(); - - dc.DrawLine(0, cy, clientSize.x, cy); - lastH = h; - } - } - if (lastH.IsOk() && GetBoundingRect(lastH, itemRect)) - { - cy = itemRect.GetBottom(); - dc.DrawLine(0, cy, clientSize.x, cy); - } + wxRect itemRect; + int cy=0; + wxTreeItemId h, lastH; + for(h=GetFirstVisibleItem();h;h=GetNextVisible(h)) + { + if (h.IsOk() && GetBoundingRect(h, itemRect)) + { + cy = itemRect.GetTop(); + + dc.DrawLine(0, cy, clientSize.x, cy); + lastH = h; + } + } + if (lastH.IsOk() && GetBoundingRect(lastH, itemRect)) + { + cy = itemRect.GetBottom(); + dc.DrawLine(0, cy, clientSize.x, cy); + } } void OnSelChange(wxTreeEvent& event) @@ -93,7 +93,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl m_EditCtrl->EndEdit(); m_EditCtrl = NULL; } - + wxTreeItemId item = event.GetItem(); PETreeData *dt = (PETreeData*)GetItemData(item); if (dt != NULL) @@ -102,7 +102,7 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl GetBoundingRect(item, bounding); bounding.SetX(0); - bounding.SetWidth(GetCompanionWindow()->GetSize().x); + bounding.SetWidth(GetCompanionWindow()->GetSize().x); dt->EditCtrl->BeginEdit(bounding, item); m_EditCtrl = dt->EditCtrl; } @@ -124,22 +124,22 @@ class PropsTree: public wxRemotelyScrolledTreeCtrl event.Skip(); if (event.GetOrientation() == wxHORIZONTAL) return; if (!m_EditCtrl) return; - + wxTreeItemId id = GetSelection(); wxRect bounding; GetBoundingRect(id, bounding); - - m_EditCtrl->Move(-1, bounding.y); + + m_EditCtrl->Move(wxDefaultCoord, bounding.y); } - + PropEditCtrl *m_EditCtrl; - + DECLARE_EVENT_TABLE() }; BEGIN_EVENT_TABLE(PropsTree, wxRemotelyScrolledTreeCtrl) - EVT_PAINT(PropsTree::OnPaint) - EVT_TREE_SEL_CHANGED(-1, PropsTree::OnSelChange) + EVT_PAINT(PropsTree::OnPaint) + EVT_TREE_SEL_CHANGED(wxID_ANY, PropsTree::OnSelChange) EVT_SCROLLWIN(PropsTree::OnScroll) END_EVENT_TABLE() @@ -147,34 +147,34 @@ END_EVENT_TABLE() class PropsValueWindow: public wxTreeCompanionWindow { public: - PropsValueWindow(wxWindow* parent, wxWindowID id = -1, + PropsValueWindow(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = 0) : wxTreeCompanionWindow(parent, id, pos, sz, style) {} - + virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect) { - if (m_treeCtrl) - { + if (m_treeCtrl) + { PETreeData *data = (PETreeData*)m_treeCtrl->GetItemData(id); - wxString text; + wxString text; if (data != NULL) text = data->EditCtrl->GetValueAsText(id); dc.SetBrush(wxBrush(GetBackgroundColour(), wxSOLID)); dc.DrawRectangle(rect); - dc.SetTextForeground(* wxBLACK); - dc.SetBackgroundMode(wxTRANSPARENT); + dc.SetTextForeground(* wxBLACK); + dc.SetBackgroundMode(wxTRANSPARENT); - int textW, textH; - dc.GetTextExtent(text, & textW, & textH); + int textW, textH; + dc.GetTextExtent(text, & textW, & textH); - int x = 5; - int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2); + int x = 5; + int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2); - dc.DrawText(text, x, y); - } + dc.DrawText(text, x, y); + } } - + void OnClick(wxMouseEvent& event) { int flags; @@ -189,7 +189,7 @@ class PropsValueWindow: public wxTreeCompanionWindow }; BEGIN_EVENT_TABLE(PropsValueWindow, wxTreeCompanionWindow) - EVT_LEFT_DOWN(PropsValueWindow::OnClick) + EVT_LEFT_DOWN(PropsValueWindow::OnClick) END_EVENT_TABLE() @@ -202,18 +202,18 @@ PropertiesFrame* PropertiesFrame::ms_Instance = NULL; PropertiesFrame *PropertiesFrame::Get() { - if (ms_Instance == NULL) + if (ms_Instance == NULL) { (void)new PropertiesFrame; - ms_Instance->Show(TRUE); + ms_Instance->Show(true); } return ms_Instance; } PropertiesFrame::PropertiesFrame() - : wxFrame(EditorFrame::Get(), -1, _("Properties"), + : wxFrame(EditorFrame::Get(), wxID_ANY, _("Properties"), wxDefaultPosition, wxDefaultSize, - wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR + wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR #ifdef __WXMSW__ | wxFRAME_TOOL_WINDOW #endif @@ -222,34 +222,34 @@ PropertiesFrame::PropertiesFrame() ms_Instance = this; m_Node = NULL; - m_scrolledWindow = new wxSplitterScrolledWindow(this, -1, wxDefaultPosition, - wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); - m_splitter = new wxThinSplitterWindow(m_scrolledWindow, -1, wxDefaultPosition, - wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */); - m_splitter->SetSashSize(2); - m_tree = new PropsTree(m_splitter, -1, wxDefaultPosition, - wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER ); + m_scrolledWindow = new wxSplitterScrolledWindow(this, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxNO_BORDER | wxCLIP_CHILDREN | wxVSCROLL); + m_splitter = new wxThinSplitterWindow(m_scrolledWindow, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxSP_3DBORDER | wxCLIP_CHILDREN /* | wxSP_LIVE_UPDATE */); + m_splitter->SetSashSize(2); + m_tree = new PropsTree(m_splitter, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxTR_HAS_BUTTONS | wxTR_NO_LINES | wxNO_BORDER ); m_tree->SetIndent(2); - m_valueWindow = new PropsValueWindow(m_splitter, -1, wxDefaultPosition, - wxDefaultSize, wxNO_BORDER); + m_valueWindow = new PropsValueWindow(m_splitter, wxID_ANY, wxDefaultPosition, + wxDefaultSize, wxNO_BORDER); m_valueWindow->SetBackgroundColour(m_tree->GetBackgroundColour()); m_splitter->SplitVertically(m_tree, m_valueWindow, wxConfig::Get()->Read(_T("propertiesframe_sash"), 100)); - //m_splitter->AdjustScrollbars(); - m_scrolledWindow->SetTargetWindow(m_tree); + //m_splitter->AdjustScrollbars(); + m_scrolledWindow->SetTargetWindow(m_tree); - m_scrolledWindow->EnableScrolling(FALSE, FALSE); + m_scrolledWindow->EnableScrolling(false, false); - // Let the two controls know about each other - m_valueWindow->SetTreeCtrl(m_tree); - m_tree->SetCompanionWindow(m_valueWindow); + // Let the two controls know about each other + m_valueWindow->SetTreeCtrl(m_tree); + m_tree->SetCompanionWindow(m_valueWindow); wxConfigBase *cfg = wxConfigBase::Get(); - SetSize(wxRect(wxPoint(cfg->Read(_T("propertiesframe_x"), -1), cfg->Read(_T("propertiesframe_y"), -1)), + SetSize(wxRect(wxPoint(cfg->Read(_T("propertiesframe_x"), wxDefaultCoord), cfg->Read(_T("propertiesframe_y"), wxDefaultCoord)), wxSize(cfg->Read(_T("propertiesframe_w"), 200), cfg->Read(_T("propertiesframe_h"), 200)))); - - m_EditCtrls.DeleteContents(TRUE); + + m_EditCtrls.DeleteContents(true); m_EditCtrls.Put(_T("bool"), new PropEditCtrlBool(this)); m_EditCtrls.Put(_T("coord"), new PropEditCtrlCoord(this)); m_EditCtrls.Put(_T("color"), new PropEditCtrlColor(this)); @@ -264,7 +264,7 @@ PropertiesFrame::PropertiesFrame() m_EditCtrls.Put(_T("file"), new PropEditCtrlFile(this)); m_EditCtrls.Put(_T("imagefile"), new PropEditCtrlImageFile(this)); m_EditCtrls.Put(_T(""), new PropEditCtrlNull(this)); - + ClearProps(); } @@ -272,26 +272,26 @@ PropertiesFrame::PropertiesFrame() PropertiesFrame::~PropertiesFrame() { - wxConfigBase *cfg = wxConfigBase::Get(); + wxConfigBase *cfg = wxConfigBase::Get(); cfg->Write(_T("propertiesframe_x"), (long)GetPosition().x); cfg->Write(_T("propertiesframe_y"), (long)GetPosition().y); cfg->Write(_T("propertiesframe_w"), (long)GetSize().x); cfg->Write(_T("propertiesframe_h"), (long)GetSize().y); cfg->Write(_T("propertiesframe_sash"), (long)m_splitter->GetSashPosition()); - + ms_Instance = NULL; } - + void PropertiesFrame::ShowProps(wxXmlNode *node) { m_Node = node; - + ClearProps(); AddSingleProp(PropertyInfo(_T("xmlid"), _T("XRCID"), wxEmptyString)); AddProps(NodeHandler::Find(node)->GetPropsList(node)); - + m_tree->Expand(m_tree->GetRootItem()); m_valueWindow->Refresh(); } @@ -321,7 +321,7 @@ void PropertiesFrame::AddSingleProp(const PropertyInfo& pinfo, wxTreeItemId *roo wxTreeItemId tid; if (root != NULL) tid = *root; else tid = m_tree->GetRootItem(); - + if (pec == NULL) wxLogError(_("Unknown property type '%s'!"), pinfo.Type.c_str()); else