Class: Wx::SF::EditTextShape
- Defined in:
- lib/wx/shapes/shapes/edit_text_shape.rb
Overview
Class encapsulating the editable text shape. It extends the basic text shape.
Defined Under Namespace
Modules: DEFAULT Classes: EDITTYPE
Instance Attribute Summary collapse
-
#force_multiline ⇒ Object
readonly
Returns the value of attribute force_multiline.
Instance Method Summary collapse
-
#_on_canvas(change, *_args) ⇒ Boolean?
protected
Event handler called by ShapeCanvas to request,report canvas changes.
-
#edit_label ⇒ Object
Switch the shape to a label editing mode.
-
#get_edit_type ⇒ EDITTYPE
(also: #edit_type)
Get current type of text shape’s edit control.
-
#get_text_ctrl ⇒ ContentCtrl
(also: #text_ctrl)
Instance of wxSFContentCtrl class.
-
#initialize(pos = Shape::DEFAULT::POSITION, txt = TextShape::DEFAULT::TEXT, diagram: nil) ⇒ EditTextShape
constructor
Constructor.
- #on_key(key) ⇒ Object
- #on_left_double_click(pos) ⇒ Object
-
#set_edit_type(type) ⇒ Object
(also: #edit_type=)
Set way how the text shape’s content can be edited.
- #set_force_multiline(multiline) ⇒ Object (also: #force_multiline=)
Methods inherited from TextShape
#deserialize_finalize, #do_on_handle, #draw_highlighted, #draw_hover, #draw_normal, #draw_shadow, #draw_text_content, #get_border, #get_fill, #get_font, #get_text, #get_text_colour, #get_text_extent, #on_bottom_handle, #on_left_handle, #on_right_handle, #on_top_handle, #scale_rectangle, #serialize_text_colour, #serialize_text_font, #set_font, #set_text, #set_text_colour, #update, #update_rect_size
Methods inherited from RectShape
#create_handles, #do_begin_handle, #do_on_handle, #draw_highlighted, #draw_hover, #draw_normal, #draw_shadow, #fit_to_children, #get_border, #get_border_point, #get_bounding_box, #get_fill, #get_rect_size, #on_begin_handle, #on_bottom_handle, #on_handle, #on_left_handle, #on_right_handle, #on_top_handle, #scale, #scale_rectangle, #set_border, #set_fill, #set_rect_size
Methods inherited from Shape
#accept_child, #accept_connection, #accept_currently_dragged_shapes, #accept_src_neighbour, #accept_trg_neighbour, #activate, #active?, #add_child_shape, #add_connection_point, #add_handle, #add_style, #ancestor?, #clear_accepted_childs, #clear_accepted_connections, #clear_accepted_src_neighbours, #clear_accepted_trg_neighbours, component, component_shapes, #contains?, #contains_style, #create_handles, #descendant?, #do_alignment, #does_not_accept_children?, #draw, #draw_highlighted, #draw_hover, #draw_normal, #draw_selected, #draw_shadow, #fit_to_children, #get_absolute_position, #get_accepted_children, #get_accepted_connections, #get_accepted_src_neighbours, #get_accepted_trg_neighbours, #get_assigned_connections, #get_border_point, #get_bounding_box, #get_center, #get_child_shapes, #get_children, #get_children_recursively, #get_complete_bounding_box, #get_connection_point, #get_connection_points, #get_custom_dock_point, #get_diagram, #get_grand_parent_shape, #get_h_align, #get_h_border, #get_handle, #get_handles, #get_hover_colour, #get_nearest_connection_point, #get_neighbours, #get_parent_absolute_position, #get_parent_canvas, #get_parent_shape, #get_relative_position, #get_shape_canvas, #get_style, #get_user_data, #get_v_align, #get_v_border, #has_children, #has_selected_parent?, #include_child_shape?, #inside?, #inspect, #intersects?, #is_child_accepted, #is_connection_accepted, #is_managed, #is_manager, #is_src_neighbour_accepted, #is_trg_neighbour_accepted, lines_intersection, #lines_intersection, #move_by, #move_to, #on_begin_drag, #on_begin_handle, #on_child_dropped, #on_dragging, #on_end_drag, #on_end_handle, #on_handle, #on_import, #on_left_click, #on_mouse_enter, #on_mouse_leave, #on_mouse_over, #on_right_click, #on_right_double_click, #refresh, #refresh_rect, #remove_connection_point, #remove_handle, #remove_style, #scale, #scale_children, #select, #selected?, #set_custom_dock_point, #set_diagram, #set_h_align, #set_h_border, #set_hover_colour, #set_parent_shape, #set_relative_position, #set_style, #set_user_data, #set_v_align, #set_v_border, #show, #show_handles, #to_s, #update, #visible?
Constructor Details
#initialize(pos = Shape::DEFAULT::POSITION, txt = TextShape::DEFAULT::TEXT, diagram: nil) ⇒ EditTextShape
Constructor.
175 176 177 178 179 180 181 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 175 def initialize(pos = Shape::DEFAULT::POSITION, txt = TextShape::DEFAULT::TEXT, diagram: nil) super @text_ctrl = nil @force_multiline = DEFAULT::FORCE_MULTILINE @edit_type = DEFAULT::EDIT_TYPE @current_state = 0 end |
Instance Attribute Details
#force_multiline ⇒ Object (readonly)
Returns the value of attribute force_multiline.
183 184 185 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 183 def force_multiline @force_multiline end |
Instance Method Details
#_on_canvas(change, *_args) ⇒ Boolean? (protected)
Event handler called by ShapeCanvas to request,report canvas changes.
296 297 298 299 300 301 302 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 296 def _on_canvas(change, *_args) if change == ShapeCanvas::CHANGE::FOCUS text_ctrl = get_text_ctrl text_ctrl.quit(APPLY_TEXT_CHANGES) if text_ctrl end super end |
#edit_label ⇒ Object
Switch the shape to a label editing mode.
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 215 def edit_label if get_parent_canvas shp_pos = get_absolute_position scale = get_parent_canvas.get_scale dx, dy = get_parent_canvas.calc_unscrolled_position(0, 0) case @edit_type when EDITTYPE::INPLACE shp_bb = get_bounding_box style = 0 style = Wx::TE_MULTILINE if @force_multiline || @text.index("\n") # set minimal control size shp_bb.set_width(50) if @text == '' || (style == Wx::TE_MULTILINE && shp_bb.width < 50) @current_state = get_style remove_style(STYLE::SIZE_CHANGE) @text_ctrl = ContentCtrl.new(get_parent_canvas, Wx::ID_ANY, self, @text, [((shp_pos.x * scale) - dx).to_i, ((shp_pos.y * scale) - dy).to_i], [(shp_bb.width * scale).to_i, (shp_bb.height * scale).to_i], style) when EDITTYPE::DIALOG prev_text = get_text DetachedContentCtrl(get_parent_canvas) do |text_dlg| text_dlg.set_content(prev_text) if text_dlg.show_modal == Wx::ID_OK if text_dlg.get_content != prev_text set_text(text_dlg.get_content) get_parent_canvas.on_text_change(self) get_parent_canvas.save_canvas_state update get_parent_canvas.refresh(false) end end end end end end |
#get_edit_type ⇒ EDITTYPE Also known as: edit_type
Get current type of text shape’s edit control.
196 197 198 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 196 def get_edit_type @edit_type end |
#get_text_ctrl ⇒ ContentCtrl Also known as: text_ctrl
Returns instance of wxSFContentCtrl class.
204 205 206 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 204 def get_text_ctrl @text_ctrl end |
#on_key(key) ⇒ Object
282 283 284 285 286 287 288 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 282 def on_key(key) # HINT: override it if necessary... if key == Wx::K_F2 edit_label if active? && visible? end super end |
#on_left_double_click(pos) ⇒ Object
269 270 271 272 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 269 def on_left_double_click(pos) # HINT: override it if necessary... edit_label end |
#set_edit_type(type) ⇒ Object Also known as: edit_type=
Set way how the text shape’s content can be edited.
188 189 190 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 188 def set_edit_type(type) @edit_type = type end |
#set_force_multiline(multiline) ⇒ Object Also known as: force_multiline=
261 262 263 |
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 261 def set_force_multiline(multiline) @force_multiline = multiline end |