Re: Pango::Layout text within Gtk::Entry
- From: Bob Caryl <bob fis-cal com>
- To: Erdem Gokhan YILMAZ <gokhan yilmaz havelsan com tr>
- Cc: gtkmm-list gnome org
- Subject: Re: Pango::Layout text within Gtk::Entry
- Date: Wed, 27 Apr 2005 12:54:03 -0500
Erdem Gokhan YILMAZ wrote:
Hi,
I have been looking around for a solution to my problem of ,
Displaying a text which has markup on it (Pango::Layout::set_markup)
within Gtk::Entry()
but couldnt find one.
I have tried the following within a -----> class ventry:public
Gtk::Entry()
...
this->get_layout()->set_markup(markup);
...
which doesn't work :( but the same logic and the same markup works
quite well for a Gtk::Label()
...
Gtk::Label *x=new Gtk::Label();
x->set_markup(markup); ...
I will appreciate any working C++ example or an idea :)
Thanks in advance.
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
Hi Erdem,
I think your problem in trying to use set_markup for a Gtk::Entry in a
way analogous to how it is used in Gtk::Label is that the label text is
static compared to that Gtk::Entry text. So, to use the
Gtk::Pango::Layout::set_markup function for Gtk::Entry text requires
that you do it in a dynamic way. Using Gtk::PangoLayout::set_markup
works for me this way:
Gtk::Entry *entry = manage(new Gtk::Entry);
entry->signal_key_release_event().connect(sigc::mem_fun(*this,&Test::my_callback_function));
// connect a callback function to dynamically get access to the
Gtk::Entry text
The callback function looks something like this:
void Test::my_callback_function(void)
{
Glib::ustring str = "<big>"; // these lines create a marked up
version of the text in the Gtk::Entry
str += entry->get_text();
str += "</big>";
entry->get_layout()->set_markup(str); // dynamically replace the
Gtk::Entry text with the marked up version
}
Then the text in the entry appears as <big> after each time a character
is typed in by the user. This method is rather clunky though.. I
would recommend using Gtk::Pango::Layout::set_attributes instead.
Best regards,
Bob Caryl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]