Re: write a xlib textbox application without widgets



michele wrote:
hi all

i need to understand the basic lines on how to write a simple textbox
with xlib without using widgets...

the argument is so difficult (i have tried to read x11 documentation
yet) that i decide to ask to you before:

is there an example code that show me how to start?

naturally i'm not a complete xlib newbie, so don't worry about
explanations....

with regards

There are several ways to solve this problem. You can use the core and
standard X11 functions, or Xft, or even Freetype directly.

Here's a fairly simple way:

1. measure the text with XTextWidth()

2. use XCreateWindow to create a window or subwindow with padding for
around the text.

3. create a Pixmap with XCreatePixmap() that is the size of the window.

4. use XFillRectangle to draw a background for the Pixmap.

5. XDrawText(), or XDrawString, or XDrawImageString on the Pixmap.

6. Use XCopyArea to copy the Pixmap to the Window.

7. call XMapWindow

8. call XFlush

9. save the Pixmap and copy the Pixmap to the Window whenever you
receive an Expose event.


You can also get more sophisticated, and use Xdbe/DBE to provide
double-buffering.

I have a few tutorials here about working with Xlib:
http://www.xmission.com/~georgeps/documentation/tutorials/Xlib_Beginner-7.html

http://www.xmission.com/~georgeps/documentation/tutorials/Xlib_JPEG_Tutorial-5.html

http://www.xmission.com/~georgeps/documentation/tutorials/WM_TUTORIAL-3

Have fun :-)


George
.



Relevant Pages

  • Re: Discovering a windows background
    ... when you have changed something in the Edit window. ... 150x7) into that much smaller Pixmap, ... cannot bail out of XGlyphcore just because the glyphs are not entirely ... No, it is not trying to draw the Cursor itself, but the Cursor is ...
    (comp.windows.x)
  • Re: Inquiry on displaying GLX pixmap by glDrawPixels()
    ... our system is running X Window applications on some embedded ... Before Copying the base pixmap ... some difficulties in displaying the GLX pixmap onto the window. ... because XCopyAreacommand requires the X server interference. ...
    (comp.graphics.api.opengl)
  • Re: X/XCB programming (list of windows, raising/focus, sending events).
    ... I just started with X-related programming and everythings seems to me ... reasonably newbie oriented about Xlib nor XCB. ... a list of current visible windows, how to raise and focus a window by ... its id (and not confusing the current window manager by that if ...
    (comp.programming)
  • Re: newbie questions
    ... Specifically, I have cairo drawing ... into a pixmap, and I want to display this pixmap in a window (using a ... directly into the window, but I need the pixmap because then I would ... Display *display; ...
    (comp.windows.x)
  • XShape and anti-aliasing
    ... I want to draw a text in a transparent window. ... Making background transparent works fine. ... the problem is the color depth of 1 of the pixmap. ... How can I use XShape with Xft (anti- ...
    (comp.windows.x)