Re: [gtkmm] Widget for viewing multi-line text



> You need to tell it to wrap the lines. I've forgotten the details, but
> they should be in the reference manual.

I've tried it with set_wrap_mode() for my TextView but it
only works if I enlarge the parent window. I can't make it
smaller!! What is the problem?

TextViewWindow::TextViewWindow(
  const string& title,
  const string& message)
  :
  m_title(title),
  m_message(message),
  m_CloseButton("Close")
{
  set_border_width(10);
  set_default_size(200, 200);
  set_title(m_title);


  // Scrolled Window that holds text view for description
  m_scrolledWindow.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
  m_scrolledWindow.add(m_textView);

  m_textView.set_wrap_mode(Gtk::WRAP_WORD);

  m_TextBuffer = Gtk::TextBuffer::create();
  m_TextBuffer->set_text(m_message);
  m_textView.set_buffer(m_TextBuffer);

  Gtk::VBox *VBox = Gtk::manage(new Gtk::VBox());
  VBox->pack_start(m_scrolledWindow);
  VBox->pack_start(m_CloseButton,    Gtk::PACK_SHRINK);
  m_CloseButton.signal_clicked().connect(slot(*this,        
                                 &TextViewWindow::onCloseClicked));

  add(*VBox); // this object

  show_all_children();
}

-- 
Andreas B. Thun - Ingenieurbüro Thun GmbH




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]