void CTLFrame::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); // resize all the controls { CRect m_wndRect; GetClientRect(&m_wndRect); CRect m_headerRect; m_tree.m_wndHeader.GetWindowRect(&m_headerRect); m_tree.ScreenToClient(&m_headerRect); m_tree.m_wndHeader.SetWindowPos(&wndTop, 0, 0, -m_headerRect.left + m_wndRect.Width(), m_headerRect.Height(), SWP_NOMOVE); CRect m_scrollRect; m_horScrollBar.GetClientRect(&m_scrollRect); m_tree.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height() - m_scrollRect.Height(), SWP_NOMOVE); CRect m_treeRect; m_tree.GetClientRect(&m_treeRect); m_horScrollBar.SetWindowPos(&wndTop, 0, m_treeRect.bottom, m_wndRect.Width(), m_scrollRect.Height(), SWP_SHOWWINDOW); m_tree.ResetVertScrollBar(); ResetScrollBar(); } }
void CBirchCtrl::OnSize(UINT nType, int cx, int cy) { // Setting the scroll sends its own size message. Prevent it thus avoiding an ugly loop. // Other than that, resizing the control means that the tree height may change (word-wrap). if( !m_bScrollBarMessage ) ResetScrollBar(); if (m_edit) { CRect rrr; m_edit->GetWindowRect(rrr); ScreenToClient(rrr); rrr.right = cx; m_edit->MoveWindow(rrr); } CWnd::OnSize(nType, cx, cy); }
void CPWL_Note::RePosChildWnd() { RePosNoteChildren(); m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); ResetScrollBar(); m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, 0); //ͬ²½ if (const CPWL_Wnd* pWnd = this->GetFocused()) { if (pWnd->GetClassName() == "CPWL_Edit") { CPWL_Edit* pEdit = (CPWL_Edit*)pWnd; pEdit->SetCaret(pEdit->GetCaret()); } } //CPDF_Point ptNew = m_pContents->GetScrollPos(); //m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptNew.y); }
bool BContainer::Create(unsigned int x, unsigned int y, unsigned int width, unsigned height,CWnd* parent,unsigned int ID) { if(parent == NULL) return false; if(!CWnd::Create(NULL,NULL,WS_CHILD | WS_VISIBLE | WS_VSCROLL, CRect(x,y,x+width, y+height),parent,ID)) return false; tooltipCtrl.Create(this,TTS_ALWAYSTIP | TTF_TRACK | TTF_ABSOLUTE); tooltipCtrl.SetDelayTime(TTDT_INITIAL, 0); tooltipCtrl.SetDelayTime(TTDT_AUTOPOP, 120*1000); tooltipCtrl.Activate(true); tooltipCtrl.SetFont(&simpleFont); tooltipCtrl.SetTipBkColor(RGB(255,255,255)); tooltipCtrl.SetTipTextColor(RGB(255,0,0)); ResetScrollBar(); return true; }
void BContainer::ShowChildren() { DWORD yPos; BItem* item; CRect rect; yPos = 0; for (int i=0;i<vElements.GetSize();i++) { BItem* parent = GetParent(i); item = (BItem*)vElements.GetPointer(i); if(parent !=NULL && parent->collapsed == ITEM_COLLAPSED) { while(i < vElements.GetSize() && item->offset > parent->offset) { item->ShowWindow(SW_HIDE); i++; item = (BItem*)vElements.GetPointer(i); } i--; } else { item->ShowWindow(SW_SHOW); yPos=item->MoveElement(yPos)+ELEMENT_SIZE_BETWEEN; } } ResetScrollBar(); Invalidate(); }
bool BContainer::AddElement(BItem* element) { BItem* parentItem; if(!vElements.Push(&element)) return false; if(vElements.GetSize() > 1) { //am cel putin doua elemente parentItem = (BItem*) vElements.GetPointer(vElements.GetSize()-2); if(parentItem->offset < element->offset) { parentItem->SetCollapsed(ITEM_COLLAPSED); element->ShowWindow(SW_HIDE); } } if(element->description!=NULL) tooltipCtrl.AddTool(element,element->description); ResetScrollBar(); return true; }
void CPWL_Note::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam, FX_INTPTR lParam) { switch (msg) { case PNM_NOTEEDITCHANGED: { CPDF_Rect rcScroll = m_pContents->GetScrollArea(); PWL_SCROLL_INFO sInfo; sInfo.fContentMin = rcScroll.bottom; sInfo.fContentMax = rcScroll.top; sInfo.fPlateWidth = m_pContents->GetClientRect().Height(); sInfo.fSmallStep = 13.0f; sInfo.fBigStep = sInfo.fPlateWidth; if (FXSYS_memcmp(&m_OldScrollInfo, &sInfo, sizeof(PWL_SCROLL_INFO)) != 0) { FX_BOOL bScrollChanged = FALSE; if (lParam < 3) //·ÀÖ¹ËÀÑ»· mantis:15759 { bScrollChanged = ResetScrollBar(); if (bScrollChanged) { lParam++; m_pContents->OnNotify(this, PNM_NOTERESET, 0, 0); this->OnNotify(this, PNM_NOTEEDITCHANGED, 0, lParam); } } if (!bScrollChanged) { if (m_pContentsBar->IsVisible()) { m_pContentsBar->OnNotify(pWnd, PNM_SETSCROLLINFO, SBT_VSCROLL, (FX_INTPTR)&sInfo); m_OldScrollInfo = sInfo; CPDF_Point ptScroll = m_pContents->GetScrollPos(); CPDF_Point ptOld = ptScroll; if (ptScroll.y > sInfo.fContentMax) ptScroll.y = sInfo.fContentMax; if (ptScroll.y < sInfo.fContentMin + sInfo.fPlateWidth) ptScroll.y = sInfo.fContentMin + sInfo.fPlateWidth; if (ptScroll.y < sInfo.fContentMin) ptScroll.y = sInfo.fContentMin; if (ptOld.y != ptScroll.y) { m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); m_pContentsBar->InvalidateRect(NULL); m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); } } } } } m_pContents->InvalidateRect(NULL); return; case PNM_SCROLLWINDOW: if (m_pContents) m_pContents->OnNotify(pWnd, msg, wParam, lParam); return; case PNM_SETSCROLLPOS: if (m_pContentsBar) m_pContentsBar->OnNotify(pWnd,PNM_SETSCROLLPOS,wParam,lParam); return; } if (msg == PNM_SETCARETINFO && IsValid()) { if (PWL_CARET_INFO * pInfo = (PWL_CARET_INFO*)wParam) { if (m_pContents) { CPDF_Rect rcClient = m_pContents->GetClientRect(); if (pInfo->ptHead.y > rcClient.top) { CPDF_Point pt = m_pContents->OutToIn(pInfo->ptHead); m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); CPDF_Point ptScroll = m_pContents->GetScrollPos(); m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); return; } if (pInfo->ptFoot.y < rcClient.bottom) { CPDF_Point pt = m_pContents->OutToIn(pInfo->ptFoot); pt.y += rcClient.Height(); m_pContents->OnNotify(this, PNM_SCROLLWINDOW, SBT_VSCROLL, (FX_INTPTR)&pt.y); CPDF_Point ptScroll = m_pContents->GetScrollPos(); m_pContentsBar->OnNotify(this, PNM_SETSCROLLPOS, SBT_VSCROLL, (FX_INTPTR)&ptScroll.y); return; } } } } CPWL_NoteItem::OnNotify(pWnd, msg, wParam, lParam); }
BOOL CTreeListFrame::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam; if((wParam == ID_TREE_LIST_HEADER) && (pHDN->hdr.code == HDN_ITEMCLICK)) { if (m_sortingEnabled) { int nCol = pHDN->iItem; BOOL bAscending = FALSE; if(getTree().m_wndHeader.GetItemImage(nCol)==-1) bAscending = TRUE; else if(getTree().m_wndHeader.GetItemImage(nCol)==1) bAscending = TRUE; for(int i=0;i<getTree().GetColumnsNum();i++) { getTree().m_wndHeader.SetItemImage(i, -1); } if(bAscending) getTree().m_wndHeader.SetItemImage(nCol, 0); else getTree().m_wndHeader.SetItemImage(nCol, 1); getTree().SortItems(nCol, bAscending, NULL); SortTree(nCol, bAscending, getTree().GetRootItem()); getTree().UpdateWindow(); } } else if((wParam == ID_TREE_LIST_HEADER) && (pHDN->hdr.code == HDN_ITEMCHANGED)) { int m_nPrevColumnsWidth = getTree().GetColumnsWidth(); getTree().RecalcColumnsWidth(); ResetScrollBar(); // in case we were at the scroll bar's end, // and some column's width was reduced, // update header's position (move to the right). CRect m_treeRect; getTree().GetClientRect(&m_treeRect); CRect m_headerRect; getTree().m_wndHeader.GetClientRect(&m_headerRect); if((m_nPrevColumnsWidth > getTree().GetColumnsWidth()) && (m_horScrollBar.GetScrollPos() == m_horScrollBar.GetScrollLimit()-1) && (m_treeRect.Width() < getTree().GetColumnsWidth())) { getTree().m_nOffset = -getTree().GetColumnsWidth()+m_treeRect.Width(); getTree().m_wndHeader.SetWindowPos(&wndTop, getTree().m_nOffset, 0, 0, 0, SWP_NOSIZE); } getTree().Invalidate(); GetParent()->SendMessage(WM_NOTIFY, wParam, lParam); } else { GetParent()->SendMessage(WM_NOTIFY, wParam, lParam); } return CWnd::OnNotify(wParam, lParam, pResult); }
void CBirchCtrl::OnPaint() { CPaintDC dc(this); // Device context for painting if (!m_birch) return; // Double-buffering CDC* pDCMem = new CDC; CBitmap* pOldBitmap = NULL; CBitmap bmpCanvas; CRect rFrame; GetClientRect( rFrame ); pDCMem->CreateCompatibleDC( &dc ); bmpCanvas.CreateCompatibleBitmap( &dc, rFrame.Width(), rFrame.Height() ); pOldBitmap = pDCMem->SelectObject( &bmpCanvas ); // START DRAW ------------------------------------------------- // If there is a bitmap loaded, use it // Otherwise, paint the background white pDCMem->FillSolidRect( rFrame, GetSysColor(COLOR_WINDOW) ); UINT nMode = pDCMem->SetBkMode( TRANSPARENT ); CFont* pOldFont = pDCMem->SelectObject( &m_Font ); CPen *pOldPen = pDCMem->GetCurrentPen(); CPen linesPen(PS_SOLID, 1, m_crConnectingLines), marksPen(PS_SOLID, 1, m_crConnectingLines); int iLastNodePos = m_iPadding - GetScrollPos( SB_VERT ); HTREENODE curTreeNode = m_birch->GetTopNode()->pFirstChild ; while (curTreeNode) { iLastNodePos = DrawNodesRecursive( pDCMem, curTreeNode, iLastNodePos+1, &linesPen, &marksPen, rFrame ); curTreeNode = curTreeNode->pNextSibling; } pDCMem->SelectObject(pOldPen); pDCMem->SelectObject( pOldFont ); pDCMem->SetBkMode( nMode ); // END DRAW ------------------------------------------------- dc.BitBlt( 0, 0, rFrame.Width(), rFrame.Height(), pDCMem, 0, 0, SRCCOPY ); pDCMem->SelectObject( pOldBitmap ); delete pDCMem; iLastNodePos+=GetScrollPos( SB_VERT ); // Has the total document height changed? if( iLastNodePos != m_iDocHeight ) { BOOL bInvalidate = ( ( m_iDocHeight < rFrame.Height() ) != ( iLastNodePos < rFrame.Height() ) ); m_iDocHeight = iLastNodePos; ResetScrollBar(); // If the scrollbar has just been hidden/shown, repaint if( bInvalidate ) Invalidate(); } }