gnustep-dev
[Top][All Lists]
Advanced

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

Re: Gorm : Xib loading doesn't respect size


From: forumer
Subject: Re: Gorm : Xib loading doesn't respect size
Date: Mon, 24 Jun 2013 17:19:13 +0200
User-agent: Roundcube Webmail/0.6

Oh I think I understand what you are doing in GSScreenRectToMS and in this case I would propose something like :

static inline
RECT GSScreenRectToMS(HWND hwnd, NSRect r)
{
    RECT r1;
    DWORD dwStyle = GetWindowLongPtr( hwnd, GWL_STYLE ) ;
    DWORD dwExStyle = GetWindowLongPtr( hwnd, GWL_EXSTYLE ) ;
    HMENU menu = GetMenu( hwnd ) ;

    r1.left = r.origin.x;
    r1.bottom = screen_height - r.origin.y;
    r1.right = r.origin.x + r.size.width;
    r1.top = screen_height - r.origin.y - r.size.height;

    AdjustWindowRectEx( &r1, dwStyle, menu ? TRUE : FALSE, dwExStyle );

    return r1
}

I cannot test it so I am just thinking aloud and we even could avoid the call to GetWindowLongPtr to retrieve the windows styles if we pass it as parameters because these information are known inside Win32Server.m :

wstyle = [self windowStyleForGSStyle: style];
estyle = [self exwindowStyleForGSStyle: style];

Anyway just hope I am in the right direction.



I would need to setup a dev. environment to debug gnustep on windows
but in the mean time I am having a look at source code but I don't
know which parts
of code is used.
Could you tell me if Win32Server.m is used when using the cairo backend ? In this case I don't really understand the GSScreenRectToMS function :


static inline
RECT GSScreenRectToMS(NSRect r)
{
  RECT r1;
  int screen_height = GetSystemMetrics(SM_CYSCREEN);

  r1.left = r.origin.x;
  r1.bottom = screen_height - r.origin.y;
  r1.right = r.origin.x + r.size.width;
  r1.top = screen_height - r.origin.y - r.size.height;

  return r1;
}



For instance when the window is created you do :

- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned
int)style
              : (int) screen
{
  HWND hwnd;
  RECT r;
  DWORD wstyle;
  DWORD estyle;

  wstyle = [self windowStyleForGSStyle: style];
  estyle = [self exwindowStyleForGSStyle: style];

  r = GSScreenRectToMS(frame);


...
}

 So you use the result of GSScreenRectToMS to call the win32
CreateWindowEx function but to me you should use some method like
  AdjustWindowRectEx to transform a client size into a window size
because win32 api only works with window size.

Same remark about resizing you should have some method like :

void SetClientSize( HWND hwnd, int clientWidth, int clientHeight ) {
  if ( IsWindow( hwnd ) ) {
    DWORD dwStyle = GetWindowLongPtr( hwnd, GWL_STYLE ) ;
    DWORD dwExStyle = GetWindowLongPtr( hwnd, GWL_EXSTYLE ) ;
    HMENU menu = GetMenu( hwnd ) ;
    RECT rc = { 0, 0, clientWidth, clientHeight } ;
AdjustWindowRectEx( &rc, dwStyle, menu ? TRUE : FALSE, dwExStyle ); SetWindowPos( hwnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
                  SWP_NOZORDER | SWP_NOMOVE ) ;
  }
}



http://stackoverflow.com/questions/431470/window-border-width-and-height-in-win32-how-do-i-get-it
for more information about how to get a window size from a client size.
In my opinion the best method is given by AdjustWindowRectEx.

Of course if Win32Server.m is not used you can ignore this email :-)




_______________________________________________
Gnustep-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/gnustep-dev



reply via email to

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