void MercuryScrollBar::RedrawArrowButton(UINT nBtnHitTest) { if( m_bVscroll ){ if( nBtnHitTest == HITTEST_TOP_ARROW ){ CRect rcInvalidate (m_rcArrowBtnTop.left, m_rcArrowBtnTop.top, m_rcArrowBtnTop.right, m_rcArrowBtnTop.top + m_pGUI->scrollBar.m_imgVScrollTopSel.GetHeight()); RedrawRect(rcInvalidate, TRUE); } else if( nBtnHitTest == HITTEST_BOTTOM_ARROW ){ CRect rcInvalidate (m_rcArrowBtnBottom.left, m_rcArrowBtnBottom.bottom - m_pGUI->scrollBar.m_imgVScrollBottomSel.GetHeight(), m_rcArrowBtnBottom.right, m_rcArrowBtnBottom.bottom); RedrawRect(rcInvalidate, TRUE); } } else{ if( nBtnHitTest == HITTEST_LEFT_ARROW ){ CRect rcInvalidate (m_rcArrowBtnLeft.left, m_rcArrowBtnLeft.top, m_rcArrowBtnLeft.left + m_pGUI->scrollBar.m_imgHScrollLeftSel.GetWidth(), m_rcArrowBtnLeft.bottom); RedrawRect(rcInvalidate, TRUE); } else if( nBtnHitTest == HITTEST_RIGHT_ARROW ){ CRect rcInvalidate (m_rcArrowBtnRight.right - m_pGUI->scrollBar.m_imgHScrollLeftSel.GetWidth(), m_rcArrowBtnRight.top, m_rcArrowBtnRight.right, m_rcArrowBtnRight.bottom); RedrawRect(rcInvalidate, TRUE); } } }
bool ESChildSlider::CalcCursorPosByPoint(_Point pt){ if( m_bVerticalMode ){ float fDelta = (float)((m_rcBar.Height()) / ((m_nMax - m_nMin)*1.0f)); m_nPos = m_nMin + (int)((pt.y - m_rcBar.top)/fDelta); _Rect rcCursor; if( CalcCursorRect(m_rcBar, rcCursor) ){ _Rect rcRedraw = m_rcCursor|rcCursor; RedrawRect(rcRedraw, true); m_rcCursor = rcCursor; return true; } } else{ float fDelta = (float)((m_rcBar.Width()) / ((m_nMax - m_nMin)*1.0f)); m_nPos = m_nMin + (int)((pt.x - m_rcBar.left)/fDelta); _Rect rcCursor; if( CalcCursorRect(m_rcBar, rcCursor) ){ _Rect rcRedraw = m_rcCursor|rcCursor; RedrawRect(rcRedraw, true); m_rcCursor = rcCursor; return true; } } return false; }
void TWindow::Redraw() { if (IsCreated()) { TRect r(0, 0, GetWidth(), GetHeight()); const TPoint& scroll = GetScroll(); r.Offset(scroll.h, scroll.v); RedrawRect(r); } }
void ESChildSlider::OnLButtonUp(_Point pt, UINT nFlags){ ESChildControl::OnLButtonUp(pt, nFlags); KillTimer(MinusSlideTimerId); KillTimer(PlusSlideTimerId); if( m_hitTest == SliderHitTest::MinusSign ){ RedrawRect(m_rcMinus); } else if( m_hitTest == SliderHitTest::PlusSign ){ RedrawRect(m_rcPlus); } if( m_bCursorCaptured || m_rcCursor.PtInRect(pt) ){ m_bCursorCaptured = false; RedrawRect(m_rcCursor); } m_hitTest = SliderHitTest::NoSign; }
void ESChildScrollView::RedrawViewArea(){ _Rect rcView = GetClientRect(); if( m_nBorderWidth > 0 ){ rcView.left += m_nBorderWidth; rcView.top += m_nBorderWidth; rcView.right -= m_nBorderWidth; rcView.bottom -= m_nBorderWidth; } _Rect rcRedraw; rcRedraw.left = rcView.left; rcRedraw.top = rcView.top; rcRedraw.right = m_pVScroll->IsVisible() ? rcView.right - m_nArrowBtnCX : rcView.right; rcRedraw.bottom = rcRedraw.top + (m_pHScroll->IsVisible() ? (rcView.Height() - m_nArrowBtnCY) : rcView.Height()); RedrawRect(rcRedraw, false); }
void ESSimpleRenderView::AddText(_string sStyleName, _string sText, bool bLineBreak, COLORREF crText, _Size szText, float fCX, float fPosX /*= 0.0f*/, int nVAlign, int nHAlign, bool bRedraw){ ESSimpleRenderView_TextStyle* pStyle = (ESSimpleRenderView_TextStyle*)GetTextStyleByName(sStyleName.c_str()); if( !pStyle ) return; /* if( !m_pLastLine ){ m_pLastLine = new RenderLine(); m_pRootLine->m_pNextLine = m_pLastLine; m_pLastLine->m_bLineBreak = bLineBreak; bLineBreak = false; }*/ CStringArray arrStrings; StringHelper::Split(&sText, _T("\r\n"), arrStrings); RenderItemText* pItemNew = NULL; RenderItem* pItemPrev = NULL; RenderLine* pLine = m_pLastLine; bool bNewLine = false; if( !pLine || pLine->m_bLineBreak ){ RenderLine* pNewLine = new RenderLine(); pNewLine->m_pPrevLine = pLine; if( !pLine ){ m_pLastLine = pNewLine; m_pRootLine->m_pNextLine = m_pLastLine; m_pLastLine->m_bLineBreak = bLineBreak; } else{ pLine->m_pNextLine = pNewLine; } pLine = pNewLine; bNewLine = true; } pItemPrev = pLine->m_pFirstItem; if( pItemPrev ){ while(pItemPrev->m_pNext) pItemPrev = pItemPrev->m_pNext; } int nHeightOld = pLine->m_szLine.cy; for(int i=0; i<arrStrings.size(); i++){ RenderItemText* pItemNew = new RenderItemText(); pItemNew->m_pLine = pLine; pItemNew->m_pStyle = pStyle; pItemNew->m_sText = arrStrings.at(i); pItemNew->m_sTextLocal = pItemNew->m_sText; ESLocalizationMan::ParseText(pItemNew->m_sTextLocal); pItemNew->m_nHAlign = nHAlign; pItemNew->m_nVAlign = nVAlign; pItemNew->m_crText = crText; pItemNew->m_fPosX = fPosX; pItemNew->m_fCX = fCX; pStyle->m_font.GetTextSize(&pItemNew->m_sTextLocal, pItemNew->m_szText); pItemNew->m_szItem = pItemNew->m_szText; pItemNew->m_szItem.cy += 2*m_nTextMarginTopBottom; if( i > 0 ){ // Break line on previous item. pItemPrev->m_bBreakLine = true; // Set offset of item. pItemNew->m_ptOffset.SetPoint(0, pLine->m_szLine.cy); // Set size of line height. pLine->m_szLine.cy += pItemNew->m_szText.cy; } else{ pLine->m_szLine.cx += pItemNew->m_szItem.cx; pLine->m_szLine.cy = std::max(pLine->m_szLine.cy, pItemNew->m_szItem.cy); } if( pItemPrev ) pItemPrev->m_pNext = pItemNew; else pLine->m_pFirstItem = pItemNew; pItemNew->m_pPrev = pItemPrev; pItemPrev = pItemNew; } CalcLineSize(pLine); if( bNewLine ){ m_nContentHeight += pLine->m_szLine.cy; m_pLastLine = pLine; } else m_nContentHeight += (pLine->m_szLine.cy - nHeightOld); m_nTopFullOffsetY = 0; if( m_szView.cy != m_nContentHeight ){ m_szView.cy = m_nContentHeight; if( IsCreated() ) AdjustScrollBarPos(bRedraw); } pLine->m_bLineBreak = bLineBreak; if( bRedraw ){ _Rect rcLine; if( IsLineVisible(pLine, rcLine) ) RedrawRect(rcLine, false); //Redraw(true); } }
/******************************************************************************************** > void TipsDlg::OnRedraw(ReDrawInfoType* pRedrawInfo) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 03/08/96 Purpose: Redraws the dialog in response to a DIM_REDRAW message ********************************************************************************************/ void TipsDlg::OnRedraw(ReDrawInfoType* pRedrawInfo) { // Use the actual size of the window as our scale DocRect RedrawRect(0, 0, pRedrawInfo->dx, pRedrawInfo->dy); m_pRenderer = CreateGRenderRegion(&RedrawRect, pRedrawInfo); if (m_pRenderer != NULL) { // Interlock redraw with the drag manager to ensure we don't redraw over any drag // blobs DragManagerOp::RedrawStarting(WindowID, m_pCurrentMsg->GadgetID); DialogColourInfo defaultColours; // Object supplying Host OS redraw colours m_pRenderer->SaveContext(); // Paint the background m_pRenderer->SetLineWidth(0); m_pRenderer->SetLineColour(COLOUR_WHITE); m_pRenderer->SetFillColour(COLOUR_WHITE); m_pRenderer->DrawRect(&RedrawRect); switch (m_pCurrentMsg->GadgetID) { case _R(IDC_BITMAP): { // Draw bitmap in top corner and validate only top portion of window DrawBitmap(_R(IDB_LIGHTBULB), RedrawRect); break; } case _R(IDC_DIDYOUKNOW): { DrawBitmap(_R(IDB_DIDYOU), RedrawRect); /* m_pRenderer->SetFixedSystemTextColours( &defaultColours.TextFore(), &defaultColours.TextBack()); // Draw out "Did you know..." message next to the bitmap String_256 strMessage; strMessage.Load(_R(IDS_DIDYOUKNOW)); DrawText(&strMessage, RedrawRect, ALN_CENTRE); */ break; // Just draw a white rectangle with the text on it } default: { TRACEUSER( "Colin", _T("Invalidated - m_bSentInvalid %d\n"), m_bSentInvalid); if (!m_bSentInvalid) { m_bSentInvalid = TRUE; m_pTipTextGadget->Invalidate(pRedrawInfo->pClipRect); } else { m_bSentInvalid = FALSE; } break; } } m_pRenderer->RestoreContext(); DestroyGRenderRegion(m_pRenderer); // And turn off the drag redraw interlock DragManagerOp::RedrawFinished(); } }
BOOL MercuryScrollBar::SetScrollInfo(int nMin, int nMax, int nPage) { CRect rcClient; GetClientRect(rcClient); if( m_bVscroll ){ m_rcArrowBtnTop .SetRect(rcClient.left, rcClient.top, rcClient.right, rcClient.top + m_pGUI->scrollBar.m_imgVScrollTopNormal.GetHeight()); m_rcArrowBtnBottom .SetRect(rcClient.left, rcClient.bottom - m_pGUI->scrollBar.m_imgVScrollBottomNormal.GetHeight(), rcClient.right, rcClient.bottom); } else{ m_rcArrowBtnLeft .SetRect(rcClient.left, rcClient.top, rcClient.left + m_pGUI->scrollBar.m_imgHScrollLeftNormal.GetWidth(), rcClient.bottom); m_rcArrowBtnRight .SetRect(rcClient.right - m_pGUI->scrollBar.m_imgHScrollRightNormal.GetWidth(), rcClient.top, rcClient.right, rcClient.bottom); } // Validate scroll infoes. ######################## int nPosOld = m_nPos; if( nMin >= nMax || nPage >= (nMax - nMin)) { if( m_nPos != m_nMin ){ m_nPos = m_nMin; GetParent()->SendMessage(m_bVscroll ? WM_VSCROLL : WM_HSCROLL, m_nPos, SB_THUMBTRACK); } return FALSE; } /* if( m_nMin != nMin || m_nMax != nMax ){ int nLimitPos = (nMax - nPage) + nMin; if( m_nPos > m_nMax || m_nPos < m_nMin ) m_nPos = 0; } else{ int nLimitPos = (nMax - nPage) + nMin; if( m_nPos > nLimitPos ){ m_nPos = nLimitPos; } }*/ int nLimitPos = (nMax - nPage) + nMin; if( m_nPos > nLimitPos ){ m_nPos = nLimitPos; } m_nMin = nMin; m_nMax = nMax; m_nPage = nPage; // ################################################ // Calculate scroll bar thumb rect. ############### CRect rcThumbOld; if( m_bVscroll ){ int nThumbHeightMax = rcClient.Height() - 2*m_pGUI->scrollBar.m_nArrowBtnCXCY; int nThumbHeight = (((double)m_nPage)/(m_nMax - m_nMin))*((double)nThumbHeightMax); if( nThumbHeight < m_nThumbHeightMin ) nThumbHeight = m_nThumbHeightMin; int nThumbHeightOld = m_rcThumb.Height(); rcThumbOld = m_rcThumb; int nThumbTopPos = ThumbPosByPos(); m_rcThumb.left = 0; m_rcThumb.top = nThumbTopPos; m_rcThumb.right = rcClient.Width(); m_rcThumb.bottom = min(m_rcThumb.top + nThumbHeight, m_rcArrowBtnBottom.bottom - m_pGUI->scrollBar.m_nArrowBtnCXCY); if( m_rcThumb.top + nThumbHeight > m_rcArrowBtnBottom.top ){ m_rcThumb.top -= (nThumbHeight - nThumbHeightOld); } if( m_rcThumb.top <= 0 ) m_rcThumb.top = nThumbTopPos; } else{ int nThumbWidthMax = rcClient.Width() - 2*m_pGUI->scrollBar.m_nArrowBtnCXCY; int nThumbWidth = (((double)m_nPage)/(m_nMax - m_nMin))*((double)nThumbWidthMax); if( nThumbWidth < m_nThumbHeightMin ) nThumbWidth = m_nThumbHeightMin; int nThumbWidthOld = m_rcThumb.Width(); rcThumbOld = m_rcThumb; int nThumbLeftPos = ThumbPosByPos(); m_rcThumb.left = nThumbLeftPos; m_rcThumb.top = 0; m_rcThumb.right = min(m_rcThumb.left + nThumbWidth, m_rcArrowBtnRight.right - m_pGUI->scrollBar.m_nArrowBtnCXCY); m_rcThumb.bottom = rcClient.Height(); if( m_rcThumb.left + nThumbWidth > m_rcArrowBtnRight.left ){ m_rcThumb.left -= (nThumbWidth - nThumbWidthOld); } if( m_rcThumb.left <= 0 ) m_rcThumb.left = nThumbLeftPos; } if( rcThumbOld != m_rcThumb ) RedrawRect(rcThumbOld|m_rcThumb, TRUE); if( m_nPos != nPosOld ){ GetParent()->SendMessage(m_bVscroll ? WM_VSCROLL : WM_HSCROLL, m_nPos, SB_THUMBTRACK); } // ################################################# return 1; }
void MercuryScrollBar::OnMouseMove(UINT nFlags, CPoint point) { CWnd::OnMouseMove(nFlags, point); if( m_bMouseDown && nFlags&MK_LBUTTON ){ if( m_nHitTest == HITTEST_THUMB ){ if( m_bVscroll ){ int nMoveY = (point.y - m_ptMouseDown.y); if( nMoveY == 0 ) return; CRect rcThumb = m_rcThumb; m_rcThumb.top += nMoveY; m_rcThumb.bottom += nMoveY; CPoint ptMouseDown = m_ptMouseDown; m_ptMouseDown = point; if( m_rcThumb.top < m_pGUI->scrollBar.m_nArrowBtnCXCY || m_rcThumb.bottom > m_rcArrowBtnBottom.bottom - m_pGUI->scrollBar.m_nArrowBtnCXCY ){ m_rcThumb.top -= nMoveY; m_rcThumb.bottom -= nMoveY; return; } int nPosNew = PosByThumbPos (); if( nPosNew == m_nPos ){ m_rcThumb = rcThumb; m_ptMouseDown = ptMouseDown; } else{ BOOL bRet = GetParent()->SendMessage(WM_VSCROLL, nPosNew, SB_THUMBTRACK); if( bRet ){ m_nPos = nPosNew; CRect rcInvalidate = rcThumb|m_rcThumb; RedrawRect(rcInvalidate, TRUE); } else{ m_rcThumb = rcThumb; m_ptMouseDown = ptMouseDown; } } return; } else{ int nMoveX = (point.x - m_ptMouseDown.x); if( nMoveX == 0 ) return; CRect rcThumb = m_rcThumb; m_rcThumb.left += nMoveX; m_rcThumb.right += nMoveX; m_ptMouseDown = point; if( m_rcThumb.left < m_pGUI->scrollBar.m_nArrowBtnCXCY || m_rcThumb.right > m_rcArrowBtnRight.right - m_pGUI->scrollBar.m_nArrowBtnCXCY ){ m_rcThumb.left -= nMoveX; m_rcThumb.right -= nMoveX; return; } int nPosNew = PosByThumbPos (); BOOL bRet = GetParent()->SendMessage(WM_HSCROLL, nPosNew, SB_THUMBTRACK); if( bRet ){ m_nPos = nPosNew; CRect rcInvalidate = rcThumb|m_rcThumb; RedrawRect(rcInvalidate, TRUE); } else m_rcThumb = rcThumb; return; } } else if( m_bVscroll ){ if( m_nHitTest == HITTEST_TOP_ARROW ){ if( !m_rcArrowBtnTop.PtInRect(point) ){ m_bMouseDown = FALSE; m_nHitTest = 0; ReleaseCapture (); RedrawArrowButton(HITTEST_TOP_ARROW); // Stop auto scroll timer. KillTimer(TIMER_SCROLL_UP); } } else if( m_nHitTest == HITTEST_BOTTOM_ARROW ){ if( !m_rcArrowBtnBottom.PtInRect(point) ){ m_bMouseDown = FALSE; m_nHitTest = 0; ReleaseCapture (); RedrawArrowButton (HITTEST_BOTTOM_ARROW); // Stop auto scroll timer. KillTimer(TIMER_SCROLL_DOWN); } } } else{ if( m_nHitTest == HITTEST_LEFT_ARROW ){ if( !m_rcArrowBtnLeft.PtInRect(point) ){ m_bMouseDown = FALSE; m_nHitTest = 0; ReleaseCapture (); RedrawArrowButton(HITTEST_LEFT_ARROW); // Stop auto scroll timer. KillTimer(TIMER_SCROLL_LEFT); } } else if( m_nHitTest == HITTEST_RIGHT_ARROW ){ if( !m_rcArrowBtnRight.PtInRect(point) ){ m_bMouseDown = FALSE; m_nHitTest = 0; ReleaseCapture (); RedrawArrowButton (HITTEST_RIGHT_ARROW); // Stop auto scroll timer. KillTimer(TIMER_SCROLL_RIGHT); } } } } }
void ESChildComboBox::ShowListBox(bool bHide /*= false*/){ if( bHide ){ if( m_pListBox ){ SendEvent(this, EventCode_ComboBoxCloseUp); _Rect rcListBox = m_pListBox->GetClientRect(); m_pListBox->SetVisible(false, false); m_pOwner->RemoveChildControl(m_pListBox); m_pListBox = NULL; RedrawRect (rcListBox, true); RedrawRect (m_rcBoxButton, true); } return; } if( m_pListBox == NULL ){ m_pListBox = new ESChildComboListBox(); int nItems = m_content.GetCount(); int nItemCY = m_pListBox->GetItemHeight(); int nListBoxHeight = m_nListBoxHeight; if( nListBoxHeight > nItems*nItemCY ){ nListBoxHeight = nItems*nItemCY; } _Rect rcListBox(m_rRect.left, m_rRect.bottom + 1, m_rRect.right, (m_rRect.bottom + 1) + nListBoxHeight); _Rect rcOwner; if( !m_pParent ) m_pOwner->GetClientRectMy(rcOwner); else rcOwner = m_pParent->GetClientRect(); if( rcOwner.bottom < rcListBox.bottom ){ rcListBox.bottom = m_rRect.top - 1; rcListBox.top = rcListBox.bottom - nListBoxHeight; } SendEvent(this, EventCode_ComboBoxDropDown); if( m_pOwner->AddChildControl(m_pListBox, MercuryBaseView::GetChildControlIdUnused(m_pOwner), rcListBox, m_pParent, 100) ){ for(int i=0; i<m_content.GetCount(); i++) m_pListBox->AddItem(m_content.GetKey(i), m_content.GetValueByIndex(i), false); m_pListBox->GetVScrollBar()->OwnerWindowSizeChanged(rcOwner.Width(), rcOwner.Height()); int nIndex = -1; if( m_content.KeyExists(GetText(), &nIndex) ) m_pListBox->SetSelectedItem(nIndex, false, true); m_pListBox->AddEventListener((ESFrameBase*)this, ChildControlEventCode::EventCode_ListBoxItemClick, (ControlEventListener)&ESChildComboBox::OnListBoxItemClick); m_pListBox->SetTextFont (&m_textFont, false); m_pOwner->RedrawRect (rcListBox, 1); RedrawRect (m_rcBoxButton, true); } else{ delete m_pListBox; m_pListBox = NULL; return; } } else{ for(int i=0; i<m_content.GetCount(); i++) m_pListBox->AddItem(m_content.GetKey(i), m_content.GetValueByIndex(i), false); int nIndex = -1; if( m_content.KeyExists(GetText(), &nIndex) ) m_pListBox->SetSelectedItem(nIndex, false, true); } }
void ESChildSlider::OnLButtonDown(_Point pt, UINT nFlags){ ESChildControl::OnLButtonDown(pt, nFlags); if( m_rcBar.PtInRect(pt) ){ if( m_rcCursor.PtInRect(pt) && m_bAllowDrag ){ m_hitTest = SliderHitTest::CursorSign; m_bCursorCaptured = true; RedrawRect(m_rcCursor); return; } if( m_bJumpToClickedPos && CalcCursorPosByPoint(pt) ){ SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); return; } if( m_bVerticalMode ){ if( pt.y > m_rcCursor.bottom ){ m_nPos -= m_nStep; m_nPos = std::max(m_nPos, m_nMin); CalcCursorRect(m_rcBar, m_rcCursor); SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); } else if( pt.y < m_rcCursor.top ){ m_nPos += m_nStep; m_nPos = std::min(m_nPos, m_nMax); CalcCursorRect(m_rcBar, m_rcCursor); SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); } } else{ if( pt.x > m_rcCursor.right ){ m_nPos += m_nStep; m_nPos = std::min(m_nPos, m_nMax); CalcCursorRect(m_rcBar, m_rcCursor); SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); } else if( pt.x < m_rcCursor.left ){ m_nPos -= m_nStep; m_nPos = std::max(m_nPos, m_nMin); CalcCursorRect(m_rcBar, m_rcCursor); SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); } } } else{ if( m_rcPlus.PtInRect(pt) ){ if( m_nPos < m_nMax ){ m_hitTest = SliderHitTest::PlusSign; m_nPos += m_nStep; m_nPos = std::min(m_nPos, m_nMax); CalcCursorRect(m_rcBar, m_rcCursor); SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); SetTimer(PlusSlideTimerId, 300); } return; } if( m_rcMinus.PtInRect(pt) ){ if( m_nPos > m_nMin ){ m_hitTest = SliderHitTest::MinusSign; m_nPos -= m_nStep; m_nPos = std::max(m_nPos, m_nMin); CalcCursorRect(m_rcBar, m_rcCursor); SendEvent(this, ChildControlEventCode::EventCode_SliderPosChanged, (void*)m_nPos); Redraw(); SetTimer(MinusSlideTimerId, 300); } return; } } }