void VDUIButtonW32::PreLayoutBase(const VDUILayoutSpecs& parentConstraints) { vduisize pad = mpBase->MapUnitsToPixels(vduisize(8,14)); SIZE siz = SizeText(parentConstraints.minsize.w, pad.w, pad.h); mLayoutSpecs.minsize.w = pad.w + siz.cx; // hack for non-command buttons if ((mAlignY & nsVDUI::kAlignTypeMask) == nsVDUI::kFill) mLayoutSpecs.minsize.h = 0; else mLayoutSpecs.minsize.h = pad.h; }
void VDUICheckboxW32::PreLayoutBase(const VDUILayoutSpecs& parentConstraints) { const vduisize pad = mpBase->MapUnitsToPixels(vduisize(14, 10)); mLayoutSpecs.minsize.w = pad.w; mLayoutSpecs.minsize.h = pad.h; SIZE siz = SizeText(parentConstraints.minsize.w - pad.w, pad.w, pad.h); siz.cy += 2*GetSystemMetrics(SM_CYEDGE); mLayoutSpecs.minsize.w += siz.cx; if (mLayoutSpecs.minsize.h < siz.cy) mLayoutSpecs.minsize.h = siz.cy; }
void VDUILabelW32::PreLayoutBaseW32(const VDUILayoutSpecs& parentConstraints) { SIZE siz = SizeText(parentConstraints.minsize.w, 0, 0); mLayoutSpecs.minsize.w = siz.cx; mLayoutSpecs.minsize.h = siz.cy; }
void TranscriptWindow::Layout(void) { CRect clientRect; GetClientRect(clientRect); m_layout.clientSize = clientRect.Size(); m_layout.columnWidth = clientRect.Width()/2; m_layout.font = theApp.GetFont(InformApp::FontDisplay); m_layout.fontSize = theApp.MeasureFont(m_layout.font); m_layout.margin = CSize(m_layout.fontSize.cx,m_layout.fontSize.cy/3); m_layout.centreMargin = m_layout.margin.cx*4; CDC* dc = GetDC(); m_layout.nodes.clear(); Skein::Node* node = m_skeinEndThread; while (node != NULL) { NodeLayout nl; nl.node = node; // Get the text associated with the node const CStringW& transcript = nl.node->GetTranscriptText(); const CStringW& expected = nl.node->GetExpectedText(); // Measure the height of the expected text CRect textRect; textRect.SetRectEmpty(); textRect.right = m_layout.columnWidth-m_layout.margin.cx-m_layout.centreMargin; SizeText(*dc,textRect,expected); nl.height = textRect.Height(); // Measure the height of the transcript text textRect.SetRectEmpty(); textRect.right = m_layout.columnWidth-m_layout.margin.cx-m_layout.centreMargin; SizeText(*dc,textRect,transcript); if (textRect.Height() > nl.height) nl.height = textRect.Height(); // Use the tallest for the height of the node in the transcript if (m_layout.fontSize.cy > nl.height) nl.height = m_layout.fontSize.cy; m_layout.nodes.push_front(nl); node = node->GetParent(); } ReleaseDC(dc); // Compare the height of the transcript with the height of the window int height = GetHeight(); if (height > clientRect.Height()) { // The transcript is taller than the window, so turn the scrollbar on EnableScrollBar(SB_VERT,ESB_ENABLE_BOTH); // Get the current scrollbar settings SCROLLINFO scroll; ::ZeroMemory(&scroll,sizeof scroll); scroll.cbSize = sizeof scroll; GetScrollInfo(SB_VERT,&scroll); // Change the maximum position and the size of the scrollbar scroll.nMin = 0; scroll.nMax = height-1; scroll.nPage = clientRect.Height(); SetScrollInfo(SB_VERT,&scroll); } else { // The transcript is shorter than the window, so turn the scrollbar off EnableScrollBar(SB_VERT,ESB_DISABLE_BOTH); SCROLLINFO scroll; ::ZeroMemory(&scroll,sizeof scroll); scroll.cbSize = sizeof scroll; SetScrollInfo(SB_VERT,&scroll); } }