Gadget request
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by turtle.
Hi,
Is it possible to have a multiline text gadget implemented? In Win32 for example the RichEdit widget can be used for that, in Linux GTK the "gtk_text_new" function might be used.
- Commands like "SetGadgetText" and "GetGadgetText" can be implemented to set/get the text.
- It should also be possible to set the foreground/background color of the entered text (GTK: gdk_color_alloc(gdk_colormap_get_system(), text_fg_color) and gdk_color_alloc(gdk_colormap_get_system(), text_bg_color)) so we can program a cool IDE for Linux as well.
- Finally it should be possible to set/get the cursor position within the multiline edit (gtk_text_set_point(GTK_TEXT(object),pos), gtk_text_get_point(GTK_TEXT(object),pos))
I have been programming a lot of GTK so in case of detailed information on the GTK API I can help you out.
I hope you are able to add this gadget.
Thanks,
Peter.
Hi,
Is it possible to have a multiline text gadget implemented? In Win32 for example the RichEdit widget can be used for that, in Linux GTK the "gtk_text_new" function might be used.
- Commands like "SetGadgetText" and "GetGadgetText" can be implemented to set/get the text.
- It should also be possible to set the foreground/background color of the entered text (GTK: gdk_color_alloc(gdk_colormap_get_system(), text_fg_color) and gdk_color_alloc(gdk_colormap_get_system(), text_bg_color)) so we can program a cool IDE for Linux as well.
- Finally it should be possible to set/get the cursor position within the multiline edit (gtk_text_set_point(GTK_TEXT(object),pos), gtk_text_get_point(GTK_TEXT(object),pos))
I have been programming a lot of GTK so in case of detailed information on the GTK API I can help you out.
I hope you are able to add this gadget.
Thanks,
Peter.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Franco.
nice to hear that.
The more functions are available in PureBasic for Linux the more user will code for both platforms and are in need for more knowledge.
BTW: Welcome to the PureBasic community.
Have a nice day...
Franco
Hello Peter,Originally posted by turtle
I have been programming a lot of GTK so in case of detailed information on the GTK API I can help you out.
nice to hear that.
The more functions are available in PureBasic for Linux the more user will code for both platforms and are in need for more knowledge.
BTW: Welcome to the PureBasic community.
Have a nice day...
Franco
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by turtle.
Hi Franco,
Thank you for your kind welcome!
I have registered PureBasic yesterday. For a long time I have been using Scriptbasic myself. I have programmed 2 libraries for Scriptbasic, one for GUI programming and one for sockets. That why I come up with questions I have solved myself already with Scriptbasic.
The big advantage of PureBasic however is it's genuine ASM compilation, and the tremendous amount of libraries which provides a lot of possibilities to the programmer. The ability to program multimedia stuff is pretty cool! My primary focus however will be the Linux version of PureBasic.
Peter.
PS If you are interested in my work for Scriptbasic, take a look at my site: http://www.turtle.dds.nl
Hi Franco,
Thank you for your kind welcome!
I have registered PureBasic yesterday. For a long time I have been using Scriptbasic myself. I have programmed 2 libraries for Scriptbasic, one for GUI programming and one for sockets. That why I come up with questions I have solved myself already with Scriptbasic.
The big advantage of PureBasic however is it's genuine ASM compilation, and the tremendous amount of libraries which provides a lot of possibilities to the programmer. The ability to program multimedia stuff is pretty cool! My primary focus however will be the Linux version of PureBasic.
Peter.
PS If you are interested in my work for Scriptbasic, take a look at my site: http://www.turtle.dds.nl
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by PB.
> Is it possible to have a multiline text gadget implemented?
It already is implemented, although the docs for the StringGadget
don't mention it.
See here for your answer:
http://www.curvesoftware.co.uk/purebasi ... =multiline
> Is it possible to have a multiline text gadget implemented?
It already is implemented, although the docs for the StringGadget
don't mention it.

http://www.curvesoftware.co.uk/purebasi ... =multiline
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
Its a long way to the top if you wanna .....CodeGuru
You are wrong! This works only under Windows, never with linux.Originally posted by PB
> Is it possible to have a multiline text gadget implemented?
It already is implemented, although the docs for the StringGadget
don't mention it.See here for your answer:
http://www.curvesoftware.co.uk/purebasi ... =multiline
Its a long way to the top if you wanna .....CodeGuru
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
Welcome Peter !
As I wrote you in the mail, you're about the first user which want to use it for Linux. Your input about GTK can be very useful to us, as I don't know it very very well (I've spend several days building the PB Linux libs but I not considering myself as a GTK master). About the EditorGadget(), I will implement it soon, for both Linux and Windows. I would like to put buildin syntax coloring, so if you have some tips on the GTK side, it will be perfect
.
Fred - AlphaSND
Welcome Peter !
As I wrote you in the mail, you're about the first user which want to use it for Linux. Your input about GTK can be very useful to us, as I don't know it very very well (I've spend several days building the PB Linux libs but I not considering myself as a GTK master). About the EditorGadget(), I will implement it soon, for both Linux and Windows. I would like to put buildin syntax coloring, so if you have some tips on the GTK side, it will be perfect

Fred - AlphaSND
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by turtle.
And Fred, you're already mentioning a name for the mutliline widget, EditorGadget, that's great! I may have tips, especially on coloring, which for GTK is really a pain in the... well you know what. Anyway, I have programmed GTK with C, and I am not sure whether this is appropriate for you and PureBASIC.
Thank you all for your responses and nice welcome,
Peter.
Well, that is no problem! Ask!Be aware, from now on there will be a lot of GTK-API questions in the forum...
Have a nice day...
And Fred, you're already mentioning a name for the mutliline widget, EditorGadget, that's great! I may have tips, especially on coloring, which for GTK is really a pain in the... well you know what. Anyway, I have programmed GTK with C, and I am not sure whether this is appropriate for you and PureBASIC.
Thank you all for your responses and nice welcome,
Peter.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by turtle.
GdkColor *text_fg_color;
text_fg_color = (GdkColor*) g_malloc (sizeof(GdkColor));
text_fg_color->red = red;
text_fg_color->green = green;
text_fg_color->blue = blue;
gdk_color_alloc(gdk_colormap_get_system(), text_fg_color);
The same code works for the text background color. Every time you put text in the widget, the color has to be specified:
gtk_text_insert(GTK_TEXT(EditorGadget), font, text_fg_color, text_bg_color, "text", -1);
As you can see, you also need to set the background color here. One nice free advantage of text coloring is, that changing the textcolor will not affect other pieces of text already in the widget. So, every time you change the color, only the text which is printed after the change, will have the new color.
The coloring may deliver a difficulty however. The default PureBASIC command "SetGadgetText" now also needs an argument to specify the color. Or a new color command must be introduced. For build-in syntax coloring support, the TEXT widget delivers no extra functionality. I am afraid you have to write the complete syntax recognition yourself. But the GTK API provides functions to get, set and delete text. You can also set and get the cursor position.
Finally, you may want to set the color of the field in which the complete text appears. This is a nasty part. I have implemented this in Visio using styles:
//define a pointer to the style
GtkRcStyle *rc_style;
//define a variable for the color to set
GdkColor wcolor;
//create a new style
rc_style = gtk_rc_style_new ();
//define your color
wcolor.red = red;
wcolor.green = green;
wcolor.blue = blue;
//set the colors of the style
rc_style->base[GTK_STATE_NORMAL] = wcolor;
rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_BASE;
//actually change the style of the widget
gtk_widget_modify_style (GTK_WIDGET(EditorGadget), rc_style);
//remove the created reference to the style from the GTK ref. list
gtk_rc_style_unref (rc_style);
It took me quite some time to find this out. Coloring widgets is implemented in a very clumsy way in GTK 1.2.
I hope this info may help you implementing the EditorGadget.
Regards
Peter.
Well, the TEXT widget of GTK 1.2 isn't that advanced, unfortunately. For example, it cannot support a horizontal scrollbar. And the vertical scrollbar is a separate widget which have to be created along with the TEXT widget. But the coloring can easily be achieved:About the EditorGadget(), I will implement it soon, for both Linux and Windows. I would like to put buildin syntax coloring, so if you have some tips on the GTK side, it will be perfect.
GdkColor *text_fg_color;
text_fg_color = (GdkColor*) g_malloc (sizeof(GdkColor));
text_fg_color->red = red;
text_fg_color->green = green;
text_fg_color->blue = blue;
gdk_color_alloc(gdk_colormap_get_system(), text_fg_color);
The same code works for the text background color. Every time you put text in the widget, the color has to be specified:
gtk_text_insert(GTK_TEXT(EditorGadget), font, text_fg_color, text_bg_color, "text", -1);
As you can see, you also need to set the background color here. One nice free advantage of text coloring is, that changing the textcolor will not affect other pieces of text already in the widget. So, every time you change the color, only the text which is printed after the change, will have the new color.
The coloring may deliver a difficulty however. The default PureBASIC command "SetGadgetText" now also needs an argument to specify the color. Or a new color command must be introduced. For build-in syntax coloring support, the TEXT widget delivers no extra functionality. I am afraid you have to write the complete syntax recognition yourself. But the GTK API provides functions to get, set and delete text. You can also set and get the cursor position.
Finally, you may want to set the color of the field in which the complete text appears. This is a nasty part. I have implemented this in Visio using styles:
//define a pointer to the style
GtkRcStyle *rc_style;
//define a variable for the color to set
GdkColor wcolor;
//create a new style
rc_style = gtk_rc_style_new ();
//define your color
wcolor.red = red;
wcolor.green = green;
wcolor.blue = blue;
//set the colors of the style
rc_style->base[GTK_STATE_NORMAL] = wcolor;
rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_BASE;
//actually change the style of the widget
gtk_widget_modify_style (GTK_WIDGET(EditorGadget), rc_style);
//remove the created reference to the style from the GTK ref. list
gtk_rc_style_unref (rc_style);
It took me quite some time to find this out. Coloring widgets is implemented in a very clumsy way in GTK 1.2.
I hope this info may help you implementing the EditorGadget.
Regards
Peter.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm