comparison mac/dw.m @ 686:218d676baf7f

Implemented dw_window_reparent using the method used for MDI simulation. Implemented mouse capture.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 03 Mar 2011 14:23:00 +0000
parents 314a12dccd20
children 5dde8d34bc69
comparison
equal deleted inserted replaced
685:314a12dccd20 686:218d676baf7f
5088 * Parameters: 5088 * Parameters:
5089 * handle: The window handle to make visible. 5089 * handle: The window handle to make visible.
5090 */ 5090 */
5091 int API dw_window_hide(HWND handle) 5091 int API dw_window_hide(HWND handle)
5092 { 5092 {
5093 NSLog(@"dw_window_hide() unimplemented\n"); 5093 /* TODO: Figure out proper dw_window_hide behavior...
5094 * individual windows don't appear to be hidable,
5095 * but all application windows can be hidden/deactivated
5096 * via the NS/DWApplication class.
5097 */
5094 return 0; 5098 return 0;
5095 } 5099 }
5096 5100
5097 /* 5101 /*
5098 * Sets the colors used by a specified window (widget) handle. 5102 * Sets the colors used by a specified window (widget) handle.
5182 void API dw_window_click_default(HWND window, HWND next) 5186 void API dw_window_click_default(HWND window, HWND next)
5183 { 5187 {
5184 NSLog(@"dw_window_click_default() unimplemented\n"); 5188 NSLog(@"dw_window_click_default() unimplemented\n");
5185 } 5189 }
5186 5190
5191 static id _DWCapture;
5192
5187 /* 5193 /*
5188 * Captures the mouse input to this window. 5194 * Captures the mouse input to this window.
5189 * Parameters: 5195 * Parameters:
5190 * handle: Handle to receive mouse input. 5196 * handle: Handle to receive mouse input.
5191 */ 5197 */
5192 void API dw_window_capture(HWND handle) 5198 void API dw_window_capture(HWND handle)
5193 { 5199 {
5194 NSLog(@"dw_window_capture() unimplemented\n"); 5200 id object = handle;
5201
5202 if(![object isMemberOfClass:[NSWindow class]])
5203 {
5204 object = [object window];
5205 }
5206 if(object)
5207 {
5208 [object setAcceptsMouseMovedEvents:YES];
5209 _DWCapture = object;
5210 }
5195 } 5211 }
5196 5212
5197 /* 5213 /*
5198 * Releases previous mouse capture. 5214 * Releases previous mouse capture.
5199 */ 5215 */
5200 void API dw_window_release(void) 5216 void API dw_window_release(void)
5201 { 5217 {
5202 NSLog(@"dw_window_release() unimplemented\n"); 5218 if(_DWCapture)
5219 {
5220 [_DWCapture setAcceptsMouseMovedEvents:NO];
5221 _DWCapture = nil;
5222 }
5203 } 5223 }
5204 5224
5205 /* 5225 /*
5206 * Tracks this window movement. 5226 * Tracks this window movement.
5207 * Parameters: 5227 * Parameters:
5218 * handle: The window handle to destroy. 5238 * handle: The window handle to destroy.
5219 * newparent: The window's new parent window. 5239 * newparent: The window's new parent window.
5220 */ 5240 */
5221 void API dw_window_reparent(HWND handle, HWND newparent) 5241 void API dw_window_reparent(HWND handle, HWND newparent)
5222 { 5242 {
5223 /* Is this even possible? */ 5243 id object = handle;
5224 NSLog(@"dw_window_reparent() unimplemented\n"); 5244
5245 if([object isMemberOfClass:[NSWindow class]])
5246 {
5247 /* We can't actually reparent on MacOS but if the
5248 * new parent is an MDI window, change to be a
5249 * floating window... otherwise set it to normal.
5250 */
5251 NSWindow *window = handle;
5252
5253 /* If it isn't a toplevel window... */
5254 if(newparent)
5255 {
5256 object = newparent;
5257
5258 /* Check to see if the parent is an MDI window */
5259 if([object isMemberOfClass:[DWMDI class]])
5260 {
5261 /* Set the window level to be floating */
5262 [window setLevel:NSFloatingWindowLevel];
5263 [window setHidesOnDeactivate:YES];
5264 return;
5265 }
5266 }
5267 /* Set the window back to a normal window */
5268 [window setLevel:NSNormalWindowLevel];
5269 [window setHidesOnDeactivate:NO];
5270 }
5225 } 5271 }
5226 5272
5227 /* 5273 /*
5228 * Sets the font used by a specified window (widget) handle. 5274 * Sets the font used by a specified window (widget) handle.
5229 * Parameters: 5275 * Parameters: