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: DefaultDecorator.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Description: Fallback decorator for the app_server
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
2003-07-07 23:48:38 +04:00
|
|
|
#include <Rect.h>
|
2003-02-13 05:13:55 +03:00
|
|
|
#include "DisplayDriver.h"
|
|
|
|
#include <View.h>
|
|
|
|
#include "LayerData.h"
|
|
|
|
#include "ColorUtils.h"
|
|
|
|
#include "DefaultDecorator.h"
|
2003-07-28 21:09:49 +04:00
|
|
|
#include "PatternHandler.h"
|
2003-02-13 05:13:55 +03:00
|
|
|
#include "RGBColor.h"
|
2003-07-24 23:38:24 +04:00
|
|
|
#include "RectUtils.h"
|
|
|
|
#include <stdio.h>
|
2003-04-05 05:51:35 +04:00
|
|
|
|
2003-09-04 01:43:09 +04:00
|
|
|
|
2003-03-31 01:09:39 +04:00
|
|
|
#define USE_VIEW_FILL_HACK
|
2003-03-23 23:52:37 +03:00
|
|
|
|
2003-08-31 21:38:34 +04:00
|
|
|
//#define DEBUG_DECORATOR
|
2003-03-23 23:52:37 +03:00
|
|
|
#ifdef DEBUG_DECORATOR
|
2003-09-09 01:48:35 +04:00
|
|
|
# include <stdio.h>
|
|
|
|
# define STRACE(x) printf x
|
|
|
|
#else
|
|
|
|
# define STRACE(x) ;
|
2003-03-23 23:52:37 +03:00
|
|
|
#endif
|
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
DefaultDecorator::DefaultDecorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
|
|
|
: Decorator(rect,wlook,wfeel,wflags)
|
|
|
|
{
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
taboffset=0;
|
2003-06-24 17:55:18 +04:00
|
|
|
titlepixelwidth=0;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
framecolors=new RGBColor[5];
|
|
|
|
framecolors[0].SetColor(255,255,255);
|
|
|
|
framecolors[1].SetColor(216,216,216);
|
|
|
|
framecolors[2].SetColor(152,152,152);
|
|
|
|
framecolors[3].SetColor(136,136,136);
|
|
|
|
framecolors[4].SetColor(96,96,96);
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// Set appropriate colors based on the current focus value. In this case, each decorator
|
|
|
|
// defaults to not having the focus.
|
2003-07-24 23:38:24 +04:00
|
|
|
_SetFocus();
|
2003-09-07 01:09:11 +04:00
|
|
|
|
|
|
|
// Do initial decorator setup
|
2003-02-13 05:13:55 +03:00
|
|
|
_DoLayout();
|
|
|
|
|
|
|
|
// This flag is used to determine whether or not we're moving the tab
|
|
|
|
slidetab=false;
|
|
|
|
|
2003-09-09 01:48:35 +04:00
|
|
|
// tab_highcol=_colors->window_tab;
|
|
|
|
// tab_lowcol=_colors->window_tab;
|
|
|
|
|
|
|
|
STRACE(("DefaultDecorator:\n"));
|
|
|
|
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DefaultDecorator::~DefaultDecorator(void)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("DefaultDecorator: ~DefaultDecorator()\n"));
|
2003-07-24 23:38:24 +04:00
|
|
|
delete [] framecolors;
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
click_type DefaultDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers)
|
|
|
|
{
|
2003-09-07 01:09:11 +04:00
|
|
|
#ifdef DEBUG_DECORATOR
|
|
|
|
printf("DefaultDecorator: Clicked\n");
|
|
|
|
printf("\tPoint: (%.1f,%.1f)\n",pt.x,pt.y);
|
|
|
|
printf("\tButtons:\n");
|
|
|
|
if(buttons==0)
|
|
|
|
printf("\t\tNone\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(buttons & B_PRIMARY_MOUSE_BUTTON)
|
|
|
|
printf("\t\tPrimary\n");
|
|
|
|
if(buttons & B_SECONDARY_MOUSE_BUTTON)
|
|
|
|
printf("\t\tSecondary\n");
|
|
|
|
if(buttons & B_TERTIARY_MOUSE_BUTTON)
|
|
|
|
printf("\t\tTertiary\n");
|
|
|
|
}
|
|
|
|
printf("\tModifiers:\n");
|
|
|
|
if(modifiers==0)
|
|
|
|
printf("\t\tNone\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(modifiers & B_CAPS_LOCK)
|
|
|
|
printf("\t\tCaps Lock\n");
|
|
|
|
if(modifiers & B_NUM_LOCK)
|
|
|
|
printf("\t\tNum Lock\n");
|
|
|
|
if(modifiers & B_SCROLL_LOCK)
|
|
|
|
printf("\t\tScroll Lock\n");
|
|
|
|
if(modifiers & B_LEFT_COMMAND_KEY)
|
|
|
|
printf("\t\t Left Command\n");
|
|
|
|
if(modifiers & B_RIGHT_COMMAND_KEY)
|
|
|
|
printf("\t\t Right Command\n");
|
|
|
|
if(modifiers & B_LEFT_CONTROL_KEY)
|
|
|
|
printf("\t\tLeft Control\n");
|
|
|
|
if(modifiers & B_RIGHT_CONTROL_KEY)
|
|
|
|
printf("\t\tRight Control\n");
|
|
|
|
if(modifiers & B_LEFT_OPTION_KEY)
|
|
|
|
printf("\t\tLeft Option\n");
|
|
|
|
if(modifiers & B_RIGHT_OPTION_KEY)
|
|
|
|
printf("\t\tRight Option\n");
|
|
|
|
if(modifiers & B_LEFT_SHIFT_KEY)
|
|
|
|
printf("\t\tLeft Shift\n");
|
|
|
|
if(modifiers & B_RIGHT_SHIFT_KEY)
|
|
|
|
printf("\t\tRight Shift\n");
|
|
|
|
if(modifiers & B_MENU_KEY)
|
|
|
|
printf("\t\tMenu\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// In checking for hit test stuff, we start with the smallest rectangles the user might
|
|
|
|
// be clicking on and gradually work our way out into larger rectangles.
|
2003-02-13 05:13:55 +03:00
|
|
|
if(_closerect.Contains(pt))
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_CLOSE;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
if(_zoomrect.Contains(pt))
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_ZOOM;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
if(_resizerect.Contains(pt) && _look==B_DOCUMENT_WINDOW_LOOK)
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_RESIZE;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
// Clicking in the tab?
|
|
|
|
if(_tabrect.Contains(pt))
|
|
|
|
{
|
|
|
|
// Here's part of our window management stuff
|
|
|
|
if(buttons==B_SECONDARY_MOUSE_BUTTON)
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_MOVETOBACK;
|
|
|
|
return DEC_DRAG;
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// We got this far, so user is clicking on the border?
|
|
|
|
BRect brect(_frame);
|
|
|
|
brect.top+=19;
|
|
|
|
BRect clientrect(brect.InsetByCopy(3,3));
|
|
|
|
if(brect.Contains(pt) && !clientrect.Contains(pt))
|
|
|
|
{
|
|
|
|
if(_resizerect.Contains(pt))
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_RESIZE;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_DRAG;
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Guess user didn't click anything
|
2003-11-15 03:27:26 +03:00
|
|
|
return DEC_NONE;
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::_DoLayout(void)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("DefaultDecorator: Do Layout\n"));
|
2003-02-13 05:13:55 +03:00
|
|
|
// Here we determine the size of every rectangle that we use
|
|
|
|
// internally when we are given the size of the client rectangle.
|
2003-07-28 21:09:49 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
switch(GetLook())
|
|
|
|
{
|
2003-07-28 21:09:49 +04:00
|
|
|
case B_FLOATING_WINDOW_LOOK:
|
|
|
|
case B_MODAL_WINDOW_LOOK:
|
|
|
|
|
|
|
|
// We're going to make the frame 5 pixels wide, no matter what. R5's decorator frame
|
|
|
|
// requires the skills of a gaming master to click on the tiny frame if resizing is necessary,
|
|
|
|
// and there *are* apps which do this
|
|
|
|
// borderwidth=3;
|
|
|
|
// break;
|
2003-09-07 01:09:11 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
case B_BORDERED_WINDOW_LOOK:
|
|
|
|
case B_TITLED_WINDOW_LOOK:
|
|
|
|
case B_DOCUMENT_WINDOW_LOOK:
|
2003-08-31 21:38:34 +04:00
|
|
|
borderwidth = 5;
|
2003-07-24 23:38:24 +04:00
|
|
|
break;
|
|
|
|
default:
|
2003-08-31 21:38:34 +04:00
|
|
|
borderwidth = 0;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// distance from one item of the tab bar to another. In this case the text and close/zoom rects
|
2003-08-31 21:38:34 +04:00
|
|
|
textoffset = (_look==B_FLOATING_WINDOW_LOOK) ? 7 : 10;
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// calculate our tab rect
|
2003-08-31 21:38:34 +04:00
|
|
|
_tabrect.Set( _frame.left - borderwidth,
|
|
|
|
_frame.top - borderwidth - 19.0,
|
|
|
|
((_frame.right - _frame.left) < 35.0 ?
|
|
|
|
_frame.left + 35.0 : _frame.right) + borderwidth,
|
|
|
|
_frame.top - (borderwidth-1) );
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// make it text width sensitive
|
2003-08-31 21:38:34 +04:00
|
|
|
if(strlen(GetTitle())>1)
|
|
|
|
{
|
|
|
|
if(_driver)
|
|
|
|
titlepixelwidth=_driver->StringWidth(GetTitle(),_TitleWidth(), &_layerdata);
|
|
|
|
else
|
|
|
|
titlepixelwidth=10;
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
int32 tabLength = int32(14 + // _closerect width
|
2003-08-31 21:38:34 +04:00
|
|
|
textoffset + titlepixelwidth + textoffset +
|
|
|
|
14 + // _zoomrect width
|
2003-09-07 01:09:11 +04:00
|
|
|
8); // margins
|
2003-08-31 21:38:34 +04:00
|
|
|
int32 tabWidth = (int32)_tabrect.Width();
|
|
|
|
if ( tabLength < tabWidth )
|
|
|
|
_tabrect.right = _tabrect.left + tabLength;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_tabrect.right = _tabrect.left + _tabrect.Width()/2;
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// calculate left/top/right/bottom borders
|
2003-08-31 21:38:34 +04:00
|
|
|
if ( borderwidth != 0 ){
|
|
|
|
_borderrect = _frame.InsetByCopy( -borderwidth, -borderwidth );
|
|
|
|
leftborder.Set( _borderrect.left, _frame.top - borderwidth,
|
|
|
|
_frame.left, _frame.bottom + borderwidth );
|
|
|
|
rightborder.Set( _frame.right, _frame.top - borderwidth,
|
|
|
|
_borderrect.right, _frame.bottom + borderwidth );
|
|
|
|
topborder.Set( _borderrect.left, _borderrect.top,
|
|
|
|
_borderrect.right, _frame.top );
|
|
|
|
bottomborder.Set( _borderrect.left, _frame.bottom,
|
|
|
|
_borderrect.right, _borderrect.bottom );
|
|
|
|
}
|
|
|
|
else{
|
2003-09-07 01:09:11 +04:00
|
|
|
// no border ... (?) useful when displaying windows that are just images
|
2003-08-31 21:38:34 +04:00
|
|
|
_borderrect = _frame;
|
|
|
|
leftborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
|
|
|
rightborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
|
|
|
topborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
|
|
|
bottomborder.Set( 0.0, 0.0, -1.0, -1.0 );
|
|
|
|
}
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// calculate resize rect
|
2003-08-31 21:38:34 +04:00
|
|
|
_resizerect.Set( _borderrect.right - 19.0, _borderrect.bottom - 19.0,
|
|
|
|
_borderrect.right, _borderrect.bottom);
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// format tab rect for a floating window - make the rect smaller
|
2003-08-31 21:38:34 +04:00
|
|
|
if ( _look == B_FLOATING_WINDOW_LOOK ){
|
|
|
|
_tabrect.InsetBy( 0, 2 );
|
|
|
|
_tabrect.OffsetBy( 0, 2 );
|
|
|
|
}
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// calulate close rect based on the tab rectangle
|
2003-08-31 21:38:34 +04:00
|
|
|
_closerect.Set( _tabrect.left + 4.0, _tabrect.top + 4.0,
|
|
|
|
_tabrect.left + 4.0 + 13.0, _tabrect.top + 4.0 + 13.0 );
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// calulate zoom rect based on the tab rectangle
|
2003-08-31 21:38:34 +04:00
|
|
|
_zoomrect.Set( _tabrect.right - 4.0 - 13.0, _tabrect.top + 4.0,
|
|
|
|
_tabrect.right - 4.0, _tabrect.top + 4.0 + 13.0 );
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// format close and zoom rects for a floating window - make rectangles smaller
|
2003-08-31 21:38:34 +04:00
|
|
|
if ( _look == B_FLOATING_WINDOW_LOOK ){
|
|
|
|
_closerect.InsetBy( 1, 1 );
|
|
|
|
_zoomrect.InsetBy( 1, 1 );
|
|
|
|
_closerect.OffsetBy( 0, -2 );
|
|
|
|
_zoomrect.OffsetBy( 0, -2 );
|
|
|
|
}
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::MoveBy(float x, float y)
|
|
|
|
{
|
|
|
|
MoveBy(BPoint(x,y));
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::MoveBy(BPoint pt)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("DefaultDecorator: Move By (%.1f, %.1f)\n",pt.x,pt.y));
|
2003-02-13 05:13:55 +03:00
|
|
|
// Move all internal rectangles the appropriate amount
|
|
|
|
_frame.OffsetBy(pt);
|
|
|
|
_closerect.OffsetBy(pt);
|
|
|
|
_tabrect.OffsetBy(pt);
|
|
|
|
_resizerect.OffsetBy(pt);
|
|
|
|
_borderrect.OffsetBy(pt);
|
|
|
|
_zoomrect.OffsetBy(pt);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
|
|
|
leftborder.OffsetBy(pt);
|
|
|
|
rightborder.OffsetBy(pt);
|
|
|
|
topborder.OffsetBy(pt);
|
|
|
|
bottomborder.OffsetBy(pt);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
2003-09-17 21:14:22 +04:00
|
|
|
void DefaultDecorator::GetFootprint(BRegion *region)
|
2003-02-13 05:13:55 +03:00
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("DefaultDecorator: Get Footprint\n"));
|
2003-02-13 05:13:55 +03:00
|
|
|
// This function calculates the decorator's footprint in coordinates
|
2003-02-14 04:53:53 +03:00
|
|
|
// relative to the layer. This is most often used to set a WinBorder
|
2003-02-13 05:13:55 +03:00
|
|
|
// object's visible region.
|
2003-09-17 21:14:22 +04:00
|
|
|
if(!region)
|
|
|
|
return;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-09-17 21:14:22 +04:00
|
|
|
region->Set(_borderrect);
|
|
|
|
region->Include(_tabrect);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
2003-09-04 01:43:09 +04:00
|
|
|
BRect DefaultDecorator::SlideTab(float dx, float dy=0){
|
|
|
|
//return Decorator::SlideTab(dx,dy);
|
|
|
|
return _tabrect;
|
|
|
|
}
|
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
void DefaultDecorator::_DrawTitle(BRect r)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("_DrawTitle(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
2003-02-13 05:13:55 +03:00
|
|
|
// Designed simply to redraw the title when it has changed on
|
|
|
|
// the client side.
|
2003-06-24 17:55:18 +04:00
|
|
|
_layerdata.highcolor=_colors->window_tab_text;
|
2003-07-07 23:48:38 +04:00
|
|
|
_layerdata.lowcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab;
|
|
|
|
|
2003-08-31 21:38:34 +04:00
|
|
|
int32 titlecount=_ClipTitle((_zoomrect.left-textoffset)-(_closerect.right+textoffset));
|
|
|
|
BString titlestr( GetTitle() );
|
|
|
|
|
2003-07-07 23:48:38 +04:00
|
|
|
if(titlecount<titlestr.CountChars())
|
|
|
|
{
|
|
|
|
titlestr.Truncate(titlecount-1);
|
|
|
|
titlestr+="...";
|
|
|
|
titlecount+=2;
|
|
|
|
}
|
2003-09-07 01:09:11 +04:00
|
|
|
|
|
|
|
// The text position needs tweaked when working as a floating window because the closerect placement
|
|
|
|
// is a little different. If it isn't moved, title placement looks really funky
|
|
|
|
if(_look==B_FLOATING_WINDOW_LOOK)
|
|
|
|
_driver->DrawString(titlestr.String(),titlecount,
|
|
|
|
BPoint(_closerect.right+textoffset,_closerect.bottom+1),&_layerdata);
|
|
|
|
else
|
2003-07-07 23:48:38 +04:00
|
|
|
_driver->DrawString(titlestr.String(),titlecount,
|
2003-09-07 01:09:11 +04:00
|
|
|
BPoint(_closerect.right+textoffset,_closerect.bottom),&_layerdata);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::_SetFocus(void)
|
|
|
|
{
|
|
|
|
// SetFocus() performs necessary duties for color swapping and
|
|
|
|
// other things when a window is deactivated or activated.
|
|
|
|
|
2003-09-07 01:09:11 +04:00
|
|
|
// Removed Adi's short-term color hack and replaced with a more palatable substitute for the old,
|
|
|
|
// dark colors
|
2003-02-13 05:13:55 +03:00
|
|
|
if(GetFocus())
|
|
|
|
{
|
2003-09-07 01:09:11 +04:00
|
|
|
button_highcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_LIGHTEN_2_TINT));
|
|
|
|
button_lowcol.SetColor(tint_color(_colors->window_tab.GetColor32(),B_DARKEN_1_TINT));
|
2003-07-07 23:48:38 +04:00
|
|
|
textcol=_colors->window_tab_text;
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-09-07 01:09:11 +04:00
|
|
|
button_highcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_LIGHTEN_2_TINT));
|
|
|
|
button_lowcol.SetColor(tint_color(_colors->inactive_window_tab.GetColor32(),B_DARKEN_1_TINT));
|
2003-07-07 23:48:38 +04:00
|
|
|
textcol=_colors->inactive_window_tab_text;
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::Draw(BRect update)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("DefaultDecorator: Draw(%.1f,%.1f,%.1f,%.1f)\n",update.left,update.top,update.right,update.bottom));
|
2003-02-13 05:13:55 +03:00
|
|
|
// We need to draw a few things: the tab, the resize thumb, the borders,
|
|
|
|
// and the buttons
|
|
|
|
|
|
|
|
_DrawFrame(update);
|
2003-08-31 21:38:34 +04:00
|
|
|
_DrawTab(update);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::Draw(void)
|
|
|
|
{
|
|
|
|
// Easy way to draw everything - no worries about drawing only certain
|
|
|
|
// things
|
|
|
|
|
2003-09-04 01:43:09 +04:00
|
|
|
_DrawFrame(_borderrect);
|
|
|
|
_DrawTab(_tabrect);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::_DrawZoom(BRect r)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("_DrawZoom(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
2003-02-13 05:13:55 +03:00
|
|
|
// If this has been implemented, then the decorator has a Zoom button
|
|
|
|
// which should be drawn based on the state of the member zoomstate
|
2003-08-31 21:38:34 +04:00
|
|
|
BRect zr( r );
|
|
|
|
|
|
|
|
zr.left += 3.0;
|
|
|
|
zr.top += 3.0;
|
|
|
|
DrawBlendedRect( zr, GetZoom() );
|
|
|
|
|
|
|
|
zr = r;
|
|
|
|
zr.right -= 5.0;
|
|
|
|
zr.bottom -= 5.0;
|
|
|
|
DrawBlendedRect( zr, GetZoom() );
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::_DrawClose(BRect r)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("_DrawClose(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
2003-02-13 05:13:55 +03:00
|
|
|
// Just like DrawZoom, but for a close button
|
2003-08-31 21:38:34 +04:00
|
|
|
DrawBlendedRect( r, GetClose());
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void DefaultDecorator::_DrawTab(BRect r)
|
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("_DrawTab(%f,%f,%f,%f)\n", r.left, r.top, r.right, r.bottom));
|
2003-02-13 05:13:55 +03:00
|
|
|
// If a window has a tab, this will draw it and any buttons which are
|
|
|
|
// in it.
|
|
|
|
if(_look==B_NO_BORDER_WINDOW_LOOK)
|
|
|
|
return;
|
|
|
|
|
2003-07-07 23:48:38 +04:00
|
|
|
_layerdata.highcolor=(GetFocus())?_colors->window_tab:_colors->inactive_window_tab;
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->FillRect(_tabrect,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
|
|
|
_layerdata.highcolor=framecolors[2];
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->StrokeLine(_tabrect.LeftTop(),_tabrect.LeftBottom(),_layerdata.pensize,_layerdata.highcolor);
|
|
|
|
_driver->StrokeLine(_tabrect.LeftTop(),_tabrect.RightTop(),_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_layerdata.highcolor=framecolors[4];
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->StrokeLine(_tabrect.RightTop(),_tabrect.RightBottom(),_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_layerdata.highcolor=framecolors[1];
|
|
|
|
_driver->StrokeLine( BPoint( _tabrect.left + 2, _tabrect.bottom ),
|
|
|
|
BPoint( _tabrect.right - 2, _tabrect.bottom ),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
|
|
|
_layerdata.highcolor = RGBColor( 255, 255, 0 );
|
|
|
|
_driver->StrokeLine( BPoint( _tabrect.left + 1, _tabrect.top + 1),
|
|
|
|
BPoint( _tabrect.left + 1, _tabrect.bottom),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_driver->StrokeLine( BPoint( _tabrect.left + 1, _tabrect.top + 1),
|
|
|
|
BPoint( _tabrect.right - 1, _tabrect.top + 1),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
|
|
|
_layerdata.highcolor = RGBColor( 175, 123, 0 );
|
|
|
|
_driver->StrokeLine( BPoint( _tabrect.right - 1, _tabrect.top + 2),
|
|
|
|
BPoint( _tabrect.right - 1, _tabrect.bottom),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-06-24 17:55:18 +04:00
|
|
|
_DrawTitle(_tabrect);
|
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
// Draw the buttons if we're supposed to
|
|
|
|
if(!(_flags & B_NOT_CLOSABLE))
|
|
|
|
_DrawClose(_closerect);
|
|
|
|
if(!(_flags & B_NOT_ZOOMABLE))
|
|
|
|
_DrawZoom(_zoomrect);
|
|
|
|
}
|
|
|
|
|
2003-07-07 17:09:42 +04:00
|
|
|
void DefaultDecorator::_SetColors(void)
|
|
|
|
{
|
|
|
|
_SetFocus();
|
|
|
|
}
|
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
void DefaultDecorator::DrawBlendedRect(BRect r, bool down)
|
|
|
|
{
|
|
|
|
// This bad boy is used to draw a rectangle with a gradient.
|
|
|
|
// Note that it is not part of the Decorator API - it's specific
|
|
|
|
// to just the DefaultDecorator. Called by DrawZoom and DrawClose
|
|
|
|
|
2003-08-31 21:38:34 +04:00
|
|
|
_layerdata.highcolor = RGBColor( 175, 123, 0 );
|
|
|
|
_driver->StrokeLine( r.LeftTop(),
|
|
|
|
BPoint( r.left, r.bottom - 1 ),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_driver->StrokeLine( r.LeftTop(),
|
|
|
|
BPoint( r.right - 1, r.top ),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_driver->StrokeLine( BPoint( r.right - 1, r.top + 2),
|
|
|
|
BPoint( r.right - 1, r.bottom - 1),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_driver->StrokeLine( BPoint( r.left + 2, r.bottom -1),
|
|
|
|
BPoint( r.right - 2, r.bottom - 1),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
|
|
|
_layerdata.highcolor = RGBColor( 255, 255, 0 );
|
|
|
|
_driver->StrokeRect( BRect( r.left + 1, r.top + 1,
|
|
|
|
r.right, r.bottom),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
|
|
|
|
r.InsetBy( 2, 2 );
|
|
|
|
|
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
int32 w=r.IntegerWidth(), h=r.IntegerHeight();
|
|
|
|
|
|
|
|
rgb_color tmpcol,halfcol, startcol, endcol;
|
|
|
|
float rstep,gstep,bstep,i;
|
|
|
|
|
|
|
|
int steps=(w<h)?w:h;
|
|
|
|
|
|
|
|
if(down)
|
|
|
|
{
|
|
|
|
startcol=button_lowcol.GetColor32();
|
|
|
|
endcol=button_highcol.GetColor32();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
startcol=button_highcol.GetColor32();
|
|
|
|
endcol=button_lowcol.GetColor32();
|
|
|
|
}
|
|
|
|
|
|
|
|
halfcol=MakeBlendColor(startcol,endcol,0.5);
|
|
|
|
|
|
|
|
rstep=float(startcol.red-halfcol.red)/steps;
|
|
|
|
gstep=float(startcol.green-halfcol.green)/steps;
|
|
|
|
bstep=float(startcol.blue-halfcol.blue)/steps;
|
|
|
|
|
|
|
|
for(i=0;i<=steps; i++)
|
|
|
|
{
|
|
|
|
SetRGBColor(&tmpcol, uint8(startcol.red-(i*rstep)),
|
|
|
|
uint8(startcol.green-(i*gstep)),
|
|
|
|
uint8(startcol.blue-(i*bstep)));
|
|
|
|
_layerdata.highcolor=tmpcol;
|
|
|
|
_driver->StrokeLine(BPoint(r.left,r.top+i),
|
2003-12-07 06:22:15 +03:00
|
|
|
BPoint(r.left+i,r.top),_layerdata.pensize,_layerdata.highcolor);
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
|
|
|
|
uint8(halfcol.green-(i*gstep)),
|
|
|
|
uint8(halfcol.blue-(i*bstep)));
|
|
|
|
|
|
|
|
_layerdata.highcolor=tmpcol;
|
|
|
|
_driver->StrokeLine(BPoint(r.left+steps,r.top+i),
|
2003-12-07 06:22:15 +03:00
|
|
|
BPoint(r.left+i,r.top+steps),_layerdata.pensize,_layerdata.highcolor);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
void DefaultDecorator::_DrawFrame(BRect invalid)
|
2003-02-13 05:13:55 +03:00
|
|
|
{
|
2003-09-09 01:48:35 +04:00
|
|
|
STRACE(("_DrawFrame(%f,%f,%f,%f)\n", invalid.left, invalid.top,
|
|
|
|
invalid.right, invalid.bottom));
|
2003-07-24 23:38:24 +04:00
|
|
|
// We need to test each side to determine whether or not it needs drawn. Additionally,
|
|
|
|
// we must clip the lines drawn by this function to the invalid rectangle we are given
|
|
|
|
|
|
|
|
#ifdef USE_VIEW_FILL_HACK
|
2003-09-04 01:43:09 +04:00
|
|
|
_layerdata.highcolor = RGBColor( 255, 255, 255 );
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->FillRect(_frame,_layerdata.highcolor);
|
2003-07-24 23:38:24 +04:00
|
|
|
#endif
|
2003-03-31 01:09:39 +04:00
|
|
|
|
2003-08-31 21:38:34 +04:00
|
|
|
if(!borderwidth){
|
2003-02-13 05:13:55 +03:00
|
|
|
return;
|
2003-08-31 21:38:34 +04:00
|
|
|
}
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
// Data specifically for the StrokeLineArray call.
|
|
|
|
int32 numlines=0, maxlines=20;
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
BPoint points[maxlines*2];
|
|
|
|
RGBColor colors[maxlines];
|
|
|
|
|
|
|
|
// For quick calculation of gradients for each side. Top is same as left, right is same as
|
|
|
|
// bottom
|
2003-07-27 04:24:07 +04:00
|
|
|
// int8 rightindices[borderwidth],leftindices[borderwidth];
|
|
|
|
int8 *rightindices=new int8[borderwidth],
|
|
|
|
*leftindices=new int8[borderwidth];
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
if(borderwidth==5)
|
|
|
|
{
|
|
|
|
leftindices[0]=2;
|
|
|
|
leftindices[1]=0;
|
|
|
|
leftindices[2]=1;
|
|
|
|
leftindices[3]=3;
|
|
|
|
leftindices[4]=2;
|
|
|
|
|
|
|
|
rightindices[0]=2;
|
|
|
|
rightindices[1]=0;
|
|
|
|
rightindices[2]=1;
|
|
|
|
rightindices[3]=3;
|
|
|
|
rightindices[4]=4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// TODO: figure out border colors for floating window look
|
2003-07-28 21:09:49 +04:00
|
|
|
leftindices[0]=2;
|
|
|
|
leftindices[1]=2;
|
|
|
|
leftindices[2]=1;
|
|
|
|
leftindices[3]=1;
|
|
|
|
leftindices[4]=4;
|
|
|
|
|
|
|
|
rightindices[0]=2;
|
|
|
|
rightindices[1]=2;
|
|
|
|
rightindices[2]=1;
|
|
|
|
rightindices[3]=1;
|
|
|
|
rightindices[4]=4;
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
|
|
|
|
2003-07-27 04:24:07 +04:00
|
|
|
// Variables used in each calculation
|
|
|
|
int32 startx,endx,starty,endy,i;
|
|
|
|
bool topcorner,bottomcorner,leftcorner,rightcorner;
|
|
|
|
int8 step,colorindex;
|
|
|
|
BRect r;
|
|
|
|
BPoint start, end;
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
// Right side
|
|
|
|
if(TestRectIntersection(rightborder,invalid))
|
|
|
|
{
|
|
|
|
// We may not have to redraw the entire width of the frame itself. Rare case, but
|
|
|
|
// it must be accounted for.
|
2003-07-27 04:24:07 +04:00
|
|
|
startx=(int32) MAX(invalid.left,rightborder.left);
|
|
|
|
endx=(int32) MIN(invalid.right,rightborder.right);
|
2003-07-24 23:38:24 +04:00
|
|
|
|
|
|
|
// We'll need these flags to see if we must include the corners in final line
|
|
|
|
// calculations
|
2003-07-27 04:24:07 +04:00
|
|
|
r=(rightborder);
|
2003-07-24 23:38:24 +04:00
|
|
|
r.bottom=r.top+borderwidth;
|
2003-07-27 04:24:07 +04:00
|
|
|
topcorner=TestRectIntersection(invalid,r);
|
2003-07-24 23:38:24 +04:00
|
|
|
|
|
|
|
r=rightborder;
|
|
|
|
r.top=r.bottom-borderwidth;
|
2003-07-27 04:24:07 +04:00
|
|
|
bottomcorner=TestRectIntersection(invalid,r);
|
|
|
|
step=(borderwidth==5)?1:2;
|
|
|
|
colorindex=0;
|
2003-07-24 23:38:24 +04:00
|
|
|
|
|
|
|
// Generate the lines for this side
|
2003-07-27 04:24:07 +04:00
|
|
|
for(i=startx+1; i<=endx; i++)
|
2003-07-24 23:38:24 +04:00
|
|
|
{
|
|
|
|
start.x=end.x=i;
|
|
|
|
|
|
|
|
if(topcorner)
|
|
|
|
{
|
|
|
|
start.y=rightborder.top+(borderwidth-(i-rightborder.left));
|
|
|
|
start.y=MAX(start.y,invalid.top);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
start.y=MAX(start.y+borderwidth,invalid.top);
|
|
|
|
|
|
|
|
if(bottomcorner)
|
|
|
|
{
|
|
|
|
end.y=rightborder.bottom-(borderwidth-(i-rightborder.left));
|
2003-07-27 04:24:07 +04:00
|
|
|
end.y=MIN(end.y,invalid.bottom);
|
2003-07-24 23:38:24 +04:00
|
|
|
}
|
|
|
|
else
|
2003-07-27 04:24:07 +04:00
|
|
|
end.y=MIN(end.y-borderwidth,invalid.bottom);
|
|
|
|
|
|
|
|
// Make the appropriate
|
|
|
|
points[numlines*2]=start;
|
|
|
|
points[(numlines*2)+1]=end;
|
|
|
|
colors[numlines]=framecolors[rightindices[colorindex]];
|
|
|
|
colorindex+=step;
|
|
|
|
numlines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Left side
|
|
|
|
if(TestRectIntersection(leftborder,invalid))
|
|
|
|
{
|
|
|
|
// We may not have to redraw the entire width of the frame itself. Rare case, but
|
|
|
|
// it must be accounted for.
|
|
|
|
startx=(int32) MAX(invalid.left,leftborder.left);
|
|
|
|
endx=(int32) MIN(invalid.right,leftborder.right);
|
|
|
|
|
|
|
|
// We'll need these flags to see if we must include the corners in final line
|
|
|
|
// calculations
|
|
|
|
r=leftborder;
|
|
|
|
r.bottom=r.top+borderwidth;
|
|
|
|
topcorner=TestRectIntersection(invalid,r);
|
|
|
|
|
|
|
|
r=leftborder;
|
|
|
|
r.top=r.bottom-borderwidth;
|
|
|
|
bottomcorner=TestRectIntersection(invalid,r);
|
|
|
|
step=(borderwidth==5)?1:2;
|
|
|
|
colorindex=0;
|
|
|
|
|
|
|
|
// Generate the lines for this side
|
|
|
|
for(i=startx; i<endx; i++)
|
|
|
|
{
|
|
|
|
start.x=end.x=i;
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2003-07-27 04:24:07 +04:00
|
|
|
if(topcorner)
|
|
|
|
{
|
|
|
|
start.y=leftborder.top+(i-leftborder.left);
|
|
|
|
start.y=MAX(start.y,invalid.top);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
start.y=MAX(start.y+borderwidth,invalid.top);
|
|
|
|
|
|
|
|
if(bottomcorner)
|
|
|
|
{
|
|
|
|
end.y=leftborder.bottom-(i-leftborder.left);
|
|
|
|
end.y=MIN(end.y,invalid.bottom);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
end.y=MIN(end.y-borderwidth,invalid.bottom);
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
// Make the appropriate
|
|
|
|
points[numlines*2]=start;
|
|
|
|
points[(numlines*2)+1]=end;
|
2003-07-27 04:24:07 +04:00
|
|
|
colors[numlines]=framecolors[leftindices[colorindex]];
|
|
|
|
colorindex+=step;
|
|
|
|
numlines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top side
|
|
|
|
if(TestRectIntersection(topborder,invalid))
|
|
|
|
{
|
|
|
|
// We may not have to redraw the entire width of the frame itself. Rare case, but
|
|
|
|
// it must be accounted for.
|
|
|
|
starty=(int32) MAX(invalid.top,topborder.top);
|
|
|
|
endy=(int32) MIN(invalid.bottom,topborder.bottom);
|
|
|
|
|
|
|
|
// We'll need these flags to see if we must include the corners in final line
|
|
|
|
// calculations
|
|
|
|
r=topborder;
|
|
|
|
r.bottom=r.top+borderwidth;
|
|
|
|
r.right=r.left+borderwidth;
|
|
|
|
leftcorner=TestRectIntersection(invalid,r);
|
|
|
|
|
|
|
|
r=topborder;
|
|
|
|
r.top=r.bottom-borderwidth;
|
|
|
|
r.left=r.right-borderwidth;
|
|
|
|
|
|
|
|
rightcorner=TestRectIntersection(invalid,r);
|
|
|
|
step=(borderwidth==5)?1:2;
|
|
|
|
colorindex=0;
|
|
|
|
|
|
|
|
// Generate the lines for this side
|
|
|
|
for(i=starty; i<endy; i++)
|
|
|
|
{
|
|
|
|
start.y=end.y=i;
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2003-07-27 04:24:07 +04:00
|
|
|
if(leftcorner)
|
|
|
|
{
|
|
|
|
start.x=topborder.left+(i-topborder.top);
|
|
|
|
start.x=MAX(start.x,invalid.left);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
start.x=MAX(start.x+borderwidth,invalid.left);
|
|
|
|
|
|
|
|
if(rightcorner)
|
|
|
|
{
|
|
|
|
end.x=topborder.right-(i-topborder.top);
|
|
|
|
end.x=MIN(end.x,invalid.right);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
end.x=MIN(end.x-borderwidth,invalid.right);
|
|
|
|
|
|
|
|
// Make the appropriate
|
|
|
|
points[numlines*2]=start;
|
|
|
|
points[(numlines*2)+1]=end;
|
|
|
|
|
|
|
|
// Top side uses the same color order as the left one
|
|
|
|
colors[numlines]=framecolors[leftindices[colorindex]];
|
|
|
|
colorindex+=step;
|
2003-07-24 23:38:24 +04:00
|
|
|
numlines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-27 04:24:07 +04:00
|
|
|
// Bottom side
|
|
|
|
if(TestRectIntersection(bottomborder,invalid))
|
|
|
|
{
|
|
|
|
// We may not have to redraw the entire width of the frame itself. Rare case, but
|
|
|
|
// it must be accounted for.
|
|
|
|
starty=(int32) MAX(invalid.top,bottomborder.top);
|
|
|
|
endy=(int32) MIN(invalid.bottom,bottomborder.bottom);
|
|
|
|
|
|
|
|
// We'll need these flags to see if we must include the corners in final line
|
|
|
|
// calculations
|
|
|
|
r=bottomborder;
|
|
|
|
r.bottom=r.top+borderwidth;
|
|
|
|
r.right=r.left+borderwidth;
|
|
|
|
leftcorner=TestRectIntersection(invalid,r);
|
|
|
|
|
|
|
|
r=bottomborder;
|
|
|
|
r.top=r.bottom-borderwidth;
|
|
|
|
r.left=r.right-borderwidth;
|
|
|
|
|
|
|
|
rightcorner=TestRectIntersection(invalid,r);
|
|
|
|
step=(borderwidth==5)?1:2;
|
|
|
|
colorindex=0;
|
|
|
|
|
|
|
|
// Generate the lines for this side
|
|
|
|
for(i=starty+1; i<=endy; i++)
|
|
|
|
{
|
|
|
|
start.y=end.y=i;
|
|
|
|
|
|
|
|
if(leftcorner)
|
|
|
|
{
|
|
|
|
start.x=bottomborder.left+(borderwidth-(i-bottomborder.top));
|
|
|
|
start.x=MAX(start.x,invalid.left);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
start.x=MAX(start.x+borderwidth,invalid.left);
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-07-27 04:24:07 +04:00
|
|
|
if(rightcorner)
|
|
|
|
{
|
|
|
|
end.x=bottomborder.right-(borderwidth-(i-bottomborder.top));
|
|
|
|
end.x=MIN(end.x,invalid.right);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
end.x=MIN(end.x-borderwidth,invalid.right);
|
|
|
|
|
|
|
|
// Make the appropriate
|
|
|
|
points[numlines*2]=start;
|
|
|
|
points[(numlines*2)+1]=end;
|
|
|
|
|
|
|
|
// Top side uses the same color order as the left one
|
|
|
|
colors[numlines]=framecolors[rightindices[colorindex]];
|
|
|
|
colorindex+=step;
|
|
|
|
numlines++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->StrokeLineArray(points,numlines,_layerdata.pensize,colors);
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2003-07-27 04:24:07 +04:00
|
|
|
delete rightindices;
|
|
|
|
delete leftindices;
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2003-07-28 21:09:49 +04:00
|
|
|
// Draw the resize thumb if we're supposed to
|
2003-02-13 05:13:55 +03:00
|
|
|
if(!(_flags & B_NOT_RESIZABLE))
|
|
|
|
{
|
|
|
|
r=_resizerect;
|
2003-07-28 21:09:49 +04:00
|
|
|
// int32 w=r.IntegerWidth(), h=r.IntegerHeight();
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
// This code is strictly for B_DOCUMENT_WINDOW looks
|
|
|
|
if(_look==B_DOCUMENT_WINDOW_LOOK)
|
|
|
|
{
|
2003-07-28 21:09:49 +04:00
|
|
|
r.right-=4;
|
|
|
|
r.bottom-=4;
|
|
|
|
_layerdata.highcolor=framecolors[2];
|
2003-07-28 23:13:24 +04:00
|
|
|
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->StrokeLine(r.LeftTop(),r.RightTop(),_layerdata.pensize,_layerdata.highcolor);
|
|
|
|
_driver->StrokeLine(r.LeftTop(),r.LeftBottom(),_layerdata.pensize,_layerdata.highcolor);
|
2003-07-28 21:09:49 +04:00
|
|
|
|
|
|
|
r.OffsetBy(1,1);
|
|
|
|
_layerdata.highcolor=framecolors[0];
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->StrokeLine(r.LeftTop(),r.RightTop(),_layerdata.pensize,_layerdata.highcolor);
|
|
|
|
_driver->StrokeLine(r.LeftTop(),r.LeftBottom(),_layerdata.pensize,_layerdata.highcolor);
|
2003-07-28 21:09:49 +04:00
|
|
|
|
|
|
|
r.OffsetBy(1,1);
|
|
|
|
_layerdata.highcolor=framecolors[1];
|
2003-12-07 06:22:15 +03:00
|
|
|
_driver->FillRect(r,_layerdata.highcolor);
|
2003-07-28 21:09:49 +04:00
|
|
|
|
|
|
|
/* r.left+=2;
|
|
|
|
r.top+=2;
|
|
|
|
r.right-=3;
|
|
|
|
r.bottom-=3;
|
|
|
|
*/
|
|
|
|
r.right-=2;
|
|
|
|
r.bottom-=2;
|
|
|
|
int32 w=r.IntegerWidth(), h=r.IntegerHeight();
|
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
rgb_color halfcol, startcol, endcol;
|
|
|
|
float rstep,gstep,bstep,i;
|
|
|
|
|
|
|
|
int steps=(w<h)?w:h;
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
startcol=framecolors[0].GetColor32();
|
|
|
|
endcol=framecolors[4].GetColor32();
|
2003-02-13 05:13:55 +03:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
halfcol=framecolors[0].MakeBlendColor(framecolors[4],0.5).GetColor32();
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
rstep=(startcol.red-halfcol.red)/steps;
|
|
|
|
gstep=(startcol.green-halfcol.green)/steps;
|
|
|
|
bstep=(startcol.blue-halfcol.blue)/steps;
|
2003-07-28 21:09:49 +04:00
|
|
|
|
|
|
|
// Explicitly locking the driver is normally unnecessary. However, we need to do
|
|
|
|
// this because we are rapidly drawing a series of calls which would not necessarily
|
|
|
|
// draw correctly if we didn't do so.
|
|
|
|
_driver->Lock();
|
2003-02-13 05:13:55 +03:00
|
|
|
for(i=0;i<=steps; i++)
|
|
|
|
{
|
|
|
|
_layerdata.highcolor.SetColor(uint8(startcol.red-(i*rstep)),
|
|
|
|
uint8(startcol.green-(i*gstep)),
|
|
|
|
uint8(startcol.blue-(i*bstep)));
|
|
|
|
|
|
|
|
_driver->StrokeLine(BPoint(r.left,r.top+i),
|
2003-12-07 06:22:15 +03:00
|
|
|
BPoint(r.left+i,r.top),_layerdata.pensize,_layerdata.highcolor);
|
2003-02-13 05:13:55 +03:00
|
|
|
|
|
|
|
_layerdata.highcolor.SetColor(uint8(halfcol.red-(i*rstep)),
|
|
|
|
uint8(halfcol.green-(i*gstep)),
|
|
|
|
uint8(halfcol.blue-(i*bstep)));
|
|
|
|
_driver->StrokeLine(BPoint(r.left+steps,r.top+i),
|
2003-12-07 06:22:15 +03:00
|
|
|
BPoint(r.left+i,r.top+steps),_layerdata.pensize,_layerdata.highcolor);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
2003-07-28 21:09:49 +04:00
|
|
|
_driver->Unlock();
|
|
|
|
// _layerdata.highcolor=framecolors[4];
|
2003-12-07 06:22:15 +03:00
|
|
|
// _driver->StrokeRect(r,_layerdata.pensize,_layerdata.highcolor);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-31 21:38:34 +04:00
|
|
|
_layerdata.highcolor=framecolors[2];
|
|
|
|
_driver->StrokeLine(BPoint(r.right-4,r.top),BPoint(r.right-2,r.top),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-08-31 21:38:34 +04:00
|
|
|
_driver->StrokeLine(BPoint(r.left,r.bottom-4),BPoint(r.left,r.bottom-2),
|
2003-12-07 06:22:15 +03:00
|
|
|
_layerdata.pensize,_layerdata.highcolor);
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|
|
|
|
}
|
2003-07-28 21:09:49 +04:00
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
|
2003-02-13 05:13:55 +03:00
|
|
|
}
|