Serious reworking of the code - AFAICT it works the way it should now.
My first attempt at OT style-compliant code. Axel would be proud. :P git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12757 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,6 +2,6 @@ SubDir OBOS_TOP src prefs scrollbar ;
|
||||
|
||||
AddResources ScrollBar : ScrollBar.rdef ;
|
||||
|
||||
Preference ScrollBar : ScrollBar.cpp ScrollBarApp.cpp ScrollBarWindow.cpp ScrollBarView.cpp ;
|
||||
Preference ScrollBar : ScrollBarApp.cpp ScrollBarWindow.cpp ScrollBarView.cpp knobsizeadjuster.cpp fakescrollbar.cpp ;
|
||||
|
||||
LinkSharedOSLibs ScrollBar : be root <boot!home!config!lib>libopenbeos.so ;
|
||||
LinkSharedOSLibs ScrollBar : be root ;
|
||||
|
||||
@@ -81,4 +81,4 @@ resource mini_icon array {
|
||||
$"FFFF00000E0F0F0F0F0000FFFFFFFFFF"
|
||||
};
|
||||
|
||||
resource app_signature "application/x-vnd.obos.scroll-bar";
|
||||
resource app_signature "application/x-vnd.haiku-ScrollBar";
|
||||
|
||||
@@ -1,13 +1,40 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ScrollBarApp.cpp
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: main app class
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "ScrollBarApp.h"
|
||||
#include "ScrollBarWindow.h"
|
||||
|
||||
ScrollBarApp * scroll_bar_app = 0;
|
||||
scroll_bar_info gSettings;
|
||||
scroll_bar_info gRevertSettings;
|
||||
|
||||
ScrollBarApp::ScrollBarApp()
|
||||
: BApplication("application/x-vnd.obos.scroll-bar")
|
||||
: BApplication("application/x-vnd.haiku-ScrollBar")
|
||||
{
|
||||
window = new ScrollBarWindow();
|
||||
scroll_bar_app = this;
|
||||
fWindow = new ScrollBarWindow();
|
||||
}
|
||||
|
||||
ScrollBarApp::~ScrollBarApp()
|
||||
@@ -17,7 +44,14 @@ ScrollBarApp::~ScrollBarApp()
|
||||
void
|
||||
ScrollBarApp::ReadyToRun()
|
||||
{
|
||||
if (window) {
|
||||
window->Show();
|
||||
}
|
||||
fWindow->Show();
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
ScrollBarApp myApplication;
|
||||
|
||||
myApplication.Run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ScrollBarApp.h
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: main app class
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SCROLL_BAR_APP_H
|
||||
#define SCROLL_BAR_APP_H
|
||||
|
||||
@@ -7,14 +34,16 @@ class ScrollBarWindow;
|
||||
|
||||
class ScrollBarApp : public BApplication
|
||||
{
|
||||
public:
|
||||
ScrollBarApp();
|
||||
virtual ~ScrollBarApp();
|
||||
virtual void ReadyToRun();
|
||||
private:
|
||||
ScrollBarWindow * window;
|
||||
public:
|
||||
ScrollBarApp();
|
||||
virtual ~ScrollBarApp();
|
||||
virtual void ReadyToRun();
|
||||
|
||||
private:
|
||||
ScrollBarWindow *fWindow;
|
||||
};
|
||||
|
||||
extern ScrollBarApp * scroll_bar_app;
|
||||
extern scroll_bar_info gSettings;
|
||||
extern scroll_bar_info gRevertSettings;
|
||||
|
||||
#endif // SCROLL_BAR_APP_H
|
||||
|
||||
@@ -1,95 +1,133 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ScrollBarView.cpp
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: view which does all the work
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "ScrollBarApp.h"
|
||||
#include "ScrollBarView.h"
|
||||
#include "fakescrollbar.h"
|
||||
#include "knobsizeadjuster.h"
|
||||
#include "messages.h"
|
||||
|
||||
// our own homegrown private cheat function for controlling scrollbars
|
||||
status_t control_scrollbar(scroll_bar_info *info, BScrollBar *sb);
|
||||
// This is R5's default value
|
||||
#define DEFAULT_KNOB_SIZE 15
|
||||
|
||||
ScrollBarView::ScrollBarView(void)
|
||||
: BView(BRect(0,0,348,280),"scrollbarview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
|
||||
: BView( BRect(0,0,348,280),"scrollbarview", B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
B_WILL_DRAW)
|
||||
{
|
||||
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
|
||||
|
||||
arrowstyleBox = new BBox( BRect( 12, 7, 169, 119) );
|
||||
get_scroll_bar_info(&gRevertSettings);
|
||||
gSettings=gRevertSettings;
|
||||
|
||||
// Set up the top left box - single vs. double arrow selection
|
||||
BBox *arrowstyleBox = new BBox( BRect(12, 7, 169, 119) );
|
||||
arrowstyleBox->SetLabel( "Arrow Style" );
|
||||
|
||||
float doubleWidth = StringWidth("Double:");
|
||||
int32 tempint;
|
||||
bool tempbool;
|
||||
scroll_bar_info sbi;
|
||||
BStringView *doubleStringView = new BStringView( BRect(25,20,25+doubleWidth,38),
|
||||
"doubleStringView","Double:");
|
||||
|
||||
// We're going to need the basics here
|
||||
get_scroll_bar_info(&sbi);
|
||||
|
||||
// save this for later use
|
||||
tempbool=sbi.double_arrows;
|
||||
|
||||
doubleStringView = new BStringView( BRect(25,20,25+doubleWidth,38), "doubleStringView", "Double:");
|
||||
sbdouble=new BScrollBar(BRect(12,38,145,58),"doublearrowsbar",NULL,0,100,B_HORIZONTAL);
|
||||
arrowstyleBox->AddChild( sbdouble );
|
||||
fDouble=new FakeScrollBar( BPoint(12,38), gSettings.double_arrows, gSettings.knob,
|
||||
!gSettings.proportional, true, gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_ARROW_STYLE_DOUBLE));
|
||||
arrowstyleBox->AddChild( fDouble );
|
||||
|
||||
sbi.double_arrows=true;
|
||||
control_scrollbar(&sbi,sbdouble);
|
||||
|
||||
float singleWidth = StringWidth("Single:");
|
||||
singleStringView = new BStringView( BRect(25,60,25+singleWidth,87), "singleStringView", "Single:");
|
||||
sbsingle=new BScrollBar(BRect(12,82,145,102),"singlearrowsbar",NULL,0,100,B_HORIZONTAL);
|
||||
arrowstyleBox->AddChild( sbsingle );
|
||||
BStringView *singleStringView = new BStringView( BRect(25,60,25+singleWidth,87),
|
||||
"singleStringView", "Single:");
|
||||
|
||||
fSingle=new FakeScrollBar( BPoint(12,singleStringView->Frame().bottom+1),
|
||||
!gSettings.double_arrows, gSettings.knob,
|
||||
!gSettings.proportional, false, gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_ARROW_STYLE_SINGLE));
|
||||
arrowstyleBox->AddChild( fSingle );
|
||||
|
||||
sbi.double_arrows=false;
|
||||
control_scrollbar(&sbi,sbsingle);
|
||||
|
||||
// Restore the original value so we don't screw up the other ones
|
||||
sbi.double_arrows=tempbool;
|
||||
|
||||
tempbool=sbi.proportional;
|
||||
|
||||
knobtypeBox = new BBox( BRect( 180, 7, 338, 119) );
|
||||
BBox *knobtypeBox = new BBox( BRect(180, 7, 338, 119) );
|
||||
knobtypeBox->SetLabel( "Knob Type" );
|
||||
|
||||
float proportionalWidth = StringWidth("Proportional");
|
||||
proportionalStringView = new BStringView( BRect(193,20,193+proportionalWidth,38), "proportionalStringView", "Proportional" );
|
||||
sbproportional=new BScrollBar(BRect(12,38,145,58),"proportionalbar",NULL,0,100,B_HORIZONTAL);
|
||||
knobtypeBox->AddChild( sbproportional );
|
||||
float proportionalWidth = StringWidth("Proportional:");
|
||||
BStringView *proportionalStringView = new BStringView( BRect(193,20,193+proportionalWidth,38),
|
||||
"proportionalStringView",
|
||||
"Proportional:" );
|
||||
|
||||
fProportional=new FakeScrollBar( BPoint(12,38),gSettings.proportional, gSettings.knob,
|
||||
false, gSettings.double_arrows, gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_KNOB_TYPE_PROPORTIONAL));
|
||||
knobtypeBox->AddChild( fProportional );
|
||||
|
||||
sbi.proportional=true;
|
||||
control_scrollbar(&sbi,sbproportional);
|
||||
float fixedWidth = StringWidth("Fixed:");
|
||||
BStringView *fixedStringView = new BStringView( BRect(193,60,193+fixedWidth,87),
|
||||
"fixedStringView", "Fixed:" );
|
||||
|
||||
fFixed=new FakeScrollBar( BPoint(12,87),!gSettings.proportional, gSettings.knob,
|
||||
true, gSettings.double_arrows, gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_KNOB_TYPE_FIXED));
|
||||
knobtypeBox->AddChild( fFixed );
|
||||
|
||||
BBox *minknobsizeBox = new BBox( BRect(12, 123, 169, 232) );
|
||||
minknobsizeBox->SetLabel( "Minimum Knob Size:" );
|
||||
|
||||
fSizeAdjuster = new KnobSizeAdjuster( BPoint(12,38), gSettings.min_knob_size );
|
||||
minknobsizeBox->AddChild( fSizeAdjuster );
|
||||
|
||||
BBox *knobstyleBox = new BBox( BRect(180, 123, 338, 232) );
|
||||
knobstyleBox->SetLabel( "Knob Style:" );
|
||||
|
||||
float fixedWidth = StringWidth("Fixed");
|
||||
fixedStringView = new BStringView( BRect(193,60,193+fixedWidth,87), "fixedStringView", "Fixed" );
|
||||
sbfixed=new BScrollBar(BRect(12,87,145,105),"fixedbar",NULL,0,100,B_HORIZONTAL);
|
||||
knobtypeBox->AddChild( sbfixed );
|
||||
|
||||
sbi.proportional=false;
|
||||
control_scrollbar(&sbi,sbfixed);
|
||||
|
||||
minknobsizeBox = new BBox( BRect( 12, 123, 169, 232) );
|
||||
minknobsizeBox->SetLabel( "Minimum Knob Size" );
|
||||
|
||||
sbi.proportional=tempbool;
|
||||
|
||||
knobstyleBox = new BBox( BRect( 180, 123, 338, 232) );
|
||||
knobstyleBox->SetLabel( "Knob Style" );
|
||||
fFlat=new FakeScrollBar( BPoint(12,22),gSettings.knob==THUMB_BLANK, THUMB_BLANK,
|
||||
!gSettings.proportional, gSettings.double_arrows,
|
||||
gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_KNOB_STYLE_FLAT));
|
||||
knobstyleBox->AddChild( fFlat );
|
||||
|
||||
tempint=sbi.knob;
|
||||
sbflat=new BScrollBar(BRect(12,22,145,42),"flatbar",NULL,0,100,B_HORIZONTAL);
|
||||
knobstyleBox->AddChild( sbflat );
|
||||
sbi.knob=0;
|
||||
control_scrollbar(&sbi,sbflat);
|
||||
|
||||
sbdots=new BScrollBar(BRect(12,52,145,72),"dotbar",NULL,0,100,B_HORIZONTAL);
|
||||
knobstyleBox->AddChild( sbdots );
|
||||
sbi.knob=1;
|
||||
control_scrollbar(&sbi,sbdots);
|
||||
fDots=new FakeScrollBar( BPoint(12,52),gSettings.knob==THUMB_DOTS, THUMB_DOTS,
|
||||
!gSettings.proportional, gSettings.double_arrows,
|
||||
gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_KNOB_STYLE_DOT));
|
||||
knobstyleBox->AddChild( fDots );
|
||||
|
||||
sblines=new BScrollBar(BRect(12,82,145,102),"linebar",NULL,0,100,B_HORIZONTAL);
|
||||
knobstyleBox->AddChild( sblines );
|
||||
sbi.knob=2;
|
||||
control_scrollbar(&sbi,sblines);
|
||||
|
||||
fLines=new FakeScrollBar( BPoint(12,82),gSettings.knob==THUMB_LINES, THUMB_LINES,
|
||||
!gSettings.proportional, gSettings.double_arrows,
|
||||
gSettings.min_knob_size,
|
||||
new BMessage(SCROLLBAR_KNOB_STYLE_LINE));
|
||||
knobstyleBox->AddChild( fLines );
|
||||
|
||||
defaultsButton = new BButton( BRect( 10, 242, 85, 265), "defaultsButton", "Defaults", NULL );
|
||||
revertButton = new BButton( BRect( 95, 242, 170, 265), "revertButton", "Revert", NULL );
|
||||
revertButton->SetEnabled( FALSE );
|
||||
fDefaultsButton = new BButton( BRect(10, 242, 85, 265), "defaultsbutton",
|
||||
"Defaults", new BMessage(SCROLLBAR_DEFAULTS) );
|
||||
|
||||
// Disable defaults button if the current settings are already the defaults
|
||||
if( gSettings.knob==THUMB_DOTS && gSettings.proportional==true &&
|
||||
gSettings.double_arrows==true && gSettings.min_knob_size==DEFAULT_KNOB_SIZE )
|
||||
{
|
||||
fDefaultsButton->SetEnabled(false);
|
||||
}
|
||||
|
||||
fRevertButton = new BButton( BRect( 95, 242, 170, 265), "revertbutton", "Revert",
|
||||
new BMessage(SCROLLBAR_REVERT) );
|
||||
fRevertButton->SetEnabled( false );
|
||||
|
||||
AddChild( arrowstyleBox );
|
||||
AddChild( doubleStringView );
|
||||
@@ -102,19 +140,237 @@ ScrollBarView::ScrollBarView(void)
|
||||
AddChild( minknobsizeBox );
|
||||
AddChild( knobstyleBox );
|
||||
|
||||
AddChild( defaultsButton );
|
||||
AddChild( revertButton );
|
||||
AddChild( fDefaultsButton );
|
||||
AddChild( fRevertButton );
|
||||
}
|
||||
|
||||
ScrollBarView::~ScrollBarView(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ScrollBarView::MessageReceived(BMessage *msg)
|
||||
void
|
||||
ScrollBarView::AttachedToWindow(void)
|
||||
{
|
||||
fSingle->SetTarget(this);
|
||||
fDouble->SetTarget(this);
|
||||
fProportional->SetTarget(this);
|
||||
fFixed->SetTarget(this);
|
||||
fFlat->SetTarget(this);
|
||||
fDots->SetTarget(this);
|
||||
fLines->SetTarget(this);
|
||||
|
||||
fSizeAdjuster->SetTarget(this);
|
||||
|
||||
fDefaultsButton->SetTarget(this);
|
||||
fRevertButton->SetTarget(this);
|
||||
}
|
||||
|
||||
void
|
||||
ScrollBarView::HandleButtonStates(void)
|
||||
{
|
||||
if( gSettings.knob!=gRevertSettings.knob ||
|
||||
gSettings.proportional!=gRevertSettings.proportional ||
|
||||
gSettings.double_arrows!=gRevertSettings.double_arrows ||
|
||||
gSettings.min_knob_size!=gRevertSettings.min_knob_size )
|
||||
{
|
||||
fDefaultsButton->SetEnabled(false);
|
||||
fRevertButton->SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
fDefaultsButton->SetEnabled(true);
|
||||
fRevertButton->SetEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ScrollBarView::SetAllScrollBars(void)
|
||||
{
|
||||
fSingle->SetFromScrollBarInfo(gSettings);
|
||||
fDouble->SetFromScrollBarInfo(gSettings);
|
||||
fProportional->SetFromScrollBarInfo(gSettings);
|
||||
fFixed->SetFromScrollBarInfo(gSettings);
|
||||
fFlat->SetFromScrollBarInfo(gSettings);
|
||||
fDots->SetFromScrollBarInfo(gSettings);
|
||||
fLines->SetFromScrollBarInfo(gSettings);
|
||||
|
||||
fSingle->SetSelected( !gSettings.double_arrows );
|
||||
fDouble->SetSelected( gSettings.double_arrows );
|
||||
|
||||
fProportional->SetSelected( gSettings.proportional );
|
||||
fFixed->SetSelected( !gSettings.proportional );
|
||||
|
||||
fFlat->SetSelected(gSettings.knob==THUMB_BLANK);
|
||||
fDots->SetSelected(gSettings.knob==THUMB_DOTS);
|
||||
fLines->SetSelected(gSettings.knob==THUMB_LINES);
|
||||
}
|
||||
|
||||
void
|
||||
ScrollBarView::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch(msg->what)
|
||||
{
|
||||
case SCROLLBAR_DEFAULTS:
|
||||
{
|
||||
gSettings.double_arrows=true;
|
||||
gSettings.proportional=true;
|
||||
gSettings.knob=THUMB_DOTS;
|
||||
gSettings.min_knob_size=DEFAULT_KNOB_SIZE;
|
||||
|
||||
SetAllScrollBars();
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
case SCROLLBAR_REVERT:
|
||||
{
|
||||
gSettings=gRevertSettings;
|
||||
|
||||
fSingle->SetFromScrollBarInfo(gSettings);
|
||||
fDouble->SetFromScrollBarInfo(gSettings);
|
||||
fProportional->SetFromScrollBarInfo(gSettings);
|
||||
fFixed->SetFromScrollBarInfo(gSettings);
|
||||
fFlat->SetFromScrollBarInfo(gSettings);
|
||||
fDots->SetFromScrollBarInfo(gSettings);
|
||||
fLines->SetFromScrollBarInfo(gSettings);
|
||||
|
||||
SetAllScrollBars();
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
|
||||
case SCROLLBAR_ARROW_STYLE_DOUBLE:
|
||||
{
|
||||
fDouble->SetSelected(true);
|
||||
fSingle->SetSelected(false);
|
||||
|
||||
fFixed->SetDoubleArrows(true);
|
||||
fProportional->SetDoubleArrows(true);
|
||||
|
||||
fFlat->SetDoubleArrows(true);
|
||||
fDots->SetDoubleArrows(true);
|
||||
fLines->SetDoubleArrows(true);
|
||||
|
||||
gSettings.double_arrows=true;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
case SCROLLBAR_ARROW_STYLE_SINGLE:
|
||||
{
|
||||
fDouble->SetSelected(false);
|
||||
fSingle->SetSelected(true);
|
||||
|
||||
fFixed->SetDoubleArrows(false);
|
||||
fProportional->SetDoubleArrows(false);
|
||||
|
||||
fFlat->SetDoubleArrows(false);
|
||||
fDots->SetDoubleArrows(false);
|
||||
fLines->SetDoubleArrows(false);
|
||||
|
||||
gSettings.double_arrows=false;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
case SCROLLBAR_KNOB_TYPE_PROPORTIONAL:
|
||||
{
|
||||
fDouble->SetFixedThumb(false);
|
||||
fSingle->SetFixedThumb(false);
|
||||
|
||||
fFixed->SetSelected(false);
|
||||
fProportional->SetSelected(true);
|
||||
|
||||
fFlat->SetFixedThumb(false);
|
||||
fDots->SetFixedThumb(false);
|
||||
fLines->SetFixedThumb(false);
|
||||
|
||||
gSettings.proportional=true;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
case SCROLLBAR_KNOB_TYPE_FIXED:
|
||||
{
|
||||
fDouble->SetFixedThumb(true);
|
||||
fSingle->SetFixedThumb(true);
|
||||
|
||||
fFixed->SetSelected(true);
|
||||
fProportional->SetSelected(false);
|
||||
|
||||
fFlat->SetFixedThumb(true);
|
||||
fDots->SetFixedThumb(true);
|
||||
fLines->SetFixedThumb(true);
|
||||
|
||||
gSettings.proportional=false;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
|
||||
case SCROLLBAR_KNOB_STYLE_FLAT:
|
||||
{
|
||||
fDouble->SetKnobStyle(THUMB_BLANK);
|
||||
fSingle->SetKnobStyle(THUMB_BLANK);
|
||||
|
||||
fFixed->SetKnobStyle(THUMB_BLANK);
|
||||
fProportional->SetKnobStyle(THUMB_BLANK);
|
||||
|
||||
fFlat->SetSelected(true);
|
||||
fDots->SetSelected(false);
|
||||
fLines->SetSelected(false);
|
||||
|
||||
gSettings.knob=THUMB_BLANK;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
case SCROLLBAR_KNOB_STYLE_DOT:
|
||||
{
|
||||
fDouble->SetKnobStyle(THUMB_DOTS);
|
||||
fSingle->SetKnobStyle(THUMB_DOTS);
|
||||
|
||||
fFixed->SetKnobStyle(THUMB_DOTS);
|
||||
fProportional->SetKnobStyle(THUMB_DOTS);
|
||||
|
||||
fFlat->SetSelected(false);
|
||||
fDots->SetSelected(true);
|
||||
fLines->SetSelected(false);
|
||||
|
||||
gSettings.knob=THUMB_DOTS;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
case SCROLLBAR_KNOB_STYLE_LINE:
|
||||
{
|
||||
fDouble->SetKnobStyle(THUMB_LINES);
|
||||
fSingle->SetKnobStyle(THUMB_LINES);
|
||||
|
||||
fFixed->SetKnobStyle(THUMB_LINES);
|
||||
fProportional->SetKnobStyle(THUMB_LINES);
|
||||
|
||||
fFlat->SetSelected(false);
|
||||
fDots->SetSelected(false);
|
||||
fLines->SetSelected(true);
|
||||
|
||||
gSettings.knob=THUMB_LINES;
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
|
||||
case SCROLLBAR_KNOB_SIZE_CHANGED:
|
||||
{
|
||||
fDouble->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
fSingle->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
|
||||
fFixed->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
fProportional->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
|
||||
fFlat->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
fDots->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
fLines->SetKnobSize(fSizeAdjuster->KnobSize());
|
||||
|
||||
gSettings.min_knob_size=fSizeAdjuster->KnobSize();
|
||||
HandleButtonStates();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ScrollBarView.cpp
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: view which does all the work
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SCROLLBAR_VIEW
|
||||
#define SCROLLBAR_VIEW
|
||||
|
||||
@@ -7,21 +34,34 @@
|
||||
#include <Button.h>
|
||||
#include <ScrollBar.h>
|
||||
|
||||
class FakeScrollBar;
|
||||
class KnobSizeAdjuster;
|
||||
|
||||
class ScrollBarView : public BView
|
||||
{
|
||||
public:
|
||||
ScrollBarView(void);
|
||||
~ScrollBarView(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
|
||||
BBox *arrowstyleBox, *knobtypeBox, *knobstyleBox, *minknobsizeBox;
|
||||
BStringView *singleStringView,*doubleStringView, *proportionalStringView,
|
||||
*fixedStringView;
|
||||
BButton *defaultsButton, *revertButton;
|
||||
ScrollBarView(void);
|
||||
~ScrollBarView(void);
|
||||
void MessageReceived(BMessage *msg);
|
||||
void AttachedToWindow(void);
|
||||
|
||||
BScrollBar *sbsingle, *sbdouble, *sbproportional, *sbfixed,
|
||||
*sbflat, *sbdots, *sblines;
|
||||
private:
|
||||
|
||||
void HandleButtonStates(void);
|
||||
void SetAllScrollBars(void);
|
||||
|
||||
BButton *fDefaultsButton;
|
||||
BButton *fRevertButton;
|
||||
|
||||
KnobSizeAdjuster *fSizeAdjuster;
|
||||
|
||||
FakeScrollBar *fSingle;
|
||||
FakeScrollBar *fDouble;
|
||||
FakeScrollBar *fProportional;
|
||||
FakeScrollBar *fFixed;
|
||||
FakeScrollBar *fFlat;
|
||||
FakeScrollBar *fDots;
|
||||
FakeScrollBar *fLines;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,46 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ScrollBarWindow.cpp
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: Container window class
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include "ScrollBarWindow.h"
|
||||
#include "ScrollBarApp.h"
|
||||
#include "ScrollBarView.h"
|
||||
|
||||
ScrollBarWindow::ScrollBarWindow(void)
|
||||
: BWindow( BRect(50,50,398,325), "Scroll Bar", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE )
|
||||
: BWindow( BRect(50,50,398,325), "Scroll Bar", B_TITLED_WINDOW, B_NOT_RESIZABLE |
|
||||
B_NOT_ZOOMABLE )
|
||||
{
|
||||
sbview=new ScrollBarView;
|
||||
AddChild(sbview);
|
||||
AddChild(new ScrollBarView);
|
||||
}
|
||||
|
||||
ScrollBarWindow::~ScrollBarWindow(void)
|
||||
@@ -21,6 +50,8 @@ ScrollBarWindow::~ScrollBarWindow(void)
|
||||
bool
|
||||
ScrollBarWindow::QuitRequested(void)
|
||||
{
|
||||
scroll_bar_app->PostMessage(B_QUIT_REQUESTED);
|
||||
set_scroll_bar_info(&gSettings);
|
||||
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: ScrollBarWindow.h
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: Container window class
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SCROLL_BAR_WINDOW_H
|
||||
#define SCROLL_BAR_WINDOW_H
|
||||
|
||||
@@ -5,13 +32,12 @@
|
||||
|
||||
class ScrollBarView;
|
||||
|
||||
class ScrollBarWindow : public BWindow {
|
||||
class ScrollBarWindow : public BWindow
|
||||
{
|
||||
public:
|
||||
ScrollBarWindow(void);
|
||||
virtual ~ScrollBarWindow(void);
|
||||
virtual bool QuitRequested(void);
|
||||
|
||||
ScrollBarView *sbview;
|
||||
ScrollBarWindow(void);
|
||||
virtual ~ScrollBarWindow(void);
|
||||
virtual bool QuitRequested(void);
|
||||
};
|
||||
|
||||
#endif // SCROLL_BAR_WINDOW_H
|
||||
|
||||
@@ -1,307 +1,258 @@
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: fakescrollbar.cpp
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: Control to simulate a scrollbar
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include "scrollbar.h"
|
||||
#include "fakescrollbar.h"
|
||||
#include "messages.h"
|
||||
|
||||
FakeScrollBar::FakeScrollBar( BPoint position, bool selected,
|
||||
uint32 style, uint32 type, uint32 arrow, uint32 size, BMessage *message ):
|
||||
BView( BRect( position.x, position.y, position.x+132,
|
||||
position.y+20 ), "FakeScrollBar", B_FOLLOW_LEFT |
|
||||
B_FOLLOW_TOP, B_WILL_DRAW )
|
||||
{
|
||||
Selected=selected;
|
||||
Pressed=false;
|
||||
ArrowStyle=arrow;
|
||||
KnobType=type;
|
||||
KnobStyle=style;
|
||||
KnobSize=size;
|
||||
FakeScrollBar::FakeScrollBar( BPoint position, bool selected, int32 knobstyle,
|
||||
bool fixedthumb, bool doublearrow, int32 size, BMessage *message )
|
||||
|
||||
Message=message;
|
||||
: BControl( BRect(position.x, position.y, position.x+132, position.y+20), "FakeScrollBar", NULL,
|
||||
message, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE)
|
||||
{
|
||||
fIsSelected=selected;
|
||||
fIsPressed=false;
|
||||
fDoubleArrows=doublearrow;
|
||||
fFixedThumb=fixedthumb;
|
||||
|
||||
fKnobStyle=knobstyle;
|
||||
fMinKnobSize=size;
|
||||
}
|
||||
|
||||
void FakeScrollBar::DrawArrowBox( uint32 x, bool facingleft )
|
||||
FakeScrollBar::~FakeScrollBar(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FakeScrollBar::DrawArrowBox( uint32 x, bool facingleft )
|
||||
{
|
||||
// draw box
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( x, Bounds().top+3,
|
||||
x+16, Bounds().bottom-3 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(x, Bounds().top+3, x+16, Bounds().bottom-3), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( x, Bounds().top+3, x+16,
|
||||
Bounds().bottom-3 ) , B_SOLID_HIGH );
|
||||
StrokeRect( BRect(x, Bounds().top+3, x+16, Bounds().bottom-3 ) , B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x+1, Bounds().top+4 ),
|
||||
BPoint( x+15, Bounds().top+4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+1, Bounds().top+4 ),
|
||||
BPoint( x+1, Bounds().bottom-4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+1, Bounds().top+4), BPoint(x+15, Bounds().top+4), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+1, Bounds().top+4), BPoint(x+1, Bounds().bottom-4), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 192, 192, 192 );
|
||||
StrokeLine( BPoint( x+15, Bounds().bottom-4 ),
|
||||
BPoint( x+15, Bounds().top+4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+15, Bounds().bottom-4 ),
|
||||
BPoint( x+1, Bounds().bottom-4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+15, Bounds().bottom-4), BPoint(x+15, Bounds().top+4), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+15, Bounds().bottom-4), BPoint(x+1, Bounds().bottom-4), B_SOLID_HIGH );
|
||||
|
||||
if ( facingleft == true )
|
||||
if ( facingleft )
|
||||
{
|
||||
// draw arrow
|
||||
SetHighColor( 112, 112, 112 );
|
||||
StrokeLine( BPoint( x+4, Bounds().top+10 ),
|
||||
BPoint( x+11, Bounds().top+7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+4, Bounds().top+10 ),
|
||||
BPoint( x+11, Bounds().bottom-7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+11, Bounds().top+7 ),
|
||||
BPoint( x+11, Bounds().bottom-7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+4, Bounds().top+10), BPoint(x+11, Bounds().top+7), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+4, Bounds().top+10), BPoint(x+11, Bounds().bottom-7), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+11, Bounds().top+7), BPoint(x+11, Bounds().bottom-7), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x+4, Bounds().top+11 ),
|
||||
BPoint( x+11, Bounds().bottom-6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+12, Bounds().top+7 ),
|
||||
BPoint( x+12, Bounds().bottom-6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+4, Bounds().top+11), BPoint(x+11, Bounds().bottom-6), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+12, Bounds().top+7), BPoint(x+12, Bounds().bottom-6), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 192, 192, 192 );
|
||||
StrokeLine( BPoint( x+4, Bounds().top+9 ),
|
||||
BPoint( x+11, Bounds().top+6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+3, Bounds().top+10 ),
|
||||
BPoint( x+3, Bounds().top+10 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+12, Bounds().top+6 ),
|
||||
BPoint( x+12, Bounds().top+6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+4, Bounds().top+9), BPoint(x+11, Bounds().top+6), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+3, Bounds().top+10), BPoint(x+3, Bounds().top+10), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+12, Bounds().top+6), BPoint(x+12, Bounds().top+6), B_SOLID_HIGH );
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// draw arrow
|
||||
SetHighColor( 112, 112, 112 );
|
||||
StrokeLine( BPoint( x+12, Bounds().top+10 ),
|
||||
BPoint( x+5, Bounds().top+7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+12, Bounds().top+10 ),
|
||||
BPoint( x+5, Bounds().bottom-7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+5, Bounds().top+7 ),
|
||||
BPoint( x+5, Bounds().bottom-7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+12, Bounds().top+10), BPoint(x+5, Bounds().top+7), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+12, Bounds().top+10), BPoint(x+5, Bounds().bottom-7), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+5, Bounds().top+7), BPoint(x+5, Bounds().bottom-7), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x+12, Bounds().top+11 ),
|
||||
BPoint( x+5, Bounds().bottom-6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+4, Bounds().top+7 ),
|
||||
BPoint( x+4, Bounds().bottom-6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+12, Bounds().top+11), BPoint(x+5, Bounds().bottom-6), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+4, Bounds().top+7), BPoint(x+4, Bounds().bottom-6), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 192, 192, 192 );
|
||||
StrokeLine( BPoint( x+12, Bounds().top+9 ),
|
||||
BPoint( x+5, Bounds().top+6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+13, Bounds().top+10 ),
|
||||
BPoint( x+13, Bounds().top+10 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+4, Bounds().top+6 ),
|
||||
BPoint( x+4, Bounds().top+6 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+12, Bounds().top+9), BPoint(x+5, Bounds().top+6), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+13, Bounds().top+10), BPoint(x+13, Bounds().top+10), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+4, Bounds().top+6), BPoint(x+4, Bounds().top+6), B_SOLID_HIGH );
|
||||
}
|
||||
}
|
||||
|
||||
void FakeScrollBar::Draw( BRect updateRect )
|
||||
void
|
||||
FakeScrollBar::Draw( BRect updateRect )
|
||||
{
|
||||
SetViewColor( 216, 216, 216 );
|
||||
// Draw border.
|
||||
if ( Selected == true )
|
||||
|
||||
// Draw border
|
||||
if ( fIsSelected )
|
||||
SetHighColor( 0, 0, 0 );
|
||||
else if ( Pressed == true )
|
||||
else if ( fIsPressed )
|
||||
SetHighColor( 128, 128, 128 );
|
||||
else
|
||||
SetHighColor( 216, 216, 216 );
|
||||
|
||||
SetPenSize( 2 );
|
||||
StrokeRect( BRect( Bounds().left, Bounds().top,
|
||||
Bounds().right-1, Bounds().bottom-1 ), B_SOLID_HIGH );
|
||||
StrokeRect( BRect(Bounds().left, Bounds().top, Bounds().right-1, Bounds().bottom-1) );
|
||||
|
||||
SetPenSize( 1 );
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( Bounds().left+2, Bounds().top+2,
|
||||
Bounds().right-2, Bounds().bottom-2 ), B_SOLID_HIGH );
|
||||
|
||||
FillRect( BRect(Bounds().left+2, Bounds().top+2, Bounds().right-2, Bounds().bottom-2) );
|
||||
|
||||
// Draw first arrows
|
||||
if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_SINGLE )
|
||||
{
|
||||
DrawArrowBox( 3, true );
|
||||
DrawArrowBox( 113, false );
|
||||
}
|
||||
DrawArrowBox( 3, true );
|
||||
DrawArrowBox( 113, false );
|
||||
|
||||
// If double arrows, draw another set.
|
||||
if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_DOUBLE )
|
||||
if ( fDoubleArrows )
|
||||
{
|
||||
DrawArrowBox( 3, true );
|
||||
DrawArrowBox( 113, false );
|
||||
DrawArrowBox( 19, false );
|
||||
DrawArrowBox( 97, true );
|
||||
}
|
||||
|
||||
// Draw back
|
||||
if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_DOUBLE )
|
||||
if ( fDoubleArrows )
|
||||
{
|
||||
SetHighColor( 200, 200, 200 );
|
||||
FillRect( BRect( 36, 3, 96, 15 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(36, 3, 96, 15) );
|
||||
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeLine( BPoint( 36, 3 ), BPoint( 96, 3 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 36, 17 ), BPoint( 96, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 216, 216, 216 );
|
||||
StrokeLine( BPoint( 36, 16 ), BPoint( 96, 16 ), B_SOLID_HIGH );
|
||||
SetHighColor( 184, 184, 184 );
|
||||
FillRect( BRect( 36, 4, 37, 15 ), B_SOLID_HIGH );
|
||||
FillRect( BRect( 36, 4, 96, 5 ), B_SOLID_HIGH );
|
||||
}
|
||||
else if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_SINGLE )
|
||||
{
|
||||
SetHighColor( 200, 200, 200 );
|
||||
FillRect( BRect( 20, 3, 112, 15 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(36, 3), BPoint(96, 3) );
|
||||
StrokeLine( BPoint(36, 17), BPoint(96, 17) );
|
||||
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeLine( BPoint( 20, 3 ), BPoint( 112, 3 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 20, 17 ), BPoint( 112, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 216, 216, 216 );
|
||||
StrokeLine( BPoint( 20, 16 ), BPoint( 112, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(36, 16), BPoint(96, 16) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
FillRect( BRect( 20, 4, 21, 15 ), B_SOLID_HIGH );
|
||||
FillRect( BRect( 20, 4, 112, 5 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(36, 4, 37, 15) );
|
||||
FillRect( BRect(36, 4, 96, 5) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeLine( BPoint( 4, 3 ), BPoint( Bounds().right-5, 3 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 4, 17 ), BPoint( Bounds().right-5, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 184, 184, 184 );
|
||||
FillRect( BRect( 4, 4, Bounds().right-5, 5 ), B_SOLID_HIGH );
|
||||
SetHighColor( 200, 200, 200 );
|
||||
FillRect( BRect( 4, 6, Bounds().right-5, 15), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 3, 15 ), BPoint( 3, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( Bounds().right-4, 7 ), BPoint( Bounds().right-4, 11 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( Bounds().right-3, 9 ), BPoint( Bounds().right-3, 9 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(20, 3, 112, 15) );
|
||||
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeLine( BPoint(20, 3), BPoint(112, 3) );
|
||||
StrokeLine( BPoint(20, 17), BPoint(112, 17) );
|
||||
|
||||
SetHighColor( 216, 216, 216 );
|
||||
StrokeLine( BPoint( 4, 7 ), BPoint( 4, 11 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 5, 9 ), BPoint( 5, 9 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( Bounds().right-5, 15 ), BPoint( Bounds().right-5, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(20, 16), BPoint(112, 16) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
FillRect( BRect(20, 4, 21, 15) );
|
||||
FillRect( BRect(20, 4, 112, 5) );
|
||||
}
|
||||
|
||||
// Draw knob
|
||||
if ( KnobType == SCROLLBAR_KNOB_TYPE_PROPORTIONAL )
|
||||
if ( fFixedThumb )
|
||||
{
|
||||
if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_DOUBLE )
|
||||
{
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( 44, 3, 88, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( 44, 3, 88, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect((Bounds().right/2)-(fMinKnobSize/2), 3,
|
||||
(Bounds().right/2)+(fMinKnobSize/2), 17) );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect((Bounds().right/2)-(fMinKnobSize/2), 3,
|
||||
(Bounds().right/2)+(fMinKnobSize/2), 17) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( 45, 4 ), BPoint( 87, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 45, 4 ), BPoint( 45, 16 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( 45, 16 ), BPoint( 87, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 87, 16 ), BPoint( 87, 4 ), B_SOLID_HIGH );
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint((Bounds().right/2)-(fMinKnobSize/2)+1, 4),
|
||||
BPoint((Bounds().right/2)+(fMinKnobSize/2)-1, 4) );
|
||||
StrokeLine( BPoint((Bounds().right/2)-(fMinKnobSize/2)+1, 4),
|
||||
BPoint((Bounds().right/2)-(fMinKnobSize/2)+1, 16) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint((Bounds().right/2)-(fMinKnobSize/2)+1, 16),
|
||||
BPoint((Bounds().right/2)+(fMinKnobSize/2)-1, 16) );
|
||||
StrokeLine( BPoint((Bounds().right/2)+(fMinKnobSize/2)-1, 16),
|
||||
BPoint((Bounds().right/2)+(fMinKnobSize/2)-1, 4) );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint( 88, 4 ), BPoint( 88, 16 ), B_SOLID_HIGH );
|
||||
}
|
||||
else if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_SINGLE )
|
||||
{
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( 32, 3, 100, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( 32, 3, 100, 17 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( 33, 4 ), BPoint( 99, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 33, 4 ), BPoint( 33, 16 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( 33, 16 ), BPoint( 99, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 99, 16 ), BPoint( 99, 4 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint( 100, 4 ), BPoint( 100, 16 ), B_SOLID_HIGH );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( 13, 3, 119, 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( 13, 3, 119, 17 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( 14, 4 ), BPoint( 118, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 14, 4 ), BPoint( 14, 16 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( 14, 16 ), BPoint( 118, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 118, 16 ), BPoint( 118, 4 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint( 119, 4 ), BPoint( 119, 16 ), B_SOLID_HIGH );
|
||||
}
|
||||
}
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint((Bounds().right/2)+(fMinKnobSize/2), 4),
|
||||
BPoint((Bounds().right/2)+(fMinKnobSize/2), 16) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ArrowStyle == SCROLLBAR_ARROW_STYLE_NONE )
|
||||
if ( fDoubleArrows )
|
||||
{
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( 13, 3, 119, 17 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(44, 3, 88, 17) );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( 13, 3, 119, 17 ), B_SOLID_HIGH );
|
||||
|
||||
StrokeRect( BRect(44, 3, 88, 17) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( 14, 4 ), BPoint( 118, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 14, 4 ), BPoint( 14, 16 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( 14, 16 ), BPoint( 118, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 118, 16 ), BPoint( 118, 4 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint( 119, 4 ), BPoint( 119, 16 ), B_SOLID_HIGH );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( (Bounds().right/2)-(KnobSize/2), 3,
|
||||
(Bounds().right/2)+(KnobSize/2), 17 ), B_SOLID_HIGH );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( (Bounds().right/2)-(KnobSize/2), 3,
|
||||
(Bounds().right/2)+(KnobSize/2), 17 ), B_SOLID_HIGH );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( (Bounds().right/2)-(KnobSize/2)+1, 4 ),
|
||||
BPoint( (Bounds().right/2)+(KnobSize/2)-1, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( (Bounds().right/2)-(KnobSize/2)+1, 4 ),
|
||||
BPoint( (Bounds().right/2)-(KnobSize/2)+1, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(45, 4), BPoint(87, 4) );
|
||||
StrokeLine( BPoint(45, 4), BPoint(45, 16) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( (Bounds().right/2)-(KnobSize/2)+1, 16 ),
|
||||
BPoint( (Bounds().right/2)+(KnobSize/2)-1, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( (Bounds().right/2)+(KnobSize/2)-1, 16 ),
|
||||
BPoint( (Bounds().right/2)+(KnobSize/2)-1, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(45, 16), BPoint(87, 16) );
|
||||
StrokeLine( BPoint(87, 16), BPoint(87, 4) );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint( (Bounds().right/2)+(KnobSize/2), 4 ),
|
||||
BPoint( (Bounds().right/2)+(KnobSize/2), 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(88, 4), BPoint(88, 16) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect(32, 3, 100, 17) );
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect(32, 3, 100, 17) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint(33, 4), BPoint(99, 4) );
|
||||
StrokeLine( BPoint(33, 4), BPoint(33, 16) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint(33, 16), BPoint(99, 16) );
|
||||
StrokeLine( BPoint(99, 16), BPoint(99, 4) );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint(100, 4), BPoint(100, 16) );
|
||||
}
|
||||
}
|
||||
|
||||
// Draw knob grabber
|
||||
if ( KnobStyle == SCROLLBAR_KNOB_STYLE_DOT )
|
||||
if ( fKnobStyle == THUMB_DOTS )
|
||||
{
|
||||
if ( KnobType == SCROLLBAR_KNOB_TYPE_PROPORTIONAL ||
|
||||
ArrowStyle == SCROLLBAR_ARROW_STYLE_NONE )
|
||||
if( fFixedThumb )
|
||||
DrawDotGrabber( Bounds().right/2, fMinKnobSize );
|
||||
else
|
||||
DrawDotGrabber( Bounds().right/2, 100 );
|
||||
else
|
||||
DrawDotGrabber( Bounds().right/2, KnobSize );
|
||||
}
|
||||
else if ( KnobStyle == SCROLLBAR_KNOB_STYLE_LINE )
|
||||
else if ( fKnobStyle == THUMB_LINES )
|
||||
{
|
||||
if ( KnobType == SCROLLBAR_KNOB_TYPE_PROPORTIONAL ||
|
||||
ArrowStyle == SCROLLBAR_ARROW_STYLE_NONE )
|
||||
DrawLineGrabber( Bounds().right/2, 100 );
|
||||
if ( fFixedThumb )
|
||||
DrawLineGrabber( Bounds().right/2, fMinKnobSize );
|
||||
else
|
||||
DrawLineGrabber( Bounds().right/2, KnobSize );
|
||||
DrawLineGrabber( Bounds().right/2, 100 );
|
||||
}
|
||||
}
|
||||
|
||||
void FakeScrollBar::DrawLineGrabber( uint32 x, uint32 size )
|
||||
void
|
||||
FakeScrollBar::DrawLineGrabber( uint32 x, uint32 size )
|
||||
{
|
||||
if ( size < 12 )
|
||||
{
|
||||
@@ -310,39 +261,40 @@ void FakeScrollBar::DrawLineGrabber( uint32 x, uint32 size )
|
||||
else if ( size < 22 )
|
||||
{
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x-1, 7 ), BPoint( x+1, 7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-1, 7 ), BPoint( x-1, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-1, 7), BPoint(x+1, 7) );
|
||||
StrokeLine( BPoint(x-1, 7), BPoint(x-1, 13) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x+1, 7 ), BPoint( x+1, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+1, 13 ), BPoint( x-1, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+1, 7), BPoint(x+1, 13) );
|
||||
StrokeLine( BPoint(x+1, 13), BPoint(x-1, 13) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x-1, 7 ), BPoint( x+1, 7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-1, 7 ), BPoint( x-1, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-1, 7), BPoint(x+1, 7) );
|
||||
StrokeLine( BPoint(x-1, 7), BPoint(x-1, 13) );
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x+1, 7 ), BPoint( x+1, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+1, 13 ), BPoint( x-1, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+1, 7), BPoint(x+1, 13) );
|
||||
StrokeLine( BPoint(x+1, 13), BPoint(x-1, 13) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x-5, 7 ), BPoint( x-3, 7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-5, 7 ), BPoint( x-5, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-5, 7), BPoint(x-3, 7) );
|
||||
StrokeLine( BPoint(x-5, 7), BPoint(x-5, 13) );
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x-3, 7 ), BPoint( x-3, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-3, 13 ), BPoint( x-5, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-3, 7), BPoint(x-3, 13) );
|
||||
StrokeLine( BPoint(x-3, 13), BPoint(x-5, 13) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x+3, 7 ), BPoint( x+5, 7 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+3, 7 ), BPoint( x+3, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+3, 7), BPoint(x+5, 7) );
|
||||
StrokeLine( BPoint(x+3, 7), BPoint(x+3, 13) );
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x+5, 7 ), BPoint( x+5, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+5, 13 ), BPoint( x+3, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+5, 7), BPoint(x+5, 13) );
|
||||
StrokeLine( BPoint(x+5, 13), BPoint(x+3, 13) );
|
||||
}
|
||||
}
|
||||
|
||||
void FakeScrollBar::DrawDotGrabber( uint32 x, uint32 size )
|
||||
void
|
||||
FakeScrollBar::DrawDotGrabber( uint32 x, uint32 size )
|
||||
{
|
||||
if ( size < 14 )
|
||||
{
|
||||
@@ -351,100 +303,124 @@ void FakeScrollBar::DrawDotGrabber( uint32 x, uint32 size )
|
||||
else if ( size < 27 )
|
||||
{
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x-2, 8 ), BPoint( x+2, 8 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-2, 8 ), BPoint( x-2, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-2, 8), BPoint(x+2, 8) );
|
||||
StrokeLine( BPoint(x-2, 8), BPoint(x-2, 12) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x+2, 8 ), BPoint( x+2, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+2, 12 ), BPoint( x-2, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+2, 8), BPoint(x+2, 12) );
|
||||
StrokeLine( BPoint(x+2, 12), BPoint(x-2, 12) );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x-2, 8 ), BPoint( x+2, 8 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-2, 8 ), BPoint( x-2, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-2, 8), BPoint(x+2, 8) );
|
||||
StrokeLine( BPoint(x-2, 8), BPoint(x-2, 12) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x+2, 8 ), BPoint( x+2, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+2, 12 ), BPoint( x-2, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+2, 8), BPoint(x+2, 12) );
|
||||
StrokeLine( BPoint(x+2, 12), BPoint(x-2, 12) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x-9, 8 ), BPoint( x-5, 8 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-9, 8 ), BPoint( x-9, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-9, 8), BPoint(x-5, 8) );
|
||||
StrokeLine( BPoint(x-9, 8), BPoint(x-9, 12) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x-5, 8 ), BPoint( x-5, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x-5, 12 ), BPoint( x-9, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x-5, 8), BPoint(x-5, 12) );
|
||||
StrokeLine( BPoint(x-5, 12), BPoint(x-9, 12) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( x+5, 8 ), BPoint( x+9, 8 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+5, 8 ), BPoint( x+5, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+5, 8), BPoint(x+9, 8) );
|
||||
StrokeLine( BPoint(x+5, 8), BPoint(x+5, 12) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( x+9, 8 ), BPoint( x+9, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( x+9, 12 ), BPoint( x+5, 12 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(x+9, 8), BPoint(x+9, 12) );
|
||||
StrokeLine( BPoint(x+9, 12), BPoint(x+5, 12) );
|
||||
}
|
||||
}
|
||||
|
||||
void FakeScrollBar::MouseDown( BPoint point )
|
||||
void
|
||||
FakeScrollBar::MouseDown( BPoint point )
|
||||
{
|
||||
SetTracking( true );
|
||||
}
|
||||
|
||||
void FakeScrollBar::MouseUp( BPoint point )
|
||||
void
|
||||
FakeScrollBar::MouseUp( BPoint point )
|
||||
{
|
||||
if ( IsPressed() == true )
|
||||
be_app->PostMessage( Message );
|
||||
if ( IsPressed() )
|
||||
Invoke();
|
||||
|
||||
SetTracking( false );
|
||||
}
|
||||
|
||||
void FakeScrollBar::MouseMoved( BPoint point, uint32 transit, const BMessage *message )
|
||||
void
|
||||
FakeScrollBar::MouseMoved( BPoint point, uint32 transit, const BMessage *message )
|
||||
{
|
||||
if ( transit == B_ENTERED_VIEW && IsTracking() == true )
|
||||
if ( transit == B_ENTERED_VIEW && IsTracking() )
|
||||
SetPressed( true );
|
||||
if ( transit == B_EXITED_VIEW && IsTracking() == true )
|
||||
|
||||
if ( transit == B_EXITED_VIEW && IsTracking() )
|
||||
SetPressed( false );
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetKnobStyle( uint32 style )
|
||||
void
|
||||
FakeScrollBar::SetDoubleArrows( bool doublearrows )
|
||||
{
|
||||
KnobStyle=style;
|
||||
fDoubleArrows = doublearrows;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetKnobType( uint32 type )
|
||||
void
|
||||
FakeScrollBar::SetFixedThumb( bool fixed )
|
||||
{
|
||||
KnobType=type;
|
||||
fFixedThumb = fixed;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetArrowStyle( uint32 arrow )
|
||||
void
|
||||
FakeScrollBar::SetKnobStyle( uint32 style )
|
||||
{
|
||||
ArrowStyle=arrow;
|
||||
fKnobStyle=style;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetKnobSize( uint32 size )
|
||||
void
|
||||
FakeScrollBar::SetKnobSize( int32 size )
|
||||
{
|
||||
KnobSize=size;
|
||||
fMinKnobSize=size;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetSelected( bool selected )
|
||||
void
|
||||
FakeScrollBar::SetFromScrollBarInfo(const scroll_bar_info &info)
|
||||
{
|
||||
Selected=selected;
|
||||
fDoubleArrows=info.double_arrows;
|
||||
fFixedThumb=!info.proportional;
|
||||
fMinKnobSize=info.min_knob_size;
|
||||
fKnobStyle=info.knob;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetPressed( bool pressed )
|
||||
void
|
||||
FakeScrollBar::SetSelected( bool selected )
|
||||
{
|
||||
Pressed=pressed;
|
||||
fIsSelected=selected;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void FakeScrollBar::SetTracking( bool tracking )
|
||||
void
|
||||
FakeScrollBar::SetPressed( bool pressed )
|
||||
{
|
||||
Tracking=tracking;
|
||||
fIsPressed=pressed;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void
|
||||
FakeScrollBar::SetTracking( bool tracking )
|
||||
{
|
||||
fIsTracking=tracking;
|
||||
|
||||
if ( IsTracking() == true )
|
||||
if ( IsTracking() )
|
||||
{
|
||||
SetEventMask( B_POINTER_EVENTS );
|
||||
SetPressed( true );
|
||||
@@ -456,18 +432,20 @@ void FakeScrollBar::SetTracking( bool tracking )
|
||||
}
|
||||
}
|
||||
|
||||
bool FakeScrollBar::IsSelected()
|
||||
bool
|
||||
FakeScrollBar::IsSelected()
|
||||
{
|
||||
return Selected;
|
||||
return fIsSelected;
|
||||
}
|
||||
|
||||
bool FakeScrollBar::IsPressed()
|
||||
bool
|
||||
FakeScrollBar::IsPressed()
|
||||
{
|
||||
return Pressed;
|
||||
return fIsPressed;
|
||||
}
|
||||
|
||||
bool FakeScrollBar::IsTracking()
|
||||
bool
|
||||
FakeScrollBar::IsTracking()
|
||||
{
|
||||
return Tracking;
|
||||
return fIsTracking;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,36 +1,86 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: fakescrollbar.h
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: Control to simulate a scrollbar
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SCROLLBAR_FAKE_H
|
||||
#define SCROLLBAR_FAKE_H
|
||||
|
||||
#include <View.h>
|
||||
#include <Control.h>
|
||||
|
||||
|
||||
class FakeScrollBar : public BView
|
||||
// These values are the same as what is kept in the scroll_bar_info struct.
|
||||
enum
|
||||
{
|
||||
public:
|
||||
FakeScrollBar( BPoint position, bool selected, uint32 style,
|
||||
uint32 type, uint32 arrow, uint32 size, BMessage *message );
|
||||
|
||||
void SetKnobStyle( uint32 style );
|
||||
void SetKnobType( uint32 type );
|
||||
void SetArrowStyle( uint32 arrow );
|
||||
void SetKnobSize( uint32 size );
|
||||
void SetSelected( bool selected );
|
||||
void SetPressed( bool pressed );
|
||||
void SetTracking( bool tracking );
|
||||
bool IsPressed();
|
||||
bool IsSelected();
|
||||
bool IsTracking();
|
||||
private:
|
||||
void Draw( BRect updateRect );
|
||||
void MouseDown( BPoint point );
|
||||
void MouseUp( BPoint point );
|
||||
void MouseMoved( BPoint point, uint32 transit, const BMessage *message );
|
||||
void DrawArrowBox( uint32 x, bool facingleft );
|
||||
void DrawDotGrabber( uint32 x, uint32 size );
|
||||
void DrawLineGrabber( uint32 x, uint32 size );
|
||||
BMessage *Message;
|
||||
bool Selected, Pressed, Tracking;
|
||||
uint32 ArrowStyle,KnobType,KnobStyle,KnobSize;
|
||||
THUMB_BLANK = 0,
|
||||
THUMB_DOTS,
|
||||
THUMB_LINES
|
||||
};
|
||||
|
||||
#endif
|
||||
class FakeScrollBar : public BControl
|
||||
{
|
||||
public:
|
||||
FakeScrollBar( BPoint position, bool selected, int32 knobstyle,
|
||||
bool fixedthumb, bool doublearrows, int32 size,
|
||||
BMessage *message );
|
||||
~FakeScrollBar(void);
|
||||
|
||||
void SetFromScrollBarInfo(const scroll_bar_info &info);
|
||||
|
||||
void SetDoubleArrows( bool doublearrows );
|
||||
void SetKnobSize( int32 size );
|
||||
void SetFixedThumb( bool fixed );
|
||||
void SetKnobStyle( uint32 style );
|
||||
|
||||
void SetSelected( bool selected );
|
||||
void SetPressed( bool pressed );
|
||||
void SetTracking( bool tracking );
|
||||
|
||||
bool IsPressed();
|
||||
bool IsSelected();
|
||||
bool IsTracking();
|
||||
|
||||
private:
|
||||
|
||||
void MouseDown( BPoint point );
|
||||
void MouseUp( BPoint point );
|
||||
void MouseMoved( BPoint point, uint32 transit, const BMessage *message );
|
||||
|
||||
void Draw( BRect updateRect );
|
||||
void DrawArrowBox( uint32 x, bool facingleft );
|
||||
void DrawDotGrabber( uint32 x, uint32 size );
|
||||
void DrawLineGrabber( uint32 x, uint32 size );
|
||||
|
||||
bool fIsSelected;
|
||||
bool fIsPressed;
|
||||
bool fIsTracking;
|
||||
|
||||
int32 fKnobStyle;
|
||||
|
||||
bool fDoubleArrows;
|
||||
bool fFixedThumb;
|
||||
int32 fMinKnobSize;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,63 +1,99 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: knobsizeadjuster.cpp
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: Control for changing the minimum size of thumb for scrollbars
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
|
||||
#include "scrollbar.h"
|
||||
#include "ScrollBarApp.h"
|
||||
#include "knobsizeadjuster.h"
|
||||
#include "messages.h"
|
||||
|
||||
KnobSizeAdjuster::KnobSizeAdjuster( BPoint position, uint32 size ):
|
||||
BView( BRect( position.x, position.y, position.x+133,
|
||||
position.y+26 ), "KnobSizeAdjuster", B_FOLLOW_LEFT |
|
||||
B_FOLLOW_TOP, B_WILL_DRAW )
|
||||
#define MAXIMUM_KNOB_SIZE 50
|
||||
#define MINIMUM_KNOB_SIZE 9
|
||||
|
||||
KnobSizeAdjuster::KnobSizeAdjuster( BPoint position, uint32 size )
|
||||
:BControl( BRect(position.x, position.y, position.x+133, position.y+26),
|
||||
"KnobSizeAdjuster", NULL, new BMessage(SCROLLBAR_KNOB_SIZE_CHANGED),
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW )
|
||||
{
|
||||
KnobSize=size;
|
||||
fKnobSize=size;
|
||||
}
|
||||
|
||||
void KnobSizeAdjuster::Draw( BRect updateRect )
|
||||
{
|
||||
SetViewColor( 216, 216, 216 );
|
||||
// Draw border.
|
||||
|
||||
// Draw border
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( Bounds(), B_SOLID_HIGH );
|
||||
FillRect( Bounds() );
|
||||
|
||||
// Draw back
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeLine( BPoint( 4, 3 ), BPoint( Bounds().right-5, 3 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 4, 17 ), BPoint( Bounds().right-5, 17 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(4, 3), BPoint(Bounds().right-5, 3) );
|
||||
StrokeLine( BPoint(4, 17), BPoint(Bounds().right-5, 17) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
FillRect( BRect( 4, 4, Bounds().right-5, 5 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(4, 4, Bounds().right-5, 5) );
|
||||
|
||||
SetHighColor( 200, 200, 200 );
|
||||
FillRect( BRect( 4, 6, Bounds().right-5, 15), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 3, 15 ), BPoint( 3, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( Bounds().right-4, 7 ), BPoint( Bounds().right-4, 11 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( Bounds().right-3, 9 ), BPoint( Bounds().right-3, 9 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(4, 6, Bounds().right-5, 15) );
|
||||
StrokeLine( BPoint(3, 15), BPoint(3, 13) );
|
||||
StrokeLine( BPoint(Bounds().right-4, 7), BPoint(Bounds().right-4, 11) );
|
||||
StrokeLine( BPoint(Bounds().right-3, 9), BPoint(Bounds().right-3, 9) );
|
||||
|
||||
SetHighColor( 216, 216, 216 );
|
||||
StrokeLine( BPoint( 4, 7 ), BPoint( 4, 11 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 5, 9 ), BPoint( 5, 9 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( Bounds().right-5, 15 ), BPoint( Bounds().right-5, 13 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(4, 7), BPoint(4, 11) );
|
||||
StrokeLine( BPoint(5, 9), BPoint(5, 9) );
|
||||
StrokeLine( BPoint(Bounds().right-5, 15), BPoint(Bounds().right-5, 13) );
|
||||
|
||||
// Draw knob
|
||||
SetHighColor( 216, 216, 216 );
|
||||
FillRect( BRect( 41, 3, 41+KnobSize, 17 ), B_SOLID_HIGH );
|
||||
FillRect( BRect(41, 3, 41+fKnobSize, 17) );
|
||||
|
||||
SetHighColor( 152, 152, 152 );
|
||||
StrokeRect( BRect( 41, 3, 41+KnobSize, 17 ), B_SOLID_HIGH );
|
||||
StrokeRect( BRect(41, 3, 41+fKnobSize, 17) );
|
||||
|
||||
SetHighColor( 255, 255, 255 );
|
||||
StrokeLine( BPoint( 42, 4 ), BPoint( 41+KnobSize-1, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 42, 4 ), BPoint( 42, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(42, 4), BPoint(41+fKnobSize-1, 4) );
|
||||
StrokeLine( BPoint(42, 4), BPoint(42, 16) );
|
||||
|
||||
SetHighColor( 184, 184, 184 );
|
||||
StrokeLine( BPoint( 42, 16 ), BPoint( 41+KnobSize-1, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint( 41+KnobSize-1, 16 ), BPoint( 41+KnobSize-1, 4 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(42, 16), BPoint(41+fKnobSize-1, 16) );
|
||||
StrokeLine( BPoint(41+fKnobSize-1, 16), BPoint(41+fKnobSize-1, 4) );
|
||||
|
||||
SetHighColor( 96, 96, 96 );
|
||||
StrokeLine( BPoint( 41+KnobSize, 4 ), BPoint( 41+KnobSize, 16 ), B_SOLID_HIGH );
|
||||
StrokeLine( BPoint(41+fKnobSize, 4), BPoint(41+fKnobSize, 16) );
|
||||
|
||||
// Draw slider
|
||||
SetHighColor( 0, 255, 0 );
|
||||
FillTriangle( BPoint( 41+KnobSize, 18), BPoint( 41+KnobSize+5, 23 ), BPoint( 41+KnobSize-5, 23), B_SOLID_HIGH );
|
||||
FillTriangle( BPoint(41+fKnobSize, 18), BPoint(41+fKnobSize+5, 23), BPoint(41+fKnobSize-5, 23) );
|
||||
|
||||
SetHighColor( 0, 0, 0 );
|
||||
StrokeTriangle( BPoint( 41+KnobSize, 18), BPoint( 41+KnobSize+5, 23 ),
|
||||
BPoint( 41+KnobSize-5, 23), B_SOLID_HIGH );
|
||||
StrokeTriangle( BPoint(41+fKnobSize, 18), BPoint(41+fKnobSize+5, 23),
|
||||
BPoint(41+fKnobSize-5, 23) );
|
||||
}
|
||||
|
||||
void KnobSizeAdjuster::MouseDown( BPoint point )
|
||||
@@ -66,10 +102,13 @@ void KnobSizeAdjuster::MouseDown( BPoint point )
|
||||
|
||||
if ( point.x > 41+MINIMUM_KNOB_SIZE && point.x < MAXIMUM_KNOB_SIZE+41 )
|
||||
newsize = (int)point.x-41;
|
||||
|
||||
if ( point.x <= 41+MINIMUM_KNOB_SIZE )
|
||||
newsize = MINIMUM_KNOB_SIZE;
|
||||
|
||||
if ( point.x >= 41+MAXIMUM_KNOB_SIZE )
|
||||
newsize = MAXIMUM_KNOB_SIZE;
|
||||
|
||||
SetKnobSize( newsize );
|
||||
|
||||
SetTracking( true );
|
||||
@@ -78,11 +117,10 @@ void KnobSizeAdjuster::MouseDown( BPoint point )
|
||||
void KnobSizeAdjuster::MouseUp( BPoint point )
|
||||
{
|
||||
SetTracking( false );
|
||||
be_app->PostMessage( SCROLLBAR_KNOB_SIZE_CHANGED );
|
||||
Invoke();
|
||||
}
|
||||
|
||||
void KnobSizeAdjuster::MouseMoved( BPoint point, uint32 transit,
|
||||
const BMessage *message )
|
||||
void KnobSizeAdjuster::MouseMoved( BPoint point, uint32 transit, const BMessage *message )
|
||||
{
|
||||
int32 newsize=0;
|
||||
|
||||
@@ -90,30 +128,33 @@ void KnobSizeAdjuster::MouseMoved( BPoint point, uint32 transit,
|
||||
{
|
||||
if ( point.x > 41+MINIMUM_KNOB_SIZE && point.x < MAXIMUM_KNOB_SIZE+41 )
|
||||
newsize = (int)point.x-41;
|
||||
|
||||
if ( point.x <= 41+MINIMUM_KNOB_SIZE )
|
||||
newsize = MINIMUM_KNOB_SIZE;
|
||||
|
||||
if ( point.x >= 41+MAXIMUM_KNOB_SIZE )
|
||||
newsize = MAXIMUM_KNOB_SIZE;
|
||||
|
||||
SetKnobSize( newsize );
|
||||
}
|
||||
}
|
||||
|
||||
void KnobSizeAdjuster::SetKnobSize( uint32 size )
|
||||
void KnobSizeAdjuster::SetKnobSize( int32 size )
|
||||
{
|
||||
KnobSize=size;
|
||||
Settings.KnobSize=KnobSize;
|
||||
fKnobSize=size;
|
||||
gSettings.min_knob_size=fKnobSize;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void KnobSizeAdjuster::SetPressed( bool pressed )
|
||||
{
|
||||
Pressed=pressed;
|
||||
fPressed=pressed;
|
||||
}
|
||||
|
||||
void KnobSizeAdjuster::SetTracking( bool tracking )
|
||||
{
|
||||
Tracking=tracking;
|
||||
fTracking=tracking;
|
||||
|
||||
if ( IsTracking() == true )
|
||||
SetEventMask( B_POINTER_EVENTS );
|
||||
@@ -123,12 +164,12 @@ void KnobSizeAdjuster::SetTracking( bool tracking )
|
||||
|
||||
bool KnobSizeAdjuster::IsPressed()
|
||||
{
|
||||
return Pressed;
|
||||
return fPressed;
|
||||
}
|
||||
|
||||
bool KnobSizeAdjuster::IsTracking()
|
||||
{
|
||||
return Tracking;
|
||||
return fTracking;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +1,58 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: knobsizeadjuster.h
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: Control for changing the minimum size of thumb for scrollbars
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SCROLLBAR_KNOB_ADJUSTER_H
|
||||
#define SCROLLBAR_KNOB_ADJUSTER_H
|
||||
|
||||
#include <View.h>
|
||||
#include <Control.h>
|
||||
|
||||
|
||||
class KnobSizeAdjuster : public BView
|
||||
class KnobSizeAdjuster : public BControl
|
||||
{
|
||||
public:
|
||||
KnobSizeAdjuster( BPoint position, uint32 size );
|
||||
public:
|
||||
KnobSizeAdjuster( BPoint position, uint32 size );
|
||||
|
||||
void SetKnobSize( uint32 size );
|
||||
void SetPressed( bool pressed );
|
||||
void SetTracking( bool tracking );
|
||||
bool IsPressed();
|
||||
bool IsTracking();
|
||||
private:
|
||||
void Draw( BRect updateRect );
|
||||
void MouseDown( BPoint point );
|
||||
void MouseUp( BPoint point );
|
||||
void MouseMoved( BPoint point, uint32 transit, const BMessage *message );
|
||||
uint32 KnobSize;
|
||||
bool Pressed, Tracking;
|
||||
void SetKnobSize( int32 size );
|
||||
void SetPressed( bool pressed );
|
||||
void SetTracking( bool tracking );
|
||||
bool IsPressed();
|
||||
bool IsTracking();
|
||||
|
||||
int32 KnobSize(void) const { return fKnobSize; }
|
||||
|
||||
private:
|
||||
|
||||
void Draw( BRect updateRect );
|
||||
void MouseDown( BPoint point );
|
||||
void MouseUp( BPoint point );
|
||||
void MouseMoved( BPoint point, uint32 transit, const BMessage *message );
|
||||
|
||||
int32 fKnobSize;
|
||||
bool fPressed;
|
||||
bool fTracking;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,3 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// Copyright (c) 2001-2005, Haiku, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
// File Name: messages.h
|
||||
// Author: MrSiggler
|
||||
// DarkWyrm <[email protected]>
|
||||
// Description: message defs
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef SCROLLBAR_MESSAGES_H
|
||||
#define SCROLLBAR_MESSAGES_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user