GTK+ Text widget

GTK+ Text widget

Post by Jared M Minc » Sun, 22 Jul 2001 06:56:06



In the midst of writing a program (a RPN calculator), I came across a bit
of a problem that I haven't figured out how to solve.

I'm using a GtkText widget to represent the stack, and so I want the data
to appear at the bottom of the widget area:

---
(empty space)

1
2
3
---

However, I'm not sure how to make that happen.  Will I have to break out
the code for the text widget and change it to suit my needs, or is there
some way to do it?  Or is there a better way of hadnling this?  I've
thought of simply adding enough newlines to the widget to fill the window
when the stack is smaller than the window, but I couldn't figure out how
to figure out the number of lines in the window.

While I'm here, I have another question: To handle shortcut keys (A '+',
or '-' or several other keys that immediately enter the current line and
perform the function), I've made an event handler to catch all the
keystrokes and decide whether to pass them through or act on it.  Is that
an acceptable solution, or is there a better way of doing it?

I apologize if the answer's RTFM ... I've tried to do so, but I've never
really done any GTK+ programming (or any GUI stuff at all), and things
definately go over my head on occasion.

Aardvark Joe

 
 
 

GTK+ Text widget

Post by Michael Linnema » Sun, 22 Jul 2001 17:43:57



Quote:>In the midst of writing a program (a RPN calculator), I came across a bit
>of a problem that I haven't figured out how to solve.
>I'm using a GtkText widget to represent the stack, and so I want the data
>to appear at the bottom of the widget area:
>---
>(empty space)

>1
>2
>3
>---
>However, I'm not sure how to make that happen.

Have you considerd using a clist instead? It seems more appropriate to
visualize a stack, plus it has the necessary methods for prepending
and deleting items.

Regards
Michael

 
 
 

GTK+ Text widget

Post by Victor Wagn » Sun, 22 Jul 2001 15:32:38



: In the midst of writing a program (a RPN calculator), I came across a bit
: of a problem that I haven't figured out how to solve.

: I'm using a GtkText widget to represent the stack, and so I want the data
: to appear at the bottom of the widget area:

First thing to do:

Never use widget to represent data object which lives inside your
program.

You should have working part and interface part coupled as loosely as
possible, so you can easlily throw out your gtk interface and write
Qt one, console one, or even Web-based one instead.

--
Obviously I was either onto something, or on something.
             -- Larry Wall on the creation of Perl

 
 
 

GTK+ Text widget

Post by Jared M Minc » Tue, 24 Jul 2001 01:43:32




> : In the midst of writing a program (a RPN calculator), I came across a bit
> : of a problem that I haven't figured out how to solve.

> : I'm using a GtkText widget to represent the stack, and so I want the data
> : to appear at the bottom of the widget area:

> First thing to do:

> Never use widget to represent data object which lives inside your
> program.

> You should have working part and interface part coupled as loosely as
> possible, so you can easlily throw out your gtk interface and write
> Qt one, console one, or even Web-based one instead.

Sorry, I guess I wasn't being clear :)
That's been done.  (In fact, I'd previously written a curses interface for
this program, so it was already split off very well.)  The data is stored
internally; I'm just using the text widget as a visualization system for
the data.

Aardvark Joe

 
 
 

1. GTK Text widgets

I have a text widget called output_text that is in a window.  I'm trying to
figure out how to use a function to do the equivalent of moving the cursor
up by one row.  I've looked in gtkeditable.h, gtktext.h and gtkwidget.h and
I can't seem to find any method that would help me out any...

I tried casting the widget to GtkText and then doing casted->cursor_pos_y--;
but it turns out the cursor_pos_[xy] is actually referring to a pixel position
not a position within the text widget (or so it seems to me).

Does anybody have any suggestions about how this might be accomplished?  

Browsing through the source of gtk+-1.2.3 there seems to be some functions in
there that would do it quite nicely, but they are static functions and ones
that I can't use.  (For the library only I guess)  I tried cutting and pasting
some code, but they are so dependant on internal macros and other static
functions that it's not worth it.

What I would really like to do is see a function that would let you manipulate
the x,y values for a text widget where the x,y values are actually positions
of the characters in the buffer.

Any suggestions?

(By the way, the source I'm working on is for a program called gtkeyboard
available at the page in the sig)

--
David Allen
http://opop.nols.com/
----------------------------------------
AUTHOR'S NOTE:
(B FLAT, 4/4, Staccato)

2. TURN $30 INTO THOUSANDS - Glasgow University

3. GTK: Horizontal Bar on Text Widget

4. Lost my serial mouse Slack 1.1.0 -> 1.1.1

5. text widget with controllable size using GTK???

6. user license upgrade

7. Making clickable text in the GTK texbox widget

8. Syqest Syjet EIDE & LINUX - does it work?

9. GTK - Detect Keypad ENTER - Text Entry Widget

10. gtk: how to draw arbitrary widgets

11. Changing widget color in GTK

12. Grid like widget for GTK or KDE

13. updating gtk widget in child