From 62e7938594d1d95c8913aef7874e7e4de9c3ad3d Mon Sep 17 00:00:00 2001 From: shatty Date: Sun, 10 Aug 2003 11:46:37 +0000 Subject: [PATCH] wrapping cascading! okay, i am really wasting my time now... I will go back to terminal I promise. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4268 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/stylededit/StyledEditApp.cpp | 48 ++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/src/apps/stylededit/StyledEditApp.cpp b/src/apps/stylededit/StyledEditApp.cpp index e0bea2a3e6..33949fb25f 100644 --- a/src/apps/stylededit/StyledEditApp.cpp +++ b/src/apps/stylededit/StyledEditApp.cpp @@ -1,18 +1,50 @@ +#include #include #include #include #include #include -#include +#include #include -#include "Constants.h" -#include "StyledEditApp.h" -#include "StyledEditWindow.h" + +#include +#include +#include using namespace BPrivate; -BRect windowRect(7,26,507,426); +BRect windowRect(7-15,26-15,507,426); + +void cascade() { + BScreen screen(NULL); + BRect screenBorder = screen.Frame(); + float left = windowRect.left + 15; + if (left + windowRect.Width() > screenBorder.right) { + left = 7; + } + float top = windowRect.top + 15; + if (top + windowRect.Height() > screenBorder.bottom) { + top = 26; + } + windowRect.OffsetTo(BPoint(left,top)); +} + +void uncascade() { + BScreen screen(NULL); + BRect screenBorder = screen.Frame(); + float left = windowRect.left - 15; + if (left < 7) { + left = screenBorder.right - windowRect.Width() - 7; + left = left - ((int)left % 15) + 7; + } + float top = windowRect.top - 15; + if (top < 26) { + top = screenBorder.bottom - windowRect.Height() - 26; + top = top - ((int)left % 15) + 26; + } + windowRect.OffsetTo(BPoint(left,top)); +} StyledEditApp * styled_edit_app; @@ -106,24 +138,24 @@ StyledEditApp::MessageReceived(BMessage *message) void StyledEditApp::OpenDocument() { + cascade(); new StyledEditWindow(windowRect,fNext_Untitled_Window++,fOpenAsEncoding); - windowRect.OffsetBy(15,15); // TODO: wrap around screen fWindowCount++; } void StyledEditApp::OpenDocument(entry_ref * ref) { + cascade(); new StyledEditWindow(windowRect,ref,fOpenAsEncoding); - windowRect.OffsetBy(15,15); // TODO: wrap around screen fWindowCount++; } void StyledEditApp::CloseDocument() { + uncascade(); fWindowCount--; - windowRect.OffsetBy(-15,-15); if (fWindowCount == 0) { BAutolock lock(this); Quit();