//----------------------------------------------------------------------------- void LineProfileCanvas::OnPaintCustom( wxPaintDC& dc ) //----------------------------------------------------------------------------- { wxCoord yOffset( 1 ), w( 0 ), h( 0 ); dc.GetSize( &w, &h ); const double scaleX = static_cast<double>( w - 2 * GetBorderWidth() ) / static_cast<double>( ( GetDataCount() == 0 ) ? 1 : GetDataCount() - 1 ); const double scaleY = GetScaleY( h ); DrawMarkerLines( dc, w, h, scaleX ); unsigned int from, to; GetDrawRange( &from, &to ); const int borderWidth = GetBorderWidth(); const wxString YMarkerString( wxString::Format( wxT( "Draw Range(absolute): %d / %d, " ), from, to ) ); wxCoord xOffset; dc.GetTextExtent( YMarkerString, &xOffset, 0 ); xOffset += borderWidth / 2; dc.DrawText( YMarkerString, borderWidth / 2, yOffset ); if( m_boUnsupportedPixelFormat ) { dc.SetTextForeground( *wxRED ); dc.DrawText( wxString( wxT( "Unsupported pixel format" ) ), xOffset, yOffset ); dc.SetTextForeground( *wxBLACK ); } else if( m_ppData ) { for( int channel = 0; channel < m_ChannelCount; channel++ ) { DrawProfileLine( dc, h, borderWidth + 1, scaleX, scaleY, from, to, m_ppData[channel], GetDataCount(), *m_Pens[channel].pColour_ ); DrawInfoString( dc, wxString::Format( wxT( "%s%s: " ), ( channel != 0 ) ? wxT( ", " ) : wxT( "" ), m_Pens[channel].description_.c_str() ), xOffset, yOffset, *( m_Pens[channel].pColour_ ) ); } } }
CRect PartBase::GetBoxLocation(bool bWithBorder) const { if (bWithBorder) return m_Rect; CRect cRect = m_Rect; cRect.DeflateRect(GetBorderWidth(false), GetBorderWidth(false)); return cRect; }
sf::FloatRect Window::GetClientRect() const { sf::FloatRect clientrect( 0, 0, GetAllocation().Width, GetAllocation().Height ); float title_height( HasStyle( Titlebar ) ? Context::Get().GetEngine().GetProperty<float>( "TitleHeight", shared_from_this() ) : 0.f ); float border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); clientrect.Left += border_width + GetBorderWidth(); clientrect.Top += title_height + border_width + GetBorderWidth(); clientrect.Width -= 2 * border_width + 2 * GetBorderWidth(); clientrect.Height -= title_height + 2 * border_width + 2 * GetBorderWidth(); return clientrect; }
void wxAuiMSWTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { if ( !IsThemed() ) { wxAuiGenericTabArt::DrawBorder(dc, wnd, rect); return; } wxRect drawRect(rect); drawRect.y += m_maxTabHeight + wnd->FromDIP(1); drawRect.height -= m_maxTabHeight; // Mask border not covered by native theme wxRect topDrawRect(rect); topDrawRect.height = drawRect.height; dc.SetPen(wxPen(wnd->GetBackgroundColour(), GetBorderWidth(wnd))); dc.DrawRectangle(topDrawRect); RECT r; wxCopyRectToRECT(drawRect, r); wxUxThemeHandle hTheme(wnd, L"TAB"); ::DrawThemeBackground( hTheme, GetHdcOf(dc.GetTempHDC()), TABP_PANE, 0, &r, NULL); }
void JXImageCheckbox::DrawBorder ( JXWindowPainter& p, const JRect& frame ) { const JBoolean drawChecked = DrawChecked(); const JBoolean isActive = IsActive(); const JSize borderWidth = GetBorderWidth(); if (drawChecked && isActive) { JXDrawDownFrame(p, frame, borderWidth); } else if (isActive) { JXDrawUpFrame(p, frame, borderWidth); } else if (borderWidth > 0) { p.SetLineWidth(borderWidth); if (drawChecked) { p.SetPenColor((GetColormap())->GetWhiteColor()); } else { p.SetPenColor((GetColormap())->GetInactiveLabelColor()); } p.RectInside(frame); } }
void JXButton::SetShortcuts ( const JCharacter* list ) { JXWindow* w = GetWindow(); w->ClearShortcuts(this); w->InstallShortcuts(this, list); const JBoolean wasReturnButton = itsIsReturnButtonFlag; itsIsReturnButtonFlag = kJFalse; if (list != NULL) { JString shortcuts = list; if (shortcuts.Contains("^M") || shortcuts.Contains("^m")) { itsIsReturnButtonFlag = kJTrue; } } const JSize borderWidth = GetBorderWidth(); if (!wasReturnButton && itsIsReturnButtonFlag) { SetBorderWidth(borderWidth+1); } else if (wasReturnButton && !itsIsReturnButtonFlag && borderWidth > 0) { SetBorderWidth(borderWidth-1); } Refresh(); }
void JXButton::DrawBorder ( JXWindowPainter& p, const JRect& origFrame ) { JSize borderWidth = GetBorderWidth(); if (borderWidth > 0 && IsActive()) { JRect frame = origFrame; if (itsIsReturnButtonFlag) { p.JPainter::Rect(frame); frame.Shrink(1,1); borderWidth--; } if (itsIsPushedFlag) { JXDrawDownFrame(p, frame, borderWidth); } else { JXDrawUpFrame(p, frame, borderWidth); } } else if (borderWidth > 0) { p.SetLineWidth(borderWidth); p.SetPenColor((GetColormap())->GetInactiveLabelColor()); p.RectInside(origFrame); } }
void nsBCTableCellFrame::PaintUnderlay(nsPresContext& aPresContext, nsIRenderingContext& aRenderingContext, const nsRect& aDirtyRect, PRUint32& aFlags, const nsStyleBorder& aStyleBorder, const nsStylePadding& aStylePadding, const nsStyleTableBorder& aCellTableStyle) { if (!(aFlags & NS_PAINT_FLAG_TABLE_BG_PAINT) /*direct call; not table-based paint*/ || (aFlags & NS_PAINT_FLAG_TABLE_CELL_BG_PASS) /*table cell background only pass*/) { // make border-width reflect the half of the border-collapse // assigned border that's inside the cell GET_PIXELS_TO_TWIPS(&aPresContext, p2t); nsMargin borderWidth; GetBorderWidth(p2t, borderWidth); nsStyleBorder myBorder(aStyleBorder); NS_FOR_CSS_SIDES(side) { myBorder.SetBorderWidth(side, borderWidth.side(side)); } nsRect rect(0, 0, mRect.width, mRect.height); nsCSSRendering::PaintBackground(&aPresContext, aRenderingContext, this, aDirtyRect, rect, myBorder, aStylePadding, PR_TRUE); // borders are painted by nsTableFrame }
void JXMenuBar::DrawBorder ( JXWindowPainter& p, const JRect& frame ) { JXDrawUpFrame(p, frame, GetBorderWidth()); }
CFX_FloatRect CPWL_Wnd::GetClientRect() const { CFX_FloatRect rcWindow = GetWindowRect(); CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); if (CPWL_ScrollBar* pVSB = GetVScrollBar()) rcClient.right -= pVSB->GetScrollBarWidth(); rcClient.Normalize(); return rcWindow.Contains(rcClient) ? rcClient : CFX_FloatRect(); }
void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CFX_FloatRect rectWnd = GetWindowRect(); if (!rectWnd.IsEmpty()) { if (HasFlag(PWS_BACKGROUND)) { CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient, GetBackgroundColor(), GetTransparency()); } if (HasFlag(PWS_BORDER)) CPWL_Utils::DrawBorder(pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), GetTransparency()); } }
void JXRadioGroup::DrawBorder ( JXWindowPainter& p, const JRect& frame ) { // Modified by CD - don't draw frame if width is zero if (GetBorderWidth()) JXDrawEngravedFrame(p, frame, kFrameDownWidth, kFrameBetweenWidth, kFrameUpWidth); }
void wxAuiSimpleTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { int i, border_width = GetBorderWidth(wnd); wxRect theRect(rect); for (i = 0; i < border_width; ++i) { dc.DrawRectangle(theRect.x, theRect.y, theRect.width, theRect.height); theRect.Deflate(1); } }
void FlatAuiTabArt::DrawBorder(wxDC& dc, wxWindow* wnd, const wxRect& rect) { dc.SetPen(wxPen(wxColour(255,255,255))); int i, border_width = GetBorderWidth(wnd); wxRect theRect(rect); for (i = 0; i < border_width; ++i) { dc.DrawRectangle(theRect.x, theRect.y, theRect.width, theRect.height); theRect.Deflate(1); } }
sf::Vector2f Window::GetRequisitionImpl() const { sf::Vector2f requisition( 2 * GetBorderWidth(), 2 * GetBorderWidth() ); if( HasStyle( Titlebar ) ) { float visual_border_width( Context::Get().GetEngine().GetProperty<float>( "BorderWidth", shared_from_this() ) ); float title_height( Context::Get().GetEngine().GetProperty<float>( "TitleHeight", shared_from_this() ) ); requisition.x += visual_border_width; requisition.y += visual_border_width + title_height; } if( GetChild() ) { requisition += GetChild()->GetRequisition(); } else { requisition.x = std::max( 50.f, requisition.x ); requisition.y = std::max( 50.f, requisition.y * 2.f ); } return requisition; }
CPDF_Rect CPWL_Edit::GetClientRect() const { CPDF_Rect rcClient = CPWL_Utils::DeflateRect( GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { if (pVSB->IsVisible()) { rcClient.right -= PWL_SCROLLBAR_WIDTH; } } return rcClient; }
void CPWL_Wnd::RePosChildWnd() { CFX_FloatRect rcContent = CPWL_Utils::DeflateRect( GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); CPWL_ScrollBar* pVSB = GetVScrollBar(); CFX_FloatRect rcVScroll = CFX_FloatRect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom, rcContent.right - 1.0f, rcContent.top); if (pVSB) pVSB->Move(rcVScroll, TRUE, FALSE); }
VOID CXElement::On_CXMsg_PaintElement( CXMsg_PaintElement& arg ) { arg.msgHandled = TRUE; if (!m_memDC) { return; } BOOL updated = FALSE; CRect rect; GetRect(rect); rect.OffsetRect(-rect.left,-rect.top); COLORREF color; if (XSUCCEEDED(GetColor(color))) { LOGBRUSH brushLog; brushLog.lbColor = color; brushLog.lbStyle = BS_SOLID; brushLog.lbHatch = 0; HBRUSH brush = CreateBrushIndirect(&brushLog); m_memDC->FillRect(rect,brush); DeleteObject(brush); updated = TRUE; } COLORREF borderColor; if(XSUCCEEDED(GetBorderColor(borderColor))) { DWORD borderWidth; GetBorderWidth(borderWidth); HPEN pen = CreatePen(PS_SOLID,borderWidth,borderColor); CGDIHandleSwitcher handleSwitcher(m_memDC->m_hDC,pen); m_memDC->Rectangle(rect); updated = TRUE; } if (arg.paintChildren) { _SendXMsg(arg); } if (updated) { CXMsg_Invalidate msg; msg.invalidRect = ElementUtil::GetElementRectInClientCoord(this); _SendXMsg(msg); } }
void CheckBoxObject::SaveToXml(TiXmlElement * elem) { TiXmlElement * str = new TiXmlElement( "String" ); elem->LinkEndChild( str ); str->SetAttribute("value", GetString().c_str()); TiXmlElement * checked = new TiXmlElement( "Checked" ); elem->LinkEndChild( checked ); checked->SetAttribute("value", static_cast<bool>(IsChecked())); TiXmlElement * font = new TiXmlElement( "Font" ); elem->LinkEndChild( font ); font->SetAttribute("value", GetFont().c_str()); TiXmlElement * characterSize = new TiXmlElement( "CharacterSize" ); elem->LinkEndChild( characterSize ); characterSize->SetAttribute("value", GetCharacterSize()); TiXmlElement * backgroundColorElem = new TiXmlElement( "BackgroundColorScheme" ); elem->LinkEndChild( backgroundColorElem ); backgroundColor->SaveToXml(backgroundColorElem); TiXmlElement * borderColorElem = new TiXmlElement( "BorderColorScheme" ); elem->LinkEndChild( borderColorElem ); borderColor->SaveToXml(borderColorElem); TiXmlElement * textColorElem = new TiXmlElement( "TextColorScheme" ); elem->LinkEndChild( textColorElem ); textColor->SaveToXml(textColorElem); TiXmlElement * checkColorElem = new TiXmlElement( "CheckColorScheme" ); elem->LinkEndChild( checkColorElem ); checkColor->SaveToXml(checkColorElem); TiXmlElement * borderWidthElem = new TiXmlElement( "BorderWidth" ); elem->LinkEndChild( borderWidthElem ); borderWidthElem->SetAttribute("value", GetBorderWidth()); TiXmlElement * paddingElem = new TiXmlElement( "Padding" ); elem->LinkEndChild( paddingElem ); paddingElem->SetAttribute("value", GetPadding()); TiXmlElement * boxSizeElem = new TiXmlElement( "BoxSize" ); elem->LinkEndChild( boxSizeElem ); boxSizeElem->SetAttribute("value", GetBoxSize()); TiXmlElement * checkSignSizeElem = new TiXmlElement( "CheckSignSize" ); elem->LinkEndChild( checkSignSizeElem ); checkSignSizeElem->SetAttribute("value", GetCheckSignSize()); }
// if don't set,Get default apperance stream void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { CFX_FloatRect rectWnd = GetWindowRect(); if (!rectWnd.IsEmpty()) { CFX_ByteTextBuf sThis; if (HasFlag(PWS_BACKGROUND)) sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor()); if (HasFlag(PWS_BORDER)) { sThis << CPWL_Utils::GetBorderAppStream( rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()), GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(), GetBorderDash()); } sAppStream << sThis; } }
void JX3DWidget::DrawBorder ( JXWindowPainter& p, const JRect& frame ) { const JSize borderWidth = GetBorderWidth(); if (itsShowFocusFlag && HasFocus() && borderWidth > 0) { p.SetLineWidth(borderWidth); p.SetPenColor((p.GetColormap())->GetWhiteColor()); p.RectInside(frame); } else { JXDrawDownFrame(p, frame, borderWidth); } }
void QGraph::SaveSettings(QSettings *pSettings) { QFont lgft; QColor clr; int k,s,w; bool ba, bs; double f; pSettings->beginGroup(m_GraphName); { //read variables clr = GetAxisColor(); pSettings->setValue("AxisColorRed", clr.red()); pSettings->setValue("AxisColorGreen",clr.green()); pSettings->setValue("AxisColorBlue", clr.blue()); k = GetAxisStyle(); pSettings->setValue("AxisStyle", k); k = GetAxisWidth(); pSettings->setValue("AxisWidth", k); clr = GetTitleColor(); pSettings->setValue("TitleColorRed", clr.red()); pSettings->setValue("TitleColorGreen",clr.green()); pSettings->setValue("TitleColorBlue", clr.blue()); clr = GetLabelColor(); pSettings->setValue("LabelColorRed", clr.red()); pSettings->setValue("LabelColorGreen",clr.green()); pSettings->setValue("LabelColorBlue", clr.blue()); GetTitleLogFont(&lgft); pSettings->setValue("TitleFontName", lgft.family()); pSettings->setValue("TitleFontSize", lgft.pointSize()); GetLabelLogFont(&lgft); pSettings->setValue("LabelFontName", lgft.family()); pSettings->setValue("LabelFontSize", lgft.pointSize()); GetXMajGrid(bs,clr,s,w); pSettings->setValue("XMajGridColorRed", clr.red()); pSettings->setValue("XMajGridColorGreen",clr.green()); pSettings->setValue("XMajGridColorBlue", clr.blue()); pSettings->setValue("XMajGridShow",bs); pSettings->setValue("XMajGridStyle",s); pSettings->setValue("XMajGridWidth",w); GetYMajGrid(bs,clr,s,w); pSettings->setValue("YMajGridColorRed", clr.red()); pSettings->setValue("YMajGridColorGreen",clr.green()); pSettings->setValue("YMajGridColorBlue", clr.blue()); pSettings->setValue("YMajGridShow",bs); pSettings->setValue("YMajGridStyle",s); pSettings->setValue("YMajGridWidth",w); GetXMinGrid(bs,ba,clr,s,w,f); pSettings->setValue("XMinGridColorRed", clr.red()); pSettings->setValue("XMinGridColorGreen",clr.green()); pSettings->setValue("XMinGridColorBlue", clr.blue()); pSettings->setValue("XMinGridAuto",ba); pSettings->setValue("XMinGridShow",bs); pSettings->setValue("XMinGridStyle",s); pSettings->setValue("XMinGridWidth",w); pSettings->setValue("XMinGridUnit",f); GetYMinGrid(bs,ba,clr,s,w,f); pSettings->setValue("YMinGridColorRed", clr.red()); pSettings->setValue("YMinGridColorGreen",clr.green()); pSettings->setValue("YMinGridColorBlue", clr.blue()); pSettings->setValue("YMinGridAuto",ba); pSettings->setValue("YMinGridShow",bs); pSettings->setValue("YMinGridStyle",s); pSettings->setValue("YMinGridWidth",w); pSettings->setValue("YMinGridUnit",f); clr = GetBorderColor(); s = GetBorderStyle(); w = GetBorderWidth(); pSettings->setValue("BorderColorRed", clr.red()); pSettings->setValue("BorderColorGreen", clr.green()); pSettings->setValue("BorderColorBlue", clr.blue()); pSettings->setValue("BorderStyle", s); pSettings->setValue("BorderWidth", w); pSettings->setValue("BorderShow", m_bBorder); clr = GetBackColor(); pSettings->setValue("BackColorRed", clr.red()); pSettings->setValue("BackColorGreen", clr.green()); pSettings->setValue("BackColorBlue", clr.blue()); pSettings->setValue("Inverted", m_bYInverted); pSettings->setValue("XVariable", m_X); pSettings->setValue("YVariable", m_Y); } pSettings->endGroup(); }
/*---------------------------------------------------------------------------*/ template<class T> IPositionedFormatContext* HTMLElementDisplay<T>::FormatSelfPositioned ( DisplayElement* displayParent, IPositionedFormatContext* rootContext, IPositionedFormatContext* parentContext, FormatContextFactory* childContextFactory, WEBC_BOOL generateChildContext ) { WebRect rect; WEBC_UINT16 position = GetPosition(); IPositionedFormatContext* childContext = 0; if (position == TU_POSITION_RELATIVE) { if (generateChildContext) { const WebRect * tmpRect = &(((DisplayElement *)(this))->mRect); rect.Set(tmpRect); rect.MoveTo(0,0); CSSLength height; GetCSSLength(&height, CSS_PROPERTY_HEIGHT); childContext = childContextFactory->newPositioned ( &rect, (height.type == CSS_LENGTH_UNIT_AUTO) || (height.type == CSS_LENGTH_UNIT_PERCENT && parentContext->parentHeightIsAuto()), // parent height is auto TU_DIR_LTR, 0, // border-left-width 0, // border-top-width 0, // border-right-width 0, // border-bottom-width 0, // autoIndentLeft 0, // autoIndentTop 0 // autoIndentRight ); } } else { WebRect containingBlock; IPositionedFormatContext* containingContext; DISPLAY_INT borderLeftValue; DISPLAY_INT borderTopValue; DISPLAY_INT borderRightValue; DISPLAY_INT borderBottomValue; if (displayParent) { if (displayParent != T::mpParent) { mHtmlElementDisplayFlags &= ~HELEM_DISPLAY_FLAG_STYLE_SET; } displayParent->InsertOrdered(this); } if (position == TU_POSITION_FIXED) { T::SetFixedPosition(WEBC_TRUE); containingContext = rootContext; } else { T::SetFixedPosition(WEBC_FALSE); containingContext = parentContext; } containingContext->getContainingBlock(&containingBlock); WEBC_BOOL parentHeightIsAuto = containingContext->parentHeightIsAuto(); int textDirection = containingContext->getTextDirection(); DISPLAY_INT parentBorderLeft = containingContext->getParentBorderLeft(); DISPLAY_INT parentBorderTop = containingContext->getParentBorderTop(); DISPLAY_INT parentBorderRight = containingContext->getParentBorderRight(); DISPLAY_INT parentBorderBottom = containingContext->getParentBorderBottom(); DISPLAY_INT autoIndentLeft = parentContext->getAutoIndentLeft(); DISPLAY_INT autoIndentTop = parentContext->getAutoIndentTop(); DISPLAY_INT autoIndentRight = parentContext->getAutoIndentRight(); if (position == TU_POSITION_FIXED) { WebRect parentRect; parentContext->getContainingBlock(&parentRect); autoIndentLeft += parentRect.left; autoIndentTop += parentRect.top; autoIndentRight += (containingBlock.right - parentRect.right); } DISPLAY_INT parentWidth = containingBlock.Width() - (parentBorderLeft + parentBorderRight); DISPLAY_INT parentHeight = containingBlock.Height() - (parentBorderTop + parentBorderBottom); WebFont font = mpHtmlElement->GetWebFont(); DISPLAY_INT emHeight = font? WEB_FONT_HEIGHT(font) : WEBC_CFG_DEFAULT_TEXT_HEIGHT; DISPLAY_INT exHeight = emHeight >> 1; // First find the left edge and width CSSLength left; CSSLength right; CSSLength width; // Find value for left, right, width, marginLeft, marginRight GetCSSLength(&left, CSS_PROPERTY_LEFT); GetCSSLength(&right, CSS_PROPERTY_RIGHT); GetCSSLength(&width, CSS_PROPERTY_WIDTH); DISPLAY_INT leftValue; DISPLAY_INT rightValue; DISPLAY_INT widthValue; DISPLAY_INT marginLeftValue; DISPLAY_INT paddingLeftValue; DISPLAY_INT paddingTopValue; DISPLAY_INT paddingRightValue; DISPLAY_INT paddingBottomValue; // Find value for padding and border paddingLeftValue = GetPixelLength(CSS_PROPERTY_PADDING_LEFT, parentWidth, emHeight, exHeight, 0); paddingTopValue = GetPixelLength(CSS_PROPERTY_PADDING_TOP, parentWidth, emHeight, exHeight, 0); paddingRightValue = GetPixelLength(CSS_PROPERTY_PADDING_RIGHT, parentWidth, emHeight, exHeight, 0); paddingBottomValue = GetPixelLength(CSS_PROPERTY_PADDING_BOTTOM, parentWidth, emHeight, exHeight, 0); borderLeftValue = GetBorderWidth(CSS_LEFT, parentWidth, emHeight, exHeight, parentBorderLeft); borderTopValue = GetBorderWidth(CSS_TOP, parentWidth, emHeight, exHeight, parentBorderTop); borderRightValue = GetBorderWidth(CSS_RIGHT, parentWidth, emHeight, exHeight, parentBorderRight); borderBottomValue = GetBorderWidth(CSS_BOTTOM, parentWidth, emHeight, exHeight, parentBorderBottom); CSSLength height; CSSLength top; CSSLength bottom; DISPLAY_INT heightValue=0; WEBC_BOOL heightIsAuto=0; GetCSSLength(&height, CSS_PROPERTY_HEIGHT); GetCSSLength(&top, CSS_PROPERTY_TOP); #define NOTHING_KNOWN 0 #define HEIGHT_KNOWN 1 #define TOP_KNOWN 2 #define BOTTOM_KNOWN 4 WEBC_UINT8 verticalCase; verticalCase = (height.type == CSS_LENGTH_UNIT_AUTO || (height.type == CSS_LENGTH_UNIT_PERCENT && parentHeightIsAuto))? 0 : HEIGHT_KNOWN; verticalCase |= (top.type == CSS_LENGTH_UNIT_AUTO)? 0 : TOP_KNOWN; if (verticalCase != (HEIGHT_KNOWN|TOP_KNOWN)) { GetCSSLength(&bottom, CSS_PROPERTY_BOTTOM); verticalCase |= (bottom.type == CSS_LENGTH_UNIT_AUTO || parentHeightIsAuto)? 0 : BOTTOM_KNOWN; } DISPLAY_INT topValue = 0; DISPLAY_INT bottomValue = 0; DISPLAY_INT marginTopValue = 0; DISPLAY_INT marginBottomValue = 0; switch (verticalCase) { case NOTHING_KNOWN: // top = auto indent top // height = content height topValue = autoIndentTop; heightValue = 0; heightIsAuto = WEBC_TRUE; marginTopValue = GetPixelLength(CSS_PROPERTY_MARGIN_TOP, parentWidth, emHeight, exHeight, 0); break; case HEIGHT_KNOWN: // top = auto indent top // height = height topValue = autoIndentTop; heightValue = CSS_LengthToPixels(&height, parentHeight, emHeight, exHeight); heightIsAuto = WEBC_FALSE; marginTopValue = GetPixelLength(CSS_PROPERTY_MARGIN_TOP, parentWidth, emHeight, exHeight, 0); break; case TOP_KNOWN: // top = top // height = content height if (top.type == CSS_LENGTH_UNIT_PERCENT && parentHeightIsAuto) { topValue = autoIndentTop; } else { topValue = CSS_LengthToPixels(&top, parentHeight, emHeight, exHeight); } heightValue = 0; heightIsAuto = WEBC_TRUE; marginTopValue = GetPixelLength(CSS_PROPERTY_MARGIN_TOP, parentWidth, emHeight, exHeight, 0); break; case HEIGHT_KNOWN|TOP_KNOWN: // top = top // height = height if (top.type == CSS_LENGTH_UNIT_PERCENT && parentHeightIsAuto) { topValue = autoIndentTop; } else { topValue = CSS_LengthToPixels(&top, parentHeight, emHeight, exHeight); } heightValue = CSS_LengthToPixels(&height, parentHeight, emHeight, exHeight); heightIsAuto = WEBC_FALSE; marginTopValue = GetPixelLength(CSS_PROPERTY_MARGIN_TOP, parentWidth, emHeight, exHeight, 0); break; case BOTTOM_KNOWN: // bottom = bottom // height = content height // top = parentHeight - (height + bottom) bottomValue = GetPixelLength(&bottom, parentHeight, emHeight, exHeight, 0); marginBottomValue = GetPixelLength(CSS_PROPERTY_MARGIN_BOTTOM, parentWidth, emHeight, exHeight, 0); heightValue = 0; heightIsAuto = WEBC_TRUE; break; case HEIGHT_KNOWN|BOTTOM_KNOWN: // bottom = bottom // height = height // top = parentHeight - (height + bottom) bottomValue = GetPixelLength(&bottom, parentHeight, emHeight, exHeight, 0); heightValue = CSS_LengthToPixels(&height, parentHeight, emHeight, exHeight); heightIsAuto = WEBC_FALSE; marginBottomValue = GetPixelLength(CSS_PROPERTY_MARGIN_BOTTOM, parentWidth, emHeight, exHeight, 0); topValue = parentHeight - (borderTopValue + paddingTopValue + heightValue + paddingBottomValue + borderBottomValue + marginBottomValue + bottomValue); break; case TOP_KNOWN|BOTTOM_KNOWN: // top = top // bottom = bottom // height = parentHeight - (top + bottom) if (top.type == CSS_LENGTH_UNIT_PERCENT && parentHeightIsAuto) { topValue = autoIndentTop; } else { topValue = CSS_LengthToPixels(&top, parentHeight, emHeight, exHeight); } bottomValue = GetPixelLength(&bottom, parentHeight, emHeight, exHeight, 0); marginTopValue = GetPixelLength(CSS_PROPERTY_MARGIN_TOP, parentWidth, emHeight, exHeight, 0); marginBottomValue = GetPixelLength(CSS_PROPERTY_MARGIN_BOTTOM, parentWidth, emHeight, exHeight, 0); heightValue = parentHeight - (topValue + marginTopValue + borderTopValue + paddingTopValue + paddingBottomValue + borderBottomValue + marginBottomValue + bottomValue); heightIsAuto = WEBC_FALSE; break; } if (width.type != CSS_LENGTH_UNIT_AUTO) { widthValue = CSS_LengthToPixels(&width, parentWidth, emHeight, exHeight); WEBC_BOOL leftAligned = (textDirection == TU_DIR_RTL)? (right.type == CSS_LENGTH_UNIT_AUTO && left.type != CSS_LENGTH_UNIT_AUTO) : (left.type != CSS_LENGTH_UNIT_AUTO || right.type == CSS_LENGTH_UNIT_AUTO); if (leftAligned) { // ignore right and margin-right leftValue = GetPixelLength(&left, parentWidth, emHeight, exHeight, autoIndentLeft); marginLeftValue = GetPixelLength(CSS_PROPERTY_MARGIN_LEFT, parentWidth, emHeight, exHeight, 0); } else { DISPLAY_INT marginRightValue; // ignore left and margin-left rightValue = GetPixelLength(&right, parentWidth, emHeight, exHeight, autoIndentRight); marginRightValue = GetPixelLength(CSS_PROPERTY_MARGIN_RIGHT, parentWidth, emHeight, exHeight, 0); leftValue = parentWidth - (rightValue + marginRightValue + borderRightValue + paddingRightValue + widthValue + paddingLeftValue + borderLeftValue); marginLeftValue = 0; } } else { // width.type == CSS_LENGTH_UNIT_AUTO // try to get the intrinsic width of the element. This might rely on the // calculated height of the element; for example, in the case of an image with // specified height and auto width, the aspect ratio of the source image determines // the resulting intrinsic width. DISPLAY_INT marginRightValue; WEBC_BOOL hasIntrinsicWidth = GetIntrinsicWidth(&widthValue, heightValue, heightIsAuto); if (left.type == CSS_LENGTH_UNIT_AUTO && right.type != CSS_LENGTH_UNIT_AUTO && hasIntrinsicWidth) { rightValue = GetPixelLength(&right, parentWidth, emHeight, exHeight, autoIndentRight); marginRightValue = GetPixelLength(CSS_PROPERTY_MARGIN_RIGHT, parentWidth, emHeight, exHeight, 0); marginLeftValue = 0; leftValue = parentWidth - (widthValue + borderLeftValue + paddingLeftValue + paddingRightValue + borderRightValue + marginRightValue + rightValue); } else { leftValue = GetPixelLength(&left, parentWidth, emHeight, exHeight, autoIndentLeft); marginLeftValue = GetPixelLength(CSS_PROPERTY_MARGIN_LEFT, parentWidth, emHeight, exHeight, 0); if (!hasIntrinsicWidth || (right.type != CSS_LENGTH_UNIT_AUTO && left.type != CSS_LENGTH_UNIT_AUTO)) { // right and left are both non-auto, OR element has no intrinsic width: // calculate left, right, and margins then extrapolate width rightValue = GetPixelLength(&right, parentWidth, emHeight, exHeight, autoIndentRight); marginRightValue = GetPixelLength(CSS_PROPERTY_MARGIN_RIGHT, parentWidth, emHeight, exHeight, 0); widthValue = parentWidth - (leftValue + marginLeftValue + borderLeftValue + paddingLeftValue + paddingRightValue + borderRightValue + marginRightValue + rightValue); // we don't want to stretch the width beyond what the maximum content // width; only give the element as much space as it actually needs. if (right.type == CSS_LENGTH_UNIT_AUTO || left.type == CSS_LENGTH_UNIT_AUTO) { // to speed this up, bail out of GetMaxWidth when we exceed widthValue DISPLAY_INT maxWidth = GetMaxWidthSmallerThan(widthValue); // NOTE: GetMaxWidth and GetMaxWidthSmallerThan return the total width // of the element, including borders and padding. So we must subtract // borders and padding to make it correspond to the contentWidth maxWidth -= (borderLeftValue + paddingLeftValue + paddingRightValue + borderRightValue); if (maxWidth < widthValue) { WEBC_BOOL leftAligned = (textDirection == TU_DIR_RTL)? (right.type == CSS_LENGTH_UNIT_AUTO && left.type != CSS_LENGTH_UNIT_AUTO) : (left.type != CSS_LENGTH_UNIT_AUTO || right.type == CSS_LENGTH_UNIT_AUTO); if (!leftAligned) { // box is right-aligned // adjust leftValue to account for the unused space leftValue += (widthValue - maxWidth); } widthValue = maxWidth; } } } } } // Now format the content of this element DISPLAY_INT contentHeight = FormatContentPositioned ( widthValue, heightValue, heightIsAuto, borderLeftValue, borderTopValue, borderRightValue, borderBottomValue, paddingLeftValue, paddingTopValue, paddingRightValue, paddingBottomValue ); // Find the top edge and height // NOTE: top and bottom percentages are relative to parent's HEIGHT, whereas // margin-top and margin-bottom are relative to parent's WIDTH, except in the root // context (tbd - handle this special case correctly) switch (verticalCase) { case NOTHING_KNOWN: case TOP_KNOWN: heightValue = contentHeight; break; case BOTTOM_KNOWN: // height = content height // top = parentHeight - (height + bottom) heightValue = contentHeight; topValue = parentHeight - (borderTopValue + paddingTopValue + heightValue + paddingBottomValue + borderBottomValue + marginBottomValue + bottomValue); break; } rect.Set (0, 0, borderLeftValue + paddingLeftValue + widthValue + paddingRightValue + borderRightValue - 1, borderTopValue + paddingTopValue + heightValue + paddingBottomValue + borderBottomValue - 1 ); rect.MoveTo ( parentBorderLeft + leftValue + marginLeftValue, parentBorderTop + topValue + marginTopValue ); if (position == TU_POSITION_FIXED) { rect.Shift(containingBlock.left, containingBlock.top); } Move(&rect); if (generateChildContext) { childContext = childContextFactory->newPositioned ( &rect, heightIsAuto, TU_DIR_LTR, borderLeftValue, borderTopValue, borderRightValue, borderBottomValue, paddingLeftValue, paddingTopValue, paddingRightValue ); } } return (childContext); }
void CPWL_ComboBox::RePosChildWnd() { CPDF_Rect rcClient = GetClientRect(); if (m_bPopup) { CPDF_Rect rclient = GetClientRect(); CPDF_Rect rcButton = rclient; CPDF_Rect rcEdit = rcClient; CPDF_Rect rcList = CPWL_Wnd::GetWindowRect(); FX_FLOAT fOldWindowHeight = m_rcOldWindow.Height(); FX_FLOAT fOldClientHeight = fOldWindowHeight - GetBorderWidth() * 2; switch (m_nPopupWhere) { case 0: rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; if (rcButton.left < rclient.left) rcButton.left = rclient.left; rcButton.bottom = rcButton.top - fOldClientHeight; rcEdit.right = rcButton.left - 1.0f; if (rcEdit.left < rclient.left) rcEdit.left = rclient.left; if (rcEdit.right < rcEdit.left) rcEdit.right = rcEdit.left; rcEdit.bottom = rcEdit.top - fOldClientHeight; rcList.top -= fOldWindowHeight; break; case 1: rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; if (rcButton.left < rclient.left) rcButton.left = rclient.left; rcButton.top = rcButton.bottom + fOldClientHeight; rcEdit.right = rcButton.left - 1.0f; if (rcEdit.left < rclient.left) rcEdit.left = rclient.left; if (rcEdit.right < rcEdit.left) rcEdit.right = rcEdit.left; rcEdit.top = rcEdit.bottom + fOldClientHeight; rcList.bottom += fOldWindowHeight; break; } if (m_pButton) m_pButton->Move(rcButton, TRUE, FALSE); if (m_pEdit) m_pEdit->Move(rcEdit, TRUE, FALSE); if (m_pList) { m_pList->SetVisible(TRUE); m_pList->Move(rcList, TRUE, FALSE); m_pList->ScrollToListItem(m_nSelectItem); } } else { CPDF_Rect rcButton = rcClient; rcButton.left = rcButton.right - PWL_COMBOBOX_BUTTON_WIDTH; if (rcButton.left < rcClient.left) rcButton.left = rcClient.left; if (m_pButton) m_pButton->Move(rcButton, TRUE, FALSE); CPDF_Rect rcEdit = rcClient; rcEdit.right = rcButton.left - 1.0f; if (rcEdit.left < rcClient.left) rcEdit.left = rcClient.left; if (rcEdit.right < rcEdit.left) rcEdit.right = rcEdit.left; if (m_pEdit) m_pEdit->Move(rcEdit, TRUE, FALSE); if (m_pList) m_pList->SetVisible(FALSE); } }
NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize, const nsHTMLReflowState& aReflowState, nsReflowStatus& aStatus) { DO_GLOBAL_REFLOW_COUNT("nsTableCellFrame", aReflowState.reason); DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus); #if defined DEBUG_TABLE_REFLOW_TIMING nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState); #endif float p2t = aPresContext->ScaledPixelsToTwips(); // work around pixel rounding errors, round down to ensure we don't exceed the avail height in nscoord availHeight = aReflowState.availableHeight; if (NS_UNCONSTRAINEDSIZE != availHeight) { availHeight = nsTableFrame::RoundToPixel(availHeight, p2t, eAlwaysRoundDown); } nsresult rv = NS_OK; // see if a special height reflow needs to occur due to having a pct height if (!NeedSpecialReflow()) nsTableFrame::CheckRequestSpecialHeightReflow(aReflowState); // this should probably be cached somewhere nsCompatibility compatMode = aPresContext->CompatibilityMode(); // Initialize out parameter if (aDesiredSize.mComputeMEW) { aDesiredSize.mMaxElementWidth = 0; } aStatus = NS_FRAME_COMPLETE; nsSize availSize(aReflowState.availableWidth, availHeight); PRBool noBorderBeforeReflow = GetContentEmpty() && GetStyleTableBorder()->mEmptyCells != NS_STYLE_TABLE_EMPTY_CELLS_SHOW; /* XXX: remove tableFrame when border-collapse inherits */ nsTableFrame* tableFrame = nsnull; rv = nsTableFrame::GetTableFrame(this, tableFrame); if (!tableFrame) ABORT1(NS_ERROR_NULL_POINTER); nsMargin borderPadding = aReflowState.mComputedPadding; nsMargin border; GetBorderWidth(p2t, border); if ((NS_UNCONSTRAINEDSIZE == availSize.width) || !noBorderBeforeReflow) { borderPadding += border; } nscoord topInset = borderPadding.top; nscoord rightInset = borderPadding.right; nscoord bottomInset = borderPadding.bottom; nscoord leftInset = borderPadding.left; // reduce available space by insets, if we're in a constrained situation if (NS_UNCONSTRAINEDSIZE!=availSize.width) availSize.width -= leftInset+rightInset; if (NS_UNCONSTRAINEDSIZE!=availSize.height) availSize.height -= topInset+bottomInset; PRBool isStyleChanged = PR_FALSE; if (eReflowReason_Incremental == aReflowState.reason) { // if the path has a reflow command then the cell must be the target of a style change nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand; if (command) { // if there are other reflow commands targeted at the cell's block, these will // be subsumed by the style change reflow nsReflowType type; command->GetType(type); if (eReflowType_StyleChanged == type) { isStyleChanged = PR_TRUE; } else NS_ASSERTION(PR_FALSE, "table cell target of illegal incremental reflow type"); } // else the reflow command will be passed down to the child } // Try to reflow the child into the available space. It might not // fit or might need continuing. if (availSize.height < 0) availSize.height = 1; nsHTMLReflowMetrics kidSize(NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth || aDesiredSize.mComputeMEW, aDesiredSize.mFlags); kidSize.width=kidSize.height=kidSize.ascent=kidSize.descent=0; SetPriorAvailWidth(aReflowState.availableWidth); nsIFrame* firstKid = mFrames.FirstChild(); NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame"); nscoord computedPaginatedHeight = 0; if (aReflowState.mFlags.mSpecialHeightReflow || (HadSpecialReflow() && (eReflowReason_Incremental == aReflowState.reason))) { ((nsHTMLReflowState&)aReflowState).mComputedHeight = mRect.height - topInset - bottomInset; DISPLAY_REFLOW_CHANGE(); } else if (aPresContext->IsPaginated()) { computedPaginatedHeight = CalcUnpaginagedHeight(aPresContext, (nsTableCellFrame&)*this, *tableFrame, topInset + bottomInset); if (computedPaginatedHeight > 0) { ((nsHTMLReflowState&)aReflowState).mComputedHeight = computedPaginatedHeight; DISPLAY_REFLOW_CHANGE(); } } else { SetHasPctOverHeight(PR_FALSE); } // If it was a style change targeted at us, then reflow the child with a style change reason nsReflowReason reason = aReflowState.reason; if (isStyleChanged) { reason = eReflowReason_StyleChange; // the following could be optimized with a fair amount of effort tableFrame->SetNeedStrategyInit(PR_TRUE); } nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid, availSize, reason); // mIPercentHeightObserver is for non table related frames inside cells in quirks mode kidReflowState.mPercentHeightObserver = (eCompatibility_NavQuirks == compatMode) ? (nsIPercentHeightObserver *)this : nsnull; // Assume the inner child will stay positioned exactly where it is. Later in // VerticallyAlignChild() we'll move it if it turns out to be wrong. This // avoids excessive movement and is more stable nsPoint kidOrigin; if (isStyleChanged || (eReflowReason_Initial == aReflowState.reason) || (eReflowReason_StyleChange == aReflowState.reason)) { kidOrigin.MoveTo(leftInset, topInset); } else { // handle percent padding-left which was 0 during initial reflow if (eStyleUnit_Percent == aReflowState.mStylePadding->mPadding.GetLeftUnit()) { nsRect kidRect = firstKid->GetRect(); // only move in the x direction for the same reason as above kidOrigin.MoveTo(leftInset, kidRect.y); firstKid->SetPosition(nsPoint(leftInset, kidRect.y)); } kidOrigin = firstKid->GetPosition(); } #if defined DEBUG_TABLE_REFLOW_TIMING nsTableFrame::DebugReflow(firstKid, (nsHTMLReflowState&)kidReflowState); #endif nscoord priorBlockHeight = GetLastBlockHeight(); ReflowChild(firstKid, aPresContext, kidSize, kidReflowState, kidOrigin.x, kidOrigin.y, 0, aStatus); SetLastBlockHeight(kidSize.height); if (isStyleChanged) { Invalidate(GetOverflowRect(), PR_FALSE); } #if defined DEBUG_TABLE_REFLOW_TIMING nsTableFrame::DebugReflow(firstKid, (nsHTMLReflowState&)kidReflowState, &kidSize, aStatus); #endif #ifdef NS_DEBUG DebugCheckChildSize(firstKid, kidSize, availSize, (NS_UNCONSTRAINEDSIZE != aReflowState.availableWidth)); #endif // 0 dimensioned cells need to be treated specially in Standard/NavQuirks mode // see testcase "emptyCells.html" if ((0 == kidSize.width) || (0 == kidSize.height)) { // XXX why was this && SetContentEmpty(PR_TRUE); if (NS_UNCONSTRAINEDSIZE == kidReflowState.availableWidth && GetStyleTableBorder()->mEmptyCells != NS_STYLE_TABLE_EMPTY_CELLS_SHOW) { // need to reduce the insets by border if the cell is empty leftInset -= border.left; rightInset -= border.right; topInset -= border.top; bottomInset -= border.bottom; } } else { SetContentEmpty(PR_FALSE); if ((eReflowReason_Incremental == aReflowState.reason) && noBorderBeforeReflow) { // need to consider borders, since they were factored out above leftInset += border.left; rightInset += border.right; topInset += border.top; bottomInset += border.bottom; kidOrigin.MoveTo(leftInset, topInset); } } const nsStylePosition* pos = GetStylePosition(); // calculate the min cell width nscoord onePixel = NSIntPixelsToTwips(1, p2t); nscoord smallestMinWidth = 0; if (eCompatibility_NavQuirks == compatMode) { if ((pos->mWidth.GetUnit() != eStyleUnit_Coord) && (pos->mWidth.GetUnit() != eStyleUnit_Percent)) { if (PR_TRUE == GetContentEmpty()) { if (border.left > 0) smallestMinWidth += onePixel; if (border.right > 0) smallestMinWidth += onePixel; } } } PRInt32 colspan = tableFrame->GetEffectiveColSpan(*this); if (colspan > 1) { smallestMinWidth = PR_MAX(smallestMinWidth, colspan * onePixel); nscoord spacingX = tableFrame->GetCellSpacingX(); nscoord spacingExtra = spacingX * (colspan - 1); smallestMinWidth += spacingExtra; if (aReflowState.mComputedPadding.left > 0) { smallestMinWidth -= onePixel; } } if ((0 == kidSize.width) && (NS_UNCONSTRAINEDSIZE != kidReflowState.availableWidth)) { // empty content has to be forced to the assigned width for resize or incremental reflow kidSize.width = kidReflowState.availableWidth; } if (0 == kidSize.height) { if ((pos->mHeight.GetUnit() != eStyleUnit_Coord) && (pos->mHeight.GetUnit() != eStyleUnit_Percent)) { PRInt32 pixHeight = (eCompatibility_NavQuirks == compatMode) ? 1 : 0; kidSize.height = NSIntPixelsToTwips(pixHeight, p2t); } } // end 0 dimensioned cells kidSize.width = PR_MAX(kidSize.width, smallestMinWidth); if (!tableFrame->IsAutoLayout()) { // a cell in a fixed layout table is constrained to the avail width // if we need to shorten the cell the previous non overflowing block // will get some overflow area if (kidSize.width > availSize.width) { kidSize.width = availSize.width; firstKid->FinishAndStoreOverflow(&kidSize); } } //if (eReflowReason_Resize == aReflowState.reason) { // NS_ASSERTION(kidSize.width <= availSize.width, "child needed more space during resize reflow"); //} // Place the child FinishReflowChild(firstKid, aPresContext, &kidReflowState, kidSize, kidOrigin.x, kidOrigin.y, 0); // first, compute the height which can be set w/o being restricted by aMaxSize.height nscoord cellHeight = kidSize.height; if (NS_UNCONSTRAINEDSIZE != cellHeight) { cellHeight += topInset + bottomInset; // work around block rounding errors, round down to ensure we don't exceed the avail height in nsPixelRound roundMethod = (NS_UNCONSTRAINEDSIZE == availHeight) ? eAlwaysRoundUp : eAlwaysRoundDown; cellHeight = nsTableFrame::RoundToPixel(cellHeight, p2t, roundMethod); } // next determine the cell's width nscoord cellWidth = kidSize.width; // at this point, we've factored in the cell's style attributes // factor in border and padding if (NS_UNCONSTRAINEDSIZE != cellWidth) { cellWidth += leftInset + rightInset; } cellWidth = nsTableFrame::RoundToPixel(cellWidth, p2t); // work around block rounding errors // set the cell's desired size and max element size aDesiredSize.width = cellWidth; aDesiredSize.height = cellHeight; aDesiredSize.ascent = topInset; aDesiredSize.descent = bottomInset; aDesiredSize.ascent += kidSize.ascent; aDesiredSize.descent += kidSize.descent; // the overflow area will be computed when the child will be vertically aligned if (aDesiredSize.mComputeMEW) { aDesiredSize.mMaxElementWidth = PR_MAX(smallestMinWidth, kidSize.mMaxElementWidth); if (NS_UNCONSTRAINEDSIZE != aDesiredSize.mMaxElementWidth) { aDesiredSize.mMaxElementWidth = nsTableFrame::RoundToPixel( aDesiredSize.mMaxElementWidth + leftInset + rightInset, p2t); } } if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) { aDesiredSize.mMaximumWidth = kidSize.mMaximumWidth; if (NS_UNCONSTRAINEDSIZE != aDesiredSize.mMaximumWidth) { aDesiredSize.mMaximumWidth += leftInset + rightInset; aDesiredSize.mMaximumWidth = nsTableFrame::RoundToPixel(aDesiredSize.mMaximumWidth, p2t); } // make sure the preferred width is at least as big as the max element width if (aDesiredSize.mComputeMEW) { aDesiredSize.mMaximumWidth = PR_MAX(aDesiredSize.mMaximumWidth, aDesiredSize.mMaxElementWidth); } } if (aReflowState.mFlags.mSpecialHeightReflow) { if (aDesiredSize.height > mRect.height) { // set a bit indicating that the pct height contents exceeded // the height that they could honor in the pass 2 reflow SetHasPctOverHeight(PR_TRUE); } if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) { aDesiredSize.height = mRect.height; } SetNeedSpecialReflow(PR_FALSE); SetHadSpecialReflow(PR_TRUE); } else if (HadSpecialReflow()) { if (eReflowReason_Incremental == aReflowState.reason) { // with an unconstrained height, if the block height value hasn't changed, // use the last height of the cell. if ((NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) && (GetLastBlockHeight() == priorBlockHeight)) { aDesiredSize.height = mRect.height; } } // XXX should probably call SetHadSpecialReflow(PR_FALSE) when things change so that // nothing inside the cell has a percent height, but it is not easy determining this } // remember the desired size for this reflow SetDesiredSize(aDesiredSize); #if defined DEBUG_TABLE_REFLOW_TIMING nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState, &aDesiredSize, aStatus); #endif if (NS_UNCONSTRAINEDSIZE == aReflowState.availableWidth) { SetNeedPass2Reflow(PR_TRUE); } else if ((eReflowReason_Initial == aReflowState.reason) || (eReflowReason_Resize == aReflowState.reason)) { SetNeedPass2Reflow(PR_FALSE); } NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize); return NS_OK; }
//----------------------------------------------------------------------------- double LineProfileCanvas::GetScaleY( wxCoord h ) const //----------------------------------------------------------------------------- { int diagramHeight = h - ( 2 * GetBorderWidth() ); return static_cast<double>( diagramHeight ) / ( static_cast<double>( m_valCount ) * static_cast<double>( GetPercentageToDraw() ) / 100. ); }
void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { CPWL_Wnd::GetThisAppearanceStream(sAppStream); CPDF_Rect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); if (nCharArray > 0) { switch (GetBorderStyle()) { case PBS_SOLID: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) << " 2 J 0 j\n"; for (int32_t i = 1; i < nCharArray; i++) { sLine << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.bottom << " m\n" << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.top << " l S\n"; } sLine << "Q\n"; } break; case PBS_DASH: { sLine << "q\n" << GetBorderWidth() << " w\n" << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) << " 2 J 0 j\n" << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap << "] " << GetBorderDash().nPhase << " d\n"; for (int32_t i = 1; i < nCharArray; i++) { sLine << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.bottom << " m\n" << rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * i << " " << rcClient.top << " l S\n"; } sLine << "Q\n"; } break; } } sAppStream << sLine; CFX_ByteTextBuf sText; CPDF_Point ptOffset = CPDF_Point(0.0f, 0.0f); CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); CPVT_WordRange wrSelect = GetSelectWordRange(); CPVT_WordRange wrVisible = (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); CPVT_WordRange wrTemp = CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); CFX_ByteString sEditSel = CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); if (sEditSel.GetLength() > 0) sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) << sEditSel; wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar()); if (sEditBefore.GetLength() > 0) sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditBefore << "ET\n"; wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar()); if (sEditMid.GetLength() > 0) sText << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) << sEditMid << "ET\n"; wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar()); if (sEditAfter.GetLength() > 0) sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditAfter << "ET\n"; if (HasFlag(PES_SPELLCHECK)) { CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream( m_pEdit, m_pSpellCheck, ptOffset, &wrVisible); if (sSpellCheck.GetLength() > 0) sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB, 1, 0, 0), FALSE) << sSpellCheck; } if (sText.GetLength() > 0) { CPDF_Rect rcClient = GetClientRect(); sAppStream << "q\n/Tx BMC\n"; if (!HasFlag(PES_TEXTOVERFLOW)) sAppStream << rcClient.left << " " << rcClient.bottom << " " << rcClient.right - rcClient.left << " " << rcClient.top - rcClient.bottom << " re W n\n"; sAppStream << sText; sAppStream << "EMC\nQ\n"; } }
void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); CPDF_Rect rcClient = GetClientRect(); CFX_ByteTextBuf sLine; int32_t nCharArray = m_pEdit->GetCharArray(); FX_SAFE_INT32 nCharArraySafe = nCharArray; nCharArraySafe -= 1; nCharArraySafe *= 2; if (nCharArray > 0 && nCharArraySafe.IsValid()) { switch (GetBorderStyle()) { case PBS_SOLID: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); CFX_PathData path; path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { path.SetPoint( i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_MOVETO); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } if (path.GetPointCount() > 0) pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); } break; case PBS_DASH: { CFX_GraphStateData gsd; gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); gsd.SetDashCount(2); gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; CFX_PathData path; path.SetPointCount(nCharArraySafe.ValueOrDie()); for (int32_t i = 0; i < nCharArray - 1; i++) { path.SetPoint( i * 2, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.bottom, FXPT_MOVETO); path.SetPoint( i * 2 + 1, rcClient.left + ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), rcClient.top, FXPT_LINETO); } if (path.GetPointCount() > 0) pDevice->DrawPath( &path, pUser2Device, &gsd, 0, CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), FXFILL_ALTERNATE); } break; } } CPDF_Rect rcClip; CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); CPVT_WordRange* pRange = NULL; if (!HasFlag(PES_TEXTOVERFLOW)) { rcClip = GetClientRect(); pRange = &wrRange; } IFX_SystemHandler* pSysHandler = GetSystemHandler(); IFX_Edit::DrawEdit( pDevice, pUser2Device, m_pEdit, CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), rcClip, CPDF_Point(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); if (HasFlag(PES_SPELLCHECK)) { CPWL_Utils::DrawEditSpellCheck(pDevice, pUser2Device, m_pEdit, rcClip, CPDF_Point(0.0f, 0.0f), pRange, GetCreationParam().pSpellCheck); } }
int wxSystemSettingsNative::GetMetric( wxSystemMetric index, wxWindow* win ) { GdkWindow *window = NULL; if (win) window = gtk_widget_get_window(win->GetHandle()); switch (index) { case wxSYS_BORDER_X: case wxSYS_BORDER_Y: case wxSYS_EDGE_X: case wxSYS_EDGE_Y: case wxSYS_FRAMESIZE_X: case wxSYS_FRAMESIZE_Y: if (win) { wxTopLevelWindow *tlw = wxDynamicCast(win, wxTopLevelWindow); if (!tlw) return GetBorderWidth(index, win); else if (window) { // Get the frame extents from the windowmanager. // In most cases the top extent is the titlebar, so we use the bottom extent // for the heights. int right, bottom; if (wxGetFrameExtents(window, NULL, &right, NULL, &bottom)) { switch (index) { case wxSYS_BORDER_X: case wxSYS_EDGE_X: case wxSYS_FRAMESIZE_X: return right; // width of right extent default: return bottom; // height of bottom extent } } } } return -1; // no window specified case wxSYS_CURSOR_X: case wxSYS_CURSOR_Y: return gdk_display_get_default_cursor_size( window ? gdk_window_get_display(window) : gdk_display_get_default()); case wxSYS_DCLICK_X: case wxSYS_DCLICK_Y: gint dclick_distance; g_object_get(GetSettingsForWindowScreen(window), "gtk-double-click-distance", &dclick_distance, NULL); return dclick_distance * 2; case wxSYS_DCLICK_MSEC: gint dclick; g_object_get(GetSettingsForWindowScreen(window), "gtk-double-click-time", &dclick, NULL); return dclick; case wxSYS_DRAG_X: case wxSYS_DRAG_Y: gint drag_threshold; g_object_get(GetSettingsForWindowScreen(window), "gtk-dnd-drag-threshold", &drag_threshold, NULL); // The correct thing here would be to double the value // since that is what the API wants. But the values // are much bigger under GNOME than under Windows and // just seem to much in many cases to be useful. // drag_threshold *= 2; return drag_threshold; case wxSYS_ICON_X: case wxSYS_ICON_Y: return 32; case wxSYS_SCREEN_X: if (window) return gdk_screen_get_width(gdk_window_get_screen(window)); else return gdk_screen_width(); case wxSYS_SCREEN_Y: if (window) return gdk_screen_get_height(gdk_window_get_screen(window)); else return gdk_screen_height(); case wxSYS_HSCROLL_Y: case wxSYS_VSCROLL_X: return 15; case wxSYS_CAPTION_Y: if (!window) // No realized window specified, and no implementation for that case yet. return -1; wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow), wxT("Asking for caption height of a non toplevel window") ); // Get the height of the top windowmanager border. // This is the titlebar in most cases. The titlebar might be elsewhere, and // we could check which is the thickest wm border to decide on which side the // titlebar is, but this might lead to interesting behaviours in used code. // Reconsider when we have a way to report to the user on which side it is. { int top; if (wxGetFrameExtents(window, NULL, NULL, &top, NULL)) { return top; // top frame extent } } // Try a default approach without a window pointer, if possible // ... return -1; case wxSYS_PENWINDOWS_PRESENT: // No MS Windows for Pen computing extension available in X11 based gtk+. return 0; default: return -1; // metric is unknown } }
void CheckBoxObject::UpdateProperties() { //Update BackgroundColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId(), "BackgroundColor", backgroundColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "BackgroundColor", backgroundColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "BackgroundColor", backgroundColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "BackgroundColor", backgroundColor->disabledColor ); //Update BorderColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId(), "BorderColor", borderColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "BorderColor", borderColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "BorderColor", borderColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "BorderColor", borderColor->disabledColor ); //Update TextColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + "", "Color", textColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "Color", textColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "Color", textColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "Color", textColor->disabledColor ); //Update CheckColor sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + "", "CheckColor", checkColor->unfocusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":PRELIGHT", "CheckColor", checkColor->hoveredColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":ACTIVE", "CheckColor", checkColor->focusedColor ); sfg::Context::Get().GetEngine().SetProperty<sf::Color>( "CheckButton#" + obj->GetId() + ":INSENSITIVE", "CheckColor", checkColor->disabledColor ); //Update font size sfg::Context::Get().GetEngine().SetProperty<unsigned int>("CheckButton#" + obj->GetId() + "", "FontSize", GetCharacterSize()); sfg::Context::Get().GetEngine().SetProperty<std::string>("CheckButton#" + obj->GetId(), "FontName", std::string("gdres:") + GetFont()); //Update border width and padding sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "BorderWidth", static_cast<float>(GetBorderWidth())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "Padding", static_cast<float>(GetPadding())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "BoxSize", static_cast<float>(GetBoxSize())); sfg::Context::Get().GetEngine().SetProperty<float>("CheckButton#" + obj->GetId(), "CheckSize", static_cast<float>(GetCheckSignSize())); }