Previous 199869 Revisions Next

r35105 Wednesday 18th February, 2015 at 13:42:26 UTC by Vasantha Crabb
Add preliminary device detail windows
[src/osd/modules/debugger/osx]debugconsole.h debugconsole.m debugview.m deviceinfoviewer.h* deviceinfoviewer.m* devicesviewer.h devicesviewer.m
[src/osd/sdl]sdl.mak

trunk/src/osd/modules/debugger/osx/debugconsole.h
r243616r243617
4949
5050- (void)debugNewMemoryWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression;
5151- (void)debugNewDisassemblyWindowForSpace:(address_space *)space device:(device_t *)device expression:(NSString *)expression;
52- (void)debugNewInfoWindowForDevice:(device_t &)device;
5253
5354- (void)showDebugger:(NSNotification *)notification;
5455- (void)auxiliaryWindowWillClose:(NSNotification *)notification;
trunk/src/osd/modules/debugger/osx/debugconsole.m
r243616r243617
1414#import "debugcommandhistory.h"
1515#import "consoleview.h"
1616#import "debugview.h"
17#import "deviceinfoviewer.h"
1718#import "devicesviewer.h"
1819#import "disassemblyview.h"
1920#import "disassemblyviewer.h"
r243616r243617
350351}
351352
352353
354- (void)debugNewInfoWindowForDevice:(device_t &)device {
355   MAMEDeviceInfoViewer *win = [[MAMEDeviceInfoViewer alloc] initWithDevice:device
356                                                    machine:*machine
357                                                    console:self];
358   [auxiliaryWindows addObject:win];
359   [win release];
360   [win activate];
361}
362
363
353364- (void)showDebugger:(NSNotification *)notification {
354365   device_t *device = (device_t * )[[[notification userInfo] objectForKey:@"MAMEDebugDevice"] pointerValue];
355366   if (&device->machine() == machine)
trunk/src/osd/modules/debugger/osx/debugview.m
r243616r243617
456456
457457
458458- (void)mouseDragged:(NSEvent *)event {
459   [self autoscroll:event];
459460   NSPoint const location = [self convertPoint:[event locationInWindow] fromView:nil];
460461   NSUInteger const modifiers = [event modifierFlags];
461462   if (view->cursor_supported()
trunk/src/osd/modules/debugger/osx/deviceinfoviewer.h
r0r243617
1// license:BSD-3-Clause
2// copyright-holders:Vas Crabb
3//============================================================
4//
5//  deviceinfoviewer.h - MacOS X Cocoa debug window handling
6//
7//  Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
8//  Visit http://mamedev.org for licensing and usage restrictions.
9//
10//============================================================
11
12#import "debugosx.h"
13
14#import "debugwindowhandler.h"
15
16#include "emu.h"
17
18#import <Cocoa/Cocoa.h>
19
20
21@class MAMEDebugConsole, MAMEDeviceWrapper;
22
23@interface MAMEDeviceInfoViewer : MAMEAuxiliaryDebugWindowHandler
24{
25   device_t   *device;
26}
27
28- (id)initWithDevice:(device_t &)d machine:(running_machine &)m console:(MAMEDebugConsole *)c;
29
30@end
trunk/src/osd/modules/debugger/osx/deviceinfoviewer.m
r0r243617
1// license:BSD-3-Clause
2// copyright-holders:Vas Crabb
3//============================================================
4//
5//  deviceinfoviewer.m - MacOS X Cocoa debug window handling
6//
7//  Copyright (c) 1996-2015, Nicola Salmoria and the MAME Team.
8//  Visit http://mamedev.org for licensing and usage restrictions.
9//
10//============================================================
11
12#import "deviceinfoviewer.h"
13
14
15@implementation MAMEDeviceInfoViewer
16
17- (NSTextField *)makeLabel:(NSString *)text {
18   NSTextField *const result = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 14)];
19   [result setAutoresizingMask:NSViewMinYMargin];
20   [[result cell] setControlSize:NSSmallControlSize];
21   [result setEditable:NO];
22   [result setSelectable:NO];
23   [result setBezeled:NO];
24   [result setBordered:NO];
25   [result setDrawsBackground:NO];
26   [result setAlignment:NSRightTextAlignment];
27   [result setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
28   [result setStringValue:text];
29   [result sizeToFit];
30   return result;
31}
32
33
34- (NSTextField *)makeField:(NSString *)text {
35   NSTextField *const result = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 100, 14)];
36   [result setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
37   [[result cell] setControlSize:NSSmallControlSize];
38   [result setEditable:NO];
39   [result setSelectable:YES];
40   [result setBezeled:NO];
41   [result setBordered:NO];
42   [result setDrawsBackground:NO];
43   [result setAlignment:NSLeftTextAlignment];
44   [result setFont:[NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]]];
45   [result setStringValue:text];
46   [result sizeToFit];
47   return result;
48}
49
50
51- (NSBox *)makeBox:(NSString *)t toFit:(NSView *)v {
52   NSBox *const result = [[NSBox alloc] initWithFrame:NSMakeRect(0, 0, [v frame].size.width - 34, 32)];
53   [result setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
54   [result setTitle:t];
55   [result setBoxType:NSBoxPrimary];
56   [result setBorderType:NSLineBorder];
57   [result setContentViewMargins:NSMakeSize(0, 0)];
58   [result setAutoresizesSubviews:YES];
59   return result;
60}
61
62
63- (void)addLabel:(NSString *)l withWidth:(CGFloat)w andField:(NSString *)f toView:(NSView *)v {
64   NSTextField *const label = [self makeLabel:l];
65   NSTextField *const field = [self makeField:f];
66   CGFloat const height = MAX([label frame].size.height, [field frame].size.height);
67   NSSize space = [v bounds].size;
68   space.width = MAX(space.width, [field frame].size.width + w + 52);
69   space.height += height + 8;
70   [label setFrame:NSMakeRect(25, 20, w, height)];
71   [field setFrame:NSMakeRect(w + 27, 20, space.width - w - 52, height)];
72   [v setFrameSize:space];
73   [v addSubview:label];
74   [v addSubview:field];
75   [label release];
76   [field release];
77}
78
79
80- (void)addField:(NSString *)f toBox:(NSBox *)b {
81   NSTextField *const field = [self makeField:f];
82   NSSize space = [b frame].size;
83   space.width = MAX(space.width, [field frame].size.width + 32);
84   space.height += [field frame].size.height + 8;
85   [field setFrame:NSMakeRect(15, 14, space.width - 32, [field frame].size.height)];
86   [b setFrameSize:space];
87   [[b contentView] addSubview:field];
88   [field release];
89}
90
91
92- (void)addBox:(NSBox *)b toView:(NSView *)v {
93   [b setFrameOrigin:NSMakePoint(17, 16)];
94   NSSize space = [v frame].size;
95   space.width = MAX(space.width, [b frame].size.width + 34);
96   space.height += [b frame].size.height + 4;
97   [v setFrameSize:space];
98   [v addSubview:b];
99}
100
101
102- (id)initWithDevice:(device_t &)d machine:(running_machine &)m console:(MAMEDebugConsole *)c {
103   NSView         *contentView;
104   NSScrollView   *contentScroll;
105
106   if (!(self = [super initWithMachine:m
107                          title:[NSString stringWithFormat:@"Device %s", d.tag()]
108                        console:c]))
109   {
110      return nil;
111   }
112   device = &d;
113
114   // Create a view to hold everything
115   contentView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 32)];
116   [contentView setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
117   [contentView setAutoresizesSubviews:YES];
118
119   // add the stuff that's always present
120   [self addLabel:@"Tag:"
121       withWidth:100
122        andField:[NSString stringWithUTF8String:device->tag()]
123         toView:contentView];
124   [self addLabel:@"Name:"
125       withWidth:100
126        andField:[NSString stringWithUTF8String:device->name()]
127         toView:contentView];
128   [self addLabel:@"Shortname:"
129       withWidth:100
130        andField:[NSString stringWithUTF8String:device->shortname()]
131         toView:contentView];
132
133   // add interfaces if present
134   device_interface *interface = device->first_interface();
135   if (interface != NULL)
136   {
137      NSBox *const interfacesBox = [self makeBox:@"Interfaces" toFit:contentView];
138      while (interface != NULL)
139      {
140         [self addField:[NSString stringWithUTF8String:interface->interface_type()]
141                toBox:interfacesBox];
142         interface = interface->interface_next();
143      }
144      [self addBox:interfacesBox toView:contentView];
145      [interfacesBox release];
146   }
147
148   // add memory maps if present
149   device_memory_interface *memory;
150   if (device->interface(memory))
151   {
152      NSBox *memoryBox = nil;
153      for (address_spacenum i = AS_0; i < ADDRESS_SPACES; i++)
154      {
155         if (memory->has_space(i))
156         {
157            if (memoryBox == nil)
158               memoryBox = [self makeBox:@"Memory maps" toFit:contentView];
159            [self addField:[NSString stringWithUTF8String:memory->space_config(i)->name()]
160                   toBox:memoryBox];
161         }
162      }
163      if (memoryBox != nil)
164      {
165         [self addBox:memoryBox toView:contentView];
166         [memoryBox release];
167      }
168   }
169
170   // create a scroll view for holding everything
171   NSSize desired = [NSScrollView frameSizeForContentSize:[contentView frame].size
172                            hasHorizontalScroller:YES
173                              hasVerticalScroller:YES
174                                    borderType:NSNoBorder];
175   [window setContentSize:desired];
176   contentScroll = [[NSScrollView alloc] initWithFrame:[[window contentView] bounds]];
177   [contentScroll setDrawsBackground:NO];
178   [contentScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
179   [contentScroll setHasHorizontalScroller:YES];
180   [contentScroll setHasVerticalScroller:YES];
181   [contentScroll setAutohidesScrollers:YES];
182   [contentScroll setBorderType:NSNoBorder];
183   [contentScroll setDocumentView:contentView];
184   [contentView release];
185   [[window contentView] addSubview:contentScroll];
186   [contentScroll release];
187
188   // calculate the optimal size for everything
189   [self cascadeWindowWithDesiredSize:NSMakeSize(320, 240) forView:contentScroll];
190
191   // don't forget the result
192   return self;
193}
194
195@end
No newline at end of file
trunk/src/osd/modules/debugger/osx/devicesviewer.h
r243616r243617
2828
2929- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c;
3030
31- (IBAction)showDeviceDetail:(id)sender;
32
3133@end
trunk/src/osd/modules/debugger/osx/devicesviewer.m
r243616r243617
1111
1212#import "devicesviewer.h"
1313
14#import "debugconsole.h"
1415
16
1517@interface MAMEDeviceWrapper : NSObject
1618{
1719   running_machine   *machine;
r243616r243617
138140   [nameColumn release];
139141   [devicesView setOutlineTableColumn:tagColumn];
140142   [devicesView setAutoresizesOutlineColumn:YES];
143   [devicesView setDoubleAction:@selector(showDeviceDetail:)];
141144   [devicesView setDataSource:self];
142145   devicesScroll = [[NSScrollView alloc] initWithFrame:[[window contentView] bounds]];
143   [devicesScroll setDrawsBackground:YES];
144146   [devicesScroll setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
145147   [devicesScroll setHasHorizontalScroller:YES];
146148   [devicesScroll setHasVerticalScroller:YES];
r243616r243617
175177}
176178
177179
180- (IBAction)showDeviceDetail:(id)sender {
181   [console debugNewInfoWindowForDevice:[(MAMEDeviceWrapper *)[sender itemAtRow:[sender clickedRow]] device]];
182}
183
184
178185- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
179186   return [(MAMEDeviceWrapper *)item children] > 0;
180187}
trunk/src/osd/sdl/sdl.mak
r243616r243617
295295   $(OSDOBJ)/modules/debugger/osx/debugconsole.o \
296296   $(OSDOBJ)/modules/debugger/osx/debugview.o \
297297   $(OSDOBJ)/modules/debugger/osx/debugwindowhandler.o \
298   $(OSDOBJ)/modules/debugger/osx/deviceinfoviewer.o \
298299   $(OSDOBJ)/modules/debugger/osx/devicesviewer.o \
299300   $(OSDOBJ)/modules/debugger/osx/disassemblyview.o \
300301   $(OSDOBJ)/modules/debugger/osx/disassemblyviewer.o \


Previous 199869 Revisions Next


© 1997-2024 The MAME Team