Initial checkin
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@870 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,486 @@
|
|||||||
|
#include "DisplayDriver.h"
|
||||||
|
#include <View.h>
|
||||||
|
#include "LayerData.h"
|
||||||
|
#include "ColorUtils.h"
|
||||||
|
#include "BeDecorator.h"
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
//#define DEBUG_DECOR
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BeDecorator::BeDecorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||||
|
: Decorator(rect,wlook,wfeel,wflags)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator()\n");
|
||||||
|
#endif
|
||||||
|
taboffset=0;
|
||||||
|
|
||||||
|
// These hard-coded assignments will go bye-bye when the system colors
|
||||||
|
// API is implemented
|
||||||
|
|
||||||
|
// commented these out because they are taken care of by the SetFocus() call
|
||||||
|
SetFocus(false);
|
||||||
|
|
||||||
|
frame_highercol.SetColor(216,216,216);
|
||||||
|
frame_lowercol.SetColor(110,110,110);
|
||||||
|
|
||||||
|
textcol.SetColor(0,0,0);
|
||||||
|
|
||||||
|
frame_highcol=frame_lowercol.MakeBlendColor(frame_highercol,0.75);
|
||||||
|
frame_midcol=frame_lowercol.MakeBlendColor(frame_highercol,0.5);
|
||||||
|
frame_lowcol=frame_lowercol.MakeBlendColor(frame_highercol,0.25);
|
||||||
|
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
// This flag is used to determine whether or not we're moving the tab
|
||||||
|
slidetab=false;
|
||||||
|
solidhigh=0xFFFFFFFFFFFFFFFFLL;
|
||||||
|
solidlow=0;
|
||||||
|
|
||||||
|
tab_highcol=colors->window_tab;
|
||||||
|
tab_lowcol=colors->window_tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
BeDecorator::~BeDecorator(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("~BeDecorator()\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
click_type BeDecorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
|
||||||
|
{
|
||||||
|
if(closerect.Contains(pt))
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator():Clicked() - Close\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return CLICK_CLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(zoomrect.Contains(pt))
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator():Clicked() - Zoom\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return CLICK_ZOOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(resizerect.Contains(pt) && look==WLOOK_DOCUMENT)
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator():Clicked() - Resize thumb\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return CLICK_RESIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clicking in the tab?
|
||||||
|
if(tabrect.Contains(pt))
|
||||||
|
{
|
||||||
|
// Here's part of our window management stuff
|
||||||
|
if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus())
|
||||||
|
return CLICK_MOVETOFRONT;
|
||||||
|
if(buttons==B_SECONDARY_MOUSE_BUTTON)
|
||||||
|
return CLICK_MOVETOBACK;
|
||||||
|
return CLICK_DRAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We got this far, so user is clicking on the border?
|
||||||
|
SRect srect(frame);
|
||||||
|
srect.top+=19;
|
||||||
|
SRect clientrect(srect.InsetByCopy(3,3));
|
||||||
|
if(srect.Contains(pt) && !clientrect.Contains(pt))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator():Clicked() - Drag\n");
|
||||||
|
#endif
|
||||||
|
if(resizerect.Contains(pt))
|
||||||
|
return CLICK_RESIZE;
|
||||||
|
|
||||||
|
return CLICK_DRAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guess user didn't click anything
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator():Clicked()\n");
|
||||||
|
#endif
|
||||||
|
return CLICK_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::_DoLayout(void)
|
||||||
|
{
|
||||||
|
// Here we determine the size of every rectangle that we use
|
||||||
|
// internally when we are given the size of the client rectangle.
|
||||||
|
|
||||||
|
// Current version simply makes everything fit inside the rect
|
||||||
|
// instead of building around it. This will change.
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("BeDecorator()::_DoLayout()"); rect.PrintToStream();
|
||||||
|
#endif
|
||||||
|
tabrect=frame;
|
||||||
|
resizerect=frame;
|
||||||
|
borderrect=frame;
|
||||||
|
closerect=frame;
|
||||||
|
|
||||||
|
closerect.left+=(look==WLOOK_FLOATING)?2:4;
|
||||||
|
closerect.top+=(look==WLOOK_FLOATING)?6:4;
|
||||||
|
closerect.right=closerect.left+10;
|
||||||
|
closerect.bottom=closerect.top+10;
|
||||||
|
|
||||||
|
borderrect.top+=19;
|
||||||
|
|
||||||
|
resizerect.top=resizerect.bottom-18;
|
||||||
|
resizerect.left=resizerect.right-18;
|
||||||
|
|
||||||
|
tabrect.bottom=tabrect.top+18;
|
||||||
|
/* if(GetTitle())
|
||||||
|
{
|
||||||
|
float titlewidth=closerect.right
|
||||||
|
+driver->StringWidth(layer->name->String(),
|
||||||
|
layer->name->Length())
|
||||||
|
+35;
|
||||||
|
tabrect.right=(titlewidth<frame.right -1)?titlewidth:frame.right;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*/ tabrect.right=tabrect.left+tabrect.Width()/2;
|
||||||
|
|
||||||
|
if(look==WLOOK_FLOATING)
|
||||||
|
tabrect.top+=4;
|
||||||
|
|
||||||
|
zoomrect=tabrect;
|
||||||
|
zoomrect.top+=(look==WLOOK_FLOATING)?2:4;
|
||||||
|
zoomrect.right-=4;
|
||||||
|
zoomrect.bottom-=4;
|
||||||
|
zoomrect.left=zoomrect.right-10;
|
||||||
|
zoomrect.bottom=zoomrect.top+10;
|
||||||
|
|
||||||
|
textoffset=(look==WLOOK_FLOATING)?5:7;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::MoveBy(float x, float y)
|
||||||
|
{
|
||||||
|
MoveBy(SPoint(x,y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::MoveBy(SPoint pt)
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
SRegion * BeDecorator::GetFootprint(void)
|
||||||
|
{
|
||||||
|
// This function calculates the decorator's footprint in coordinates
|
||||||
|
// relative to the layer. This is most often used to set a WindowBorder
|
||||||
|
// object's visible region.
|
||||||
|
|
||||||
|
SRegion *reg=new SRegion(borderrect);
|
||||||
|
reg->Include(tabrect);
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void BeDecorator::_DrawTitle(SRect r)
|
||||||
|
{
|
||||||
|
// Designed simply to redraw the title when it has changed on
|
||||||
|
// the client side.
|
||||||
|
/* driver->SetDrawingMode(B_OP_OVER);
|
||||||
|
rgb_color tmpcol=driver->HighColor();
|
||||||
|
driver->SetHighColor(textcol.red,textcol.green,textcol.blue);
|
||||||
|
driver->DrawString((char *)string,strlen(string),
|
||||||
|
SPoint(closerect.right+textoffset,closerect.bottom-1));
|
||||||
|
driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue);
|
||||||
|
driver->SetDrawingMode(B_OP_COPY);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::_SetFocus(void)
|
||||||
|
{
|
||||||
|
// SetFocus() performs necessary duties for color swapping and
|
||||||
|
// other things when a window is deactivated or activated.
|
||||||
|
|
||||||
|
if(GetFocus())
|
||||||
|
{
|
||||||
|
// tab_highcol.SetColor(255,236,33);
|
||||||
|
// tab_lowcol.SetColor(234,181,0);
|
||||||
|
tab_highcol=colors->window_tab;
|
||||||
|
tab_lowcol=colors->window_tab;
|
||||||
|
|
||||||
|
button_highcol.SetColor(255,255,0);
|
||||||
|
button_lowcol.SetColor(255,203,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tab_highcol.SetColor(235,235,235);
|
||||||
|
tab_lowcol.SetColor(160,160,160);
|
||||||
|
|
||||||
|
button_highcol.SetColor(229,229,229);
|
||||||
|
button_lowcol.SetColor(153,153,153);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::Draw(SRect update)
|
||||||
|
{
|
||||||
|
// We need to draw a few things: the tab, the resize thumb, the borders,
|
||||||
|
// and the buttons
|
||||||
|
|
||||||
|
_DrawTab(update);
|
||||||
|
|
||||||
|
// Draw the top view's client area - just a hack :)
|
||||||
|
RGBColor blue(100,100,255);
|
||||||
|
|
||||||
|
layerdata.highcolor=blue;
|
||||||
|
|
||||||
|
if(borderrect.Intersects(update))
|
||||||
|
driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
_DrawFrame(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::Draw(void)
|
||||||
|
{
|
||||||
|
// Easy way to draw everything - no worries about drawing only certain
|
||||||
|
// things
|
||||||
|
|
||||||
|
// Draw the top view's client area - just a hack :)
|
||||||
|
RGBColor blue(100,100,255);
|
||||||
|
|
||||||
|
layerdata.highcolor=blue;
|
||||||
|
|
||||||
|
driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
DrawFrame();
|
||||||
|
|
||||||
|
DrawTab();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::_DrawZoom(SRect r)
|
||||||
|
{
|
||||||
|
// If this has been implemented, then the decorator has a Zoom button
|
||||||
|
// which should be drawn based on the state of the member zoomstate
|
||||||
|
SRect zr=r;
|
||||||
|
zr.left+=zr.Width()/3;
|
||||||
|
zr.top+=zr.Height()/3;
|
||||||
|
|
||||||
|
DrawBlendedRect(zr,GetZoom());
|
||||||
|
DrawBlendedRect(zr.OffsetToCopy(r.LeftTop()),GetZoom());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::_DrawClose(SRect r)
|
||||||
|
{
|
||||||
|
// Just like DrawZoom, but for a close button
|
||||||
|
DrawBlendedRect(r,GetClose());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::_DrawTab(SRect r)
|
||||||
|
{
|
||||||
|
// If a window has a tab, this will draw it and any buttons which are
|
||||||
|
// in it.
|
||||||
|
if(look==WLOOK_NO_BORDER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
layerdata.highcolor=frame_lowcol;
|
||||||
|
driver->StrokeRect(tabrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
// UpdateTitle(layer->name->String());
|
||||||
|
|
||||||
|
layerdata.highcolor=colors->window_tab;
|
||||||
|
driver->FillRect(tabrect.InsetByCopy(1,1),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
// Draw the buttons if we're supposed to
|
||||||
|
if(!(flags & NOT_CLOSABLE))
|
||||||
|
_DrawClose(closerect);
|
||||||
|
if(!(flags & NOT_ZOOMABLE))
|
||||||
|
_DrawZoom(zoomrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::DrawBlendedRect(SRect 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 BeDecorator. Called by DrawZoom and DrawClose
|
||||||
|
|
||||||
|
// Actually just draws a blended square
|
||||||
|
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(SPoint(r.left,r.top+i),
|
||||||
|
SPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
|
||||||
|
uint8(halfcol.green-(i*gstep)),
|
||||||
|
uint8(halfcol.blue-(i*bstep)));
|
||||||
|
|
||||||
|
layerdata.highcolor=tmpcol;
|
||||||
|
driver->StrokeLine(SPoint(r.left+steps,r.top+i),
|
||||||
|
SPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// layerdata.highcolor=startcol;
|
||||||
|
// driver->FillRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowcol;
|
||||||
|
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeDecorator::_DrawFrame(SRect rect)
|
||||||
|
{
|
||||||
|
// Duh, draws the window frame, I think. ;)
|
||||||
|
|
||||||
|
if(look==WLOOK_NO_BORDER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SRect r=borderrect;
|
||||||
|
|
||||||
|
layerdata.highcolor=frame_midcol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowcol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
r.InsetBy(1,1);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_midcol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_midcol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
r.InsetBy(1,1);
|
||||||
|
layerdata.highcolor=frame_highcol;
|
||||||
|
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
r.InsetBy(1,1);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
driver->StrokeRect(borderrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
// Draw the resize thumb if we're supposed to
|
||||||
|
if(!(flags & NOT_RESIZABLE))
|
||||||
|
{
|
||||||
|
r=resizerect;
|
||||||
|
|
||||||
|
int32 w=r.IntegerWidth(), h=r.IntegerHeight();
|
||||||
|
|
||||||
|
// This code is strictly for B_DOCUMENT_WINDOW looks
|
||||||
|
if(look==WLOOK_DOCUMENT)
|
||||||
|
{
|
||||||
|
rgb_color halfcol, startcol, endcol;
|
||||||
|
float rstep,gstep,bstep,i;
|
||||||
|
|
||||||
|
int steps=(w<h)?w:h;
|
||||||
|
|
||||||
|
startcol=frame_highercol.GetColor32();
|
||||||
|
endcol=frame_lowercol.GetColor32();
|
||||||
|
|
||||||
|
halfcol=frame_highercol.MakeBlendColor(frame_lowercol,0.5).GetColor32();
|
||||||
|
|
||||||
|
rstep=(startcol.red-halfcol.red)/steps;
|
||||||
|
gstep=(startcol.green-halfcol.green)/steps;
|
||||||
|
bstep=(startcol.blue-halfcol.blue)/steps;
|
||||||
|
|
||||||
|
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(SPoint(r.left,r.top+i),
|
||||||
|
SPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
layerdata.highcolor.SetColor(uint8(halfcol.red-(i*rstep)),
|
||||||
|
uint8(halfcol.green-(i*gstep)),
|
||||||
|
uint8(halfcol.blue-(i*bstep)));
|
||||||
|
driver->StrokeLine(SPoint(r.left+steps,r.top+i),
|
||||||
|
SPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.top),SPoint(r.right-3,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.bottom),SPoint(r.left,r.bottom-3),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" float get_decorator_version(void)
|
||||||
|
{
|
||||||
|
return 1.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" Decorator *instantiate_decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||||
|
{
|
||||||
|
return new BeDecorator(rect,wlook,wfeel,wflags);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
#ifndef _BEOS_DECORATOR_H_
|
||||||
|
#define _BEOS_DECORATOR_H_
|
||||||
|
|
||||||
|
#include "Decorator.h"
|
||||||
|
#include "SRect.h"
|
||||||
|
#include "SPoint.h"
|
||||||
|
|
||||||
|
class BeDecorator: public Decorator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BeDecorator(SRect frame, int32 wlook, int32 wfeel, int32 wflags);
|
||||||
|
~BeDecorator(void);
|
||||||
|
|
||||||
|
void MoveBy(float x, float y);
|
||||||
|
void MoveBy(SPoint pt);
|
||||||
|
// void ResizeBy(float x, float y);
|
||||||
|
// void ResizeBy(SPoint pt);
|
||||||
|
void Draw(SRect r);
|
||||||
|
void Draw(void);
|
||||||
|
//SRegion GetFootprint(void);
|
||||||
|
click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void _DrawClose(SRect r);
|
||||||
|
void _DrawFrame(SRect r);
|
||||||
|
void _DrawTab(SRect r);
|
||||||
|
void _DrawTitle(SRect r);
|
||||||
|
void _DrawZoom(SRect r);
|
||||||
|
void _DoLayout(void);
|
||||||
|
void _SetFocus(void);
|
||||||
|
void DrawBlendedRect(SRect r, bool down);
|
||||||
|
uint32 taboffset;
|
||||||
|
|
||||||
|
RGBColor tab_highcol, tab_lowcol;
|
||||||
|
RGBColor button_highcol, button_lowcol;
|
||||||
|
RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_highercol,
|
||||||
|
frame_lowercol;
|
||||||
|
RGBColor textcol;
|
||||||
|
uint64 solidhigh, solidlow;
|
||||||
|
|
||||||
|
bool slidetab;
|
||||||
|
int textoffset;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "ColorSet.h"
|
||||||
|
|
||||||
|
ColorSet::ColorSet(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorSet::ColorSet(const ColorSet &cs)
|
||||||
|
{
|
||||||
|
panel_background=cs.panel_background;
|
||||||
|
panel_text=cs.panel_text;
|
||||||
|
document_background=cs.document_background;
|
||||||
|
document_text=cs.document_text;
|
||||||
|
control_background=cs.control_background;
|
||||||
|
control_text=cs.control_text;
|
||||||
|
control_border=cs.control_border;
|
||||||
|
control_highlight=cs.control_highlight;
|
||||||
|
tooltip_background=cs.tooltip_background;
|
||||||
|
tooltip_text=cs.tooltip_text;
|
||||||
|
menu_background=cs.menu_background;
|
||||||
|
menu_selected_background=cs.menu_selected_background;
|
||||||
|
menu_text=cs.menu_text;
|
||||||
|
menu_selected_text=cs.menu_selected_text;
|
||||||
|
menu_separator_high=cs.menu_separator_high;
|
||||||
|
menu_separator_low=cs.menu_separator_low;
|
||||||
|
menu_triggers=cs.menu_triggers;
|
||||||
|
window_tab=cs.window_tab;
|
||||||
|
window_tab_text=cs.window_tab_text;
|
||||||
|
keyboard_navigation=cs.keyboard_navigation;
|
||||||
|
desktop=cs.desktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorSet & ColorSet::operator=(const ColorSet &cs)
|
||||||
|
{
|
||||||
|
SetColors(cs);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorSet::SetColors(const ColorSet &cs)
|
||||||
|
{
|
||||||
|
panel_background=cs.panel_background;
|
||||||
|
panel_text=cs.panel_text;
|
||||||
|
document_background=cs.document_background;
|
||||||
|
document_text=cs.document_text;
|
||||||
|
control_background=cs.control_background;
|
||||||
|
control_text=cs.control_text;
|
||||||
|
control_border=cs.control_border;
|
||||||
|
control_highlight=cs.control_highlight;
|
||||||
|
tooltip_background=cs.tooltip_background;
|
||||||
|
tooltip_text=cs.tooltip_text;
|
||||||
|
menu_background=cs.menu_background;
|
||||||
|
menu_selected_background=cs.menu_selected_background;
|
||||||
|
menu_text=cs.menu_text;
|
||||||
|
menu_selected_text=cs.menu_selected_text;
|
||||||
|
menu_separator_high=cs.menu_separator_high;
|
||||||
|
menu_separator_low=cs.menu_separator_low;
|
||||||
|
menu_triggers=cs.menu_triggers;
|
||||||
|
window_tab=cs.window_tab;
|
||||||
|
window_tab_text=cs.window_tab_text;
|
||||||
|
keyboard_navigation=cs.keyboard_navigation;
|
||||||
|
desktop=cs.desktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorSet::PrintToStream(void)
|
||||||
|
{
|
||||||
|
printf("panel_background "); panel_background.PrintToStream();
|
||||||
|
printf("panel_text "); panel_text.PrintToStream();
|
||||||
|
printf("document_background "); document_background.PrintToStream();
|
||||||
|
printf("document_text "); document_text.PrintToStream();
|
||||||
|
printf("control_background "); control_background.PrintToStream();
|
||||||
|
printf("control_text "); control_text.PrintToStream();
|
||||||
|
printf("control_border "); control_border.PrintToStream();
|
||||||
|
printf("control_highlight "); control_highlight.PrintToStream();
|
||||||
|
printf("tooltip_background "); tooltip_background.PrintToStream();
|
||||||
|
printf("tooltip_text "); tooltip_text.PrintToStream();
|
||||||
|
printf("menu_background "); menu_background.PrintToStream();
|
||||||
|
printf("menu_selected_background "); menu_selected_background.PrintToStream();
|
||||||
|
printf("menu_text "); menu_text.PrintToStream();
|
||||||
|
printf("menu_selected_text "); menu_selected_text.PrintToStream();
|
||||||
|
printf("menu_separator_high "); menu_separator_high.PrintToStream();
|
||||||
|
printf("menu_separator_low "); menu_separator_low.PrintToStream();
|
||||||
|
printf("menu_triggers "); menu_triggers.PrintToStream();
|
||||||
|
printf("window_tab "); window_tab.PrintToStream();
|
||||||
|
printf("window_tab_text "); window_tab_text.PrintToStream();
|
||||||
|
printf("keyboard_navigation "); keyboard_navigation.PrintToStream();
|
||||||
|
printf("desktop "); desktop.PrintToStream();
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef COLORSET_H_
|
||||||
|
#define COLORSET_H_
|
||||||
|
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
class ColorSet
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ColorSet(void);
|
||||||
|
ColorSet(const ColorSet &cs);
|
||||||
|
ColorSet & operator=(const ColorSet &cs);
|
||||||
|
void SetColors(const ColorSet &cs);
|
||||||
|
void PrintToStream(void);
|
||||||
|
|
||||||
|
RGBColor panel_background,
|
||||||
|
panel_text,
|
||||||
|
document_background,
|
||||||
|
document_text,
|
||||||
|
control_background,
|
||||||
|
control_text,
|
||||||
|
control_border,
|
||||||
|
control_highlight,
|
||||||
|
tooltip_background,
|
||||||
|
tooltip_text,
|
||||||
|
menu_background,
|
||||||
|
menu_selected_background,
|
||||||
|
menu_text,
|
||||||
|
menu_selected_text,
|
||||||
|
menu_separator_high,
|
||||||
|
menu_separator_low,
|
||||||
|
menu_triggers,
|
||||||
|
window_tab,
|
||||||
|
window_tab_text,
|
||||||
|
keyboard_navigation,
|
||||||
|
desktop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
#include "ColorUtils.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
//#define DEBUG_COLOR_UTILS
|
||||||
|
|
||||||
|
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||||
|
{
|
||||||
|
col->red=r;
|
||||||
|
col->green=g;
|
||||||
|
col->blue=b;
|
||||||
|
col->alpha=a;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 FindClosestColor(rgb_color *palette, rgb_color color)
|
||||||
|
{
|
||||||
|
// We will be passed a 256-color palette and a 24-bit color
|
||||||
|
uint16 cindex=0,cdelta=765,delta=765;
|
||||||
|
rgb_color *c;
|
||||||
|
|
||||||
|
for(uint16 i=0;i<256;i++)
|
||||||
|
{
|
||||||
|
c=&(palette[i]);
|
||||||
|
delta=abs(c->red-color.red)+abs(c->green-color.green)+
|
||||||
|
abs(c->blue-color.blue);
|
||||||
|
|
||||||
|
if(delta==0)
|
||||||
|
{
|
||||||
|
cindex=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(delta<cdelta)
|
||||||
|
{
|
||||||
|
cindex=i;
|
||||||
|
cdelta=delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DEBUG_COLOR_UTILS
|
||||||
|
printf("FindClosestColor( {%u,%u,%u,%u} ) : {%u,%u,%u,%u}\n",
|
||||||
|
color.red,color.green,color.blue,color.alpha,
|
||||||
|
palette[cindex].red,palette[cindex].green,palette[cindex].blue,palette[cindex].alpha);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (uint8)cindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 FindClosestColor16(rgb_color color)
|
||||||
|
{
|
||||||
|
printf("FindClosestColor16 unimplemented\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)
|
||||||
|
{
|
||||||
|
rgb_color newcol={0,0,0,0};
|
||||||
|
float mod=0;
|
||||||
|
int16 delta;
|
||||||
|
if(position<0 || position>1)
|
||||||
|
return newcol;
|
||||||
|
|
||||||
|
delta=int16(col2.red)-int16(col.red);
|
||||||
|
mod=col.red + (position * delta);
|
||||||
|
newcol.red=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.red=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.red=0;
|
||||||
|
|
||||||
|
delta=int16(col2.green)-int16(col.green);
|
||||||
|
mod=col.green + (position * delta);
|
||||||
|
newcol.green=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.green=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.green=0;
|
||||||
|
|
||||||
|
delta=int16(col2.blue)-int16(col.blue);
|
||||||
|
mod=col.blue + (position * delta);
|
||||||
|
newcol.blue=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.blue=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.blue=0;
|
||||||
|
|
||||||
|
delta=int8(col2.alpha)-int8(col.alpha);
|
||||||
|
mod=col.alpha + (position * delta);
|
||||||
|
newcol.alpha=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.alpha=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.alpha=0;
|
||||||
|
#ifdef DEBUG_COLOR_UTILS
|
||||||
|
printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
|
||||||
|
col.red,col.green,col.blue,col.alpha,
|
||||||
|
col2.red,col2.green,col2.blue,col2.alpha,
|
||||||
|
position,
|
||||||
|
newcol.red,newcol.green,newcol.blue,newcol.alpha);
|
||||||
|
#endif
|
||||||
|
return newcol;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef COLORUTILS_H_
|
||||||
|
#define COLORUTILS_H_
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
|
// Quick assignment for rgb_color structs
|
||||||
|
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
|
|
||||||
|
// Given a color palette, returns the index of the closest match to
|
||||||
|
// the color passed to it. Alpha values are not considered
|
||||||
|
uint8 FindClosestColor(rgb_color *palette, rgb_color color);
|
||||||
|
uint16 FindClosestColor16(rgb_color color);
|
||||||
|
|
||||||
|
// Function which could be used to calculate gradient colors. Position is
|
||||||
|
// a floating point number such that 0.0 <= position <= 1.0. Any number outside
|
||||||
|
// this range will cause the function to fail and return the color (0,0,0,0)
|
||||||
|
// Alpha components are included in the calculations. 0 yields color #1
|
||||||
|
// and 1 yields color #2.
|
||||||
|
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
#include "ColorWell.h"
|
||||||
|
|
||||||
|
ColorWell::ColorWell(BRect frame, BMessage *msg, bool is_rectangle=false)
|
||||||
|
: BView(frame,"ColorWell", B_FOLLOW_ALL_SIDES, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
SetLowColor(0,0,0);
|
||||||
|
invoker=new BInvoker(msg,this);
|
||||||
|
disabledcol.red=128;
|
||||||
|
disabledcol.green=128;
|
||||||
|
disabledcol.blue=128;
|
||||||
|
disabledcol.alpha=255;
|
||||||
|
is_enabled=true;
|
||||||
|
is_rect=is_rectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorWell::~ColorWell(void)
|
||||||
|
{
|
||||||
|
delete invoker;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::SetTarget(BHandler *tgt)
|
||||||
|
{
|
||||||
|
invoker->SetTarget(tgt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::SetColor(rgb_color col)
|
||||||
|
{
|
||||||
|
SetHighColor(col);
|
||||||
|
currentcol=col;
|
||||||
|
Draw(Bounds());
|
||||||
|
// Invalidate();
|
||||||
|
invoker->Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::SetColor(uint8 r,uint8 g, uint8 b)
|
||||||
|
{
|
||||||
|
SetHighColor(r,g,b);
|
||||||
|
currentcol.red=r;
|
||||||
|
currentcol.green=g;
|
||||||
|
currentcol.blue=b;
|
||||||
|
Draw(Bounds());
|
||||||
|
//Invalidate();
|
||||||
|
invoker->Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
// If we received a dropped message, try to see if it has color data
|
||||||
|
// in it
|
||||||
|
if(msg->WasDropped())
|
||||||
|
{
|
||||||
|
rgb_color *col;
|
||||||
|
uint8 *ptr;
|
||||||
|
ssize_t size;
|
||||||
|
if(msg->FindData("RGBColor",(type_code)'RGBC',(const void**)&ptr,&size)==B_OK)
|
||||||
|
{
|
||||||
|
col=(rgb_color*)ptr;
|
||||||
|
SetHighColor(*col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The default
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::SetEnabled(bool value)
|
||||||
|
{
|
||||||
|
if(is_enabled!=value)
|
||||||
|
{
|
||||||
|
is_enabled=value;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::Draw(BRect update)
|
||||||
|
{
|
||||||
|
if(is_enabled)
|
||||||
|
SetHighColor(currentcol);
|
||||||
|
else
|
||||||
|
SetHighColor(disabledcol);
|
||||||
|
|
||||||
|
if(is_rect)
|
||||||
|
{
|
||||||
|
FillRect(Bounds());
|
||||||
|
if(is_enabled)
|
||||||
|
StrokeRect(Bounds(),B_SOLID_LOW);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FillEllipse(Bounds());
|
||||||
|
if(is_enabled)
|
||||||
|
StrokeEllipse(Bounds(),B_SOLID_LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color ColorWell::Color(void) const
|
||||||
|
{
|
||||||
|
return currentcol;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorWell::SetMode(bool is_rectangle)
|
||||||
|
{
|
||||||
|
is_rect=is_rectangle;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef COLORWELL_H_
|
||||||
|
#define COLORWELL_H_
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Invoker.h>
|
||||||
|
|
||||||
|
class ColorWell : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ColorWell(BRect frame, BMessage *msg, bool is_rectangle=false);
|
||||||
|
~ColorWell(void);
|
||||||
|
void SetColor(rgb_color col);
|
||||||
|
rgb_color Color(void) const;
|
||||||
|
void SetColor(uint8 r,uint8 g, uint8 b);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void Draw(BRect update);
|
||||||
|
virtual void SetTarget(BHandler *tgt);
|
||||||
|
virtual void SetEnabled(bool value);
|
||||||
|
void SetMode(bool is_rectangle);
|
||||||
|
protected:
|
||||||
|
BInvoker *invoker;
|
||||||
|
bool is_enabled, is_rect;
|
||||||
|
rgb_color disabledcol, currentcol;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
#include "Decorator.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
Decorator::Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||||
|
{
|
||||||
|
close_state=false;
|
||||||
|
minimize_state=false;
|
||||||
|
zoom_state=false;
|
||||||
|
title_string=NULL;
|
||||||
|
driver=NULL;
|
||||||
|
|
||||||
|
closerect.Set(0,0,1,1);
|
||||||
|
zoomrect.Set(0,0,1,1);
|
||||||
|
minimizerect.Set(0,0,1,1);
|
||||||
|
resizerect.Set(0,0,1,1);
|
||||||
|
frame=rect;
|
||||||
|
tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4));
|
||||||
|
|
||||||
|
look=wlook;
|
||||||
|
feel=wfeel;
|
||||||
|
flags=wflags;
|
||||||
|
|
||||||
|
colors=new ColorSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
Decorator::~Decorator(void)
|
||||||
|
{
|
||||||
|
if(colors!=NULL)
|
||||||
|
{
|
||||||
|
delete colors;
|
||||||
|
colors=NULL;
|
||||||
|
}
|
||||||
|
if(title_string)
|
||||||
|
delete title_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetColors(ColorSet cset)
|
||||||
|
{
|
||||||
|
colors->SetColors(cset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetDriver(DisplayDriver *d)
|
||||||
|
{
|
||||||
|
driver=d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetClose(bool is_down)
|
||||||
|
{
|
||||||
|
close_state=is_down;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetMinimize(bool is_down)
|
||||||
|
{
|
||||||
|
zoom_state=is_down;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetZoom(bool is_down)
|
||||||
|
{
|
||||||
|
minimize_state=is_down;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetFlags(int32 wflags)
|
||||||
|
{
|
||||||
|
flags=wflags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetFeel(int32 wfeel)
|
||||||
|
{
|
||||||
|
feel=wfeel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetLook(int32 wlook)
|
||||||
|
{
|
||||||
|
look=wlook;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Decorator::GetClose(void)
|
||||||
|
{
|
||||||
|
return close_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Decorator::GetMinimize(void)
|
||||||
|
{
|
||||||
|
return minimize_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Decorator::GetZoom(void)
|
||||||
|
{
|
||||||
|
return zoom_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Decorator::GetLook(void)
|
||||||
|
{
|
||||||
|
return look;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Decorator::GetFeel(void)
|
||||||
|
{
|
||||||
|
return feel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Decorator::GetFlags(void)
|
||||||
|
{
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetTitle(const char *string)
|
||||||
|
{
|
||||||
|
if(string)
|
||||||
|
{
|
||||||
|
size_t size=strlen(string);
|
||||||
|
if(!(size>0))
|
||||||
|
return;
|
||||||
|
delete title_string;
|
||||||
|
title_string=new char[size];
|
||||||
|
strcpy(title_string,string);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete title_string;
|
||||||
|
title_string=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *Decorator::GetTitle(void)
|
||||||
|
{
|
||||||
|
return title_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetFocus(bool is_active)
|
||||||
|
{
|
||||||
|
has_focus=is_active;
|
||||||
|
_SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void Decorator::SetFont(SFont *sf)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
void Decorator::_ClipTitle(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// Virtual Methods
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
void Decorator::MoveBy(float x, float y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::MoveBy(SPoint pt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::ResizeBy(float x, float y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::ResizeBy(SPoint pt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::Draw(SRect r)
|
||||||
|
{
|
||||||
|
_DrawTab(r & tabrect);
|
||||||
|
_DrawFrame(r & frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::Draw(void)
|
||||||
|
{
|
||||||
|
_DrawTab(tabrect);
|
||||||
|
_DrawFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawClose(void)
|
||||||
|
{
|
||||||
|
_DrawClose(closerect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawFrame(void)
|
||||||
|
{
|
||||||
|
_DrawFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawMinimize(void)
|
||||||
|
{
|
||||||
|
_DrawTab(minimizerect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawTab(void)
|
||||||
|
{
|
||||||
|
_DrawTab(tabrect);
|
||||||
|
_DrawZoom(zoomrect);
|
||||||
|
_DrawMinimize(minimizerect);
|
||||||
|
_DrawTitle(tabrect);
|
||||||
|
_DrawClose(closerect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawTitle(void)
|
||||||
|
{
|
||||||
|
_DrawTitle(tabrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawZoom(void)
|
||||||
|
{
|
||||||
|
_DrawZoom(zoomrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawClose(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawFrame(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawMinimize(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawTab(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawTitle(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawZoom(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
SRegion Decorator::GetFootprint(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
click_type Decorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
|
||||||
|
{
|
||||||
|
return CLICK_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
#ifndef _DECORATOR_H_
|
||||||
|
#define _DECORATOR_H_
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include "SRect.h"
|
||||||
|
#include "ColorSet.h"
|
||||||
|
#include "LayerData.h"
|
||||||
|
|
||||||
|
class DisplayDriver;
|
||||||
|
|
||||||
|
typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE,
|
||||||
|
CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT,
|
||||||
|
|
||||||
|
CLICK_RESIZE, CLICK_RESIZE_L, CLICK_RESIZE_T,
|
||||||
|
CLICK_RESIZE_R, CLICK_RESIZE_B, CLICK_RESIZE_LT, CLICK_RESIZE_RT,
|
||||||
|
CLICK_RESIZE_LB, CLICK_RESIZE_RB } click_type;
|
||||||
|
|
||||||
|
// Definitions which are used in place of including Window.h
|
||||||
|
// window_look and window_feel are enumerated types, so we convert them
|
||||||
|
// to uint32's in order to ensure a constant size when sending via PortLink
|
||||||
|
// instead of depending on magic numbers in the header file.
|
||||||
|
|
||||||
|
#define WLOOK_NO_BORDER 0
|
||||||
|
#define WLOOK_BORDERED 1
|
||||||
|
#define WLOOK_TITLED 2
|
||||||
|
#define WLOOK_DOCUMENT 3
|
||||||
|
#define WLOOK_MODAL 4
|
||||||
|
#define WLOOK_FLOATING 5
|
||||||
|
|
||||||
|
#define WFEEL_NORMAL 0
|
||||||
|
#define WFEEL_MODAL_SUBSET 1
|
||||||
|
#define WFEEL_MODAL_APP 2
|
||||||
|
#define WFEEL_MODAL_WINDOW 3
|
||||||
|
#define WFEEL_FLOATING_SUBSET 4
|
||||||
|
#define WFEEL_FLOATING_APP 5
|
||||||
|
#define WFEEL_FLOATING_WINDOW 6
|
||||||
|
|
||||||
|
#define NOT_MOVABLE 0x00000001
|
||||||
|
#define NOT_CLOSABLE 0x00000020
|
||||||
|
#define NOT_ZOOMABLE 0x00000040
|
||||||
|
#define NOT_MINIMIZABLE 0x00004000
|
||||||
|
#define NOT_RESIZABLE 0x00000002
|
||||||
|
#define NOT_H_RESIZABLE 0x00000004
|
||||||
|
#define NOT_V_RESIZABLE 0x00000008
|
||||||
|
#define AVOID_FRONT 0x00000080
|
||||||
|
#define AVOID_FOCUS 0x00002000
|
||||||
|
#define WILL_ACCEPT_FIRST_CLICK 0x00000010
|
||||||
|
#define OUTLINE_RESIZE 0x00001000
|
||||||
|
#define NO_WORKSPACE_ACTIVATION 0x00000100
|
||||||
|
#define NOT_ANCHORED_ON_ACTIVATE 0x00020000
|
||||||
|
#define ASYNCHRONOUS_CONTROLS 0x00080000
|
||||||
|
#define QUIT_ON_WINDOW_CLOSE 0x00100000
|
||||||
|
|
||||||
|
class Decorator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags);
|
||||||
|
virtual ~Decorator(void);
|
||||||
|
void SetColors(ColorSet cset);
|
||||||
|
void SetDriver(DisplayDriver *d);
|
||||||
|
void SetClose(bool is_down);
|
||||||
|
void SetMinimize(bool is_down);
|
||||||
|
void SetZoom(bool is_down);
|
||||||
|
void SetFlags(int32 wflags);
|
||||||
|
void SetFeel(int32 wfeel);
|
||||||
|
void SetLook(int32 wlook);
|
||||||
|
bool GetClose(void);
|
||||||
|
bool GetMinimize(void);
|
||||||
|
bool GetZoom(void);
|
||||||
|
int32 GetLook(void);
|
||||||
|
int32 GetFeel(void);
|
||||||
|
int32 GetFlags(void);
|
||||||
|
void SetTitle(const char *string);
|
||||||
|
void SetFocus(bool is_active);
|
||||||
|
bool GetFocus(void) { return has_focus; };
|
||||||
|
const char *GetTitle(void);
|
||||||
|
// void SetFont(SFont *sf);
|
||||||
|
void _ClipTitle(void);
|
||||||
|
ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); }
|
||||||
|
|
||||||
|
virtual void MoveBy(float x, float y);
|
||||||
|
virtual void MoveBy(SPoint pt);
|
||||||
|
virtual void ResizeBy(float x, float y);
|
||||||
|
virtual void ResizeBy(SPoint pt);
|
||||||
|
virtual void Draw(SRect r);
|
||||||
|
virtual void Draw(void);
|
||||||
|
virtual void DrawClose(void);
|
||||||
|
virtual void DrawFrame(void);
|
||||||
|
virtual void DrawMinimize(void);
|
||||||
|
virtual void DrawTab(void);
|
||||||
|
virtual void DrawTitle(void);
|
||||||
|
virtual void DrawZoom(void);
|
||||||
|
//virtual SRegion GetFootprint(void);
|
||||||
|
virtual click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void _DrawClose(SRect r);
|
||||||
|
virtual void _DrawFrame(SRect r);
|
||||||
|
virtual void _DrawMinimize(SRect r);
|
||||||
|
virtual void _DrawTab(SRect r);
|
||||||
|
virtual void _DrawTitle(SRect r);
|
||||||
|
virtual void _DrawZoom(SRect r);
|
||||||
|
virtual void _SetFocus(void)=0;
|
||||||
|
virtual void _DoLayout(void)=0;
|
||||||
|
ColorSet *colors;
|
||||||
|
int32 look, feel, flags;
|
||||||
|
DisplayDriver *driver;
|
||||||
|
LayerData layerdata;
|
||||||
|
SRect zoomrect,closerect,minimizerect,tabrect,frame,
|
||||||
|
resizerect,borderrect;
|
||||||
|
private:
|
||||||
|
bool close_state, zoom_state, minimize_state;
|
||||||
|
bool has_focus;
|
||||||
|
char *title_string;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
DisplayDriver.cpp
|
||||||
|
Modular class to allow the server to not care what the ultimate output is
|
||||||
|
for graphics calls.
|
||||||
|
*/
|
||||||
|
#include "DisplayDriver.h"
|
||||||
|
#include "LayerData.h"
|
||||||
|
|
||||||
|
DisplayDriver::DisplayDriver(void)
|
||||||
|
{
|
||||||
|
lock_sem=create_sem(1,"displaydriver_lock");
|
||||||
|
buffer_depth=0;
|
||||||
|
buffer_width=0;
|
||||||
|
buffer_height=0;
|
||||||
|
buffer_mode=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayDriver::~DisplayDriver(void)
|
||||||
|
{
|
||||||
|
delete_sem(lock_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayDriver::Initialize(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 DisplayDriver::GetDepth(void)
|
||||||
|
{
|
||||||
|
return buffer_depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 DisplayDriver::GetHeight(void)
|
||||||
|
{
|
||||||
|
return buffer_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 DisplayDriver::GetWidth(void)
|
||||||
|
{
|
||||||
|
return buffer_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 DisplayDriver::GetMode(void)
|
||||||
|
{
|
||||||
|
return buffer_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayDriver::DumpToFile(const char *path)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Private Methods
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
void DisplayDriver::Lock(void)
|
||||||
|
{
|
||||||
|
acquire_sem(lock_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::Unlock(void)
|
||||||
|
{
|
||||||
|
release_sem(lock_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetDepthInternal(uint8 d)
|
||||||
|
{
|
||||||
|
buffer_depth=d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetHeightInternal(uint16 h)
|
||||||
|
{
|
||||||
|
buffer_height=h;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetWidthInternal(uint16 w)
|
||||||
|
{
|
||||||
|
buffer_width=w;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetModeInternal(int32 m)
|
||||||
|
{
|
||||||
|
buffer_mode=m;
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#ifndef _DISPLAY_DRIVER_H_
|
||||||
|
#define _DISPLAY_DRIVER_H_
|
||||||
|
|
||||||
|
#include <GraphicsCard.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
|
#include "SRect.h"
|
||||||
|
#include "SPoint.h"
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
class ServerBitmap;
|
||||||
|
class ServerCursor;
|
||||||
|
class LayerData;
|
||||||
|
|
||||||
|
#ifndef ROUND
|
||||||
|
#define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uchar *xormask, *andmask;
|
||||||
|
int32 width, height;
|
||||||
|
int32 hotx, hoty;
|
||||||
|
|
||||||
|
} cursor_data;
|
||||||
|
|
||||||
|
#ifndef HOOK_DEFINE_CURSOR
|
||||||
|
|
||||||
|
#define HOOK_DEFINE_CURSOR 0
|
||||||
|
#define HOOK_MOVE_CURSOR 1
|
||||||
|
#define HOOK_SHOW_CURSOR 2
|
||||||
|
#define HOOK_DRAW_LINE_8BIT 3
|
||||||
|
#define HOOK_DRAW_LINE_16BIT 12
|
||||||
|
#define HOOK_DRAW_LINE_32BIT 4
|
||||||
|
#define HOOK_DRAW_RECT_8BIT 5
|
||||||
|
#define HOOK_DRAW_RECT_16BIT 13
|
||||||
|
#define HOOK_DRAW_RECT_32BIT 6
|
||||||
|
#define HOOK_BLIT 7
|
||||||
|
#define HOOK_DRAW_ARRAY_8BIT 8
|
||||||
|
#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers
|
||||||
|
#define HOOK_DRAW_ARRAY_32BIT 9
|
||||||
|
#define HOOK_SYNC 10
|
||||||
|
#define HOOK_INVERT_RECT 11
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DRAW_COPY 0
|
||||||
|
#define DRAW_OVER 1
|
||||||
|
#define DRAW_ERASE 2
|
||||||
|
#define DRAW_INVERT 3
|
||||||
|
#define DRAW_ADD 4
|
||||||
|
#define DRAW_SUBTRACT 5
|
||||||
|
#define DRAW_BLEND 6
|
||||||
|
#define DRAW_MIN 7
|
||||||
|
#define DRAW_MAX 8
|
||||||
|
#define DRAW_SELECT 9
|
||||||
|
#define DRAW_ALPHA 10
|
||||||
|
|
||||||
|
class DisplayDriver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DisplayDriver(void);
|
||||||
|
virtual ~DisplayDriver(void);
|
||||||
|
virtual bool Initialize(void);
|
||||||
|
virtual void Shutdown(void)=0;
|
||||||
|
virtual void CopyBits(SRect src, SRect dest)=0;
|
||||||
|
virtual void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest)=0;
|
||||||
|
virtual void DrawChar(char c, SPoint pt)=0;
|
||||||
|
// virtual void DrawPicture(SPicture *pic, SPoint pt)=0;
|
||||||
|
// virtual void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL)=0;
|
||||||
|
virtual void InvertRect(SRect r)=0;
|
||||||
|
virtual void StrokeBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeEllipse(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillEllipse(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeLine(SPoint start, SPoint end, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
|
||||||
|
virtual void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeRect(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillRect(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
|
||||||
|
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat)=0;
|
||||||
|
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeLineArray(SPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
|
||||||
|
virtual void SetMode(int32 mode)=0;
|
||||||
|
virtual bool DumpToFile(const char *path)=0;
|
||||||
|
|
||||||
|
uint8 GetDepth(void);
|
||||||
|
uint16 GetHeight(void);
|
||||||
|
uint16 GetWidth(void);
|
||||||
|
int32 GetMode(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Lock(void);
|
||||||
|
void Unlock(void);
|
||||||
|
void SetDepthInternal(uint8 d);
|
||||||
|
void SetHeightInternal(uint16 h);
|
||||||
|
void SetWidthInternal(uint16 w);
|
||||||
|
void SetModeInternal(int32 m);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sem_id lock_sem;
|
||||||
|
uint8 buffer_depth;
|
||||||
|
uint16 buffer_width;
|
||||||
|
uint16 buffer_height;
|
||||||
|
int32 buffer_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#ifndef LAYERDATA_H_
|
||||||
|
#define LAYERDATA_H_
|
||||||
|
|
||||||
|
class ServerBitmap;
|
||||||
|
|
||||||
|
class LayerData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LayerData(void)
|
||||||
|
{
|
||||||
|
pensize=1.0;
|
||||||
|
penlocation.Set(0,0);
|
||||||
|
drawing_mode=0;
|
||||||
|
bitmap_background=NULL;
|
||||||
|
bitmap_overlay=NULL;
|
||||||
|
highcolor.SetColor(0,0,0,255);
|
||||||
|
lowcolor.SetColor(255,255,255,255);
|
||||||
|
//SFont font;
|
||||||
|
//bool antialias_text;
|
||||||
|
scale=1.0;
|
||||||
|
};
|
||||||
|
|
||||||
|
float pensize;
|
||||||
|
SPoint penlocation;
|
||||||
|
int32 drawing_mode;
|
||||||
|
ServerBitmap *bitmap_background;
|
||||||
|
ServerBitmap *bitmap_overlay;
|
||||||
|
RGBColor highcolor, lowcolor;
|
||||||
|
//SFont font;
|
||||||
|
//bool antialias_text;
|
||||||
|
float scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/*
|
||||||
|
RGBColor.cpp
|
||||||
|
Color encapsulation class for app_server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||||
|
{
|
||||||
|
SetColor(r,g,b,a);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(rgb_color col)
|
||||||
|
{
|
||||||
|
SetColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(uint16 col)
|
||||||
|
{
|
||||||
|
SetColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(uint8 col)
|
||||||
|
{
|
||||||
|
SetColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(const RGBColor &col)
|
||||||
|
{
|
||||||
|
color32=col.color32;
|
||||||
|
color16=col.color16;
|
||||||
|
color8=col.color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(void)
|
||||||
|
{
|
||||||
|
SetColor(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 RGBColor::GetColor8(void)
|
||||||
|
{
|
||||||
|
return color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 RGBColor::GetColor16(void)
|
||||||
|
{
|
||||||
|
return color16;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color RGBColor::GetColor32(void)
|
||||||
|
{
|
||||||
|
return color32;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||||
|
{
|
||||||
|
color32.red=r;
|
||||||
|
color32.green=g;
|
||||||
|
color32.blue=b;
|
||||||
|
color32.alpha=a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(uint16 col16)
|
||||||
|
{
|
||||||
|
// Pared-down version from what is used in the app_server to
|
||||||
|
// eliminate some dependencies
|
||||||
|
color16=col16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(uint8 col8)
|
||||||
|
{
|
||||||
|
// Pared-down version from what is used in the app_server to
|
||||||
|
// eliminate some dependencies
|
||||||
|
color8=col8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(rgb_color color)
|
||||||
|
{
|
||||||
|
// Pared-down version from what is used in the app_server to
|
||||||
|
// eliminate some dependencies
|
||||||
|
color32=color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(const RGBColor &col)
|
||||||
|
{
|
||||||
|
color32=col.color32;
|
||||||
|
color16=col.color16;
|
||||||
|
color8=col.color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RGBColor & RGBColor::operator=(const RGBColor &col)
|
||||||
|
{
|
||||||
|
color32=col.color32;
|
||||||
|
color16=col.color16;
|
||||||
|
color8=col.color8;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor & RGBColor::operator=(rgb_color col)
|
||||||
|
{
|
||||||
|
color32=col;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
|
||||||
|
{
|
||||||
|
rgb_color col=color32;
|
||||||
|
rgb_color col2=color.color32;
|
||||||
|
|
||||||
|
rgb_color newcol={0,0,0,0};
|
||||||
|
float mod=0;
|
||||||
|
int16 delta;
|
||||||
|
if(position<0 || position>1)
|
||||||
|
return newcol;
|
||||||
|
|
||||||
|
delta=int16(col2.red)-int16(col.red);
|
||||||
|
mod=col.red + (position * delta);
|
||||||
|
newcol.red=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.red=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.red=0;
|
||||||
|
|
||||||
|
delta=int16(col2.green)-int16(col.green);
|
||||||
|
mod=col.green + (position * delta);
|
||||||
|
newcol.green=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.green=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.green=0;
|
||||||
|
|
||||||
|
delta=int16(col2.blue)-int16(col.blue);
|
||||||
|
mod=col.blue + (position * delta);
|
||||||
|
newcol.blue=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.blue=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.blue=0;
|
||||||
|
|
||||||
|
delta=int8(col2.alpha)-int8(col.alpha);
|
||||||
|
mod=col.alpha + (position * delta);
|
||||||
|
newcol.alpha=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.alpha=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.alpha=0;
|
||||||
|
#ifdef DEBUG_COLOR_UTILS
|
||||||
|
printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
|
||||||
|
col.red,col.green,col.blue,col.alpha,
|
||||||
|
col2.red,col2.green,col2.blue,col2.alpha,
|
||||||
|
position,
|
||||||
|
newcol.red,newcol.green,newcol.blue,newcol.alpha);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return RGBColor(newcol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::PrintToStream(void)
|
||||||
|
{
|
||||||
|
printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef RGBCOLOR_H_
|
||||||
|
#define RGBCOLOR_H_
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
|
class RGBColor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
|
RGBColor(rgb_color col);
|
||||||
|
RGBColor(uint16 col);
|
||||||
|
RGBColor(uint8 col);
|
||||||
|
RGBColor(const RGBColor &col);
|
||||||
|
RGBColor(void);
|
||||||
|
void PrintToStream(void);
|
||||||
|
uint8 GetColor8(void);
|
||||||
|
uint16 GetColor16(void);
|
||||||
|
rgb_color GetColor32(void);
|
||||||
|
void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
|
void SetColor(uint16 color16);
|
||||||
|
void SetColor(uint8 color8);
|
||||||
|
void SetColor(rgb_color color);
|
||||||
|
void SetColor(const RGBColor &col);
|
||||||
|
RGBColor MakeBlendColor(RGBColor color, float position);
|
||||||
|
RGBColor & operator=(const RGBColor &col);
|
||||||
|
RGBColor & operator=(rgb_color col);
|
||||||
|
protected:
|
||||||
|
rgb_color color32;
|
||||||
|
uint16 color16;
|
||||||
|
uint8 color8;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
SPoint.cpp:
|
||||||
|
Point class which utilizes Frans van Nispen's original SPoint sources
|
||||||
|
and extends them slightly for app_server use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include "SPoint.h"
|
||||||
|
#include "SRect.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SPoint::ConstrainTo(SRect r)
|
||||||
|
{
|
||||||
|
x = max_c(min_c(x, r.right), r.left);
|
||||||
|
y = max_c(min_c(y, r.bottom), r.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPoint::PrintToStream() const
|
||||||
|
{
|
||||||
|
printf("SPoint(x:%.0f, y:%.0f)\n", x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator+(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint(x + p.x, y + p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator-(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint(x - p.x, y - p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator*(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint(x * p.x, y * p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator/(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint((p.x!=0)?(x / p.x):0,(p.y!=0)?(y / p.y):0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint& SPoint::operator+=(const SPoint& p)
|
||||||
|
{
|
||||||
|
x += p.x;
|
||||||
|
y += p.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint& SPoint::operator-=(const SPoint& p)
|
||||||
|
{
|
||||||
|
x -= p.x;
|
||||||
|
y -= p.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator!=(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x != p.x || y != p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator==(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x == p.x && y == p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator<=(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x <= p.x && y <= p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator>=(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x >= p.x && y >= p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator<(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x < p.x || y < p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator>(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x > p.x && y > p.y;
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#ifndef _SPOINT_H
|
||||||
|
#define _SPOINT_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
class SRect;
|
||||||
|
/*
|
||||||
|
#ifndef BE_SUPPORT
|
||||||
|
#define BE_SUPPORT
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SPoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
|
||||||
|
SPoint();
|
||||||
|
SPoint(float X, float Y);
|
||||||
|
SPoint(const SPoint &p);
|
||||||
|
|
||||||
|
SPoint &operator=(const SPoint &p);
|
||||||
|
void Set(float X, float Y);
|
||||||
|
|
||||||
|
void ConstrainTo(SRect r);
|
||||||
|
void PrintToStream() const;
|
||||||
|
|
||||||
|
SPoint operator+(const SPoint &p) const;
|
||||||
|
SPoint operator-(const SPoint &p) const;
|
||||||
|
SPoint operator*(const SPoint &p) const;
|
||||||
|
SPoint operator/(const SPoint &p) const;
|
||||||
|
SPoint& operator+=(const SPoint &p);
|
||||||
|
SPoint& operator-=(const SPoint &p);
|
||||||
|
|
||||||
|
bool operator!=(const SPoint &p) const;
|
||||||
|
bool operator==(const SPoint &p) const;
|
||||||
|
bool operator>=(const SPoint &p) const;
|
||||||
|
bool operator<=(const SPoint &p) const;
|
||||||
|
bool operator>(const SPoint &p) const;
|
||||||
|
bool operator<(const SPoint &p) const;
|
||||||
|
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
BPoint Point(void) { return BPoint(x,y); };
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
inline SPoint::SPoint()
|
||||||
|
{
|
||||||
|
x = y = 0;
|
||||||
|
}
|
||||||
|
inline SPoint::SPoint(float X, float Y)
|
||||||
|
{
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
}
|
||||||
|
inline SPoint::SPoint(const SPoint& pt)
|
||||||
|
{
|
||||||
|
x = pt.x;
|
||||||
|
y = pt.y;
|
||||||
|
}
|
||||||
|
inline SPoint &SPoint::operator=(const SPoint& from)
|
||||||
|
{
|
||||||
|
x = from.x;
|
||||||
|
y = from.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline void SPoint::Set(float X, float Y)
|
||||||
|
{
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
SPoint.cpp:
|
||||||
|
Point class which utilizes Frans van Nispen's original SPoint sources
|
||||||
|
and extends them slightly for app_server use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "SRect.h"
|
||||||
|
|
||||||
|
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
|
||||||
|
bool vertical = true);
|
||||||
|
|
||||||
|
|
||||||
|
void SRect::InsetBy(SPoint p)
|
||||||
|
{
|
||||||
|
left += p.x;
|
||||||
|
right -= p.x;
|
||||||
|
top += p.y;
|
||||||
|
bottom -= p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::InsetBy(float dx, float dy)
|
||||||
|
{
|
||||||
|
left += dx;
|
||||||
|
right -= dx;
|
||||||
|
top += dy;
|
||||||
|
bottom -= dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::InsetBySelf(SPoint p)
|
||||||
|
{
|
||||||
|
this->InsetBy(p);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::InsetBySelf(float dx, float dy)
|
||||||
|
{
|
||||||
|
this->InsetBy(dx, dy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::InsetByCopy(SPoint p)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.InsetBy(p);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::InsetByCopy(float dx, float dy)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.InsetBy(dx, dy);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetBy(SPoint p)
|
||||||
|
{
|
||||||
|
left += p.x;
|
||||||
|
right += p.x;
|
||||||
|
top += p.y;
|
||||||
|
bottom += p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetBy(float dx, float dy)
|
||||||
|
{
|
||||||
|
left += dx;
|
||||||
|
right += dx;
|
||||||
|
top += dy;
|
||||||
|
bottom += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetBySelf(SPoint p)
|
||||||
|
{
|
||||||
|
this->OffsetBy(p);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetBySelf(float dx, float dy)
|
||||||
|
{
|
||||||
|
this->OffsetBy(dx, dy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetByCopy(SPoint p)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetBy(p);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetByCopy(float dx, float dy)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetBy(dx, dy);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetTo(SPoint p)
|
||||||
|
{
|
||||||
|
right = (right - left) + p.x;
|
||||||
|
left = p.x;
|
||||||
|
bottom = (bottom - top) + p.y;
|
||||||
|
top = p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetTo(float x, float y)
|
||||||
|
{
|
||||||
|
right = (right - left) + x;
|
||||||
|
left = x;
|
||||||
|
bottom = (bottom - top) + y;
|
||||||
|
top=y;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetToSelf(SPoint p)
|
||||||
|
{
|
||||||
|
this->OffsetTo(p);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetToSelf(float dx, float dy)
|
||||||
|
{
|
||||||
|
this->OffsetTo(dx, dy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetToCopy(SPoint p)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetTo(p);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetToCopy(float dx, float dy)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetTo(dx, dy);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::PrintToStream() const
|
||||||
|
{
|
||||||
|
printf("(l:%.1f t:%.1f r:%.1f b:%.1f)\n", left, top, right, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::operator==(SRect r) const
|
||||||
|
{
|
||||||
|
return left == r.left && right == r.right &&
|
||||||
|
top == r.top && bottom == r.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::operator!=(SRect r) const
|
||||||
|
{
|
||||||
|
return !(*this == r);
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::operator&(SRect r) const
|
||||||
|
{
|
||||||
|
return SRect(max_c(left, r.left), max_c(top, r.top),
|
||||||
|
min_c(right, r.right), min_c(bottom, r.bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::operator|(SRect r) const
|
||||||
|
{
|
||||||
|
return SRect(min_c(left, r.left), min_c(top, r.top),
|
||||||
|
max_c(right, r.right), max_c(bottom, r.bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::Intersects(SRect r) const
|
||||||
|
{
|
||||||
|
return TestLineIntersect(*this, r.left, r.top, r.left, r.bottom) ||
|
||||||
|
TestLineIntersect(*this, r.left, r.top, r.right, r.top, false) ||
|
||||||
|
TestLineIntersect(*this, r.right, r.top, r.right, r.bottom) ||
|
||||||
|
TestLineIntersect(*this, r.left, r.bottom, r.right, r.bottom, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::Contains(SPoint p) const
|
||||||
|
{
|
||||||
|
return p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::Contains(SRect r) const
|
||||||
|
{
|
||||||
|
return r.left >= left && r.right <= right &&
|
||||||
|
r.top >= top && r.bottom <= bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
|
||||||
|
bool vertical)
|
||||||
|
{
|
||||||
|
if (vertical)
|
||||||
|
{
|
||||||
|
return (x1 >= r.left && x1 <= r.right) &&
|
||||||
|
((y1 >= r.top && y1 <= r.bottom) ||
|
||||||
|
(y2 >= r.top && y2 <= r.bottom));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (y1 >= r.top && y1 <= r.bottom) &&
|
||||||
|
((x1 >= r.left && x1 <= r.right) ||
|
||||||
|
(x2 >= r.left && x2 <= r.right));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
#ifndef _SRECT_H_
|
||||||
|
#define _SRECT_H_
|
||||||
|
|
||||||
|
// define used when this class also needs to support BRects
|
||||||
|
/*
|
||||||
|
#ifndef BE_SUPPORT
|
||||||
|
#define BE_SUPPORT
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include "SPoint.h"
|
||||||
|
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
#include <Rect.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SRect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float left;
|
||||||
|
float top;
|
||||||
|
float right;
|
||||||
|
float bottom;
|
||||||
|
|
||||||
|
SRect();
|
||||||
|
SRect(const SRect &r);
|
||||||
|
SRect(float l, float t, float r, float b);
|
||||||
|
SRect(SPoint lt, SPoint rb);
|
||||||
|
|
||||||
|
SRect &operator=(const SRect &r);
|
||||||
|
void Set(float l, float t, float r, float b);
|
||||||
|
|
||||||
|
void PrintToStream() const;
|
||||||
|
|
||||||
|
SPoint LeftTop() const;
|
||||||
|
SPoint RightBottom() const;
|
||||||
|
SPoint LeftBottom() const;
|
||||||
|
SPoint RightTop() const;
|
||||||
|
|
||||||
|
void SetLeftTop(const SPoint p);
|
||||||
|
void SetRightBottom(const SPoint p);
|
||||||
|
void SetLeftBottom(const SPoint p);
|
||||||
|
void SetRightTop(const SPoint p);
|
||||||
|
|
||||||
|
// transformation
|
||||||
|
void InsetBy(SPoint p);
|
||||||
|
void InsetBy(float dx, float dy);
|
||||||
|
void OffsetBy(SPoint p);
|
||||||
|
void OffsetBy(float dx, float dy);
|
||||||
|
void OffsetTo(SPoint p);
|
||||||
|
void OffsetTo(float x, float y);
|
||||||
|
|
||||||
|
// expression transformations
|
||||||
|
SRect & InsetBySelf(SPoint);
|
||||||
|
SRect & InsetBySelf(float dx, float dy);
|
||||||
|
SRect InsetByCopy(SPoint);
|
||||||
|
SRect InsetByCopy(float dx, float dy);
|
||||||
|
SRect & OffsetBySelf(SPoint);
|
||||||
|
SRect & OffsetBySelf(float dx, float dy);
|
||||||
|
SRect OffsetByCopy(SPoint);
|
||||||
|
SRect OffsetByCopy(float dx, float dy);
|
||||||
|
SRect & OffsetToSelf(SPoint);
|
||||||
|
SRect & OffsetToSelf(float dx, float dy);
|
||||||
|
SRect OffsetToCopy(SPoint);
|
||||||
|
SRect OffsetToCopy(float dx, float dy);
|
||||||
|
|
||||||
|
// comparison
|
||||||
|
bool operator==(SRect r) const;
|
||||||
|
bool operator!=(SRect r) const;
|
||||||
|
|
||||||
|
// intersection and union
|
||||||
|
SRect operator&(SRect r) const;
|
||||||
|
SRect operator|(SRect r) const;
|
||||||
|
|
||||||
|
bool Intersects(SRect r) const;
|
||||||
|
bool IsValid() const;
|
||||||
|
float Width() const;
|
||||||
|
int32 IntegerWidth() const;
|
||||||
|
float Height() const;
|
||||||
|
int32 IntegerHeight() const;
|
||||||
|
bool Contains(SPoint p) const;
|
||||||
|
bool Contains(SRect r) const;
|
||||||
|
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
BRect Rect(void) { return BRect(left,top,right,bottom); };
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// inline definitions ----------------------------------------------------------
|
||||||
|
|
||||||
|
inline SPoint SRect::LeftTop() const
|
||||||
|
{
|
||||||
|
return(*((const SPoint*)&left));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SPoint SRect::RightBottom() const
|
||||||
|
{
|
||||||
|
return(*((const SPoint*)&right));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SPoint SRect::LeftBottom() const
|
||||||
|
{
|
||||||
|
return(SPoint(left, bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SPoint SRect::RightTop() const
|
||||||
|
{
|
||||||
|
return(SPoint(right, top));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect()
|
||||||
|
{
|
||||||
|
top = left = 0;
|
||||||
|
bottom = right = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect(float l, float t, float r, float b)
|
||||||
|
{
|
||||||
|
left = l;
|
||||||
|
top = t;
|
||||||
|
right = r;
|
||||||
|
bottom = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect(const SRect &r)
|
||||||
|
{
|
||||||
|
left = r.left;
|
||||||
|
top = r.top;
|
||||||
|
right = r.right;
|
||||||
|
bottom = r.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect(SPoint leftTop, SPoint rightBottom)
|
||||||
|
{
|
||||||
|
left = leftTop.x;
|
||||||
|
top = leftTop.y;
|
||||||
|
right = rightBottom.x;
|
||||||
|
bottom = rightBottom.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect &SRect::operator=(const SRect& from)
|
||||||
|
{
|
||||||
|
left = from.left;
|
||||||
|
top = from.top;
|
||||||
|
right = from.right;
|
||||||
|
bottom = from.bottom;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SRect::Set(float l, float t, float r, float b)
|
||||||
|
{
|
||||||
|
left = l;
|
||||||
|
top = t;
|
||||||
|
right = r;
|
||||||
|
bottom = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SRect::IsValid() const
|
||||||
|
{
|
||||||
|
if (left <= right && top <= bottom)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 SRect::IntegerWidth() const
|
||||||
|
{
|
||||||
|
return((int32)ceil(right - left));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float SRect::Width() const
|
||||||
|
{
|
||||||
|
return(right - left);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 SRect::IntegerHeight() const
|
||||||
|
{
|
||||||
|
return((int32)ceil(bottom - top));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float SRect::Height() const
|
||||||
|
{
|
||||||
|
return(bottom - top);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef DEFS_H_
|
||||||
|
#define DEFS_H_
|
||||||
|
|
||||||
|
#define SETTINGS_DIR "/boot/home/config/settings/app_server/"
|
||||||
|
|
||||||
|
#define APPLY_SETTINGS 'aply'
|
||||||
|
#define REVERT_SETTINGS 'rvrt'
|
||||||
|
#define DEFAULT_SETTINGS 'dflt'
|
||||||
|
#define TRY_SETTINGS 'trys'
|
||||||
|
|
||||||
|
#define ATTRIBUTE_CHOSEN 'atch'
|
||||||
|
#define UPDATE_COLOR 'upcl'
|
||||||
|
#define DECORATOR_CHOSEN 'dcch'
|
||||||
|
#define UPDATE_DECORATOR 'updc'
|
||||||
|
|
||||||
|
#define SET_DECORATOR 'sdec'
|
||||||
|
#define GET_DECORATOR 'gdec'
|
||||||
|
|
||||||
|
#define SET_UI_COLORS 'suic'
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
SubDir OBOS_TOP src add-ons decorators ;
|
||||||
|
|
||||||
|
SubInclude OBOS_TOP src add-ons decorators BeDecorator ;
|
||||||
|
SubInclude OBOS_TOP src add-ons decorators WinDecorator ;
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
#include "ColorSet.h"
|
||||||
|
|
||||||
|
ColorSet::ColorSet(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorSet::ColorSet(const ColorSet &cs)
|
||||||
|
{
|
||||||
|
panel_background=cs.panel_background;
|
||||||
|
panel_text=cs.panel_text;
|
||||||
|
document_background=cs.document_background;
|
||||||
|
document_text=cs.document_text;
|
||||||
|
control_background=cs.control_background;
|
||||||
|
control_text=cs.control_text;
|
||||||
|
control_border=cs.control_border;
|
||||||
|
control_highlight=cs.control_highlight;
|
||||||
|
tooltip_background=cs.tooltip_background;
|
||||||
|
tooltip_text=cs.tooltip_text;
|
||||||
|
menu_background=cs.menu_background;
|
||||||
|
menu_selected_background=cs.menu_selected_background;
|
||||||
|
menu_text=cs.menu_text;
|
||||||
|
menu_selected_text=cs.menu_selected_text;
|
||||||
|
menu_separator_high=cs.menu_separator_high;
|
||||||
|
menu_separator_low=cs.menu_separator_low;
|
||||||
|
menu_triggers=cs.menu_triggers;
|
||||||
|
window_tab=cs.window_tab;
|
||||||
|
window_tab_text=cs.window_tab_text;
|
||||||
|
keyboard_navigation=cs.keyboard_navigation;
|
||||||
|
desktop=cs.desktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColorSet & ColorSet::operator=(const ColorSet &cs)
|
||||||
|
{
|
||||||
|
SetColors(cs);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColorSet::SetColors(const ColorSet &cs)
|
||||||
|
{
|
||||||
|
panel_background=cs.panel_background;
|
||||||
|
panel_text=cs.panel_text;
|
||||||
|
document_background=cs.document_background;
|
||||||
|
document_text=cs.document_text;
|
||||||
|
control_background=cs.control_background;
|
||||||
|
control_text=cs.control_text;
|
||||||
|
control_border=cs.control_border;
|
||||||
|
control_highlight=cs.control_highlight;
|
||||||
|
tooltip_background=cs.tooltip_background;
|
||||||
|
tooltip_text=cs.tooltip_text;
|
||||||
|
menu_background=cs.menu_background;
|
||||||
|
menu_selected_background=cs.menu_selected_background;
|
||||||
|
menu_text=cs.menu_text;
|
||||||
|
menu_selected_text=cs.menu_selected_text;
|
||||||
|
menu_separator_high=cs.menu_separator_high;
|
||||||
|
menu_separator_low=cs.menu_separator_low;
|
||||||
|
menu_triggers=cs.menu_triggers;
|
||||||
|
window_tab=cs.window_tab;
|
||||||
|
window_tab_text=cs.window_tab_text;
|
||||||
|
keyboard_navigation=cs.keyboard_navigation;
|
||||||
|
desktop=cs.desktop;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef COLORSET_H_
|
||||||
|
#define COLORSET_H_
|
||||||
|
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
class ColorSet
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ColorSet(void);
|
||||||
|
ColorSet(const ColorSet &cs);
|
||||||
|
ColorSet & operator=(const ColorSet &cs);
|
||||||
|
void SetColors(const ColorSet &cs);
|
||||||
|
|
||||||
|
RGBColor panel_background,
|
||||||
|
panel_text,
|
||||||
|
document_background,
|
||||||
|
document_text,
|
||||||
|
control_background,
|
||||||
|
control_text,
|
||||||
|
control_border,
|
||||||
|
control_highlight,
|
||||||
|
tooltip_background,
|
||||||
|
tooltip_text,
|
||||||
|
menu_background,
|
||||||
|
menu_selected_background,
|
||||||
|
menu_text,
|
||||||
|
menu_selected_text,
|
||||||
|
menu_separator_high,
|
||||||
|
menu_separator_low,
|
||||||
|
menu_triggers,
|
||||||
|
window_tab,
|
||||||
|
window_tab_text,
|
||||||
|
keyboard_navigation,
|
||||||
|
desktop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
#include "ColorUtils.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
//#define DEBUG_COLOR_UTILS
|
||||||
|
|
||||||
|
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||||
|
{
|
||||||
|
col->red=r;
|
||||||
|
col->green=g;
|
||||||
|
col->blue=b;
|
||||||
|
col->alpha=a;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 FindClosestColor(rgb_color *palette, rgb_color color)
|
||||||
|
{
|
||||||
|
// We will be passed a 256-color palette and a 24-bit color
|
||||||
|
uint16 cindex=0,cdelta=765,delta=765;
|
||||||
|
rgb_color *c;
|
||||||
|
|
||||||
|
for(uint16 i=0;i<256;i++)
|
||||||
|
{
|
||||||
|
c=&(palette[i]);
|
||||||
|
delta=abs(c->red-color.red)+abs(c->green-color.green)+
|
||||||
|
abs(c->blue-color.blue);
|
||||||
|
|
||||||
|
if(delta==0)
|
||||||
|
{
|
||||||
|
cindex=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(delta<cdelta)
|
||||||
|
{
|
||||||
|
cindex=i;
|
||||||
|
cdelta=delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef DEBUG_COLOR_UTILS
|
||||||
|
printf("FindClosestColor( {%u,%u,%u,%u} ) : {%u,%u,%u,%u}\n",
|
||||||
|
color.red,color.green,color.blue,color.alpha,
|
||||||
|
palette[cindex].red,palette[cindex].green,palette[cindex].blue,palette[cindex].alpha);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (uint8)cindex;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 FindClosestColor16(rgb_color color)
|
||||||
|
{
|
||||||
|
printf("FindClosestColor16 unimplemented\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position)
|
||||||
|
{
|
||||||
|
rgb_color newcol={0,0,0,0};
|
||||||
|
float mod=0;
|
||||||
|
int16 delta;
|
||||||
|
if(position<0 || position>1)
|
||||||
|
return newcol;
|
||||||
|
|
||||||
|
delta=int16(col2.red)-int16(col.red);
|
||||||
|
mod=col.red + (position * delta);
|
||||||
|
newcol.red=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.red=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.red=0;
|
||||||
|
|
||||||
|
delta=int16(col2.green)-int16(col.green);
|
||||||
|
mod=col.green + (position * delta);
|
||||||
|
newcol.green=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.green=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.green=0;
|
||||||
|
|
||||||
|
delta=int16(col2.blue)-int16(col.blue);
|
||||||
|
mod=col.blue + (position * delta);
|
||||||
|
newcol.blue=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.blue=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.blue=0;
|
||||||
|
|
||||||
|
delta=int8(col2.alpha)-int8(col.alpha);
|
||||||
|
mod=col.alpha + (position * delta);
|
||||||
|
newcol.alpha=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.alpha=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.alpha=0;
|
||||||
|
#ifdef DEBUG_COLOR_UTILS
|
||||||
|
printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
|
||||||
|
col.red,col.green,col.blue,col.alpha,
|
||||||
|
col2.red,col2.green,col2.blue,col2.alpha,
|
||||||
|
position,
|
||||||
|
newcol.red,newcol.green,newcol.blue,newcol.alpha);
|
||||||
|
#endif
|
||||||
|
return newcol;
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef COLORUTILS_H_
|
||||||
|
#define COLORUTILS_H_
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
|
// Quick assignment for rgb_color structs
|
||||||
|
void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
|
|
||||||
|
// Given a color palette, returns the index of the closest match to
|
||||||
|
// the color passed to it. Alpha values are not considered
|
||||||
|
uint8 FindClosestColor(rgb_color *palette, rgb_color color);
|
||||||
|
uint16 FindClosestColor16(rgb_color color);
|
||||||
|
|
||||||
|
// Function which could be used to calculate gradient colors. Position is
|
||||||
|
// a floating point number such that 0.0 <= position <= 1.0. Any number outside
|
||||||
|
// this range will cause the function to fail and return the color (0,0,0,0)
|
||||||
|
// Alpha components are included in the calculations. 0 yields color #1
|
||||||
|
// and 1 yields color #2.
|
||||||
|
rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
#include "Decorator.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
Decorator::Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||||
|
{
|
||||||
|
close_state=false;
|
||||||
|
minimize_state=false;
|
||||||
|
zoom_state=false;
|
||||||
|
title_string=NULL;
|
||||||
|
driver=NULL;
|
||||||
|
|
||||||
|
closerect.Set(0,0,1,1);
|
||||||
|
zoomrect.Set(0,0,1,1);
|
||||||
|
minimizerect.Set(0,0,1,1);
|
||||||
|
resizerect.Set(0,0,1,1);
|
||||||
|
frame=rect;
|
||||||
|
tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4));
|
||||||
|
|
||||||
|
look=wlook;
|
||||||
|
feel=wfeel;
|
||||||
|
flags=wflags;
|
||||||
|
|
||||||
|
colors=new ColorSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
Decorator::~Decorator(void)
|
||||||
|
{
|
||||||
|
if(colors!=NULL)
|
||||||
|
{
|
||||||
|
delete colors;
|
||||||
|
colors=NULL;
|
||||||
|
}
|
||||||
|
if(title_string)
|
||||||
|
delete title_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetColors(ColorSet cset)
|
||||||
|
{
|
||||||
|
colors->SetColors(cset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetDriver(DisplayDriver *d)
|
||||||
|
{
|
||||||
|
driver=d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetClose(bool is_down)
|
||||||
|
{
|
||||||
|
close_state=is_down;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetMinimize(bool is_down)
|
||||||
|
{
|
||||||
|
zoom_state=is_down;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetZoom(bool is_down)
|
||||||
|
{
|
||||||
|
minimize_state=is_down;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetFlags(int32 wflags)
|
||||||
|
{
|
||||||
|
flags=wflags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetFeel(int32 wfeel)
|
||||||
|
{
|
||||||
|
feel=wfeel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetLook(int32 wlook)
|
||||||
|
{
|
||||||
|
look=wlook;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Decorator::GetClose(void)
|
||||||
|
{
|
||||||
|
return close_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Decorator::GetMinimize(void)
|
||||||
|
{
|
||||||
|
return minimize_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Decorator::GetZoom(void)
|
||||||
|
{
|
||||||
|
return zoom_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Decorator::GetLook(void)
|
||||||
|
{
|
||||||
|
return look;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Decorator::GetFeel(void)
|
||||||
|
{
|
||||||
|
return feel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 Decorator::GetFlags(void)
|
||||||
|
{
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetTitle(const char *string)
|
||||||
|
{
|
||||||
|
if(string)
|
||||||
|
{
|
||||||
|
size_t size=strlen(string);
|
||||||
|
if(!(size>0))
|
||||||
|
return;
|
||||||
|
delete title_string;
|
||||||
|
title_string=new char[size];
|
||||||
|
strcpy(title_string,string);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete title_string;
|
||||||
|
title_string=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *Decorator::GetTitle(void)
|
||||||
|
{
|
||||||
|
return title_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::SetFocus(bool is_active)
|
||||||
|
{
|
||||||
|
has_focus=is_active;
|
||||||
|
_SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void Decorator::SetFont(SFont *sf)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
void Decorator::_ClipTitle(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// Virtual Methods
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
void Decorator::MoveBy(float x, float y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::MoveBy(SPoint pt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::ResizeBy(float x, float y)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::ResizeBy(SPoint pt)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::Draw(SRect r)
|
||||||
|
{
|
||||||
|
_DrawTab(r & tabrect);
|
||||||
|
_DrawFrame(r & frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::Draw(void)
|
||||||
|
{
|
||||||
|
_DrawTab(tabrect);
|
||||||
|
_DrawFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawClose(void)
|
||||||
|
{
|
||||||
|
_DrawClose(closerect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawFrame(void)
|
||||||
|
{
|
||||||
|
_DrawFrame(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawMinimize(void)
|
||||||
|
{
|
||||||
|
_DrawTab(minimizerect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawTab(void)
|
||||||
|
{
|
||||||
|
_DrawTab(tabrect);
|
||||||
|
_DrawZoom(zoomrect);
|
||||||
|
_DrawMinimize(minimizerect);
|
||||||
|
_DrawTitle(tabrect);
|
||||||
|
_DrawClose(closerect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawTitle(void)
|
||||||
|
{
|
||||||
|
_DrawTitle(tabrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::DrawZoom(void)
|
||||||
|
{
|
||||||
|
_DrawZoom(zoomrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawClose(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawFrame(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawMinimize(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawTab(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawTitle(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decorator::_DrawZoom(SRect r)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
SRegion Decorator::GetFootprint(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
click_type Decorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
|
||||||
|
{
|
||||||
|
return CLICK_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
#ifndef _DECORATOR_H_
|
||||||
|
#define _DECORATOR_H_
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include "SRect.h"
|
||||||
|
#include "ColorSet.h"
|
||||||
|
#include "LayerData.h"
|
||||||
|
|
||||||
|
class DisplayDriver;
|
||||||
|
|
||||||
|
typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE,
|
||||||
|
CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT,
|
||||||
|
|
||||||
|
CLICK_RESIZE, CLICK_RESIZE_L, CLICK_RESIZE_T,
|
||||||
|
CLICK_RESIZE_R, CLICK_RESIZE_B, CLICK_RESIZE_LT, CLICK_RESIZE_RT,
|
||||||
|
CLICK_RESIZE_LB, CLICK_RESIZE_RB } click_type;
|
||||||
|
|
||||||
|
// Definitions which are used in place of including Window.h
|
||||||
|
// window_look and window_feel are enumerated types, so we convert them
|
||||||
|
// to uint32's in order to ensure a constant size when sending via PortLink
|
||||||
|
// instead of depending on magic numbers in the header file.
|
||||||
|
|
||||||
|
#define WLOOK_NO_BORDER 0
|
||||||
|
#define WLOOK_BORDERED 1
|
||||||
|
#define WLOOK_TITLED 2
|
||||||
|
#define WLOOK_DOCUMENT 3
|
||||||
|
#define WLOOK_MODAL 4
|
||||||
|
#define WLOOK_FLOATING 5
|
||||||
|
|
||||||
|
#define WFEEL_NORMAL 0
|
||||||
|
#define WFEEL_MODAL_SUBSET 1
|
||||||
|
#define WFEEL_MODAL_APP 2
|
||||||
|
#define WFEEL_MODAL_WINDOW 3
|
||||||
|
#define WFEEL_FLOATING_SUBSET 4
|
||||||
|
#define WFEEL_FLOATING_APP 5
|
||||||
|
#define WFEEL_FLOATING_WINDOW 6
|
||||||
|
|
||||||
|
#define NOT_MOVABLE 0x00000001
|
||||||
|
#define NOT_CLOSABLE 0x00000020
|
||||||
|
#define NOT_ZOOMABLE 0x00000040
|
||||||
|
#define NOT_MINIMIZABLE 0x00004000
|
||||||
|
#define NOT_RESIZABLE 0x00000002
|
||||||
|
#define NOT_H_RESIZABLE 0x00000004
|
||||||
|
#define NOT_V_RESIZABLE 0x00000008
|
||||||
|
#define AVOID_FRONT 0x00000080
|
||||||
|
#define AVOID_FOCUS 0x00002000
|
||||||
|
#define WILL_ACCEPT_FIRST_CLICK 0x00000010
|
||||||
|
#define OUTLINE_RESIZE 0x00001000
|
||||||
|
#define NO_WORKSPACE_ACTIVATION 0x00000100
|
||||||
|
#define NOT_ANCHORED_ON_ACTIVATE 0x00020000
|
||||||
|
#define ASYNCHRONOUS_CONTROLS 0x00080000
|
||||||
|
#define QUIT_ON_WINDOW_CLOSE 0x00100000
|
||||||
|
|
||||||
|
class Decorator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags);
|
||||||
|
virtual ~Decorator(void);
|
||||||
|
void SetColors(ColorSet cset);
|
||||||
|
void SetDriver(DisplayDriver *d);
|
||||||
|
void SetClose(bool is_down);
|
||||||
|
void SetMinimize(bool is_down);
|
||||||
|
void SetZoom(bool is_down);
|
||||||
|
void SetFlags(int32 wflags);
|
||||||
|
void SetFeel(int32 wfeel);
|
||||||
|
void SetLook(int32 wlook);
|
||||||
|
bool GetClose(void);
|
||||||
|
bool GetMinimize(void);
|
||||||
|
bool GetZoom(void);
|
||||||
|
int32 GetLook(void);
|
||||||
|
int32 GetFeel(void);
|
||||||
|
int32 GetFlags(void);
|
||||||
|
void SetTitle(const char *string);
|
||||||
|
void SetFocus(bool is_active);
|
||||||
|
bool GetFocus(void) { return has_focus; };
|
||||||
|
const char *GetTitle(void);
|
||||||
|
// void SetFont(SFont *sf);
|
||||||
|
void _ClipTitle(void);
|
||||||
|
ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); }
|
||||||
|
|
||||||
|
virtual void MoveBy(float x, float y);
|
||||||
|
virtual void MoveBy(SPoint pt);
|
||||||
|
virtual void ResizeBy(float x, float y);
|
||||||
|
virtual void ResizeBy(SPoint pt);
|
||||||
|
virtual void Draw(SRect r);
|
||||||
|
virtual void Draw(void);
|
||||||
|
virtual void DrawClose(void);
|
||||||
|
virtual void DrawFrame(void);
|
||||||
|
virtual void DrawMinimize(void);
|
||||||
|
virtual void DrawTab(void);
|
||||||
|
virtual void DrawTitle(void);
|
||||||
|
virtual void DrawZoom(void);
|
||||||
|
//virtual SRegion GetFootprint(void);
|
||||||
|
virtual click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void _DrawClose(SRect r);
|
||||||
|
virtual void _DrawFrame(SRect r);
|
||||||
|
virtual void _DrawMinimize(SRect r);
|
||||||
|
virtual void _DrawTab(SRect r);
|
||||||
|
virtual void _DrawTitle(SRect r);
|
||||||
|
virtual void _DrawZoom(SRect r);
|
||||||
|
virtual void _SetFocus(void)=0;
|
||||||
|
virtual void _DoLayout(void)=0;
|
||||||
|
ColorSet *colors;
|
||||||
|
int32 look, feel, flags;
|
||||||
|
DisplayDriver *driver;
|
||||||
|
LayerData layerdata;
|
||||||
|
SRect zoomrect,closerect,minimizerect,tabrect,frame,
|
||||||
|
resizerect,borderrect;
|
||||||
|
private:
|
||||||
|
bool close_state, zoom_state, minimize_state;
|
||||||
|
bool has_focus;
|
||||||
|
char *title_string;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
DisplayDriver.cpp
|
||||||
|
Modular class to allow the server to not care what the ultimate output is
|
||||||
|
for graphics calls.
|
||||||
|
*/
|
||||||
|
#include "DisplayDriver.h"
|
||||||
|
#include "LayerData.h"
|
||||||
|
|
||||||
|
DisplayDriver::DisplayDriver(void)
|
||||||
|
{
|
||||||
|
lock_sem=create_sem(1,"displaydriver_lock");
|
||||||
|
buffer_depth=0;
|
||||||
|
buffer_width=0;
|
||||||
|
buffer_height=0;
|
||||||
|
buffer_mode=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisplayDriver::~DisplayDriver(void)
|
||||||
|
{
|
||||||
|
delete_sem(lock_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayDriver::Initialize(void)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 DisplayDriver::GetDepth(void)
|
||||||
|
{
|
||||||
|
return buffer_depth;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 DisplayDriver::GetHeight(void)
|
||||||
|
{
|
||||||
|
return buffer_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 DisplayDriver::GetWidth(void)
|
||||||
|
{
|
||||||
|
return buffer_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 DisplayDriver::GetMode(void)
|
||||||
|
{
|
||||||
|
return buffer_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DisplayDriver::DumpToFile(const char *path)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------
|
||||||
|
// Private Methods
|
||||||
|
//---------------------------------------------------------
|
||||||
|
|
||||||
|
void DisplayDriver::Lock(void)
|
||||||
|
{
|
||||||
|
acquire_sem(lock_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::Unlock(void)
|
||||||
|
{
|
||||||
|
release_sem(lock_sem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetDepthInternal(uint8 d)
|
||||||
|
{
|
||||||
|
buffer_depth=d;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetHeightInternal(uint16 h)
|
||||||
|
{
|
||||||
|
buffer_height=h;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetWidthInternal(uint16 w)
|
||||||
|
{
|
||||||
|
buffer_width=w;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisplayDriver::SetModeInternal(int32 m)
|
||||||
|
{
|
||||||
|
buffer_mode=m;
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#ifndef _DISPLAY_DRIVER_H_
|
||||||
|
#define _DISPLAY_DRIVER_H_
|
||||||
|
|
||||||
|
#include <GraphicsCard.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
|
#include "SRect.h"
|
||||||
|
#include "SPoint.h"
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
class ServerBitmap;
|
||||||
|
class ServerCursor;
|
||||||
|
class LayerData;
|
||||||
|
|
||||||
|
#ifndef ROUND
|
||||||
|
#define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uchar *xormask, *andmask;
|
||||||
|
int32 width, height;
|
||||||
|
int32 hotx, hoty;
|
||||||
|
|
||||||
|
} cursor_data;
|
||||||
|
|
||||||
|
#ifndef HOOK_DEFINE_CURSOR
|
||||||
|
|
||||||
|
#define HOOK_DEFINE_CURSOR 0
|
||||||
|
#define HOOK_MOVE_CURSOR 1
|
||||||
|
#define HOOK_SHOW_CURSOR 2
|
||||||
|
#define HOOK_DRAW_LINE_8BIT 3
|
||||||
|
#define HOOK_DRAW_LINE_16BIT 12
|
||||||
|
#define HOOK_DRAW_LINE_32BIT 4
|
||||||
|
#define HOOK_DRAW_RECT_8BIT 5
|
||||||
|
#define HOOK_DRAW_RECT_16BIT 13
|
||||||
|
#define HOOK_DRAW_RECT_32BIT 6
|
||||||
|
#define HOOK_BLIT 7
|
||||||
|
#define HOOK_DRAW_ARRAY_8BIT 8
|
||||||
|
#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers
|
||||||
|
#define HOOK_DRAW_ARRAY_32BIT 9
|
||||||
|
#define HOOK_SYNC 10
|
||||||
|
#define HOOK_INVERT_RECT 11
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DRAW_COPY 0
|
||||||
|
#define DRAW_OVER 1
|
||||||
|
#define DRAW_ERASE 2
|
||||||
|
#define DRAW_INVERT 3
|
||||||
|
#define DRAW_ADD 4
|
||||||
|
#define DRAW_SUBTRACT 5
|
||||||
|
#define DRAW_BLEND 6
|
||||||
|
#define DRAW_MIN 7
|
||||||
|
#define DRAW_MAX 8
|
||||||
|
#define DRAW_SELECT 9
|
||||||
|
#define DRAW_ALPHA 10
|
||||||
|
|
||||||
|
class DisplayDriver
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DisplayDriver(void);
|
||||||
|
virtual ~DisplayDriver(void);
|
||||||
|
virtual bool Initialize(void);
|
||||||
|
virtual void Shutdown(void)=0;
|
||||||
|
virtual void CopyBits(SRect src, SRect dest)=0;
|
||||||
|
virtual void DrawBitmap(ServerBitmap *bmp, SRect src, SRect dest)=0;
|
||||||
|
virtual void DrawChar(char c, SPoint pt)=0;
|
||||||
|
// virtual void DrawPicture(SPicture *pic, SPoint pt)=0;
|
||||||
|
// virtual void DrawString(const char *string, int32 length, SPoint pt, escapement_delta *delta=NULL)=0;
|
||||||
|
virtual void InvertRect(SRect r)=0;
|
||||||
|
virtual void StrokeBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillBezier(SPoint *pts, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeEllipse(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillEllipse(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillArc(SRect r, float angle, float span, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeLine(SPoint start, SPoint end, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokePolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat, bool is_closed=true)=0;
|
||||||
|
virtual void FillPolygon(SPoint *ptlist, int32 numpts, SRect rect, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeRect(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillRect(SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillRoundRect(SRect r, float xrad, float yrad, LayerData *d, int8 *pat)=0;
|
||||||
|
// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat)=0;
|
||||||
|
// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void FillTriangle(SPoint *pts, SRect r, LayerData *d, int8 *pat)=0;
|
||||||
|
virtual void StrokeLineArray(SPoint *pts, int32 numlines, RGBColor *colors, LayerData *d)=0;
|
||||||
|
virtual void SetMode(int32 mode)=0;
|
||||||
|
virtual bool DumpToFile(const char *path)=0;
|
||||||
|
|
||||||
|
uint8 GetDepth(void);
|
||||||
|
uint16 GetHeight(void);
|
||||||
|
uint16 GetWidth(void);
|
||||||
|
int32 GetMode(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Lock(void);
|
||||||
|
void Unlock(void);
|
||||||
|
void SetDepthInternal(uint8 d);
|
||||||
|
void SetHeightInternal(uint16 h);
|
||||||
|
void SetWidthInternal(uint16 w);
|
||||||
|
void SetModeInternal(int32 m);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sem_id lock_sem;
|
||||||
|
uint8 buffer_depth;
|
||||||
|
uint16 buffer_width;
|
||||||
|
uint16 buffer_height;
|
||||||
|
int32 buffer_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#ifndef LAYERDATA_H_
|
||||||
|
#define LAYERDATA_H_
|
||||||
|
|
||||||
|
class ServerBitmap;
|
||||||
|
|
||||||
|
class LayerData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LayerData(void)
|
||||||
|
{
|
||||||
|
pensize=1.0;
|
||||||
|
penlocation.Set(0,0);
|
||||||
|
drawing_mode=0;
|
||||||
|
bitmap_background=NULL;
|
||||||
|
bitmap_overlay=NULL;
|
||||||
|
highcolor.SetColor(0,0,0,255);
|
||||||
|
lowcolor.SetColor(255,255,255,255);
|
||||||
|
//SFont font;
|
||||||
|
//bool antialias_text;
|
||||||
|
scale=1.0;
|
||||||
|
};
|
||||||
|
|
||||||
|
float pensize;
|
||||||
|
SPoint penlocation;
|
||||||
|
int32 drawing_mode;
|
||||||
|
ServerBitmap *bitmap_background;
|
||||||
|
ServerBitmap *bitmap_overlay;
|
||||||
|
RGBColor highcolor, lowcolor;
|
||||||
|
//SFont font;
|
||||||
|
//bool antialias_text;
|
||||||
|
float scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
/*
|
||||||
|
RGBColor.cpp
|
||||||
|
Color encapsulation class for app_server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||||
|
{
|
||||||
|
SetColor(r,g,b,a);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(rgb_color col)
|
||||||
|
{
|
||||||
|
SetColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(uint16 col)
|
||||||
|
{
|
||||||
|
SetColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(uint8 col)
|
||||||
|
{
|
||||||
|
SetColor(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(const RGBColor &col)
|
||||||
|
{
|
||||||
|
color32=col.color32;
|
||||||
|
color16=col.color16;
|
||||||
|
color8=col.color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor::RGBColor(void)
|
||||||
|
{
|
||||||
|
SetColor(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 RGBColor::GetColor8(void)
|
||||||
|
{
|
||||||
|
return color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16 RGBColor::GetColor16(void)
|
||||||
|
{
|
||||||
|
return color16;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color RGBColor::GetColor32(void)
|
||||||
|
{
|
||||||
|
return color32;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255)
|
||||||
|
{
|
||||||
|
color32.red=r;
|
||||||
|
color32.green=g;
|
||||||
|
color32.blue=b;
|
||||||
|
color32.alpha=a;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(uint16 col16)
|
||||||
|
{
|
||||||
|
// Pared-down version from what is used in the app_server to
|
||||||
|
// eliminate some dependencies
|
||||||
|
color16=col16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(uint8 col8)
|
||||||
|
{
|
||||||
|
// Pared-down version from what is used in the app_server to
|
||||||
|
// eliminate some dependencies
|
||||||
|
color8=col8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(rgb_color color)
|
||||||
|
{
|
||||||
|
// Pared-down version from what is used in the app_server to
|
||||||
|
// eliminate some dependencies
|
||||||
|
color32=color;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBColor::SetColor(const RGBColor &col)
|
||||||
|
{
|
||||||
|
color32=col.color32;
|
||||||
|
color16=col.color16;
|
||||||
|
color8=col.color8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RGBColor & RGBColor::operator=(const RGBColor &col)
|
||||||
|
{
|
||||||
|
color32=col.color32;
|
||||||
|
color16=col.color16;
|
||||||
|
color8=col.color8;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor & RGBColor::operator=(rgb_color col)
|
||||||
|
{
|
||||||
|
color32=col;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBColor RGBColor::MakeBlendColor(RGBColor color, float position)
|
||||||
|
{
|
||||||
|
rgb_color col=color32;
|
||||||
|
rgb_color col2=color.color32;
|
||||||
|
|
||||||
|
rgb_color newcol={0,0,0,0};
|
||||||
|
float mod=0;
|
||||||
|
int16 delta;
|
||||||
|
if(position<0 || position>1)
|
||||||
|
return newcol;
|
||||||
|
|
||||||
|
delta=int16(col2.red)-int16(col.red);
|
||||||
|
mod=col.red + (position * delta);
|
||||||
|
newcol.red=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.red=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.red=0;
|
||||||
|
|
||||||
|
delta=int16(col2.green)-int16(col.green);
|
||||||
|
mod=col.green + (position * delta);
|
||||||
|
newcol.green=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.green=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.green=0;
|
||||||
|
|
||||||
|
delta=int16(col2.blue)-int16(col.blue);
|
||||||
|
mod=col.blue + (position * delta);
|
||||||
|
newcol.blue=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.blue=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.blue=0;
|
||||||
|
|
||||||
|
delta=int8(col2.alpha)-int8(col.alpha);
|
||||||
|
mod=col.alpha + (position * delta);
|
||||||
|
newcol.alpha=uint8(mod);
|
||||||
|
if(mod>255 )
|
||||||
|
newcol.alpha=255;
|
||||||
|
if(mod<0 )
|
||||||
|
newcol.alpha=0;
|
||||||
|
#ifdef DEBUG_COLOR_UTILS
|
||||||
|
printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n",
|
||||||
|
col.red,col.green,col.blue,col.alpha,
|
||||||
|
col2.red,col2.green,col2.blue,col2.alpha,
|
||||||
|
position,
|
||||||
|
newcol.red,newcol.green,newcol.blue,newcol.alpha);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return RGBColor(newcol);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef RGBCOLOR_H_
|
||||||
|
#define RGBCOLOR_H_
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
|
class RGBColor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
|
RGBColor(rgb_color col);
|
||||||
|
RGBColor(uint16 col);
|
||||||
|
RGBColor(uint8 col);
|
||||||
|
RGBColor(const RGBColor &col);
|
||||||
|
RGBColor(void);
|
||||||
|
uint8 GetColor8(void);
|
||||||
|
uint16 GetColor16(void);
|
||||||
|
rgb_color GetColor32(void);
|
||||||
|
void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255);
|
||||||
|
void SetColor(uint16 color16);
|
||||||
|
void SetColor(uint8 color8);
|
||||||
|
void SetColor(rgb_color color);
|
||||||
|
void SetColor(const RGBColor &col);
|
||||||
|
RGBColor MakeBlendColor(RGBColor color, float position);
|
||||||
|
RGBColor & operator=(const RGBColor &col);
|
||||||
|
RGBColor & operator=(rgb_color col);
|
||||||
|
protected:
|
||||||
|
rgb_color color32;
|
||||||
|
uint16 color16;
|
||||||
|
uint8 color8;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
SPoint.cpp:
|
||||||
|
Point class which utilizes Frans van Nispen's original SPoint sources
|
||||||
|
and extends them slightly for app_server use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include "SPoint.h"
|
||||||
|
#include "SRect.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SPoint::ConstrainTo(SRect r)
|
||||||
|
{
|
||||||
|
x = max_c(min_c(x, r.right), r.left);
|
||||||
|
y = max_c(min_c(y, r.bottom), r.top);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SPoint::PrintToStream() const
|
||||||
|
{
|
||||||
|
printf("SPoint(x:%.0f, y:%.0f)\n", x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator+(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint(x + p.x, y + p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator-(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint(x - p.x, y - p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator*(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint(x * p.x, y * p.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint SPoint::operator/(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return SPoint((p.x!=0)?(x / p.x):0,(p.y!=0)?(y / p.y):0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint& SPoint::operator+=(const SPoint& p)
|
||||||
|
{
|
||||||
|
x += p.x;
|
||||||
|
y += p.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SPoint& SPoint::operator-=(const SPoint& p)
|
||||||
|
{
|
||||||
|
x -= p.x;
|
||||||
|
y -= p.y;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator!=(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x != p.x || y != p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator==(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x == p.x && y == p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator<=(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x <= p.x && y <= p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator>=(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x >= p.x && y >= p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator<(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x < p.x || y < p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SPoint::operator>(const SPoint& p) const
|
||||||
|
{
|
||||||
|
return x > p.x && y > p.y;
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#ifndef _SPOINT_H
|
||||||
|
#define _SPOINT_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
class SRect;
|
||||||
|
/*
|
||||||
|
#ifndef BE_SUPPORT
|
||||||
|
#define BE_SUPPORT
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SPoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
|
||||||
|
SPoint();
|
||||||
|
SPoint(float X, float Y);
|
||||||
|
SPoint(const SPoint &p);
|
||||||
|
|
||||||
|
SPoint &operator=(const SPoint &p);
|
||||||
|
void Set(float X, float Y);
|
||||||
|
|
||||||
|
void ConstrainTo(SRect r);
|
||||||
|
void PrintToStream() const;
|
||||||
|
|
||||||
|
SPoint operator+(const SPoint &p) const;
|
||||||
|
SPoint operator-(const SPoint &p) const;
|
||||||
|
SPoint operator*(const SPoint &p) const;
|
||||||
|
SPoint operator/(const SPoint &p) const;
|
||||||
|
SPoint& operator+=(const SPoint &p);
|
||||||
|
SPoint& operator-=(const SPoint &p);
|
||||||
|
|
||||||
|
bool operator!=(const SPoint &p) const;
|
||||||
|
bool operator==(const SPoint &p) const;
|
||||||
|
bool operator>=(const SPoint &p) const;
|
||||||
|
bool operator<=(const SPoint &p) const;
|
||||||
|
bool operator>(const SPoint &p) const;
|
||||||
|
bool operator<(const SPoint &p) const;
|
||||||
|
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
BPoint Point(void) { return BPoint(x,y); };
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
inline SPoint::SPoint()
|
||||||
|
{
|
||||||
|
x = y = 0;
|
||||||
|
}
|
||||||
|
inline SPoint::SPoint(float X, float Y)
|
||||||
|
{
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
}
|
||||||
|
inline SPoint::SPoint(const SPoint& pt)
|
||||||
|
{
|
||||||
|
x = pt.x;
|
||||||
|
y = pt.y;
|
||||||
|
}
|
||||||
|
inline SPoint &SPoint::operator=(const SPoint& from)
|
||||||
|
{
|
||||||
|
x = from.x;
|
||||||
|
y = from.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
inline void SPoint::Set(float X, float Y)
|
||||||
|
{
|
||||||
|
x = X;
|
||||||
|
y = Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/*
|
||||||
|
SPoint.cpp:
|
||||||
|
Point class which utilizes Frans van Nispen's original SPoint sources
|
||||||
|
and extends them slightly for app_server use.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "SRect.h"
|
||||||
|
|
||||||
|
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
|
||||||
|
bool vertical = true);
|
||||||
|
|
||||||
|
|
||||||
|
void SRect::InsetBy(SPoint p)
|
||||||
|
{
|
||||||
|
left += p.x;
|
||||||
|
right -= p.x;
|
||||||
|
top += p.y;
|
||||||
|
bottom -= p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::InsetBy(float dx, float dy)
|
||||||
|
{
|
||||||
|
left += dx;
|
||||||
|
right -= dx;
|
||||||
|
top += dy;
|
||||||
|
bottom -= dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::InsetBySelf(SPoint p)
|
||||||
|
{
|
||||||
|
this->InsetBy(p);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::InsetBySelf(float dx, float dy)
|
||||||
|
{
|
||||||
|
this->InsetBy(dx, dy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::InsetByCopy(SPoint p)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.InsetBy(p);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::InsetByCopy(float dx, float dy)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.InsetBy(dx, dy);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetBy(SPoint p)
|
||||||
|
{
|
||||||
|
left += p.x;
|
||||||
|
right += p.x;
|
||||||
|
top += p.y;
|
||||||
|
bottom += p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetBy(float dx, float dy)
|
||||||
|
{
|
||||||
|
left += dx;
|
||||||
|
right += dx;
|
||||||
|
top += dy;
|
||||||
|
bottom += dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetBySelf(SPoint p)
|
||||||
|
{
|
||||||
|
this->OffsetBy(p);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetBySelf(float dx, float dy)
|
||||||
|
{
|
||||||
|
this->OffsetBy(dx, dy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetByCopy(SPoint p)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetBy(p);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetByCopy(float dx, float dy)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetBy(dx, dy);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetTo(SPoint p)
|
||||||
|
{
|
||||||
|
right = (right - left) + p.x;
|
||||||
|
left = p.x;
|
||||||
|
bottom = (bottom - top) + p.y;
|
||||||
|
top = p.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::OffsetTo(float x, float y)
|
||||||
|
{
|
||||||
|
right = (right - left) + x;
|
||||||
|
left = x;
|
||||||
|
bottom = (bottom - top) + y;
|
||||||
|
top=y;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetToSelf(SPoint p)
|
||||||
|
{
|
||||||
|
this->OffsetTo(p);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect& SRect::OffsetToSelf(float dx, float dy)
|
||||||
|
{
|
||||||
|
this->OffsetTo(dx, dy);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetToCopy(SPoint p)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetTo(p);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::OffsetToCopy(float dx, float dy)
|
||||||
|
{
|
||||||
|
SRect copy(*this);
|
||||||
|
copy.OffsetTo(dx, dy);
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SRect::PrintToStream() const
|
||||||
|
{
|
||||||
|
printf("(l:%.1f t:%.1f r:%.1f b:%.1f)\n", left, top, right, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::operator==(SRect r) const
|
||||||
|
{
|
||||||
|
return left == r.left && right == r.right &&
|
||||||
|
top == r.top && bottom == r.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::operator!=(SRect r) const
|
||||||
|
{
|
||||||
|
return !(*this == r);
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::operator&(SRect r) const
|
||||||
|
{
|
||||||
|
return SRect(max_c(left, r.left), max_c(top, r.top),
|
||||||
|
min_c(right, r.right), min_c(bottom, r.bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
SRect SRect::operator|(SRect r) const
|
||||||
|
{
|
||||||
|
return SRect(min_c(left, r.left), min_c(top, r.top),
|
||||||
|
max_c(right, r.right), max_c(bottom, r.bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::Intersects(SRect r) const
|
||||||
|
{
|
||||||
|
return TestLineIntersect(*this, r.left, r.top, r.left, r.bottom) ||
|
||||||
|
TestLineIntersect(*this, r.left, r.top, r.right, r.top, false) ||
|
||||||
|
TestLineIntersect(*this, r.right, r.top, r.right, r.bottom) ||
|
||||||
|
TestLineIntersect(*this, r.left, r.bottom, r.right, r.bottom, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::Contains(SPoint p) const
|
||||||
|
{
|
||||||
|
return p.x >= left && p.x <= right && p.y >= top && p.y <= bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SRect::Contains(SRect r) const
|
||||||
|
{
|
||||||
|
return r.left >= left && r.right <= right &&
|
||||||
|
r.top >= top && r.bottom <= bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool TestLineIntersect(const SRect& r, float x1, float y1, float x2, float y2,
|
||||||
|
bool vertical)
|
||||||
|
{
|
||||||
|
if (vertical)
|
||||||
|
{
|
||||||
|
return (x1 >= r.left && x1 <= r.right) &&
|
||||||
|
((y1 >= r.top && y1 <= r.bottom) ||
|
||||||
|
(y2 >= r.top && y2 <= r.bottom));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (y1 >= r.top && y1 <= r.bottom) &&
|
||||||
|
((x1 >= r.left && x1 <= r.right) ||
|
||||||
|
(x2 >= r.left && x2 <= r.right));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
#ifndef _SRECT_H_
|
||||||
|
#define _SRECT_H_
|
||||||
|
|
||||||
|
// define used when this class also needs to support BRects
|
||||||
|
/*
|
||||||
|
#ifndef BE_SUPPORT
|
||||||
|
#define BE_SUPPORT
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
#include "SPoint.h"
|
||||||
|
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
#include <Rect.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class SRect
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float left;
|
||||||
|
float top;
|
||||||
|
float right;
|
||||||
|
float bottom;
|
||||||
|
|
||||||
|
SRect();
|
||||||
|
SRect(const SRect &r);
|
||||||
|
SRect(float l, float t, float r, float b);
|
||||||
|
SRect(SPoint lt, SPoint rb);
|
||||||
|
|
||||||
|
SRect &operator=(const SRect &r);
|
||||||
|
void Set(float l, float t, float r, float b);
|
||||||
|
|
||||||
|
void PrintToStream() const;
|
||||||
|
|
||||||
|
SPoint LeftTop() const;
|
||||||
|
SPoint RightBottom() const;
|
||||||
|
SPoint LeftBottom() const;
|
||||||
|
SPoint RightTop() const;
|
||||||
|
|
||||||
|
void SetLeftTop(const SPoint p);
|
||||||
|
void SetRightBottom(const SPoint p);
|
||||||
|
void SetLeftBottom(const SPoint p);
|
||||||
|
void SetRightTop(const SPoint p);
|
||||||
|
|
||||||
|
// transformation
|
||||||
|
void InsetBy(SPoint p);
|
||||||
|
void InsetBy(float dx, float dy);
|
||||||
|
void OffsetBy(SPoint p);
|
||||||
|
void OffsetBy(float dx, float dy);
|
||||||
|
void OffsetTo(SPoint p);
|
||||||
|
void OffsetTo(float x, float y);
|
||||||
|
|
||||||
|
// expression transformations
|
||||||
|
SRect & InsetBySelf(SPoint);
|
||||||
|
SRect & InsetBySelf(float dx, float dy);
|
||||||
|
SRect InsetByCopy(SPoint);
|
||||||
|
SRect InsetByCopy(float dx, float dy);
|
||||||
|
SRect & OffsetBySelf(SPoint);
|
||||||
|
SRect & OffsetBySelf(float dx, float dy);
|
||||||
|
SRect OffsetByCopy(SPoint);
|
||||||
|
SRect OffsetByCopy(float dx, float dy);
|
||||||
|
SRect & OffsetToSelf(SPoint);
|
||||||
|
SRect & OffsetToSelf(float dx, float dy);
|
||||||
|
SRect OffsetToCopy(SPoint);
|
||||||
|
SRect OffsetToCopy(float dx, float dy);
|
||||||
|
|
||||||
|
// comparison
|
||||||
|
bool operator==(SRect r) const;
|
||||||
|
bool operator!=(SRect r) const;
|
||||||
|
|
||||||
|
// intersection and union
|
||||||
|
SRect operator&(SRect r) const;
|
||||||
|
SRect operator|(SRect r) const;
|
||||||
|
|
||||||
|
bool Intersects(SRect r) const;
|
||||||
|
bool IsValid() const;
|
||||||
|
float Width() const;
|
||||||
|
int32 IntegerWidth() const;
|
||||||
|
float Height() const;
|
||||||
|
int32 IntegerHeight() const;
|
||||||
|
bool Contains(SPoint p) const;
|
||||||
|
bool Contains(SRect r) const;
|
||||||
|
|
||||||
|
#ifdef BE_SUPPORT
|
||||||
|
BRect Rect(void) { return BRect(left,top,right,bottom); };
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// inline definitions ----------------------------------------------------------
|
||||||
|
|
||||||
|
inline SPoint SRect::LeftTop() const
|
||||||
|
{
|
||||||
|
return(*((const SPoint*)&left));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SPoint SRect::RightBottom() const
|
||||||
|
{
|
||||||
|
return(*((const SPoint*)&right));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SPoint SRect::LeftBottom() const
|
||||||
|
{
|
||||||
|
return(SPoint(left, bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SPoint SRect::RightTop() const
|
||||||
|
{
|
||||||
|
return(SPoint(right, top));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect()
|
||||||
|
{
|
||||||
|
top = left = 0;
|
||||||
|
bottom = right = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect(float l, float t, float r, float b)
|
||||||
|
{
|
||||||
|
left = l;
|
||||||
|
top = t;
|
||||||
|
right = r;
|
||||||
|
bottom = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect(const SRect &r)
|
||||||
|
{
|
||||||
|
left = r.left;
|
||||||
|
top = r.top;
|
||||||
|
right = r.right;
|
||||||
|
bottom = r.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect::SRect(SPoint leftTop, SPoint rightBottom)
|
||||||
|
{
|
||||||
|
left = leftTop.x;
|
||||||
|
top = leftTop.y;
|
||||||
|
right = rightBottom.x;
|
||||||
|
bottom = rightBottom.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SRect &SRect::operator=(const SRect& from)
|
||||||
|
{
|
||||||
|
left = from.left;
|
||||||
|
top = from.top;
|
||||||
|
right = from.right;
|
||||||
|
bottom = from.bottom;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SRect::Set(float l, float t, float r, float b)
|
||||||
|
{
|
||||||
|
left = l;
|
||||||
|
top = t;
|
||||||
|
right = r;
|
||||||
|
bottom = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SRect::IsValid() const
|
||||||
|
{
|
||||||
|
if (left <= right && top <= bottom)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 SRect::IntegerWidth() const
|
||||||
|
{
|
||||||
|
return((int32)ceil(right - left));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float SRect::Width() const
|
||||||
|
{
|
||||||
|
return(right - left);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 SRect::IntegerHeight() const
|
||||||
|
{
|
||||||
|
return((int32)ceil(bottom - top));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline float SRect::Height() const
|
||||||
|
{
|
||||||
|
return(bottom - top);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,400 @@
|
|||||||
|
#include "DisplayDriver.h"
|
||||||
|
#include <View.h>
|
||||||
|
#include "LayerData.h"
|
||||||
|
#include "ColorUtils.h"
|
||||||
|
#include "WinDecorator.h"
|
||||||
|
#include "RGBColor.h"
|
||||||
|
|
||||||
|
//#define DEBUG_DECOR
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
WinDecorator::WinDecorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||||
|
: Decorator(rect,wlook,wfeel,wflags)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator()\n");
|
||||||
|
#endif
|
||||||
|
taboffset=0;
|
||||||
|
|
||||||
|
// These hard-coded assignments will go bye-bye when the system colors
|
||||||
|
// API is implemented
|
||||||
|
tab_highcol.SetColor(100,100,255);
|
||||||
|
tab_lowcol.SetColor(40,0,255);
|
||||||
|
|
||||||
|
button_highercol.SetColor(255,255,255);
|
||||||
|
button_lowercol.SetColor(0,0,0);
|
||||||
|
|
||||||
|
button_highcol=button_lowercol.MakeBlendColor(button_highercol,0.85);
|
||||||
|
button_midcol=button_lowercol.MakeBlendColor(button_highercol,0.75);
|
||||||
|
button_lowcol=button_lowercol.MakeBlendColor(button_highercol,0.5);
|
||||||
|
|
||||||
|
frame_highercol.SetColor(216,216,216);
|
||||||
|
frame_lowercol.SetColor(110,110,110);
|
||||||
|
|
||||||
|
textcol.SetColor(0,0,0);
|
||||||
|
|
||||||
|
frame_highcol=frame_lowercol.MakeBlendColor(frame_highercol,0.75);
|
||||||
|
frame_midcol=frame_lowercol.MakeBlendColor(frame_highercol,0.5);
|
||||||
|
frame_lowcol=frame_lowercol.MakeBlendColor(frame_highercol,0.25);
|
||||||
|
|
||||||
|
_DoLayout();
|
||||||
|
|
||||||
|
textoffset=5;
|
||||||
|
solidhigh=0xFFFFFFFFFFFFFFFFLL;
|
||||||
|
solidlow=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WinDecorator::~WinDecorator(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("~WinDecorator()\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
click_type WinDecorator::Clicked(SPoint pt, int32 buttons, int32 modifiers)
|
||||||
|
{
|
||||||
|
if(closerect.Contains(pt))
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator():Clicked() - Close\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return CLICK_CLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(zoomrect.Contains(pt))
|
||||||
|
{
|
||||||
|
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator():Clicked() - Zoom\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return CLICK_ZOOM;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clicking in the tab?
|
||||||
|
if(tabrect.Contains(pt))
|
||||||
|
{
|
||||||
|
// Here's part of our window management stuff
|
||||||
|
if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus())
|
||||||
|
return CLICK_MOVETOFRONT;
|
||||||
|
return CLICK_DRAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We got this far, so user is clicking on the border?
|
||||||
|
SRect srect(frame);
|
||||||
|
srect.top+=19;
|
||||||
|
SRect clientrect(srect.InsetByCopy(3,3));
|
||||||
|
if(srect.Contains(pt) && !clientrect.Contains(pt))
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator():Clicked() - Resize\n");
|
||||||
|
#endif
|
||||||
|
return CLICK_RESIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Guess user didn't click anything
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator():Clicked()\n");
|
||||||
|
#endif
|
||||||
|
return CLICK_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_DoLayout(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator()::_DoLayout()\n");
|
||||||
|
#endif
|
||||||
|
tabrect=frame;
|
||||||
|
borderrect=frame;
|
||||||
|
|
||||||
|
borderrect.top+=19;
|
||||||
|
|
||||||
|
tabrect.bottom=tabrect.top+18;
|
||||||
|
|
||||||
|
zoomrect=tabrect;
|
||||||
|
zoomrect.top+=4;
|
||||||
|
zoomrect.right-=4;
|
||||||
|
zoomrect.bottom-=4;
|
||||||
|
zoomrect.left=zoomrect.right-10;
|
||||||
|
zoomrect.bottom=zoomrect.top+10;
|
||||||
|
|
||||||
|
closerect=zoomrect;
|
||||||
|
zoomrect.OffsetBy(0-zoomrect.Width()-4,0);
|
||||||
|
|
||||||
|
minimizerect=zoomrect;
|
||||||
|
minimizerect.OffsetBy(0-zoomrect.Width()-2,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::MoveBy(float x, float y)
|
||||||
|
{
|
||||||
|
MoveBy(SPoint(x,y));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::MoveBy(SPoint pt)
|
||||||
|
{
|
||||||
|
// Move all internal rectangles the appropriate amount
|
||||||
|
frame.OffsetBy(pt);
|
||||||
|
closerect.OffsetBy(pt);
|
||||||
|
tabrect.OffsetBy(pt);
|
||||||
|
borderrect.OffsetBy(pt);
|
||||||
|
zoomrect.OffsetBy(pt);
|
||||||
|
minimizerect.OffsetBy(pt);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
SRegion * WinDecorator::GetFootprint(void)
|
||||||
|
{
|
||||||
|
// This function calculates the decorator's footprint in coordinates
|
||||||
|
// relative to the layer. This is most often used to set a WindowBorder
|
||||||
|
// object's visible region.
|
||||||
|
|
||||||
|
SRegion *reg=new SRegion(borderrect);
|
||||||
|
reg->Include(tabrect);
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void WinDecorator::_DrawTitle(SRect r)
|
||||||
|
{
|
||||||
|
// Designed simply to redraw the title when it has changed on
|
||||||
|
// the client side.
|
||||||
|
/* if(title)
|
||||||
|
{
|
||||||
|
driver->SetDrawingMode(B_OP_OVER);
|
||||||
|
rgb_color tmpcol=driver->HighColor();
|
||||||
|
driver->SetHighColor(textcol.red,textcol.green,textcol.blue);
|
||||||
|
driver->DrawString((char *)string,strlen(string),
|
||||||
|
BPoint(frame.left+textoffset,closerect.bottom-1));
|
||||||
|
driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue);
|
||||||
|
driver->SetDrawingMode(B_OP_COPY);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_SetFocus(void)
|
||||||
|
{
|
||||||
|
// SetFocus() performs necessary duties for color swapping and
|
||||||
|
// other things when a window is deactivated or activated.
|
||||||
|
|
||||||
|
if(GetFocus())
|
||||||
|
{
|
||||||
|
tab_highcol.SetColor(100,100,255);
|
||||||
|
tab_lowcol.SetColor(40,0,255);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tab_highcol.SetColor(220,220,220);
|
||||||
|
tab_lowcol.SetColor(128,128,128);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::Draw(SRect update)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator::Draw(): "); update.PrintToStream();
|
||||||
|
#endif
|
||||||
|
// Draw the top view's client area - just a hack :)
|
||||||
|
RGBColor blue(100,100,255);
|
||||||
|
|
||||||
|
layerdata.highcolor=blue;
|
||||||
|
|
||||||
|
if(borderrect.Intersects(update))
|
||||||
|
driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
_DrawFrame(update);
|
||||||
|
_DrawTab(update);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::Draw(void)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_DECOR
|
||||||
|
printf("WinDecorator::Draw()\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Draw the top view's client area - just a hack :)
|
||||||
|
RGBColor blue(100,100,255);
|
||||||
|
|
||||||
|
layerdata.highcolor=blue;
|
||||||
|
|
||||||
|
driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
DrawFrame();
|
||||||
|
|
||||||
|
DrawTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_DrawZoom(SRect r)
|
||||||
|
{
|
||||||
|
DrawBlendedRect(r,GetZoom());
|
||||||
|
|
||||||
|
// Draw the Zoom box
|
||||||
|
layerdata.highcolor=textcol;
|
||||||
|
driver->StrokeRect(r.InsetByCopy(2,2),&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_DrawClose(SRect r)
|
||||||
|
{
|
||||||
|
// Just like DrawZoom, but for a close button
|
||||||
|
DrawBlendedRect(r,GetClose());
|
||||||
|
|
||||||
|
// Draw the X
|
||||||
|
layerdata.highcolor=textcol;
|
||||||
|
driver->StrokeLine(SPoint(closerect.left+2,closerect.top+2),SPoint(closerect.right-2,
|
||||||
|
closerect.bottom-2),&layerdata,(int8*)&solidhigh);
|
||||||
|
driver->StrokeLine(SPoint(closerect.right-2,closerect.top+2),SPoint(closerect.left+2,
|
||||||
|
closerect.bottom-2),&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_DrawMinimize(SRect r)
|
||||||
|
{
|
||||||
|
// Just like DrawZoom, but for a Minimize button
|
||||||
|
DrawBlendedRect(r,GetMinimize());
|
||||||
|
|
||||||
|
layerdata.highcolor=textcol;
|
||||||
|
driver->StrokeLine(SPoint(minimizerect.left+2,minimizerect.bottom-2),SPoint(minimizerect.right-2,
|
||||||
|
minimizerect.bottom-2),&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_DrawTab(SRect r)
|
||||||
|
{
|
||||||
|
// If a window has a tab, this will draw it and any buttons which are
|
||||||
|
// in it.
|
||||||
|
if(look==WLOOK_NO_BORDER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
layerdata.highcolor=frame_lowcol;
|
||||||
|
driver->StrokeRect(tabrect,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
// UpdateTitle(layer->name->String());
|
||||||
|
|
||||||
|
layerdata.highcolor=tab_lowcol;
|
||||||
|
driver->FillRect(tabrect.InsetByCopy(1,1),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
// Draw the buttons if we're supposed to
|
||||||
|
if(!(flags & NOT_CLOSABLE))
|
||||||
|
_DrawClose(closerect);
|
||||||
|
if(!(flags & NOT_ZOOMABLE))
|
||||||
|
_DrawZoom(zoomrect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::DrawBlendedRect(SRect 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 WinDecorator. Called by DrawZoom and DrawClose
|
||||||
|
|
||||||
|
// Actually just draws a blended square
|
||||||
|
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(SPoint(r.left,r.top+i),
|
||||||
|
SPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)),
|
||||||
|
uint8(halfcol.green-(i*gstep)),
|
||||||
|
uint8(halfcol.blue-(i*bstep)));
|
||||||
|
|
||||||
|
layerdata.highcolor=tmpcol;
|
||||||
|
driver->StrokeLine(SPoint(r.left+steps,r.top+i),
|
||||||
|
SPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// layerdata.highcolor=startcol;
|
||||||
|
// driver->FillRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowcol;
|
||||||
|
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WinDecorator::_DrawFrame(SRect rect)
|
||||||
|
{
|
||||||
|
if(look==WLOOK_NO_BORDER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SRect r=borderrect;
|
||||||
|
|
||||||
|
layerdata.highcolor=frame_midcol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowcol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
r.InsetBy(1,1);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_midcol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_midcol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
r.InsetBy(1,1);
|
||||||
|
layerdata.highcolor=frame_highcol;
|
||||||
|
driver->StrokeRect(r,&layerdata,(int8*)&solidhigh);
|
||||||
|
|
||||||
|
r.InsetBy(1,1);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.right-1,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_lowercol;
|
||||||
|
driver->StrokeLine(SPoint(r.left,r.top),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.right,r.top),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
layerdata.highcolor=frame_highercol;
|
||||||
|
driver->StrokeLine(SPoint(r.right,r.bottom),SPoint(r.left,r.bottom),
|
||||||
|
&layerdata,(int8*)&solidhigh);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" float get_decorator_version(void)
|
||||||
|
{
|
||||||
|
return 1.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" Decorator *instantiate_decorator(SRect rect, int32 wlook, int32 wfeel, int32 wflags)
|
||||||
|
{
|
||||||
|
return new WinDecorator(rect,wlook,wfeel,wflags);
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#ifndef _BEOS_DECORATOR_H_
|
||||||
|
#define _BEOS_DECORATOR_H_
|
||||||
|
|
||||||
|
#include "Decorator.h"
|
||||||
|
#include "SRect.h"
|
||||||
|
#include "SPoint.h"
|
||||||
|
|
||||||
|
class WinDecorator: public Decorator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WinDecorator(SRect frame, int32 wlook, int32 wfeel, int32 wflags);
|
||||||
|
~WinDecorator(void);
|
||||||
|
|
||||||
|
void MoveBy(float x, float y);
|
||||||
|
void MoveBy(SPoint pt);
|
||||||
|
// void ResizeBy(float x, float y);
|
||||||
|
// void ResizeBy(SPoint pt);
|
||||||
|
void Draw(SRect r);
|
||||||
|
void Draw(void);
|
||||||
|
//SRegion GetFootprint(void);
|
||||||
|
click_type Clicked(SPoint pt, int32 buttons, int32 modifiers);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void _DrawClose(SRect r);
|
||||||
|
void _DrawFrame(SRect r);
|
||||||
|
void _DrawTab(SRect r);
|
||||||
|
void _DrawTitle(SRect r);
|
||||||
|
void _DrawZoom(SRect r);
|
||||||
|
void _DrawMinimize(SRect r);
|
||||||
|
void _DoLayout(void);
|
||||||
|
void _SetFocus(void);
|
||||||
|
void DrawBlendedRect(SRect r, bool down);
|
||||||
|
uint32 taboffset;
|
||||||
|
|
||||||
|
RGBColor tab_highcol, tab_lowcol;
|
||||||
|
RGBColor button_highcol, button_lowcol;
|
||||||
|
RGBColor button_highercol, button_lowercol, button_midcol;
|
||||||
|
RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_highercol,
|
||||||
|
frame_lowercol;
|
||||||
|
RGBColor textcol;
|
||||||
|
uint64 solidhigh, solidlow;
|
||||||
|
|
||||||
|
bool slidetab;
|
||||||
|
int textoffset;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#ifndef DEFS_H_
|
||||||
|
#define DEFS_H_
|
||||||
|
|
||||||
|
#define SETTINGS_DIR "/boot/home/config/settings/app_server/"
|
||||||
|
|
||||||
|
#define APPLY_SETTINGS 'aply'
|
||||||
|
#define REVERT_SETTINGS 'rvrt'
|
||||||
|
#define DEFAULT_SETTINGS 'dflt'
|
||||||
|
#define TRY_SETTINGS 'trys'
|
||||||
|
|
||||||
|
#define ATTRIBUTE_CHOSEN 'atch'
|
||||||
|
#define UPDATE_COLOR 'upcl'
|
||||||
|
#define DECORATOR_CHOSEN 'dcch'
|
||||||
|
#define UPDATE_DECORATOR 'updc'
|
||||||
|
|
||||||
|
#define SET_DECORATOR 'sdec'
|
||||||
|
#define GET_DECORATOR 'gdec'
|
||||||
|
|
||||||
|
#define SET_UI_COLORS 'suic'
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user