Minor retooling of code to utilize a BView subclass to hold all controls

Utilizes OBOS BScrollBar class
Still BC, but no longer "drop-in" binary compatible - requires the R1 app_server
It is possible to tweak the sources to run it under R5


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5389 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-11-16 18:23:16 +00:00
parent 9107dffadc
commit 8246ebe549
6 changed files with 153 additions and 69 deletions
+2 -2
View File
@@ -2,6 +2,6 @@ SubDir OBOS_TOP src prefs scrollbar ;
AddResources ScrollBar : ScrollBar.rdef ; AddResources ScrollBar : ScrollBar.rdef ;
Preference ScrollBar : ScrollBar.cpp ScrollBarApp.cpp ScrollBarWindow.cpp ; Preference ScrollBar : ScrollBar.cpp ScrollBarApp.cpp ScrollBarWindow.cpp ScrollBarView.cpp ;
LinkSharedOSLibs ScrollBar : be root ; LinkSharedOSLibs ScrollBar : be root <boot!home!config!lib>libopenbeos.so ;
+2 -2
View File
@@ -1,5 +1,5 @@
#include <ScrollBarApp.h> #include "ScrollBarApp.h"
#include <ScrollBarWindow.h> #include "ScrollBarWindow.h"
ScrollBarApp * scroll_bar_app = 0; ScrollBarApp * scroll_bar_app = 0;
+113
View File
@@ -0,0 +1,113 @@
#include "ScrollBarView.h"
#include "messages.h"
// our own homegrown private cheat function for controlling scrollbars
status_t control_scrollbar(int8 command, void *data, BScrollBar *sb);
// Magic numbers for control_scrollbar()
#define CONTROL_SET_DOUBLE 1
#define CONTROL_SET_PROPORTIONAL 2
#define CONTROL_SET_STYLE 3
ScrollBarView::ScrollBarView(void)
: 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) );
arrowstyleBox->SetLabel( "Arrow Style" );
float doubleWidth = StringWidth("Double:");
bool tempbool;
int8 tempint;
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 );
tempbool=true;
control_scrollbar(CONTROL_SET_DOUBLE,&tempbool,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 );
tempbool=false;
control_scrollbar(CONTROL_SET_DOUBLE,&tempbool,sbsingle);
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 );
tempbool=true;
control_scrollbar(CONTROL_SET_PROPORTIONAL, &tempbool,sbdouble);
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 );
tempbool=false;
control_scrollbar(CONTROL_SET_PROPORTIONAL,&tempbool,sbfixed);
minknobsizeBox = new BBox( BRect( 12, 123, 169, 232) );
minknobsizeBox->SetLabel( "Minimum Knob Size" );
knobstyleBox = new BBox( BRect( 180, 123, 338, 232) );
knobstyleBox->SetLabel( "Knob Style" );
sbflat=new BScrollBar(BRect(12,22,145,42),"flatbar",NULL,0,100,B_HORIZONTAL);
knobstyleBox->AddChild( sbflat );
tempint=0;
control_scrollbar(CONTROL_SET_STYLE,&tempbool,sbflat);
sbdots=new BScrollBar(BRect(12,52,145,72),"dotbar",NULL,0,100,B_HORIZONTAL);
knobstyleBox->AddChild( sbdots );
tempint=1;
control_scrollbar(CONTROL_SET_STYLE,&tempbool,sbdots);
sblines=new BScrollBar(BRect(12,82,145,102),"linebar",NULL,0,100,B_HORIZONTAL);
knobstyleBox->AddChild( sblines );
tempint=2;
control_scrollbar(CONTROL_SET_STYLE,&tempbool,sblines);
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 );
AddChild( arrowstyleBox );
AddChild( doubleStringView );
AddChild( singleStringView );
AddChild( knobtypeBox );
AddChild( proportionalStringView );
AddChild( fixedStringView );
AddChild( minknobsizeBox );
AddChild( knobstyleBox );
AddChild( defaultsButton );
AddChild( revertButton );
}
ScrollBarView::~ScrollBarView(void)
{
}
void ScrollBarView::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
default:
break;
}
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef SCROLLBAR_VIEW
#define SCROLLBAR_VIEW
#include <View.h>
#include <Box.h>
#include <StringView.h>
#include <Button.h>
#include <ScrollBar.h>
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;
BScrollBar *sbsingle, *sbdouble, *sbproportional, *sbfixed,
*sbflat, *sbdots, *sblines;
};
#endif
+5 -65
View File
@@ -3,75 +3,15 @@
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <StringView.h> #include <StringView.h>
#include <ScrollBarWindow.h> #include "ScrollBarWindow.h"
#include <ScrollBarApp.h> #include "ScrollBarApp.h"
#include "ScrollBarView.h"
ScrollBarWindow::ScrollBarWindow(void) 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 )
{ {
BBox* bigBox = new BBox( BRect(0,0,348,275), NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER ); sbview=new ScrollBarView;
BView* mainView = new BView( BRect(0,0,348,280),"mainView",B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW ); AddChild(sbview);
mainView->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
BBox* arrowstyleBox = new BBox( BRect( 12, 7, 169, 119) );
arrowstyleBox->SetLabel( "Arrow Style" );
char * doubleLabel = "Double:";
float doubleWidth = mainView->StringWidth(doubleLabel);
BStringView* doubleStringView = new BStringView( BRect(25,20,25+doubleWidth,38), "doubleStringView", doubleLabel );
BView* doublearrowView = new BView( BRect(24,38,157,58), "doublearrowView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
char * singleLabel = "Single:";
float singleWidth = mainView->StringWidth(singleLabel);
BStringView* singleStringView = new BStringView( BRect(25,60,25+singleWidth,87), "singleStringView", singleLabel );
BView* singlearrowView = new BView( BRect(24,87,157,107), "singlearrowView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
BBox* knobtypeBox = new BBox( BRect( 180, 7, 338, 119) );
knobtypeBox->SetLabel( "Knob Type" );
char * proportionalLabel = "Proportional:";
float proportionalWidth = mainView->StringWidth(proportionalLabel);
BStringView* proportionalStringView = new BStringView( BRect(193,20,193+proportionalWidth,38), "proportionalStringView", proportionalLabel );
BView* proportionalknobView = new BView( BRect(192,38,326,58), "proportionalknobView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
char * fixedLabel = "Fixed:";
float fixedWidth = mainView->StringWidth(fixedLabel);
BStringView* fixedStringView = new BStringView( BRect(193,60,193+fixedWidth,87), "fixedStringView", fixedLabel );
BView* fixedknobView = new BView( BRect(192,87,326,107), "fixedknobView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
BBox* minknobsizeBox = new BBox( BRect( 12, 123, 169, 232) );
minknobsizeBox->SetLabel( "Minimum Knob Size" );
BBox* knobstyleBox = new BBox( BRect( 180, 123, 338, 232) );
knobstyleBox->SetLabel( "Knob Style" );
BView* flatknobView = new BView( BRect(192,142,326,162), "flatknobView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
BView* dotknobView = new BView( BRect(192,173,326,193), "dotknobView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
BView* lineknobView = new BView( BRect(192,203,326,223), "lineknobView", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW );
BButton* defaultsButton = new BButton( BRect( 10, 242, 85, 265), "defaultsButton", "Defaults", NULL );
BButton* revertButton = new BButton( BRect( 95, 242, 170, 265), "revertButton", "Revert", NULL );
revertButton->SetEnabled( FALSE );
AddChild( mainView );
mainView->AddChild( bigBox );
mainView->AddChild( arrowstyleBox );
mainView->AddChild( doubleStringView );
mainView->AddChild( doublearrowView );
mainView->AddChild( singleStringView );
mainView->AddChild( singlearrowView );
mainView->AddChild( knobtypeBox );
mainView->AddChild( proportionalStringView );
mainView->AddChild( proportionalknobView );
mainView->AddChild( fixedStringView );
mainView->AddChild( fixedknobView );
mainView->AddChild( minknobsizeBox );
mainView->AddChild( knobstyleBox );
mainView->AddChild( flatknobView );
mainView->AddChild( lineknobView );
mainView->AddChild( dotknobView );
mainView->AddChild( defaultsButton );
mainView->AddChild( revertButton );
} }
ScrollBarWindow::~ScrollBarWindow(void) ScrollBarWindow::~ScrollBarWindow(void)
+4
View File
@@ -3,11 +3,15 @@
#include <Window.h> #include <Window.h>
class ScrollBarView;
class ScrollBarWindow : public BWindow { class ScrollBarWindow : public BWindow {
public: public:
ScrollBarWindow(void); ScrollBarWindow(void);
virtual ~ScrollBarWindow(void); virtual ~ScrollBarWindow(void);
virtual bool QuitRequested(void); virtual bool QuitRequested(void);
ScrollBarView *sbview;
}; };
#endif // SCROLL_BAR_WINDOW_H #endif // SCROLL_BAR_WINDOW_H