Fixed one of the reported bugs by using the default flags of the bounding

box instead of manually defining them (and forgetting about B_NAVIGABLE_JUMP).
Many style updates - more to come, though.
Moved the revert and default button variables into private. It now has an
extra SetRevertable() method to hide them.
Added newline to the end of file :)


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5944 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2004-01-06 22:01:44 +00:00
parent 7ad05b5060
commit e9cc36ba1a
2 changed files with 77 additions and 67 deletions
+39 -32
View File
@@ -30,10 +30,10 @@
#include "MouseMessages.h" #include "MouseMessages.h"
#include "MouseBitmap.h" #include "MouseBitmap.h"
BoxView::BoxView(BRect rect, MouseView *mouseView) BoxView::BoxView(BRect rect, MouseView *mouseView)
: BBox(rect, "mouse_box", : BBox(rect, "mouse_box"),
B_FOLLOW_LEFT, B_WILL_DRAW,B_FANCY_BORDER), fMouseView(mouseView)
fMouseView(mouseView)
{ {
} }
@@ -41,7 +41,6 @@ BoxView::BoxView(BRect rect, MouseView *mouseView)
void void
BoxView::MouseDown(BPoint where) BoxView::MouseDown(BPoint where)
{ {
int32 index = fMouseView->mouseTypeMenu->IndexOf(fMouseView->mouseTypeMenu->FindMarked()); int32 index = fMouseView->mouseTypeMenu->IndexOf(fMouseView->mouseTypeMenu->FindMarked());
fMouseView->fCurrentButton = -1; fMouseView->fCurrentButton = -1;
@@ -76,33 +75,31 @@ BoxView::MouseDown(BPoint where)
MouseView::MouseView(BRect rect) MouseView::MouseView(BRect rect)
: BBox(rect, "mouse_view", : BView(rect, "mouse_view", B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED),
B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP | B_PULSE_NEEDED, fCurrentButton(-1),
B_PLAIN_BORDER), fButtons(0),
fCurrentButton(-1), fOldButtons(0)
fButtons(0),
fOldButtons(0)
{ {
BRect frame; BTextControl *textcontrol;
BTextControl *textcontrol; BMenuField *menufield;
BMenuField *menufield; BRect frame;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fDoubleClickBitmap = BTranslationUtils::GetBitmap("double_click_bmap"); fDoubleClickBitmap = BTranslationUtils::GetBitmap("double_click_bmap");
if(!fDoubleClickBitmap) { if (!fDoubleClickBitmap) {
printf("can't load double_click_bmap with BTranslationUtils::GetBitmap\n"); printf("can't load double_click_bmap with BTranslationUtils::GetBitmap\n");
exit(1); exit(1);
} }
fSpeedBitmap = BTranslationUtils::GetBitmap("speed_bmap"); fSpeedBitmap = BTranslationUtils::GetBitmap("speed_bmap");
if(!fSpeedBitmap) { if (!fSpeedBitmap) {
printf("can't load speed_bmap with BTranslationUtils::GetBitmap\n"); printf("can't load speed_bmap with BTranslationUtils::GetBitmap\n");
exit(1); exit(1);
} }
fAccelerationBitmap = BTranslationUtils::GetBitmap("acceleration_bmap"); fAccelerationBitmap = BTranslationUtils::GetBitmap("acceleration_bmap");
if(!fAccelerationBitmap) { if (!fAccelerationBitmap) {
printf("can't load acceleration_bmap with BTranslationUtils::GetBitmap\n"); printf("can't load acceleration_bmap with BTranslationUtils::GetBitmap\n");
exit(1); exit(1);
} }
@@ -128,18 +125,18 @@ MouseView::MouseView(BRect rect)
AddChild(revertButton); AddChild(revertButton);
// Create the main box for the controls... // Create the main box for the controls...
frame=Bounds(); frame = Bounds();
frame.left=frame.left+11; frame.left = frame.left+11;
frame.top=frame.top+11; frame.top = frame.top+11;
frame.right=frame.right-11; frame.right = frame.right-11;
frame.bottom=frame.bottom-44; frame.bottom = frame.bottom-44;
fBox = new BoxView(frame, this); fBox = new BoxView(frame, this);
// Add the "Mouse Type" pop up menu // Add the "Mouse Type" pop up menu
mouseTypeMenu = new BPopUpMenu("Mouse Type Menu"); mouseTypeMenu = new BPopUpMenu("Mouse Type Menu");
mouseTypeMenu->AddItem(new BMenuItem("1-Button",new BMessage(POPUP_MOUSE_TYPE))); mouseTypeMenu->AddItem(new BMenuItem("1-Button", new BMessage(POPUP_MOUSE_TYPE)));
mouseTypeMenu->AddItem(new BMenuItem("2-Button",new BMessage(POPUP_MOUSE_TYPE))); mouseTypeMenu->AddItem(new BMenuItem("2-Button", new BMessage(POPUP_MOUSE_TYPE)));
mouseTypeMenu->AddItem(new BMenuItem("3-Button",new BMessage(POPUP_MOUSE_TYPE))); mouseTypeMenu->AddItem(new BMenuItem("3-Button", new BMessage(POPUP_MOUSE_TYPE)));
frame.Set(7,8,208,20); frame.Set(7,8,208,20);
menufield = new BMenuField(frame, "mouse_type", "Mouse type", mouseTypeMenu); menufield = new BMenuField(frame, "mouse_type", "Mouse type", mouseTypeMenu);
@@ -154,16 +151,16 @@ MouseView::MouseView(BRect rect)
focusMenu->AddItem(new BMenuItem("Warping",new BMessage(POPUP_MOUSE_FOCUS))); focusMenu->AddItem(new BMenuItem("Warping",new BMessage(POPUP_MOUSE_FOCUS)));
focusMenu->AddItem(new BMenuItem("Instant-Warping",new BMessage(POPUP_MOUSE_FOCUS))); focusMenu->AddItem(new BMenuItem("Instant-Warping",new BMessage(POPUP_MOUSE_FOCUS)));
frame.Set(165,208,440,200); frame.Set(165, 208, 440, 200);
menufield = new BMenuField(frame, "Focus follows mouse", "Focus follows mouse", focusMenu); menufield = new BMenuField(frame, "Focus follows mouse", "Focus follows mouse", focusMenu);
menufield->SetDivider(menufield->Divider() - 18); menufield->SetDivider(menufield->Divider() - 18);
menufield->SetAlignment(B_ALIGN_RIGHT); menufield->SetAlignment(B_ALIGN_RIGHT);
fBox->AddChild(menufield); fBox->AddChild(menufield);
// Create the "Double-click speed slider... // Create the "Double-click speed slider...
frame.Set(166,11,328,50); frame.Set(166, 11, 328, 50);
dcSpeedSlider = new BSlider(frame,"double_click_speed","Double-click speed", dcSpeedSlider = new BSlider(frame,"double_click_speed","Double-click speed",
new BMessage(SLIDER_DOUBLE_CLICK_SPEED),0,1000,B_BLOCK_THUMB,B_FOLLOW_LEFT,B_WILL_DRAW); new BMessage(SLIDER_DOUBLE_CLICK_SPEED), 0, 1000, B_BLOCK_THUMB, B_FOLLOW_LEFT, B_WILL_DRAW);
dcSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); dcSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
dcSpeedSlider->SetHashMarkCount(5); dcSpeedSlider->SetHashMarkCount(5);
dcSpeedSlider->SetLimitLabels("Slow","Fast"); dcSpeedSlider->SetLimitLabels("Slow","Fast");
@@ -199,9 +196,9 @@ MouseView::MouseView(BRect rect)
AddChild(fBox); AddChild(fBox);
mouseMapMenu = new BPopUpMenu("Mouse Map Menu", true, true); mouseMapMenu = new BPopUpMenu("Mouse Map Menu", true, true);
mouseMapMenu->AddItem(new BMenuItem("1",new BMessage(POPUP_MOUSE_MAP))); mouseMapMenu->AddItem(new BMenuItem("1", new BMessage(POPUP_MOUSE_MAP)));
mouseMapMenu->AddItem(new BMenuItem("2",new BMessage(POPUP_MOUSE_MAP))); mouseMapMenu->AddItem(new BMenuItem("2", new BMessage(POPUP_MOUSE_MAP)));
mouseMapMenu->AddItem(new BMenuItem("3",new BMessage(POPUP_MOUSE_MAP))); mouseMapMenu->AddItem(new BMenuItem("3", new BMessage(POPUP_MOUSE_MAP)));
} }
@@ -218,7 +215,7 @@ MouseView::AttachedToWindow()
get_mouse_map(&fCurrentMouseMap); get_mouse_map(&fCurrentMouseMap);
Init(); Init();
mouseMapMenu->SetTargetForItems( this->Window() ); mouseMapMenu->SetTargetForItems(Window());
} }
@@ -229,6 +226,7 @@ MouseView::Pulse()
GetMouse(&point, &fButtons, true); GetMouse(&point, &fButtons, true);
if (fOldButtons != fButtons) { if (fOldButtons != fButtons) {
printf("buttons: old = %ld, new = %ld\n", fOldButtons, fButtons);
Invalidate(); Invalidate();
fOldButtons = fButtons; fOldButtons = fButtons;
} }
@@ -239,6 +237,7 @@ void
MouseView::Draw(BRect updateFrame) MouseView::Draw(BRect updateFrame)
{ {
inherited::Draw(updateFrame); inherited::Draw(updateFrame);
fBox->SetHighColor(120,120,120); fBox->SetHighColor(120,120,120);
fBox->SetLowColor(255,255,255); fBox->SetLowColor(255,255,255);
// Line above the test area // Line above the test area
@@ -390,7 +389,7 @@ MouseView::Init()
item->SetMarked(true); item->SetMarked(true);
int32 mode; int32 mode;
switch(fMouseMode) { switch (fMouseMode) {
case B_NORMAL_MOUSE: mode = 0; break; case B_NORMAL_MOUSE: mode = 0; break;
case B_FOCUS_FOLLOWS_MOUSE: mode = 1; break; case B_FOCUS_FOLLOWS_MOUSE: mode = 1; break;
case B_WARP_MOUSE: mode = 2; break; case B_WARP_MOUSE: mode = 2; break;
@@ -404,3 +403,11 @@ MouseView::Init()
printf("click_speed : %lli, mouse_speed : %li, mouse_acc : %li, mouse_type : %li\n", printf("click_speed : %lli, mouse_speed : %li, mouse_acc : %li, mouse_type : %li\n",
fClickSpeed, fMouseSpeed, fMouseAcc, fMouseType); fClickSpeed, fMouseSpeed, fMouseAcc, fMouseType);
} }
void
MouseView::SetRevertable(bool revertable)
{
revertButton->SetEnabled(revertable);
}
+16 -13
View File
@@ -15,24 +15,25 @@
#ifndef MOUSE_VIEW_H #ifndef MOUSE_VIEW_H
#define MOUSE_VIEW_H #define MOUSE_VIEW_H
#include <Box.h> #include <Box.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Button.h> #include <Button.h>
#include <Slider.h> #include <Slider.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
class MouseView : public BBox
{
public:
typedef BBox inherited;
class MouseView : public BView {
public:
MouseView(BRect frame); MouseView(BRect frame);
void AttachedToWindow();
virtual void AttachedToWindow();
virtual void Draw(BRect frame); virtual void Draw(BRect frame);
virtual void Pulse(); virtual void Pulse();
void Init();
BButton *defaultButton, *revertButton; void Init();
void SetRevertable(bool revertable);
BSlider *dcSpeedSlider, *mouseSpeedSlider, *mouseAccSlider; BSlider *dcSpeedSlider, *mouseSpeedSlider, *mouseAccSlider;
BPopUpMenu *mouseTypeMenu, *focusMenu, *mouseMapMenu; BPopUpMenu *mouseTypeMenu, *focusMenu, *mouseMapMenu;
@@ -46,22 +47,24 @@ public:
uint32 fButtons; uint32 fButtons;
uint32 fOldButtons; uint32 fOldButtons;
private: private:
typedef BView inherited;
BBox *fBox; BBox *fBox;
BBitmap *fDoubleClickBitmap, *fSpeedBitmap, *fAccelerationBitmap; BBitmap *fDoubleClickBitmap, *fSpeedBitmap, *fAccelerationBitmap;
BBitmap *fMouseBitmap, *fMouseDownBitmap; BBitmap *fMouseBitmap, *fMouseDownBitmap;
BButton *defaultButton, *revertButton;
}; };
class BoxView : public BBox class BoxView : public BBox {
{ public:
public:
BoxView(BRect frame, MouseView *mouseView); BoxView(BRect frame, MouseView *mouseView);
void MouseDown(BPoint where); void MouseDown(BPoint where);
private:
private:
MouseView *fMouseView; MouseView *fMouseView;
}; };
#endif #endif