Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / MS / Internal / Text / LineMetrics.cs / 1 / LineMetrics.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // File: LineMetrics.cs // // Description: Cached metrics of a text line. // // History: // 04/25/2003 : grzegorz - moving from Avalon branch. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Media; using System.Windows.Media.TextFormatting; namespace MS.Internal.Text { // --------------------------------------------------------------------- // Storage for metrics of a formatted line. // --------------------------------------------------------------------- internal struct LineMetrics { // ------------------------------------------------------------------ // Constructor. // // wrappingWidth - wrapping width for the line // length - number or characters in the line // width - width of the line // height - height of the line // baseline - baseline of the line // hasInlineObjects - has inline objects? // ----------------------------------------------------------------- internal LineMetrics( #if DEBUG double wrappingWidth, #endif int length, double width, double height, double baseline, bool hasInlineObjects, TextLineBreak textLineBreak) { #if DEBUG _wrappingWidth = wrappingWidth; #endif _start = 0; _width = width; _height = height; _baseline = baseline; _textLineBreak = textLineBreak; _packedData = ((uint) length & LengthMask) | (hasInlineObjects ? HasInlineObjectsMask : 0); } internal LineMetrics(LineMetrics source, double start, double width) { #if DEBUG _wrappingWidth = source.WrappingWidth; #endif _start = start; _width = width; _height = source.Height; _baseline = source.Baseline; _textLineBreak = source.TextLineBreak; _packedData = source._packedData | HasBeenUpdatedMask; } ////// Disposes linebreak object /// internal LineMetrics Dispose(bool returnUpdatedMetrics) { if(_textLineBreak != null) { _textLineBreak.Dispose(); if (returnUpdatedMetrics) { return new LineMetrics( #if DEBUG _wrappingWidth, #endif Length, _width, _height, _baseline, HasInlineObjects, null); } } return this; } #if DEBUG // ------------------------------------------------------------------ // Wrapping width for the line. // ------------------------------------------------------------------ internal double WrappingWidth { get { return _wrappingWidth; } } private double _wrappingWidth; #endif // ----------------------------------------------------------------- // Number or characters in the line. // ------------------------------------------------------------------ internal int Length { get { return (int) (_packedData & LengthMask); } } private uint _packedData; // ----------------------------------------------------------------- // Width of the line. // ----------------------------------------------------------------- internal double Width { get { Debug.Assert((_packedData & HasBeenUpdatedMask) != 0); return _width; } } private double _width; // ----------------------------------------------------------------- // Height of the line. // ------------------------------------------------------------------ internal double Height { get { return _height; } } private double _height; // ----------------------------------------------------------------- // Start of the line. Distance from paragraph edge to line start. // ------------------------------------------------------------------ internal double Start { get { Debug.Assert((_packedData & HasBeenUpdatedMask) != 0); return _start; } } private double _start; // ------------------------------------------------------------------ // Baseline offset of the line. // ----------------------------------------------------------------- internal double Baseline { get { return _baseline; } } private double _baseline; // ------------------------------------------------------------------ // Has inline objects? // ----------------------------------------------------------------- internal bool HasInlineObjects { get { return (_packedData & HasInlineObjectsMask) != 0; } } // ----------------------------------------------------------------- // Line break for formatting. (Line Break In) // ----------------------------------------------------------------- internal TextLineBreak TextLineBreak { get { return _textLineBreak; } } private TextLineBreak _textLineBreak; private static readonly uint HasBeenUpdatedMask = 0x40000000; private static readonly uint LengthMask = 0x3FFFFFFF; private static readonly uint HasInlineObjectsMask = 0x80000000; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // // File: LineMetrics.cs // // Description: Cached metrics of a text line. // // History: // 04/25/2003 : grzegorz - moving from Avalon branch. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Media; using System.Windows.Media.TextFormatting; namespace MS.Internal.Text { // --------------------------------------------------------------------- // Storage for metrics of a formatted line. // --------------------------------------------------------------------- internal struct LineMetrics { // ------------------------------------------------------------------ // Constructor. // // wrappingWidth - wrapping width for the line // length - number or characters in the line // width - width of the line // height - height of the line // baseline - baseline of the line // hasInlineObjects - has inline objects? // ----------------------------------------------------------------- internal LineMetrics( #if DEBUG double wrappingWidth, #endif int length, double width, double height, double baseline, bool hasInlineObjects, TextLineBreak textLineBreak) { #if DEBUG _wrappingWidth = wrappingWidth; #endif _start = 0; _width = width; _height = height; _baseline = baseline; _textLineBreak = textLineBreak; _packedData = ((uint) length & LengthMask) | (hasInlineObjects ? HasInlineObjectsMask : 0); } internal LineMetrics(LineMetrics source, double start, double width) { #if DEBUG _wrappingWidth = source.WrappingWidth; #endif _start = start; _width = width; _height = source.Height; _baseline = source.Baseline; _textLineBreak = source.TextLineBreak; _packedData = source._packedData | HasBeenUpdatedMask; } ////// Disposes linebreak object /// internal LineMetrics Dispose(bool returnUpdatedMetrics) { if(_textLineBreak != null) { _textLineBreak.Dispose(); if (returnUpdatedMetrics) { return new LineMetrics( #if DEBUG _wrappingWidth, #endif Length, _width, _height, _baseline, HasInlineObjects, null); } } return this; } #if DEBUG // ------------------------------------------------------------------ // Wrapping width for the line. // ------------------------------------------------------------------ internal double WrappingWidth { get { return _wrappingWidth; } } private double _wrappingWidth; #endif // ----------------------------------------------------------------- // Number or characters in the line. // ------------------------------------------------------------------ internal int Length { get { return (int) (_packedData & LengthMask); } } private uint _packedData; // ----------------------------------------------------------------- // Width of the line. // ----------------------------------------------------------------- internal double Width { get { Debug.Assert((_packedData & HasBeenUpdatedMask) != 0); return _width; } } private double _width; // ----------------------------------------------------------------- // Height of the line. // ------------------------------------------------------------------ internal double Height { get { return _height; } } private double _height; // ----------------------------------------------------------------- // Start of the line. Distance from paragraph edge to line start. // ------------------------------------------------------------------ internal double Start { get { Debug.Assert((_packedData & HasBeenUpdatedMask) != 0); return _start; } } private double _start; // ------------------------------------------------------------------ // Baseline offset of the line. // ----------------------------------------------------------------- internal double Baseline { get { return _baseline; } } private double _baseline; // ------------------------------------------------------------------ // Has inline objects? // ----------------------------------------------------------------- internal bool HasInlineObjects { get { return (_packedData & HasInlineObjectsMask) != 0; } } // ----------------------------------------------------------------- // Line break for formatting. (Line Break In) // ----------------------------------------------------------------- internal TextLineBreak TextLineBreak { get { return _textLineBreak; } } private TextLineBreak _textLineBreak; private static readonly uint HasBeenUpdatedMask = 0x40000000; private static readonly uint LengthMask = 0x3FFFFFFF; private static readonly uint HasInlineObjectsMask = 0x80000000; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpDictionary.cs
- SemanticBasicElement.cs
- MeasurementDCInfo.cs
- ProgressBar.cs
- FixedPageStructure.cs
- Table.cs
- LocatorBase.cs
- BooleanExpr.cs
- Win32PrintDialog.cs
- UrlMappingsSection.cs
- XmlIgnoreAttribute.cs
- Attributes.cs
- HttpRuntimeSection.cs
- VectorCollectionConverter.cs
- LinearGradientBrush.cs
- StringExpressionSet.cs
- HttpDictionary.cs
- ConnectionPointGlyph.cs
- WebPartZoneCollection.cs
- ExpressionVisitor.cs
- ExceptionValidationRule.cs
- SvcMapFileLoader.cs
- DbException.cs
- MdiWindowListItemConverter.cs
- TypeSystem.cs
- ToolStripPanel.cs
- RelationshipNavigation.cs
- FontDifferentiator.cs
- Stack.cs
- MailMessage.cs
- XmlSerializationGeneratedCode.cs
- SubpageParaClient.cs
- ApplicationSettingsBase.cs
- MaskPropertyEditor.cs
- StatusBarPanel.cs
- ZoomPercentageConverter.cs
- Pointer.cs
- InterleavedZipPartStream.cs
- MissingSatelliteAssemblyException.cs
- ReadOnlyCollectionBase.cs
- Style.cs
- MobileControlDesigner.cs
- CompilerErrorCollection.cs
- QilXmlWriter.cs
- WizardStepBase.cs
- KeyToListMap.cs
- InputMethodStateChangeEventArgs.cs
- WindowPattern.cs
- CustomLineCap.cs
- TrustManager.cs
- TextBoxLine.cs
- SqlProvider.cs
- TypeBuilder.cs
- WebScriptEnablingElement.cs
- TouchesCapturedWithinProperty.cs
- HttpCacheVaryByContentEncodings.cs
- RectAnimationBase.cs
- _ShellExpression.cs
- Validator.cs
- SerializableAttribute.cs
- DependencyPropertyConverter.cs
- CapabilitiesRule.cs
- ManagedWndProcTracker.cs
- XmlDataSourceNodeDescriptor.cs
- ItemsControl.cs
- HttpCookie.cs
- AndMessageFilterTable.cs
- OleDbPermission.cs
- WindowsTitleBar.cs
- GroupBoxRenderer.cs
- DocumentXmlWriter.cs
- WebExceptionStatus.cs
- ButtonBaseAutomationPeer.cs
- FillErrorEventArgs.cs
- GregorianCalendarHelper.cs
- CountAggregationOperator.cs
- httpapplicationstate.cs
- CodeEventReferenceExpression.cs
- Overlapped.cs
- RegexFCD.cs
- RelationshipFixer.cs
- DataPagerFieldCollection.cs
- GridEntry.cs
- ASCIIEncoding.cs
- FillRuleValidation.cs
- LoadWorkflowAsyncResult.cs
- ViewPort3D.cs
- ErrorEventArgs.cs
- ImageFormatConverter.cs
- DragDrop.cs
- OleDbParameterCollection.cs
- ObjectItemLoadingSessionData.cs
- DecoderFallback.cs
- GridView.cs
- NullableLongSumAggregationOperator.cs
- RoutedCommand.cs
- EventTrigger.cs
- MachineKeyValidationConverter.cs
- RootDesignerSerializerAttribute.cs
- WebPartDisplayModeCancelEventArgs.cs