1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
// license:BSD-3-Clause
// copyright-holders:Vas Crabb
//============================================================
//
// pointsviewer.m - MacOS X Cocoa debug window handling
//
//============================================================
#import "pointsviewer.h"
#import "breakpointsview.h"
#import "watchpointsview.h"
@implementation MAMEPointsViewer
- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c {
MAMEDebugView *breakView, *watchView;
NSScrollView *breakScroll, *watchScroll;
NSTabViewItem *breakTab, *watchTab;
NSPopUpButton *actionButton, *subviewButton;
NSRect subviewFrame;
if (!(self = [super initWithMachine:m title:@"(Break|Watch)points" console:c]))
return nil;
NSRect const contentBounds = [[window contentView] bounds];
NSFont *const defaultFont = [[MAMEDebugView class] defaultFontForMachine:m];
// create the subview popup
subviewButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 100, 19)];
[subviewButton setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
[subviewButton setBezelStyle:NSShadowlessSquareBezelStyle];
[subviewButton setFocusRingType:NSFocusRingTypeNone];
[subviewButton setFont:defaultFont];
[subviewButton setTarget:self];
[subviewButton setAction:@selector(changeSubview:)];
[[subviewButton cell] setArrowPosition:NSPopUpArrowAtBottom];
[[[subviewButton menu] addItemWithTitle:@"All Breakpoints"
action:NULL
keyEquivalent:@""] setTag:0];
[[[subviewButton menu] addItemWithTitle:@"All Watchpoints"
action:NULL
keyEquivalent:@""] setTag:1];
[subviewButton sizeToFit];
subviewFrame = [subviewButton frame];
subviewFrame.origin.x = subviewFrame.size.height;
subviewFrame.origin.y = contentBounds.size.height - subviewFrame.size.height;
subviewFrame.size.width = contentBounds.size.width - subviewFrame.size.height;
[subviewButton setFrame:subviewFrame];
[[window contentView] addSubview:subviewButton];
[subviewButton release];
// create the action popup
actionButton = [[self class] newActionButtonWithFrame:NSMakeRect(0,
subviewFrame.origin.y,
subviewFrame.size.height,
subviewFrame.size.height)];
[actionButton setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
[actionButton setFont:[NSFont systemFontOfSize:[defaultFont pointSize]]];
[[window contentView] addSubview:actionButton];
[actionButton release];
// create the breakpoints view
breakView = [[MAMEBreakpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
machine:*machine];
breakScroll = [[NSScrollView alloc] initWithFrame:NSMakeRect(0,
0,
contentBounds.size.width,
contentBounds.size.height - subviewFrame.size.height)];
[breakScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[breakScroll setHasHorizontalScroller:YES];
[breakScroll setHasVerticalScroller:YES];
[breakScroll setAutohidesScrollers:YES];
[breakScroll setBorderType:NSNoBorder];
[breakScroll setDrawsBackground:NO];
[breakScroll setDocumentView:breakView];
[breakView release];
breakTab = [[NSTabViewItem alloc] initWithIdentifier:@""];
[breakTab setView:breakScroll];
[breakScroll release];
// create the breakpoints view
watchView = [[MAMEWatchpointsView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)
machine:*machine];
watchScroll = [[NSScrollView alloc] initWithFrame:[breakScroll frame]];
[watchScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[watchScroll setHasHorizontalScroller:YES];
[watchScroll setHasVerticalScroller:YES];
[watchScroll setAutohidesScrollers:YES];
[watchScroll setBorderType:NSNoBorder];
[watchScroll setDrawsBackground:NO];
[watchScroll setDocumentView:watchView];
[watchView release];
watchTab = [[NSTabViewItem alloc] initWithIdentifier:@""];
[watchTab setView:watchScroll];
[watchScroll release];
// create a tabless tabview for the two subviews
tabs = [[NSTabView alloc] initWithFrame:[breakScroll frame]];
[tabs setTabViewType:NSNoTabsNoBorder];
[tabs setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
[tabs addTabViewItem:breakTab];
[breakTab release];
[tabs addTabViewItem:watchTab];
[watchTab release];
[[window contentView] addSubview:tabs];
[tabs release];
// set default state
[subviewButton selectItemAtIndex:0];
[tabs selectFirstTabViewItem:self];
[window makeFirstResponder:subviewButton];
[window setTitle:[[subviewButton selectedItem] title]];
// calculate the optimal size for everything
NSSize const breakDesired = [NSScrollView frameSizeForContentSize:[breakView maximumFrameSize]
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[breakScroll borderType]];
NSSize const watchDesired = [NSScrollView frameSizeForContentSize:[watchView maximumFrameSize]
hasHorizontalScroller:YES
hasVerticalScroller:YES
borderType:[watchScroll borderType]];
NSSize const desired = NSMakeSize(std::max(breakDesired.width, watchDesired.width),
std::max(breakDesired.height, watchDesired.height));
[self cascadeWindowWithDesiredSize:desired forView:tabs];
// don't forget the result
return self;
}
- (void)dealloc {
[super dealloc];
}
- (IBAction)changeSubview:(id)sender {
[tabs selectTabViewItemAtIndex:[[sender selectedItem] tag]];
[window setTitle:[[sender selectedItem] title]];
}
@end
|