mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-23 16:10:52 +00:00
* Restructuring of the windows server to handle various
window and toolbar issues (See Source/win32/RELEASE_NOTES for more info). * Headers/win32/WIN32Server.h: Added ivars and flags and methods. * Headers/winlib/WIN32GState.h: Added method to avoid confliting types with superclass. * Source/win32/GNUmakefile: Add new files. * w32_debug.m, w32_activate.m, w32_create.m, w32_general.m, w32_movesize.m, w32_text_focus.m, w32_windowdisplay.m, GSDisplayServer_details.m: New files. * Source/win32/WIN32Server.m: Large changes. Merged with WIN32ServerEvent. Lots of documentation. * Source/winlib/WIN32GState.m: Variable name changes to avoid shadowing. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@21716 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a1693eaf2
commit
1ce2926317
19 changed files with 5546 additions and 1043 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2005-09-14 Tom MacSween <macsweent@sympatico.ca>
|
||||
|
||||
* Restructuring of the windows server to handle various
|
||||
window and toolbar issues (See Source/win32/RELEASE_NOTES for
|
||||
more info).
|
||||
* Headers/win32/WIN32Server.h: Added ivars and flags and methods.
|
||||
* Headers/winlib/WIN32GState.h: Added method to avoid confliting
|
||||
types with superclass.
|
||||
* Source/win32/GNUmakefile: Add new files.
|
||||
* w32_debug.m, w32_activate.m, w32_create.m, w32_general.m,
|
||||
w32_movesize.m, w32_text_focus.m, w32_windowdisplay.m,
|
||||
GSDisplayServer_details.m: New files.
|
||||
* Source/win32/WIN32Server.m: Large changes. Merged with
|
||||
WIN32ServerEvent. Lots of documentation.
|
||||
|
||||
* Source/winlib/WIN32GState.m: Variable name changes to
|
||||
avoid shadowing.
|
||||
|
||||
2005-08-28 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/cairo/CairoSurface.h,
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002,2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
Part of this code have been re-written by:
|
||||
Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
|
@ -25,10 +27,48 @@
|
|||
#ifndef _WIN32Server_h_INCLUDE
|
||||
#define _WIN32Server_h_INCLUDE
|
||||
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
#include <AppKit/AppKitExceptions.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSCursor.h>
|
||||
#include <AppKit/NSText.h>
|
||||
#include <AppKit/DPSOperators.h>
|
||||
|
||||
#include "win32/WIN32Server.h"
|
||||
|
||||
#include <GNUstepGUI/GSDisplayServer.h>
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/*
|
||||
This standard windows macros are missing in MinGW. The definition
|
||||
here is almost correct, but will fail for multi monitor systems
|
||||
*/
|
||||
#ifndef GET_X_LPARAM
|
||||
#define GET_X_LPARAM(p) ((int)(short)LOWORD(p))
|
||||
#endif
|
||||
#ifndef GET_Y_LPARAM
|
||||
#define GET_Y_LPARAM(p) ((int)(short)HIWORD(p))
|
||||
#endif
|
||||
|
||||
//#define __debugServer__ // main server debug (from WIN32Server)
|
||||
//#define __W32_debug__ // event frame debugging/logging
|
||||
|
||||
#define EVENT_WINDOW(lp) (GSWindowWithNumber((int)lp))
|
||||
@interface WIN32Server : GSDisplayServer
|
||||
{
|
||||
HINSTANCE hinstance;
|
||||
|
@ -36,11 +76,91 @@
|
|||
HWND currentFocus;
|
||||
HWND desiredFocus;
|
||||
HWND currentActive;
|
||||
|
||||
|
||||
struct {
|
||||
|
||||
BOOL useWMTaskBar;
|
||||
int _last_WM_ACTIVATE;
|
||||
int eventQueCount;
|
||||
int menuRef; // reference to menu window
|
||||
unsigned int currentGS_Style; // what style is current event window
|
||||
BOOL HOLD_MENU_FOR_MOVE; // override GS move event on hide
|
||||
BOOL HOLD_MENU_FOR_SIZE; // override GS size event on hide
|
||||
BOOL HOLD_MINI_FOR_SIZE; // override GS size event on miniturize
|
||||
BOOL HOLD_MINI_FOR_MOVE; // override GS move event on miniturize
|
||||
BOOL HOLD_TRANSIENT_FOR_SIZE; // override GS size event on popup context
|
||||
BOOL HOLD_TRANSIENT_FOR_MOVE; // override GS move event on popup context
|
||||
BOOL HAVE_MAIN_MENU; // do we have a main menu?
|
||||
BOOL _is_menu; // is event window the main menu?
|
||||
BOOL _eventHandled; // did we handle the event?
|
||||
BOOL _is_cache; // is the event window a cache rep
|
||||
BOOL _hasGSClassName; // does the event window have a GSclassName
|
||||
int lastEventType;
|
||||
int hold;
|
||||
} flags;
|
||||
}
|
||||
|
||||
- (LRESULT) windowEventProc: (HWND)hwnd : (UINT)uMsg
|
||||
: (WPARAM)wParam : (LPARAM)lParam;
|
||||
|
||||
- (void) setFlagsforEventLoop: (HWND)hwnd;
|
||||
- (NSString *) getNativeClassName: (HWND)hwnd;
|
||||
- (NSString *) getWindowtext: (HWND)hwnd;
|
||||
|
||||
// declared but should be implimented in a subclass window server
|
||||
// (subclass resposibility)
|
||||
- (LRESULT) decodeWM_ACTIVEParams: (WPARAM)wParam : (LPARAM)lParam
|
||||
: (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam
|
||||
: (LPARAM)lParam;
|
||||
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam
|
||||
: (HWND)hwnd;
|
||||
/*
|
||||
Hooks for the subclass to process notifications and syncronize the
|
||||
win32 env with the application.
|
||||
*/
|
||||
- (void) ApplicationDidFinishLaunching: (NSNotification*)aNotification;
|
||||
- (void) ApplicationWillFinishLaunching: (NSNotification*)aNotification;
|
||||
- (void) WindowWillMiniaturizeNotification: (NSNotification*)aNotification;
|
||||
- (void) MenuWillTearOff: (NSNotification*)aNotification;
|
||||
- (void) MenuwillPopUP: (NSNotification*)aNotification;
|
||||
|
||||
|
||||
- (LRESULT) decodeWM_SIZEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
|
||||
- (LRESULT) decodeWM_MOVEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
|
||||
- (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_WINDOWPOSCHANGINGParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_WINDOWPOSCHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_GETMINMAXINFOParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_EXITSIZEMOVEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
|
||||
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
|
||||
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) resizeBackingStoreFor: (HWND)hwnd;
|
||||
|
||||
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
|
||||
- (void) decodeWM_CLOSEParams: (WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd;
|
||||
- (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
|
||||
// diagnotic and debugging
|
||||
- (BOOL) displayEvent: (unsigned int)uMsg;
|
||||
- (void) registerForWindowEvents;
|
||||
- (void) registerForViewEvents;
|
||||
@end
|
||||
|
||||
typedef struct _win_intern {
|
||||
|
@ -50,5 +170,4 @@ typedef struct _win_intern {
|
|||
MINMAXINFO minmax;
|
||||
} WIN_INTERN;
|
||||
|
||||
|
||||
#endif /* _WIN32Server_h_INCLUDE */
|
||||
|
|
|
@ -48,6 +48,12 @@
|
|||
|
||||
- (void) setWindow: (HWND)number;
|
||||
- (HWND) window;
|
||||
// declared to fix conflicting type with super class warning during compile
|
||||
- (void) compositeGState: (WIN32GState *) source
|
||||
fromRect: (NSRect) sourceRect
|
||||
toPoint: (NSPoint) destPoint
|
||||
op: (NSCompositingOperation) op
|
||||
fraction: (float)delta;
|
||||
|
||||
@end
|
||||
|
||||
|
|
344
Source/win32/Event_format.sed
Normal file
344
Source/win32/Event_format.sed
Normal file
|
@ -0,0 +1,344 @@
|
|||
# WIN32Server - Implements window handling for MSWindows
|
||||
#
|
||||
# Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Tom MacSween <macsweent@sympatico.ca>
|
||||
# Date August 2005
|
||||
# This file is part of the GNU Objective C User Interface Library.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Library General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Library General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Library General Public
|
||||
# License along with this library; if not, write to the Free
|
||||
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
#
|
||||
|
||||
|
||||
#sed -f Event_format.sed result.sed >test_result.log
|
||||
s/CYCLE 0 /WM_NULL 0/ g
|
||||
s/CYCLE 1 /WM_CREATE 1/g
|
||||
s/CYCLE 2 /WM_DESTROY 2/g
|
||||
s/CYCLE 3 /WM_MOVE 3/g
|
||||
s/CYCLE 5 /WM_SIZE 5/g
|
||||
s/CYCLE 6 /WM_ACTIVATE 6/g
|
||||
s/CYCLE 7 /WM_SETFOCUS 7/g
|
||||
s/CYCLE 8 /WM_KILLFOCUS 8/g
|
||||
s/CYCLE 10 /WM_ENABLE 10/g
|
||||
s/CYCLE 11 /WM_SETREDRAW 11/g
|
||||
s/CYCLE 12 /WM_SETTEXT 12/g
|
||||
s/CYCLE 13 /WM_GETTEXT 13/g
|
||||
s/CYCLE 14 /WM_GETTEXTLENGTH 14/g
|
||||
s/CYCLE 15 /WM_PAINT 15/g
|
||||
s/CYCLE 16 /WM_CLOSE 16/g
|
||||
s/CYCLE 17 /WM_QUERYENDSESSION 17/g
|
||||
s/CYCLE 18 /WM_QUIT 18/g
|
||||
s/CYCLE 19 /WM_QUERYOPEN 19/g
|
||||
s/CYCLE 20 /WM_ERASEBKGND 20/g
|
||||
s/CYCLE 21 /WM_SYSCOLORCHANGE 21/g
|
||||
s/CYCLE 22 /WM_ENDSESSION 22/g
|
||||
s/CYCLE 24 /WM_SHOWWINDOW 24/g
|
||||
s/CYCLE 26 /WM_SETTINGCHANGE 26/g
|
||||
s/CYCLE 26 /WM_WININICHANGE 26/g
|
||||
s/CYCLE 27 /WM_DEVMODECHANGE 27/g
|
||||
s/CYCLE 28 /WM_ACTIVATEAPP 28/g
|
||||
s/CYCLE 29 /WM_FONTCHANGE 29/g
|
||||
s/CYCLE 30 /WM_TIMECHANGE 30/g
|
||||
s/CYCLE 31 /WM_CANCELMODE 31/g
|
||||
s/CYCLE 32 /WM_SETCURSOR 32/g
|
||||
s/CYCLE 33 /WM_MOUSEACTIVATE 33/g
|
||||
s/CYCLE 34 /WM_CHILDACTIVATE 34/g
|
||||
s/CYCLE 35 /WM_QUEUESYNC 35/g
|
||||
s/CYCLE 36 /WM_GETMINMAXINFO 36/g
|
||||
s/CYCLE 38 /WM_PAINTICON 38/g
|
||||
s/CYCLE 39 /WM_ICONERASEBKGND 39/g
|
||||
s/CYCLE 40 /WM_NEXTDLGCTL 40/g
|
||||
s/CYCLE 42 /WM_SPOOLERSTATUS 42/g
|
||||
s/CYCLE 43 /WM_DRAWITEM 43/g
|
||||
s/CYCLE 44 /WM_MEASUREITEM 44/g
|
||||
s/CYCLE 45 /WM_DELETEITEM 45/g
|
||||
s/CYCLE 46 /WM_VKEYTOITEM 46/g
|
||||
s/CYCLE 47 /WM_CHARTOITEM 47/g
|
||||
s/CYCLE 48 /WM_SETFONT 48/g
|
||||
s/CYCLE 49 /WM_GETFONT 49/g
|
||||
s/CYCLE 50 /WM_SETHOTKEY 50/g
|
||||
s/CYCLE 51 /WM_GETHOTKEY 51/g
|
||||
s/CYCLE 55 /WM_QUERYDRAGICON 55/g
|
||||
s/CYCLE 57 /WM_COMPAREITEM 57/g
|
||||
s/CYCLE 65 /WM_COMPACTING 65/g
|
||||
s/CYCLE 68 /WM_COMMNOTIFY 68/g
|
||||
s/CYCLE 70 /WM_WINDOWPOSCHANGING 70/g
|
||||
s/CYCLE 71 /WM_WINDOWPOSCHANGED 71/g
|
||||
s/CYCLE 72 /WM_POWER 72/g
|
||||
s/CYCLE 74 /WM_COPYDATA 74/g
|
||||
s/CYCLE 75 /WM_CANCELJOURNAL 75/g
|
||||
s/CYCLE 78 /WM_NOTIFY 78/g
|
||||
s/CYCLE 80 /WM_INPUTLANGCHANGEREQUEST 80/g
|
||||
s/CYCLE 81 /WM_INPUTLANGCHANGE 81/g
|
||||
s/CYCLE 82 /WM_TCARD 82/g
|
||||
s/CYCLE 83 /WM_HELP 83/g
|
||||
s/CYCLE 84 /WM_USERCHANGED 84/g
|
||||
s/CYCLE 85 /WM_NOTIFYFORMAT 85/g
|
||||
s/CYCLE 123 /WM_CONTEXTMENU 123/g
|
||||
s/CYCLE 124 /WM_STYLECHANGING 124/g
|
||||
s/CYCLE 125 /WM_STYLECHANGED 125/g
|
||||
s/CYCLE 126 /WM_DISPLAYCHANGE 126/g
|
||||
s/CYCLE 127 /WM_GETICON 127/g
|
||||
s/CYCLE 128 /WM_SETICON 128/g
|
||||
s/CYCLE 129 /WM_NCCREATE 129/g
|
||||
s/CYCLE 130 /WM_NCDESTROY 130/g
|
||||
s/CYCLE 131 /WM_NCCALCSIZE 131/g
|
||||
s/CYCLE 132 /WM_NCHITTEST 132/g
|
||||
s/CYCLE 133 /WM_NCPAINT 133/g
|
||||
s/CYCLE 134 /WM_NCACTIVATE 134/g
|
||||
s/CYCLE 135 /WM_GETDLGCODE 135/g
|
||||
s/CYCLE 136 /WM_SYNCPAINT 136/g
|
||||
s/CYCLE 160 /WM_NCMOUSEMOVE 160/g
|
||||
s/CYCLE 161 /WM_NCLBUTTONDOWN 161/g
|
||||
s/CYCLE 162 /WM_NCLBUTTONUP 162/g
|
||||
s/CYCLE 163 /WM_NCLBUTTONDBLCLK 163/g
|
||||
s/CYCLE 164 /WM_NCRBUTTONDOWN 164/g
|
||||
s/CYCLE 165 /WM_NCRBUTTONUP 165/g
|
||||
s/CYCLE 166 /WM_NCRBUTTONDBLCLK 166/g
|
||||
s/CYCLE 167 /WM_NCMBUTTONDOWN 167/g
|
||||
s/CYCLE 168 /WM_NCMBUTTONUP 168/g
|
||||
s/CYCLE 169 /WM_NCMBUTTONDBLCLK 169/g
|
||||
s/CYCLE 171 /WM_NCXBUTTONDOWN 171/g
|
||||
s/CYCLE 172 /WM_NCXBUTTONUP 172/g
|
||||
s/CYCLE 173 /WM_NCXBUTTONDBLCLK 173/g
|
||||
s/CYCLE 256 /WM_KEYDOWN 256/g
|
||||
s/CYCLE 256 /WM_KEYFIRST 256/g
|
||||
s/CYCLE 257 /WM_KEYUP 257/g
|
||||
s/CYCLE 258 /WM_CHAR 258/g
|
||||
s/CYCLE 259 /WM_DEADCHAR 259/g
|
||||
s/CYCLE 260 /WM_SYSKEYDOWN 260/g
|
||||
s/CYCLE 261 /WM_SYSKEYUP 261/g
|
||||
s/CYCLE 262 /WM_SYSCHAR 262/g
|
||||
s/CYCLE 263 /WM_SYSDEADCHAR 263/g
|
||||
s/CYCLE 264 /WM_KEYLAST 264/g
|
||||
s/CYCLE 272 /WM_INITDIALOG 271/g
|
||||
s/CYCLE 273 /WM_COMMAND 273/g
|
||||
s/CYCLE 274 /WM_SYSCOMMAND 274/g
|
||||
s/CYCLE 275 /WM_TIMER 275/g
|
||||
s/CYCLE 276 /WM_HSCROLL 276/g
|
||||
s/CYCLE 277 /WM_VSCROLL 277/g
|
||||
s/CYCLE 278 /WM_INITMENU 278/g
|
||||
s/CYCLE 279 /WM_INITMENUPOPUP 279/g
|
||||
s/CYCLE 287 /WM_MENUSELECT 287/g
|
||||
s/CYCLE 288 /WM_MENUCHAR 288/g
|
||||
s/CYCLE 289 /WM_ENTERIDLE 289/g
|
||||
s/CYCLE 290 /WM_MENURBUTTONUP 290/g
|
||||
s/CYCLE 306 /WM_CTLCOLORMSGBOX 306/g
|
||||
s/CYCLE 307 /WM_CTLCOLOREDIT 307/g
|
||||
s/CYCLE 308 /WM_CTLCOLORLISTBOX 308/g
|
||||
s/CYCLE 309 /WM_CTLCOLORBTN 309/g
|
||||
s/CYCLE 310 /WM_CTLCOLORDLG 310/g
|
||||
s/CYCLE 311 /WM_CTLCOLORSCROLLBAR 311/g
|
||||
s/CYCLE 312 /WM_CTLCOLORSTATIC 312/g
|
||||
s/CYCLE 512 /WM_MOUSEMOVE 512/g
|
||||
s/CYCLE 512 /WM_MOUSEFIRST 512/g
|
||||
s/CYCLE 513 /WM_LBUTTONDOWN 513/g
|
||||
s/CYCLE 514 /WM_LBUTTONUP 514/g
|
||||
s/CYCLE 515 /WM_LBUTTONDBLCLK 515/g
|
||||
s/CYCLE 516 /WM_RBUTTONDOWN 516/g
|
||||
s/CYCLE 517 /WM_RBUTTONUP 517/g
|
||||
s/CYCLE 518 /WM_RBUTTONDBLCLK 518/g
|
||||
s/CYCLE 519 /WM_MBUTTONDOWN 519/g
|
||||
s/CYCLE 520 /WM_MBUTTONUP 520/g
|
||||
s/CYCLE 521 /WM_MBUTTONDBLCLK 521/g
|
||||
s/CYCLE 522 /WM_MOUSEWHEEL 522/g
|
||||
s/CYCLE 522 /WM_MOUSELAST 522/g
|
||||
s/CYCLE 523 /WM_XBUTTONDOWN 523/g
|
||||
s/CYCLE 524 /WM_XBUTTONUP 524/g
|
||||
s/CYCLE 525 /WM_XBUTTONDBLCLK 525/g
|
||||
s/CYCLE 525 /WM_MOUSELAST 525/g
|
||||
s/CYCLE 528 /WM_PARENTNOTIFY 528/g
|
||||
s/CYCLE 529 /WM_ENTERMENULOOP 529/g
|
||||
s/CYCLE 530 /WM_EXITMENULOOP 530/g
|
||||
s/CYCLE 531 /WM_NEXTMENU 531/g
|
||||
s/CYCLE 531 /WM_NEXTMENU 531/g
|
||||
s/CYCLE 532 /WM_SIZING 532/g
|
||||
s/CYCLE 533 /WM_CAPTURECHANGED 533/g
|
||||
s/CYCLE 534 /WM_MOVING 534/g
|
||||
s/CYCLE 536 /WM_POWERBROADCAST 536/g
|
||||
s/CYCLE 537 /WM_DEVICECHANGE 537/g
|
||||
s/CYCLE 544 /WM_MDICREATE 544/g
|
||||
s/CYCLE 545 /WM_MDIDESTROY 545/g
|
||||
s/CYCLE 546 /WM_MDIACTIVATE 546/g
|
||||
s/CYCLE 547 /WM_MDIRESTORE 547/g
|
||||
s/CYCLE 548 /WM_MDINEXT 548/g
|
||||
s/CYCLE 549 /WM_MDIMAXIMIZE 549/g
|
||||
s/CYCLE 550 /WM_MDITILE 550/g
|
||||
s/CYCLE 551 /WM_MDICASCADE 551/g
|
||||
s/CYCLE 552 /WM_MDIICONARRANGE 552/g
|
||||
s/CYCLE 553 /WM_MDIGETACTIVE 553/g
|
||||
s/CYCLE 560 /WM_MDISETMENU 560/g
|
||||
s/CYCLE 561 /WM_ENTERSIZEMOVE 561/g
|
||||
s/CYCLE 562 /WM_EXITSIZEMOVE 562/g
|
||||
s/CYCLE 563 /WM_DROPFILES 563/g
|
||||
s/CYCLE 564 /WM_MDIREFRESHMENU 564/g
|
||||
s/CYCLE 768 /WM_CUT 768/g
|
||||
s/CYCLE 769 /WM_COPY 769/g
|
||||
s/CYCLE 770 /WM_PASTE 770/g
|
||||
s/CYCLE 771 /WM_CLEAR 771/g
|
||||
s/CYCLE 772 /WM_UNDO 772/g
|
||||
s/CYCLE 773 /WM_RENDERFORMAT 773/g
|
||||
s/CYCLE 774 /WM_RENDERALLFORMATS 774/g
|
||||
s/CYCLE 775 /WM_DESTROYCLIPBOARD 775/g
|
||||
s/CYCLE 776 /WM_DRAWCLIPBOARD 776/g
|
||||
s/CYCLE 777 /WM_PAINTCLIPBOARD 777/g
|
||||
s/CYCLE 778 /WM_VSCROLLCLIPBOARD 778/g
|
||||
s/CYCLE 779 /WM_SIZECLIPBOARD 779/g
|
||||
s/CYCLE 780 /WM_ASKCBFORMATNAME 780/g
|
||||
s/CYCLE 781 /WM_CHANGECBCHAIN 781/g
|
||||
s/CYCLE 782 /WM_HSCROLLCLIPBOARD 782/g
|
||||
s/CYCLE 783 /WM_QUERYNEWPALETTE 783/g
|
||||
s/CYCLE 784 /WM_PALETTEISCHANGING 784/g
|
||||
s/CYCLE 785 /WM_PALETTECHANGED 785/g
|
||||
s/CYCLE 786 /WM_HOTKEY 786/g
|
||||
s/CYCLE 791 /WM_PRINT 791/g
|
||||
s/CYCLE 792 /WM_PRINTCLIENT 792/g
|
||||
s/CYCLE 794 /WM_THEMECHANGED 794/g
|
||||
s/CYCLE 856 /WM_HANDHELDFIRST 856/g
|
||||
s/CYCLE 863 /WM_HANDHELDLAST 863/g
|
||||
s/CYCLE 864 /WM_AFXFIRST 864/g
|
||||
s/CYCLE 895 /WM_AFXLAST 895/g
|
||||
s/CYCLE 896 /WM_PENWINFIRST 896/g
|
||||
s/CYCLE 911 /WM_PENWINLAST 911/g
|
||||
s/CYCLE 1024 /WM_USER 1024/g
|
||||
s/CYCLE 32768 /WM_APP 32768/g
|
||||
s/CYCLE 0x0123 /WM_MENUDRAG 0x0123/g
|
||||
s/CYCLE 0x0124 /WM_MENUGETOBJECT 0x0124/g
|
||||
s/CYCLE 0x0125 /WM_UNINITMENUPOPUP 0x0125/g
|
||||
s/CYCLE 0x0126 /WM_MENUCOMMAND 0x0126/g
|
||||
s/CYCLE 0x02A0 /WM_NCMOUSEHOVER 0x02A0/g
|
||||
s/CYCLE 0x02A2 /WM_NCMOUSELEAVE 0x02A2/g
|
||||
s/CYCLE 0x2A1 /WM_MOUSEHOVER 0x2A1/g
|
||||
s/CYCLE 0x2A3 /WM_MOUSELEAVE 0x2A3/g
|
||||
s/NEW EVENT WM_LBUTTONUP 514/\n\n\n\n******************************* NEW EVENT COMBO ON WM_LBUTTONUP 514 ***********************************/g
|
||||
#state Formats
|
||||
s/STATE 1/WA_ACTIVE (1) - deactivate (lParam)/g
|
||||
s/STATE 2/WA_CLICKACTIVE (2) - deactivate (lParam) /g
|
||||
s/STATE 0/WA_INACTIVE (0) - activate (lParam)/g
|
||||
#window styles
|
||||
s/Extended Style 16/WS_EX_ACCEPTFILES 16/g
|
||||
s/Extended Style 262144/WS_EX_APPWINDOW 262144/g
|
||||
s/Extended Style 512/WS_EX_CLIENTEDGE 512/g
|
||||
s/Extended Style 33554432/WS_EX_COMPOSITED 33554432/g
|
||||
s/Extended Style 1024/WS_EX_CONTEXTHELP 1024/g
|
||||
s/Extended Style 65536/WS_EX_CONTROLPARENT 65536/g
|
||||
s/Extended Style 16384/WS_EX_LEFTSCROLLBAR 16384/g
|
||||
s/Extended Style 134217728/WS_EX_NOACTIVATE 134217728/g
|
||||
s/Extended Style 1048576/WS_EX_NOINHERITLAYOUT 1048576/g
|
||||
s/Extended Style 4/WS_EX_NOPARENTNOTIFY 4/g
|
||||
s/Extended Style 392/WS_EX_PALETTEWINDOW 392/g
|
||||
s/Extended Style 768/WS_EX_OVERLAPPEDWINDOW 768/g
|
||||
s/Extended Style 4096/WS_EX_RIGHT 4096/g
|
||||
s/Extended Style 0/WS_EX_RIGHTSCROLLBAR 0/g
|
||||
s/Extended Style 131072/WS_EX_STATICEDGE 131072/g
|
||||
s/Extended Style 32/WS_EX_TRANSPARENT 32/g
|
||||
s/Extended Style 256/WS_EX_WINDOWEDGE 256/g
|
||||
s/Extended Style 128/WS_EX_TOOLWINDOW 128/g
|
||||
# size flags
|
||||
s/SIZE_FLAG is 4/SIZE_MAXHIDE (4)/g
|
||||
s/SIZE_FLAG is 2/SIZE_MAXIMIZED (2)/g
|
||||
s/SIZE_FLAG is 3/SIZE_MAXSHOW (3)/g
|
||||
s/SIZE_FLAG is 1/SIZE_MINIMIZED (1)/g
|
||||
s/SIZE_FLAG is 0/SIZE_RESTORED (0)/g
|
||||
# Event Type
|
||||
s/EventType 0/NSLeftMouseDown/g
|
||||
s/EventType 1/NSLeftMouseUp/g
|
||||
s/EventType 2/NSOtherMouseDown/g
|
||||
s/EventType 3/NSOtherMouseUp/g
|
||||
s/EventType 4/NSRightMouseDown/g
|
||||
s/EventType 5/NSRightMouseUp/g
|
||||
s/EventType 6/NSMouseMoved/g
|
||||
s/EventType 7/NSLeftMouseDragged/g
|
||||
s/EventType 8/NSOtherMouseDragged/g
|
||||
s/EventType 9/NSRightMouseDragged/g
|
||||
s/EventType 10/NSMouseEntered/g
|
||||
s/EventType 11/NSMouseExited/g
|
||||
s/EventType 12/NSKeyDown/g
|
||||
s/EventType 13/NSKeyUp/g
|
||||
s/EventType 14/NSFlagsChanged/g
|
||||
s/EventType 15/NSAppKitDefined/g
|
||||
s/EventType 16/NSSystemDefined/g
|
||||
s/EventType 17/NSApplicationDefined/g
|
||||
s/EventType 18/NSPeriodic/g
|
||||
s/EventType 19/NSCursorUpdate/g
|
||||
s/EventType 20/NSScrollWheel/g
|
||||
#show window
|
||||
s/SW_FLAG 4/SW_OTHERUNZOOM 4/g
|
||||
s/SW_FLAG 2/SW_OTHERZOOM 2/g
|
||||
s/SW_FLAG 1/SW_PARENTCLOSING 1/g
|
||||
s/SW_FLAG 3/SW_PARENTOPENING 3/g
|
||||
s/SW_FLAG 0/ZERO 0/g
|
||||
#Gnustep state flags
|
||||
s/MENU item state is 0/NSOffState 0/g
|
||||
s/MENU item state is 1/NSOnState 1/g
|
||||
s/MENU item state is -1/NSMixedState -1/g
|
||||
#
|
||||
#GS eventTypes
|
||||
#
|
||||
s/GSMouse_EVENT 0/NSLeftMouseDown 0/g
|
||||
#s/GSMouse_EVENT 1/NSLeftMouseUp 1/g
|
||||
s/GSMouse_EVENT 2/NSOtherMouseDown 2/g
|
||||
s/GSMouse_EVENT 3/NSOtherMouseUp 3/g
|
||||
s/GSMouse_EVENT 4/NSRightMouseDown 4/g
|
||||
#s/GSMouse_EVENT 5/NSRightMouseUp 5/g
|
||||
s/GSMouse_EVENT 6/NSMouseMoved 6/g
|
||||
s/GSMouse_EVENT 7/NSLeftMouseDragged 7/g
|
||||
s/GSMouse_EVENT 8/NSOtherMouseDragged 8/g
|
||||
s/GSMouse_EVENT 9/NSRightMouseDragged 9/g
|
||||
s/GSMouse_EVENT 10/NSMouseEntered 10/g
|
||||
s/GSMouse_EVENT 11/NSMouseExited 11/g
|
||||
s/GSKeyboard_EVENT 12/NSKeyDown 12/g
|
||||
s/GSKeyboard_EVENT 13/NSKeyUp 13/g
|
||||
s/GS_EVENT 14/NSFlagsChanged 14/g
|
||||
s/GS_EVENT 15/NSAppKitDefined 15/g
|
||||
s/GS_EVENT 16/NSSystemDefined 16/g
|
||||
s/GS_EVENT 17/NSApplicationDefined 17/g
|
||||
s/GS_EVENT 18/NSPeriodic 18/g
|
||||
s/GS_EVENT 19/NSCursorUpdate 19/g
|
||||
s/GS_EVENT 20/NSScrollWheel 20/g
|
||||
#
|
||||
#GS_SUBTYPES
|
||||
#
|
||||
s/GS_SUBTYPE 1/GSAppKitWindowMoved 1/g
|
||||
s/GS_SUBTYPE 2/GSAppKitWindowResized 2/g
|
||||
s/GS_SUBTYPE 3/GSAppKitWindowClose 3/g
|
||||
s/GS_SUBTYPE 4/GSAppKitWindowMiniaturize 4/g
|
||||
s/GS_SUBTYPE 5/GSAppKitWindowFocusIn 5/g
|
||||
s/GS_SUBTYPE 6/GSAppKitWindowFocusOut 6/g
|
||||
s/GS_SUBTYPE 7/GSAppKitWindowLeave 7/g
|
||||
s/GS_SUBTYPE 8/GSAppKitWindowEnter 8/g
|
||||
s/GS_SUBTYPE 9/GSAppKitDraggingEnter 9/g
|
||||
s/GS_SUBTYPE 10/GSAppKitDraggingUpdate 10/g
|
||||
s/GS_SUBTYPE 11/GSAppKitDraggingStatus 11/g
|
||||
s/GS_SUBTYPE 12/GSAppKitDraggingExit 12/g
|
||||
s/GS_SUBTYPE 13/GSAppKitDraggingDrop 13/g
|
||||
s/GS_SUBTYPE 14/GSAppKitDraggingFinished 14/g
|
||||
|
||||
#finalize format
|
||||
s/+//g
|
||||
s/*//g
|
||||
s/#//g
|
||||
s/=//g
|
||||
s/ / /g
|
||||
s/NEW EVENT COMBO ON WM_LBUTTONUP 514/NEW CYCLE/g
|
||||
s/NEW EVENT/NEW EVENT\n/g
|
||||
s/\n\n/\n/g
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -36,13 +36,22 @@ include ../../config.make
|
|||
# The library to be compiled, as a library or as a bundle
|
||||
SUBPROJECT_NAME=win32
|
||||
|
||||
win32_LOCALIZED_RESOURCE_FILES = \
|
||||
|
||||
# The C source files to be compiled
|
||||
win32_C_FILES = \
|
||||
|
||||
# The Objective-C source files to be compiled
|
||||
win32_OBJC_FILES = \
|
||||
WIN32Server.m \
|
||||
WIN32ServerEvent.m
|
||||
w32_debug.m \
|
||||
w32_activate.m \
|
||||
w32_create.m \
|
||||
w32_general.m \
|
||||
w32_movesize.m \
|
||||
w32_text_focus.m \
|
||||
w32_windowdisplay.m \
|
||||
GSDisplayServer_details.m \
|
||||
|
||||
-include GNUmakefile.preamble
|
||||
|
||||
|
|
68
Source/win32/GSDisplayServer_details.m
Normal file
68
Source/win32/GSDisplayServer_details.m
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <GNUstepGUI/GSDisplayServer.h>
|
||||
#include "w32_events.h"
|
||||
|
||||
@implementation GSDisplayServer (GSDisplayServer_details)
|
||||
|
||||
- (int) eventQueCount
|
||||
{
|
||||
return [event_queue count];
|
||||
}
|
||||
|
||||
- (NSMutableString *) dumpQue:(int)acount
|
||||
{
|
||||
NSMutableString * output=[NSMutableString stringWithCString:"Dumping "];
|
||||
|
||||
int i=0;
|
||||
int c=[event_queue count];
|
||||
if (acount >=c || acount==0)
|
||||
acount=c;
|
||||
else
|
||||
c=acount;
|
||||
|
||||
if(c==0)
|
||||
{
|
||||
[output appendString:@"0 Events Que is empty\n"];
|
||||
return output;
|
||||
}
|
||||
|
||||
[output appendFormat:@"%d From the EventQue\n-> ",c];
|
||||
|
||||
for (i=0;i<c;i++)
|
||||
{
|
||||
[output appendFormat:@"%d EventType %d\n-> "
|
||||
,i,[(NSEvent *)[event_queue objectAtIndex:i] type]];
|
||||
}
|
||||
[output appendString:@"\n"];
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
- (void) clearEventQue
|
||||
{
|
||||
[event_queue removeAllObjects];
|
||||
}
|
||||
|
||||
@end
|
209
Source/win32/RELEASE_NOTES
Normal file
209
Source/win32/RELEASE_NOTES
Normal file
|
@ -0,0 +1,209 @@
|
|||
August 22, 2005
|
||||
|
||||
CYGWIN 1.5.17(0.129/4/2) or higher
|
||||
CYGWIN CYGWIN_NT-5.1
|
||||
CYGWIN 2005-05-25 19:38
|
||||
|
||||
Project OverView:
|
||||
I started this to simply fix the display of toolbars under cygwin...
|
||||
Well I wound up doing a whole lot more:
|
||||
|
||||
Fixed in this release
|
||||
view resizing issues related to toolbars and minimizing of windows
|
||||
|
||||
application hiding - main menu has a taskbar icon everything else hides
|
||||
|
||||
Menu positioning bug - on activate after a hide - menu now does what it should
|
||||
|
||||
App windows - now have a named taskbar icon
|
||||
|
||||
window styles mapping - completed but not implimented; A future release will
|
||||
support native win32 decorations.
|
||||
|
||||
tear off Menus - now have a close button and an icon on the taskbar
|
||||
|
||||
Context Menu - working much better not fully completed but very usable
|
||||
|
||||
notifications - backend now receives key notifications from the App that it is
|
||||
displaying. see details view for more info.
|
||||
|
||||
structure - backend is more managable with event type catagories.
|
||||
It will also support subclassing more easily.
|
||||
Positioned for a native backend implimentation (future)
|
||||
Other window evwnts not currently managed are stubbed and ready for
|
||||
a future release
|
||||
|
||||
debugging - with the right defines the backend will produce rich and readable
|
||||
log files. See detail in the details view
|
||||
|
||||
|
||||
|
||||
details view:
|
||||
|
||||
Styles are mapped between the two systems note that this release does not
|
||||
utilize them but I have left them here for a future release.
|
||||
|
||||
I have also removed the check for useWMTaskBar in this release. behavior is native
|
||||
win32 - at this point I do not have gworkspace running under cygwin so it is not
|
||||
relivant.
|
||||
|
||||
I do not use the handlesWindowDecorations in my code but it is still set for use
|
||||
by the original code. I have not changed current inplimentation of mouse or keyboard
|
||||
events.
|
||||
|
||||
The WM_SETTEXT is removed from the event loop. win32 will handle this nicely for us.
|
||||
It will give us nice taskbar icons with window titles!
|
||||
|
||||
Window events are not posted - window events are either handled directly by the server
|
||||
or are sent directly to the window that they were called on using:
|
||||
|
||||
[EVENT_WINDOW(hwnd) sendEvent:anEvent]
|
||||
|
||||
This fixes any issues with view related display problems... like toolbars for example.
|
||||
Mouse and Keyboard events are posted and qued as usual.
|
||||
|
||||
|
||||
New debug features: controls are found in w32_config.h
|
||||
|
||||
#define _logging
|
||||
use to log messages to NSDebuglog
|
||||
|
||||
define any of these at compile time or uncomment them in the w32_config.h
|
||||
and get a bucket to catch stdout!
|
||||
|
||||
note: do not divert the out put from these next defines to NSDebuglog
|
||||
there is so much data that it will clog the works.
|
||||
I also do not recommend these be used unless you are debugging
|
||||
the back end
|
||||
#define __W32_debug__
|
||||
activate the debug code in the main event server
|
||||
output is to standard out only
|
||||
|
||||
#define __W32_debug_Event_loop
|
||||
special flag for event loops and counts all posted events are
|
||||
displayed in the log file.
|
||||
__W32_debug__ must be defined for this to work
|
||||
output is to standard out only
|
||||
|
||||
#define __STATE (YES or NO)
|
||||
when set to yes, events that are not currently implimented but monitered
|
||||
in the event loop will be included in the log output
|
||||
__W32_debug__ must be defined for this to work
|
||||
output is to standard out only
|
||||
|
||||
Event_format.sed
|
||||
pipe the output through sed with this file and it will clean up the
|
||||
output and make it more reader friendly.
|
||||
|
||||
|
||||
Notifications:
|
||||
|
||||
The backend now has better communication between it and the application.
|
||||
A display server needs to know what the app is doing in order to manage the
|
||||
task of displaying windows for it. To that end the backend is registerd for
|
||||
the following notifications:
|
||||
|
||||
NSApplicationWillHideNotification
|
||||
Catch the hide event and set flags so that the backend will defer
|
||||
to the native server (winxp NT or 9x) and allow the App to hide.
|
||||
|
||||
NSApplicationWillFinishLaunching
|
||||
registered but not utilized at this point (planned future development)
|
||||
|
||||
NSApplicationDidFinishLaunching
|
||||
Catch the main menu and finalize its setup for use in the win32
|
||||
environment. I have used some native win32 code here to accomplish
|
||||
this task. In future other tasks could also be carried out here.
|
||||
|
||||
NSWindowWillMiniaturizeNotification
|
||||
Basically this is done for the same reason as catching the hide.
|
||||
Set flags so that the backend will defer to the native server
|
||||
(winxp NT or 9x) and allow the window to miniturize without disturbing
|
||||
the views that it contains.
|
||||
|
||||
The next two Notifications are custom and unique to the win32 server and
|
||||
are implimented to manage specific menu events. I have overriden two internal
|
||||
NSMenu methods so that the notifications get sent. See notes on overrides.
|
||||
|
||||
NSMenuWillTearOff
|
||||
Set the win32 style on the menu window so that it will display an icon on
|
||||
the taskbar with a title. A tear of menu will always have a title that
|
||||
looks like: 'MENU submenu title' this makes it easy to find a tear off menu
|
||||
that could be hidden under any number of other windows.
|
||||
|
||||
NSMenuwillPopUP
|
||||
This allows the backend to setup and manage the behavior of a context
|
||||
menu in the win32 environment. This is not fully implimented but the
|
||||
behavior of the context menu is greatly improved. More work will be done
|
||||
on this in s future release.
|
||||
|
||||
Note: when debug is active (#define __W32_debug__) the server will register for all
|
||||
NSWindow notifications and some NSView notifications. Helps to show where
|
||||
appevents and server events are happening relitive to each other.
|
||||
these are all dumpted to a formatter for display in the log output.
|
||||
|
||||
Overrides of key methods:
|
||||
|
||||
In order the get the behavior I wanted the following methods from NSMenu
|
||||
have been overriden:
|
||||
|
||||
- (void) _rightMouseDisplay: (NSEvent*)theEvent;
|
||||
Modified by override to send NSMenuwillPopUP notification to the server.
|
||||
|
||||
- (void) setTornOff: (BOOL)flag;
|
||||
Modified by override to send NSMenuWillTearOff notification to the server
|
||||
|
||||
code Organization:
|
||||
|
||||
The code has been restructured to allow for more flexibility, managability and
|
||||
future development. The main event code is organized as catagories of
|
||||
WIN32Server in the following files:
|
||||
|
||||
w32_config.h: manage all of the defines need to control the debug output
|
||||
w32_debug.m: all of the main debug log generation is done here
|
||||
GSDisplayServer_details.m: (special catagory for debug hooks)
|
||||
|
||||
WIN32Server.m: main entry point for event handling
|
||||
|
||||
w32_Events.h: declarations of catagories and methods implimented in
|
||||
the follow files (see the code for more details)
|
||||
|
||||
w32_activate.m
|
||||
w32_create.m
|
||||
w32_debug.m
|
||||
w32_general.m
|
||||
w32_movesize.m
|
||||
w32_text_focus.m
|
||||
w32_windowdisplay.m
|
||||
|
||||
|
||||
Future release:
|
||||
|
||||
complete context menu handling
|
||||
|
||||
Fully impliment window style mapping to allow for native win32 look.
|
||||
|
||||
More robust window registration under win32.
|
||||
|
||||
Parent - child window mapping down to the win32 level. This should give access
|
||||
to more events and improve server to server communication, and hopfully
|
||||
get a step closer to native evwent handling.
|
||||
|
||||
display of custom app icons on the taskbar.
|
||||
|
||||
Rect tracing when resizing windows
|
||||
|
||||
log file manager; this is allready in progress but not ready for release
|
||||
|
||||
integration with GSWorkspace
|
||||
|
||||
re impliment keyboard events so that cut copy past and other key equivilents work
|
||||
|
||||
Final closing remarks:
|
||||
I think I have addressed most if not all of the major issues with the win32backend...
|
||||
|
||||
PLEASE try it out and send FEEDBACK
|
||||
|
||||
Tom MacSween
|
||||
macsweent@sympatico.ca
|
||||
|
File diff suppressed because it is too large
Load diff
|
@ -1,955 +0,0 @@
|
|||
/* WIN32ServerEvent - Implements event handling for MSWindows
|
||||
|
||||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
#include <AppKit/AppKitExceptions.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSCursor.h>
|
||||
#include <AppKit/NSText.h>
|
||||
#include <AppKit/DPSOperators.h>
|
||||
|
||||
#include "win32/WIN32Server.h"
|
||||
#include "win32/WIN32Geometry.h"
|
||||
|
||||
/*
|
||||
This standard windows macros are missing in MinGW. The definition
|
||||
here is almost correct, but will fail for multi monitor systems
|
||||
*/
|
||||
#ifndef GET_X_LPARAM
|
||||
#define GET_X_LPARAM(p) ((int)(short)LOWORD(p))
|
||||
#endif
|
||||
#ifndef GET_Y_LPARAM
|
||||
#define GET_Y_LPARAM(p) ((int)(short)HIWORD(p))
|
||||
#endif
|
||||
|
||||
static NSEvent *process_key_event(HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||
NSEventType eventType);
|
||||
static NSEvent *process_mouse_event(HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||
NSEventType eventType);
|
||||
static void invalidateWindow(HWND hwnd, RECT rect);
|
||||
|
||||
@interface WIN32Server (Internal)
|
||||
- (NSEvent *) handleGotFocus: (HWND)hwnd;
|
||||
- (NSEvent *) handleMoveSize: (HWND)hwnd
|
||||
: (GSAppKitSubtype) subtype;
|
||||
- (void) resizeBackingStoreFor: (HWND)hwnd;
|
||||
- (LRESULT) windowEventProc: (HWND)hwnd : (UINT)uMsg
|
||||
: (WPARAM)wParam : (LPARAM)lParam;
|
||||
@end
|
||||
|
||||
@implementation WIN32Server (EventOps)
|
||||
|
||||
- (void) callback: (id) sender
|
||||
{
|
||||
MSG msg;
|
||||
WINBOOL bRet;
|
||||
|
||||
while ((bRet = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) != 0)
|
||||
{
|
||||
|
||||
if (msg.message == WM_QUIT)
|
||||
{
|
||||
// Exit the program
|
||||
return;
|
||||
}
|
||||
if (bRet == -1)
|
||||
{
|
||||
// handle the error and possibly exit
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't translate messages, as this would give extra character messages.
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) hasEvent
|
||||
{
|
||||
return (GetQueueStatus(QS_ALLEVENTS) != 0);
|
||||
}
|
||||
|
||||
- (void) receivedEvent: (void*)data
|
||||
type: (RunLoopEventType)type
|
||||
extra: (void*)extra
|
||||
forMode: (NSString*)mode
|
||||
{
|
||||
[self callback: mode];
|
||||
}
|
||||
|
||||
|
||||
- (NSEvent*) getEventMatchingMask: (unsigned)mask
|
||||
beforeDate: (NSDate*)limit
|
||||
inMode: (NSString*)mode
|
||||
dequeue: (BOOL)flag
|
||||
{
|
||||
[self callback: nil];
|
||||
return [super getEventMatchingMask: mask
|
||||
beforeDate: limit
|
||||
inMode: mode
|
||||
dequeue: flag];
|
||||
}
|
||||
|
||||
- (void) discardEventsMatchingMask: (unsigned)mask
|
||||
beforeEvent: (NSEvent*)limit
|
||||
{
|
||||
[self callback: nil];
|
||||
[super discardEventsMatchingMask: mask
|
||||
beforeEvent: limit];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation WIN32Server (Internal)
|
||||
|
||||
/* This message comes when the window already got focus, so we send a focus
|
||||
in event to the front end, but also mark the window as having current focus
|
||||
so that the front end doesn't try to focus the window again. */
|
||||
- (NSEvent *) handleGotFocus: (HWND)hwnd
|
||||
{
|
||||
int key_num, win_num;
|
||||
NSEvent *e = nil;
|
||||
NSPoint eventLocation;
|
||||
|
||||
key_num = [[NSApp keyWindow] windowNumber];
|
||||
win_num = (int)hwnd;
|
||||
NSDebugLLog(@"Focus", @"Got focus:%d (current = %d, key = %d)",
|
||||
win_num, currentFocus, key_num);
|
||||
currentFocus = hwnd;
|
||||
eventLocation = NSMakePoint(0,0);
|
||||
if (currentFocus == desiredFocus)
|
||||
{
|
||||
/* This was from a request from the front end. Mark as done. */
|
||||
desiredFocus = 0;
|
||||
NSDebugLLog(@"Focus", @" result of focus request");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We need to do this directly and not send an event to the frontend -
|
||||
that's too slow and allows the window state to get out of sync,
|
||||
causing bad recursion problems */
|
||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
||||
if ([window canBecomeKeyWindow] == YES)
|
||||
{
|
||||
NSDebugLLog(@"Focus", @"Making %d key", win_num);
|
||||
[window makeKeyWindow];
|
||||
[window makeMainWindow];
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
- (NSEvent *) handleMoveSize: (HWND)hwnd
|
||||
: (GSAppKitSubtype) subtype
|
||||
{
|
||||
NSPoint eventLocation;
|
||||
NSRect rect;
|
||||
RECT r;
|
||||
NSEvent *ev = nil;
|
||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
||||
|
||||
GetWindowRect(hwnd, &r);
|
||||
rect = MSScreenRectToGS(r, [window styleMask], self);
|
||||
eventLocation = rect.origin;
|
||||
|
||||
if (window)
|
||||
{
|
||||
if( subtype == GSAppKitWindowMoved )
|
||||
{
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowMoved
|
||||
data1: rect.origin.x
|
||||
data2: rect.origin.y];
|
||||
}
|
||||
else if( subtype == GSAppKitWindowResized )
|
||||
{
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int) hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowResized
|
||||
data1: rect.size.width
|
||||
data2: rect.size.height];
|
||||
}
|
||||
else
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
return ev;
|
||||
}
|
||||
|
||||
- (void) resizeBackingStoreFor: (HWND)hwnd
|
||||
{
|
||||
RECT r;
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)hwnd, GWL_USERDATA);
|
||||
|
||||
// FIXME: We should check if the size really did change.
|
||||
if (win->useHDC)
|
||||
{
|
||||
HDC hdc, hdc2;
|
||||
HBITMAP hbitmap;
|
||||
HGDIOBJ old;
|
||||
|
||||
old = SelectObject(win->hdc, win->old);
|
||||
DeleteObject(old);
|
||||
DeleteDC(win->hdc);
|
||||
win->hdc = NULL;
|
||||
win->old = NULL;
|
||||
|
||||
GetClientRect((HWND)hwnd, &r);
|
||||
NSDebugLLog(@"NSEvent", @"Change backing store to %d %d", r.right - r.left, r.bottom - r.top);
|
||||
hdc = GetDC((HWND)hwnd);
|
||||
hdc2 = CreateCompatibleDC(hdc);
|
||||
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
|
||||
win->old = SelectObject(hdc2, hbitmap);
|
||||
win->hdc = hdc2;
|
||||
|
||||
ReleaseDC((HWND)hwnd, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
- (LRESULT) windowEventProc: (HWND)hwnd : (UINT)uMsg
|
||||
: (WPARAM)wParam : (LPARAM)lParam
|
||||
{
|
||||
NSEvent *ev = nil;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_SETTEXT:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SETTEXT", hwnd);
|
||||
break;
|
||||
case WM_NCCREATE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCCREATE", hwnd);
|
||||
break;
|
||||
case WM_NCCALCSIZE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCCALCSIZE", hwnd);
|
||||
break;
|
||||
case WM_NCACTIVATE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d: %s", "NCACTIVATE",
|
||||
hwnd, (wParam) ? "active" : "deactive");
|
||||
break;
|
||||
case WM_NCPAINT:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCPAINT", hwnd);
|
||||
break;
|
||||
case WM_NCHITTEST:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCHITTEST", hwnd);
|
||||
break;
|
||||
case WM_SHOWWINDOW:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d: %s %d", "SHOWWINDOW",
|
||||
hwnd, (wParam) ? "show" : "hide", lParam);
|
||||
break;
|
||||
case WM_NCMOUSEMOVE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCMOUSEMOVE", hwnd);
|
||||
break;
|
||||
case WM_NCLBUTTONDOWN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCLBUTTONDOWN", hwnd);
|
||||
break;
|
||||
case WM_NCLBUTTONUP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCLBUTTONUP", hwnd);
|
||||
break;
|
||||
case WM_NCDESTROY:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "NCDESTROY", hwnd);
|
||||
break;
|
||||
case WM_GETTEXT:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "GETTEXT", hwnd);
|
||||
break;
|
||||
case WM_STYLECHANGING:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "STYLECHANGING", hwnd);
|
||||
break;
|
||||
case WM_STYLECHANGED:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "STYLECHANGED", hwnd);
|
||||
break;
|
||||
|
||||
case WM_GETMINMAXINFO:
|
||||
{
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
MINMAXINFO *mm;
|
||||
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "GETMINMAXINFO", hwnd);
|
||||
if (win != NULL)
|
||||
{
|
||||
mm = (MINMAXINFO*)lParam;
|
||||
mm->ptMinTrackSize = win->minmax.ptMinTrackSize;
|
||||
mm->ptMaxTrackSize = win->minmax.ptMaxTrackSize;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case WM_CREATE:
|
||||
{
|
||||
WIN_INTERN *win;
|
||||
NSBackingStoreType type = (NSBackingStoreType)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
|
||||
// Initialize the window.
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "CREATE", hwnd);
|
||||
/* For windows with backingstore we create a compatible DC, that
|
||||
is stored in the extra fields for this window. Drawing operations
|
||||
work on this buffer. */
|
||||
win = objc_malloc(sizeof(WIN_INTERN));
|
||||
SetWindowLong(hwnd, GWL_USERDATA, (int)win);
|
||||
|
||||
if (type != NSBackingStoreNonretained)
|
||||
{
|
||||
HDC hdc, hdc2;
|
||||
HBITMAP hbitmap;
|
||||
RECT r;
|
||||
|
||||
GetClientRect((HWND)hwnd, &r);
|
||||
hdc = GetDC(hwnd);
|
||||
hdc2 = CreateCompatibleDC(hdc);
|
||||
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left,
|
||||
r.bottom - r.top);
|
||||
win->old = SelectObject(hdc2, hbitmap);
|
||||
|
||||
win->hdc = hdc2;
|
||||
win->useHDC = YES;
|
||||
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
else
|
||||
{
|
||||
win->useHDC = NO;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_WINDOWPOSCHANGING:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "WINDOWPOSCHANGING", hwnd);
|
||||
break;
|
||||
case WM_WINDOWPOSCHANGED:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "WINDOWPOSCHANGED", hwnd);
|
||||
break;
|
||||
case WM_MOVE:
|
||||
{
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOVE", hwnd);
|
||||
ev = [self handleMoveSize: hwnd : GSAppKitWindowMoved];
|
||||
break;
|
||||
}
|
||||
case WM_MOVING:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOVING", hwnd);
|
||||
break;
|
||||
case WM_SIZE:
|
||||
{
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SIZE", hwnd);
|
||||
ev = [self handleMoveSize: hwnd : GSAppKitWindowResized];
|
||||
break;
|
||||
}
|
||||
case WM_SIZING:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SIZING", hwnd);
|
||||
break;
|
||||
case WM_ENTERSIZEMOVE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "ENTERSIZEMOVE", hwnd);
|
||||
break;
|
||||
case WM_EXITSIZEMOVE:
|
||||
{
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "EXITSIZEMOVE", hwnd);
|
||||
[self resizeBackingStoreFor: hwnd];
|
||||
ev = [self handleMoveSize: hwnd : GSAppKitWindowMoved];
|
||||
if (ev != nil)
|
||||
{
|
||||
[GSCurrentServer() postEvent: ev atStart: NO];
|
||||
}
|
||||
ev = [self handleMoveSize: hwnd : GSAppKitWindowResized];
|
||||
if (ev != nil)
|
||||
{
|
||||
[GSCurrentServer() postEvent: ev atStart: NO];
|
||||
}
|
||||
// Make sure DefWindowProc gets called
|
||||
ev = nil;
|
||||
break;
|
||||
}
|
||||
case WM_ACTIVATE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d: %s %d", "ACTIVATE",
|
||||
hwnd, (LOWORD(wParam)) ? "activate" : "deactivate",
|
||||
HIWORD(wParam));
|
||||
if (LOWORD(wParam))
|
||||
currentActive = hwnd;
|
||||
break;
|
||||
case WM_ACTIVATEAPP:
|
||||
{
|
||||
int special;
|
||||
BOOL active = [NSApp isActive];
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d: %s (app is %s)",
|
||||
"ACTIVATEAPP", hwnd, (wParam) ? "activate" : "deactivate",
|
||||
(active) ? "active" : "deactivated");
|
||||
special = [[[NSApp mainMenu] window] windowNumber];
|
||||
if (active == NO && wParam)
|
||||
{
|
||||
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
}
|
||||
else if (special == (int)hwnd && active == YES && wParam == 0)
|
||||
[NSApp deactivate];
|
||||
}
|
||||
break;
|
||||
case WM_MOUSEACTIVATE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEACTIVATE", hwnd);
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
{
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SETFOCUS", hwnd);
|
||||
ev = [self handleGotFocus: hwnd];
|
||||
break;
|
||||
}
|
||||
case WM_KILLFOCUS:
|
||||
{
|
||||
NSPoint eventLocation = NSMakePoint(0,0);
|
||||
|
||||
if (wParam == (int)hwnd)
|
||||
return 0;
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "KILLFOCUS", hwnd);
|
||||
NSDebugLLog(@"Focus", @"Got KILLFOCUS (focus out) for %d", hwnd);
|
||||
ev = [NSEvent otherEventWithType:NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowFocusOut
|
||||
data1: 0
|
||||
data2: 0];
|
||||
break;
|
||||
}
|
||||
case WM_SETCURSOR:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SETCURSOR", hwnd);
|
||||
break;
|
||||
case WM_QUERYOPEN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "QUERYOPEN", hwnd);
|
||||
break;
|
||||
case WM_CAPTURECHANGED:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "CAPTURECHANGED", hwnd);
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "ERASEBKGND", hwnd);
|
||||
// Handle background painting ourselves.
|
||||
return (LRESULT)1;
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
RECT rect;
|
||||
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "PAINT", hwnd);
|
||||
if (GetUpdateRect(hwnd, &rect, NO))
|
||||
{
|
||||
invalidateWindow(hwnd, rect);
|
||||
// validate the whole window, for in some cases an infinite series
|
||||
// of WM_PAINT is triggered
|
||||
ValidateRect(hwnd, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
case WM_SYNCPAINT:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SYNCPAINT", hwnd);
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
NSPoint eventLocation = NSMakePoint(0,0);
|
||||
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "CLOSE", hwnd);
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowClose
|
||||
data1: 0
|
||||
data2: 0];
|
||||
break;
|
||||
}
|
||||
case WM_DESTROY:
|
||||
{
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
|
||||
// Clean up window-specific data objects.
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "DESTROY", hwnd);
|
||||
|
||||
if (win->useHDC)
|
||||
{
|
||||
HGDIOBJ old;
|
||||
|
||||
old = SelectObject(win->hdc, win->old);
|
||||
DeleteObject(old);
|
||||
DeleteDC(win->hdc);
|
||||
}
|
||||
objc_free(win);
|
||||
break;
|
||||
}
|
||||
case WM_KEYDOWN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "KEYDOWN", hwnd);
|
||||
ev = process_key_event(hwnd, wParam, lParam, NSKeyDown);
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "KEYUP", hwnd);
|
||||
ev = process_key_event(hwnd, wParam, lParam, NSKeyUp);
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEMOVE", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSMouseMoved);
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDOWN", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSLeftMouseDown);
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONUP", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSLeftMouseUp);
|
||||
break;
|
||||
case WM_LBUTTONDBLCLK:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "LBUTTONDBLCLK", hwnd);
|
||||
break;
|
||||
case WM_MBUTTONDOWN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDOWN", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSOtherMouseDown);
|
||||
break;
|
||||
case WM_MBUTTONUP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONUP", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSOtherMouseUp);
|
||||
break;
|
||||
case WM_MBUTTONDBLCLK:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MBUTTONDBLCLK", hwnd);
|
||||
break;
|
||||
case WM_RBUTTONDOWN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDOWN", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSRightMouseDown);
|
||||
break;
|
||||
case WM_RBUTTONUP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONUP", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSRightMouseUp);
|
||||
break;
|
||||
case WM_RBUTTONDBLCLK:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "RBUTTONDBLCLK", hwnd);
|
||||
break;
|
||||
case WM_MOUSEWHEEL:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MOUSEWHEEL", hwnd);
|
||||
ev = process_mouse_event(hwnd, wParam, lParam, NSScrollWheel);
|
||||
break;
|
||||
|
||||
case WM_QUIT:
|
||||
NSLog(@"Got Message %s for %d", "QUIT", hwnd);
|
||||
break;
|
||||
case WM_USER:
|
||||
NSLog(@"Got Message %s for %d", "USER", hwnd);
|
||||
break;
|
||||
case WM_APP:
|
||||
NSLog(@"Got Message %s for %d", "APP", hwnd);
|
||||
break;
|
||||
|
||||
case WM_ENTERMENULOOP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "ENTERMENULOOP", hwnd);
|
||||
break;
|
||||
case WM_EXITMENULOOP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "EXITMENULOOP", hwnd);
|
||||
break;
|
||||
case WM_INITMENU:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "INITMENU", hwnd);
|
||||
break;
|
||||
case WM_MENUSELECT:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "MENUSELECT", hwnd);
|
||||
break;
|
||||
case WM_ENTERIDLE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "ENTERIDLE", hwnd);
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "COMMAND", hwnd);
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SYSKEYDOWN", hwnd);
|
||||
break;
|
||||
case WM_SYSKEYUP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SYSKEYUP", hwnd);
|
||||
break;
|
||||
case WM_SYSCOMMAND:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "SYSCOMMAND", hwnd);
|
||||
break;
|
||||
case WM_HELP:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "HELP", hwnd);
|
||||
break;
|
||||
case WM_POWERBROADCAST:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "POWERBROADCAST", hwnd);
|
||||
break;
|
||||
case WM_TIMECHANGE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "TIMECHANGE", hwnd);
|
||||
break;
|
||||
case WM_DEVICECHANGE:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "DEVICECHANGE", hwnd);
|
||||
break;
|
||||
case WM_GETICON:
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "GETICON", hwnd);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Process all other messages.
|
||||
NSDebugLLog(@"NSEvent", @"Got unhandled Message %d for %d", uMsg, hwnd);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ev != nil)
|
||||
{
|
||||
[GSCurrentServer() postEvent: ev atStart: NO];
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
static unichar
|
||||
process_char(WPARAM wParam, unsigned *eventModifierFlags)
|
||||
{
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_RETURN: return NSCarriageReturnCharacter;
|
||||
case VK_TAB: return NSTabCharacter;
|
||||
case VK_ESCAPE: return 0x1b;
|
||||
case VK_BACK: return NSBackspaceCharacter;
|
||||
|
||||
/* The following keys need to be reported as function keys */
|
||||
#define WIN_FUNCTIONKEY \
|
||||
*eventModifierFlags = *eventModifierFlags | NSFunctionKeyMask;
|
||||
case VK_F1: WIN_FUNCTIONKEY return NSF1FunctionKey;
|
||||
case VK_F2: WIN_FUNCTIONKEY return NSF2FunctionKey;
|
||||
case VK_F3: WIN_FUNCTIONKEY return NSF3FunctionKey;
|
||||
case VK_F4: WIN_FUNCTIONKEY return NSF4FunctionKey;
|
||||
case VK_F5: WIN_FUNCTIONKEY return NSF5FunctionKey;
|
||||
case VK_F6: WIN_FUNCTIONKEY return NSF6FunctionKey;
|
||||
case VK_F7: WIN_FUNCTIONKEY return NSF7FunctionKey;
|
||||
case VK_F8: WIN_FUNCTIONKEY return NSF8FunctionKey;
|
||||
case VK_F9: WIN_FUNCTIONKEY return NSF9FunctionKey;
|
||||
case VK_F10: WIN_FUNCTIONKEY return NSF10FunctionKey;
|
||||
case VK_F11: WIN_FUNCTIONKEY return NSF12FunctionKey;
|
||||
case VK_F12: WIN_FUNCTIONKEY return NSF12FunctionKey;
|
||||
case VK_F13: WIN_FUNCTIONKEY return NSF13FunctionKey;
|
||||
case VK_F14: WIN_FUNCTIONKEY return NSF14FunctionKey;
|
||||
case VK_F15: WIN_FUNCTIONKEY return NSF15FunctionKey;
|
||||
case VK_F16: WIN_FUNCTIONKEY return NSF16FunctionKey;
|
||||
case VK_F17: WIN_FUNCTIONKEY return NSF17FunctionKey;
|
||||
case VK_F18: WIN_FUNCTIONKEY return NSF18FunctionKey;
|
||||
case VK_F19: WIN_FUNCTIONKEY return NSF19FunctionKey;
|
||||
case VK_F20: WIN_FUNCTIONKEY return NSF20FunctionKey;
|
||||
case VK_F21: WIN_FUNCTIONKEY return NSF21FunctionKey;
|
||||
case VK_F22: WIN_FUNCTIONKEY return NSF22FunctionKey;
|
||||
case VK_F23: WIN_FUNCTIONKEY return NSF23FunctionKey;
|
||||
case VK_F24: WIN_FUNCTIONKEY return NSF24FunctionKey;
|
||||
|
||||
case VK_DELETE: WIN_FUNCTIONKEY return NSDeleteFunctionKey;
|
||||
case VK_HOME: WIN_FUNCTIONKEY return NSHomeFunctionKey;
|
||||
case VK_LEFT: WIN_FUNCTIONKEY return NSLeftArrowFunctionKey;
|
||||
case VK_RIGHT: WIN_FUNCTIONKEY return NSRightArrowFunctionKey;
|
||||
case VK_UP: WIN_FUNCTIONKEY return NSUpArrowFunctionKey;
|
||||
case VK_DOWN: WIN_FUNCTIONKEY return NSDownArrowFunctionKey;
|
||||
case VK_PRIOR: WIN_FUNCTIONKEY return NSPrevFunctionKey;
|
||||
case VK_NEXT: WIN_FUNCTIONKEY return NSNextFunctionKey;
|
||||
case VK_END: WIN_FUNCTIONKEY return NSEndFunctionKey;
|
||||
//case VK_BEGIN: WIN_FUNCTIONKEY return NSBeginFunctionKey;
|
||||
case VK_SELECT: WIN_FUNCTIONKEY return NSSelectFunctionKey;
|
||||
case VK_PRINT: WIN_FUNCTIONKEY return NSPrintFunctionKey;
|
||||
case VK_EXECUTE: WIN_FUNCTIONKEY return NSExecuteFunctionKey;
|
||||
case VK_INSERT: WIN_FUNCTIONKEY return NSInsertFunctionKey;
|
||||
case VK_HELP: WIN_FUNCTIONKEY return NSHelpFunctionKey;
|
||||
case VK_CANCEL: WIN_FUNCTIONKEY return NSBreakFunctionKey;
|
||||
//case VK_MODECHANGE: WIN_FUNCTIONKEY return NSModeSwitchFunctionKey;
|
||||
case VK_SCROLL: WIN_FUNCTIONKEY return NSScrollLockFunctionKey;
|
||||
case VK_PAUSE: WIN_FUNCTIONKEY return NSPauseFunctionKey;
|
||||
case VK_OEM_CLEAR: WIN_FUNCTIONKEY return NSClearDisplayFunctionKey;
|
||||
#undef WIN_FUNCTIONKEY
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static NSEvent*
|
||||
process_key_event(HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||
NSEventType eventType)
|
||||
{
|
||||
NSEvent *event;
|
||||
BOOL repeat;
|
||||
DWORD pos;
|
||||
NSPoint eventLocation;
|
||||
unsigned int eventFlags;
|
||||
NSTimeInterval time;
|
||||
LONG ltime;
|
||||
unichar unicode[5];
|
||||
unsigned int scan;
|
||||
int result;
|
||||
BYTE keyState[256];
|
||||
NSString *keys, *ukeys;
|
||||
NSGraphicsContext *gcontext;
|
||||
unichar uChar;
|
||||
|
||||
/* FIXME: How do you guarentee a context is associated with an event? */
|
||||
gcontext = GSCurrentContext();
|
||||
|
||||
repeat = (lParam & 0xFFFF) != 0;
|
||||
|
||||
pos = GetMessagePos();
|
||||
eventLocation = MSWindowPointToGS(hwnd, GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
|
||||
|
||||
ltime = GetMessageTime();
|
||||
time = ltime / 1000;
|
||||
|
||||
GetKeyboardState(keyState);
|
||||
eventFlags = 0;
|
||||
if (keyState[VK_CONTROL] & 128)
|
||||
eventFlags |= NSControlKeyMask;
|
||||
if (keyState[VK_SHIFT] & 128)
|
||||
eventFlags |= NSShiftKeyMask;
|
||||
if (keyState[VK_CAPITAL] & 128)
|
||||
eventFlags |= NSShiftKeyMask;
|
||||
if (keyState[VK_MENU] & 128)
|
||||
eventFlags |= NSAlternateKeyMask;
|
||||
if ((keyState[VK_LWIN] & 128) || (keyState[VK_RWIN] & 128))
|
||||
eventFlags |= NSCommandKeyMask;
|
||||
|
||||
|
||||
switch(wParam)
|
||||
{
|
||||
case VK_SHIFT:
|
||||
case VK_CAPITAL:
|
||||
case VK_CONTROL:
|
||||
case VK_MENU:
|
||||
case VK_NUMLOCK:
|
||||
eventType = NSFlagsChanged;
|
||||
break;
|
||||
case VK_NUMPAD0:
|
||||
case VK_NUMPAD1:
|
||||
case VK_NUMPAD2:
|
||||
case VK_NUMPAD3:
|
||||
case VK_NUMPAD4:
|
||||
case VK_NUMPAD5:
|
||||
case VK_NUMPAD6:
|
||||
case VK_NUMPAD7:
|
||||
case VK_NUMPAD8:
|
||||
case VK_NUMPAD9:
|
||||
eventFlags |= NSNumericPadKeyMask;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uChar = process_char(wParam, &eventFlags);
|
||||
if (uChar)
|
||||
{
|
||||
keys = [NSString stringWithCharacters: &uChar length: 1];
|
||||
ukeys = [NSString stringWithCharacters: &uChar length: 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
scan = ((lParam >> 16) & 0xFF);
|
||||
//NSLog(@"Got key code %d %d", scan, wParam);
|
||||
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
||||
//NSLog(@"To Unicode resulted in %d with %d", result, unicode[0]);
|
||||
if (result == -1)
|
||||
{
|
||||
// A non spacing accent key was found, we still try to use the result
|
||||
result = 1;
|
||||
}
|
||||
keys = [NSString stringWithCharacters: unicode length: result];
|
||||
// Now switch modifiers off
|
||||
keyState[VK_LCONTROL] = 0;
|
||||
keyState[VK_RCONTROL] = 0;
|
||||
keyState[VK_LMENU] = 0;
|
||||
keyState[VK_RMENU] = 0;
|
||||
result = ToUnicode(wParam, scan, keyState, unicode, 5, 0);
|
||||
//NSLog(@"To Unicode resulted in %d with %d", result, unicode[0]);
|
||||
if (result == -1)
|
||||
{
|
||||
// A non spacing accent key was found, we still try to use the result
|
||||
result = 1;
|
||||
}
|
||||
ukeys = [NSString stringWithCharacters: unicode length: result];
|
||||
}
|
||||
|
||||
event = [NSEvent keyEventWithType: eventType
|
||||
location: eventLocation
|
||||
modifierFlags: eventFlags
|
||||
timestamp: time
|
||||
windowNumber: (int)hwnd
|
||||
context: gcontext
|
||||
characters: keys
|
||||
charactersIgnoringModifiers: ukeys
|
||||
isARepeat: repeat
|
||||
keyCode: wParam];
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
static NSEvent*
|
||||
process_mouse_event(HWND hwnd, WPARAM wParam, LPARAM lParam,
|
||||
NSEventType eventType)
|
||||
{
|
||||
NSEvent *event;
|
||||
NSPoint eventLocation;
|
||||
unsigned int eventFlags;
|
||||
NSTimeInterval time;
|
||||
LONG ltime;
|
||||
DWORD tick;
|
||||
NSGraphicsContext *gcontext;
|
||||
short deltaY = 0;
|
||||
static int clickCount = 1;
|
||||
static LONG lastTime = 0;
|
||||
|
||||
gcontext = GSCurrentContext();
|
||||
eventLocation = MSWindowPointToGS(hwnd, GET_X_LPARAM(lParam),
|
||||
GET_Y_LPARAM(lParam));
|
||||
ltime = GetMessageTime();
|
||||
time = ltime / 1000;
|
||||
tick = GetTickCount();
|
||||
eventFlags = 0;
|
||||
if (wParam & MK_CONTROL)
|
||||
{
|
||||
eventFlags |= NSControlKeyMask;
|
||||
}
|
||||
if (wParam & MK_SHIFT)
|
||||
{
|
||||
eventFlags |= NSShiftKeyMask;
|
||||
}
|
||||
if (GetKeyState(VK_MENU) < 0)
|
||||
{
|
||||
eventFlags |= NSAlternateKeyMask;
|
||||
}
|
||||
// What about other modifiers?
|
||||
|
||||
if (eventType == NSScrollWheel)
|
||||
{
|
||||
deltaY = GET_WHEEL_DELTA_WPARAM(wParam) / 120;
|
||||
//NSLog(@"Scroll event with delat %d", deltaY);
|
||||
}
|
||||
else if (eventType == NSMouseMoved)
|
||||
{
|
||||
if (wParam & MK_LBUTTON)
|
||||
{
|
||||
eventType = NSLeftMouseDragged;
|
||||
}
|
||||
else if (wParam & MK_RBUTTON)
|
||||
{
|
||||
eventType = NSRightMouseDragged;
|
||||
}
|
||||
else if (wParam & MK_MBUTTON)
|
||||
{
|
||||
eventType = NSOtherMouseDragged;
|
||||
}
|
||||
}
|
||||
else if ((eventType == NSLeftMouseDown) ||
|
||||
(eventType == NSRightMouseDown) ||
|
||||
(eventType == NSOtherMouseDown))
|
||||
{
|
||||
if (lastTime + GetDoubleClickTime() > ltime)
|
||||
{
|
||||
clickCount += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
clickCount = 1;
|
||||
lastTime = ltime;
|
||||
}
|
||||
}
|
||||
|
||||
event = [NSEvent mouseEventWithType: eventType
|
||||
location: eventLocation
|
||||
modifierFlags: eventFlags
|
||||
timestamp: time
|
||||
windowNumber: (int)hwnd
|
||||
context: gcontext
|
||||
eventNumber: tick
|
||||
clickCount: clickCount
|
||||
pressure: 1.0
|
||||
buttonNumber: 0 /* FIXME */
|
||||
deltaX: 0.
|
||||
deltaY: deltaY
|
||||
deltaZ: 0.];
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
static void
|
||||
invalidateWindow(HWND hwnd, RECT rect)
|
||||
{
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)hwnd, GWL_USERDATA);
|
||||
|
||||
if (win->useHDC)
|
||||
{
|
||||
HDC hdc = GetDC((HWND)hwnd);
|
||||
WINBOOL result;
|
||||
|
||||
result = BitBlt(hdc, rect.left, rect.top,
|
||||
(rect.right - rect.left), (rect.bottom - rect.top),
|
||||
win->hdc, rect.left, rect.top, SRCCOPY);
|
||||
if (!result)
|
||||
{
|
||||
NSLog(@"validated window %d %@", hwnd,
|
||||
NSStringFromRect(MSWindowRectToGS((HWND)hwnd, rect)));
|
||||
NSLog(@"validateWindow failed %d", GetLastError());
|
||||
}
|
||||
ReleaseDC((HWND)hwnd, hdc);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
||||
NSRect r = MSWindowRectToGS((HWND)hwnd, rect);
|
||||
|
||||
/*
|
||||
NSLog(@"Invalidated window %d %@ (%d, %d, %d, %d)", hwnd,
|
||||
NSStringFromRect(r), rect.left, rect.top, rect.right, rect.bottom);
|
||||
*/
|
||||
// Repaint the window's client area.
|
||||
[[window contentView] setNeedsDisplayInRect: r];
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
WIN32Server *ctxt = (WIN32Server *)GSCurrentServer();
|
||||
|
||||
return [ctxt windowEventProc: hwnd : uMsg : wParam : lParam];
|
||||
}
|
148
Source/win32/w32_Events.h
Normal file
148
Source/win32/w32_Events.h
Normal file
|
@ -0,0 +1,148 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef _W32_EVENTS_h_INCLUDE
|
||||
#define _W32_EVENTS_h_INCLUDE
|
||||
|
||||
#include <Foundation/NSDebug.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
#include <AppKit/AppKitExceptions.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSGraphics.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSMenuView.h>
|
||||
#include <AppKit/NSWindow.h>
|
||||
#include <AppKit/NSView.h>
|
||||
#include <AppKit/NSEvent.h>
|
||||
#include <AppKit/NSCursor.h>
|
||||
#include <AppKit/NSText.h>
|
||||
#include <AppKit/DPSOperators.h>
|
||||
|
||||
#include "win32/WIN32Server.h"
|
||||
#include "win32/WIN32Geometry.h"
|
||||
#include "w32_config.h"
|
||||
|
||||
|
||||
@interface WIN32Server (w32_activate)
|
||||
- (LRESULT) decodeWM_ACTIVEParams: (WPARAM)wParam :(LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd :(WPARAM)wParam : (LPARAM)lParam;
|
||||
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) ApplicationDidFinishLaunching: (NSNotification*)aNotification;
|
||||
- (void) ApplicationWillFinishLaunching: (NSNotification*)aNotification;
|
||||
- (void) ApplicationWillHideNotification: (NSNotification*)aNotification;
|
||||
- (void) WindowWillMiniaturizeNotification:(NSNotification*)aNotification;
|
||||
- (void) MenuWillTearOff: (NSNotification*)aNotification;
|
||||
- (void) MenuwillPopUP: (NSNotification*)aNotification;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@interface WIN32Server (w32_movesize)
|
||||
|
||||
- (LRESULT) decodeWM_SIZEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
|
||||
- (LRESULT) decodeWM_MOVEParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
|
||||
- (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_WINDOWPOSCHANGINGParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_WINDOWPOSCHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_GETMINMAXINFOParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_EXITSIZEMOVEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_SIZINGParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam;
|
||||
@end
|
||||
|
||||
@interface WIN32Server (w32_create)
|
||||
|
||||
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) trackWindow:(NSNotification*)aNotification;
|
||||
@end
|
||||
|
||||
@interface WIN32Server (w32_windowdisplay)
|
||||
|
||||
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) resizeBackingStoreFor: (HWND)hwnd;
|
||||
@end
|
||||
|
||||
@interface WIN32Server (w32_text_focus)
|
||||
|
||||
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
|
||||
@end
|
||||
|
||||
//small but useful events
|
||||
|
||||
@interface WIN32Server (w32_General)
|
||||
|
||||
- (void) decodeWM_CLOSEParams: (WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd;
|
||||
- (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
- (void) resetForGSWindowStyle: (HWND)hwnd gsStryle:(int)aStyle;
|
||||
//- (LRESULT) decodeWM_LBUTTONDOWNParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface WIN32Server (w32_debug)
|
||||
|
||||
- (BOOL) displayEvent: (unsigned int)uMsg; // diagnotic filter
|
||||
- (void) test_Geomemetry: (HWND)hwnd;
|
||||
- (void) print_result: (RECT)msrect and: (NSRect)gsrect and: (RECT)control;
|
||||
- (NSMutableString *) w32_createDetails: (LPCREATESTRUCT)details;
|
||||
- (NSMutableString *) createWindowDetail: (NSArray *)anArray;
|
||||
- (NSMutableString *) WindowDetail: (NSWindow *) theWindow;
|
||||
- (NSMutableString *) MSRectDetails: (RECT)aRect;
|
||||
- (NSMutableString *) NSRectDetails: (NSRect)aRect;
|
||||
- (NSMutableString *) gswindowstate: (NSWindow *)theWindow;
|
||||
- (NSMutableString *) MINMAXDetails: (MINMAXINFO *) mm;
|
||||
- (NSMutableString *) subViewDetails: (NSWindow *)theWindow;
|
||||
|
||||
@end
|
||||
|
||||
// debug hooks into the GSDisplayServer class
|
||||
@interface GSDisplayServer (GSDisplayServer_details)
|
||||
- (int) eventQueCount;
|
||||
- (NSMutableString *) dumpQue:(int)acount;
|
||||
- (void) clearEventQue;
|
||||
|
||||
@end
|
||||
|
||||
#endif //_W32_EVENTS_h_INCLUDE
|
458
Source/win32/w32_activate.m
Normal file
458
Source/win32/w32_activate.m
Normal file
|
@ -0,0 +1,458 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <AppKit/NSImage.h>
|
||||
#include <AppKit/NSBitmapImageRep.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include "w32_Events.h"
|
||||
|
||||
static NSString *NSMenuWillTearOff = @"MenuWillTearOff";
|
||||
static NSString *NSMenuwillPopUP =@"MenuwillPopUP";
|
||||
@interface NSMenu (w32Menu)
|
||||
|
||||
- (void) _rightMouseDisplay: (NSEvent*)theEvent;
|
||||
- (void) setTornOff: (BOOL)flag;
|
||||
@end
|
||||
|
||||
@implementation NSMenu (w32Menu)
|
||||
|
||||
// fixme to handle context menues better on win32
|
||||
// although it works better then it used to, it still
|
||||
// needs more work.
|
||||
|
||||
- (void) _rightMouseDisplay: (NSEvent*)theEvent
|
||||
{
|
||||
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSNotification * popped;
|
||||
//printf("my menu tarnsient method\n");
|
||||
|
||||
// need to get hwnd for the window
|
||||
[self displayTransient];
|
||||
// post notification here
|
||||
popped = [NSNotification
|
||||
notificationWithName: NSMenuwillPopUP
|
||||
object: _bWindow
|
||||
userInfo: nil];
|
||||
|
||||
[nc postNotification: popped];
|
||||
|
||||
[_view mouseDown: theEvent];
|
||||
[self closeTransient];
|
||||
[_bWindow orderOut:self];
|
||||
|
||||
}
|
||||
|
||||
- (void) setTornOff: (BOOL)flag
|
||||
{
|
||||
|
||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||
NSNotification * torn;
|
||||
NSMenu *supermenu;
|
||||
|
||||
_is_tornoff = flag;
|
||||
|
||||
if (flag)
|
||||
{
|
||||
supermenu = [self supermenu];
|
||||
if (supermenu != nil)
|
||||
{
|
||||
[[supermenu menuRepresentation] setHighlightedItemIndex: -1];
|
||||
supermenu->_attachedMenu = nil;
|
||||
}
|
||||
|
||||
torn = [NSNotification
|
||||
notificationWithName: NSMenuWillTearOff
|
||||
object: self
|
||||
userInfo: nil];
|
||||
|
||||
[nc postNotification: torn];
|
||||
}
|
||||
[_view update];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
@implementation WIN32Server (w32_activate)
|
||||
|
||||
/*
|
||||
* wParam
|
||||
* The low-order word specifies whether the window is being activated
|
||||
* or deactivated.
|
||||
* This parameter can be one of the following values.
|
||||
* The high-order word specifies the minimized state of
|
||||
* the window being activated or deactivated.
|
||||
* A nonzero value indicates the window is minimized.
|
||||
* WA_ACTIVE
|
||||
* Activated by some method other than a mouse click
|
||||
* (for example, by a call to the SetActiveWindow
|
||||
* function or by use of the keyboard interface to select the window).
|
||||
* WA_CLICKACTIVE
|
||||
* Activated by a mouse click.
|
||||
* WA_INACTIVE
|
||||
* Deactivated.
|
||||
* lParam
|
||||
* Handle to the window being activated or deactivated, depending on
|
||||
* the value of the wParam parameter. If the low-order word of wParam
|
||||
* is WA_INACTIVE, lParam is the handle to the window being activated.
|
||||
* If the low-order word of wParam is WA_ACTIVE or WA_CLICKACTIVE,
|
||||
* lParam is the handle to the window being deactivated. This handle
|
||||
* can be NULL.
|
||||
*
|
||||
* Return Value
|
||||
* If an application processes this message, it should return zero.
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_ACTIVEParams:(WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
|
||||
// decode our params
|
||||
|
||||
flags._last_WM_ACTIVATE = LOWORD(wParam);
|
||||
//int minimized = HIWORD(wParam);
|
||||
|
||||
|
||||
|
||||
|
||||
switch (flags._last_WM_ACTIVATE)
|
||||
{
|
||||
case WA_ACTIVE: //deactivate
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
break;
|
||||
case WA_CLICKACTIVE: //order back the window
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
break;
|
||||
case WA_INACTIVE: // set currentactive and display
|
||||
{
|
||||
currentActive=hwnd;
|
||||
[EVENT_WINDOW(lParam) display];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#ifdef __WM_ACTIVE__
|
||||
BOOL target=NO;
|
||||
|
||||
if((int)lParam == flags.menuRef)
|
||||
target=YES;
|
||||
|
||||
printf("RECEIVER [hwnd]%s\n",[[EVENT_WINDOW(hwnd) className] cString]);
|
||||
printf("ON [lParam]%s\n",[[EVENT_WINDOW(lParam) className] cString]);
|
||||
|
||||
printf("[lParam] %s",[[self gswindowstate:EVENT_WINDOW(lParam)] cString]);
|
||||
printf("ACTIVATE_FLAG STATE %d \n",_last_WM_ACTIVATE);
|
||||
|
||||
printf("[hwnd] %s",[[self gswindowstate:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* The WM_ACTIVATEAPP message is sent when a window belonging to a
|
||||
* different application than the active window is about to be
|
||||
* activated. The message is sent to the application whose window is
|
||||
* being activated and to the application whose window is being
|
||||
* deactivated.
|
||||
*
|
||||
* A window receives this message through its WindowProc function.
|
||||
*
|
||||
* Syntax
|
||||
*
|
||||
* WM_ACTIVATEAPP
|
||||
*
|
||||
* WPARAM wParam
|
||||
* LPARAM lParam;
|
||||
* Parameters
|
||||
*
|
||||
* wParam
|
||||
* Specifies whether the window is being activated or deactivated.
|
||||
* This parameter is TRUE if the window is being activated; it is FALSE if
|
||||
* the window is being deactivated.
|
||||
* lParam
|
||||
* Specifies a thread identifier (a DWORD). If the wParam parameter
|
||||
* is TRUE, lParam is the identifier of the thread that owns the
|
||||
* window being deactivated. If wParam is FALSE, lParam is the
|
||||
* identifier of the thread that owns the window being activated.
|
||||
*
|
||||
* Return Value
|
||||
* If an application processes this message, it should return zero. */
|
||||
|
||||
|
||||
- (LRESULT) decodeWM_ACTIVEAPPParams: (HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
||||
{
|
||||
|
||||
BOOL active=[NSApp isActive];
|
||||
|
||||
switch ((int)wParam)
|
||||
{
|
||||
case TRUE:
|
||||
{
|
||||
if(active==YES)
|
||||
{
|
||||
if (flags._is_menu==YES) // have menu and app active
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
else // Not a menu and app is active
|
||||
{
|
||||
// window is Visable
|
||||
if([EVENT_WINDOW(hwnd) isVisible]==YES)
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
else
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
}
|
||||
}
|
||||
else // app is not active
|
||||
{
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
flags._eventHandled=YES;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FALSE:
|
||||
{
|
||||
if (flags._is_menu==YES)
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
else
|
||||
{
|
||||
// future implimentation if needed
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __WM_ACTIVATEAPP__
|
||||
|
||||
printf("NSApp is:[%s]\n",active ? "active" : "inactive");
|
||||
printf("lParam is [%s]\n thread = [%u]\n w32_Class[%s] \n",
|
||||
(int)wParam ? "TRUE": "FALSE",
|
||||
(unsigned int)lParam,
|
||||
[[self getNativeClassName:hwnd] cString]);
|
||||
// debug GS_state details
|
||||
printf("%s",[[self gswindowstate:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("%s",[[self gswindowstate:EVENT_WINDOW(wParam)] cString]);
|
||||
printf("eventHandled=[%s]\n",_eventHandled ? "YES" : "NO");
|
||||
|
||||
printf("REQUESTED STATE %d\n",flags._last_WM_ACTIVATE);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
WM_NCACTIVATE Notification
|
||||
|
||||
The WM_NCACTIVATE message is sent to a window when its nonclient
|
||||
area needs to be changed to indicate an active or inactive state. A
|
||||
window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_NCACTIVATE
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Specifies when a title bar or icon needs to be changed to indicate
|
||||
an active or inactive state. If an active title bar or icon is to
|
||||
be drawn, the wParam parameter is TRUE. It is FALSE for an
|
||||
inactive title bar or icon.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
|
||||
When the wParam parameter is FALSE, an application should return
|
||||
TRUE to indicate that the system should proceed with the default
|
||||
processing, or it should return FALSE to prevent the title bar or
|
||||
icon from being deactivated. When wParam is TRUE, the return value
|
||||
is ignored.
|
||||
|
||||
Remarks
|
||||
|
||||
The DefWindowProc function draws the title bar or icon title in its
|
||||
active colors when the wParam parameter is TRUE and in its inactive
|
||||
colors when wParam is FALSE.
|
||||
*/
|
||||
|
||||
- (void) decodeWM_NCACTIVATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_NCACTIVATE\n");
|
||||
#endif
|
||||
}
|
||||
/*
|
||||
Notification hook from application
|
||||
The default notification are:
|
||||
|
||||
NSApplicationDidFinishLaunchingNotification
|
||||
NSApplicationWillFinishLaunchingNotification
|
||||
NSApplicationWillHideNotification
|
||||
NSWindowWillMiniaturizeNotification
|
||||
|
||||
Custom Notifications:
|
||||
NSMenuWillTearOff
|
||||
NSMenuwillPopUP
|
||||
|
||||
when these are received the Win32 server can now finalize its setup.
|
||||
other hook can also be set at this point
|
||||
syncronize the GS Env with The native Backend so we can use native
|
||||
calls to manage certain things directly.
|
||||
*/
|
||||
- (void) ApplicationWillFinishLaunching: (NSNotification*)aNotification;
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
- (void) ApplicationDidFinishLaunching: (NSNotification*)aNotification
|
||||
{
|
||||
LONG result;
|
||||
// Get our MainMenu window refference:
|
||||
|
||||
flags.menuRef=[[[NSApp mainMenu] window] windowNumber];
|
||||
flags.HAVE_MAIN_MENU=YES;
|
||||
|
||||
/*
|
||||
reset the style on the main menu panel so when it hides it will go
|
||||
the the task bar I will use WS_EX_RIGHT for this. Note that this
|
||||
is native code mixed with GNUStep */
|
||||
ShowWindow((HWND)flags.menuRef,SW_HIDE);
|
||||
SetLastError(0);
|
||||
result=SetWindowLong((HWND)flags.menuRef,GWL_EXSTYLE,(LONG)WS_EX_RIGHT);
|
||||
// should check error here...
|
||||
|
||||
ShowWindow((HWND)flags.menuRef,SW_SHOWNORMAL);
|
||||
|
||||
// set app icon image for win32
|
||||
|
||||
// future implimentation
|
||||
|
||||
#ifdef __WM_ACTIVE__
|
||||
|
||||
printf("reseting menu style\n");
|
||||
if (result==0)
|
||||
{
|
||||
printf("setting mainMenu Style: Error %ld\n",GetLastError());
|
||||
|
||||
}
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) ApplicationWillHideNotification: (NSNotification*)aNotification
|
||||
{
|
||||
flags.HOLD_MENU_FOR_MOVE=TRUE;
|
||||
flags.HOLD_MENU_FOR_SIZE=TRUE;
|
||||
|
||||
ReleaseCapture(); // if the mouse is 'stuck' release it
|
||||
|
||||
#ifdef __WM_ACTIVE__
|
||||
printf("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\n");
|
||||
printf("got Notification: %s\n",
|
||||
[[aNotification name] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
-(void) WindowWillMiniaturizeNotification:(NSNotification*)aNotification
|
||||
{
|
||||
flags.HOLD_MINI_FOR_SIZE=TRUE;
|
||||
flags.HOLD_MINI_FOR_MOVE=TRUE;
|
||||
}
|
||||
|
||||
-(void) MenuWillTearOff:(NSNotification*)aNotification
|
||||
{
|
||||
LONG result;
|
||||
NSMutableString * iconTitle =[NSMutableString stringWithString:@"MENU "];
|
||||
NSMenu * theMenu=[aNotification object];
|
||||
int windowNum =[[theMenu window] windowNumber];
|
||||
|
||||
ShowWindow((HWND)windowNum,SW_HIDE);
|
||||
SetLastError(0);
|
||||
result=SetWindowLong((HWND)windowNum,GWL_EXSTYLE,(LONG)WS_EX_RIGHT);
|
||||
// should check error here...
|
||||
|
||||
// set the icon title
|
||||
[iconTitle appendString: [theMenu title]];
|
||||
result=SetWindowText((HWND)windowNum,[iconTitle cString]);
|
||||
ShowWindow((HWND)windowNum,SW_SHOWNORMAL);
|
||||
|
||||
|
||||
#ifdef __APPNOTIFICATIONS__
|
||||
printf("got menu tear off Notification\n");
|
||||
printf("menu title is: %s\n",[[theMenu title] cString]);
|
||||
#endif
|
||||
}
|
||||
|
||||
-(void) MenuwillPopUP:(NSNotification*)aNotification
|
||||
{
|
||||
LONG result;
|
||||
int windowNum=[[aNotification object] windowNumber];
|
||||
|
||||
ShowWindow((HWND)windowNum,SW_HIDE);
|
||||
SetLastError(0);
|
||||
result=SetWindowLong((HWND)windowNum,GWL_EXSTYLE,(LONG)WS_EX_RIGHT);
|
||||
// should check error here...
|
||||
|
||||
// set the icon title
|
||||
result=SetWindowText((HWND)windowNum,"Context menu");
|
||||
ShowWindow((HWND)windowNum,SW_SHOWNORMAL);
|
||||
|
||||
flags.HOLD_TRANSIENT_FOR_SIZE=TRUE;
|
||||
flags.HOLD_TRANSIENT_FOR_MOVE=TRUE;
|
||||
|
||||
#ifdef __APPNOTIFICATIONS__
|
||||
printf("got menu Popup Notification\n");
|
||||
printf("window title is: %s\n",[[[aNotification object] title] cString]);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@end
|
89
Source/win32/w32_config.h
Normal file
89
Source/win32/w32_config.h
Normal file
|
@ -0,0 +1,89 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _W32_CONFIG_h_INCLUDE
|
||||
#define _W32_CONFIG_h_INCLUDE
|
||||
|
||||
#define EVENT_WINDOW(lp) (GSWindowWithNumber((int)lp))
|
||||
|
||||
//#define _logging //use to log messages from our debug code
|
||||
|
||||
//#define __W32_debug_Event_loop //special flag for event loops and counts
|
||||
|
||||
//#define __W32_debug__ // activate the debug code in the main event server
|
||||
#define __STATE NO
|
||||
|
||||
#ifdef __W32_debug__ // turn on tests for this
|
||||
#define __SETFOCUS__
|
||||
#define __KILLFOCUS__
|
||||
#define __SHOWWINDOW__
|
||||
#define __WM_ACTIVE__
|
||||
#define __WM_ACTIVATEAPP__
|
||||
#define __WM_NCACTIVATE__
|
||||
#define __WM_NCCREATE__
|
||||
#define __WM_CREATE__
|
||||
#define __WM_MOVE__
|
||||
#define __WM_SIZE__
|
||||
#define __PAINT__
|
||||
#define __BACKING__
|
||||
#define __CLOSE__
|
||||
#define __DESTROY__
|
||||
#define __ERASEBKGND__
|
||||
#define __GETMINMAXINFO__
|
||||
#define __EXITSIZEMOVE__
|
||||
#define __APPNOTIFICATIONS__
|
||||
#define __SIZING__
|
||||
|
||||
#define __SETFOCUS_FLAG 1
|
||||
#define __ACTIVE_FLAG 1
|
||||
#define __CREATE_FLAG 1
|
||||
#define __MOVE_FLAG 1
|
||||
#define __SIZE_FLAG 1
|
||||
#define __SHOWWINDOW_FLAG 1
|
||||
#define __KILLFOCUS_FLAG 1
|
||||
#define __PAINT_FLAG 1
|
||||
#define __CLOSE_FLAG 1
|
||||
#define __DESTROY_FLAG 1
|
||||
#define __ERASEBKGND_FLAG 1
|
||||
#define __GETMINMAXINFO_FLAG 1
|
||||
#define __EXITSIZEMOVE_FLAG 1
|
||||
#define __SIZING_FLAG 1
|
||||
#else
|
||||
#define __ACTIVE_FLAG 0
|
||||
#define __CREATE_FLAG 0
|
||||
#define __MOVE_FLAG 0
|
||||
#define __SIZE_FLAG 0
|
||||
#define __SHOWWINDOW_FLAG 0
|
||||
#define __KILLFOCUS_FLAG 0
|
||||
#define __SETFOCUS_FLAG 0
|
||||
#define __PAINT_FLAG 0
|
||||
#define __CLOSE_FLAG 0
|
||||
#define __DESTROY_FLAG 0
|
||||
#define __ERASEBKGND_FLAG 0
|
||||
#define __GETMINMAXINFO_FLAG 0
|
||||
#define __EXITSIZEMOVE_FLAG 0
|
||||
#define __SIZING_FLAG 0
|
||||
#endif
|
||||
|
||||
#endif //_W32_CONFIG_h_INCLUDE
|
317
Source/win32/w32_create.m
Normal file
317
Source/win32/w32_create.m
Normal file
|
@ -0,0 +1,317 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
Part of this code have been re-written by:
|
||||
Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "w32_Events.h"
|
||||
|
||||
|
||||
@implementation WIN32Server (w32_create)
|
||||
|
||||
/*
|
||||
WM_NCCREATE Notification
|
||||
|
||||
The WM_NCCREATE message is sent prior to the WM_CREATE message when a window
|
||||
is first created.
|
||||
|
||||
A window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_NCCREATE
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Pointer to the CREATESTRUCT structure that contains information about the
|
||||
window being created. The members of CREATESTRUCT are identical to the
|
||||
parameters of the CreateWindowEx function.
|
||||
|
||||
Return Value
|
||||
|
||||
If an application processes this message, it should return TRUE to
|
||||
continue creation of the window. If the application returns FALSE,
|
||||
the CreateWindow or CreateWindowEx function will return a NULL
|
||||
handle.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
- (LRESULT) decodeWM_NCCREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stubbed for future development
|
||||
#ifdef __WM_NCCREATE__
|
||||
printf("WM_NCCREATE\n");
|
||||
#ifdef __W32_debug__
|
||||
printf("%s",[[self w32_createDetails:(LPCREATESTRUCT)lParam] cString]);
|
||||
#endif
|
||||
printf("\nRequested GS Window Style is %u\n",flags.currentGS_Style);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
/*
|
||||
|
||||
WM_CREATE Notification
|
||||
|
||||
The WM_CREATE message is sent when an application requests that a
|
||||
window be created by calling the CreateWindowEx or CreateWindow
|
||||
function. (The message is sent before the function returns.) The
|
||||
window procedure of the new window receives this message after the
|
||||
window is created, but before the window becomes visible.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_CREATE
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Pointer to a CREATESTRUCT structure that contains information
|
||||
about the window being created.
|
||||
|
||||
typedef struct tagCREATESTRUCT {
|
||||
LPVOID lpCreateParams;
|
||||
HINSTANCE hInstance;
|
||||
HMENU hMenu;
|
||||
HWND hwndParent;
|
||||
int cy;
|
||||
int cx;
|
||||
int y;
|
||||
int x;
|
||||
LONG style;
|
||||
LPCTSTR lpszName;
|
||||
LPCTSTR lpszClass;
|
||||
DWORD dwExStyle;
|
||||
} CREATESTRUCT, *LPCREATESTRUCT;
|
||||
|
||||
Return Value
|
||||
|
||||
If an application processes this message, it should return zero to
|
||||
continue creation of the window. If the application returns –1, the
|
||||
window is destroyed and the CreateWindowEx or CreateWindow function
|
||||
returns a NULL handle.
|
||||
|
||||
dwExStyle [in] Specifies the extended window style of the window
|
||||
being created. This parameter can be one or more of the following
|
||||
values.
|
||||
|
||||
WS_EX_ACCEPTFILES
|
||||
Specifies that a window created with this style accepts drag-drop files.
|
||||
|
||||
WS_EX_APPWINDOW
|
||||
Forces a top-level window onto the taskbar when the window is visible.
|
||||
|
||||
WS_EX_CLIENTEDGE
|
||||
Specifies that a window has a border with a sunken edge.
|
||||
|
||||
WS_EX_COMPOSITED
|
||||
Windows XP: Paints all descendants of a window in bottom-to-top
|
||||
painting order using double-buffering. For more information, see
|
||||
Remarks. This cannot be used if the window has a class style of
|
||||
either CS_OWNDC or CS_CLASSDC.
|
||||
|
||||
WS_EX_CONTEXTHELP
|
||||
Includes a question mark in the title bar of the window. When the
|
||||
user clicks the question mark, the cursor changes to a question mark
|
||||
with a pointer. If the user then clicks a child window, the child
|
||||
receives a WM_HELP message. The child window should pass the message
|
||||
to the parent window procedure, which should call the WinHelp
|
||||
function using the HELP_WM_HELP command. The Help application
|
||||
displays a pop-up window that typically contains help for the child
|
||||
window. WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or
|
||||
WS_MINIMIZEBOX styles.
|
||||
|
||||
WS_EX_CONTROLPARENT
|
||||
The window itself contains child windows that should take part in
|
||||
dialog box navigation. If this style is specified, the dialog
|
||||
manager recurses into children of this window when performing
|
||||
navigation operations such as handling the TAB key, an arrow key, or
|
||||
a keyboard mnemonic. WS_EX_DLGMODALFRAME Creates a window that has a
|
||||
double border; the window can, optionally, be created with a title
|
||||
bar by specifying the WS_CAPTION style in the dwStyle
|
||||
parameter. WS_EX_LAYERED Windows 2000/XP: Creates a layered
|
||||
window. Note that this cannot be used for child windows. Also, this
|
||||
cannot be used if the window has a class style of either CS_OWNDC or
|
||||
CS_CLASSDC. WS_EX_LAYOUTRTL Arabic and Hebrew versions of Windows
|
||||
98/Me, Windows 2000/XP: Creates a window whose horizontal origin is
|
||||
on the right edge. Increasing horizontal values advance to the
|
||||
left. WS_EX_LEFT Creates a window that has generic left-aligned
|
||||
properties. This is the default.
|
||||
|
||||
WS_EX_LEFTSCROLLBAR
|
||||
If the shell language is Hebrew, Arabic, or another language that
|
||||
supports reading order alignment, the vertical scroll bar (if
|
||||
present) is to the left of the client area. For other languages, the
|
||||
style is ignored. WS_EX_LTRREADING The window text is displayed
|
||||
using left-to-right reading-order properties. This is the
|
||||
default. WS_EX_MDICHILD Creates a multiple-document interface (MDI)
|
||||
child window.
|
||||
|
||||
WS_EX_NOACTIVATE
|
||||
Windows 2000/XP: A top-level window created with this style does not
|
||||
become the foreground window when the user clicks it. The system
|
||||
does not bring this window to the foreground when the user minimizes
|
||||
or closes the foreground window. To activate the window, use the
|
||||
SetActiveWindow or SetForegroundWindow function. The window does
|
||||
not appear on the taskbar by default. To force the window to appear
|
||||
on the taskbar, use the WS_EX_APPWINDOW style.
|
||||
|
||||
WS_EX_NOINHERITLAYOUT
|
||||
Windows 2000/XP: A window created with this style does not pass its window
|
||||
layout to its child windows.
|
||||
WS_EX_NOPARENTNOTIFY
|
||||
Specifies that a child window created with this style does not send
|
||||
the WM_PARENTNOTIFY message to its parent window when it is created
|
||||
or destroyed.
|
||||
|
||||
WS_EX_OVERLAPPEDWINDOW
|
||||
Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
|
||||
WS_EX_PALETTEWINDOW
|
||||
Combines the WS_EX_WINDOWEDGE, WS_EX_TOOLWINDOW, and WS_EX_TOPMOST styles.
|
||||
|
||||
WS_EX_RIGHT
|
||||
The window has generic "right-aligned" properties. This depends on
|
||||
the window class. This style has an effect only if the shell
|
||||
language is Hebrew, Arabic, or another language that supports
|
||||
reading-order alignment; otherwise, the style is ignored. Using the
|
||||
WS_EX_RIGHT style for static or edit controls has the same effect as
|
||||
using the SS_RIGHT or ES_RIGHT style, respectively. Using this style
|
||||
with button controls has the same effect as using BS_RIGHT and
|
||||
BS_RIGHTBUTTON styles.
|
||||
|
||||
WS_EX_RIGHTSCROLLBAR
|
||||
Vertical scroll bar (if present) is to the right of the client area. This is
|
||||
the default. WS_EX_RTLREADING
|
||||
If the shell language is Hebrew, Arabic, or another language that supports
|
||||
reading-order alignment, the window text is displayed using right-to-left
|
||||
reading-order properties. For other languages, the style is ignored.
|
||||
|
||||
WS_EX_STATICEDGE
|
||||
Creates a window with a three-dimensional border style intended to
|
||||
be used for items that do not accept user input. WS_EX_TOOLWINDOW
|
||||
Creates a tool window; that is, a window intended to be used as a
|
||||
floating toolbar. A tool window has a title bar that is shorter than
|
||||
a normal title bar, and the window title is drawn using a smaller
|
||||
font. A tool window does not appear in the taskbar or in the dialog
|
||||
that appears when the user presses ALT+TAB. If a tool window has a
|
||||
system menu, its icon is not displayed on the title bar. However,
|
||||
you can display the system menu by right-clicking or by typing
|
||||
ALT+SPACE. WS_EX_TOPMOST Specifies that a window created with this
|
||||
style should be placed above all non- topmost windows and should
|
||||
stay above them, even when the window is deactivated. To add or
|
||||
remove this style, use the SetWindowPos function.
|
||||
|
||||
WS_EX_TRANSPARENT
|
||||
Specifies that a window created with this style should not be
|
||||
painted until siblings beneath the window (that were created by the
|
||||
same thread) have been painted. The window appears transparent
|
||||
because the bits of underlying sibling windows have already been
|
||||
painted. To achieve transparency without these restrictions, use
|
||||
the SetWindowRgn function.
|
||||
|
||||
WS_EX_WINDOWEDGE
|
||||
Specifies that a window has a border with a raised edge.
|
||||
|
||||
*/
|
||||
- (LRESULT) decodeWM_CREATEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
//Created by original author
|
||||
WIN_INTERN *win;
|
||||
NSBackingStoreType type = (NSBackingStoreType)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
|
||||
// Initialize the window.
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "CREATE", hwnd);
|
||||
/* For windows with backingstore we create a compatible DC, that
|
||||
is stored in the extra fields for this window. Drawing operations
|
||||
work on this buffer. */
|
||||
win = objc_malloc(sizeof(WIN_INTERN));
|
||||
SetWindowLong(hwnd, GWL_USERDATA, (int)win);
|
||||
|
||||
if (type != NSBackingStoreNonretained)
|
||||
{
|
||||
HDC hdc, hdc2;
|
||||
HBITMAP hbitmap;
|
||||
RECT r;
|
||||
|
||||
GetClientRect((HWND)hwnd, &r);
|
||||
hdc = GetDC(hwnd);
|
||||
hdc2 = CreateCompatibleDC(hdc);
|
||||
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left,
|
||||
r.bottom - r.top);
|
||||
win->old = SelectObject(hdc2, hbitmap);
|
||||
|
||||
win->hdc = hdc2;
|
||||
win->useHDC = YES;
|
||||
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
else
|
||||
{
|
||||
win->useHDC = NO;
|
||||
}
|
||||
|
||||
#ifdef __WM_CREATE__
|
||||
printf("WM_CREATE: *********************\n");
|
||||
#ifdef __W32_debug__
|
||||
printf("%s",[[self w32_createDetails:(LPCREATESTRUCT)lParam] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
||||
printf("Parent isa %s\n",[[self getNativeClassName:GetParent(hwnd)] cString]);
|
||||
printf("[hwnd]Native WindowType %s\n",[[self getNativeClassName:(HWND)hwnd] cString]);
|
||||
printf("[hwnd]GS WindowType %s:\n",[[EVENT_WINDOW(hwnd) className] cString]);
|
||||
printf("HAVE_MAIN_MENU = %s\n",flags.HAVE_MAIN_MENU ? "YES": "NO");
|
||||
printf("Main Menu Window Num: %d Currrent window Num: %d\n",
|
||||
[[[NSApp mainMenu] window] windowNumber],(int)hwnd);
|
||||
printf("Window Task bar flag %s\n",flags.useWMTaskBar ? "YES" : "NO");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (void) trackWindow:(NSNotification*)aNotification
|
||||
{
|
||||
// stubbed for future development
|
||||
|
||||
// later when I have a Clss/ stye system in place, I can get the
|
||||
// window server
|
||||
//to Post a notification when a window is fully inited.... or I could use a catagorey extention
|
||||
//to NSwindow, to make it post my notification.
|
||||
}
|
||||
|
||||
@end
|
||||
|
381
Source/win32/w32_debug.m
Normal file
381
Source/win32/w32_debug.m
Normal file
|
@ -0,0 +1,381 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "w32_Events.h"
|
||||
|
||||
static NSString * spacer =@"<BLANK_LINE>\n";
|
||||
|
||||
@implementation WIN32Server (w32_debug)
|
||||
|
||||
- (void) test_Geomemetry:(HWND)hwnd
|
||||
{
|
||||
NSRect gsrect;
|
||||
RECT r;
|
||||
RECT msrect;
|
||||
|
||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
||||
|
||||
GetWindowRect(hwnd, &r);
|
||||
|
||||
printf("*******************testing Conversion \n\n\n");
|
||||
printf("MSScreenRectToGS GSScreenRectToMS\n");
|
||||
gsrect = MSScreenRectToGS(r, [window styleMask], self);
|
||||
msrect= GSScreenRectToMS(gsrect, [window styleMask],self);
|
||||
printf("*************************test complete\n\n\n");
|
||||
|
||||
[self print_result:msrect and:gsrect and:r];
|
||||
//TestsDone=YES;
|
||||
}
|
||||
|
||||
- (void) print_result:(RECT) msrect and:(NSRect) gsrect and:(RECT) control
|
||||
{
|
||||
|
||||
printf("MS - Control\n");
|
||||
printf("MSrect = left %ld ",control.left);
|
||||
printf(" top %ld",control.top);
|
||||
printf(" right %ld",control.right);
|
||||
printf(" Bottom %ld\n",control.bottom);
|
||||
|
||||
printf("GS - Calculated\n");
|
||||
printf("NSRect = height %f width %f ",gsrect.size.height,gsrect.size.width);
|
||||
printf(" X %f Y %f\n",gsrect.origin.x,gsrect.origin.y);
|
||||
|
||||
printf("MS - Calculated\n");
|
||||
printf("MSrect = left %ld ",msrect.left);
|
||||
printf(" top %ld",msrect.top);
|
||||
printf(" right %ld",msrect.right);
|
||||
printf(" Bottom %ld\n",msrect.bottom);
|
||||
|
||||
}
|
||||
|
||||
- (BOOL) displayEvent: (unsigned int)uMsg
|
||||
{
|
||||
|
||||
#ifdef __W32_debug__ //_logging
|
||||
//NSDebugLLog(@"NSEvent", @"Got Message %u for %d", uMsg, hwnd);
|
||||
#endif
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_KEYDOWN: return NO; break; //Keyboard events
|
||||
case WM_KEYUP: return NO; break;
|
||||
case WM_MOUSEMOVE: return NO; break;// mouse moved events
|
||||
case WM_NCHITTEST: return NO; break;
|
||||
case WM_SETCURSOR: return NO; break;
|
||||
case WM_MOUSEWHEEL: return NO; break;
|
||||
case WM_LBUTTONDOWN: return YES; break;
|
||||
case WM_MOUSEACTIVATE: return NO; break;
|
||||
case WM_CAPTURECHANGED: return NO; break; //related to window -- redraw if needed
|
||||
case WM_NCMOUSEMOVE: return NO; break;
|
||||
case WM_RBUTTONDOWN: return YES; break;
|
||||
case WM_RBUTTONUP: return YES; break;
|
||||
case WM_NCLBUTTONDOWN: return NO; break;
|
||||
case WM_NCLBUTTONDBLCLK: return NO; break;
|
||||
// window events Stubed or Functioning
|
||||
case WM_SETTEXT: return __STATE; break;
|
||||
case WM_NCCREATE: return __CREATE_FLAG; break;
|
||||
case WM_NCCALCSIZE: return __STATE; break;
|
||||
case WM_NCACTIVATE: return __ACTIVE_FLAG; break;
|
||||
case WM_NCPAINT: return __STATE; break;
|
||||
case WM_SHOWWINDOW: return __SHOWWINDOW_FLAG; break;
|
||||
case WM_NCDESTROY: return __STATE; break;
|
||||
case WM_GETTEXT: return __STATE; break;
|
||||
case WM_STYLECHANGING: return __STATE; break;
|
||||
case WM_STYLECHANGED: return __STATE; break;
|
||||
case WM_GETMINMAXINFO: return __GETMINMAXINFO_FLAG; break;
|
||||
case WM_CREATE: return __CREATE_FLAG; break;
|
||||
case WM_WINDOWPOSCHANGING: return __STATE; break;
|
||||
case WM_WINDOWPOSCHANGED: return __STATE; break;
|
||||
case WM_MOVE: return __MOVE_FLAG; break;
|
||||
case WM_MOVING: return __STATE; break;
|
||||
case WM_SIZE: return __SIZE_FLAG; break;
|
||||
case WM_SIZING: return __SIZING_FLAG; break;
|
||||
case WM_ENTERSIZEMOVE: return __STATE; break;
|
||||
case WM_EXITSIZEMOVE: return __EXITSIZEMOVE_FLAG; break;
|
||||
case WM_ACTIVATE: return __ACTIVE_FLAG; break;
|
||||
case WM_ACTIVATEAPP: return __ACTIVE_FLAG; break;
|
||||
case WM_SETFOCUS: return __SETFOCUS_FLAG; break;
|
||||
case WM_KILLFOCUS: return __KILLFOCUS_FLAG; break;
|
||||
//case WM_SETCURSOR: return __STATE; break;
|
||||
case WM_QUERYOPEN: return __STATE; break;
|
||||
//case WM_CAPTURECHANGED: return __STATE; break;
|
||||
case WM_ERASEBKGND: return __ERASEBKGND_FLAG; break;
|
||||
case WM_PAINT: return __PAINT_FLAG; break;
|
||||
case WM_SYNCPAINT: return __STATE; break;
|
||||
case WM_CLOSE: return __CLOSE_FLAG; break;
|
||||
case WM_DESTROY: return __DESTROY_FLAG; break;
|
||||
case WM_QUIT: return __STATE; break;
|
||||
case WM_USER: return __STATE; break;
|
||||
case WM_APP: return __STATE; break;
|
||||
case WM_ENTERMENULOOP: return __STATE; break;
|
||||
case WM_EXITMENULOOP: return __STATE; break;
|
||||
case WM_INITMENU: return __STATE; break;
|
||||
case WM_MENUSELECT: return __STATE; break;
|
||||
case WM_ENTERIDLE: return __STATE; break;
|
||||
case WM_COMMAND: return __STATE; break;
|
||||
case WM_SYSKEYDOWN: return __STATE; break;
|
||||
case WM_SYSKEYUP: return __STATE; break;
|
||||
case WM_SYSCOMMAND: return __STATE; break;
|
||||
case WM_HELP: return __STATE; break;
|
||||
case WM_GETICON: return __STATE; break;
|
||||
case WM_CANCELMODE: return __STATE; break;
|
||||
case WM_ENABLE: return __STATE; break;
|
||||
case WM_CHILDACTIVATE: return __ACTIVE_FLAG; break;
|
||||
case WM_NULL: return __STATE; break;
|
||||
case WM_LBUTTONUP: return YES; break;
|
||||
case WM_PARENTNOTIFY: return __STATE; break;
|
||||
|
||||
default:
|
||||
return YES;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct tagCREATESTRUCT {
|
||||
LPVOID lpCreateParams;
|
||||
HINSTANCE hInstance;
|
||||
HMENU hMenu;
|
||||
HWND hwndParent;
|
||||
int cy;
|
||||
int cx;
|
||||
int y;
|
||||
int x;
|
||||
LONG style;
|
||||
LPCTSTR lpszName;
|
||||
LPCTSTR lpszClass;
|
||||
DWORD dwExStyle;
|
||||
} CREATESTRUCT, *LPCREATESTRUCT;
|
||||
*/
|
||||
|
||||
- (NSMutableString *) w32_createDetails:(LPCREATESTRUCT)details
|
||||
{
|
||||
|
||||
NSMutableString * output= [NSMutableString stringWithString:spacer];
|
||||
[output appendString:@"\n\nLPCREATESTRUCT details\n"];
|
||||
|
||||
[output appendFormat:@"HINSTANCE %p ",details->hInstance];
|
||||
|
||||
[output appendFormat:@"HMENU %p\n",details->hMenu];
|
||||
|
||||
|
||||
[output appendFormat:@"Creating window: Parent is %s:\n",
|
||||
[self getNativeClassName:details->hwndParent]];
|
||||
|
||||
[output appendFormat:@"Co-ordanates:height[%d] width[%d] Pos[%d] Pox[%d]\n",
|
||||
details->cy,details->cx,details->y,details->x];
|
||||
|
||||
[output appendFormat:@"Style %lu Name: %s Win32Class: %s Extended Style %ld\n\n\n",
|
||||
details->style,details->lpszName,
|
||||
details->lpszClass,details->dwExStyle];
|
||||
[output appendString:spacer];
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
- (NSMutableString *) createWindowDetail:(NSArray *)anArray
|
||||
{
|
||||
int i =0;
|
||||
int c=[anArray count];
|
||||
|
||||
|
||||
NSMutableString * output= [NSMutableString stringWithString:spacer];
|
||||
|
||||
[output appendFormat:@"Application window count is: %d\n",c];
|
||||
|
||||
for(i=0;i<c;i++)
|
||||
{
|
||||
NSWindow * theWindow=[anArray objectAtIndex:i];
|
||||
|
||||
[output appendString:[self WindowDetail:theWindow]];
|
||||
}
|
||||
[output appendString:spacer];
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
- (NSMutableString *) WindowDetail:(NSWindow *) theWindow
|
||||
{
|
||||
return [self gswindowstate:theWindow];
|
||||
|
||||
}
|
||||
|
||||
- (NSMutableString *) MSRectDetails:(RECT)aRect
|
||||
{
|
||||
NSMutableString * output= [NSMutableString stringWithCString:"MSRect Details\n"];
|
||||
|
||||
[output appendFormat:@"left %ld ",aRect.left];
|
||||
[output appendFormat:@"top %ld ",aRect.top];
|
||||
[output appendFormat:@"right %ld ",aRect.right];
|
||||
[output appendFormat:@"Bottom %ld\n",aRect.bottom];
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
- (NSMutableString *) NSRectDetails:(NSRect)aRect
|
||||
{
|
||||
|
||||
NSMutableString * output= [NSMutableString stringWithString:@" "];
|
||||
|
||||
[output appendFormat:@"height %ld width %ld ",(int)aRect.size.height
|
||||
,(int)aRect.size.width];
|
||||
[output appendFormat:@" XPos %ld YPos %ld\n",(int)aRect.origin.x
|
||||
,(int)aRect.origin.y];
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
- (NSMutableString *) gswindowstate:(NSWindow *)theWindow
|
||||
{
|
||||
// NSRect cvRect=[[theWindow contentView] frame];
|
||||
NSMutableString * output= [NSMutableString stringWithString:spacer];
|
||||
[output appendFormat:@"MenuRef = %d\n",flags.menuRef];
|
||||
[output appendFormat:@"Main Menu %s\n",flags._is_menu ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW title %s\n",[[theWindow title]cString]];
|
||||
[output appendFormat:@"WINDOW className %s\n",[[theWindow className]cString]];
|
||||
[output appendFormat:@"WINDOW isVisible: %s\n",[theWindow isVisible] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isAutodisplay: %s\n",[theWindow isAutodisplay] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isMiniaturized: %s\n",[theWindow isMiniaturized] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW viewsNeedDisplay: %s\n",[theWindow viewsNeedDisplay] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isOpaque: %s\n",[theWindow isOpaque] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isReleasedWhenClosed: %s\n ",[theWindow isReleasedWhenClosed] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isOneShot: %s\n",[theWindow isOneShot] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isMainWindow: %s\n",[theWindow isMainWindow] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW isKeyWindow: %s\n",[theWindow isKeyWindow] ? "YES" : "NO"];
|
||||
[output appendFormat:@"WINDOW styleMask: %d\n",[theWindow styleMask]];
|
||||
[output appendFormat:@"WINDOW frame:%s",[[self NSRectDetails:[theWindow frame]] cString]];
|
||||
//[output appendString:[self subViewDetails:theWindow]];
|
||||
|
||||
[output appendFormat:@"Native Class Name %s\n",
|
||||
[[self getNativeClassName:(HWND)[theWindow windowNumber]] cString]];
|
||||
[output appendFormat:@"Win32 GWL_EXStyle %ld\n",
|
||||
GetWindowLong((HWND)[theWindow windowNumber],GWL_EXSTYLE)];
|
||||
|
||||
[output appendFormat:@"Win32 GWL_STYLE %X\n",
|
||||
GetWindowLong((HWND)[theWindow windowNumber],GWL_STYLE)];
|
||||
|
||||
[output appendFormat:@"Win32 GWL_WNDPROC %ld\n",
|
||||
GetWindowLong((HWND)[theWindow windowNumber],GWL_WNDPROC)];
|
||||
|
||||
[output appendFormat:@"Win32 GWL_HINSTANCE %ld\n",
|
||||
GetWindowLong((HWND)[theWindow windowNumber],GWL_HINSTANCE)];
|
||||
|
||||
[output appendFormat:@"Win32 GWL_HWNDPARENT %ld\n",
|
||||
GetWindowLong((HWND)[theWindow windowNumber],GWL_HWNDPARENT)];
|
||||
|
||||
[output appendFormat:@"Win32 GWL_ID %ld\n",
|
||||
GetWindowLong((HWND)[theWindow windowNumber],GWL_ID)];
|
||||
[output appendString:spacer];
|
||||
|
||||
[output appendFormat:@"Win32 windowtext %s\n",
|
||||
[[self getWindowtext:(HWND)[theWindow windowNumber]] cString]];
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
The MINMAXINFO structure contains information about a window's maximized
|
||||
size and position and its minimum and maximum tracking size.
|
||||
|
||||
Syntax
|
||||
|
||||
typedef struct {
|
||||
POINT ptReserved;
|
||||
POINT ptMaxSize;
|
||||
POINT ptMaxPosition;
|
||||
POINT ptMinTrackSize;
|
||||
POINT ptMaxTrackSize;
|
||||
} MINMAXINFO;
|
||||
|
||||
Members
|
||||
|
||||
ptReserved
|
||||
Reserved; do not use.
|
||||
ptMaxSize
|
||||
Specifies the maximized width (POINT. x) and the maximized height
|
||||
(POINT. y) of the window. For systems with multiple monitors, this
|
||||
refers to the primary monitor. ptMaxPosition Specifies the
|
||||
position of the left side of the maximized window (POINT. x) and
|
||||
the position of the top of the maximized window (POINT. y). For
|
||||
systems with multiple monitors, this refers to the monitor on
|
||||
which the window maximizes.
|
||||
|
||||
ptMinTrackSize
|
||||
Specifies the minimum tracking width (POINT. x) and the minimum
|
||||
tracking height (POINT. y) of the window. This is unchanged for
|
||||
systems with multiple monitors.
|
||||
|
||||
ptMaxTrackSize
|
||||
Specifies the maximum tracking width (POINT. x) and the maximum
|
||||
tracking height (POINT. y) of the window. For systems with
|
||||
multiple monitors, this is the size for a window that is made as
|
||||
large as the virtual screen.
|
||||
*/
|
||||
- (NSMutableString *) MINMAXDetails:(MINMAXINFO *) mm
|
||||
{
|
||||
NSMutableString * output =[NSMutableString stringWithString:spacer];
|
||||
[output appendString:@"MINMAXINFO"];
|
||||
|
||||
[output appendFormat:@"ptMaxSize width[%ld] X height[%ld]\n",
|
||||
mm->ptMaxSize.x,mm->ptMaxSize.y];
|
||||
|
||||
[output appendFormat:@"ptMaxPosition width[%ld] X height[%ld]\n",
|
||||
mm->ptMaxPosition.x,mm->ptMaxPosition.y];
|
||||
|
||||
[output appendFormat:@"ptMinTrackSize width[%ld] X height[%ld]\n",
|
||||
mm->ptMinTrackSize.x,mm->ptMinTrackSize.y];
|
||||
|
||||
[output appendFormat:@"ptMaxTrackSize width[%ld] X height[%ld]\n",
|
||||
mm->ptMaxTrackSize.x,mm->ptMaxTrackSize.y];
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
- (NSMutableString *) subViewDetails:(NSWindow *)theWindow
|
||||
{
|
||||
NSView * cView=[theWindow contentView];
|
||||
NSView * sView=[cView superview];
|
||||
NSArray * theViews=[cView subviews];
|
||||
unsigned int i=0;
|
||||
unsigned int c=[theViews count];
|
||||
NSView * temp=nil;
|
||||
NSRect cvRect = [cView frame];
|
||||
NSRect svRect = [sView frame];
|
||||
NSRect tRect;
|
||||
NSMutableString * output =[NSMutableString stringWithString:spacer];
|
||||
[output appendFormat:@"subView Details for %s\n",[[theWindow title] cString]];
|
||||
[output appendFormat:@"superRect %s",
|
||||
[[self NSRectDetails:svRect] cString]];
|
||||
[output appendFormat:@"contentRect %s",
|
||||
[[self NSRectDetails:cvRect] cString]];
|
||||
|
||||
for (i=0;i<c;i++)
|
||||
{
|
||||
temp=[theViews objectAtIndex:i];
|
||||
tRect =[temp frame];
|
||||
[output appendFormat:@"subView %u rect %s",
|
||||
i,[[self NSRectDetails:tRect] cString]];
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
@end
|
391
Source/win32/w32_general.m
Normal file
391
Source/win32/w32_general.m
Normal file
|
@ -0,0 +1,391 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
Part of this code have been written by:
|
||||
Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "w32_Events.h"
|
||||
|
||||
@implementation WIN32Server (w32_General)
|
||||
/*
|
||||
|
||||
WM_CLOSE Notification
|
||||
|
||||
The WM_CLOSE message is sent as a signal that a window or an
|
||||
application should terminate.
|
||||
|
||||
A window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_CLOSE
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
An application can prompt the user for confirmation, prior to
|
||||
destroying a window, by processing the WM_CLOSE message and calling
|
||||
the DestroyWindow function only if the user confirms the choice.
|
||||
|
||||
By default, the DefWindowProc function calls the DestroyWindow
|
||||
function to destroy the window.
|
||||
|
||||
*/
|
||||
- (void) decodeWM_CLOSEParams:(WPARAM)wParam :(LPARAM)lParam :(HWND)hwnd;
|
||||
{
|
||||
NSEvent * ev;
|
||||
NSPoint eventLocation = NSMakePoint(0,0);
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowClose
|
||||
data1: 0
|
||||
data2: 0];
|
||||
|
||||
// need to send the event... or handle it directly.
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
|
||||
ev=nil;
|
||||
flags._eventHandled=YES;
|
||||
|
||||
#ifdef __CLOSE__
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "CLOSE", hwnd);
|
||||
printf("CLOSING\n");
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("sending event %s \n",[[ev eventNameWithSubtype:YES] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_NCDESTROY Notification
|
||||
|
||||
The WM_NCDESTROY message informs a window that its nonclient area is
|
||||
being destroyed. The DestroyWindow function sends the WM_NCDESTROY
|
||||
message to the window following the WM_DESTROY message. WM_DESTROY
|
||||
is used to free the allocated memory object associated with the
|
||||
window.
|
||||
The WM_NCDESTROY message is sent after the child windows have been
|
||||
destroyed. In contrast, WM_DESTROY is sent before the child windows
|
||||
are destroyed. A window receives this message through its
|
||||
WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_NCDESTROY
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
This message frees any memory internally allocated for the window.
|
||||
*/
|
||||
- (void) decodeWM_NCDESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_NCDESTROY\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_DESTROY Notification
|
||||
|
||||
The WM_DESTROY message is sent when a window is being destroyed. It
|
||||
is sent to the window procedure of the window being destroyed after
|
||||
the window is removed from the screen. This message is sent first
|
||||
to the window being destroyed and then to the child windows (if any)
|
||||
as they are destroyed. During the processing of the message, it can
|
||||
be assumed that all child windows still exist. A window receives
|
||||
this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_DESTROY
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
If the window being destroyed is part of the clipboard viewer chain
|
||||
(set by calling the SetClipboardViewer function), the window must
|
||||
remove itself from the chain by processing the ChangeClipboardChain
|
||||
function before returning from the WM_DESTROY message.
|
||||
*/
|
||||
- (void) decodeWM_DESTROYParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
|
||||
// Clean up window-specific data objects.
|
||||
|
||||
if (win->useHDC)
|
||||
{
|
||||
HGDIOBJ old;
|
||||
|
||||
old = SelectObject(win->hdc, win->old);
|
||||
DeleteObject(old);
|
||||
DeleteDC(win->hdc);
|
||||
}
|
||||
objc_free(win);
|
||||
flags._eventHandled=YES;
|
||||
|
||||
#ifdef __DESTROY__
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_QUERYOPEN Notification
|
||||
|
||||
The WM_QUERYOPEN message is sent to an icon when the user requests
|
||||
that the window be restored to its previous size and position. A
|
||||
window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_QUERYOPEN
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
|
||||
If the icon can be opened, an application that processes this
|
||||
message should return TRUE; otherwise, it should return FALSE to
|
||||
prevent the icon from being opened.
|
||||
|
||||
Remarks
|
||||
|
||||
By default, the DefWindowProc function returns TRUE.
|
||||
|
||||
While processing this message, the application should not perform
|
||||
any action that would cause an activation or focus change (for
|
||||
example, creating a dialog box).
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_QUERYOPENParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_QUERYOPEN\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_SYSCOMMAND Notification
|
||||
|
||||
A window receives this message when the user chooses a command from
|
||||
the Window menu (formerly known as the system or control menu) or
|
||||
when the user chooses the maximize button, minimize button, restore
|
||||
button, or close button.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_SYSCOMMAND
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Specifies the type of system command requested. This parameter can
|
||||
be one of the following values. SC_CLOSE Closes the window.
|
||||
|
||||
SC_CONTEXTHELP
|
||||
Changes the cursor to a question mark with a pointer. If the user
|
||||
then clicks a control in the dialog box, the control receives a
|
||||
WM_HELP message. SC_DEFAULT Selects the default item; the user
|
||||
double-clicked the window menu.
|
||||
|
||||
SC_HOTKEY
|
||||
Activates the window associated with the application-specified hot
|
||||
key. The lParam parameter identifies the window to
|
||||
activate. SC_HSCROLL Scrolls horizontally.
|
||||
|
||||
SC_KEYMENU
|
||||
Retrieves the window menu as a result of a keystroke. For more
|
||||
information, see the Remarks section. SC_MAXIMIZE Maximizes the
|
||||
window.
|
||||
|
||||
SC_MINIMIZE
|
||||
Minimizes the window.
|
||||
|
||||
SC_MONITORPOWER
|
||||
Sets the state of the display. This command supports devices that
|
||||
have power- saving features, such as a battery-powered personal
|
||||
computer. The lParam parameter can have the following values:
|
||||
|
||||
1 - the display is going to low power
|
||||
|
||||
2 - the display is being shut off
|
||||
|
||||
SC_MOUSEMENU
|
||||
Retrieves the window menu as a result of a mouse click.
|
||||
SC_MOVE
|
||||
Moves the window.
|
||||
SC_NEXTWINDOW
|
||||
Moves to the next window.
|
||||
SC_PREVWINDOW
|
||||
Moves to the previous window.
|
||||
SC_RESTORE
|
||||
Restores the window to its normal position and size.
|
||||
SC_SCREENSAVE
|
||||
Executes the screen saver application specified in the [boot]
|
||||
section of the System.ini file. SC_SIZE Sizes the window.
|
||||
SC_TASKLIST
|
||||
Activates the Start menu.
|
||||
SC_VSCROLL
|
||||
Scrolls vertically.
|
||||
lParam
|
||||
The low-order word specifies the horizontal position of the cursor,
|
||||
in screen coordinates, if a window menu command is chosen with the
|
||||
mouse. Otherwise, this parameter is not used. The high-order word
|
||||
specifies the vertical position of the cursor, in screen
|
||||
coordinates, if a window menu command is chosen with the mouse. This
|
||||
parameter is –1 if the command is chosen using a system accelerator,
|
||||
or zero if using a mnemonic.
|
||||
|
||||
Return Value
|
||||
|
||||
An application should return zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
|
||||
To obtain the position coordinates in screen coordinates, use the following
|
||||
code:
|
||||
xPos = GET_X_LPARAM(lParam); // horizontal position
|
||||
yPos = GET_Y_LPARAM(lParam); // vertical position
|
||||
|
||||
|
||||
The DefWindowProc function carries out the window menu request for
|
||||
the predefined actions specified in the previous table. In
|
||||
WM_SYSCOMMAND messages, the four low-order bits of the wParam
|
||||
parameter are used internally by the system. To obtain the correct
|
||||
result when testing the value of wParam, an application must combine
|
||||
the value 0xFFF0 with the wParam value by using the bitwise AND
|
||||
operator. The menu items in a window menu can be modified by using
|
||||
the GetSystemMenu, AppendMenu, InsertMenu, ModifyMenu,
|
||||
InsertMenuItem, and SetMenuItemInfo functions. Applications that
|
||||
modify the window menu must process WM_SYSCOMMAND messages. An
|
||||
application can carry out any system command at any time by passing
|
||||
a WM_SYSCOMMAND message to DefWindowProc. Any WM_SYSCOMMAND messages
|
||||
not handled by the application must be passed to DefWindowProc. Any
|
||||
command values added by an application must be processed by the
|
||||
application and cannot be passed to DefWindowProc. Accelerator keys
|
||||
that are defined to choose items from the window menu are translated
|
||||
into WM_SYSCOMMAND messages; all other accelerator keystrokes are
|
||||
translated into WM_COMMAND messages. If the wParam is SC_KEYMENU,
|
||||
lParam contains the character code of the key that is used with the
|
||||
ALT key to display the popup menu. For example, pressing ALT+F to
|
||||
display the File popup will cause a WM_SYSCOMMAND with wParam equal
|
||||
to SC_KEYMENU and lParam equal to 'f'.
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_SYSCOMMANDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stubbed for future development
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_SYSCOMMAND\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
// should be moved to the debug catagory
|
||||
- (void) handleNotification:(NSNotification*)aNotification
|
||||
{
|
||||
#ifdef __APPNOTIFICATIONS__
|
||||
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
||||
printf("+++ NEW EVENT +++\n");
|
||||
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
||||
printf("WM_APPNOTIFICATION -1\n %s\nPosted by current application\n",
|
||||
[[aNotification name] cString]);
|
||||
NSWindow *theWindow=[aNotification object];
|
||||
printf("%s",[[self gswindowstate:theWindow] cString]);
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void) resetForGSWindowStyle:(HWND)hwnd gsStryle:(int)aStyle
|
||||
{
|
||||
// to be completed for styles
|
||||
LONG result;
|
||||
|
||||
ShowWindow(hwnd,SW_HIDE);
|
||||
SetLastError(0);
|
||||
result=SetWindowLong(hwnd,GWL_EXSTYLE,(LONG)WS_EX_RIGHT);
|
||||
// should check error here...
|
||||
ShowWindow(hwnd,SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
@end
|
727
Source/win32/w32_movesize.m
Normal file
727
Source/win32/w32_movesize.m
Normal file
|
@ -0,0 +1,727 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "w32_Events.h"
|
||||
|
||||
@implementation WIN32Server (w32_movesize)
|
||||
|
||||
/*
|
||||
* The WM_MOVE message is sent after a window has been moved.
|
||||
* A window receives this message through its WindowProc function.
|
||||
*
|
||||
* Syntax
|
||||
*
|
||||
* WM_MOVE
|
||||
*
|
||||
* WPARAM wParam
|
||||
* LPARAM lParam;
|
||||
*
|
||||
* Parameters
|
||||
*
|
||||
* wParam
|
||||
* This parameter is not used.
|
||||
* lParam
|
||||
* Specifies the x and y coordinates of the upper-left corner of the
|
||||
* client area of the window. The low-order word contains the x-coordinate
|
||||
* while the high-order word contains the y coordinate.
|
||||
*
|
||||
* Return Value
|
||||
*
|
||||
* If an application processes this message, it should return zero.
|
||||
*
|
||||
* Remarks
|
||||
*
|
||||
* The parameters are given in screen coordinates for overlapped and pop-up
|
||||
* windows and in parent-client coordinates for child windows.
|
||||
*
|
||||
* The following example demonstrates how to obtain the position from
|
||||
* the lParam parameter.
|
||||
*
|
||||
* xPos = (int)(short) LOWORD(lParam); // horizontal position
|
||||
* yPos = (int)(short) HIWORD(lParam); // vertical position
|
||||
*
|
||||
* You can also use the MAKEPOINTS macro to convert the lParam parameter
|
||||
* to a POINTS structure.
|
||||
*
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_MOVEParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
||||
{
|
||||
|
||||
NSPoint eventLocation;
|
||||
NSRect rect;
|
||||
RECT r;
|
||||
NSEvent *ev = nil;
|
||||
GetWindowRect(hwnd, &r);
|
||||
|
||||
rect = MSScreenRectToGS(r, [EVENT_WINDOW(hwnd) styleMask], self);
|
||||
|
||||
eventLocation = rect.origin;
|
||||
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowMoved
|
||||
data1: rect.origin.x
|
||||
data2: rect.origin.y];
|
||||
|
||||
|
||||
if(hwnd==(HWND)flags.menuRef)
|
||||
{
|
||||
//need native code here?
|
||||
if(flags.HOLD_MENU_FOR_MOVE==FALSE)
|
||||
{
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(flags.HOLD_TRANSIENT_FOR_MOVE==FALSE)
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
}
|
||||
|
||||
#ifdef __WM_MOVE__
|
||||
printf("sending GS_EVENT %d GS_SUBTYPE %d\n",[ev type],[ev subtype]);
|
||||
printf("HOLD_MENU_FOR_MOVE is %s\n",flags.HOLD_MENU_FOR_MOVE ? "TRUE" : "FALSE");
|
||||
printf("HOLD_MENU_FOR_SIZE is %s\n",flags.HOLD_MENU_FOR_SIZE ? "TRUE" : "FALSE");
|
||||
|
||||
printf("%s\n",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("EVENTLOCATION %s",[[self NSRectDetails:rect] cString]);
|
||||
printf("[hwnd rect] is %s",[[self NSRectDetails:[EVENT_WINDOW(hwnd) frame]] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
ev=nil;
|
||||
flags.HOLD_MENU_FOR_MOVE=FALSE;
|
||||
flags.HOLD_MINI_FOR_MOVE=FALSE;
|
||||
flags.HOLD_TRANSIENT_FOR_MOVE=FALSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* WM_SIZE Notification
|
||||
* The WM_SIZE message is sent to a window after its size has changed.
|
||||
*
|
||||
* A window receives this message through its WindowProc function.
|
||||
*
|
||||
* Syntax
|
||||
*
|
||||
* WM_SIZE
|
||||
*
|
||||
* WPARAM wParam
|
||||
* LPARAM lParam;
|
||||
*
|
||||
* Parameters
|
||||
*
|
||||
* wParam
|
||||
* Specifies the type of resizing requested. This parameter can be one
|
||||
* of the following values.
|
||||
* SIZE_MAXHIDE 4
|
||||
* Message is sent to all pop-up windows when some other
|
||||
* window is maximized.
|
||||
* SIZE_MAXIMIZED 2
|
||||
* The window has been maximized.
|
||||
* SIZE_MAXSHOW 3
|
||||
* Message is sent to all pop-up windows when some other window has been
|
||||
* restored to its former size.
|
||||
* SIZE_MINIMIZED 1
|
||||
* The window has been minimized.
|
||||
* SIZE_RESTORED 0
|
||||
* The window has been resized, but neither the SIZE_MINIMIZED nor
|
||||
* SIZE_MAXIMIZED value applies.
|
||||
* lParam
|
||||
* The low-order word of lParam specifies the new width of the client area.
|
||||
* The high-order word of lParam specifies the new height of the client area.
|
||||
*
|
||||
* Return Value
|
||||
*
|
||||
* If an application processes this message, it should return zero.
|
||||
*
|
||||
* Remarks
|
||||
*
|
||||
* If the SetScrollPos or MoveWindow function is called for a child window as a
|
||||
* result of the WM_SIZE message, the bRedraw or bRepaint parameter should be
|
||||
* nonzero to cause the window to be repainted.
|
||||
*
|
||||
* Although the width and height of a window are 32-bit values,
|
||||
* the lParam parameter contains only the low-order 16 bits of each.
|
||||
*
|
||||
*/
|
||||
- (LRESULT) decodeWM_SIZEParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
||||
{
|
||||
NSPoint eventLocation;
|
||||
NSRect rect;
|
||||
RECT r;
|
||||
NSEvent *ev =nil;
|
||||
|
||||
GetWindowRect(hwnd, &r);
|
||||
|
||||
rect = MSScreenRectToGS(r, [EVENT_WINDOW(hwnd) styleMask], self);
|
||||
|
||||
eventLocation = rect.origin;
|
||||
switch ((int)wParam)
|
||||
{
|
||||
case SIZE_MAXHIDE:
|
||||
{
|
||||
// stubbed for future development
|
||||
#ifdef __WM_SIZE__
|
||||
printf("got SIZE_MAXHIDE message\n");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SIZE_MAXIMIZED:
|
||||
{
|
||||
// stubbed for future development
|
||||
#ifdef __WM_SIZE__
|
||||
printf("got SIZE_MAXIMIZED message\n");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SIZE_MAXSHOW:
|
||||
{
|
||||
// stubbed for future development
|
||||
#ifdef __WM_SIZE__
|
||||
printf("got SIZE_MAXSHOW message\n");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case SIZE_MINIMIZED:
|
||||
{
|
||||
|
||||
if (flags.HOLD_MINI_FOR_SIZE==TRUE) //// this is fix for [5,25 bug]
|
||||
break;
|
||||
|
||||
// make event
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowResized
|
||||
data1: rect.size.width
|
||||
data2: rect.size.height];
|
||||
|
||||
if(hwnd==(HWND)flags.menuRef)
|
||||
{
|
||||
if(flags.HOLD_MENU_FOR_SIZE==FALSE)
|
||||
{
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
[self resizeBackingStoreFor:hwnd];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flags.HOLD_TRANSIENT_FOR_SIZE==FALSE)
|
||||
{
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
[self resizeBackingStoreFor:hwnd];
|
||||
[EVENT_WINDOW(hwnd) miniaturize:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SIZE_RESTORED:
|
||||
{
|
||||
|
||||
// make event
|
||||
ev = [NSEvent otherEventWithType: NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowResized
|
||||
data1: rect.size.width
|
||||
data2: rect.size.height];
|
||||
|
||||
if(hwnd==(HWND)flags.menuRef)
|
||||
{
|
||||
if(flags.HOLD_MENU_FOR_SIZE==FALSE)
|
||||
{
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
[self resizeBackingStoreFor:hwnd];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flags.HOLD_TRANSIENT_FOR_SIZE==FALSE)
|
||||
{
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
[self resizeBackingStoreFor:hwnd];
|
||||
// fixes part one of bug [5,25] see notes
|
||||
[EVENT_WINDOW(hwnd) deminiaturize:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __WM_SIZE__
|
||||
printf("sending GS_EVENT %d GS_SUBTYPE %d\n",[ev type],[ev subtype]);
|
||||
printf("[wParam] SIZE_FLAG is %d\n",(int)wParam);
|
||||
printf("HOLD_MENU_FOR_MOVE is %s\n",flags.HOLD_MENU_FOR_MOVE ? "TRUE" : "FALSE");
|
||||
printf("HOLD_MENU_FOR_SIZE is %s\n",flags.HOLD_MENU_FOR_SIZE ? "TRUE" : "FALSE");
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("size to:%s",[[self NSRectDetails:rect] cString]);
|
||||
printf("[hwnd rect] is %s",[[self NSRectDetails:[EVENT_WINDOW(hwnd) frame]] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
ev=nil;
|
||||
flags.HOLD_MENU_FOR_SIZE=FALSE;
|
||||
flags.HOLD_MINI_FOR_SIZE=FALSE;
|
||||
flags.HOLD_TRANSIENT_FOR_SIZE=FALSE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
WM_NCCALCSIZE Notification
|
||||
|
||||
The WM_NCCALCSIZE message is sent when the size and position of a
|
||||
window's client area must be calculated. By processing this message,
|
||||
an application can control the content of the window's client area
|
||||
when the size or position of the window changes.
|
||||
|
||||
A window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_NCCALCSIZE
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
If wParam is TRUE, it specifies that the application should indicate
|
||||
which part of the client area contains valid information. The system
|
||||
copies the valid information to the specified area within the new
|
||||
client area. If wParam is FALSE, the application does not need to
|
||||
indicate the valid part of the client area.
|
||||
|
||||
lParam
|
||||
If wParam is TRUE, lParam points to an NCCALCSIZE_PARAMS structure
|
||||
that contains information an application can use to calculate the
|
||||
new size and position of the client rectangle. If wParam is FALSE,
|
||||
lParam points to a RECT structure. On entry, the structure contains
|
||||
the proposed window rectangle for the window. On exit, the structure
|
||||
should contain the screen coordinates of the corresponding window
|
||||
client area.
|
||||
|
||||
Return Value
|
||||
|
||||
If the wParam parameter is FALSE, the application should return zero.
|
||||
|
||||
If wParam is TRUE, the application should return zero or a
|
||||
combination of the following values.
|
||||
|
||||
If wParam is TRUE and an application returns zero, the old client
|
||||
area is preserved and is aligned with the upper-left corner of the
|
||||
new client area.
|
||||
|
||||
|
||||
WVR_ALIGNTOP
|
||||
Specifies that the client area of the window is to be preserved
|
||||
and aligned with the top of the new position of the window. For
|
||||
example, to align the client area to the upper-left corner, return
|
||||
the WVR_ALIGNTOP and WVR_ALIGNLEFT values.
|
||||
|
||||
WVR_ALIGNLEFT
|
||||
Specifies that the client area of the window is to be preserved
|
||||
and aligned with the left side of the new position of the
|
||||
window. For example, to align the client area to the lower-left
|
||||
corner, return the WVR_ALIGNLEFT and WVR_ALIGNBOTTOM values.
|
||||
|
||||
WVR_ALIGNBOTTOM
|
||||
Specifies that the client area of the window is to be preserved
|
||||
and aligned with the bottom of the new position of the window. For
|
||||
example, to align the client area to the top-left corner, return
|
||||
the WVR_ALIGNTOP and WVR_ALIGNLEFT values.
|
||||
|
||||
WVR_HREDRAW
|
||||
Used in combination with any other values, causes the window to be
|
||||
completely redrawn if the client rectangle changes size
|
||||
horizontally. This value is similar to CS_HREDRAW class style
|
||||
|
||||
|
||||
WVR_VREDRAW
|
||||
Used in combination with any other values, causes the window to be
|
||||
completely redrawn if the client rectangle changes size
|
||||
vertically. This value is similar to CS_VREDRAW class style
|
||||
|
||||
WVR_REDRAW
|
||||
|
||||
This value causes the entire window to be redrawn. It is a
|
||||
combination of WVR_HREDRAW and WVR_VREDRAW values. WVR_VALIDRECTS
|
||||
This value indicates that, upon return from WM_NCCALCSIZE, the
|
||||
rectangles specified by the rgrc[1] and rgrc[2] members of the
|
||||
NCCALCSIZE_PARAMS structure contain valid destination and source
|
||||
area rectangles, respectively. The system combines these
|
||||
rectangles to calculate the area of the window to be
|
||||
preserved. The system copies any part of the window image that is
|
||||
within the source rectangle and clips the image to the destination
|
||||
rectangle. Both rectangles are in parent-relative or
|
||||
screen-relative coordinates.
|
||||
|
||||
This return value allows an application to implement more elaborate
|
||||
client-area preservation strategies, such as centering or preserving
|
||||
a subset of the client area.
|
||||
|
||||
Remarks
|
||||
|
||||
The window may be redrawn, depending on whether the CS_HREDRAW or
|
||||
CS_VREDRAW class style is specified. This is the default,
|
||||
backward-compatible processing of this message by the
|
||||
DefWindowProc function (in addition to the usual client rectangle
|
||||
calculation described in the preceding table).
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_NCCALCSIZEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_NCCALCSIZE\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_WINDOWPOSCHANGED Notification
|
||||
|
||||
The WM_WINDOWPOSCHANGED message is sent to a window whose size,
|
||||
position, or place in the Z order has changed as a result of a call
|
||||
to the SetWindowPos function or another window-management function.
|
||||
A window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_WINDOWPOSCHANGED
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Pointer to a WINDOWPOS structure that contains information about the
|
||||
window's new size and position. Return Value
|
||||
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
By default, the DefWindowProc function sends the WM_SIZE and WM_MOVE
|
||||
messages to the window. The WM_SIZE and WM_MOVE messages are not
|
||||
sent if an application handles the WM_WINDOWPOSCHANGED message
|
||||
without calling DefWindowProc. It is more efficient to perform any
|
||||
move or size change processing during the WM_WINDOWPOSCHANGED
|
||||
message without calling DefWindowProc.
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_WINDOWPOSCHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_WINDOWPOSCHANGED\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
WM_WINDOWPOSCHANGING Notification
|
||||
|
||||
The WM_WINDOWPOSCHANGING message is sent to a window whose size,
|
||||
position, or place in the Z order is about to change as a result of
|
||||
a call to the SetWindowPos function or another window-management
|
||||
function. A window receives this message through its WindowProc
|
||||
function.
|
||||
|
||||
|
||||
Syntax
|
||||
|
||||
WM_WINDOWPOSCHANGING
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Pointer to a WINDOWPOS structure that contains information about the
|
||||
window's new size and position. Return Value
|
||||
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
For a window with the WS_OVERLAPPED or WS_THICKFRAME style, the
|
||||
DefWindowProc function sends the WM_GETMINMAXINFO message to the
|
||||
window. This is done to validate the new size and position of the
|
||||
window and to enforce the CS_BYTEALIGNCLIENT and CS_BYTEALIGNWINDOW
|
||||
client styles. By not passing the WM_WINDOWPOSCHANGING message to
|
||||
the DefWindowProc function, an application can override these
|
||||
defaults. While this message is being processed, modifying any of
|
||||
the values in WINDOWPOS affects the window's new size, position, or
|
||||
place in the Z order. An application can prevent changes to the
|
||||
window by setting or clearing the appropriate bits in the flags
|
||||
member of WINDOWPOS.
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_WINDOWPOSCHANGINGParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_WINDOWPOSCHANGING\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_GETMINMAXINFO Notification
|
||||
|
||||
The WM_GETMINMAXINFO message is sent to a window when the size or
|
||||
position of the window is about to change. An application can use
|
||||
this message to override the window's default maximized size and
|
||||
position, or its default minimum or maximum tracking size.
|
||||
|
||||
A window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_GETMINMAXINFO
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Pointer to a MINMAXINFO structure that contains the default
|
||||
maximized position and dimensions, and the default minimum and
|
||||
maximum tracking sizes. An application can override the defaults by
|
||||
setting the members of this structure.
|
||||
|
||||
Return Value
|
||||
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
The maximum tracking size is the largest window size that can be
|
||||
produced by using the borders to size the window. The minimum
|
||||
tracking size is the smallest window size that can be produced by
|
||||
using the borders to size the window.
|
||||
|
||||
The MINMAXINFO structure contains information about a window's
|
||||
maximized size and position and its minimum and maximum tracking
|
||||
size.
|
||||
|
||||
Syntax
|
||||
|
||||
typedef struct {
|
||||
POINT ptReserved;
|
||||
POINT ptMaxSize;
|
||||
POINT ptMaxPosition;
|
||||
POINT ptMinTrackSize;
|
||||
POINT ptMaxTrackSize;
|
||||
} MINMAXINFO;
|
||||
Members
|
||||
|
||||
ptReserved
|
||||
Reserved; do not use.
|
||||
|
||||
ptMaxSize
|
||||
Specifies the maximized width (POINT. x) and the maximized height
|
||||
(POINT. y) of the window. For systems with multiple monitors, this
|
||||
refers to the primary monitor. ptMaxPosition Specifies the
|
||||
position of the left side of the maximized window (POINT. x) and
|
||||
the position of the top of the maximized window (POINT. y). For
|
||||
systems with multiple monitors, this refers to the monitor on
|
||||
which the window maximizes.
|
||||
|
||||
ptMinTrackSize
|
||||
Specifies the minimum tracking width (POINT. x) and the minimum
|
||||
tracking height (POINT. y) of the window. This is unchanged for
|
||||
systems with multiple monitors. ptMaxTrackSize Specifies the
|
||||
maximum tracking width (POINT. x) and the maximum tracking height
|
||||
(POINT. y) of the window. For systems with multiple monitors, this
|
||||
is the size for a window that is made as large as the virtual
|
||||
screen.
|
||||
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_GETMINMAXINFOParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// reused from original author (added debug code)
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
MINMAXINFO *mm;
|
||||
|
||||
if (win != NULL)
|
||||
{
|
||||
mm = (MINMAXINFO*)lParam;
|
||||
mm->ptMinTrackSize = win->minmax.ptMinTrackSize;
|
||||
mm->ptMaxTrackSize = win->minmax.ptMaxTrackSize;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __GETMINMAXINFO__
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("%s",[[self MINMAXDetails:mm] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_EXITSIZEMOVE Notification
|
||||
|
||||
The WM_EXITSIZEMOVE message is sent one time to a window, after it
|
||||
has exited the moving or sizing modal loop. The window enters the
|
||||
moving or sizing modal loop when the user clicks the window's title
|
||||
bar or sizing border, or when the window passes the WM_SYSCOMMAND
|
||||
message to the DefWindowProc function and the wParam parameter of
|
||||
the message specifies the SC_MOVE or SC_SIZE value. The operation
|
||||
is complete when DefWindowProc returns.
|
||||
|
||||
A window receives this message through its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_EXITSIZEMOVE
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
|
||||
An application should return zero if it processes this message.
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_EXITSIZEMOVEParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// may have a small bug here note it for follow up
|
||||
/*
|
||||
decodeWM_MOVE and decodeWM_SIZE will send event if they have one.
|
||||
no posting is needed.
|
||||
*/
|
||||
[self resizeBackingStoreFor: hwnd];
|
||||
[self decodeWM_MOVEParams:hwnd :wParam :lParam];
|
||||
[self decodeWM_SIZEParams:hwnd :wParam :lParam];
|
||||
|
||||
//Make sure DefWindowProc gets called
|
||||
|
||||
#ifdef __EXITSIZEMOVE__
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "EXITSIZEMOVE", hwnd);
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_SIZING Notification
|
||||
|
||||
The WM_SIZING message is sent to a window that the user is
|
||||
resizing. By processing this message, an application can monitor the
|
||||
size and position of the drag rectangle and, if needed, change its
|
||||
size or position. A window receives this message through its
|
||||
WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_SIZING
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Specifies which edge of the window is being sized. This parameter
|
||||
can be one of the following values.
|
||||
WMSZ_BOTTOM
|
||||
Bottom edge
|
||||
WMSZ_BOTTOMLEFT
|
||||
Bottom-left corner
|
||||
WMSZ_BOTTOMRIGHT
|
||||
Bottom-right corner
|
||||
WMSZ_LEFT
|
||||
Left edge
|
||||
WMSZ_RIGHT
|
||||
Right edge
|
||||
WMSZ_TOP
|
||||
Top edge
|
||||
WMSZ_TOPLEFT
|
||||
Top-left corner
|
||||
WMSZ_TOPRIGHT
|
||||
Top-right corner
|
||||
lParam
|
||||
Pointer to a RECT structure with the screen coordinates of the
|
||||
drag rectangle. To change the size or position of the drag
|
||||
rectangle, an application must change the members of this
|
||||
structure.
|
||||
|
||||
Return Value
|
||||
An application should return TRUE if it processes this message.
|
||||
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_SIZINGParams:(HWND)hwnd : (WPARAM)wParam : (LPARAM)lParam
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __SIZING__
|
||||
printf("SIZING was called\n");
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@end
|
291
Source/win32/w32_text_focus.m
Normal file
291
Source/win32/w32_text_focus.m
Normal file
|
@ -0,0 +1,291 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
Part of this code have been re-written by:
|
||||
Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "w32_Events.h"
|
||||
|
||||
@implementation WIN32Server (w32_text_focus)
|
||||
|
||||
/*
|
||||
WM_SETTEXT Message
|
||||
|
||||
An application sends a WM_SETTEXT message to set the text of a window.
|
||||
|
||||
Syntax
|
||||
|
||||
To send this message, call the SendMessage function as
|
||||
follows. lResult = SendMessage( // returns LRESULT in lResult (HWND)
|
||||
hWndControl, // handle to destination control (UINT) WM_SETTEXT, //
|
||||
message ID (WPARAM) wParam, // = (WPARAM) () wParam; (LPARAM) lParam
|
||||
// = (LPARAM) () lParam; ); Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Pointer to a null-terminated string that is the window text. Return
|
||||
Value
|
||||
|
||||
The return value is TRUE if the text is set. It is FALSE (for an
|
||||
edit control), LB_ERRSPACE (for a list box), or CB_ERRSPACE (for a
|
||||
combo box) if insufficient space is available to set the text in the
|
||||
edit control. It is CB_ERR if this message is sent to a combo box
|
||||
without an edit control.
|
||||
|
||||
Remarks
|
||||
|
||||
The DefWindowProc function sets and displays the window text. For an
|
||||
edit control, the text is the contents of the edit control. For a
|
||||
combo box, the text is the contents of the edit-control portion of
|
||||
the combo box. For a button, the text is the button name. For other
|
||||
windows, the text is the window title.
|
||||
|
||||
This message does not change the current selection in the list box
|
||||
of a combo box. An application should use the CB_SELECTSTRING
|
||||
message to select the item in a list box that matches the text in
|
||||
the edit control.
|
||||
|
||||
*/
|
||||
|
||||
//- (LRESULT) decodeWM_SETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
//{
|
||||
//printf("WM_SETTEXT\n");
|
||||
//printf("Window text is: %s\n",(LPSTR)lParam);
|
||||
|
||||
//BOOL result=SetWindowText(hwnd,(LPSTR)lParam);
|
||||
|
||||
// if (result==0)
|
||||
//printf("error on setWindow text %ld\n",GetLastError());
|
||||
|
||||
//return 0;
|
||||
//}
|
||||
|
||||
/*
|
||||
|
||||
WM_SETFOCUS Notification
|
||||
|
||||
The WM_SETFOCUS message is sent to a window after it has gained the
|
||||
keyboard focus.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_SETFOCUS
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Handle to the window that has lost the keyboard focus. This
|
||||
parameter can be NULL.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
|
||||
An application should return zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
|
||||
To display a caret, an application should call the appropriate caret
|
||||
functions when it receives the WM_SETFOCUS message.
|
||||
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_SETFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// reused from original author (added debug output)
|
||||
/* This message comes when the window already got focus, so we send a focus
|
||||
in event to the front end, but also mark the window as having current focus
|
||||
so that the front end doesn't try to focus the window again. */
|
||||
|
||||
int key_num, win_num;
|
||||
NSPoint eventLocation;
|
||||
|
||||
key_num = [[NSApp keyWindow] windowNumber];
|
||||
win_num = (int)hwnd;
|
||||
|
||||
currentFocus = hwnd;
|
||||
eventLocation = NSMakePoint(0,0);
|
||||
if (currentFocus == desiredFocus)
|
||||
{
|
||||
/* This was from a request from the front end. Mark as done. */
|
||||
desiredFocus = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We need to do this directly and not send an event to the frontend -
|
||||
that's too slow and allows the window state to get out of sync,
|
||||
causing bad recursion problems */
|
||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
||||
if ([window canBecomeKeyWindow] == YES)
|
||||
{
|
||||
NSDebugLLog(@"Focus", @"Making %d key", win_num);
|
||||
[window makeKeyWindow];
|
||||
[window makeMainWindow];
|
||||
[NSApp activateIgnoringOtherApps: YES];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __SETFOCUS__
|
||||
NSDebugLLog(@"Focus", @"Got focus:%d (current = %d, key = %d)",
|
||||
win_num, currentFocus, key_num);
|
||||
NSDebugLLog(@"Focus", @" result of focus request");
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
WM_KILLFOCUS Notification
|
||||
|
||||
The WM_KILLFOCUS message is sent to a window immediately before it
|
||||
loses the keyboard focus.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_KILLFOCUS
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Handle to the window that receives the keyboard focus. This
|
||||
parameter can be NULL.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
An application should return zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
|
||||
If an application is displaying a caret, the caret should be
|
||||
destroyed at this point. While processing this message, do not make
|
||||
any function calls that display or activate a window. This causes
|
||||
the thread to yield control and can cause the application to stop
|
||||
responding to messages. For more information, see Message Deadlocks.
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_KILLFOCUSParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// reused from original author (added debug output)
|
||||
NSPoint eventLocation = NSMakePoint(0,0);
|
||||
NSEvent * ev=nil;
|
||||
|
||||
ev = [NSEvent otherEventWithType:NSAppKitDefined
|
||||
location: eventLocation
|
||||
modifierFlags: 0
|
||||
timestamp: 0
|
||||
windowNumber: (int)hwnd
|
||||
context: GSCurrentContext()
|
||||
subtype: GSAppKitWindowFocusOut
|
||||
data1: 0
|
||||
data2: 0];
|
||||
|
||||
[EVENT_WINDOW(hwnd) sendEvent:ev];
|
||||
flags._eventHandled=YES;
|
||||
|
||||
#ifdef __KILLFOCUS__
|
||||
NSDebugLLog(@"NSEvent", @"Got Message %s for %d", "KILLFOCUS", hwnd);
|
||||
NSDebugLLog(@"Focus", @"Got KILLFOCUS (focus out) for %d", hwnd);
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_GETTEXT Message
|
||||
|
||||
An application sends a WM_GETTEXT message to copy the text that
|
||||
corresponds to a window into a buffer provided by the caller.
|
||||
Syntax
|
||||
|
||||
|
||||
To send this message, call the SendMessage function as follows.
|
||||
lResult = SendMessage( // returns LRESULT in lResult (HWND)
|
||||
hWndControl, // handle to destination control (UINT) WM_GETTEXT, //
|
||||
message ID (WPARAM) wParam, // = (WPARAM) () wParam; (LPARAM) lParam
|
||||
// = (LPARAM) () lParam; ); Parameters
|
||||
|
||||
wParam
|
||||
Specifies the maximum number of TCHARs to be copied, including the
|
||||
terminating null character. Windows NT/2000/XP:ANSI applications may
|
||||
have the string in the buffer reduced in size (to a minimum of half
|
||||
that of the wParam value) due to conversion from ANSI to Unicode.
|
||||
|
||||
lParam
|
||||
Pointer to the buffer that is to receive the text.
|
||||
Return Value
|
||||
|
||||
The return value is the number of TCHARs copied, not including the
|
||||
terminating null character.
|
||||
|
||||
Remarks
|
||||
|
||||
The DefWindowProc function copies the text associated with the
|
||||
window into the specified buffer and returns the number of
|
||||
characters copied. Note, for non- text static controls this gives
|
||||
you the text with which the control was originally created, that is,
|
||||
the ID number. However, it gives you the ID of the non-text static
|
||||
control as originally created. That is, if you subsequently used a
|
||||
STM_SETIMAGE to change it the original ID would still be returned.
|
||||
For an edit control, the text to be copied is the content of the
|
||||
edit control. For a combo box, the text is the content of the edit
|
||||
control (or static-text) portion of the combo box. For a button, the
|
||||
text is the button name. For other windows, the text is the window
|
||||
title. To copy the text of an item in a list box, an application can
|
||||
use the LB_GETTEXT message. When the WM_GETTEXT message is sent to
|
||||
a static control with the SS_ICON style, a handle to the icon will
|
||||
be returned in the first four bytes of the buffer pointed to by
|
||||
lParam. This is true only if the WM_SETTEXT message has been used to
|
||||
set the icon. Rich Edit: If the text to be copied exceeds 64K, use
|
||||
either the EM_STREAMOUT or EM_GETSELTEXT message. Windows 2000/XP:
|
||||
Sending a WM_GETTEXT message to a non-text static control, such as a
|
||||
static bitmap or static icon control, does not return a string
|
||||
value. Instead, it returns zero. In addition, in previous versions
|
||||
of Microsoft® Windows® and Microsoft Windows NT®, applications could
|
||||
send a WM_GETTEXT message to a non-text static control to retrieve
|
||||
the control's ID. To retrieve a control's ID in Windows 2000/XP,
|
||||
applications can use GetWindowLong passing GWL_ID as the index value
|
||||
or GetWindowLongPtr using GWLP_ID.
|
||||
|
||||
*/
|
||||
- (void) decodeWM_GETTEXTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_GETTEXT\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
539
Source/win32/w32_windowdisplay.m
Normal file
539
Source/win32/w32_windowdisplay.m
Normal file
|
@ -0,0 +1,539 @@
|
|||
/* WIN32Server - Implements window handling for MSWindows
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: March 2002
|
||||
Part of this code have been re-written by:
|
||||
Tom MacSween <macsweent@sympatico.ca>
|
||||
Date August 2005
|
||||
This file is part of the GNU Objective C User Interface Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "w32_Events.h"
|
||||
|
||||
static void invalidateWindow(HWND hwnd, RECT rect);
|
||||
|
||||
static void
|
||||
invalidateWindow(HWND hwnd, RECT rect)
|
||||
{
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)hwnd, GWL_USERDATA);
|
||||
|
||||
if (win->useHDC)
|
||||
{
|
||||
HDC hdc = GetDC((HWND)hwnd);
|
||||
WINBOOL result;
|
||||
|
||||
result = BitBlt(hdc, rect.left, rect.top,
|
||||
(rect.right - rect.left), (rect.bottom - rect.top),
|
||||
win->hdc, rect.left, rect.top, SRCCOPY);
|
||||
if (!result)
|
||||
{
|
||||
NSLog(@"validated window %d %@", hwnd,
|
||||
NSStringFromRect(MSWindowRectToGS((HWND)hwnd, rect)));
|
||||
NSLog(@"validateWindow failed %d", GetLastError());
|
||||
}
|
||||
ReleaseDC((HWND)hwnd, hdc);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSWindow *window = GSWindowWithNumber((int)hwnd);
|
||||
NSRect r = MSWindowRectToGS((HWND)hwnd, rect);
|
||||
|
||||
/*
|
||||
NSLog(@"Invalidated window %d %@ (%d, %d, %d, %d)", hwnd,
|
||||
NSStringFromRect(r), rect.left, rect.top, rect.right, rect.bottom);
|
||||
*/
|
||||
// Repaint the window's client area.
|
||||
[[window contentView] setNeedsDisplayInRect: r];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@implementation WIN32Server (w32_windowdisplay)
|
||||
|
||||
/*
|
||||
WM_SHOWWINDOW Notification
|
||||
|
||||
The WM_SHOWWINDOW message is sent to a window when the window is
|
||||
about to be hidden or shown. A window receives this message through
|
||||
its WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_SHOWWINDOW
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Specifies whether a window is being shown. If wParam is TRUE, the
|
||||
window is being shown. If wParam is FALSE, the window is being
|
||||
hidden. lParam Specifies the status of the window being shown. If
|
||||
lParam is zero, the message was sent because of a call to the
|
||||
ShowWindow function; otherwise, lParam is one of the following
|
||||
values.
|
||||
|
||||
SW_OTHERUNZOOM
|
||||
The window is being uncovered because a maximize window was restored or
|
||||
minimized.
|
||||
SW_OTHERZOOM
|
||||
The window is being covered by another window that has been maximized.
|
||||
SW_PARENTCLOSING
|
||||
The window's owner window is being minimized.
|
||||
SW_PARENTOPENING
|
||||
The window's owner window is being restored.
|
||||
|
||||
Return Value
|
||||
|
||||
If an application processes this message, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
The DefWindowProc function hides or shows the window, as specified
|
||||
by the message. If a window has the WS_VISIBLE style when it is
|
||||
created, the window receives this message after it is created, but
|
||||
before it is displayed. A window also receives this message when its
|
||||
visibility state is changed by the ShowWindow or ShowOwnedPopups
|
||||
function. The WM_SHOWWINDOW message is not sent under the following
|
||||
circumstances:
|
||||
|
||||
When a top-level, overlapped window is created with the WS_MAXIMIZE
|
||||
or WS_MINIMIZE style. When the SW_SHOWNORMAL flag is specified in
|
||||
the call to the ShowWindow function.
|
||||
|
||||
*/
|
||||
- (void) decodeWM_SHOWWINDOWParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
//SW_OTHERUNZOOM //window is being uncovered
|
||||
//SW_OTHERZOOM //window is being covered by window that has maximized.
|
||||
//SW_PARENTCLOSING // window's owner window is being minimized.
|
||||
//SW_PARENTOPENING //The window's owner window is being restored.
|
||||
//zero - 0 //call to the ShowWindow function
|
||||
|
||||
switch ((int)wParam)
|
||||
{
|
||||
case TRUE:
|
||||
{
|
||||
switch ((int)lParam)
|
||||
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
ShowWindow(hwnd,SW_SHOW);
|
||||
flags._eventHandled=YES;
|
||||
}
|
||||
break;
|
||||
case SW_PARENTCLOSING:
|
||||
{
|
||||
ShowWindow(hwnd,SW_SHOW);
|
||||
flags._eventHandled=YES;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case FALSE:
|
||||
{
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __SHOWWINDOW__
|
||||
printf("[wParam] show window %s\n",wParam ? "TRUE" : "FALSE");
|
||||
printf("[lParam] requested SW_FLAG %d\n",wParam);
|
||||
//printf("is Main Menu %d\n",_is_menu);
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_NCPAINT
|
||||
The WM_NCPAINT message is sent to a window when its frame must be
|
||||
painted. A window receives this message through its WindowProc
|
||||
function.
|
||||
|
||||
LRESULT CALLBACK WindowProc(
|
||||
HWND hwnd, // handle to window
|
||||
UINT uMsg, // WM_NCPAINT
|
||||
WPARAM wParam, // handle to update region (HRGN)
|
||||
LPARAM lParam // not used
|
||||
);
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Handle to the update region of the window. The update region is
|
||||
clipped to the window frame. When wParam is 1, the entire window
|
||||
frame needs to be updated.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Values
|
||||
An application returns zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
The DefWindowProc function paints the window frame.
|
||||
|
||||
An application can intercept the WM_NCPAINT message and paint its
|
||||
own custom window frame. The clipping region for a window is always
|
||||
rectangular, even if the shape of the frame is altered. The wParam
|
||||
value can be passed to GetDCEx as in the following example.
|
||||
|
||||
case WM_NCPAINT:
|
||||
{
|
||||
HDC hdc;
|
||||
hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
|
||||
// Paint into this DC
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
*/
|
||||
|
||||
- (void) decodeWM_NCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_NCPAINT\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
WM_ERASEBKGND Notification
|
||||
|
||||
The WM_ERASEBKGND message is sent when the window background must be
|
||||
erased (for example, when a window is resized). The message is sent
|
||||
to prepare an invalidated portion of a window for painting.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_ERASEBKGND
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
Handle to the device context.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
|
||||
An application should return nonzero if it erases the background;
|
||||
otherwise, it should return zero.
|
||||
|
||||
Remarks
|
||||
|
||||
The DefWindowProc function erases the background by using the class
|
||||
background brush specified by the hbrBackground member of the
|
||||
WNDCLASS structure. If hbrBackground is NULL, the application should
|
||||
process the WM_ERASEBKGND message and erase the background. An
|
||||
application should return nonzero in response to WM_ERASEBKGND if it
|
||||
processes the message and erases the background; this indicates that
|
||||
no further erasing is required. If the application returns zero, the
|
||||
window will remain marked for erasing. (Typically, this indicates
|
||||
that the fErase member of the PAINTSTRUCT structure will be TRUE.)
|
||||
|
||||
*/
|
||||
|
||||
- (LRESULT) decodeWM_ERASEBKGNDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// GS handles this for now...
|
||||
#ifdef __ERASEBKGND__
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return (LRESULT)1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_PAINT
|
||||
The WM_PAINT message is sent when the system or another application
|
||||
makes a request to paint a portion of an application's window. The
|
||||
message is sent when the UpdateWindow or RedrawWindow function is
|
||||
called, or by the DispatchMessage function when the application
|
||||
obtains a WM_PAINT message by using the GetMessage or PeekMessage
|
||||
function. A window receives this message through its WindowProc
|
||||
function.
|
||||
|
||||
LRESULT CALLBACK WindowProc(
|
||||
HWND hwnd, // handle to window
|
||||
UINT uMsg, // WM_PAINT
|
||||
WPARAM wParam, // not used
|
||||
LPARAM lParam // not used
|
||||
);
|
||||
Parameters
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Values
|
||||
An application returns zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
|
||||
The WM_PAINT message is generated by the system and should not be
|
||||
sent by an application. To force a window to draw into a specific
|
||||
device context, use the WM_PRINT or WM_PRINTCLIENT message. Note
|
||||
that this requires the target window to support the WM_PRINTCLIENT
|
||||
message. Most common controls support the WM_PRINTCLIENT message.
|
||||
The DefWindowProc function validates the update region. The function
|
||||
may also send the WM_NCPAINT message to the window procedure if the
|
||||
window frame must be painted and send the WM_ERASEBKGND message if
|
||||
the window background must be erased. The system sends this message
|
||||
when there are no other messages in the application's message queue.
|
||||
DispatchMessage determines where to send the message; GetMessage
|
||||
determines which message to dispatch. GetMessage returns the
|
||||
WM_PAINT message when there are no other messages in the
|
||||
application's message queue, and DispatchMessage sends the message
|
||||
to the appropriate window procedure. A window may receive internal
|
||||
paint messages as a result of calling RedrawWindow with the
|
||||
RDW_INTERNALPAINT flag set. In this case, the window may not have an
|
||||
update region. An application should call the GetUpdateRect function
|
||||
to determine whether the window has an update region. If
|
||||
GetUpdateRect returns zero, the application should not call the
|
||||
BeginPaint and EndPaint functions. An application must check for
|
||||
any necessary internal painting by looking at its internal data
|
||||
structures for each WM_PAINT message, because a WM_PAINT message may
|
||||
have been caused by both a non-NULL update region and a call to
|
||||
RedrawWindow with the RDW_INTERNALPAINT flag set. The system sends
|
||||
an internal WM_PAINT message only once. After an internal WM_PAINT
|
||||
message is returned from GetMessage or PeekMessage or is sent to a
|
||||
window by UpdateWindow, the system does not post or send further
|
||||
WM_PAINT messages until the window is invalidated or until
|
||||
RedrawWindow is called again with the RDW_INTERNALPAINT flag set.
|
||||
For some common controls, the default WM_PAINT message processing
|
||||
checks the wParam parameter. If wParam is non-NULL, the control
|
||||
assumes that the value is an HDC and paints using that device
|
||||
context.
|
||||
|
||||
*/
|
||||
- (void) decodeWM_PAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// reused from original author (added debug code)
|
||||
RECT rect;
|
||||
|
||||
if (GetUpdateRect(hwnd, &rect, NO))
|
||||
{
|
||||
invalidateWindow(hwnd, rect);
|
||||
// validate the whole window, for in some cases an infinite series
|
||||
// of WM_PAINT is triggered
|
||||
ValidateRect(hwnd, NULL);
|
||||
}
|
||||
|
||||
flags._eventHandled=YES;
|
||||
|
||||
#ifdef __PAINT__
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("%s",[[self MSRectDetails:rect] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
WM_SYNCPAINT
|
||||
The WM_SYNCPAINT message is used to synchronize painting while
|
||||
avoiding linking independent GUI threads. A window receives this
|
||||
message through its WindowProc function.
|
||||
|
||||
LRESULT CALLBACK WindowProc(
|
||||
HWND hwnd, // handle to window
|
||||
UINT uMsg, // WM_SYNCPAINT
|
||||
WPARAM wParam, // not used
|
||||
LPARAM lParam // not used
|
||||
);
|
||||
Parameters
|
||||
This message has no parameters.
|
||||
|
||||
Return Values
|
||||
An application returns zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
|
||||
When a window has been hidden, shown, moved, or sized, the system
|
||||
may determine that it is necessary to send a WM_SYNCPAINT message to
|
||||
the top-level windows of other threads. Applications must pass
|
||||
WM_SYNCPAINT to DefWindowProc for processing. The DefWindowProc
|
||||
function will send a WM_NCPAINT message to the window procedure if
|
||||
the window frame must be painted and send a WM_ERASEBKGND message if
|
||||
the window background must be erased.
|
||||
|
||||
*/
|
||||
|
||||
- (void) decodeWM_SYNCPAINTParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_SYNCPAINT\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
WM_CAPTURECHANGED Notification
|
||||
|
||||
The WM_CAPTURECHANGED message is sent to the window that is losing
|
||||
the mouse capture. A window receives this message through its
|
||||
WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_CAPTURECHANGED
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
|
||||
wParam
|
||||
This parameter is not used.
|
||||
lParam
|
||||
Handle to the window gaining the mouse capture.
|
||||
|
||||
Return Value
|
||||
|
||||
An application should return zero if it processes this message.
|
||||
|
||||
Remarks
|
||||
|
||||
A window receives this message even if it calls ReleaseCapture
|
||||
itself. An application should not attempt to set the mouse capture
|
||||
in response to this message. When it receives this message, a
|
||||
window should redraw itself, if necessary, to reflect the new
|
||||
mouse-capture state.
|
||||
*/
|
||||
- (void) decodeWM_CAPTURECHANGEDParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_CAPTURECHANGED\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
WM_GETICON Notification
|
||||
|
||||
The WM_GETICON message is sent to a window to retrieve a handle to
|
||||
the large or small icon associated with a window. The system
|
||||
displays the large icon in the ALT+TAB dialog, and the small icon in
|
||||
the window caption. A window receives this message through its
|
||||
WindowProc function.
|
||||
|
||||
Syntax
|
||||
|
||||
WM_GETICON
|
||||
|
||||
WPARAM wParam
|
||||
LPARAM lParam;
|
||||
|
||||
Parameters
|
||||
wParam
|
||||
Specifies the type of icon being retrieved. This parameter can be
|
||||
one of the following values.
|
||||
ICON_BIG
|
||||
Retrieve the large icon for the window.
|
||||
ICON_SMALL
|
||||
Retrieve the small icon for the window.
|
||||
ICON_SMALL2
|
||||
Windows XP: Retrieves the small icon provided by the
|
||||
application. If the application does not provide one, the system
|
||||
uses the system-generated icon for that window.
|
||||
lParam
|
||||
This parameter is not used.
|
||||
|
||||
Return Value
|
||||
The return value is a handle to the large or small icon, depending
|
||||
on the value of wParam. When an application receives this message,
|
||||
it can return a handle to a large or small icon, or pass the
|
||||
message to the DefWindowProc function.
|
||||
|
||||
Remarks
|
||||
|
||||
When an application receives this message, it can return a handle to
|
||||
a large or small icon, or pass the message to DefWindowProc.
|
||||
DefWindowProc returns a handle to the large or small icon associated
|
||||
with the window, depending on the value of wParam.
|
||||
|
||||
*/
|
||||
- (void) decodeWM_GETICONParams: (WPARAM)wParam : (LPARAM)lParam : (HWND)hwnd
|
||||
{
|
||||
// stub for future dev
|
||||
#ifdef __TESTEVENT__
|
||||
printf("WM_GETICON\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
- (void) resizeBackingStoreFor: (HWND)hwnd
|
||||
{
|
||||
// reused from original author (added debug code)
|
||||
RECT r;
|
||||
WIN_INTERN *win = (WIN_INTERN *)GetWindowLong((HWND)hwnd, GWL_USERDATA);
|
||||
|
||||
// FIXME: We should check if the size really did change.
|
||||
if (win->useHDC)
|
||||
{
|
||||
HDC hdc, hdc2;
|
||||
HBITMAP hbitmap;
|
||||
HGDIOBJ old;
|
||||
|
||||
old = SelectObject(win->hdc, win->old);
|
||||
DeleteObject(old);
|
||||
DeleteDC(win->hdc);
|
||||
win->hdc = NULL;
|
||||
win->old = NULL;
|
||||
|
||||
GetClientRect((HWND)hwnd, &r);
|
||||
hdc = GetDC((HWND)hwnd);
|
||||
hdc2 = CreateCompatibleDC(hdc);
|
||||
hbitmap = CreateCompatibleBitmap(hdc, r.right - r.left, r.bottom - r.top);
|
||||
win->old = SelectObject(hdc2, hbitmap);
|
||||
win->hdc = hdc2;
|
||||
|
||||
ReleaseDC((HWND)hwnd, hdc);
|
||||
}
|
||||
|
||||
#ifdef __BACKING__
|
||||
NSDebugLLog(@"NSEvent", @"Change backing store to %d %d", r.right - r.left, r.bottom - r.top);
|
||||
printf("RESIZING BACKING Store\n");
|
||||
printf("%s",[[self WindowDetail:EVENT_WINDOW(hwnd)] cString]);
|
||||
printf("New Rect: %s",[[self MSRectDetails:r] cString]);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
|
@ -502,7 +502,8 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
|
|||
|
||||
if (bits != data[0])
|
||||
{
|
||||
objc_free(bits);
|
||||
/* cast bits to Void Pointer to fix warning in compile */
|
||||
objc_free((void *)(bits));
|
||||
}
|
||||
objc_free(bitmap);
|
||||
return hbitmap;
|
||||
|
@ -897,14 +898,15 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
|
|||
[super DPSinitgraphics];
|
||||
}
|
||||
|
||||
- (void) DPSsetdash: (const float*)pattern : (int)count : (float)phase
|
||||
|
||||
- (void) DPSsetdash: (const float*)thePattern : (int)count : (float)phase
|
||||
{
|
||||
if (!path)
|
||||
{
|
||||
path = [NSBezierPath new];
|
||||
}
|
||||
|
||||
[path setLineDash: pattern count: count phase: phase];
|
||||
[path setLineDash: thePattern count: count phase: phase];
|
||||
}
|
||||
|
||||
- (void)DPScurrentmiterlimit: (float *)limit
|
||||
|
@ -1013,11 +1015,11 @@ HBITMAP GSCreateBitmap(HDC hDC, int pixelsWide, int pixelsHigh,
|
|||
penStyle = PS_GEOMETRIC | PS_SOLID;
|
||||
if (path)
|
||||
{
|
||||
float pattern[10];
|
||||
float thePattern[10];
|
||||
int count = 10;
|
||||
float phase;
|
||||
|
||||
[path getLineDash: pattern count: &count phase: &phase];
|
||||
[path getLineDash: thePattern count: &count phase: &phase];
|
||||
|
||||
if (count && (count < 10))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue