summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/debugger/osx/debugwindowhandler.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/debugger/osx/debugwindowhandler.mm')
-rw-r--r--src/osd/modules/debugger/osx/debugwindowhandler.mm62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/osd/modules/debugger/osx/debugwindowhandler.mm b/src/osd/modules/debugger/osx/debugwindowhandler.mm
index 7bee4ec8ce0..9c79e496f5d 100644
--- a/src/osd/modules/debugger/osx/debugwindowhandler.mm
+++ b/src/osd/modules/debugger/osx/debugwindowhandler.mm
@@ -15,6 +15,9 @@
#include "debugger.h"
+#include "util/xmlfile.h"
+
+
//============================================================
// NOTIFICATIONS
//============================================================
@@ -22,6 +25,7 @@
NSString *const MAMEHideDebuggerNotification = @"MAMEHideDebuggerNotification";
NSString *const MAMEShowDebuggerNotification = @"MAMEShowDebuggerNotification";
NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryDebugWindowWillCloseNotification";
+NSString *const MAMESaveDebuggerConfigurationNotification = @"MAMESaveDebuggerConfigurationNotification";
//============================================================
@@ -155,6 +159,10 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
[window setContentMinSize:NSMakeSize(320, 240)];
[[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(saveConfig:)
+ name:MAMESaveDebuggerConfigurationNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(showDebugger:)
name:MAMEShowDebuggerNotification
object:nil];
@@ -269,6 +277,46 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
[window orderOut:self];
}
+
+- (void)saveConfig:(NSNotification *)notification {
+ running_machine *m = (running_machine *)[[[notification userInfo] objectForKey:@"MAMEDebugMachine"] pointerValue];
+ if (m == machine)
+ {
+ util::xml::data_node *parentnode = (util::xml::data_node *)[[[notification userInfo] objectForKey:@"MAMEDebugParentNode"] pointerValue];
+ util::xml::data_node *node = parentnode->add_child("window", nullptr);
+ if (node)
+ [self saveConfigurationToNode:node];
+ }
+}
+
+
+- (void)saveConfigurationToNode:(util::xml::data_node *)node {
+ NSRect frame = [window frame];
+ node->set_attribute_float("position_x", frame.origin.x);
+ node->set_attribute_float("position_y", frame.origin.y);
+ node->set_attribute_float("size_x", frame.size.width);
+ node->set_attribute_float("size_y", frame.size.height);
+}
+
+
+- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
+ NSRect frame = [window frame];
+ frame.origin.x = node->get_attribute_float("position_x", frame.origin.x);
+ frame.origin.y = node->get_attribute_float("position_y", frame.origin.y);
+ frame.size.width = node->get_attribute_float("size_x", frame.size.width);
+ frame.size.height = node->get_attribute_float("size_y", frame.size.height);
+
+ NSSize min = [window minSize];
+ frame.size.width = std::max(frame.size.width, min.width);
+ frame.size.height = std::max(frame.size.height, min.height);
+
+ NSSize max = [window maxSize];
+ frame.size.width = std::min(frame.size.width, max.width);
+ frame.size.height = std::min(frame.size.height, max.height);
+
+ [window setFrame:frame display:YES];
+}
+
@end
@@ -449,4 +497,18 @@ NSString *const MAMEAuxiliaryDebugWindowWillCloseNotification = @"MAMEAuxiliaryD
return NO;
}
+
+- (void)saveConfigurationToNode:(util::xml::data_node *)node {
+ [super saveConfigurationToNode:node];
+ node->add_child("expression", [[self expression] UTF8String]);
+}
+
+
+- (void)restoreConfigurationFromNode:(util::xml::data_node const *)node {
+ [super restoreConfigurationFromNode:node];
+ util::xml::data_node const *const expr = node->get_child("expression");
+ if (expr && expr->get_value())
+ [self setExpression:[NSString stringWithUTF8String:expr->get_value()]];
+}
+
@end