2005-06-17 23:10:15 +04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2001-2005, Haiku, Inc.
|
|
|
|
* Distributed under the terms of the MIT license.
|
|
|
|
*
|
|
|
|
* Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
* Adi Oanca <adioanca@cotty.iren.ro>
|
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
|
|
|
*/
|
2005-06-24 02:43:11 +04:00
|
|
|
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
#include <Locker.h>
|
2003-02-14 04:53:53 +03:00
|
|
|
#include <Region.h>
|
|
|
|
#include <String.h>
|
2005-06-03 23:50:30 +04:00
|
|
|
#include <View.h> // for mouse button defines
|
|
|
|
|
2003-02-14 04:53:53 +03:00
|
|
|
#include <Debug.h>
|
2005-06-03 23:50:30 +04:00
|
|
|
#include "DebugInfoManager.h"
|
|
|
|
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "Decorator.h"
|
2005-06-17 23:10:15 +04:00
|
|
|
#include "DecorManager.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
#include "Desktop.h"
|
2004-01-13 03:38:42 +03:00
|
|
|
#include "Globals.h"
|
2005-06-03 23:50:30 +04:00
|
|
|
#include "MessagePrivate.h"
|
|
|
|
#include "PortLink.h"
|
2004-01-13 03:38:42 +03:00
|
|
|
#include "RootLayer.h"
|
2005-06-03 23:50:30 +04:00
|
|
|
#include "ServerWindow.h"
|
|
|
|
#include "TokenHandler.h"
|
2004-01-13 03:38:42 +03:00
|
|
|
#include "Workspace.h"
|
2003-02-14 04:53:53 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
#include "WinBorder.h"
|
|
|
|
|
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
|
|
|
|
|
2005-06-27 06:06:15 +04:00
|
|
|
WinBorder::WinBorder(const BRect &frame,
|
2005-06-03 23:50:30 +04:00
|
|
|
const char *name,
|
|
|
|
const uint32 wlook,
|
|
|
|
const uint32 wfeel,
|
|
|
|
const uint32 wflags,
|
|
|
|
const uint32 wwksindex,
|
|
|
|
ServerWindow *win,
|
|
|
|
DisplayDriver *driver)
|
2005-06-27 06:06:15 +04:00
|
|
|
: Layer(frame, name, B_NULL_TOKEN, B_FOLLOW_NONE, 0UL, driver),
|
2005-06-03 23:50:30 +04:00
|
|
|
fDecorator(NULL),
|
|
|
|
fTopLayer(NULL),
|
|
|
|
|
2005-06-25 17:09:19 +04:00
|
|
|
fCumulativeRegion(),
|
|
|
|
fInUpdateRegion(),
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fMouseButtons(0),
|
|
|
|
fKeyModifiers(0),
|
|
|
|
fLastMousePosition(-1.0, -1.0),
|
2003-02-14 04:53:53 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fIsClosing(false),
|
|
|
|
fIsMinimizing(false),
|
|
|
|
fIsZooming(false),
|
2004-04-05 00:30:20 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fIsDragging(false),
|
|
|
|
fBringToFrontOnRelease(false),
|
|
|
|
|
|
|
|
fIsResizing(false),
|
|
|
|
|
2005-06-16 16:32:42 +04:00
|
|
|
fIsSlidingTab(false),
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
fInUpdate(false),
|
|
|
|
fRequestSent(false),
|
|
|
|
|
|
|
|
fLook(wlook),
|
|
|
|
fFeel(-1),
|
|
|
|
fLevel(-100),
|
|
|
|
fWindowFlags(wflags),
|
|
|
|
fWorkspaces(wwksindex),
|
|
|
|
|
|
|
|
fMinWidth(1.0),
|
|
|
|
fMaxWidth(10000.0),
|
|
|
|
fMinHeight(1.0),
|
|
|
|
fMaxHeight(10000.0),
|
|
|
|
|
|
|
|
cnt(0) // for debugging
|
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-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;
|
2005-03-21 23:29:24 +03:00
|
|
|
fEventMask = B_POINTER_EVENTS;
|
2005-06-16 00:36:43 +04:00
|
|
|
#ifdef NEW_CLIPPING
|
|
|
|
fRebuildDecRegion = true;
|
|
|
|
#endif
|
2005-04-21 22:57:34 +04:00
|
|
|
QuietlySetFeel(wfeel);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fFeel != B_NO_BORDER_WINDOW_LOOK) {
|
2005-06-27 06:06:15 +04:00
|
|
|
// ToDo: these should probably restricted by the decorator only, but
|
|
|
|
// the code there doesn't look too robust to me currently
|
|
|
|
fMinWidth = 20;
|
|
|
|
fMinHeight = 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fFrame.Width() < fMinWidth)
|
|
|
|
fFrame.right = fFrame.left + fMinWidth;
|
|
|
|
if (fFrame.Height() < fMinHeight)
|
|
|
|
fFrame.bottom = fFrame.top + fMinHeight;
|
|
|
|
|
|
|
|
if (fFeel != B_NO_BORDER_WINDOW_LOOK) {
|
|
|
|
fDecorator = gDecorManager.AllocateDecorator(frame, name, fLook, fFeel,
|
2005-06-17 23:10:15 +04:00
|
|
|
fWindowFlags, fDriver);
|
2005-06-27 06:06:15 +04:00
|
|
|
if (fDecorator) {
|
2005-06-03 23:50:30 +04:00
|
|
|
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight, &fMaxWidth, &fMaxHeight);
|
2005-06-27 06:06:15 +04:00
|
|
|
|
|
|
|
// we need to change our size to let the decorator fit
|
|
|
|
if (fMinWidth > fFrame.Width())
|
|
|
|
fFrame.right = fFrame.left + fMinWidth;
|
|
|
|
if (fMinHeight > fFrame.Height())
|
|
|
|
fFrame.bottom = fFrame.top + fMinHeight;
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
}
|
2004-03-28 18:58:39 +04:00
|
|
|
|
2005-06-16 22:58:14 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-02-28 23:23:51 +03:00
|
|
|
RebuildFullRegion();
|
2005-06-16 22:58:14 +04:00
|
|
|
#endif
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->AddWinBorder(this);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
STRACE(("WinBorder %s:\n", GetName()));
|
|
|
|
STRACE(("\tFrame: (%.1f, %.1f, %.1f, %.1f)\n", r.left, r.top, r.right, r.bottom));
|
2005-06-27 06:06:15 +04:00
|
|
|
STRACE(("\tWindow %s\n", win ? win->Title() : "NULL"));
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
WinBorder::~WinBorder()
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-18 15:50:17 +04:00
|
|
|
STRACE(("WinBorder(%s)::~WinBorder()\n",GetName()));
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-05-28 17:43:13 +04:00
|
|
|
gDesktop->RemoveWinBorder(this);
|
2005-02-28 23:23:51 +03:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
delete fTopLayer;
|
|
|
|
delete fDecorator;
|
2003-02-14 04:53:53 +03: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
|
2005-06-03 23:50:30 +04: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.
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fDecorator) {
|
|
|
|
WinBorder* wb = GetRootLayer()->FocusWinBorder();
|
|
|
|
if (wb == this)
|
2005-02-28 23:23:51 +03:00
|
|
|
fDecorator->SetFocus(true);
|
|
|
|
else
|
|
|
|
fDecorator->SetFocus(false);
|
2005-04-06 00:03:07 +04:00
|
|
|
fDecorator->Draw(r);
|
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
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::MoveBy(float x, float y)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2005-06-06 02:02:25 +04:00
|
|
|
x = (float)int32(x);
|
|
|
|
y = (float)int32(y);
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (x == 0.0 && y == 0.0)
|
|
|
|
return;
|
|
|
|
|
2005-04-28 16:31:25 +04:00
|
|
|
STRACE(("WinBorder(%s)::MoveBy(%.1f, %.1f) fDecorator: %p\n", GetName(), x, y, fDecorator));
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fDecorator)
|
2004-03-28 18:58:39 +04:00
|
|
|
fDecorator->MoveBy(x,y);
|
2004-06-19 17:04:50 +04:00
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
|
2005-04-29 03:56:40 +04:00
|
|
|
// NOTE: I moved this here from Layer::move_layer()
|
|
|
|
// Should this have any bad consequences I'm not aware of?
|
2005-06-25 17:09:19 +04:00
|
|
|
fCumulativeRegion.OffsetBy(x, y);
|
|
|
|
fInUpdateRegion.OffsetBy(x, y);
|
2005-04-29 03:56:40 +04:00
|
|
|
|
|
|
|
if (IsHidden()) {
|
|
|
|
// TODO: This is a work around for a design issue:
|
|
|
|
// The actual movement of a layer is done during
|
|
|
|
// the region rebuild. The mechanism is somewhat
|
|
|
|
// complicated and scheduled for refractoring...
|
|
|
|
// The problem here for hidden layers is that
|
|
|
|
// they seem *not* to be part of the layer tree.
|
|
|
|
// I don't think this is wrong as such, but of
|
|
|
|
// course the rebuilding of regions does not take
|
|
|
|
// place then. I don't understand yet the consequences
|
|
|
|
// for normal views, but this here fixes at least
|
|
|
|
// BWindows being MoveTo()ed before they are Show()n.
|
|
|
|
// In Layer::move_to, StartRebuildRegions() is called
|
|
|
|
// on fParent. But the rest of the this layers tree
|
|
|
|
// has not been added to fParent apperantly. So now
|
|
|
|
// you ask why fParent is even valid? Me too.
|
|
|
|
fFrame.OffsetBy(x, y);
|
|
|
|
fFull.OffsetBy(x, y);
|
|
|
|
fTopLayer->move_layer(x, y);
|
|
|
|
// ...and here we get really hacky...
|
|
|
|
fTopLayer->fFrame.OffsetTo(0.0, 0.0);
|
|
|
|
} else {
|
|
|
|
move_layer(x, y);
|
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
#else
|
|
|
|
// implement. maybe...
|
|
|
|
#endif
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (Window()) {
|
|
|
|
// dispatch a message to the client informing about the changed size
|
|
|
|
BMessage msg(B_WINDOW_MOVED);
|
|
|
|
msg.AddPoint("where", fFrame.LeftTop());
|
|
|
|
Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
|
|
|
}
|
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
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::ResizeBy(float x, float y)
|
2003-02-14 04:53:53 +03:00
|
|
|
{
|
2004-06-11 06:46:48 +04:00
|
|
|
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
2004-06-19 17:04:50 +04:00
|
|
|
|
2005-06-06 02:02:25 +04:00
|
|
|
x = (float)int32(x);
|
|
|
|
y = (float)int32(y);
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
float wantWidth = fFrame.Width() + x;
|
|
|
|
float wantHeight = fFrame.Height() + y;
|
|
|
|
|
|
|
|
// enforce size limits
|
|
|
|
if (wantWidth < fMinWidth)
|
|
|
|
wantWidth = fMinWidth;
|
|
|
|
if (wantWidth > fMaxWidth)
|
|
|
|
wantWidth = fMaxWidth;
|
|
|
|
|
|
|
|
if (wantHeight < fMinHeight)
|
|
|
|
wantHeight = fMinHeight;
|
|
|
|
if (wantHeight > fMaxHeight)
|
|
|
|
wantHeight = fMaxHeight;
|
|
|
|
|
|
|
|
x = wantWidth - fFrame.Width();
|
|
|
|
y = wantHeight - fFrame.Height();
|
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
if (x == 0.0 && y == 0.0)
|
|
|
|
return;
|
2005-06-03 23:50:30 +04:00
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
if (fDecorator)
|
|
|
|
fDecorator->ResizeBy(x, y);
|
|
|
|
|
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
if (IsHidden()) {
|
|
|
|
// TODO: See large comment in MoveBy()
|
|
|
|
fFrame.right += x;
|
|
|
|
fFrame.bottom += y;
|
|
|
|
|
|
|
|
fTopLayer->resize_layer(x, y);
|
|
|
|
} else {
|
|
|
|
resize_layer(x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
// Do? I don't think so. The new move/resize/scroll hooks should handle these
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (Window()) {
|
|
|
|
// send a message to the client informing about the changed size
|
|
|
|
BMessage msg(B_WINDOW_RESIZED);
|
2005-06-28 04:53:41 +04:00
|
|
|
msg.AddInt64("when", system_time());
|
|
|
|
|
|
|
|
BRect frame(fTopLayer->Frame());
|
|
|
|
msg.AddInt32("width", frame.IntegerWidth());
|
|
|
|
msg.AddInt32("height", frame.IntegerHeight());
|
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
Window()->SendMessageToClient(&msg, B_NULL_TOKEN, false);
|
2005-06-03 23:50:30 +04:00
|
|
|
}
|
2003-02-14 04:53:53 +03:00
|
|
|
}
|
2004-06-11 06:46:48 +04:00
|
|
|
|
2005-06-25 17:09:19 +04:00
|
|
|
// UpdateStart
|
|
|
|
void
|
|
|
|
WinBorder::UpdateStart()
|
|
|
|
{
|
|
|
|
// During updates we only want to draw what's in the update region
|
|
|
|
fInUpdate = true;
|
|
|
|
fRequestSent = false;
|
|
|
|
|
|
|
|
cnt--;
|
|
|
|
if (cnt != 0)
|
|
|
|
CRITICAL("Layer::UpdateStart(): wb->cnt != 0 -> Not Allowed!");
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateEnd
|
|
|
|
void
|
|
|
|
WinBorder::UpdateEnd()
|
|
|
|
{
|
|
|
|
// The usual case. Drawing is permitted in the whole visible area.
|
|
|
|
|
|
|
|
fInUpdate = false;
|
|
|
|
|
|
|
|
fInUpdateRegion.MakeEmpty();
|
|
|
|
|
|
|
|
if (fCumulativeRegion.CountRects() > 0) {
|
|
|
|
BRegion reg(fCumulativeRegion);
|
|
|
|
RequestDraw(reg, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:58:14 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
|
|
|
|
2005-06-16 16:32:42 +04:00
|
|
|
//! Rebuilds the WinBorder's "fully-visible" region based on info from the decorator
|
|
|
|
void
|
|
|
|
WinBorder::RebuildFullRegion()
|
|
|
|
{
|
|
|
|
STRACE(("WinBorder(%s)::RebuildFullRegion()\n",GetName()));
|
|
|
|
|
|
|
|
fFull.MakeEmpty();
|
|
|
|
|
|
|
|
// Winborder holds Decorator's full regions. if any...
|
|
|
|
if (fDecorator)
|
|
|
|
fDecorator->GetFootprint(&fFull);
|
|
|
|
}
|
|
|
|
|
2005-06-16 22:58:14 +04:00
|
|
|
#endif
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Sets the minimum and maximum sizes of the window
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::SetSizeLimits(float minWidth, float maxWidth,
|
|
|
|
float minHeight, float maxHeight)
|
2004-08-08 00:30:58 +04:00
|
|
|
{
|
2005-06-03 23:50:30 +04:00
|
|
|
if (minWidth < 0)
|
|
|
|
minWidth = 0;
|
2004-08-08 00:30:58 +04:00
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
if (minHeight < 0)
|
|
|
|
minHeight = 0;
|
|
|
|
|
|
|
|
fMinWidth = minWidth;
|
|
|
|
fMaxWidth = maxWidth;
|
|
|
|
fMinHeight = minHeight;
|
|
|
|
fMaxHeight = maxHeight;
|
|
|
|
|
|
|
|
// give the Decorator a say in this too
|
|
|
|
if (fDecorator)
|
|
|
|
fDecorator->GetSizeLimits(&fMinWidth, &fMinHeight,
|
|
|
|
&fMaxWidth, &fMaxHeight);
|
|
|
|
|
|
|
|
if (fMaxWidth < fMinWidth)
|
|
|
|
fMaxWidth = fMinWidth;
|
|
|
|
|
|
|
|
if (fMaxHeight < fMinHeight)
|
|
|
|
fMaxHeight = fMinHeight;
|
|
|
|
|
2005-06-16 16:32:42 +04:00
|
|
|
#if 0 // On R5, Windows don't automatically resize (the code works though)
|
2005-06-03 23:50:30 +04:00
|
|
|
// Automatically resize the window to fit these new limits
|
|
|
|
// if it does not already.
|
|
|
|
float minWidthDiff = fMinWidth - fFrame.Width();
|
|
|
|
float minHeightDiff = fMinHeight - fFrame.Height();
|
|
|
|
float maxWidthDiff = fMaxWidth - fFrame.Width();
|
|
|
|
float maxHeightDiff = fMaxHeight - fFrame.Height();
|
|
|
|
|
|
|
|
float xDiff = 0.0;
|
|
|
|
if (minWidthDiff > 0.0) // we're currently smaller than minWidth
|
|
|
|
xDiff = minWidthDiff;
|
|
|
|
else if (maxWidthDiff < 0.0) // we're currently larger than maxWidth
|
|
|
|
xDiff = maxWidthDiff;
|
|
|
|
|
|
|
|
float yDiff = 0.0;
|
|
|
|
if (minHeightDiff > 0.0) // we're currently smaller than minHeight
|
|
|
|
yDiff = minHeightDiff;
|
|
|
|
else if (maxHeightDiff < 0.0) // we're currently larger than maxHeight
|
|
|
|
yDiff = maxHeightDiff;
|
|
|
|
|
|
|
|
ResizeBy(xDiff, yDiff);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetSizeLimits
|
|
|
|
void
|
|
|
|
WinBorder::GetSizeLimits(float* minWidth, float* maxWidth,
|
|
|
|
float* minHeight, float* maxHeight) const
|
|
|
|
{
|
|
|
|
*minWidth = fMinWidth;
|
|
|
|
*maxWidth = fMaxWidth;
|
|
|
|
*minHeight = fMinHeight;
|
|
|
|
*maxHeight = fMaxHeight;
|
2004-08-08 00:30:58 +04:00
|
|
|
}
|
|
|
|
|
2005-06-16 16:32:42 +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.
|
|
|
|
*/
|
|
|
|
click_type
|
|
|
|
WinBorder::MouseDown(const PointerEvent& event)
|
|
|
|
{
|
|
|
|
click_type action = _ActionFor(event);
|
|
|
|
|
|
|
|
if (fDecorator) {
|
|
|
|
// find out where user clicked in Decorator
|
|
|
|
switch(action) {
|
|
|
|
case DEC_CLOSE:
|
|
|
|
fIsClosing = true;
|
|
|
|
fDecorator->SetClose(true);
|
|
|
|
STRACE_CLICK(("===> DEC_CLOSE\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEC_ZOOM:
|
|
|
|
fIsZooming = true;
|
|
|
|
fDecorator->SetZoom(true);
|
|
|
|
STRACE_CLICK(("===> DEC_ZOOM\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEC_MINIMIZE:
|
|
|
|
fIsMinimizing = true;
|
|
|
|
fDecorator->SetMinimize(true);
|
|
|
|
STRACE_CLICK(("===> DEC_MINIMIZE\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEC_DRAG:
|
|
|
|
fIsDragging = true;
|
|
|
|
fBringToFrontOnRelease = true;
|
|
|
|
fLastMousePosition = event.where;
|
|
|
|
STRACE_CLICK(("===> DEC_DRAG\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEC_RESIZE:
|
|
|
|
fIsResizing = true;
|
|
|
|
fLastMousePosition = event.where;
|
|
|
|
fResizingClickOffset = event.where - fFrame.RightBottom();
|
|
|
|
STRACE_CLICK(("===> DEC_RESIZE\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEC_SLIDETAB:
|
|
|
|
fIsSlidingTab = true;
|
|
|
|
fLastMousePosition = event.where;
|
|
|
|
// fResizingClickOffset = event.where - fFrame.RightBottom();
|
|
|
|
STRACE_CLICK(("===> DEC_SLIDETAB\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\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
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
WinBorder::MouseMoved(const PointerEvent& event)
|
|
|
|
{
|
|
|
|
if (fDecorator) {
|
|
|
|
if (fIsZooming) {
|
|
|
|
fDecorator->SetZoom(_ActionFor(event) == DEC_ZOOM);
|
|
|
|
} else if (fIsClosing) {
|
|
|
|
fDecorator->SetClose(_ActionFor(event) == DEC_CLOSE);
|
|
|
|
} else if (fIsMinimizing) {
|
|
|
|
fDecorator->SetMinimize(_ActionFor(event) == DEC_MINIMIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fIsDragging) {
|
|
|
|
// we will not come to front if we ever actually moved
|
|
|
|
fBringToFrontOnRelease = false;
|
|
|
|
|
|
|
|
BPoint delta = event.where - fLastMousePosition;
|
|
|
|
MoveBy(delta.x, delta.y);
|
|
|
|
}
|
|
|
|
if (fIsResizing) {
|
|
|
|
BRect frame(fFrame.LeftTop(), event.where - fResizingClickOffset);
|
|
|
|
|
|
|
|
BPoint delta = frame.RightBottom() - fFrame.RightBottom();
|
|
|
|
ResizeBy(delta.x, delta.y);
|
|
|
|
}
|
|
|
|
if (fIsSlidingTab) {
|
|
|
|
}
|
|
|
|
fLastMousePosition = event.where;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\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).
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
WinBorder::MouseUp(const PointerEvent& event)
|
|
|
|
{
|
|
|
|
if (fDecorator) {
|
|
|
|
click_type action = _ActionFor(event);
|
|
|
|
|
|
|
|
if (fIsZooming) {
|
|
|
|
fIsZooming = false;
|
|
|
|
fDecorator->SetZoom(false);
|
|
|
|
if (action == DEC_ZOOM)
|
2005-06-24 02:43:11 +04:00
|
|
|
Window()->NotifyZoom();
|
2005-06-16 16:32:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fIsClosing) {
|
|
|
|
fIsClosing = false;
|
|
|
|
fDecorator->SetClose(false);
|
|
|
|
if (action == DEC_CLOSE)
|
2005-06-24 02:43:11 +04:00
|
|
|
Window()->NotifyQuitRequested();
|
2005-06-16 16:32:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (fIsMinimizing) {
|
|
|
|
fIsMinimizing = false;
|
|
|
|
fDecorator->SetMinimize(false);
|
|
|
|
if (action == DEC_MINIMIZE)
|
2005-06-24 02:43:11 +04:00
|
|
|
Window()->NotifyMinimize(true);
|
2005-06-16 16:32:42 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fBringToFrontOnRelease) {
|
|
|
|
// TODO: We would have dragged the window if
|
|
|
|
// the mouse would have moved, but it didn't
|
|
|
|
// move -> This will bring the window to the
|
|
|
|
// front on R5 in FFM mode!
|
|
|
|
}
|
|
|
|
fIsDragging = false;
|
|
|
|
fIsResizing = false;
|
|
|
|
fIsSlidingTab = false;
|
|
|
|
fBringToFrontOnRelease = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetTabLocation
|
|
|
|
void
|
|
|
|
WinBorder::SetTabLocation(float location)
|
|
|
|
{
|
|
|
|
if (fDecorator)
|
|
|
|
fDecorator->SetTabLocation(location);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TabLocation
|
|
|
|
float
|
|
|
|
WinBorder::TabLocation() const
|
|
|
|
{
|
|
|
|
if (fDecorator)
|
|
|
|
return fDecorator->TabLocation();
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Sets the decorator focus to active or inactive colors
|
|
|
|
void
|
|
|
|
WinBorder::HighlightDecorator(bool active)
|
|
|
|
{
|
|
|
|
STRACE(("Decorator->Highlight\n"));
|
|
|
|
if (fDecorator)
|
|
|
|
fDecorator->SetFocus(active);
|
|
|
|
}
|
|
|
|
|
2004-09-09 04:54:21 +04:00
|
|
|
//! Returns true if the point is in the WinBorder's screen area
|
2005-06-03 23:50:30 +04:00
|
|
|
bool
|
|
|
|
WinBorder::HasPoint(const BPoint& pt) const
|
2004-06-11 06:46:48 +04:00
|
|
|
{
|
2005-06-17 00:43:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2004-06-11 22:21:57 +04:00
|
|
|
return fFullVisible.Contains(pt);
|
2005-06-17 00:43:53 +04:00
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
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
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::UpdateColors()
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
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
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::UpdateDecorator()
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
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
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::UpdateFont()
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
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
|
2005-06-03 23:50:30 +04:00
|
|
|
void
|
|
|
|
WinBorder::UpdateScreen()
|
2003-02-24 18:47:06 +03:00
|
|
|
{
|
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
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
// QuietlySetFeel
|
|
|
|
void
|
|
|
|
WinBorder::QuietlySetFeel(int32 feel)
|
2005-02-28 23:23:51 +03:00
|
|
|
{
|
2005-04-21 22:57:34 +04:00
|
|
|
fFeel = feel;
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
switch(fFeel) {
|
2005-02-28 23:23:51 +03:00
|
|
|
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;
|
|
|
|
}
|
2005-04-21 22:57:34 +04:00
|
|
|
|
|
|
|
// floating and modal windows must appear in every workspace where
|
|
|
|
// their main window is present. Thus their wksIndex will be set to
|
|
|
|
// '0x0' and they will be made visible when needed.
|
2005-06-03 23:50:30 +04:00
|
|
|
switch (fFeel) {
|
2005-04-21 22:57:34 +04:00
|
|
|
case B_MODAL_APP_WINDOW_FEEL:
|
2005-04-23 14:05:33 +04:00
|
|
|
break;
|
2005-04-21 22:57:34 +04:00
|
|
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
|
|
|
case B_FLOATING_APP_WINDOW_FEEL:
|
|
|
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
|
|
|
fWorkspaces = 0x0UL;
|
|
|
|
break;
|
|
|
|
case B_MODAL_ALL_WINDOW_FEEL:
|
|
|
|
case B_FLOATING_ALL_WINDOW_FEEL:
|
|
|
|
case B_SYSTEM_LAST:
|
|
|
|
case B_SYSTEM_FIRST:
|
|
|
|
fWorkspaces = 0xffffffffUL;
|
|
|
|
break;
|
|
|
|
case B_NORMAL_WINDOW_FEEL:
|
2005-04-23 14:05:33 +04:00
|
|
|
break;
|
2005-04-21 22:57:34 +04:00
|
|
|
}
|
2005-06-03 23:50:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// _ActionFor
|
|
|
|
click_type
|
|
|
|
WinBorder::_ActionFor(const PointerEvent& event) const
|
|
|
|
{
|
2005-06-17 00:43:53 +04:00
|
|
|
#ifndef NEW_CLIPPING
|
2005-06-03 23:50:30 +04:00
|
|
|
if (fTopLayer->fFullVisible.Contains(event.where))
|
|
|
|
return DEC_NONE;
|
2005-06-17 00:43:53 +04:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (fDecorator)
|
2005-06-03 23:50:30 +04:00
|
|
|
return fDecorator->Clicked(event.where, event.buttons, event.modifiers);
|
|
|
|
else
|
|
|
|
return DEC_NONE;
|
|
|
|
}
|
|
|
|
|
2005-06-16 00:36:43 +04:00
|
|
|
#ifdef NEW_CLIPPING
|
|
|
|
void WinBorder::MovedByHook(float dx, float dy)
|
|
|
|
{
|
|
|
|
fDecRegion.OffsetBy(dx, dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::ResizedByHook(float dx, float dy, bool automatic)
|
|
|
|
{
|
|
|
|
fRebuildDecRegion = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::set_decorator_region(BRect bounds)
|
|
|
|
{
|
|
|
|
fRebuildDecRegion = false;
|
|
|
|
|
2005-06-22 00:11:44 +04:00
|
|
|
if (fDecorator)
|
|
|
|
{
|
|
|
|
fDecRegion.MakeEmpty();
|
|
|
|
fDecorator->GetFootprint(&fDecRegion);
|
|
|
|
}
|
2005-06-16 00:36:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WinBorder::alter_visible_for_children(BRegion ®ion)
|
|
|
|
{
|
|
|
|
region.Exclude(&fDecRegion);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinBorder::get_user_regions(BRegion ®)
|
|
|
|
{
|
|
|
|
if (fRebuildDecRegion)
|
|
|
|
{
|
|
|
|
set_decorator_region(Bounds());
|
2005-06-22 00:11:44 +04:00
|
|
|
// TODO? the decorator should be in WinBorder coordinates?? It's easier not to.
|
|
|
|
//ConvertToScreen2(&fDecRegion);
|
2005-06-16 00:36:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BRect screenFrame(Bounds());
|
|
|
|
ConvertToScreen2(&screenFrame);
|
|
|
|
reg.Set(screenFrame);
|
|
|
|
|
|
|
|
BRegion screenReg(GetRootLayer()->Bounds());
|
|
|
|
|
|
|
|
reg.IntersectWith(&screenReg);
|
|
|
|
|
|
|
|
reg.Include(&fDecRegion);
|
|
|
|
}
|
2005-06-24 02:43:11 +04:00
|
|
|
#endif
|