VOID CDUITreeViewImpl::DoPaint(HDC dc, const RECT& rtDraw) { DUI_ASSERT(dc && rtDraw.bottom-rtDraw.top >0 && rtDraw.right - rtDraw.left > 0 ); RECT rtAvailable = GetContentRect(); HDUITREEITEM hFirst = m_hTopItem; for ( hFirst;hFirst!=NULL;hFirst=GetNextVisibleItem(hFirst) ) { CDUIRenderClip clip(dc, GetContentRect()); RECT rtControl = hFirst->GetControlRect(); hFirst->DoPaint(dc,rtControl); if ( rtControl.bottom >= rtAvailable.bottom ) break; } if(m_pVertSB != NULL && (m_pVertSB->IsVisible())) { CDUIRenderClip clip(dc, GetContentRect()); m_pVertSB->DoPaint(dc, rtDraw); } }
/* virtual */ VOID CDUITreeNode::DoPaint(HDC dc, const RECT& rtDraw) { //DUI_ASSERT(dc && rtDraw.bottom-rtDraw.top >0 && rtDraw.right - rtDraw.left > 0 ); theBase::DoPaint(dc,rtDraw);return; CDUIRenderClip clip(dc, GetContentRect()); theBase::PaintBkgnd(dc); INT nLevel = GetLevel(); TCHAR szIndent[32] = {0}; int i=0; for ( i=1;i<nLevel;i++) { lstrcat(szIndent,_T(" ")); } for ( i=0;i<nLevel;i++) { lstrcat(szIndent,_T("+")); } TCHAR szText[128] = {0}; wsprintf(szText,_T("%s-%x"),szIndent,this); RECT rcIndent = rtDraw; CDUIRenderEngine::DrawText(dc,szText,lstrlen(szText),&rcIndent,DT_SINGLELINE|DT_LEFT); }
void XGPopControl::DoShowHide() { #if OPT_MACOS || OPT_WINOS if (fControl) { #if OPT_MACOS if (!IsVisible()) { XGDraw draw(this,false); if (fFont) { fFont->Attach(); draw.SetFont(fFont); } ::HideControl(fControl); ::MoveControl(fControl,-20,-20); ::SizeControl(fControl,10,10); } else { XRect r; r = GetContentRect(); ViewToGlobal(&r); ::MoveControl(fControl,r.left,r.top); ::SizeControl(fControl,r.right-r.left,r.bottom-r.top); } #endif #if OPT_WINOS if (!IsVisible()) ::ShowWindow(fControl, SW_HIDE); #endif } #endif XGControl::DoShowHide(); }
VOID CDUIWinObject::SyncProperty() { if(m_hWnd == NULL || !::IsWindow(m_hWnd)) { return; } HWND hWndManager = GetManagerWnd(FALSE); if(hWndManager == NULL) return; ::SetParent(m_hWnd, hWndManager); ::ShowWindow(m_hWnd, IsVisible()?SW_SHOW:SW_HIDE); ::EnableWindow(m_hWnd, IsEnabled()); // if(GetFocus()) // { // ::SetFocus(m_hWnd); // } RECT rtContent = GetContentRect(); ::SetWindowPos(m_hWnd, NULL, rtContent.left, rtContent.top, rtContent.right - rtContent.left, rtContent.bottom - rtContent.top, SWP_NOACTIVATE); if(m_strText.size() > 0) { SetWindowText(m_hWnd, m_strText.c_str()); } }
VOID CDUIFramePanel::SetControlRect(const RECT& rt) { m_rtControl = rt; if(GetDrawMode() != FRAME_PANEL_SINGLE_COLOR) { CalculateImageFrame(); } RECT rtAvailable = GetContentRect(); rtAvailable.left += m_rtFrame.left; rtAvailable.right -= m_rtFrame.right; rtAvailable.top += m_rtFrame.top; rtAvailable.bottom -= m_rtFrame.bottom; if(IsRectEmpty(&rtAvailable)) { rtAvailable.right = rtAvailable.left; rtAvailable.bottom = rtAvailable.top; } //DUI_ASSERT(GetControlCount() == 1); if(GetControlCount() >= 1) { GetControlByIndex(0)->SetControlRect(rtAvailable); } }
void tMercuryControlTank::DirtyControl() { tMercuryStyle* style = GetMercuryStyle(); if( style == 0 ) { return; } if( m_Font.isNull() ) { m_Font = style->GetFont("", tMercuryStyle::eFontRoleStandard); } m_Font->SetDirty(); QRectF contentRect(GetContentRect()); m_ElementSize = qMax(1.f, float(qMin(contentRect.width(), contentRect.height())) * 0.02f); m_BarWidth = float(contentRect.width()) * 0.75f; float left = float(contentRect.width()) * 0.125f; m_InnerRect = QRectF( float(contentRect.left()) + left + 2.f * m_ElementSize, float(contentRect.top()) + 3.f * m_ElementSize, m_BarWidth - 4.f * m_ElementSize, float(contentRect.height()) - 6.f * m_ElementSize - 1.f ); }
VOID CDUIProgressBarBase::PaintForgnd(HDC dc) { RECT rtContent = GetContentRect(); CRefPtr<CImageList> pImage = m_uiData.m_imageBK; if(!pImage.IsNull() && !pImage->IsNull() && pImage->GetItemCount() >= PROCRSS_BAR_IMAGE_COUNT) { RECT rtTemp = {0}; GetProgressRect(rtContent, rtTemp); if(!IsRectEmpty(&rtTemp)) { CDUIRenderClip clip2(dc, rtTemp); if(IsVertical()) { pImage->VerticalStretch(dc, rtContent, PROCRSS_BAR_IMAGE_FORE); } else { pImage->HorizontalStretch(dc, rtContent, PROCRSS_BAR_IMAGE_FORE); } } } else { DUI_ASSERT(FALSE); } }
void tMercuryControlSeparator::paintEvent(QPaintEvent*) { tMercuryStyle* style = GetMercuryStyle(); if( style == 0 ) { return; } QRect contentRect(GetContentRect()); QPainter painter(this); if( m_FixedWidth > 0 ) { if( m_IsVertical ) { int w = qMin(contentRect.width(), m_FixedWidth); contentRect.setLeft(contentRect.center().x() - w / 2); contentRect.setWidth(w); } else { int h = qMin(contentRect.height(), m_FixedWidth); contentRect.setTop(contentRect.center().y() - h / 2); contentRect.setHeight(h); } } painter.fillRect(contentRect, m_Gradient); }
void XGProgress::InitControl (void) { XRect r; fControl = NULL; if (!_GAppearance) return; if (IsVisible()) { r = GetContentRect(); ViewToGlobal(&r); } else { r.left = -20, r.top = -20, r.right = -10, r.bottom = -10; } Rect mr = r; fControl = ::NewControl(GetRootWindow(), &mr, "\p", false, fValue, fMin, fMax, kControlProgressBarProc, GetViewID()); }
void XGProgress::DoShowHide() { #if OPT_MACOS if (fControl) { XGDraw draw(this,false); if (!IsVisible()) { ::HideControl(fControl); ::MoveControl(fControl,-20,-20); ::SizeControl(fControl,10,10); } else { XRect r; r = GetContentRect(); ViewToGlobal(&r); ::MoveControl(fControl,r.left,r.top); ::SizeControl(fControl,r.right-r.left,r.bottom-r.top); } } #endif #if OPT_WINOS if (fControl) { if (!IsVisible()) ::ShowWindow(fControl, SW_HIDE); } #endif XGControl::DoShowHide(); }
void XGProgress::DoMoveView (void) { #if OPT_MACOS || OPT_WINOS XRect r; if (!fControl) { XGControl::DoMoveView(); return; } r = GetContentRect(); ViewToGlobal(&r); #if OPT_MACOS XGDraw draw(this,false); ::HideControl(fControl); ::MoveControl(fControl,r.left,r.top); ::SizeControl(fControl,r.right-r.left,r.bottom-r.top); #endif #if OPT_WINOS ::SetWindowPos(fControl, NULL, r.left, r.top, r.right-r.left, r.bottom-r.top, SWP_NOZORDER | SWP_HIDEWINDOW); #endif #endif }
void XGProgress::DrawBar(XGDraw &draw) { XRect r = GetContentRect(); short x; long min,max,val; XRect s; draw.Draw3DRect(r,KXGEFrame); ::InsetRect(&r,1,1); min = fMin/fScale; max = fMax/fScale; val = fValue/fScale; if ((r.right - r.left) > (r.bottom - r.top)) { x = ((r.right - r.left) * (val - min)) / (max - min); s = r; s.left = r.right = x; } else { x = ((r.bottom - r.top) * (val - min)) / (max - min); s = r; s.top = r.bottom = x; } if (!::EmptyRect(&s)) draw.Draw3DRect(s,KXGEBackground); if (!::EmptyRect(&r)) { draw.FillRect(r,KXGColorBtnShadow); } }
bool XGPopMenuView::ScrollInRange() { short nscroll; short b; if (fLocation == -1) return false; // nothing selected. nscroll = fScroll; if (fLocation <= fScroll) { if (fLocation == 0) nscroll = 0; else nscroll = fLocation - 1; if (nscroll < 0) nscroll = 0; } else { if (fScroll < fMaxScroll) { b = fHeight + fScroll - 1; } else { b = fList->GetNumStrings(); } if (fLocation >= b) { nscroll = fLocation + 2 - fHeight; if (nscroll > fMaxScroll) nscroll = fMaxScroll; } } if (nscroll != fScroll) { fScroll = nscroll; DoDrawView(GetContentRect()); return true; } else { return false; } }
void WebDropBox::SetWidth (DISPLAY_INT w) { DisplayElement::SetWidth(w); WebRect r; GetContentRect(&r); r.left = r.right - mListbox.GetSliderWidth() + 1; mButton.Move(&r); }
void WebDropBox::Move(WebRect * rect) { DisplayElement::Move(rect); WebRect r; GetContentRect(&r); r.left = r.right - mListbox.GetSliderWidth() + 1; mButton.Move(&r); }
void TTreeView::DrawDropPoint(XGDraw &draw, Point where) { XRect r; r = GetContentRect(); r.left = where.h; r.top = where.v; r.bottom = r.top + 1; draw.InvertRect(r); }
void XGPopMenuView::DoPrePeriodic() { XRect r; if (fScrollFlag && (fTime < XGGetTime())) { r = GetContentRect(); if (PtInRect(fLastPos,&r)) { DoMouseMove(fLastPos,0); } } }
VOID CDUIWinObject::SetControlRect(const RECT& rt) { m_rtControl = rt; if(m_hWnd != NULL && ::IsWindow(m_hWnd)) { RECT rtContent = GetContentRect(); ::SetWindowPos(m_hWnd, NULL, rtContent.left, rtContent.top, rtContent.right - rtContent.left, rtContent.bottom - rtContent.top, SWP_NOACTIVATE); } }
void XGToolbarView::DoDrawView(XRect) { XGDraw draw(this); XRect r = GetContentRect(); long i,len; /* * Draw the background of this thing */ draw.SetForeColor(KXGColorBtnShadow); draw.MoveTo(r.left,r.top); draw.LineTo(r.right,r.top); r.top++; draw.SetForeColor(KXGColorBtnHilite); draw.MoveTo(r.left,r.top); draw.LineTo(r.right,r.top); r.top++; draw.SetForeColor(KXGColorBtnShadow); draw.MoveTo(r.left,r.bottom-1); draw.LineTo(r.right,r.bottom-1); r.bottom--; draw.Draw3DRect(r,KXGEBackground); /* * Draw the buttons */ len = fStatus.GetSize(); for (i = 0; i < len; i++) { unsigned char c; c = fStatus.GetChar(i); if (0 == (c & kSkip)) { DrawButton(draw, CalcButton(i), i, c); } else { r = CalcButton(i); r.left += 5; r.bottom = r.top + 22; draw.SetForeColor(KXGColorBtnShadow); draw.MoveTo(r.left,r.top); draw.LineTo(r.left,r.bottom); r.left++; draw.SetForeColor(KXGColorBtnHilite); draw.MoveTo(r.left,r.top); draw.LineTo(r.left,r.bottom); } } }
void XGScrollView::DoDrawView(XRect) { XGDraw draw(this); XRect r; r = GetContentRect(); draw.Draw3DRect(r,KXGEFrame); if (!fCorner) return; r = CalcCornerRect(); draw.Draw3DRect(r,KXGEBackground); }
void WebListBox::GetOptionsRect(WebRect * rect) { GetContentRect(rect); if (UseVScroll()) { rect->right -= miSliderWidth; } if (UseHScroll()) { rect->bottom -= miSliderWidth; } }
void XGScrollView::DoSizeView() { XRect r = GetContentRect(); int step = fPixel; if (step < 1) step = 1; long xval = (r.right - r.left - (step >> 1)) / step; if (xval < 1) xval = 1; long yval = (r.bottom - r.top - (step >> 1)) / step; if (yval < 1) yval = 1; SetPageSize(xval,yval); XGView::DoSizeView(); }
IDUIControl* CDUITreeViewImpl::FindControl(FINDCONTROLPROC Proc, LPVOID pData, UINT uFlags) { if((uFlags & FIND_FLAG_VISIBLE) && !(GetStyle() & CONTROL_STYLE_VISIBLE)) return NULL; if((uFlags & FIND_FLAG_ENABLED) && (GetStatus() & CONTROL_STATUS_DISABLE)) return NULL; if((uFlags & FIND_FLAG_HITTEST) && (!(PtInRect(&m_rtControl, *static_cast<LPPOINT>(pData))) || (GetStyle() & CONTROL_STYLE_TRANSPARENT))) return NULL; IDUIControl* pRet = NULL; if((uFlags & FIND_FLAG_MEFIRST)) { pRet = Proc(this, pData); if(pRet != NULL) return pRet; } RECT rtAvailable = GetContentRect(); HDUITREEITEM hFirst = m_hTopItem; for ( hFirst;hFirst!=NULL;hFirst=GetNextVisibleItem(hFirst) ) { RECT rtControl = hFirst->GetControlRect(); pRet = hFirst->FindControl(Proc, pData, uFlags); if ( pRet ) return pRet; if ( rtControl.bottom >= rtAvailable.bottom ) break; } // INT nCount = m_arChildControl.size(); // for(int i=m_nTopIndex; (i<nCount && i<=m_nLastIndex); ++i) // { // pRet = m_arChildControl[i]->FindControl(Proc, pData, uFlags); // if(pRet != NULL) return pRet; // } IDUIScrollBar* pScrollBar = GetVerticalSB(); if(pScrollBar != NULL) { pRet = pScrollBar->FindControl(Proc, pData, uFlags); if(pRet != NULL) return pRet; } return Proc(this, pData); }
VOID CDUIListBox::DoPaint(HDC dc, const RECT& rtDraw) { IDUIControl* pControl = NULL; INT nCount = m_arChildControl.size(); for(INT i=m_nTopIndex; (i<nCount && i<=m_nLastIndex); ++i) { CDUIRenderClip clip(dc, GetContentRect()); pControl = m_arChildControl[i].GetPtr(); if(!(pControl->IsVisible())) continue; pControl->DoPaint(dc, rtDraw); } if(m_pVertSB != NULL && (m_pVertSB->IsVisible())) { CDUIRenderClip clip(dc, GetContentRect()); m_pVertSB->DoPaint(dc, rtDraw); } }
void ComboBox::Paint(Canvas& canvas, const Rect& dirty_rect) { __super::Paint(canvas, dirty_rect); float button_width = GetDropDownButtonWidth(); auto button_rect = GetContentRect(); button_rect.position.x = button_rect.position.x + button_rect.size.width - button_width; button_rect.size.width = button_width; float top_edge_length = button_width / 2; if (top_edge_length / 2 > button_rect.size.height / 2) { top_edge_length = button_rect.size.height / 2; } float height = top_edge_length / 2; float half_height = height / 2; Point center_point( button_rect.position.x + button_rect.size.width / 2, button_rect.position.y + button_rect.size.height / 2); Point left_point(center_point.x - height, center_point.y - half_height); left_point = MakeClearEdgePointForFill(left_point, ClearEdgeOption::Clear); Point right_point(center_point.x + height, center_point.y - half_height); right_point = MakeClearEdgePointForFill(right_point, ClearEdgeOption::Clear); Point bottom_point(center_point.x, center_point.y + half_height); bottom_point = MakeClearEdgePointForFill(bottom_point, ClearEdgeOption::Clear); auto path = GetApplication().GetResourceFactory()->CreatePathGeometry(); if (path == nullptr) { return; } auto sink = path->Open(); if (sink == nullptr) { return; } sink->BeginFigure(left_point, GeometrySink::BeginFigureOption::Fill); sink->AddLine(right_point); sink->AddLine(bottom_point); sink->EndFigure(GeometrySink::EndFigureOption::Close); sink->Close(); Canvas::StateGuard state_guard(canvas); canvas.SetBrushWithColor(GetDropDownButtonColor()); canvas.DrawGeometry(path); }
VOID CDUITreeViewImpl::SetControlRect(const RECT& rt) { m_rtControl = rt; int nMaxWidth = 0; m_nTotalHeight =CalculateTotalHeight(); RECT rtAvailable = GetContentRect(); BOOL bUpdateScroll = ProcessVerticalSB(rtAvailable, m_nTotalHeight, m_nExtraHeight); if(bUpdateScroll) return; //layout at next time if(!m_pVertSB.IsNull() && (m_pVertSB->IsVisible())) { INT nThumbWidth = m_pVertSB->GetFixedSize().cx; RECT rtScrollBar = rtAvailable; rtScrollBar.left = rtScrollBar.right - nThumbWidth; m_pVertSB->SetControlRect(rtScrollBar); rtAvailable.right -= nThumbWidth; } IDUIControl* pControl = NULL; INT nCurrentHeight(0), nControlHeight(0);; RECT rtControl = rtAvailable; m_hTopItem = CalculateTopItem(); CTrace::TraceInfo(_T("2011-09-18,hTopItem = %x"),m_hTopItem); HDUITREEITEM hFirst = m_hTopItem; for ( hFirst;hFirst!=NULL;hFirst=GetNextVisibleItem(hFirst) ) { CTrace::TraceInfo(_T("2011-09-18,hFirst = %x"),hFirst); rtControl.top = rtAvailable.top + nCurrentHeight; rtControl.bottom = rtControl.top + hFirst->GetItemHeight(); hFirst->SetControlRect(rtControl); nCurrentHeight += hFirst->GetItemHeight(); if ( nCurrentHeight >= rtAvailable.bottom - rtAvailable.top ) break; } }
VOID CDUIListBox::SetControlRect(const RECT& rt) { m_rtControl = rt; CalculateTotalHeight(); RECT rtAvailable = GetContentRect(); BOOL bUpdateScroll = ProcessVerticalSB(rtAvailable, m_nTotalHeight, m_nExtraHeight); if(bUpdateScroll) return; //layout at next time if(!m_pVertSB.IsNull() && (m_pVertSB->IsVisible())) { INT nThumbWidth = m_pVertSB->GetFixedSize().cx; RECT rtScrollBar = rtAvailable; rtScrollBar.left = rtScrollBar.right - nThumbWidth; m_pVertSB->SetControlRect(rtScrollBar); rtAvailable.right -= nThumbWidth; } CalculateTopIndex(); IDUIControl* pControl = NULL; INT nCurrentHeight(0), nControlHeight(0);; RECT rtControl = rtAvailable; INT nCount = m_arChildControl.size(); for(INT i=m_nTopIndex; i<nCount; ++i) { pControl = m_arChildControl[i].GetPtr(); if(!(pControl->IsVisible())) continue; rtControl.top = rtAvailable.top + nCurrentHeight; nControlHeight = pControl->GetFixedSize().cy; rtControl.bottom = rtControl.top + nControlHeight; pControl->SetControlRect(rtControl); nCurrentHeight += nControlHeight; m_nLastIndex = i; if(nCurrentHeight >= rtAvailable.bottom - rtAvailable.top) { break; } } }
void XGProgress::InitControl (void) { XRect r; r = GetContentRect(); ViewToGlobal(&r); fControl = ::CreateWindow(PROGRESS_CLASS, "", WS_CHILD, r.left, r.top, r.right - r.left, r.bottom - r.top, GetRootWindow(), NULL, _GInstance, NULL); }
void XGPopMenuView::RecalcScroll() { XRect r; short h; XGDraw draw(this); draw.SetFont(XGFont::LoadFont(fFont)); r = GetContentRect(); fScroll = 0; fHeight = (r.bottom - r.top - 6) / draw.GetFontHeight(); h = fList->GetNumStrings(); if (h > fHeight) { fMaxScroll = h - fHeight; } else { fMaxScroll = 0; } }
void tMercuryControlTank::AdjustControl() { tMercuryStyle* style = GetMercuryStyle(); if( style == 0 || m_Font.isNull() || !m_Font->IsDirty() ) { return; } QRect contentRect(GetContentRect()); QSize size(int(float(contentRect.width()) * 0.115f), int(float(contentRect.height()) * m_LabelHeight)); m_Font->Adapt(m_MinLabel, size); m_Font->Adapt(m_MaxLabel, size); m_BorderGradient.setStart(0, qreal(contentRect.top())); m_BorderGradient.setFinalStop(0, qreal(contentRect.bottom())); UpdateGradients(); update(); }