44
/******************************************************************************
46
******************************************************************************/
47
aqua_renderer_rep *the_renderer = NULL;
48
aqua_renderer_rep *the_aqua_renderer()
50
if (!the_renderer) the_renderer = new aqua_renderer_rep (the_gui);
55
widget aqua_widget_rep::plain_window_widget (string s)
60
widget aqua_widget_rep::make_popup_widget ()
65
widget aqua_widget_rep::popup_window_widget (string s)
71
/******************************************************************************
72
* aqua_view_widget_rep
73
******************************************************************************/
49
aqua_widget_rep::plain_window_widget (string s) {
55
aqua_widget_rep::make_popup_widget () {
60
aqua_widget_rep::popup_window_widget (string s) {
66
/******************************************************************************
67
* aqua_view_widget_rep
68
******************************************************************************/
74
70
#pragma mark aqua_view_widget_rep
76
aqua_view_widget_rep::aqua_view_widget_rep(NSView *v) : aqua_widget_rep(), view(v) { [v retain]; }
77
aqua_view_widget_rep::~aqua_view_widget_rep() { [view release]; }
72
aqua_view_widget_rep::aqua_view_widget_rep(NSView *v) :
73
aqua_widget_rep(), view(v) {
77
aqua_view_widget_rep::~aqua_view_widget_rep() {
82
84
aqua_view_widget_rep::send (slot s, blackbox val) {
86
check_type<string> (val, "SLOT_NAME");
87
string name = open_box<string> (val);
88
NSWindow *win = [view window];
90
[win setTitle:to_nsstring(name)];
94
case SLOT_SCROLLBARS_VISIBILITY:
95
// ignore this: cocoa handles scrollbars independently
96
// send_int (THIS, "scrollbars", val);
100
if (type_box (val) != type_helper<coord4>::id)
101
fatal_error ("type mismatch", "SLOT_INVALIDATE");
102
coord4 p= open_box<coord4> (val);
103
NSRect rect = to_nsrect(p);
104
NSLog(@"invalidating %@",NSStringFromRect(rect));
105
[view setNeedsDisplayInRect:rect];
110
if (type_box (val) != type_helper<coord4>::id)
111
fatal_error ("type mismatch", "SLOT_INVALIDATE");
112
coord4 p= open_box<coord4> (val);
113
NSRect rect = to_nsrect(p);
114
// [[view window] setContentSize:rect.size];
115
[[(NSScrollView*)view documentView] setFrameSize: rect.size];
118
case SLOT_INVALIDATE_ALL:
121
fatal_error ("type mismatch", "SLOT_INVALIDATE_ALL");
122
[view setNeedsDisplay:YES];
126
case SLOT_HEADER_VISIBILITY:
127
// send_bool (THIS, "header", val);
129
case SLOT_MAIN_ICONS_VISIBILITY:
130
// send_bool (THIS, "main icons", val);
132
case SLOT_CONTEXT_ICONS_VISIBILITY:
133
// send_bool (THIS, "context icons", val);
135
case SLOT_USER_ICONS_VISIBILITY:
136
// send_bool (THIS, "user icons", val);
138
case SLOT_FOOTER_VISIBILITY:
139
// send_bool (THIS, "footer flag", val);
142
case SLOT_MOUSE_GRAB:
143
// send_mouse_grab (THIS, val);
145
case SLOT_MOUSE_POINTER:
146
// send_mouse_pointer (THIS, val);
148
case SLOT_SCROLL_POSITION:
150
if (type_box (val) != type_helper<coord2>::id)
151
fatal_error ("type mismatch", "SLOT_SCROLL_POSITION");
152
coord2 p= open_box<coord2> (val);
153
NSPoint pt = to_nspoint(p);
154
[[(NSScrollView*)view documentView] scrollPoint:pt];
155
// [[(NSScrollView*)view documentView] scrollRectToVisible:NSMakeRect(pt.x,pt.y,1.0,1.0)];
158
case SLOT_SHRINKING_FACTOR:
160
if (type_box (val) != type_helper<int>::id)
161
fatal_error ("type mismatch", "SLOT_SHRINKING_FACTOR");
162
//w << set_integer (key, open_box<int> (val));
166
case SLOT_KEYBOARD_FOCUS:
167
// send_keyboard_focus (THIS, val);
169
if (type_box (val) != type_helper<bool>::id)
170
fatal_error ("type mismatch", "SLOT_KEYBOARD_FOCUS");
171
if (open_box<bool>(val)) the_keyboard_focus = this;
88
check_type<string> (val, "SLOT_NAME");
89
string name = open_box<string> (val);
90
NSWindow *win = [view window];
92
[win setTitle:to_nsstring(name)];
98
TYPE_CHECK (type_box (val) == type_helper<coord4>::id);
99
coord4 p= open_box<coord4> (val);
100
NSRect rect = to_nsrect(p);
101
if (DEBUG_EVENTS) NSLog(@"invalidating %@",NSStringFromRect(rect));
102
[view setNeedsDisplayInRect:rect];
105
case SLOT_INVALIDATE_ALL:
108
[view setNeedsDisplay:YES];
111
case SLOT_MOUSE_GRAB:
113
// send_mouse_grab (THIS, val);
115
case SLOT_MOUSE_POINTER:
117
// send_mouse_pointer (THIS, val);
120
case SLOT_KEYBOARD_FOCUS:
121
// send_keyboard_focus (THIS, val);
123
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
124
if (open_box<bool>(val)) the_keyboard_focus = this;
178
if (type_box (val) != type_helper<coord2>::id)
179
fatal_error ("type mismatch", "SLOT_SIZE");
180
coord2 p= open_box<coord2> (val);
181
NSWindow *win = [view window];
183
NSRect frame = [win frame];
184
NSSize s = to_nssize(p);
186
[win setFrame:frame display:YES];
192
if (type_box (val) != type_helper<coord2>::id)
193
fatal_error ("type mismatch", "SLOT_POSITION");
194
coord2 p= open_box<coord2> (val);
195
NSWindow *win = [view window];
197
[win setFrameTopLeftPoint:to_nspoint(p)];
201
case SLOT_VISIBILITY:
203
check_type<bool> (val, "SLOT_VISIBILITY");
204
bool flag = open_box<bool> (val);
205
NSWindow *win = [view window];
208
[win makeKeyAndOrderFront:nil] ;
214
case SLOT_IDENTIFIER:
215
check_type<int> (val, "SLOT_IDENTIFIER");
216
THIS << emit_attach_window (get_window (open_box<int> (val)));
218
case SLOT_FULL_SCREEN:
219
check_type<bool> (val, "SLOT_FULL_SCREEN");
220
win->set_full_screen (open_box<bool> (val));
223
send_update (THIS, val);
226
send_keyboard (THIS, val);
229
send_mouse (THIS, val);
232
send_repaint (THIS, val);
234
case SLOT_DELAYED_MESSAGE:
235
send_delayed_message (THIS, val);
238
send_destroy (THIS, val);
242
send_coord4 (THIS, "extents", val);
244
case SLOT_SCROLLBARS_VISIBILITY:
245
send_int (THIS, "scrollbars", val);
248
case SLOT_INTERACTIVE_MODE:
249
send_bool (THIS, "interactive mode", val);
252
case SLOT_STRING_INPUT:
253
send_string (THIS, "input", val);
255
case SLOT_INPUT_TYPE:
256
send_string (THIS, "type", val);
258
case SLOT_INPUT_PROPOSAL:
259
send_string (THIS, "default", val);
262
send_string (THIS, "file", val);
265
send_string (THIS, "directory", val);
130
TYPE_CHECK (type_box (val) == type_helper<coord4>::id);
131
coord4 p= open_box<coord4> (val);
132
NSRect rect = to_nsrect(p);
133
// [[view window] setContentSize:rect.size];
134
[[(NSScrollView*)view documentView] setFrameSize: rect.size];
138
case SLOT_HEADER_VISIBILITY:
139
// send_bool (THIS, "header", val);
141
case SLOT_MAIN_ICONS_VISIBILITY:
142
// send_bool (THIS, "main icons", val);
144
case SLOT_CONTEXT_ICONS_VISIBILITY:
145
// send_bool (THIS, "context icons", val);
147
case SLOT_USER_ICONS_VISIBILITY:
148
// send_bool (THIS, "user icons", val);
150
case SLOT_FOOTER_VISIBILITY:
151
// send_bool (THIS, "footer flag", val);
154
case SLOT_SCROLL_POSITION:
156
TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
157
coord2 p= open_box<coord2> (val);
158
NSPoint pt = to_nspoint(p);
159
[[(NSScrollView*)view documentView] scrollPoint:pt];
160
// [[(NSScrollView*)view documentView] scrollRectToVisible:NSMakeRect(pt.x,pt.y,1.0,1.0)];
163
case SLOT_SHRINKING_FACTOR:
165
TYPE_CHECK (type_box (val) == type_helper<int>::id);
166
//w << set_integer (key, open_box<int> (val));
173
TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
174
coord2 p= open_box<coord2> (val);
175
NSWindow *win = [view window];
177
NSRect frame = [win frame];
178
NSSize s = to_nssize(p);
180
[win setFrame:frame display:YES];
186
TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
187
coord2 p= open_box<coord2> (val);
188
NSWindow *win = [view window];
190
[win setFrameTopLeftPoint:to_nspoint(p)];
194
case SLOT_VISIBILITY:
196
check_type<bool> (val, "SLOT_VISIBILITY");
197
bool flag = open_box<bool> (val);
198
NSWindow *win = [view window];
201
[win makeKeyAndOrderFront:nil] ;
207
case SLOT_IDENTIFIER:
208
check_type<int> (val, "SLOT_IDENTIFIER");
209
THIS << emit_attach_window (get_window (open_box<int> (val)));
211
case SLOT_FULL_SCREEN:
212
check_type<bool> (val, "SLOT_FULL_SCREEN");
213
win->set_full_screen (open_box<bool> (val));
216
send_update (THIS, val);
219
send_keyboard (THIS, val);
222
send_mouse (THIS, val);
225
send_repaint (THIS, val);
227
case SLOT_DELAYED_MESSAGE:
228
send_delayed_message (THIS, val);
231
send_destroy (THIS, val);
235
send_coord4 (THIS, "extents", val);
237
case SLOT_SCROLLBARS_VISIBILITY:
238
send_int (THIS, "scrollbars", val);
241
case SLOT_INTERACTIVE_MODE:
242
send_bool (THIS, "interactive mode", val);
245
case SLOT_STRING_INPUT:
246
send_string (THIS, "input", val);
248
case SLOT_INPUT_TYPE:
249
send_string (THIS, "type", val);
251
case SLOT_INPUT_PROPOSAL:
252
send_string (THIS, "default", val);
255
send_string (THIS, "file", val);
258
send_string (THIS, "directory", val);
269
fatal_error ("cannot handle slot type", "aqua_view_widget_rep::send");
262
FAILED ("cannot handle slot type");
273
266
/******************************************************************************
275
******************************************************************************/
268
******************************************************************************/
278
271
aqua_view_widget_rep::query (slot s, int type_id) {
280
case SLOT_IDENTIFIER:
281
if (type_id != type_helper<int>::id)
282
fatal_error ("int expected (SLOT_IDENTIFIER)", "aqua_view_widget_rep::query");
283
return close_box<int> ((int)[view window]);
285
if (type_id != type_helper<renderer>::id)
286
fatal_error ("renderer expected (SLOT_RENDERER)",
287
"aqua_view_widget_rep::query");
288
return close_box<renderer> ((renderer) the_aqua_renderer());
289
case SLOT_VISIBLE_PART:
291
if (type_id != type_helper<coord4>::id)
292
fatal_error ("type mismatch", "SLOT_VISIBLE_PART");
293
NSRect rect = [view visibleRect];
294
coord4 c = from_nsrect(rect);
295
return close_box<coord4> (c);
298
case SLOT_SCROLL_POSITION:
300
if (type_id != type_helper<coord2>::id)
301
fatal_error ("type mismatch", "SLOT_SCROLL_POSITION");
302
NSPoint pt = [[(NSScrollView *)view contentView] bounds].origin;
303
return close_box<coord2> (from_nspoint(pt));
308
typedef pair<SI,SI> coord2;
309
if (type_id != type_helper<coord2>::id)
310
fatal_error ("type mismatch (SLOT_POSITION)", "aqua_view_widget_rep::query");
311
return close_box<coord2> (coord2(0,0)); //FIXME: fake position
273
case SLOT_IDENTIFIER:
274
TYPE_CHECK (type_id == type_helper<int>::id);
275
return close_box<int> ((int)[view window] ? 1 : 0);
277
TYPE_CHECK (type_id == type_helper<renderer>::id);
278
return close_box<renderer> ((renderer) the_aqua_renderer());
317
return query_size (THIS, type_id);
319
return query_position (THIS, type_id);
320
case SLOT_KEYBOARD_FOCUS:
321
return query_keyboard_focus (THIS, type_id);
322
case SLOT_MOUSE_GRAB:
323
return query_mouse_grab (THIS, type_id);
326
return query_coord4 (THIS, "extents", type_id);
327
case SLOT_SCROLLBARS_VISIBILITY:
328
return query_int (THIS, "scrollbars", type_id);
330
case SLOT_INTERACTIVE_MODE:
331
return query_bool (THIS, "interactive mode", type_id);
332
case SLOT_INTERACTIVE_INPUT:
333
return query_string (THIS, "interactive input", type_id);
335
case SLOT_STRING_INPUT:
336
return query_string (THIS, "input", type_id);
280
case SLOT_VISIBLE_PART:
282
TYPE_CHECK (type_id == type_helper<coord4>::id);
283
NSRect rect = [view visibleRect];
284
coord4 c = from_nsrect(rect);
285
return close_box<coord4> (c);
339
fatal_error ("cannot handle slot type", "aqua_view_widget_rep::query");
290
typedef pair<SI,SI> coord2;
291
TYPE_CHECK (type_id == type_helper<coord2>::id);
292
NSPoint pos = [view frame].origin;
293
return close_box<coord2> (from_nspoint(pos));
297
FAILED ("cannot handle slot type");
379
316
aqua_view_widget_rep::read (slot s, blackbox index) {
382
check_type_void (index, "SLOT_WINDOW");
383
return [(TMWindowController*)[[view window] windowController] widget];
386
check_type_void (index, "SLOT_WINDOW");
387
return win -> get_widget ();
388
case SLOT_FORM_FIELD:
389
check_type<int> (index, "SLOT_FORM_FIELD");
390
return abstract (THIS [0] ["inputs"] [open_box<int> (index)] ["input"]);
392
check_type_void (index, "SLOT_FILE");
393
return abstract (THIS [0] ["file"] ["input"]);
395
check_type_void (index, "SLOT_DIRECTORY");
396
return abstract (THIS [0] ["directory"] ["input"]);
399
fatal_error ("cannot handle slot type", "aqua_view_widget_rep::read");
319
check_type_void (index, "SLOT_WINDOW");
320
return [(TMWindowController*)[[view window] windowController] widget];
322
FAILED ("cannot handle slot type");
405
328
aqua_view_widget_rep::write (slot s, blackbox index, widget w) {
410
check_type_void (index, "SLOT_CANVAS");
411
NSView *v = concrete (w)->get_nsview();
412
NSScrollView *sv = (NSScrollView*) view;
413
[sv setDocumentView: v];
414
[[sv window] makeFirstResponder:v];
418
check_type_void (index, "SLOT_MAIN_MENU");
419
[NSApp setMainMenu: to_nsmenu(w)];
420
// THIS << set_widget ("menu bar", concrete (w));
422
case SLOT_MAIN_ICONS:
423
check_type_void (index, "SLOT_MAIN_ICONS");
424
// THIS << set_widget ("main icons bar", concrete (w));
426
case SLOT_CONTEXT_ICONS:
427
check_type_void (index, "SLOT_CONTEXT_ICONS");
428
// THIS << set_widget ("context icons bar", concrete (w));
430
case SLOT_USER_ICONS:
431
check_type_void (index, "SLOT_USER_ICONS");
432
// THIS << set_widget ("user icons bar", concrete (w));
436
fatal_error ("cannot handle slot type", "aqua_view_widget_rep::write");
331
FAILED ("cannot handle slot type");
441
widget aqua_view_widget_rep::plain_window_widget (string s)
337
aqua_view_widget_rep::plain_window_widget (string s)
442
338
// creates a decorated window with name s and contents w
444
NSRect screen_frame = [[NSScreen mainScreen] visibleFrame];
340
NSRect screen_frame = [[NSScreen mainScreen] visibleFrame];
446
342
NSWindow *nsw = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,100,100)
447
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
448
backing:NSBackingStoreBuffered
449
defer:NO] autorelease];
450
// NSView *view = ((aqua_view_widget_rep*)w.rep)->get_nsview();
451
// NSRect frame = [[nsw contentView] frame];
452
// [view setFrame:frame];
343
styleMask:NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask
344
backing:NSBackingStoreBuffered
345
defer:NO] autorelease];
346
// NSView *view = ((aqua_view_widget_rep*)w.rep)->get_nsview();
347
// NSRect frame = [[nsw contentView] frame];
348
// [view setFrame:frame];
453
349
[nsw setContentView:view];
454
[nsw setTitle:to_nsstring(s)];
455
// [[nsw contentView] addSubview:view];
456
// [nsw setToolbar:((aqua_tm_widget_rep*)w.rep)->toolbar];
457
widget wid = new aqua_window_widget_rep(nsw);
350
[nsw setTitle:to_nsstring(s)];
351
[nsw setAcceptsMouseMovedEvents:YES];
352
// [[nsw contentView] addSubview:view];
353
// [nsw setToolbar:((aqua_tm_widget_rep*)w.rep)->toolbar];
354
widget wid = tm_new <aqua_window_widget_rep> (nsw);
462
359
#pragma mark aqua_tm_widget_rep
465
361
NSString *TMToolbarIdentifier = @"TMToolbarIdentifier";
466
362
NSString *TMButtonsIdentifier = @"TMButtonsIdentifier";
494
390
@implementation TMWidgetHelper
497
[ti release]; [super dealloc];
393
[ti release]; [super dealloc];
499
395
- (void)notify:(NSNotification*)n
503
399
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
505
if (itemIdentifier == TMButtonsIdentifier) {
507
ti = [[TMToolbarItem alloc] initWithItemIdentifier:TMButtonsIdentifier];
508
[ti setView:[wid->bc bar]];
509
NSRect f = [[wid->bc bar] frame];
510
// NSSize s = NSMakeSize(900,70);
401
if (itemIdentifier == TMButtonsIdentifier) {
403
ti = [[TMToolbarItem alloc] initWithItemIdentifier:TMButtonsIdentifier];
404
[ti setView:[wid->bc bar]];
405
NSRect f = [[wid->bc bar] frame];
406
// NSSize s = NSMakeSize(900,70);
520
416
- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar *)toolbar
522
return [NSArray arrayWithObjects:TMButtonsIdentifier,nil];
418
return [NSArray arrayWithObjects:TMButtonsIdentifier,nil];
524
420
- (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
526
return [NSArray arrayWithObjects:TMButtonsIdentifier,nil];
422
return [NSArray arrayWithObjects:TMButtonsIdentifier,nil];
531
aqua_tm_widget_rep::aqua_tm_widget_rep() : aqua_view_widget_rep([[[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)] autorelease]),
532
sv(nil), leftField(nil), rightField(nil), bc(nil), toolbar(nil)
427
aqua_tm_widget_rep::aqua_tm_widget_rep(int mask) : aqua_view_widget_rep([[[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)] autorelease]),
428
sv(nil), leftField(nil), rightField(nil), bc(nil), toolbar(nil)
534
NSSize s = NSMakeSize(100,20); // size of the right footer;
535
NSRect r = [view bounds];
537
// r.size.height -= 100;
538
// r0.origin.y =+ r.size.height; r0.size.height = 100;
539
NSRect r1 = r; r1.origin.y += s.height; r1.size.height -= s.height;
540
NSRect r2 = r; r2.size.height = s.height;
542
r2.size.width -= s.width; r3.origin.x =+ r2.size.width;
543
sv = [[[NSScrollView alloc] initWithFrame:r1] autorelease];
544
[sv setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
545
[sv setHasVerticalScroller:YES];
546
[sv setHasHorizontalScroller:YES];
547
[sv setBorderType:NSNoBorder];
548
[sv setBackgroundColor:[NSColor redColor]];
549
[sv setDocumentView:[[[NSView alloc] initWithFrame: NSMakeRect(0,0,100,100)] autorelease]];
550
[view addSubview:sv];
552
leftField = [[[NSTextField alloc] initWithFrame:r2] autorelease];
553
rightField = [[[NSTextField alloc] initWithFrame:r3] autorelease];
554
[leftField setAutoresizingMask:NSViewWidthSizable|NSViewMaxYMargin];
555
[rightField setAutoresizingMask:NSViewMinXMargin|NSViewMaxYMargin];
556
[leftField setEditable: NO];
557
[rightField setEditable: NO];
558
[leftField setBackgroundColor:[NSColor windowFrameColor]];
559
[rightField setBackgroundColor:[NSColor windowFrameColor]];
560
[leftField setBezeled:NO];
561
[rightField setBezeled:NO];
562
[rightField setAlignment:NSRightTextAlignment];
563
[view addSubview:leftField];
564
[view addSubview:rightField];
566
bc = [[TMButtonsController alloc] init];
567
//NSView *mt = [bc bar];
569
//[mt setAutoresizingMask:NSViewMaxXMargin|NSViewMinYMargin];
570
//[view addSubview:mt];
571
// [mt setPostsFrameChangedNotifications:YES];
572
wh = [[TMWidgetHelper alloc] init];
431
visibility[0] = (mask & 1) == 1; // header
432
visibility[1] = (mask & 2) == 2; // main
433
visibility[2] = (mask & 4) == 4; // context
434
visibility[3] = (mask & 8) == 8; // user
435
visibility[4] = (mask & 16) == 16; // footer
438
NSSize s = NSMakeSize(100,20); // size of the right footer;
439
NSRect r = [view bounds];
441
// r.size.height -= 100;
442
// r0.origin.y =+ r.size.height; r0.size.height = 100;
443
NSRect r1 = r; r1.origin.y += s.height; r1.size.height -= s.height;
444
NSRect r2 = r; r2.size.height = s.height;
446
r2.size.width -= s.width; r3.origin.x =+ r2.size.width;
447
sv = [[[NSScrollView alloc] initWithFrame:r1] autorelease];
448
[sv setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
449
[sv setHasVerticalScroller:YES];
450
[sv setHasHorizontalScroller:YES];
451
[sv setBorderType:NSNoBorder];
452
// [sv setBackgroundColor:[NSColor redColor]];
453
[sv setBackgroundColor:[NSColor grayColor]];
454
[sv setDocumentView:[[[NSView alloc] initWithFrame: NSMakeRect(0,0,100,100)] autorelease]];
455
[view addSubview:sv];
457
leftField = [[[NSTextField alloc] initWithFrame:r2] autorelease];
458
rightField = [[[NSTextField alloc] initWithFrame:r3] autorelease];
459
[leftField setAutoresizingMask:NSViewWidthSizable|NSViewMaxYMargin];
460
[rightField setAutoresizingMask:NSViewMinXMargin|NSViewMaxYMargin];
461
[leftField setEditable: NO];
462
[rightField setEditable: NO];
463
[leftField setBackgroundColor:[NSColor windowFrameColor]];
464
[rightField setBackgroundColor:[NSColor windowFrameColor]];
465
[leftField setBezeled:NO];
466
[rightField setBezeled:NO];
467
[rightField setAlignment:NSRightTextAlignment];
468
[view addSubview:leftField];
469
[view addSubview:rightField];
471
bc = [[TMButtonsController alloc] init];
472
//NSView *mt = [bc bar];
474
//[mt setAutoresizingMask:NSViewMaxXMargin|NSViewMinYMargin];
475
//[view addSubview:mt];
476
// [mt setPostsFrameChangedNotifications:YES];
477
wh = [[TMWidgetHelper alloc] init];
575
[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] addObserver:wh
576
selector:@selector(notify:)
577
name:NSViewFrameDidChangeNotification
480
[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] addObserver:wh
481
selector:@selector(notify:)
482
name:NSViewFrameDidChangeNotification
581
toolbar = [[NSToolbar alloc] initWithIdentifier:TMToolbarIdentifier ];
582
[toolbar setDelegate:wh];
486
toolbar = [[NSToolbar alloc] initWithIdentifier:TMToolbarIdentifier ];
487
[toolbar setDelegate:wh];
585
493
aqua_tm_widget_rep::~aqua_tm_widget_rep()
587
// [(NSNotificationCenter*)[NSNotificationCenter defaultCenter] removeObserver:wh];
495
// [(NSNotificationCenter*)[NSNotificationCenter defaultCenter] removeObserver:wh];
593
501
void aqua_tm_widget_rep::layout()
595
NSSize s = NSMakeSize(100,20); // size of the right footer;
596
NSRect r = [view bounds];
598
// NSRect rh = [[bc bar] frame];
599
NSRect rh = NSMakeRect(0,0,0,0);
600
r.size.height -= rh.size.height;
601
r0.origin.y =+ r.size.height; r0.size.height = rh.size.height;
602
NSRect r1 = r; r1.origin.y += s.height; r1.size.height -= s.height;
603
NSRect r2 = r; r2.size.height = s.height;
605
r2.size.width -= s.width; r3.origin.x =+ r2.size.width;
606
r3.size.width -= r2.size.width + 15.0;
608
[leftField setFrame:r2];
609
[rightField setFrame:r3];
610
//[[bc bar] setFrame:r0];
503
NSSize s = NSMakeSize(100,20); // size of the right footer;
504
NSRect r = [view bounds];
506
// NSRect rh = [[bc bar] frame];
507
NSRect rh = NSMakeRect(0,0,0,0);
508
r.size.height -= rh.size.height;
509
r0.origin.y =+ r.size.height; r0.size.height = rh.size.height;
510
NSRect r1 = r; r1.origin.y += s.height; r1.size.height -= s.height;
511
NSRect r2 = r; r2.size.height = s.height;
513
r2.size.width -= s.width; r3.origin.x =+ r2.size.width;
514
r3.size.width -= r2.size.width + 15.0;
516
[leftField setFrame:r2];
517
[rightField setFrame:r3];
518
//[[bc bar] setFrame:r0];
611
519
[NSApp setWindowsNeedUpdate:YES];
523
void aqua_tm_widget_rep::updateVisibility()
526
mainToolBar->setVisible (visibility[1] && visibility[0]);
527
contextToolBar->setVisible (visibility[2] && visibility[0]);
528
userToolBar->setVisible (visibility[3] && visibility[0]);
529
tm_mainwindow()->statusBar()->setVisible (visibility[4]);
531
tm_mainwindow()->menuBar()->setVisible (visibility[0]);
616
539
aqua_tm_widget_rep::send (slot s, blackbox val) {
620
if (type_box (val) != type_helper<coord4>::id)
621
fatal_error ("type mismatch", "SLOT_INVALIDATE");
622
coord4 p= open_box<coord4> (val);
623
NSRect rect = to_nsrect(p);
624
// [[view window] setContentSize:rect.size];
625
[[sv documentView] setFrameSize: rect.size];
628
case SLOT_INVALIDATE_ALL:
631
fatal_error ("type mismatch", "SLOT_INVALIDATE_ALL");
632
[view setNeedsDisplay:YES];
636
case SLOT_HEADER_VISIBILITY:
637
// send_bool (THIS, "header", val);
639
case SLOT_MAIN_ICONS_VISIBILITY:
640
// send_bool (THIS, "main icons", val);
642
case SLOT_CONTEXT_ICONS_VISIBILITY:
643
// send_bool (THIS, "context icons", val);
645
case SLOT_USER_ICONS_VISIBILITY:
646
// send_bool (THIS, "user icons", val);
648
case SLOT_FOOTER_VISIBILITY:
649
// send_bool (THIS, "footer flag", val);
651
case SLOT_LEFT_FOOTER:
653
if (type_box (val) != type_helper<string>::id)
654
fatal_error ("type mismatch", "SLOT_LEFT_FOOTER");
655
string msg = open_box<string> (val);
656
[leftField setStringValue:to_nsstring(msg)];
657
[leftField displayIfNeeded];
660
cout << "letf footer\n";
661
// send_string (THIS, "left footer", val);
663
case SLOT_RIGHT_FOOTER:
665
if (type_box (val) != type_helper<string>::id)
666
fatal_error ("type mismatch", "SLOT_RIGHT_FOOTER");
667
string msg = open_box<string> (val);
668
[rightField setStringValue:to_nsstring(msg)];
669
[rightField displayIfNeeded];
672
cout << "right footer\n";
673
// send_string (THIS, "right footer", val);
676
case SLOT_SCROLL_POSITION:
678
if (type_box (val) != type_helper<coord2>::id)
679
fatal_error ("type mismatch", "SLOT_SCROLL_POSITION");
680
coord2 p= open_box<coord2> (val);
681
NSPoint pt = to_nspoint(p);
682
[[sv documentView] scrollPoint:pt];
683
// [[(NSScrollView*)view documentView] scrollRectToVisible:NSMakeRect(pt.x,pt.y,1.0,1.0)];
686
case SLOT_INTERACTIVE_MODE:
688
if (type_box (val) != type_helper<bool>::id)
689
fatal_error ("type mismatch", "SLOT_INTERACTIVE_MODE");
543
TYPE_CHECK (type_box (val) == type_helper<coord4>::id);
544
coord4 p= open_box<coord4> (val);
545
NSRect rect = to_nsrect(p);
546
NSSize ws = [sv contentSize];
547
NSSize sz = rect.size;
548
sz.height = max (sz.height, 7.0 * ws.height / 8.0);
549
// [[view window] setContentSize:rect.size];
550
[[sv documentView] setFrameSize: sz];
553
case SLOT_HEADER_VISIBILITY:
555
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
556
bool f= open_box<bool> (val);
561
case SLOT_MAIN_ICONS_VISIBILITY:
563
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
564
bool f= open_box<bool> (val);
569
case SLOT_CONTEXT_ICONS_VISIBILITY:
571
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
572
bool f= open_box<bool> (val);
577
case SLOT_USER_ICONS_VISIBILITY:
579
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
580
bool f= open_box<bool> (val);
585
case SLOT_FOOTER_VISIBILITY:
587
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
588
bool f= open_box<bool> (val);
594
case SLOT_LEFT_FOOTER:
596
TYPE_CHECK (type_box (val) == type_helper<string>::id);
597
string msg = open_box<string> (val);
598
[leftField setStringValue:to_nsstring_utf8(aqua_translate(msg))];
599
[leftField displayIfNeeded];
602
case SLOT_RIGHT_FOOTER:
604
TYPE_CHECK (type_box (val) == type_helper<string>::id);
605
string msg = open_box<string> (val);
606
[rightField setStringValue:to_nsstring_utf8(aqua_translate(msg))];
607
[rightField displayIfNeeded];
611
case SLOT_SCROLL_POSITION:
613
TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
614
coord2 p= open_box<coord2> (val);
615
NSPoint pt = to_nspoint(p);
616
NSSize sz = [[sv contentView] bounds].size;
619
//cout << "scroll position :" << pt.x << "," << pt.y << LF;
621
[[sv documentView] scrollPoint:pt];
622
// [[(NSScrollView*)view documentView] scrollRectToVisible:NSMakeRect(pt.x,pt.y,1.0,1.0)];
626
case SLOT_SCROLLBARS_VISIBILITY:
627
// ignore this: cocoa handles scrollbars independently
628
// send_int (THIS, "scrollbars", val);
631
case SLOT_INTERACTIVE_MODE:
633
TYPE_CHECK (type_box (val) == type_helper<bool>::id);
691
634
if (open_box<bool>(val) == true) {
692
do_interactive_prompt();
635
do_interactive_prompt();
698
aqua_view_widget_rep::send(s,val);
640
case SLOT_SHRINKING_FACTOR:
641
TYPE_CHECK (type_box (val) == type_helper<int>::id);
642
simple_widget_rep *w = (simple_widget_rep *)[(TMView*)[sv documentView] widget];
644
int new_sf = open_box<int> (val);
645
if (DEBUG_EVENTS) cout << "New shrinking factor :" << new_sf << LF;
646
w->handle_set_shrinking_factor (new_sf);
649
if (QTMWidget* tmw= qobject_cast<QTMWidget*> (tm_canvas())) {
650
int new_sf = open_box<int> (val);
651
if (DEBUG_EVENTS) cout << "New shrinking factor :" << new_sf << LF;
652
tmw->tm_widget()->handle_set_shrinking_factor (new_sf);
658
aqua_view_widget_rep::send(s,val);
703
663
aqua_tm_widget_rep::query (slot s, int type_id) {
705
case SLOT_SCROLL_POSITION:
707
if (type_id != type_helper<coord2>::id)
708
fatal_error ("type mismatch", "SLOT_SCROLL_POSITION");
709
NSPoint pt = [[sv contentView] bounds].origin;
710
return close_box<coord2> (from_nspoint(pt));
712
case SLOT_USER_ICONS_VISIBILITY:
714
if (type_id != type_helper<bool>::id)
715
fatal_error ("type mismatch", "SLOT_HEADER_VISIBILITY");
716
return close_box<bool> (false);
665
case SLOT_SCROLL_POSITION:
667
TYPE_CHECK (type_id == type_helper<coord2>::id);
668
NSPoint pt = [[sv contentView] frame].origin;
669
return close_box<coord2> (from_nspoint(pt));
674
TYPE_CHECK (type_id == type_helper<coord4>::id);
675
NSRect rect= [[sv documentView] frame];
676
coord4 c= from_nsrect (rect);
677
// if (DEBUG_EVENTS) cout << "Canvas geometry " << rect << LF;
678
return close_box<coord4> (c);
682
case SLOT_VISIBLE_PART:
684
TYPE_CHECK (type_id == type_helper<coord4>::id);
685
NSRect rect= [sv documentVisibleRect];
686
coord4 c= from_nsrect (rect);
687
// if (DEBUG_EVENTS) cout << "Visible Region " << rect << LF;
688
return close_box<coord4> (c);
719
case SLOT_CONTEXT_ICONS_VISIBILITY:
720
case SLOT_MAIN_ICONS_VISIBILITY:
721
case SLOT_HEADER_VISIBILITY:
722
case SLOT_FOOTER_VISIBILITY:
724
if (type_id != type_helper<bool>::id)
725
fatal_error ("type mismatch", "SLOT_HEADER_VISIBILITY");
726
return close_box<bool> (true);
728
case SLOT_INTERACTIVE_INPUT:
730
if (type_id != type_helper<string>::id)
731
fatal_error ("type mismatch", "SLOT_INTERACTIVE_INPUT");
732
return close_box<string> ( ((aqua_input_text_widget_rep*) int_input.rep)->text );
735
case SLOT_INTERACTIVE_MODE:
737
if (type_id != type_helper<bool>::id)
738
fatal_error ("type mismatch", "SLOT_INTERACTIVE_MODE");
692
case SLOT_USER_ICONS_VISIBILITY:
693
TYPE_CHECK (type_id == type_helper<bool>::id);
694
return close_box<bool> (visibility[3]);
696
case SLOT_CONTEXT_ICONS_VISIBILITY:
697
TYPE_CHECK (type_id == type_helper<bool>::id);
698
return close_box<bool> (visibility[2]);
700
case SLOT_MAIN_ICONS_VISIBILITY:
701
TYPE_CHECK (type_id == type_helper<bool>::id);
702
return close_box<bool> (visibility[1]);
704
case SLOT_HEADER_VISIBILITY:
705
TYPE_CHECK (type_id == type_helper<bool>::id);
706
return close_box<bool> (visibility[0]);
708
case SLOT_FOOTER_VISIBILITY:
709
TYPE_CHECK (type_id == type_helper<bool>::id);
710
return close_box<bool> (visibility[4]);
712
case SLOT_INTERACTIVE_INPUT:
714
TYPE_CHECK (type_id == type_helper<string>::id);
715
return close_box<string> ( ((aqua_input_text_widget_rep*) int_input.rep)->text );
718
case SLOT_INTERACTIVE_MODE:
720
TYPE_CHECK (type_id == type_helper<bool>::id);
739
721
return close_box<bool> (false);
744
return aqua_view_widget_rep::query(s,type_id);
749
aqua_tm_widget_rep::notify (slot s, blackbox new_val) {
753
aqua_view_widget_rep::notify (s, new_val);
726
return aqua_view_widget_rep::query(s,type_id);
758
731
aqua_tm_widget_rep::read (slot s, blackbox index) {
761
return aqua_view_widget_rep::read(s,index);
734
return aqua_view_widget_rep::read(s,index);
822
795
aqua_tm_widget_rep::write (slot s, blackbox index, widget w) {
826
check_type_void (index, "SLOT_CANVAS");
827
NSView *v = ((aqua_view_widget_rep*) w.rep)->view;
828
[sv setDocumentView: v];
829
[[sv window] makeFirstResponder:v];
833
check_type_void (index, "SLOT_MAIN_MENU");
834
[[TMMenuHelper sharedHelper] setMenu:to_nsmenu(w)];
836
case SLOT_MAIN_ICONS:
837
check_type_void (index, "SLOT_MAIN_ICONS");
838
[bc setMenu:to_nsmenu(w) forRow:0];
841
case SLOT_CONTEXT_ICONS:
842
check_type_void (index, "SLOT_CONTEXT_ICONS");
843
[bc setMenu:to_nsmenu(w) forRow:1];
846
case SLOT_USER_ICONS:
847
check_type_void (index, "SLOT_USER_ICONS");
848
[bc setMenu:to_nsmenu(w) forRow:2];
851
case SLOT_INTERACTIVE_PROMPT:
852
check_type_void (index, "SLOT_INTERACTIVE_PROMPT");
853
int_prompt = concrete(w);
854
// THIS << set_widget ("interactive prompt", concrete (w));
856
case SLOT_INTERACTIVE_INPUT:
857
check_type_void (index, "SLOT_INTERACTIVE_INPUT");
858
int_input = concrete(w);
859
// THIS << set_widget ("interactive input", concrete (w));
862
aqua_view_widget_rep::write(s,index,w);
799
check_type_void (index, "SLOT_CANVAS");
800
NSView *v = ((aqua_view_widget_rep*) w.rep)->view;
801
[sv setDocumentView: v];
802
[[sv window] makeFirstResponder:v];
806
check_type_void (index, "SLOT_MAIN_MENU");
807
[[TMMenuHelper sharedHelper] setMenu:to_nsmenu(w)];
809
case SLOT_MAIN_ICONS:
810
check_type_void (index, "SLOT_MAIN_ICONS");
811
[bc setMenu:to_nsmenu(w) forRow:0];
814
case SLOT_CONTEXT_ICONS:
815
check_type_void (index, "SLOT_CONTEXT_ICONS");
816
[bc setMenu:to_nsmenu(w) forRow:1];
819
case SLOT_USER_ICONS:
820
check_type_void (index, "SLOT_USER_ICONS");
821
[bc setMenu:to_nsmenu(w) forRow:2];
824
case SLOT_INTERACTIVE_PROMPT:
825
check_type_void (index, "SLOT_INTERACTIVE_PROMPT");
826
int_prompt = concrete(w);
827
// THIS << set_widget ("interactive prompt", concrete (w));
829
case SLOT_INTERACTIVE_INPUT:
830
check_type_void (index, "SLOT_INTERACTIVE_INPUT");
831
int_input = concrete(w);
832
// THIS << set_widget ("interactive input", concrete (w));
835
aqua_view_widget_rep::write(s,index,w);
866
widget aqua_tm_widget_rep::plain_window_widget (string s)
867
// creates a decorated window with name s and contents w
869
widget w = aqua_view_widget_rep::plain_window_widget(s); // to manage correctly retain counts
870
aqua_window_widget_rep * wid = (aqua_window_widget_rep *)(w.rep);
871
[[wid->get_windowcontroller() window] setToolbar:toolbar];
840
aqua_tm_widget_rep::plain_window_widget (string s) {
841
// creates a decorated window with name s and contents w
842
widget w = aqua_view_widget_rep::plain_window_widget(s);
843
// to manage correctly retain counts
844
aqua_window_widget_rep * wid = (aqua_window_widget_rep *)(w.rep);
845
[[wid->get_windowcontroller() window] setToolbar:toolbar];
905
879
aqua_window_widget_rep::send (slot s, blackbox val) {
909
if (type_box (val) != type_helper<coord2>::id)
910
fatal_error ("type mismatch", "SLOT_SIZE");
911
coord2 p= open_box<coord2> (val);
912
NSWindow *win = [wc window];
914
NSSize size = to_nssize(p);
915
[win setContentSize:size];
921
if (type_box (val) != type_helper<coord2>::id)
922
fatal_error ("type mismatch", "SLOT_POSITION");
923
coord2 p= open_box<coord2> (val);
924
NSWindow *win = [wc window];
926
[win setFrameOrigin:to_nspoint(p)];
930
case SLOT_VISIBILITY:
932
check_type<bool> (val, "SLOT_VISIBILITY");
933
bool flag = open_box<bool> (val);
934
NSWindow *win = [wc window];
936
if (flag) [win makeKeyAndOrderFront:nil] ;
937
else [win orderOut:nil] ;
943
check_type<string> (val, "SLOT_NAME");
944
string name = open_box<string> (val);
945
NSWindow *win = [wc window];
947
NSString *title = to_nsstring(name);
948
[win setTitle:title];
953
case SLOT_IDENTIFIER:
954
check_type<int> (val, "SLOT_IDENTIFIER");
955
THIS << emit_attach_window (get_window (open_box<int> (val)));
957
case SLOT_FULL_SCREEN:
958
check_type<bool> (val, "SLOT_FULL_SCREEN");
959
win->set_full_screen (open_box<bool> (val));
962
send_update (THIS, val);
965
send_keyboard (THIS, val);
967
case SLOT_KEYBOARD_FOCUS:
968
send_keyboard_focus (THIS, val);
971
send_mouse (THIS, val);
973
case SLOT_MOUSE_GRAB:
974
send_mouse_grab (THIS, val);
976
case SLOT_MOUSE_POINTER:
977
send_mouse_pointer (THIS, val);
979
case SLOT_INVALIDATE:
980
send_invalidate (THIS, val);
982
case SLOT_INVALIDATE_ALL:
983
send_invalidate_all (THIS, val);
986
send_repaint (THIS, val);
988
case SLOT_DELAYED_MESSAGE:
989
send_delayed_message (THIS, val);
992
send_destroy (THIS, val);
995
case SLOT_SHRINKING_FACTOR:
996
send_int (THIS, "shrinking factor", val);
999
send_coord4 (THIS, "extents", val);
1001
case SLOT_SCROLLBARS_VISIBILITY:
1002
send_int (THIS, "scrollbars", val);
1004
case SLOT_SCROLL_POSITION:
1005
send_coord2 (THIS, "scroll position", val);
1008
case SLOT_HEADER_VISIBILITY:
1009
send_bool (THIS, "header", val);
1011
case SLOT_MAIN_ICONS_VISIBILITY:
1012
send_bool (THIS, "main icons", val);
1014
case SLOT_CONTEXT_ICONS_VISIBILITY:
1015
send_bool (THIS, "context icons", val);
1017
case SLOT_USER_ICONS_VISIBILITY:
1018
send_bool (THIS, "user icons", val);
1020
case SLOT_FOOTER_VISIBILITY:
1021
send_bool (THIS, "footer flag", val);
1023
case SLOT_LEFT_FOOTER:
1024
send_string (THIS, "left footer", val);
1026
case SLOT_RIGHT_FOOTER:
1027
send_string (THIS, "right footer", val);
1029
case SLOT_INTERACTIVE_MODE:
1030
send_bool (THIS, "interactive mode", val);
1033
case SLOT_STRING_INPUT:
1034
send_string (THIS, "input", val);
1036
case SLOT_INPUT_TYPE:
1037
send_string (THIS, "type", val);
1039
case SLOT_INPUT_PROPOSAL:
1040
send_string (THIS, "default", val);
1043
send_string (THIS, "file", val);
1045
case SLOT_DIRECTORY:
1046
send_string (THIS, "directory", val);
1050
fatal_error ("cannot handle slot type", "aqua_view_widget_rep::send");
883
TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
884
coord2 p= open_box<coord2> (val);
885
NSWindow *win = [wc window];
887
NSSize size = to_nssize(p);
888
[win setContentSize:size];
894
TYPE_CHECK (type_box (val) == type_helper<coord2>::id);
895
coord2 p= open_box<coord2> (val);
896
NSWindow *win = [wc window];
898
[win setFrameOrigin:to_nspoint(p)];
902
case SLOT_VISIBILITY:
904
check_type<bool> (val, "SLOT_VISIBILITY");
905
bool flag = open_box<bool> (val);
906
NSWindow *win = [wc window];
908
if (flag) [win makeKeyAndOrderFront:nil] ;
909
else [win orderOut:nil] ;
915
check_type<string> (val, "SLOT_NAME");
916
string name = open_box<string> (val);
917
NSWindow *win = [wc window];
919
NSString *title = to_nsstring(name);
920
[win setTitle:title];
924
case SLOT_FULL_SCREEN:
925
check_type<bool> (val, "SLOT_FULL_SCREEN");
926
// win->set_full_screen (open_box<bool> (val));
930
// send_update (THIS, val);
934
FAILED ("cannot handle slot type");
1056
940
aqua_window_widget_rep::query (slot s, int type_id) {
1058
case SLOT_IDENTIFIER:
1059
if (type_id != type_helper<int>::id)
1060
fatal_error ("int expected (SLOT_IDENTIFIER)", "aqua_window_widget_rep::query");
1061
return close_box<int> ((int)[wc window]);
1064
typedef pair<SI,SI> coord2;
1065
if (type_id != type_helper<coord2>::id)
1066
fatal_error ("type mismatch (SLOT_POSITION)", "aqua_window_widget_rep::query");
1067
NSRect frame = [[wc window] frame];
1068
return close_box<coord2> (from_nspoint(frame.origin));
1072
typedef pair<SI,SI> coord2;
1073
if (type_id != type_helper<coord2>::id)
1074
fatal_error ("type mismatch (SLOT_SIZE)", "aqua_window_widget_rep::query");
1075
NSRect frame = [[wc window] frame];
1076
return close_box<coord2> (from_nssize(frame.size));
1080
if (type_id != type_helper<renderer>::id)
1081
fatal_error ("renderer expected (SLOT_RENDERER)",
1082
"aqua_window_widget_rep::query");
1083
return close_box<renderer> ((renderer) win);
1085
case SLOT_KEYBOARD_FOCUS:
1086
return query_keyboard_focus (THIS, type_id);
1087
case SLOT_MOUSE_GRAB:
1088
return query_mouse_grab (THIS, type_id);
1091
return query_coord4 (THIS, "extents", type_id);
1092
case SLOT_VISIBLE_PART:
1093
return query_coord4 (THIS, "visible", type_id);
1094
case SLOT_SCROLLBARS_VISIBILITY:
1095
return query_int (THIS, "scrollbars", type_id);
1096
case SLOT_SCROLL_POSITION:
1097
return query_coord2 (THIS, "scroll position", type_id);
1099
case SLOT_HEADER_VISIBILITY:
1100
return query_bool (THIS, "header", type_id);
1101
case SLOT_MAIN_ICONS_VISIBILITY:
1102
return query_bool (THIS, "main icons", type_id);
1103
case SLOT_CONTEXT_ICONS_VISIBILITY:
1104
return query_bool (THIS, "context icons", type_id);
1105
case SLOT_USER_ICONS_VISIBILITY:
1106
return query_bool (THIS, "user icons", type_id);
1107
case SLOT_FOOTER_VISIBILITY:
1108
return query_bool (THIS, "footer flag", type_id);
1109
case SLOT_INTERACTIVE_MODE:
1110
return query_bool (THIS, "interactive mode", type_id);
1111
case SLOT_INTERACTIVE_INPUT:
1112
return query_string (THIS, "interactive input", type_id);
1114
case SLOT_STRING_INPUT:
1115
return query_string (THIS, "input", type_id);
1118
fatal_error ("cannot handle slot type", "aqua_widow_widget_rep::query");
942
case SLOT_IDENTIFIER:
943
TYPE_CHECK (type_id == type_helper<int>::id);
944
return close_box<int> ((int)[wc window] ? 1 : 0);
947
typedef pair<SI,SI> coord2;
948
TYPE_CHECK (type_id == type_helper<coord2>::id);
949
NSRect frame = [[wc window] frame];
950
return close_box<coord2> (from_nspoint(frame.origin));
954
typedef pair<SI,SI> coord2;
955
TYPE_CHECK (type_id == type_helper<coord2>::id);
956
NSRect frame = [[wc window] frame];
957
return close_box<coord2> (from_nssize(frame.size));
960
FAILED ("cannot handle slot type");
1128
970
aqua_window_widget_rep::notify (slot s, blackbox new_val) {
1132
check_type<SI,SI> (new_val, "SLOT_SIZE");
1133
THIS << emit_resize ();
1134
if (is_window_widget ())
1135
send_size (THIS [0], new_val);
1138
check_type<SI,SI> (new_val, "SLOT_POSITION");
1139
THIS << emit_move ();
1141
case SLOT_KEYBOARD_FOCUS:
1142
notify_keyboard_focus (THIS, new_val);
1144
case SLOT_MOUSE_GRAB:
1145
notify_mouse_grab (THIS, new_val);
1150
971
widget_rep::notify (s, new_val);
1154
975
aqua_window_widget_rep::read (slot s, blackbox index) {
1158
check_type_void (index, "SLOT_WINDOW");
1159
return win -> get_widget ();
1160
case SLOT_FORM_FIELD:
1161
check_type<int> (index, "SLOT_FORM_FIELD");
1162
return abstract (THIS [0] ["inputs"] [open_box<int> (index)] ["input"]);
1164
check_type_void (index, "SLOT_FILE");
1165
return abstract (THIS [0] ["file"] ["input"]);
1166
case SLOT_DIRECTORY:
1167
check_type_void (index, "SLOT_DIRECTORY");
1168
return abstract (THIS [0] ["directory"] ["input"]);
1171
fatal_error ("cannot handle slot type", "aqua_window_widget_rep::read");
978
FAILED ("cannot handle slot type");
1177
984
aqua_window_widget_rep::write (slot s, blackbox index, widget w) {
1180
check_type_void (index, "SLOT_CANVAS");
1181
// [(NSScrollView*)view setDocumentView: concrete (w)->get_nsview()];
1183
case SLOT_MAIN_MENU:
1184
check_type_void (index, "SLOT_MAIN_MENU");
1185
// THIS << set_widget ("menu bar", concrete (w));
1187
case SLOT_MAIN_ICONS:
1188
check_type_void (index, "SLOT_MAIN_ICONS");
1189
// THIS << set_widget ("main icons bar", concrete (w));
1191
case SLOT_CONTEXT_ICONS:
1192
check_type_void (index, "SLOT_CONTEXT_ICONS");
1193
// THIS << set_widget ("context icons bar", concrete (w));
1195
case SLOT_USER_ICONS:
1196
check_type_void (index, "SLOT_USER_ICONS");
1197
// THIS << set_widget ("user icons bar", concrete (w));
1199
case SLOT_INTERACTIVE_PROMPT:
1200
check_type_void (index, "SLOT_INTERACTIVE_PROMPT");
1201
// THIS << set_widget ("interactive prompt", concrete (w));
1203
case SLOT_INTERACTIVE_INPUT:
1204
check_type_void (index, "SLOT_INTERACTIVE_INPUT");
1205
// THIS << set_widget ("interactive input", concrete (w));
1208
fatal_error ("cannot handle slot type", "aqua_window_widget_rep::write");
988
check_type_void (index, "SLOT_CANVAS");
989
// [(NSScrollView*)view setDocumentView: concrete (w)->get_nsview()];
992
check_type_void (index, "SLOT_MAIN_MENU");
993
// THIS << set_widget ("menu bar", concrete (w));
995
case SLOT_MAIN_ICONS:
996
check_type_void (index, "SLOT_MAIN_ICONS");
997
// THIS << set_widget ("main icons bar", concrete (w));
999
case SLOT_CONTEXT_ICONS:
1000
check_type_void (index, "SLOT_CONTEXT_ICONS");
1001
// THIS << set_widget ("context icons bar", concrete (w));
1003
case SLOT_USER_ICONS:
1004
check_type_void (index, "SLOT_USER_ICONS");
1005
// THIS << set_widget ("user icons bar", concrete (w));
1007
case SLOT_INTERACTIVE_PROMPT:
1008
check_type_void (index, "SLOT_INTERACTIVE_PROMPT");
1009
// THIS << set_widget ("interactive prompt", concrete (w));
1011
case SLOT_INTERACTIVE_INPUT:
1012
check_type_void (index, "SLOT_INTERACTIVE_INPUT");
1013
// THIS << set_widget ("interactive input", concrete (w));
1017
FAILED ("cannot handle slot type");
1213
1022
/******************************************************************************
1215
******************************************************************************/
1024
******************************************************************************/
1216
1025
#pragma mark simple_widget_rep
1218
1027
/******************************************************************************