drawing with cairo over a GtkBox not using GtkDrawingArea - c

I program my application in C using GTK+3 and cairo.
is there a way to draw a line on top of a Vertical GtkBox ?
the thing is that I need to mark an area with a line. the area is a row of a vertical GtkBox, which is not a GtkDrawingArea.
is that possible?
any information regarding the issue would be greatly appreciated.

I'm using glade in order to create the Gtk Vertical Box.
I connected a callback to the draw signal and I marked 'After' in glade which actually calls my callback after the basic drawing. which allows me to draw on top of the elements inside it.
as simple as that ;)

Related

Delete or Remove a line using Xlib library

Assume that we draw a line in Xlib using the XDrawLine API, what is the best way to remove or delete the line?. Are there any dedicated API's for this or do we have to use a special implementation of the the same XDrawLine API?
Thanks in Advance for your responses.
You can draw a line the color of the background (e.g, white) over the top of another line to "erase" it, but there's no way to restore the original graphics that were there before you drew the first line — Xlib does not keep a history.
In general, though, your application should be able to do a full "repaint" of the window at any time (e.g, if the window is resized or minimized, or if it is "damaged" by another window crossing over it). What you're asking makes it sound like your application may not be able to do this right now, which will prevent it from working correctly in some situations.
The best way would be to draw to off-screen pixmap and remember state (or pixmap copy) before you draw the line. Delete line == draw offline pixmap to that state ( or just copy saved pixmap back to screen )

How to do simple shape drawing in GTK?

I am new to Gtk and want to do simple drawing of shapes like circles and rectangles. I was looking at the gnome tutorial and the hello word example. However the curves section is undocumented. I was wondering if someone could point me in the right direction as to what should I look at, and maybe if I need to include some other supplementary library to draw?
The preferred drawing API in GTK 2 and 3 is Cairo. But if you need to develop a diagram program, with nodes that can react to events, you will need also to use a canvas, like GooCanvas.
Check out http://developer.gnome.org/gtk3/3.2/GtkDrawingArea.html about the GtkDrawingArea, plus http://developer.gnome.org/gdk/stable/gdk-Drawing-Primitives.html about Gdk-Drawing-Primitives and you are on the go.
You might also go a bit further by using this link and check out Cairo directly http://www.cairographics.org

Displaying sudoku grid with ncurses

I have wrote a c program to solve sudokus, and i would like to know if i can draw the grid and fill it using ncurses library.
i just would like to know how to control the lines and borders of boxes in ncurses
thank you very much
Yes, you can, using hline family of functions to draw your grid.
See http://osr600doc.sco.com/en/man/html.CURSES/hline.CURSES.html for more information.

drawing above gtkentry using cairo

I want to use cairo to enhance gtkentry look. For this, I have connected a callback to 'expose-event'. In callback, I call gtkentry's original expose-event handler. After that, I create cairo context and draw some lines and destroy the cairo. I return 'TRUE' as return value of callback function so that expose-event does not propagate.
Now my problem is, I am drawing line from (0,0) to (100,100). But line appears only over the border areas of the gtkentry. The place where text is, it does not appear.
Please help.
Kind Regards
-Durgesh O Mishra
GtkEntry uses an additional GdkWindow for the text area. It is sort-of-private, but you could access it using the following code:
GDK_WINDOW (gdk_window_peek_children (GTK_WIDGET (entry)->window)->data);
So, you can pass this window to gdk_cairo_create().
If you have problems applying this to your code, paste the code — it's hard to guess what to do without having any way to test.

Gtk buttons over a Gtk drawing area

i' working with Gtk developing some app. I must put some buttons over a map. I'm drawing the map on a GtkDrawingarea, but i'm not able to put buttons over it.
Any suggestion?
Thanks
Suggestions:
Put both the drawing area and the buttons inside a GtkFixed container. Probably not the best solution, because GtkFixed has no way of controlling the z-ordering (other than the order in which you add the widgets to it?)
Instead of using GtkDrawingArea, use a canvas widget that can include other widgets, such as GooCanvas.
Why no other library? Any specific reason?
There is a library for exactly what you want
http://geocanvas.sourceforge.net/

Resources