aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2023-09-26 21:52:38 +0200
committerTeddy Wing2023-09-26 21:52:38 +0200
commit88c9a6b8775b5c97d21811b7f48a92eeeb5906c2 (patch)
tree217a63f8da1c6a2d6a6ff09e2919efa570027214 /src
parentf8bd83d4bf2dffafefd4f5532c8bc8128278b4a7 (diff)
downloadBase-Windowed-Application-88c9a6b8775b5c97d21811b7f48a92eeeb5906c2.tar.bz2
Document: Initial attempt to cascade new document windows
When creating a new document with Apple-N, try to cascade the new window so that it opens a bit below and to the right of the previous window. Store the previous window origin in a static variable for a relative reference point. Currently this seems to cascade, but not by a full titlebar height and corresponding horizontal position. Needs some adjustment.
Diffstat (limited to 'src')
-rw-r--r--src/Document.m21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Document.m b/src/Document.m
index e50737d..609f0a6 100644
--- a/src/Document.m
+++ b/src/Document.m
@@ -1,11 +1,21 @@
#import "Document.h"
+static NSPoint *cascade_offset;
+
@implementation Document
- (id)init
{
self = [super init];
if (self) {
+ NSLog(@"Checking cascade_offset");
+ if (!cascade_offset) {
+ NSLog(@"Setting cascade_offset");
+ NSPoint p = NSMakePoint(100, 100);
+ cascade_offset = &p;
+ NSLog(@"Has set cascade_offset");
+ }
+
_label = [[NSTextField alloc]
initWithFrame:NSMakeRect(0, 0, 180, 20)];
[_label setStringValue:@"Your document contents here"];
@@ -31,7 +41,7 @@
// DocumentWindowController *controller = [[DocumentWindowController alloc] init];
NSWindow *window = [[NSWindow alloc]
- initWithContentRect:NSMakeRect(0, 0, 600, 500)
+ initWithContentRect:NSMakeRect(100, 50, 600, 500)
styleMask:
NSWindowStyleMaskTitled
| NSWindowStyleMaskClosable
@@ -63,7 +73,14 @@
| NSViewMaxYMargin];
// TODO: Cascade, store previous top-left position.
- // [window cascadeTopLeftFromPoint:NSMakePoint(100, 100)];
+ if (cascade_offset) {
+ // cascade_offset = NSMakePoint(100, 100);
+ NSLog(@"Yes");
+ }
+
+ *cascade_offset = [window cascadeTopLeftFromPoint:*cascade_offset];
+
+ // cascade_offset = [window frame].origin;
NSWindowController *window_controller = [[NSWindowController alloc]
initWithWindow:window];