discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Draw on Xwindow directly without NSWindow


From: Yen-Ju Chen
Subject: Re: Draw on Xwindow directly without NSWindow
Date: Wed, 3 May 2006 15:24:15 -0700

On 5/3/06, Fred Kiefer <address@hidden> wrote:
I just submitted code for gui and the X backends that should support
most of what you want. Here is how I changed your test code to see if it
is actually working:

Thanx a lot.
It really helps.
I will try it after work.

Yen-Ju


- (void) applicationDidFinishLaunching:(NSNotification *)aNotification
{
  NSWindow *win;
  /* Setup main window */
  int x = 100, y = 10, w = 300, h = 300, border_width = 10;
  mainXWindow = XCreateWindow(dpy, root_win, x, y, w, h, border_width,
                  CopyFromParent, CopyFromParent, CopyFromParent, 0, NULL);

  win = [[NSWindow alloc] initWithWindowRef: &mainXWindow];
  [win makeKeyAndOrderFront: self];
  [[win contentView] lockFocus];

  [[NSColor blackColor] set];
  NSRectFill(NSMakeRect(0, 0, 300, 300));
  [[NSColor whiteColor] set];
  NSRectFill(NSMakeRect(10, 10, 280, 280));
  [[win contentView] unlockFocus];
}

You shoudl be aware that after wrapping the X window inside of the
NSWindow, the later is responcible of freeing the X window. You should
not be doing this yourself. Also notice that you have to provide a
pointer to the X window not the window itself. I did this to match up
with the existing windowDevice: method.

Cheers
Fred





reply via email to

[Prev in Thread] Current Thread [Next in Thread]