int CXTPCalendarDayViewTimeScale::CalcWidth(CDC* pDC) { // calculate actual correct width int nWidth1 = m_nWidth, nWidth2 = m_nWidth; // calculate width for midnight COleDateTime dtMid(0, 0); CString strHour, strMin; Format(dtMid, TRUE, &strHour, &strMin); COleDateTimeSpan spScaleInterval = GetScaleInterval(); int nRowHeight = XTP_SAFE_GET1(m_pDayView, GetRowHeight(), 1); int nHourHeight = nRowHeight * (CXTPCalendarUtils::GetTotalMinutes(spScaleInterval) < 60 ? 2 : 1); XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleCellPart(), CalcWidth(pDC, strHour, strMin, nHourHeight, nWidth1)); // calculate width for midday dtMid += COleDateTimeSpan(0, 12, 0, 0); Format(dtMid, TRUE, &strHour, &strMin); XTP_SAFE_CALL3(m_pDayView, GetPaintManager(), GetDayViewTimeScaleCellPart(), CalcWidth(pDC, strHour, strMin, nHourHeight, nWidth2)); // choose the widest one m_nWidth = max(nWidth1, nWidth2); return m_nWidth; }
void CFileSaveAsGraphicDlg::SelectDimensionSet() { CPoint p = GetSelectedDimensionSet (); m_dWidth = (double)p.x; m_dHeight = (double)p.y; LimitDimensions (); CalcHeight (); CalcWidth (); }
void CFileSaveAsGraphicDlg::OnKillFocusHeight () { if ((UpdateData (TRUE) != FALSE) && (m_Aspect == TRUE)) { if (m_Height != (UINT)m_dHeight) { m_dHeight = (double)m_Height; CalcWidth (); UpdateData (FALSE); } } }
//! Expose callback. void GraphView::BeginViewExpose(bool predraw) { glViewport( 0, 0, mW, mH ); glDisable(GL_DEPTH_TEST); glClearColor( mClearColor[0], mClearColor[1], mClearColor[2], mClearColor[3]); glClear(GL_COLOR_BUFFER_BIT); glLineWidth(1.0); int lWidth = CalcWidth(); int lHeight = CalcHeight(); Push2dViewport(lWidth, lHeight); // call graph manager proc if (predraw) PreDraw(); }
void CStatBox::Update(int line,const char* string,double data) { if(line < 0 || line >= lines->size()) return; char buf[STATBOX_MAX_LINE_LENGTH]; sprintf(buf,"%s%.2f",string,data); CSurface* text = factory->RenderText(buf); if(text != NULL) { if(lines->at(line) != NULL) { //free old surface delete lines->at(line); lines->at(line) = NULL; } lines->at(line) = text; } w = CalcWidth(); h = CalcHeight(); }
v2i Font::CalcDimen( const char* a_text ) const { return v2i(CalcWidth(a_text), CalcHeight() ); }
bool GPanel::Pour(GRegion &r) { int Sx = CalcWidth(); GRect *Best = 0; if (Open()) { Best = FindLargest(r); } else { Best = FindSmallestFit(r, Sx, ClosedSize); if (!Best) { Best = FindLargest(r); } } if (Best) { GRect r = *Best; if (OpenSize > 0) { int Size = ((Open()) ? OpenSize : ClosedSize); int Limit = 30; if (TestFlag(Align, GV_EDGE_RIGHT) || TestFlag(Align, GV_EDGE_LEFT)) { Limit = min(Size, r.X()-1); } else /* if (TestFlag(Align, GV_EDGE_BOTTOM) || TextFlag(Align, GV_EDGE_TOP)) */ { Limit = min(Size, r.Y()-1); } if (Align & GV_EDGE_RIGHT) { r.x1 = r.x2 - Limit; } else if (Align & GV_EDGE_BOTTOM) { r.y1 = r.y2 - Limit; } else if (Align & GV_EDGE_LEFT) { r.x2 = r.x1 + Limit; } else // if (Align & GV_EDGE_TOP) { r.y2 = r.y1 + Limit; } if (!Open()) { r.x2 = r.x1 + Sx - 1; } } else { r.y2 = r.y1 - OpenSize; } SetPos(r, true); return true; } return false; }
void CDockingBar::OnPaint() { CPaintDC dc(this); // device context for painting COLORREF rgb_background= ::GetSysColor(COLOR_APPWORKSPACE); CMemoryDC mem_dc(dc, this, rgb_background); mem_dc.SelectStockObject(DEFAULT_GUI_FONT); CRect rect; GetClientRect(rect); mem_dc.Draw3dRect(rect, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DHILIGHT)); rect.DeflateRect(1, 1); mem_dc.Draw3dRect(rect, ::GetSysColor(COLOR_3DDKSHADOW), rgb_background); rect.DeflateRect(1, 0); rect.top++; const int GAP= rect.Height() / 2; const int ICON= 18; COLORREF rgb_black= ::GetSysColor(COLOR_BTNTEXT); COLORREF rgb_dark= ::GetSysColor(COLOR_3DDKSHADOW); COLORREF rgb_light= ::GetSysColor(COLOR_3DHILIGHT); COLORREF rgb_gray= GetLighterColor(rgb_background, 13.0); // 13.0% brighter CPen penBlack(PS_SOLID, 0, rgb_black); CPen penDark(PS_SOLID, 0, rgb_dark); CPen penLight(PS_SOLID, 0, rgb_light); CPen penGray(PS_SOLID, 0, rgb_gray); CBrush brGray(::GetSysColor(COLOR_3DFACE)); CBrush* brush= mem_dc.SelectObject(&brGray); mem_dc.SetBkMode(OPAQUE); CalcWidth(tabs_, mem_dc, rect); for (int index= 0; index < tabs_.size(); ++index) { CTab& tab= tabs_[index]; CRect text_rect= tab.location_rect_; text_rect.left += ICON; COLORREF rgb_tab= tab.active_ ? ::GetSysColor(COLOR_3DFACE) : rgb_background; if (tab.active_) // active tab--taller, gray backgnd { CRect rect= tab.location_rect_; rect.top++; rect.right++; rect.bottom = rect.top + 1; // draw two lines on the top mem_dc.FillSolidRect(rect, rgb_dark); rect.OffsetRect(0, 1); mem_dc.FillSolidRect(rect, rgb_light); rect.top++; rect.bottom = tab.location_rect_.bottom + 1; mem_dc.FillSolidRect(rect, rgb_tab); text_rect.top = rect.top; rect.top--; int bottom= tab.location_rect_.bottom - 1; int gap= (bottom - rect.top) / 2; POINT vptLeftTriangle[]= { { rect.left, rect.top }, { rect.left, bottom + 2 }, { rect.left - gap - 1, bottom + 2 }, { rect.left, rect.top } }; mem_dc.SelectStockObject(NULL_PEN); mem_dc.Polygon(vptLeftTriangle, array_count(vptLeftTriangle)); POINT vptRightTriangle[]= { { rect.right, rect.top }, { rect.right, bottom + 2 }, { rect.right + gap, bottom + 2 }, { rect.right + gap, bottom }, { rect.right, rect.top } }; mem_dc.Polygon(vptRightTriangle, array_count(vptRightTriangle)); // draw slanted line on the right side CPen* pen= mem_dc.SelectObject(&penBlack); mem_dc.MoveTo(rect.right, rect.top); mem_dc.LineTo(rect.right + gap, bottom); mem_dc.LineTo(rect.right + gap + 1, bottom); // draw slanted line on the left side mem_dc.SelectObject(&penDark); int left= rect.left - 1; mem_dc.MoveTo(left, rect.top); mem_dc.LineTo(left - gap, bottom); mem_dc.LineTo(left - gap + 1, bottom); // draw light slanted line on the left side mem_dc.SelectObject(&penLight); left++; mem_dc.MoveTo(left, rect.top); mem_dc.LineTo(left - gap, bottom); mem_dc.LineTo(left - gap, bottom + 2); } else // inactive tab (smaller, dark background) { CRect rect= tab.location_rect_; rect.left++; rect.right++; rect.top += 2; rect.bottom = rect.top + 1; // draw two lines on the top mem_dc.FillSolidRect(rect, rgb_dark); rect.OffsetRect(0, 1); mem_dc.FillSolidRect(rect, rgb_gray); // draw slanted line on the right side CPen* pen= mem_dc.SelectObject(&penBlack); int right= rect.right - 0; mem_dc.MoveTo(right, rect.top); int bottom= tab.location_rect_.bottom - 1; int gap= (bottom - rect.top) / 2; mem_dc.LineTo(right + gap, bottom + 1); // draw short slanted line on the left side mem_dc.SelectObject(&penDark); int left= rect.left - 1; mem_dc.MoveTo(left, rect.top); if (index == 0) // first tab? { mem_dc.LineTo(left - gap, bottom); // in the first tab whole edge is visible mem_dc.LineTo(left - gap, bottom + 1); // draw light slanted line on the left side mem_dc.SelectObject(&penGray); mem_dc.MoveTo(left + 1, rect.top); mem_dc.LineTo(left - gap + 1, bottom); mem_dc.LineTo(left - gap + 1, bottom + 1); } else { int left_half= left - gap / 2; int bottom_half= (rect.top + bottom) / 2; mem_dc.LineTo(left_half, bottom_half); mem_dc.LineTo(left_half, bottom_half + 1); // draw light slanted line on the left side mem_dc.SelectObject(&penGray); mem_dc.MoveTo(left + 1, rect.top); mem_dc.LineTo(left_half, bottom_half + 2); // previous tab is not active? // if (index > 0 && !tabs_[index - 1].active_) // mem_dc.LineTo(left_half, bottom_half + 3); } mem_dc.SelectObject(pen); text_rect.top = rect.top + 1; } mem_dc.SetBkColor(rgb_tab); mem_dc.DrawText(tab.name_, text_rect, DT_LEFT | DT_TOP | DT_SINGLELINE | DT_NOPREFIX | DT_EXPANDTABS | DT_END_ELLIPSIS); int offset= tab.active_ ? 0 : 12; CPoint icon(tab.location_rect_.left + 1, text_rect.top); if (tab.icon_ >= 0) image_list_.Draw(&mem_dc, offset + tab.icon_, icon, ILD_NORMAL); } mem_dc.SelectObject(brush); mem_dc.BitBlt(); }