⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splittree.cpp

📁 ecos实时嵌入式操作系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
    // or the top of the window? How would we convert?    wxRect itemSize;    if (GetBoundingRect(id, itemSize))    {        rect = CombineRectangles(rect, itemSize);    }    long cookie;    wxTreeItemId childId = GetFirstChild(id, cookie);    while (childId != 0)    {        CalcTreeSize(childId, rect);        childId = GetNextChild(childId, cookie);    }}// Find the scrolled window that contains this controlecScrolledWindow* wxRemotelyScrolledTreeCtrl::GetScrolledWindow() const{    wxWindow* parent = wxWindow::GetParent();    while (parent)    {        if (parent->IsKindOf(CLASSINFO(ecScrolledWindow)))            return (ecScrolledWindow*) parent;        parent = parent->GetParent();    }    return NULL;}void wxRemotelyScrolledTreeCtrl::OnScroll(wxScrollWinEvent& event){    int orient = event.GetOrientation();    if (orient == wxHORIZONTAL)    {        event.Skip();        return;    }    ecScrolledWindow* scrollWin = GetScrolledWindow();    if (!scrollWin)        return;        int x, y;    scrollWin->GetViewStart(& x, & y);        ScrollToLine(-1, y);}/** wxTreeCompanionWindow** A window displaying values associated with tree control items.*/IMPLEMENT_CLASS(wxTreeCompanionWindow, wxWindow)BEGIN_EVENT_TABLE(wxTreeCompanionWindow, wxWindow)EVT_PAINT(wxTreeCompanionWindow::OnPaint)EVT_SCROLLWIN(wxTreeCompanionWindow::OnScroll)EVT_TREE_ITEM_EXPANDED(-1, wxTreeCompanionWindow::OnExpand)EVT_TREE_ITEM_COLLAPSED(-1, wxTreeCompanionWindow::OnExpand)END_EVENT_TABLE()wxTreeCompanionWindow::wxTreeCompanionWindow(wxWindow* parent, wxWindowID id,                                             const wxPoint& pos,                                             const wxSize& sz,                                             long style):wxWindow(parent, id, pos, sz, style){    m_treeCtrl = NULL;}void wxTreeCompanionWindow::DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect){    if (m_treeCtrl)    {        wxString text = m_treeCtrl->GetItemText(id);        dc.SetTextForeground(* wxBLACK);        dc.SetBackgroundMode(wxTRANSPARENT);                int textW, textH;        dc.GetTextExtent(text, & textW, & textH);                int x = 5;        int y = rect.GetY() + wxMax(0, (rect.GetHeight() - textH) / 2);                dc.DrawText(text, x, y);    }}void wxTreeCompanionWindow::OnPaint(wxPaintEvent& event){    wxPaintDC dc(this);        if (!m_treeCtrl)        return;        wxPen pen(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT), 1, wxSOLID);    dc.SetPen(pen);    dc.SetBrush(* wxTRANSPARENT_BRUSH);    wxFont font(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));    dc.SetFont(font);        wxSize clientSize = GetClientSize();    wxRect itemRect;    int cy=0;    wxTreeItemId h, lastH;    for(h=m_treeCtrl->GetFirstVisibleItem();h;h=m_treeCtrl->GetNextVisible(h))    {        if (m_treeCtrl->GetBoundingRect(h, itemRect))        {            cy = itemRect.GetTop();            wxRect drawItemRect(0, cy, clientSize.x, itemRect.GetHeight());                        lastH = h;                        // Draw the actual item            DrawItem(dc, h, drawItemRect);            dc.DrawLine(0, cy, clientSize.x, cy);        }    }    if (lastH.IsOk() && m_treeCtrl->GetBoundingRect(lastH, itemRect))    {        cy = itemRect.GetBottom();        dc.DrawLine(0, cy, clientSize.x, cy);    }}void wxTreeCompanionWindow::OnScroll(wxScrollWinEvent& event){    int orient = event.GetOrientation();    if (orient == wxHORIZONTAL)    {        event.Skip();        return;    }    if (!m_treeCtrl)        return;        // TODO: scroll the window physically instead of just refreshing.    Refresh(TRUE);}void wxTreeCompanionWindow::OnExpand(wxTreeEvent& event){    // TODO: something more optimized than simply refresh the whole    // window when the tree is expanded/collapsed. Tricky.    Refresh();}/** wxThinSplitterWindow*/IMPLEMENT_CLASS(wxThinSplitterWindow, wxSplitterWindow)BEGIN_EVENT_TABLE(wxThinSplitterWindow, wxSplitterWindow)EVT_SIZE(wxThinSplitterWindow::OnSize)// Not in older versions of wxWindows, unfortunately#if 0EVT_SPLITTER_DOUBLECLICKED(-1, wxThinSplitterWindow::OnDoubleClickSash)#endifEND_EVENT_TABLE()wxThinSplitterWindow::wxThinSplitterWindow(wxWindow* parent, wxWindowID id,                                           const wxPoint& pos,                                           const wxSize& sz,                                           long style):wxSplitterWindow(parent, id, pos, sz, style){}void wxThinSplitterWindow::SizeWindows(){    // The client size may have changed inbetween    // the sizing of the first window and the sizing of    // the second. So repeat SizeWindows.    wxSplitterWindow::SizeWindows();    wxSplitterWindow::SizeWindows();}// Tests for x, y over sashbool wxThinSplitterWindow::SashHitTest(int x, int y, int tolerance){    return wxSplitterWindow::SashHitTest(x, y, 4);}void wxThinSplitterWindow::DrawSash(wxDC& dc){    if ( m_sashPosition == 0 || !m_windowTwo)        return;    if (GetWindowStyle() & wxSP_NOSASH)        return;        int w, h;    GetClientSize(&w, &h);        if ( m_splitMode == wxSPLIT_VERTICAL )    {        dc.SetPen(* m_facePen);        dc.SetBrush(* m_faceBrush);        int h1 = h-1;        int y1 = 0;        if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )            h1 += 1; // Not sure why this is necessary...        if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)        {            y1 = 2; h1 -= 3;        }        dc.DrawRectangle(m_sashPosition, y1, m_sashSize, h1);    }    else    {        dc.SetPen(* m_facePen);        dc.SetBrush(* m_faceBrush);        int w1 = w-1;        int x1 = 0;        if ( (GetWindowStyleFlag() & wxSP_BORDER) != wxSP_BORDER && (GetWindowStyleFlag() & wxSP_3DBORDER) != wxSP_3DBORDER )            w1 ++;        if ( (GetWindowStyleFlag() & wxSP_3DBORDER) == wxSP_3DBORDER)        {            x1 = 2; w1 -= 3;        }        dc.DrawRectangle(x1, m_sashPosition, w1, m_sashSize);    }        dc.SetPen(wxNullPen);    dc.SetBrush(wxNullBrush);}void wxThinSplitterWindow::OnSize(wxSizeEvent& event){    wxSplitterWindow::OnSize(event);}/** wxSplitterScrolledWindow*/IMPLEMENT_CLASS(wxSplitterScrolledWindow, ecScrolledWindow)BEGIN_EVENT_TABLE(wxSplitterScrolledWindow, ecScrolledWindow)EVT_SCROLLWIN(wxSplitterScrolledWindow::OnScroll)EVT_SIZE(wxSplitterScrolledWindow::OnSize)END_EVENT_TABLE()wxSplitterScrolledWindow::wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id,                                                   const wxPoint& pos,                                                   const wxSize& sz,                                                   long style):  ecScrolledWindow(parent, id, pos, sz, style){}void wxSplitterScrolledWindow::OnSize(wxSizeEvent& event){    wxSize sz = GetClientSize();    if (GetChildren().First())    {        ((wxWindow*) GetChildren().First()->Data())->SetSize(0, 0, sz.x, sz.y);    }}void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event){    // Ensure that events being propagated back up the window hierarchy    // don't cause an infinite loop    static bool inOnScroll = FALSE;    if (inOnScroll)    {        event.Skip();        return;    }    inOnScroll = TRUE;        int orient = event.GetOrientation();        int nScrollInc = CalcScrollInc(event);    if (nScrollInc == 0)    {        inOnScroll = FALSE;        return;    }        if (orient == wxHORIZONTAL)    {        inOnScroll = FALSE;        event.Skip();        return;#if 0        int newPos = m_xScrollPosition + nScrollInc;        SetScrollPos(wxHORIZONTAL, newPos, TRUE );#endif    }    else    {        int newPos = m_yScrollPosition + nScrollInc;        SetScrollPos(wxVERTICAL, newPos, TRUE );    }        if (orient == wxHORIZONTAL)    {        m_xScrollPosition += nScrollInc;    }    else    {        m_yScrollPosition += nScrollInc;    }        // Find targets in splitter window and send the event to them    wxNode* node = GetChildren().First();    while (node)    {        wxWindow* child = (wxWindow*) node->Data();        if (child->IsKindOf(CLASSINFO(wxSplitterWindow)))        {            wxSplitterWindow* splitter = (wxSplitterWindow*) child;            if (splitter->GetWindow1())                splitter->GetWindow1()->ProcessEvent(event);            if (splitter->GetWindow2())                splitter->GetWindow2()->ProcessEvent(event);            break;        }        node = node->Next();    }    #ifdef __WXMAC__    m_targetWindow->MacUpdateImmediately() ;#endif        inOnScroll = FALSE;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -