Class: Emfsvg::DeviceContext

Inherits:
Object
  • Object
show all
Defined in:
lib/emfsvg/device_context.rb

Overview

Snapshot of GDI drawing state. Pushed onto TransformStack on SaveDC, popped on RestoreDC.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDeviceContext

Returns a new instance of DeviceContext.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/emfsvg/device_context.rb', line 32

def initialize
  @pen = Pen.default
  @brush = Brush.default
  @font = Font.default
  @text_color = Emf::Model::Geometry::Color.black
  @bk_color = Emf::Model::Geometry::Color.white
  @bk_mode = 1 # TRANSPARENT
  @poly_fill_mode = 1 # ALTERNATE (evenodd)
  @text_align = 0
  @stretch_mode = 1
  @miter_limit = 10.0
  @world_transform = Emf::Model::Geometry::Matrix.identity
  @brush_origin = [0, 0]
  @icm_mode = 0
  @layout = 0
  @mapper_flags = 0
  @arc_direction = 0 # default; set by SetArcDirection (1=CW, -1=CCW in C)
  @clip_region = nil
  @clip_id = nil
  # Coordinate state shared across all dup'd DCs (see CoordinateState).
  @coordinate_state = CoordinateState.new
end

Instance Attribute Details

#arc_directionObject

Returns the value of attribute arc_direction.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def arc_direction
  @arc_direction
end

#bk_colorObject

Returns the value of attribute bk_color.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def bk_color
  @bk_color
end

#bk_modeObject

Returns the value of attribute bk_mode.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def bk_mode
  @bk_mode
end

#brushObject

Returns the value of attribute brush.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def brush
  @brush
end

#brush_originObject

Returns the value of attribute brush_origin.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def brush_origin
  @brush_origin
end

#clip_idObject

Returns the value of attribute clip_id.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def clip_id
  @clip_id
end

#clip_regionObject

Returns the value of attribute clip_region.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def clip_region
  @clip_region
end

#coordinate_stateObject

Returns the value of attribute coordinate_state.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def coordinate_state
  @coordinate_state
end

#fontObject

Returns the value of attribute font.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def font
  @font
end

#icm_modeObject

Returns the value of attribute icm_mode.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def icm_mode
  @icm_mode
end

#layoutObject

Returns the value of attribute layout.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def layout
  @layout
end

#mapper_flagsObject

Returns the value of attribute mapper_flags.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def mapper_flags
  @mapper_flags
end

#miter_limitObject

Returns the value of attribute miter_limit.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def miter_limit
  @miter_limit
end

#penObject

Returns the value of attribute pen.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def pen
  @pen
end

#poly_fill_modeObject

Returns the value of attribute poly_fill_mode.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def poly_fill_mode
  @poly_fill_mode
end

#stretch_modeObject

Returns the value of attribute stretch_mode.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def stretch_mode
  @stretch_mode
end

#text_alignObject

Returns the value of attribute text_align.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def text_align
  @text_align
end

#text_colorObject

Returns the value of attribute text_color.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def text_color
  @text_color
end

#world_transformObject

Returns the value of attribute world_transform.



55
56
57
# File 'lib/emfsvg/device_context.rb', line 55

def world_transform
  @world_transform
end

Instance Method Details

#dupObject



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/emfsvg/device_context.rb', line 114

def dup
  other = DeviceContext.allocate
  other.pen = pen.dup
  other.brush = brush.dup
  other.font = font.dup
  other.text_color = text_color
  other.bk_color = bk_color
  other.bk_mode = bk_mode
  other.poly_fill_mode = poly_fill_mode
  other.text_align = text_align
  other.stretch_mode = stretch_mode
  other.miter_limit = miter_limit
  other.world_transform = world_transform
  other.brush_origin = brush_origin.dup
  other.icm_mode = icm_mode
  other.layout = layout
  other.mapper_flags = mapper_flags
  other.arc_direction = arc_direction
  other.clip_region = clip_region
  other.clip_id = clip_id
  # CoordinateState is shared by reference — SaveDC/RestoreDC must
  # not snapshot/restore the coordinate state per libemf2svg.
  other.coordinate_state = coordinate_state
  other
end

#map_modeObject



58
59
60
# File 'lib/emfsvg/device_context.rb', line 58

def map_mode
  coordinate_state.map_mode
end

#map_mode=(value) ⇒ Object



62
63
64
# File 'lib/emfsvg/device_context.rb', line 62

def map_mode=(value)
  coordinate_state.map_mode = value
end

#viewport_extObject



74
75
76
# File 'lib/emfsvg/device_context.rb', line 74

def viewport_ext
  coordinate_state.viewport_ext
end

#viewport_ext=(value) ⇒ Object



78
79
80
# File 'lib/emfsvg/device_context.rb', line 78

def viewport_ext=(value)
  coordinate_state.viewport_ext = value
end

#viewport_ext_set=(value) ⇒ Object



110
111
112
# File 'lib/emfsvg/device_context.rb', line 110

def viewport_ext_set=(value)
  coordinate_state.viewport_ext_set = value
end

#viewport_ext_set?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/emfsvg/device_context.rb', line 102

def viewport_ext_set?
  coordinate_state.viewport_ext_set
end

#viewport_orgObject



90
91
92
# File 'lib/emfsvg/device_context.rb', line 90

def viewport_org
  coordinate_state.viewport_org
end

#viewport_org=(value) ⇒ Object



94
95
96
# File 'lib/emfsvg/device_context.rb', line 94

def viewport_org=(value)
  coordinate_state.viewport_org = value
end

#window_extObject



66
67
68
# File 'lib/emfsvg/device_context.rb', line 66

def window_ext
  coordinate_state.window_ext
end

#window_ext=(value) ⇒ Object



70
71
72
# File 'lib/emfsvg/device_context.rb', line 70

def window_ext=(value)
  coordinate_state.window_ext = value
end

#window_ext_set=(value) ⇒ Object



106
107
108
# File 'lib/emfsvg/device_context.rb', line 106

def window_ext_set=(value)
  coordinate_state.window_ext_set = value
end

#window_ext_set?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/emfsvg/device_context.rb', line 98

def window_ext_set?
  coordinate_state.window_ext_set
end

#window_orgObject



82
83
84
# File 'lib/emfsvg/device_context.rb', line 82

def window_org
  coordinate_state.window_org
end

#window_org=(value) ⇒ Object



86
87
88
# File 'lib/emfsvg/device_context.rb', line 86

def window_org=(value)
  coordinate_state.window_org = value
end