diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:55:58 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:55:58 +0100 |
commit | d1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch) | |
tree | 326578f0505cbed07cfe60de530022822dc237ac /app/wlib/gtklib/message.c | |
parent | 16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff) |
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/wlib/gtklib/message.c')
-rw-r--r-- | app/wlib/gtklib/message.c | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/app/wlib/gtklib/message.c b/app/wlib/gtklib/message.c index 396b696..af37d22 100644 --- a/app/wlib/gtklib/message.c +++ b/app/wlib/gtklib/message.c @@ -21,6 +21,7 @@ */ #include <stdlib.h> +#include <string.h> #define GTK_DISABLE_SINGLE_INCLUDES #define GDK_DISABLE_DEPRECATED @@ -84,7 +85,6 @@ void wMessageSetWidth( /** * Get height of message text - * \todo Constant height doesn't make sense, change to use the window's properties and retrieve the real font size * * \param flags IN text properties (large or small size) * \return text height @@ -93,7 +93,45 @@ void wMessageSetWidth( wPos_t wMessageGetHeight( long flags) { - return 14; + GtkWidget * temp; + + if (!(flags&COMBOBOX)) { + temp = gtk_label_new("Test"); //To get size of text itself + } else { + temp = gtk_combo_box_text_new(); //to get max size of an object in infoBar + } + + if (wMessageSetFont(flags)) { + GtkStyle *style; + PangoFontDescription *fontDesc; + int fontSize; + /* get the current font descriptor */ + style = gtk_widget_get_style(temp); + fontDesc = style->font_desc; + /* get the current font size */ + fontSize = PANGO_PIXELS(pango_font_description_get_size(fontDesc)); + + /* calculate the new font size */ + if (flags & BM_LARGE) { + pango_font_description_set_size(fontDesc, fontSize * 1.4 * PANGO_SCALE); + } else { + pango_font_description_set_size(fontDesc, fontSize * 0.7 * PANGO_SCALE); + } + + /* set the new font size */ + gtk_widget_modify_font(temp, fontDesc); + } + + if (flags&1L) { + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(temp),"Test"); + } + + GtkRequisition temp_requisition; + gtk_widget_size_request(temp,&temp_requisition); + g_object_ref_sink(temp); + gtk_widget_destroy(temp); + g_object_unref(temp); + return temp_requisition.height; } /** @@ -109,7 +147,7 @@ wPos_t wMessageGetHeight( * \return handle for created window */ - wMessage_p wMessageCreateEx( +wMessage_p wMessageCreateEx( wWin_p parent, wPos_t x, wPos_t y, @@ -147,7 +185,7 @@ wPos_t wMessageGetHeight( /* set the new font size */ gtk_widget_modify_font((GtkWidget *)b->labelWidget, fontDesc); } - + b->widget = gtk_fixed_new(); gtk_widget_size_request(GTK_WIDGET(b->labelWidget), &requisition); gtk_container_add(GTK_CONTAINER(b->widget), b->labelWidget); @@ -166,3 +204,33 @@ wPos_t wMessageGetHeight( return b; } + +/** + * Get the anticipated length of a message field + * + * \param testString IN string that should fit into the message box + * \return expected width of message box + */ + +wPos_t +wMessageGetWidth(const char *testString) +{ + GtkWidget *entry; + GtkRequisition requisition; + + return( wLabelWidth(testString)); +// entry = gtk_entry_new(); +// g_object_ref_sink(entry); +// +// gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE); +// gtk_entry_set_width_chars(GTK_ENTRY(entry), strlen(testString)); +// gtk_entry_set_max_length(GTK_ENTRY(entry), strlen(testString)); +// +// gtk_widget_size_request(entry, &requisition); +// +// gtk_widget_destroy(entry); +// g_object_unref(entry); +// +// return (requisition.width+8); +} + |