|
Post by ptitjoz on Feb 22, 2018 12:46:30 GMT 1
Hi How put a text in color in an ENTRY ? I found FONT for bold FONT(entree4, "bold") Regards
|
|
|
Post by Pjot on Feb 22, 2018 19:34:58 GMT 1
Hi ptitjoz,
You cannot set a color for the Entry widget in HUG. You can set the font name, family, style, variant, weight, stretch, or gravity, and size for each individual widget. For example:
FONT(entry, "Monospace italic bold 15")
But this function cannot set the color.
Best regards Peter
|
|
|
Post by ptitjoz on Jun 16, 2018 8:54:55 GMT 1
Hi ptitjoz, You cannot set a color for the Entry widget in HUG. [..] Thanks Peter Too bad that it is not possible.
Maybe there are workarounds? But if it's complicated, it's not worth wasting time.
with my best regards
PtitJoz
|
|
|
Post by alexfish on Jun 16, 2018 17:44:49 GMT 1
Hi ptitjoz
As Peter Mentions there is no direct hug support for the select feature
here are three functions that can do what U request.
the difficulty is , one needs to read the gtk docs to find what functions the widget can be applied to , hence in most cases without the docs is a, 'If it works it works'.
BR Alex
INCLUDE hug.bac
GTK$= HUGLIB$("gtk") IMPORT "gtk_widget_modify_fg(long,int,long)" FROM GTK$ TYPE void IMPORT "gtk_widget_modify_base(long,int,long)" FROM GTK$ TYPE void IMPORT "gtk_widget_modify_text(long,int,long)" FROM GTK$ TYPE void
SUB SETFONTCOLOR(long widget,STRING colour) col = MEMORY(96) gdk_color_parse(colour, col) gtk_widget_modify_fg (hug_widget_font(STR$(widget)), 0, col) FREE col END SUB
SUB SETBASECOLOR(long widget,STRING colour) col = MEMORY(96) gdk_color_parse(colour, col) gtk_widget_modify_base (widget, 0, col) FREE col END SUB
SUB SETTEXTCOLOR(long widget,STRING colour) col = MEMORY(96) gdk_color_parse(colour, col) gtk_widget_modify_text (widget, 0, col) FREE col END SUB
win=WINDOW("my but",600,400) but=BUTTON("Colbut",100,25) ent=ENTRY("Blue Text",100,25)
' RED TEXT on the widgets with Bin child IE in most cases a button type with label SETFONTCOLOR(but,"#ff0000") ' seting colours on likes of Text Widgets SETBASECOLOR(ent,"#0000ff") SETTEXTCOLOR(ent,"#00ff00") ATTACH(win,but,5,5) ATTACH(win,ent,5,60) DISPLAY
|
|
|
Post by bigbass on Jun 16, 2018 18:22:03 GMT 1
Hey Alex A great job! no functions no REGISTER and a MEMORY clean up and short hand syntax Whenever anyone goes outside the built in functions of HUG or any other stable tool and wants to add widgets or customize something not built in you except the idea that you just left the "easy part behind" and have to know how gtk works and how HUG source code works and how to port gtk documentation to bacon and that takes a lot of time and patients and testing and could have secondary effects that you will have to be able to solve but if its fun than all is fine Joe
|
|
|
Post by Pjot on Jun 16, 2018 18:28:11 GMT 1
Thanks Alex! Nice code Best regards Peter
|
|
|
Post by vovchik on Jun 16, 2018 18:33:12 GMT 1
Dear Alex, Yes, great work. I was just doing something very similar but you beat me to it (both bits - Alex's and mine - in the attachment). In my code I made use of this thing, which might one day prove useful: ' ------------------ FUNCTION RGB2GDK(STRING col$) ' ------------------ LOCAL gdkcol gdkcol = g_malloc(HUG_DEFAULT_WIDGET_SIZE) gdk_color_parse(col$, gdkcol) RETURN gdkcol END FUNCTION Thanks and kind regards, vovchik
|
|
|
Post by bigbass on Jun 16, 2018 19:41:07 GMT 1
Hey vovchik I like it ,looks great!
The word for today
Serendipity =
The occurrence and development of events by chance in a happy or beneficial way
Joe
|
|
|
Post by vovchik on Jun 17, 2018 11:43:33 GMT 1
Dear all, I combined my code with that of Alex into a single function, which also gives us an opportunity to take STATE into account. I also put in some enums just to make it easier to use. I think it works. With kind regards, vovchik PS. @joe: Serendipity is a nice thing.
|
|