2003-02-15 18:28:22 +03:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2001-2002, OpenBeOS
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: WinBorder.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
2004-06-03 00:44:46 +04:00
|
|
|
// Adi Oanca <adioanca@mymail.ro>
|
2003-02-15 18:28:22 +03:00
|
|
|
// Description: Layer subclass which handles window management
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2003-02-14 04:53:53 +03:00
|
|
|
#include <Region.h>
|
|
|
|
#include <String.h>
|
|
|
|
#include <Locker.h>
|
|
|
|
#include <Debug.h>
|
2003-09-17 04:03:47 +04:00
|
|
|
#include <TokenSpace.h>
|
2004-06-11 06:46:48 +04:00
|
|
|
#include "PortMessage.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "View.h" // for mouse button defines
|
|
|
|
#include "ServerWindow.h"
|
|
|
|
#include "Decorator.h"
|
|
|
|
#include "DisplayDriver.h"
|
|
|
|
#include "Desktop.h"
|
|
|
|
#include "WinBorder.h"
|
2003-03-12 21:32:27 +03:00
|
|
|
#include "AppServer.h" // for new_decorator()
|
2003-09-09 02:09:10 +04:00
|
|
|
#include "TokenHandler.h"
|
2004-01-13 03:38:42 +03:00
|
|
|
#include "Globals.h"
|
|
|
|
#include "RootLayer.h"
|
|
|
|
#include "Workspace.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
// TODO: Document this file completely
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// Toggle general function call output
|
2004-06-18 15:50:17 +04:00
|
|
|
//#define DEBUG_WINBORDER
|
2003-09-07 01:09:11 +04:00
|
|
|
|
|
|
|
// toggle
|
2004-06-03 00:44:46 +04:00
|
|
|
//#define DEBUG_WINBORDER_MOUSE
|
|
|
|
//#define DEBUG_WINBORDER_CLICK
|
2003-03-23 23:52:37 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_WINBORDER
|
2003-09-09 02:09:10 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef DEBUG_WINBORDER_MOUSE
|
2003-09-09 02:09:10 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE_MOUSE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE_MOUSE(x) ;
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
|
|
|
|
2003-04-05 05:51:35 +04:00
|
|
|
#ifdef DEBUG_WINBORDER_CLICK
|
2003-09-09 02:09:10 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE_CLICK(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE_CLICK(x) ;
|
2003-04-05 05:51:35 +04:00
|
|
|
#endif
|
|
|
|
|
2003-09-09 02:09:10 +04:00
|
|
|
//! TokenHandler object used to provide IDs for all WinBorder objects
|
2004-06-11 06:46:48 +04:00
|
|
|
TokenHandler border_token_handler;
|
|
|
|
|
|
|
|
bool gMouseDown = false;
|
2003-02-14 04:53:53 +03:00
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
|
2004-02-24 14:56:03 +03:00
|
|
|
const int32 flags, ServerWindow *win, DisplayDriver *driver)
|
|
|
|
: Layer(r, name, B_NULL_TOKEN, B_FOLLOW_NONE, flags, driver)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-02-24 14:56:03 +03:00
|
|
|
// unlike BViews, windows start off as hidden
|
2004-06-11 22:21:57 +04:00
|
|
|
fHidden = true;
|
|
|
|
fServerWin = win;
|
2004-02-24 14:56:03 +03:00
|
|
|
|
|
|
|
fMouseButtons = 0;
|
|
|
|
fKeyModifiers = 0;
|
|
|
|
fMainWinBorder = NULL;
|
|
|
|
fDecorator = NULL;
|
2004-06-16 10:40:26 +04:00
|
|
|
fAdFlags = fAdFlags | B_LAYER_CHILDREN_DEPENDANT;
|
2004-06-18 19:24:36 +04:00
|
|
|
fFlags = B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE;
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsMoving = false;
|
|
|
|
fIsResizing = false;
|
|
|
|
fIsClosing = false;
|
|
|
|
fIsMinimizing = false;
|
|
|
|
fIsZooming = false;
|
|
|
|
|
2003-11-15 03:29:14 +03:00
|
|
|
fLastMousePosition.Set(-1,-1);
|
2004-01-13 03:38:42 +03:00
|
|
|
SetLevel();
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2004-06-11 06:46:48 +04:00
|
|
|
if (feel!= B_NO_BORDER_WINDOW_LOOK)
|
|
|
|
fDecorator = new_decorator(r, name, look, feel, flags, fDriver);
|
2004-03-28 18:58:39 +04:00
|
|
|
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder %s:\n",GetName()));
|
|
|
|
STRACE(("\tFrame: (%.1f,%.1f,%.1f,%.1f)\n",r.left,r.top,r.right,r.bottom));
|
|
|
|
STRACE(("\tWindow %s\n",win?win->Title():"NULL"));
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2003-02-14 04:53:53 +03:00
|
|
|
WinBorder::~WinBorder(void)
|
|
|
|
{
|
2004-06-18 15:50:17 +04:00
|
|
|
STRACE(("WinBorder(%s)::~WinBorder()\n",GetName()));
|
2004-06-11 06:46:48 +04:00
|
|
|
if (fDecorator)
|
|
|
|
{
|
2004-02-24 14:56:03 +03:00
|
|
|
delete fDecorator;
|
2004-06-11 06:46:48 +04:00
|
|
|
fDecorator = NULL;
|
2003-11-14 03:15:29 +03:00
|
|
|
}
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::RebuildFullRegion(void)
|
|
|
|
{
|
2004-06-18 15:50:17 +04:00
|
|
|
STRACE(("WinBorder(%s)::RebuildFullRegion()\n",GetName()));
|
2004-03-28 18:58:39 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
fFull.MakeEmpty();
|
2004-03-28 18:58:39 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// Winborder holds Decorator's full regions. if any...
|
2004-06-11 06:46:48 +04:00
|
|
|
if (fDecorator)
|
2004-06-16 10:40:26 +04:00
|
|
|
fDecorator->GetFootprint(&fFull);
|
2004-03-28 18:58:39 +04:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::MouseDown(PortMessage *msg)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
// this is important to determine how much we should resize or move the Layer(WinBorder)(window)
|
|
|
|
|
|
|
|
// user clicked on WinBorder's visible region, which is in fact decorator's.
|
|
|
|
// so, if true, we find out if the user clicked the decorator.
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// Attached data:
|
|
|
|
// 1) int64 - time of mouse click
|
|
|
|
// 2) float - x coordinate of mouse click
|
|
|
|
// 3) float - y coordinate of mouse click
|
|
|
|
// 4) int32 - modifier keys down
|
|
|
|
// 5) int32 - buttons down
|
|
|
|
// 6) int32 - clicks
|
|
|
|
|
|
|
|
int64 time;
|
|
|
|
BPoint pt;
|
|
|
|
int32 modifierkeys;
|
|
|
|
int32 buttons;
|
|
|
|
int32 clicks;
|
|
|
|
|
|
|
|
msg->Read<int64>(&time);
|
|
|
|
msg->Read<float>(&pt.x);
|
|
|
|
msg->Read<float>(&pt.y);
|
|
|
|
msg->Read<int32>(&modifierkeys);
|
|
|
|
msg->Read<int32>(&buttons);
|
|
|
|
msg->Read<int32>(&clicks);
|
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
Layer *target = LayerAt(pt);
|
2004-06-11 06:46:48 +04:00
|
|
|
if (target == this)
|
|
|
|
{
|
|
|
|
click_type action;
|
|
|
|
|
2004-04-05 00:30:20 +04:00
|
|
|
// find out where user clicked in Decorator
|
2004-06-11 06:46:48 +04:00
|
|
|
action = fDecorator->Clicked(pt, buttons, modifierkeys);
|
|
|
|
switch(action)
|
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
case DEC_CLOSE:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsClosing = true;
|
2004-06-11 06:46:48 +04:00
|
|
|
fDecorator->SetClose(true);
|
|
|
|
fDecorator->DrawClose();
|
|
|
|
STRACE_CLICK(("===> DEC_CLOSE\n"));
|
2004-04-05 00:30:20 +04:00
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
case DEC_ZOOM:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsZooming = true;
|
2004-06-11 06:46:48 +04:00
|
|
|
fDecorator->SetZoom(true);
|
|
|
|
fDecorator->DrawZoom();
|
|
|
|
STRACE_CLICK(("===> DEC_ZOOM\n"));
|
2004-04-05 00:30:20 +04:00
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-06-15 00:32:21 +04:00
|
|
|
case DEC_MINIMIZE:
|
|
|
|
{
|
|
|
|
fIsMinimizing = true;
|
|
|
|
fDecorator->SetMinimize(true);
|
|
|
|
fDecorator->DrawMinimize();
|
|
|
|
STRACE_CLICK(("===> DEC_MINIMIZE\n"));
|
|
|
|
break;
|
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
case DEC_RESIZE:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsResizing = true;
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE_CLICK(("===> DEC_RESIZE\n"));
|
2004-04-05 00:30:20 +04:00
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
case DEC_DRAG:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsMoving = true;
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE_CLICK(("===> DEC_DRAG\n"));
|
2004-04-05 00:30:20 +04:00
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
case DEC_MOVETOBACK:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
GetRootLayer()->ActiveWorkspace()->MoveToBack(this);
|
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
case DEC_NONE:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
debugger("WinBorder::MouseDown - Decorator should NOT return DEC_NONE\n");
|
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
default:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
debugger("WinBorder::MouseDown - Decorator returned UNKNOWN code\n");
|
|
|
|
break;
|
2004-06-11 06:46:48 +04:00
|
|
|
}
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
BMessage msg;
|
|
|
|
msg.what= B_MOUSE_DOWN;
|
|
|
|
msg.AddInt64("when", time);
|
|
|
|
msg.AddPoint("where", pt);
|
|
|
|
msg.AddInt32("modifiers", modifierkeys);
|
|
|
|
msg.AddInt32("buttons", buttons);
|
|
|
|
msg.AddInt32("clicks", clicks);
|
2004-04-05 00:30:20 +04:00
|
|
|
|
2004-06-11 06:46:48 +04:00
|
|
|
// TODO: figure out how to specify the target
|
|
|
|
// msg.AddInt32("token", token);
|
|
|
|
Window()->SendMessageToClient(&msg);
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
|
|
|
|
2004-06-11 06:46:48 +04:00
|
|
|
// Just to clean up any mess we've made. :)
|
|
|
|
msg->Rewind();
|
|
|
|
|
|
|
|
fLastMousePosition = pt;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::MouseMoved(PortMessage *msg)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
BPoint pt;
|
|
|
|
int64 dummy;
|
|
|
|
int32 buttons;
|
|
|
|
|
|
|
|
msg->Read<int64>(&dummy);
|
|
|
|
msg->Read<float>(&pt.x);
|
|
|
|
msg->Read<float>(&pt.y);
|
|
|
|
msg->Read<int32>(&buttons);
|
|
|
|
msg->Rewind();
|
|
|
|
|
|
|
|
if (fIsMoving)
|
|
|
|
{
|
|
|
|
STRACE_CLICK(("===> Moving...\n"));
|
2004-04-05 00:30:20 +04:00
|
|
|
BPoint offset = pt;
|
|
|
|
offset -= fLastMousePosition;
|
|
|
|
MoveBy(offset.x, offset.y);
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
|
|
|
if (fIsResizing)
|
|
|
|
{
|
|
|
|
STRACE_CLICK(("===> Resizing...\n"));
|
2004-04-05 00:30:20 +04:00
|
|
|
BPoint offset = pt;
|
|
|
|
offset -= fLastMousePosition;
|
|
|
|
ResizeBy(offset.x, offset.y);
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Do a click test only if we have to, which would be now. :)
|
|
|
|
click_type location=fDecorator->Clicked(pt,buttons,fKeyModifiers);
|
|
|
|
|
|
|
|
if (fIsZooming && location!=DEC_ZOOM)
|
|
|
|
{
|
|
|
|
fDecorator->SetZoom(false);
|
|
|
|
fDecorator->DrawZoom();
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
|
|
|
if (fIsClosing && location!=DEC_CLOSE)
|
|
|
|
{
|
|
|
|
fDecorator->SetClose(false);
|
|
|
|
fDecorator->DrawClose();
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
|
|
|
if(fIsMinimizing && location!=DEC_MINIMIZE)
|
|
|
|
{
|
|
|
|
fDecorator->SetMinimize(false);
|
|
|
|
fDecorator->DrawMinimize();
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
fLastMousePosition = pt;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::MouseUp(PortMessage *msg)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
if (fIsMoving)
|
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsMoving = false;
|
|
|
|
return;
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
if (fIsResizing)
|
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsResizing = false;
|
|
|
|
return;
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
if (fIsZooming)
|
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsZooming = false;
|
2004-06-11 06:46:48 +04:00
|
|
|
fDecorator->SetZoom(false);
|
|
|
|
fDecorator->DrawZoom();
|
2004-06-15 00:32:21 +04:00
|
|
|
Window()->Zoom();
|
2004-04-05 00:30:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
if (fIsClosing)
|
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsClosing = false;
|
2004-06-11 06:46:48 +04:00
|
|
|
fDecorator->SetClose(false);
|
|
|
|
fDecorator->DrawClose();
|
2004-06-15 00:32:21 +04:00
|
|
|
Window()->Quit();
|
2004-06-11 06:46:48 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(fIsMinimizing)
|
|
|
|
{
|
|
|
|
fIsMinimizing = false;
|
|
|
|
fDecorator->SetMinimize(false);
|
|
|
|
fDecorator->DrawMinimize();
|
2004-06-15 00:32:21 +04:00
|
|
|
Window()->Minimize(true);
|
2004-04-05 00:30:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-02-24 14:56:03 +03:00
|
|
|
void WinBorder::HighlightDecorator(const bool &active)
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
2004-02-24 14:56:03 +03:00
|
|
|
fDecorator->SetFocus(active);
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2003-11-14 03:15:29 +03:00
|
|
|
void WinBorder::Draw(const BRect &r)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder(%s)::Draw()\n", GetName()));
|
2004-06-18 19:24:36 +04:00
|
|
|
|
2004-06-16 10:40:26 +04:00
|
|
|
// if we have a visible region, it is decorator's one.
|
2004-06-11 06:46:48 +04:00
|
|
|
if(fDecorator)
|
|
|
|
{
|
2004-06-16 10:40:26 +04:00
|
|
|
/*
|
2004-06-18 23:13:06 +04:00
|
|
|
//fUpdateReg.PrintToStream();
|
2004-06-11 06:46:48 +04:00
|
|
|
RGBColor c(128, 56, 98);
|
|
|
|
//fDriver->FillRect(r, c);
|
|
|
|
fDriver->FillRect(fUpdateReg.Frame(), c);
|
|
|
|
snooze(1000000);
|
|
|
|
*/
|
2004-05-16 23:27:59 +04:00
|
|
|
fDecorator->Draw(fUpdateReg.Frame());
|
2004-03-28 18:58:39 +04:00
|
|
|
}
|
2004-06-17 18:39:21 +04:00
|
|
|
// clear background, *only IF* our view color is different to B_TRANSPARENT_COLOR!
|
|
|
|
// TODO: DO That!
|
|
|
|
// TODO: UNcomment!!!
|
|
|
|
// TODO !!! UPDATE code !!!
|
|
|
|
/*
|
|
|
|
BMessage msg;
|
|
|
|
msg.what = _UPDATE_;
|
|
|
|
msg.AddInt32("_token", fViewToken);
|
|
|
|
msg.AddRect("_rect", ConvertFromTop(reg.Frame()) );
|
|
|
|
|
|
|
|
// for test purposes only!
|
|
|
|
msg.AddRect("_rect2", reg.Frame());
|
|
|
|
|
|
|
|
fServerWin->SendMessageToClient( &msg );
|
|
|
|
*/
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2003-02-14 04:53:53 +03:00
|
|
|
void WinBorder::MoveBy(float x, float y)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
|
|
|
|
if(fDecorator)
|
2004-03-28 18:58:39 +04:00
|
|
|
fDecorator->MoveBy(x,y);
|
2004-06-16 10:40:26 +04:00
|
|
|
// TODO: Repair! :-))
|
2004-03-28 18:58:39 +04:00
|
|
|
Layer::MoveBy(x,y);
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2003-02-14 04:53:53 +03:00
|
|
|
void WinBorder::ResizeBy(float x, float y)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
|
|
|
if(fDecorator)
|
2004-03-28 18:58:39 +04:00
|
|
|
fDecorator->ResizeBy(x,y);
|
2004-06-16 10:40:26 +04:00
|
|
|
// TODO: Repair! :-))
|
2004-03-28 18:58:39 +04:00
|
|
|
Layer::ResizeBy(x,y);
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
bool WinBorder::HasPoint(BPoint& pt) const
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
return fFullVisible.Contains(pt);
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::SetMainWinBorder(WinBorder *newMain)
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
fMainWinBorder = newMain;
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-01-13 03:38:42 +03:00
|
|
|
WinBorder* WinBorder::MainWinBorder() const{
|
|
|
|
return fMainWinBorder;
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::SetLevel()
|
|
|
|
{
|
2004-06-11 22:21:57 +04:00
|
|
|
switch(fServerWin->Feel())
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
case B_NORMAL_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_NORMAL_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_FLOATING_SUBSET_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_FLOATING_APP_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_FLOATING_APP_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_FLOATING_ALL_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_FLOATING_ALL_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_MODAL_SUBSET_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_MODAL_APP_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_MODAL_APP_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_MODAL_ALL_WINDOW_FEEL:
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = B_MODAL_ALL_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
case B_SYSTEM_LAST:
|
|
|
|
case B_SYSTEM_FIRST:
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// TODO: uncomment later when this code makes its way into the real server!
|
2004-01-13 03:38:42 +03:00
|
|
|
// if(_win->ServerTeamID() != _win->ClientTeamID())
|
|
|
|
// _win->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
|
|
|
// else
|
2004-06-11 22:21:57 +04:00
|
|
|
fLevel = fServerWin->Feel();
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
default:
|
2004-06-11 22:21:57 +04:00
|
|
|
fServerWin->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
|
|
|
fLevel = B_NORMAL_FEEL;
|
2004-01-13 03:38:42 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::AddToSubsetOf(WinBorder* main)
|
|
|
|
{
|
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf()\n", GetName()));
|
2004-01-13 03:38:42 +03:00
|
|
|
if (!main || (main && !(main->GetRootLayer())))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (main->Window()->fWinFMWList.HasItem(this) || !(desktop->HasWinBorder(this)))
|
|
|
|
return;
|
2003-11-14 03:15:29 +03:00
|
|
|
|
2004-06-11 06:46:48 +04:00
|
|
|
if (main->Window()->Feel() == B_NORMAL_WINDOW_FEEL &&
|
|
|
|
(Window()->Feel()==B_FLOATING_SUBSET_WINDOW_FEEL || Window()->Feel()==B_MODAL_SUBSET_WINDOW_FEEL) )
|
2004-01-13 03:38:42 +03:00
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
// if the main window is hidden also hide this one.
|
2004-01-13 03:38:42 +03:00
|
|
|
if(main->IsHidden())
|
2004-06-11 22:21:57 +04:00
|
|
|
fHidden = true;
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// add to main window's subset
|
2004-01-13 03:38:42 +03:00
|
|
|
main->Window()->fWinFMWList.AddItem(this);
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// set this member accordingly
|
2004-01-13 03:38:42 +03:00
|
|
|
fMainWinBorder = main;
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// because this window is in a subset it should appear in the
|
|
|
|
// workspaces its main window appears in.
|
2004-01-13 03:38:42 +03:00
|
|
|
Window()->QuietlySetWorkspaces(main->Window()->Workspaces());
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// this is a modal window, so add it to main window's workspaces.
|
|
|
|
if (Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
|
|
|
{
|
2004-01-14 03:26:15 +03:00
|
|
|
RootLayer *rl = main->GetRootLayer();
|
|
|
|
rl->fMainLock.Lock();
|
|
|
|
rl->AddWinBorderToWorkspaces(this, main->Window()->Workspaces());
|
|
|
|
rl->fMainLock.Unlock();
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// this a *floating* window so if the main window is 'front', and add it to workspace.
|
|
|
|
if ( !(main->IsHidden()) && Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
|
|
|
|
{
|
2004-01-14 03:26:15 +03:00
|
|
|
RootLayer *rl = main->GetRootLayer();
|
|
|
|
|
|
|
|
desktop->fGeneralLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - General lock acquired\n", GetName(), main->GetName()));
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-01-14 03:26:15 +03:00
|
|
|
rl->fMainLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - Main lock acquired\n", GetName(), main->GetName()));
|
2004-01-14 18:55:10 +03:00
|
|
|
|
2004-06-11 06:46:48 +04:00
|
|
|
for(int32 i = 0; i < rl->WorkspaceCount(); i++)
|
|
|
|
{
|
2004-01-14 03:26:15 +03:00
|
|
|
Workspace *ws = rl->WorkspaceAt(i+1);
|
2004-01-14 18:55:10 +03:00
|
|
|
if(ws->FrontLayer() == main)
|
2004-01-13 03:38:42 +03:00
|
|
|
ws->AddLayerPtr(this);
|
|
|
|
}
|
2004-01-14 18:55:10 +03:00
|
|
|
|
|
|
|
rl->fMainLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - Main lock released\n", GetName(), main->GetName()));
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-01-14 18:55:10 +03:00
|
|
|
desktop->fGeneralLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::AddToSubsetOf(%s) - General lock released\n", GetName(), main->GetName()));
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::RemoveFromSubsetOf(WinBorder* main)
|
|
|
|
{
|
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf()\n", GetName()));
|
2004-01-17 19:33:22 +03:00
|
|
|
RootLayer *rl = main->GetRootLayer();
|
|
|
|
|
|
|
|
desktop->fGeneralLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock acquired\n", GetName(), main->GetName()));
|
2004-01-17 19:33:22 +03:00
|
|
|
rl->fMainLock.Lock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock acquired\n", GetName(), main->GetName()));
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// remove from main window's subset list.
|
|
|
|
if(main->Window()->fWinFMWList.RemoveItem(this))
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
int32 count = main->GetRootLayer()->WorkspaceCount();
|
2004-06-11 06:46:48 +04:00
|
|
|
for(int32 i=0; i < count; i++)
|
|
|
|
{
|
|
|
|
if(main->Window()->Workspaces() & (0x00000001 << i))
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
Workspace *ws = main->GetRootLayer()->WorkspaceAt(i+1);
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
// if its main window is in 'i' workspaces, remove it from
|
|
|
|
// workspace 'i' if it's in there...
|
2004-01-13 03:38:42 +03:00
|
|
|
ws->RemoveLayerPtr(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fMainWinBorder = NULL;
|
2004-01-17 19:33:22 +03:00
|
|
|
|
|
|
|
rl->fMainLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - Main lock released\n", GetName(), main->GetName()));
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-01-17 19:33:22 +03:00
|
|
|
desktop->fGeneralLock.Unlock();
|
2004-01-21 05:58:39 +03:00
|
|
|
STRACE(("WinBorder(%s)::RemoveFromSubsetOf(%s) - General lock released\n", GetName(), main->GetName()));
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
|
|
|
void WinBorder::PrintToStream()
|
|
|
|
{
|
2004-01-13 03:38:42 +03:00
|
|
|
printf("\t%s", GetName());
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_FLOATING_SUBSET_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_FLOATING_SUBSET_WINDOW_FEEL");
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_FLOATING_APP_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_FLOATING_APP_WINDOW_FEEL");
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_FLOATING_ALL_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_FLOATING_ALL_WINDOW_FEEL");
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_MODAL_SUBSET_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_MODAL_SUBSET_WINDOW_FEEL");
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_MODAL_APP_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_MODAL_APP_WINDOW_FEEL");
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_MODAL_ALL_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_MODAL_ALL_WINDOW_FEEL");
|
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
if (fLevel == B_NORMAL_FEEL)
|
2004-06-11 06:46:48 +04:00
|
|
|
printf("\t%s", "B_NORMAL_WINDOW_FEEL");
|
2004-01-13 03:38:42 +03:00
|
|
|
|
2004-06-11 22:21:57 +04:00
|
|
|
printf("\t%s\n", fHidden?"hidden" : "not hidden");
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2003-02-24 18:47:06 +03:00
|
|
|
void WinBorder::UpdateColors(void)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder %s: UpdateColors unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::UpdateDecorator(void)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder %s: UpdateDecorator unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::UpdateFont(void)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder %s: UpdateFont unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::UpdateScreen(void)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder %s: UpdateScreen unimplemented\n",GetName()));
|
2003-02-24 18:47:06 +03:00
|
|
|
}
|