2003-02-15 18:28:22 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2005-02-04 00:31:42 +03:00
|
|
|
// Copyright (c) 2001-2005, Haiku, Inc.
|
2003-02-15 18:28:22 +03:00
|
|
|
//
|
|
|
|
// 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>
|
2005-02-04 00:31:42 +03:00
|
|
|
// Adi Oanca <adioanca@cotty.iren.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>
|
2004-07-30 19:16:59 +04:00
|
|
|
#include "PortLink.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "View.h" // for mouse button defines
|
2005-02-07 03:45:59 +03:00
|
|
|
#include "MessagePrivate.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
#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-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-07-05 19:23:29 +04:00
|
|
|
fClassID = AS_WINBORDER_CLASS;
|
2004-02-24 14:56:03 +03:00
|
|
|
|
|
|
|
fMouseButtons = 0;
|
|
|
|
fKeyModifiers = 0;
|
|
|
|
fDecorator = NULL;
|
2004-06-21 00:02:32 +04:00
|
|
|
fTopLayer = 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
|
|
|
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
|
|
|
|
2005-02-28 23:23:51 +03:00
|
|
|
RebuildFullRegion();
|
|
|
|
|
|
|
|
desktop->AddWinBorder(this);
|
|
|
|
|
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()));
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
desktop->RemoveWinBorder(this);
|
|
|
|
|
2004-06-21 00:02:32 +04:00
|
|
|
if (fTopLayer){
|
|
|
|
delete fTopLayer;
|
|
|
|
fTopLayer = NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Rebuilds the WinBorder's "fully-visible" region based on info from the decorator
|
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
|
|
|
|
2005-03-11 00:34:04 +03:00
|
|
|
click_type WinBorder::TellWhat(PointerEvent& evt) const
|
|
|
|
{
|
|
|
|
if (fTopLayer->fFullVisible.Contains(evt.where))
|
|
|
|
return DEC_NONE;
|
|
|
|
else if (fDecorator)
|
|
|
|
return fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
|
|
|
|
else
|
|
|
|
return DEC_NONE;
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\brief Handles B_MOUSE_DOWN events and takes appropriate actions
|
|
|
|
\param evt PointerEvent object containing the info from the last B_MOUSE_DOWN message
|
|
|
|
\param sendMessage flag to send a B_MOUSE_DOWN message to the client
|
|
|
|
|
|
|
|
This function searches to see if the B_MOUSE_DOWN message is being sent to the window tab
|
|
|
|
or frame. If it is not, the message is passed on to the appropriate view in the client
|
|
|
|
BWindow. If the WinBorder is the target, then the proper action flag is set.
|
|
|
|
*/
|
2004-07-30 19:16:59 +04:00
|
|
|
void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-19 17:04:50 +04:00
|
|
|
if (!(Window()->IsLocked()))
|
|
|
|
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseDown()\n");
|
|
|
|
|
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
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
Layer *target = LayerAt(evt.where);
|
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-07-30 19:16:59 +04:00
|
|
|
action = fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
|
2004-06-11 06:46:48 +04:00
|
|
|
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:
|
|
|
|
case DEC_DRAG:
|
|
|
|
case DEC_MOVETOBACK:
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2005-03-11 00:34:04 +03:00
|
|
|
// do nothing - RootLayer takes care of that
|
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_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
|
|
|
}
|
|
|
|
}
|
2005-02-04 01:50:48 +03:00
|
|
|
else if (sendMessage && target && target != fTopLayer)
|
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
BMessage msg;
|
2005-02-04 00:31:42 +03:00
|
|
|
msg.what = B_MOUSE_DOWN;
|
2004-07-30 19:16:59 +04:00
|
|
|
msg.AddInt64("when", evt.when);
|
|
|
|
msg.AddPoint("where", evt.where);
|
|
|
|
msg.AddInt32("modifiers", evt.modifiers);
|
|
|
|
msg.AddInt32("buttons", evt.buttons);
|
|
|
|
msg.AddInt32("clicks", evt.clicks);
|
2005-02-04 00:31:42 +03:00
|
|
|
|
2005-02-07 03:45:59 +03:00
|
|
|
Window()->SendMessageToClient(&msg, target->fViewToken, false);
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
fLastMousePosition = evt.where;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\brief Handles B_MOUSE_MOVED events and takes appropriate actions
|
|
|
|
\param evt PointerEvent object containing the info from the last B_MOUSE_MOVED message
|
|
|
|
|
|
|
|
This function doesn't do much except test continue any move/resize operations in progress
|
|
|
|
or check to see if the user clicked on a tab button (close, zoom, etc.) and then moused
|
|
|
|
away to prevent the operation from occurring
|
|
|
|
*/
|
2004-07-30 19:16:59 +04:00
|
|
|
void WinBorder::MouseMoved(PointerEvent& evt)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-19 17:04:50 +04:00
|
|
|
if (!(Window()->IsLocked()))
|
|
|
|
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseMoved()\n");
|
|
|
|
|
2005-03-11 00:34:04 +03:00
|
|
|
// Do a click test only if we have to, which would be now. :)
|
|
|
|
click_type location=fDecorator->Clicked(evt.where, evt.buttons,fKeyModifiers);
|
|
|
|
|
|
|
|
if (fIsZooming && location!=DEC_ZOOM)
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2005-03-11 00:34:04 +03:00
|
|
|
fDecorator->SetZoom(false);
|
|
|
|
fDecorator->DrawZoom();
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
2005-03-11 00:34:04 +03:00
|
|
|
if (fIsClosing && location!=DEC_CLOSE)
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2005-03-11 00:34:04 +03:00
|
|
|
fDecorator->SetClose(false);
|
|
|
|
fDecorator->DrawClose();
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
else
|
2005-03-11 00:34:04 +03:00
|
|
|
if(fIsMinimizing && location!=DEC_MINIMIZE)
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2005-03-11 00:34:04 +03:00
|
|
|
fDecorator->SetMinimize(false);
|
|
|
|
fDecorator->DrawMinimize();
|
2004-04-05 00:30:20 +04:00
|
|
|
}
|
2005-01-20 21:39:08 +03:00
|
|
|
|
|
|
|
if (fTopLayer->fFullVisible.Contains(evt.where))
|
|
|
|
{
|
|
|
|
BMessage movemsg(B_MOUSE_MOVED);
|
|
|
|
movemsg.AddInt64("when",evt.when);
|
|
|
|
movemsg.AddPoint("where",evt.where);
|
|
|
|
movemsg.AddInt32("buttons",evt.buttons);
|
|
|
|
|
|
|
|
Window()->SendMessageToClient(&movemsg);
|
|
|
|
}
|
|
|
|
|
2004-07-30 19:16:59 +04:00
|
|
|
fLastMousePosition = evt.where;
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
/*!
|
|
|
|
\brief Handles B_MOUSE_UP events and takes appropriate actions
|
|
|
|
\param evt PointerEvent object containing the info from the last B_MOUSE_UP message
|
|
|
|
|
|
|
|
This function resets any state objects (is_resizing flag and such) and if resetting a
|
|
|
|
button click flag, takes the appropriate action (i.e. clearing the close button flag also
|
|
|
|
takes steps to close the window).
|
|
|
|
*/
|
2004-07-30 19:16:59 +04:00
|
|
|
void WinBorder::MouseUp(PointerEvent& evt)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-19 17:04:50 +04:00
|
|
|
if (!(Window()->IsLocked()))
|
|
|
|
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseUp()\n");
|
|
|
|
|
2004-11-24 23:07:41 +03:00
|
|
|
click_type action;
|
|
|
|
|
|
|
|
// find out where user clicked in Decorator
|
|
|
|
action = fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
|
|
|
|
|
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-11-24 23:07:41 +03:00
|
|
|
|
|
|
|
if(action==DEC_ZOOM)
|
|
|
|
Window()->Zoom();
|
2004-04-05 00:30:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2004-11-24 23:07:41 +03:00
|
|
|
if(fIsClosing)
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2004-04-05 00:30:20 +04:00
|
|
|
fIsClosing = false;
|
2004-06-11 06:46:48 +04:00
|
|
|
fDecorator->SetClose(false);
|
|
|
|
fDecorator->DrawClose();
|
2004-11-24 23:07:41 +03:00
|
|
|
if(action==DEC_CLOSE)
|
|
|
|
Window()->Quit();
|
2004-06-11 06:46:48 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(fIsMinimizing)
|
|
|
|
{
|
|
|
|
fIsMinimizing = false;
|
|
|
|
fDecorator->SetMinimize(false);
|
|
|
|
fDecorator->DrawMinimize();
|
2004-11-24 23:07:41 +03:00
|
|
|
if(action==DEC_MINIMIZE)
|
|
|
|
Window()->Minimize(true);
|
2004-04-05 00:30:20 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-01-20 21:39:08 +03:00
|
|
|
|
2005-02-04 01:50:48 +03:00
|
|
|
Layer *target = LayerAt(evt.where);
|
|
|
|
if (target && target != fTopLayer)
|
2005-01-20 21:39:08 +03:00
|
|
|
{
|
|
|
|
BMessage upmsg(B_MOUSE_UP);
|
|
|
|
upmsg.AddInt64("when",evt.when);
|
|
|
|
upmsg.AddPoint("where",evt.where);
|
|
|
|
upmsg.AddInt32("modifiers",evt.modifiers);
|
2005-02-04 01:50:48 +03:00
|
|
|
|
2005-02-07 03:45:59 +03:00
|
|
|
Window()->SendMessageToClient(&upmsg, target->fViewToken, false);
|
2005-01-20 21:39:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::MouseWheel(PointerEvent& evt, BPoint& ptWhere)
|
|
|
|
{
|
|
|
|
if (fTopLayer->fFullVisible.Contains(ptWhere))
|
|
|
|
{
|
|
|
|
BMessage wheelmsg(B_MOUSE_WHEEL_CHANGED);
|
|
|
|
wheelmsg.AddInt64("when",evt.when);
|
|
|
|
wheelmsg.AddFloat("be:wheel_delta_x",evt.wheel_delta_x);
|
|
|
|
wheelmsg.AddFloat("be:wheel_delta_y",evt.wheel_delta_y);
|
|
|
|
|
|
|
|
Window()->SendMessageToClient(&wheelmsg);
|
|
|
|
}
|
2004-01-13 03:38:42 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Sets the decorator focus to active or inactive colors
|
2004-02-24 14:56:03 +03:00
|
|
|
void WinBorder::HighlightDecorator(const bool &active)
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
STRACE(("Decorator->Highlight\n"));
|
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
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! redraws a certain section of the window border
|
2003-11-14 03:15:29 +03:00
|
|
|
void WinBorder::Draw(const BRect &r)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-26 06:15:48 +04:00
|
|
|
#ifdef DEBUG_WINBORDER
|
2004-08-03 19:17:44 +04:00
|
|
|
printf("WinBorder(%s)::Draw() : ", GetName());
|
2004-06-26 06:15:48 +04:00
|
|
|
r.PrintToStream();
|
|
|
|
#endif
|
|
|
|
|
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)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
|
|
|
WinBorder *wb = GetRootLayer()->FocusWinBorder();
|
|
|
|
if (wb && wb == this)
|
|
|
|
fDecorator->SetFocus(true);
|
|
|
|
else
|
|
|
|
fDecorator->SetFocus(false);
|
2004-05-16 23:27:59 +04:00
|
|
|
fDecorator->Draw(fUpdateReg.Frame());
|
2005-02-28 23:23:51 +03:00
|
|
|
}
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Moves the winborder with redraw
|
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-19 17:04:50 +04:00
|
|
|
|
2005-01-23 02:25:41 +03:00
|
|
|
move_layer(x,y);
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Resizes the winborder with redraw
|
2003-02-14 04:53:53 +03:00
|
|
|
void WinBorder::ResizeBy(float x, float y)
|
|
|
|
{
|
2004-09-09 04:54:21 +04:00
|
|
|
// TODO: account for size limits
|
|
|
|
|
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-19 17:04:50 +04:00
|
|
|
|
2005-01-23 02:25:41 +03:00
|
|
|
resize_layer(x,y);
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Sets the minimum and maximum sizes of the window
|
2004-08-08 00:30:58 +04:00
|
|
|
void WinBorder::SetSizeLimits(float minwidth, float maxwidth, float minheight, float maxheight)
|
|
|
|
{
|
|
|
|
if(minwidth<0)
|
|
|
|
minwidth=0;
|
|
|
|
|
|
|
|
if(minheight<0)
|
|
|
|
minheight=0;
|
|
|
|
|
|
|
|
if(maxwidth<=minwidth)
|
|
|
|
maxwidth=minwidth+1;
|
|
|
|
|
|
|
|
if(maxheight<=minheight)
|
|
|
|
maxheight=minheight+1;
|
|
|
|
|
|
|
|
fMinWidth=minwidth;
|
|
|
|
fMaxWidth=maxwidth;
|
|
|
|
fMinHeight=minheight;
|
|
|
|
fMaxHeight=maxheight;
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Returns true if the point is in the WinBorder's screen area
|
2004-08-03 19:17:44 +04:00
|
|
|
bool WinBorder::HasPoint(const BPoint& pt) const
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
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
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// Unimplemented. Hook function for handling when system GUI colors change
|
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
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// Unimplemented. Hook function for handling when the system decorator changes
|
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
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// Unimplemented. Hook function for handling when a system font changes
|
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
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
// Unimplemented. Hook function for handling when the screen resolution changes
|
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
|
|
|
}
|
2005-02-28 23:23:51 +03:00
|
|
|
|
|
|
|
//--------------------- P R I V A T E -------------------
|
|
|
|
void WinBorder::SetLevel()
|
|
|
|
{
|
|
|
|
switch(fServerWin->Feel())
|
|
|
|
{
|
|
|
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
|
|
|
case B_FLOATING_APP_WINDOW_FEEL:
|
|
|
|
fLevel = B_FLOATING_APP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
|
|
|
case B_MODAL_APP_WINDOW_FEEL:
|
|
|
|
fLevel = B_MODAL_APP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_NORMAL_WINDOW_FEEL:
|
|
|
|
fLevel = B_NORMAL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_FLOATING_ALL_WINDOW_FEEL:
|
|
|
|
fLevel = B_FLOATING_ALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_MODAL_ALL_WINDOW_FEEL:
|
|
|
|
fLevel = B_MODAL_ALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_SYSTEM_LAST:
|
|
|
|
fLevel = B_SYSTEM_LAST;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
fLevel = B_SYSTEM_FIRST;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
fLevel = B_NORMAL;
|
|
|
|
}
|
|
|
|
}
|