discuss-gnustep
[Top][All Lists]
Advanced

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

Re: ContentView Offset


From: Steve Van Voorst
Subject: Re: ContentView Offset
Date: Sun, 9 Sep 2012 21:20:21 +0000 (GMT)

> Can you provide the source to test it?

German,

So far I have used two different methods to create a window: delegate and code in main.  An app delegate is used for the first technique (recommended), while the window building code is either called from or contained within the 'main' for the second technique.  Most of the problems have occurred with the second technique, which works fine on a Mac but causes problems over here.  The offending code follows this format:

// --------- start ------------

#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

 void createMenu()
 {
  NSMenu *menu = [[NSMenu new]autorelease];
  [menu addItemWithTitle: @"Quit"  
        action: @selector (terminate:)  
        keyEquivalent: @"q"];
  [NSApp setMainMenu: menu];
 }

 void buildWnd()  
 {
  #define _wndW  400
  #define _wndH  400
        
  NSRect wndRect = NSMakeRect( 0, 0, _wndW, _wndH);
  NSWindow *window = [ [NSWindow alloc] initWithContentRect:wndRect
    styleMask:NSTitledWindowMask |NSClosableWindowMask |NSMiniaturizableWindowMask// | NSResizableWindowMask
    backing:NSBackingStoreBuffered
    defer:NO];     
  [window setTitle:@"Test Window_main"];
  // -- White band at bottom fixer -> Black band at top creator-- //
 // [window setFrame:wndRect display:YES];
  [window center];
  [window makeKeyAndOrderFront: nil];
 }

 int main()
 {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  NSApp = [NSApplication sharedApplication];
  buildWnd();
  createMenu();
  [NSApp run];        
  [pool drain];
  return 0;
 }

// -------- end -------

Some observations:

1) If the window is resizable, the white band goes away as soon as the window is resized.  Uncomment style mask to test.
2) Knowing that, I tried simulating a resize event by using the -setFrame method on the window after it was created (uncomment [window setFrame: display:] to test).  This is helpful in that the white band disappears and the coordinates of the buttons are correct so that they me be "hit" and used as intended.  Unfortunately, a black band at the top appears as the white band at the bottom goes away.  Again, if the window is resized, the black band disappears just like the white one does.

Conclusions so far:

1) If I have to, I can build all my windows with the delegate technique, which is not immune from the problem but overall less affected.  There is a reason for it being the preferred technique and perhaps this is why.  On the other hand, the main technique works fine on the Mac and I don't understand why it won't work over here.  It would help if I had more knowledge about how windows are created on gnustep.

Thanks for your willingness to help.

Steve Van Voorst













reply via email to

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