Class: Wx::SF::DetachedContentCtrl

Inherits:
Dialog
  • Object
show all
Defined in:
lib/wx/shapes/shapes/edit_text_shape.rb

Overview

Auxiliary class providing necessary functionality needed for dialog-based modification of a content of the text shape.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(parent, id = Wx::ID_ANY, title = 'Edit content', pos = Wx::DEFAULT_POSITION, size = Wx::DEFAULT_SIZE, style = Wx::DEFAULT_DIALOG_STYLE|Wx::RESIZE_BORDER) ⇒ DetachedContentCtrl

Returns a new instance of DetachedContentCtrl.

Parameters:

  • parent (Wx::Window)

    Pointer to the parent window

  • id (Integer) (defaults to: Wx::ID_ANY)

    ID of the text control window

  • title (String) (defaults to: 'Edit content')

    Dialog’s title

  • pos (Wx::Point) (defaults to: Wx::DEFAULT_POSITION)

    Initial position

  • size (Wx::Size) (defaults to: Wx::DEFAULT_SIZE)

    Initial size

  • style (Integer) (defaults to: Wx::DEFAULT_DIALOG_STYLE|Wx::RESIZE_BORDER)

    Window style



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 110

def initialize(parent, id = Wx::ID_ANY, title = 'Edit content',
               pos = Wx::DEFAULT_POSITION, size = Wx::DEFAULT_SIZE,
               style = Wx::DEFAULT_DIALOG_STYLE|Wx::RESIZE_BORDER)
  set_size_hints(Wx::Size.new(-1,-1), Wx::DEFAULT_SIZE)

  main_sizer = Wx::VBoxSizer.new

  @text = Wx::TextCtrl.new(self, Wx::ID_ANY, '', Wx::DEFAULT_POSITION, [350,100], Wx::TE_MULTILINE)
  @text.set_min_size([350,100])

  main_sizer.add(@text, 1, Wx::ALL|Wx::EXPAND, 5)

  button_sizer = Wx::StdDialogButtonSizer.new
  button_sizer_ok = Wx::Button.new(self, Wx::ID_OK)
  button_sizer.add_button(button_sizer_ok)
  button_sizer_cancel = Wx::Button.new(self, Wx::ID_CANCEL)
  button_sizer.add_button(button_sizer_cancel)
  button_sizer.realize
  main_sizer.add(button_sizer, 0, Wx::ALIGN_RIGHT|Wx::BOTTOM|Wx::RIGHT, 5)

  set_sizer(main_sizer)
  layout
  main_sizer.fit(self)

  centre(Wx::BOTH)
end

Instance Method Details

#get_contentString

Get content of dialog’s text edit control.

Returns:

  • (String)

    Edited text



145
146
147
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 145

def get_content
  @text.get_value
end

#set_content(txt) ⇒ Object

Set content of dialog’s text edit control.

Parameters:

  • txt (String)

    Text content



139
140
141
# File 'lib/wx/shapes/shapes/edit_text_shape.rb', line 139

def set_content(txt)
  @text.set_value(txt)
end