reduced to a minimum. It's the next on my TODO list to make redrawing code work it also.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8fca004965
commit
01f14b6c8c
@ -48,7 +48,7 @@
|
||||
//#define DEBUG_WINBORDER
|
||||
|
||||
// toggle
|
||||
//#define DEBUG_WINBORDER_MOUSE
|
||||
#define DEBUG_WINBORDER_MOUSE
|
||||
#define DEBUG_WINBORDER_CLICK
|
||||
|
||||
#ifdef DEBUG_WINBORDER
|
||||
@ -75,631 +75,94 @@
|
||||
//! TokenHandler object used to provide IDs for all WinBorder objects
|
||||
TokenHandler border_token_handler;
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const int32 feel,
|
||||
const int32 flags, ServerWindow *win)
|
||||
: Layer(r, name, B_NULL_TOKEN, B_FOLLOW_NONE, flags, win)
|
||||
const int32 flags, ServerWindow *win, DisplayDriver *driver)
|
||||
: Layer(r, name, B_NULL_TOKEN, B_FOLLOW_NONE, flags, driver)
|
||||
{
|
||||
// unlike BViews, windows start off as hidden, so we need to tweak the hidecount
|
||||
// assignment made by Layer().
|
||||
// unlike BViews, windows start off as hidden
|
||||
_hidden = true;
|
||||
_serverwin = win;
|
||||
|
||||
fWindow = win;
|
||||
fMouseButtons = 0;
|
||||
fKeyModifiers = 0;
|
||||
fMainWinBorder = NULL;
|
||||
fDecorator = NULL;
|
||||
fDecFull = NULL;
|
||||
|
||||
_mbuttons = 0;
|
||||
_kmodifiers = 0;
|
||||
_win = win;
|
||||
_update = false;
|
||||
_hresizewin = false;
|
||||
_vresizewin = false;
|
||||
fLastMousePosition.Set(-1,-1);
|
||||
SetLevel();
|
||||
|
||||
fMainWinBorder = NULL;
|
||||
_decorator = NULL;
|
||||
|
||||
if (feel == B_NO_BORDER_WINDOW_LOOK)
|
||||
{
|
||||
_full = _win->fTopLayer->_full;
|
||||
fDecFull = NULL;
|
||||
fDecFullVisible = NULL;
|
||||
fDecVisible = NULL;
|
||||
_full = fWindow->fTopLayer->_full;
|
||||
}
|
||||
else
|
||||
{
|
||||
_decorator = new_decorator(r, name, look, feel, flags, fDriver);
|
||||
fDecorator = new_decorator(r, name, look, feel, flags, fDriver);
|
||||
fDecFull = new BRegion();
|
||||
fDecVisible = new BRegion();
|
||||
fDecFullVisible = fDecVisible;
|
||||
|
||||
_decorator->GetFootprint( fDecFull );
|
||||
fDecorator->GetFootprint( fDecFull );
|
||||
|
||||
// our full region is the union between decorator's region and fTopLayer's region
|
||||
_full = _win->fTopLayer->_full;
|
||||
_full = fWindow->fTopLayer->_full;
|
||||
_full.Include( fDecFull );
|
||||
}
|
||||
|
||||
// get a token
|
||||
_view_token = border_token_handler.GetToken();
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
WinBorder::~WinBorder(void)
|
||||
{
|
||||
STRACE(("WinBorder %s:~WinBorder()\n",GetName()));
|
||||
if (_decorator) {
|
||||
delete _decorator;
|
||||
_decorator = NULL;
|
||||
if (fDecorator) {
|
||||
delete fDecorator;
|
||||
fDecorator = NULL;
|
||||
|
||||
delete fDecFull;
|
||||
fDecFull = NULL;
|
||||
|
||||
delete fDecFullVisible; // NOTE: fDecFullVisible == fDecVisible
|
||||
fDecFullVisible = NULL;
|
||||
fDecVisible = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::MouseDown(const BPoint &pt, const int32 &buttons, const int32 &modifiers)
|
||||
{
|
||||
// user clicked on decorator
|
||||
if (fDecFullVisible->Contains(pt))
|
||||
{
|
||||
click_type click;
|
||||
click = _decorator->Clicked(pt, buttons, modifiers);
|
||||
|
||||
switch(click)
|
||||
{
|
||||
case DEC_CLOSE:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Push Close Button\n"));
|
||||
_decorator->SetClose(true);
|
||||
_decorator->DrawClose();
|
||||
break;
|
||||
}
|
||||
case DEC_ZOOM:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Push Zoom Button\n"));
|
||||
_decorator->SetZoom(true);
|
||||
_decorator->DrawZoom();
|
||||
break;
|
||||
}
|
||||
case DEC_MINIMIZE:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Push Close Button\n"));
|
||||
_decorator->SetMinimize(true);
|
||||
_decorator->DrawMinimize();
|
||||
break;
|
||||
}
|
||||
case DEC_MOVETOBACK:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: MoveToBack\n"));
|
||||
MoveToBack();
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
STRACE_CLICK(("WinBorder: MoveToFront\n"));
|
||||
MoveToFront();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// user clicked in window's area
|
||||
else
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: MoveToFront 2\n"));
|
||||
bool sendMessage = true;
|
||||
|
||||
if (1 /* TODO: uncomment: ActiveLayer() != this*/)
|
||||
{
|
||||
MoveToFront();
|
||||
if (0 /* B_FIRST_CLICK? what's the name of that flaaaag ??? */){
|
||||
sendMessage = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (sendMessage)
|
||||
{
|
||||
Layer *targetLayer=_win->fTopLayer->LayerAt(pt);
|
||||
if(targetLayer)
|
||||
{
|
||||
BMessage msg;
|
||||
|
||||
// a tweak for converting a point into local coords. :-)
|
||||
BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1);
|
||||
msg.what = B_MOUSE_DOWN;
|
||||
msg.AddInt64("when", real_time_clock_usecs());
|
||||
msg.AddPoint("where", (targetLayer->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddInt32("modifiers", modifiers);
|
||||
msg.AddInt32("buttons", buttons);
|
||||
msg.AddInt32("clicks", 1);
|
||||
|
||||
_win->SendMessageToClient( &msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
// this is important to determine how much we should resize or move the Layer(WinBorder)(window)
|
||||
// this is important to determine how much we should resize or move the Layer(WinBorder)(window)
|
||||
fLastMousePosition = pt;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::MouseMoved(const BPoint &pt, const int32 &buttons)
|
||||
{
|
||||
// Buffer data:
|
||||
// 1) int64 - time of mouse click
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - buttons down
|
||||
|
||||
click_type action = _decorator->Clicked(pt, _mbuttons, _kmodifiers);
|
||||
|
||||
|
||||
// If the user clicked a button and then moused away without lifting the button,
|
||||
// we don't want to trigger the button. Instead, we reset it to its original up state
|
||||
if(_decorator->GetClose() && action!=DEC_CLOSE)
|
||||
{
|
||||
_decorator->SetClose(false);
|
||||
_decorator->DrawClose();
|
||||
}
|
||||
if(_decorator->GetZoom() && action!=DEC_ZOOM)
|
||||
{
|
||||
_decorator->SetZoom(false);
|
||||
_decorator->DrawZoom();
|
||||
}
|
||||
if(_decorator->GetMinimize() && action!=DEC_MINIMIZE)
|
||||
{
|
||||
_decorator->SetMinimize(false);
|
||||
_decorator->DrawMinimize();
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case DEC_DRAG:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Drag\n"));
|
||||
BPoint difference;
|
||||
difference = pt - fLastMousePosition;
|
||||
|
||||
MoveBy( difference.x, difference.y );
|
||||
break;
|
||||
}
|
||||
case DEC_RESIZE:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Resize\n"));
|
||||
BPoint difference;
|
||||
difference = pt - fLastMousePosition;
|
||||
|
||||
ResizeBy( difference.x, difference.y );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
BMessage msg;
|
||||
|
||||
// a tweak for converting a point into local coords. :-)
|
||||
BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1);
|
||||
msg.what = B_MOUSE_MOVED;
|
||||
msg.AddInt64("when", real_time_clock_usecs());
|
||||
msg.AddPoint("where", (_win->fTopLayer->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddInt32("buttons", buttons);
|
||||
|
||||
_win->SendMessageToClient( &msg );
|
||||
}
|
||||
}
|
||||
// this is important to determine how much we should resize or move the
|
||||
// Layer(WinBorder)(window)
|
||||
fLastMousePosition = pt;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::MouseUp(const BPoint &pt, const int32 &modifiers)
|
||||
{
|
||||
STRACE_MOUSE(("WinBorder %s: MouseUp() \n",GetName()));
|
||||
|
||||
// buffer 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
|
||||
|
||||
click_type action =_decorator->Clicked(pt, _mbuttons, _kmodifiers);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case DEC_CLOSE:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Close\n"));
|
||||
|
||||
if(_decorator->GetClose())
|
||||
{
|
||||
_decorator->SetClose(false);
|
||||
_decorator->DrawClose();
|
||||
|
||||
BMessage msg(B_QUIT_REQUESTED);
|
||||
_win->SendMessageToClient(&msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DEC_ZOOM:
|
||||
{
|
||||
STRACE_CLICK(("WinBorder: Zoom\n"));
|
||||
|
||||
if(_decorator->GetZoom())
|
||||
{
|
||||
_decorator->SetZoom(false);
|
||||
_decorator->DrawZoom();
|
||||
|
||||
BMessage msg(B_ZOOM);
|
||||
_win->SendMessageToClient(&msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DEC_MINIMIZE:
|
||||
{
|
||||
STRACE_CLICK(("WinBoder: Minimize\n"));
|
||||
if(_decorator->GetMinimize())
|
||||
{
|
||||
_decorator->SetMinimize(false);
|
||||
_decorator->DrawMinimize();
|
||||
|
||||
BMessage msg(B_MINIMIZE);
|
||||
_win->SendMessageToClient(&msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Layer *targetLayer=_win->fTopLayer->LayerAt(pt);
|
||||
if(targetLayer)
|
||||
{
|
||||
BMessage msg;
|
||||
|
||||
// a tweak for converting a point into local coords. :-)
|
||||
BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1);
|
||||
msg.what = B_MOUSE_UP;
|
||||
msg.AddInt64("when", real_time_clock_usecs());
|
||||
msg.AddPoint("where", (targetLayer->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddInt32("modifiers", modifiers);
|
||||
|
||||
_win->SendMessageToClient( &msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WinBorder::Show(){
|
||||
if( !_hidden )
|
||||
return;
|
||||
|
||||
_hidden = false;
|
||||
}
|
||||
|
||||
void WinBorder::Hide(){
|
||||
if ( _hidden )
|
||||
return;
|
||||
|
||||
_hidden = true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Function to pass focus value on to decorator
|
||||
\param active Focus flag
|
||||
*/
|
||||
void WinBorder::SetFocus(const bool &active)
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::HighlightDecorator(const bool &active)
|
||||
{
|
||||
_decorator->SetFocus(active);
|
||||
fDecorator->SetFocus(active);
|
||||
}
|
||||
|
||||
void WinBorder::RebuildRegions( const BRect& r ){
|
||||
/* WinBorder is a little bit special. It doesn't have a visible region
|
||||
in which to do its drawings. Instead the whole visible region is split
|
||||
between decorator and top_layer.
|
||||
*/
|
||||
|
||||
// if we're in the rebuild area, rebuild our v.r.
|
||||
if ( _full.Intersects( r ) ){
|
||||
_visible = _full;
|
||||
|
||||
if (_parent){
|
||||
_visible.IntersectWith( &(_parent->_visible) );
|
||||
// exclude from parent's visible area.
|
||||
if ( !(_hidden) )
|
||||
_parent->_visible.Exclude( &(_visible) );
|
||||
}
|
||||
|
||||
_fullVisible = _visible;
|
||||
}
|
||||
else{
|
||||
// our visible region will stay the same
|
||||
|
||||
// exclude our FULL visible region from parent's visible region.
|
||||
if ( !(_hidden) && _parent )
|
||||
_parent->_visible.Exclude( &(_fullVisible) );
|
||||
|
||||
// we're not in the rebuild area so our children's v.r.s are OK.
|
||||
return;
|
||||
}
|
||||
|
||||
// rebuild top_layer:
|
||||
if ( _win->fTopLayer->_full.Intersects( r ) ){
|
||||
// build top_layer's visible region by intersecting its _full with winborder's _visible region.
|
||||
_win->fTopLayer->_visible = _win->fTopLayer->_full;
|
||||
_win->fTopLayer->_visible.IntersectWith( &(_visible) );
|
||||
|
||||
// then exclude it from winborder's _visible...
|
||||
_visible.Exclude( &(_win->fTopLayer->_visible) );
|
||||
|
||||
_win->fTopLayer->_fullVisible = _win->fTopLayer->_visible;
|
||||
|
||||
// Rebuild regions for children...
|
||||
for(Layer *lay = _win->fTopLayer->_bottomchild; lay != NULL; lay = lay->_uppersibling){
|
||||
if ( !(lay->_hidden) ){
|
||||
lay->RebuildRegions( r );
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
_visible.Exclude( &(_win->fTopLayer->_fullVisible) );
|
||||
}
|
||||
|
||||
// rebuild decorator.
|
||||
if (_decorator){
|
||||
if ( fDecFull->Intersects( r ) ){
|
||||
*fDecVisible = *fDecFull;
|
||||
fDecVisible->IntersectWith( &(_visible) );
|
||||
|
||||
_visible.Exclude( fDecVisible );
|
||||
|
||||
// !!!! Pointer assignement !!!!
|
||||
fDecFullVisible = fDecVisible;
|
||||
}
|
||||
else{
|
||||
_visible.Exclude( fDecFullVisible );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::Draw(const BRect &r)
|
||||
{
|
||||
//TODO: REMOVE this! For Test purposes only!
|
||||
STRACE(("*WinBorder(%s)::Draw()\n", GetName()));
|
||||
_decorator->Draw();
|
||||
STRACE(("#WinBorder(%s)::Draw() ENDED\n", GetName()));
|
||||
return;
|
||||
//----------------
|
||||
|
||||
// draw the decorator
|
||||
BRegion reg(r);
|
||||
if (_decorator){
|
||||
reg.IntersectWith( fDecVisible );
|
||||
if (reg.CountRects() > 0){
|
||||
_decorator->Draw( reg.Frame() );
|
||||
}
|
||||
}
|
||||
|
||||
// draw the top_layer
|
||||
reg.Set( r );
|
||||
reg.IntersectWith( &(_win->fTopLayer->_visible) );
|
||||
if (reg.CountRects() > 0){
|
||||
_win->fTopLayer->RequestClientUpdate( reg.Frame() );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::MoveBy(float x, float y)
|
||||
{
|
||||
BRegion oldFullVisible( _fullVisible );
|
||||
// BPoint oldFullVisibleOrigin( _fullVisible.Frame().LeftTop() );
|
||||
|
||||
_frame.OffsetBy(x, y);
|
||||
_full.OffsetBy(x, y);
|
||||
|
||||
_win->fTopLayer->_frame.OffsetBy(x, y);
|
||||
_win->fTopLayer->MoveRegionsBy(x, y);
|
||||
|
||||
if (_decorator){
|
||||
// allow decorator to make its internal calculations.
|
||||
_decorator->MoveBy(x, y);
|
||||
|
||||
fDecFull->OffsetBy(x, y);
|
||||
}
|
||||
|
||||
if ( !_hidden ){
|
||||
// to clear the area occupied on its parent _visible
|
||||
if (_fullVisible.CountRects() > 0){
|
||||
_hidden = true;
|
||||
_parent->RebuildChildRegions( _fullVisible.Frame(), this );
|
||||
_hidden = false;
|
||||
}
|
||||
_parent->RebuildChildRegions( _full.Frame(), this );
|
||||
}
|
||||
|
||||
// REDRAWING CODE:
|
||||
|
||||
if ( !(_hidden) )
|
||||
{
|
||||
/* The region(on screen) that will be invalidated.
|
||||
* It is composed by:
|
||||
* the regions that were visible, and now they aren't +
|
||||
* the regions that are now visible, and they were not visible before.
|
||||
* (oldFullVisible - _fullVisible) + (_fullVisible - oldFullVisible)
|
||||
*/
|
||||
BRegion clipReg;
|
||||
|
||||
// first offset the old region so we can do the correct operations.
|
||||
oldFullVisible.OffsetBy(x, y);
|
||||
|
||||
// + (oldFullVisible - _fullVisible)
|
||||
if ( oldFullVisible.CountRects() > 0 ){
|
||||
BRegion tempReg( oldFullVisible );
|
||||
tempReg.Exclude( &_fullVisible );
|
||||
|
||||
if (tempReg.CountRects() > 0){
|
||||
clipReg.Include( &tempReg );
|
||||
}
|
||||
}
|
||||
|
||||
// + (_fullVisible - oldFullVisible)
|
||||
if ( _fullVisible.CountRects() > 0 ){
|
||||
BRegion tempReg( _fullVisible );
|
||||
tempReg.Exclude( &oldFullVisible );
|
||||
|
||||
if (tempReg.CountRects() > 0){
|
||||
clipReg.Include( &tempReg );
|
||||
}
|
||||
}
|
||||
|
||||
// there is no point in redrawing what already is visible. So just copy
|
||||
// on-screen pixels to layer's new location.
|
||||
if ( (oldFullVisible.CountRects() > 0) && (_fullVisible.CountRects() > 0) ){
|
||||
BRegion tempReg( oldFullVisible );
|
||||
tempReg.IntersectWith( &_fullVisible );
|
||||
|
||||
if (tempReg.CountRects() > 0){
|
||||
// TODO: when you have such a method in DisplayDriver/Clipper, uncomment!
|
||||
//fDriver->CopyBits( &tempReg, oldFullVisibleOrigin, oldFullVisibleOrigin.OffsetByCopy(x,y) );
|
||||
}
|
||||
}
|
||||
|
||||
// invalidate 'clipReg' so we can see the results of this move.
|
||||
if (clipReg.CountRects() > 0){
|
||||
Invalidate( clipReg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::ResizeBy(float x, float y)
|
||||
{
|
||||
BRegion oldFullVisible( _fullVisible );
|
||||
|
||||
_frame.right = _frame.right + x;
|
||||
_frame.bottom = _frame.bottom + y;
|
||||
|
||||
_win->fTopLayer->ResizeRegionsBy(x, y);
|
||||
|
||||
_full = _win->fTopLayer->_full;
|
||||
|
||||
if (_decorator){
|
||||
// allow decorator to make its internal calculations.
|
||||
_decorator->ResizeBy(x, y);
|
||||
|
||||
_decorator->GetFootprint( fDecFull );
|
||||
|
||||
_full.Include( fDecFull );
|
||||
}
|
||||
|
||||
if ( !_hidden ){
|
||||
_parent->RebuildChildRegions( _full.Frame(), this );
|
||||
}
|
||||
|
||||
|
||||
// REDRAWING CODE:
|
||||
|
||||
if ( !(_hidden) )
|
||||
{
|
||||
/* The region(on screen) that will be invalidated.
|
||||
* It is composed by:
|
||||
* the regions that were visible, and now they aren't +
|
||||
* the regions that are now visible, and they were not visible before.
|
||||
* (oldFullVisible - _fullVisible) + (_fullVisible - oldFullVisible)
|
||||
*/
|
||||
BRegion clipReg;
|
||||
|
||||
// + (oldFullVisible - _fullVisible)
|
||||
if ( oldFullVisible.CountRects() > 0 ){
|
||||
BRegion tempReg( oldFullVisible );
|
||||
tempReg.Exclude( &_fullVisible );
|
||||
|
||||
if (tempReg.CountRects() > 0){
|
||||
clipReg.Include( &tempReg );
|
||||
}
|
||||
}
|
||||
|
||||
// + (_fullVisible - oldFullVisible)
|
||||
if ( _fullVisible.CountRects() > 0 ){
|
||||
BRegion tempReg( _fullVisible );
|
||||
tempReg.Exclude( &oldFullVisible );
|
||||
|
||||
if (tempReg.CountRects() > 0){
|
||||
clipReg.Include( &tempReg );
|
||||
}
|
||||
}
|
||||
|
||||
// invalidate 'clipReg' so we can see the results of this resize operation.
|
||||
if (clipReg.CountRects() > 0){
|
||||
Invalidate( clipReg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool WinBorder::HasPoint(BPoint pt) const{
|
||||
//---------------------------------------------------------------------------
|
||||
bool WinBorder::HasPoint(BPoint& pt) const{
|
||||
return _full.Contains(pt);
|
||||
}
|
||||
|
||||
void WinBorder::MoveToBack(){
|
||||
// TODO: take care of focus.
|
||||
if (this == _parent->_topchild)
|
||||
return;
|
||||
|
||||
if (_uppersibling){
|
||||
_uppersibling->_lowersibling = _lowersibling;
|
||||
}
|
||||
else{
|
||||
_parent->_topchild = _lowersibling;
|
||||
}
|
||||
|
||||
if (_lowersibling){
|
||||
_lowersibling->_uppersibling = _uppersibling;
|
||||
}
|
||||
else{
|
||||
_parent->_bottomchild = _uppersibling;
|
||||
}
|
||||
|
||||
this->_lowersibling = _parent->_topchild;
|
||||
this->_uppersibling = NULL;
|
||||
_parent->_topchild = this;
|
||||
|
||||
// cache WinBorder's fullVisible region for use later
|
||||
BRegion cachedFullVisible = _fullVisible;
|
||||
// rebuild only that area the encloses the full visible part of this layer.
|
||||
_parent->RebuildChildRegions(_fullVisible.Frame(), this);
|
||||
// we now have <= fullVisible region, so invalidate the parts that are not common.
|
||||
cachedFullVisible.Exclude(&_fullVisible);
|
||||
Invalidate( cachedFullVisible );
|
||||
}
|
||||
|
||||
void WinBorder::MoveToFront(){
|
||||
// TODO: take care of focus.
|
||||
if (this == _parent->_bottomchild)
|
||||
return;
|
||||
|
||||
if (_uppersibling){
|
||||
_uppersibling->_lowersibling = _lowersibling;
|
||||
}
|
||||
else{
|
||||
_parent->_topchild = _lowersibling;
|
||||
}
|
||||
|
||||
if (_lowersibling){
|
||||
_lowersibling->_uppersibling = _uppersibling;
|
||||
}
|
||||
else{
|
||||
_parent->_bottomchild = _uppersibling;
|
||||
}
|
||||
|
||||
this->_lowersibling = NULL;
|
||||
this->_uppersibling = _parent->_bottomchild;
|
||||
_parent->_bottomchild = this;
|
||||
|
||||
// cache WinBorder's fullVisible region for use later
|
||||
BRegion cachedFullVisible = _fullVisible;
|
||||
// rebuild the area that this WinBorder will occupy.
|
||||
_parent->RebuildChildRegions(_full.Frame(), this);
|
||||
// make a copy of the fullVisible region because it needs
|
||||
// to be modified for invalidating a minimum area.
|
||||
BRegion tempFullVisible = _fullVisible;
|
||||
// invalidate only the difference between the present and
|
||||
// the old fullVisible regions. We only need to update that area.
|
||||
tempFullVisible.Exclude(&cachedFullVisible);
|
||||
Invalidate( tempFullVisible );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::SetMainWinBorder(WinBorder *newMain){
|
||||
fMainWinBorder = newMain;
|
||||
@ -710,7 +173,7 @@ WinBorder* WinBorder::MainWinBorder() const{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::SetLevel(){
|
||||
switch(_win->Feel()){
|
||||
switch(fWindow->Feel()){
|
||||
case B_NORMAL_WINDOW_FEEL:
|
||||
_level = B_NORMAL_FEEL;
|
||||
break;
|
||||
@ -738,10 +201,10 @@ void WinBorder::SetLevel(){
|
||||
// if(_win->ServerTeamID() != _win->ClientTeamID())
|
||||
// _win->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
// else
|
||||
_level = _win->Feel();
|
||||
_level = fWindow->Feel();
|
||||
break;
|
||||
default:
|
||||
_win->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
fWindow->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
_level = B_NORMAL_FEEL;
|
||||
break;
|
||||
}
|
||||
@ -829,21 +292,6 @@ void WinBorder::RemoveFromSubsetOf(WinBorder* main){
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::PrintToStream(){
|
||||
printf("\t%s", GetName());
|
||||
/* if (Window()->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL)
|
||||
printf("\t%s", "B_FLOATING_SUBSET_WINDOW_FEEL");
|
||||
if (Window()->Feel() == B_FLOATING_APP_WINDOW_FEEL)
|
||||
printf("\t%s", "B_FLOATING_APP_WINDOW_FEEL");
|
||||
if (Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL)
|
||||
printf("\t%s", "B_FLOATING_ALL_WINDOW_FEEL");
|
||||
if (Window()->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
|
||||
printf("\t%s", "B_MODAL_SUBSET_WINDOW_FEEL");
|
||||
if (Window()->Feel() == B_MODAL_APP_WINDOW_FEEL)
|
||||
printf("\t%s", "B_MODAL_APP_WINDOW_FEEL");
|
||||
if (Window()->Feel() == B_MODAL_ALL_WINDOW_FEEL)
|
||||
printf("\t%s", "B_MODAL_ALL_WINDOW_FEEL");
|
||||
if (Window()->Feel() == B_NORMAL_WINDOW_FEEL)
|
||||
printf("\t%s", "B_NORMAL_WINDOW_FEEL");
|
||||
*/
|
||||
if (_level == B_FLOATING_SUBSET_FEEL)
|
||||
printf("\t%s", "B_FLOATING_SUBSET_WINDOW_FEEL");
|
||||
if (_level == B_FLOATING_APP_FEEL)
|
||||
@ -860,7 +308,6 @@ void WinBorder::PrintToStream(){
|
||||
printf("\t%s", "B_NORMAL_WINDOW_FEEL");
|
||||
|
||||
printf("\t%s\n", _hidden?"hidden" : "not hidden");
|
||||
// _full.PrintToStream();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void WinBorder::UpdateColors(void)
|
||||
|
@ -21,6 +21,7 @@
|
||||
//
|
||||
// File Name: WinBorder.h
|
||||
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
||||
// Adi Oanca <adioanca@mymail.ro>
|
||||
// Description: Layer subclass which handles window management
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
@ -38,80 +39,59 @@ class DisplayDriver;
|
||||
class WinBorder : public Layer
|
||||
{
|
||||
public:
|
||||
WinBorder(const BRect &r, const char *name, const int32 look,
|
||||
const int32 feel, const int32 flags, ServerWindow *win);
|
||||
virtual ~WinBorder(void);
|
||||
WinBorder(const BRect &r, const char *name, const int32 look,
|
||||
const int32 feel, const int32 flags, ServerWindow *win,
|
||||
DisplayDriver *driver);
|
||||
virtual ~WinBorder(void);
|
||||
|
||||
virtual void RebuildRegions( const BRect& r );
|
||||
virtual void Draw(const BRect &r);
|
||||
virtual void Draw(const BRect &r);
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
bool HasPoint(BPoint pt) const;
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
|
||||
void MouseDown(const BPoint &pt, const int32 &buttons, const int32 &modifiers);
|
||||
void MouseMoved(const BPoint &pt, const int32 &buttons);
|
||||
void MouseUp(const BPoint &pt, const int32 &modifiers);
|
||||
|
||||
void MoveToBack();
|
||||
void MoveToFront();
|
||||
void UpdateColors(void);
|
||||
void UpdateDecorator(void);
|
||||
void UpdateFont(void);
|
||||
void UpdateScreen(void);
|
||||
|
||||
void MouseDown(const BPoint &pt, const int32 &buttons, const int32 &modifiers);
|
||||
void MouseMoved(const BPoint &pt, const int32 &buttons);
|
||||
void MouseUp(const BPoint &pt, const int32 &modifiers);
|
||||
ServerWindow* Window(void) const { return fWindow; }
|
||||
Decorator* GetDecorator(void) const { return fDecorator; }
|
||||
WinBorder* MainWinBorder() const;
|
||||
|
||||
void SetLevel();
|
||||
void HighlightDecorator(const bool &active);
|
||||
|
||||
bool HasPoint(BPoint &pt) const;
|
||||
|
||||
virtual void Hide();
|
||||
virtual void Show();
|
||||
void AddToSubsetOf(WinBorder* main);
|
||||
void RemoveFromSubsetOf(WinBorder* main);
|
||||
|
||||
void UpdateColors(void);
|
||||
void UpdateDecorator(void);
|
||||
void UpdateFont(void);
|
||||
void UpdateScreen(void);
|
||||
|
||||
void SetFocus(const bool &active);
|
||||
ServerWindow* Window(void) const { return _win; }
|
||||
Decorator* GetDecorator(void) const { return _decorator; }
|
||||
|
||||
WinBorder* MainWinBorder() const;
|
||||
void SetLevel();
|
||||
|
||||
void AddToSubsetOf(WinBorder* main);
|
||||
void RemoveFromSubsetOf(WinBorder* main);
|
||||
|
||||
void PrintToStream();
|
||||
void PrintToStream();
|
||||
|
||||
// Server "private" :-) - should not be used
|
||||
void SetMainWinBorder(WinBorder *newMain);
|
||||
|
||||
void SetMainWinBorder(WinBorder *newMain);
|
||||
|
||||
protected:
|
||||
ServerWindow *_win;
|
||||
//BString *_title;
|
||||
Decorator *_decorator;
|
||||
int32 _flags;
|
||||
BRect _clientframe;
|
||||
int32 _mbuttons,
|
||||
_kmodifiers;
|
||||
BPoint fLastMousePosition;
|
||||
bool _update;
|
||||
bool _hresizewin,_vresizewin;
|
||||
ServerWindow *fWindow;
|
||||
Decorator *fDecorator;
|
||||
int32 fFlags;
|
||||
int32 fMouseButtons,
|
||||
fKeyModifiers;
|
||||
BPoint fLastMousePosition;
|
||||
|
||||
BRegion *fDecFull,
|
||||
*fDecFullVisible,
|
||||
*fDecVisible;
|
||||
BRegion *fDecFull;
|
||||
|
||||
WinBorder *fMainWinBorder;
|
||||
/* bool fIsMoving;
|
||||
bool fIsResizing;
|
||||
bool fIsClosing;
|
||||
bool fIsMinimizing;
|
||||
bool fIsZooming
|
||||
WinBorder *fMainWinBorder;
|
||||
/* bool fIsMoving;
|
||||
bool fIsResizing;
|
||||
bool fIsClosing;
|
||||
bool fIsMinimizing;
|
||||
bool fIsZooming;
|
||||
*/
|
||||
};
|
||||
|
||||
bool is_moving_window(void);
|
||||
void set_is_moving_window(bool state);
|
||||
bool is_resizing_window(void);
|
||||
void set_is_resizing_window(bool state);
|
||||
void set_active_winborder(WinBorder *win);
|
||||
WinBorder* get_active_winborder(void);
|
||||
void set_is_resizing_window(bool state);
|
||||
void set_is_sliding_tab(bool state);
|
||||
bool is_sliding_tab(void);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user