From 1f424632be5dcad5b81a23080eb205ab6471cd7b Mon Sep 17 00:00:00 2001 From: John Scipione Date: Wed, 11 Jun 2014 19:00:46 -0400 Subject: [PATCH] Style fixes to IK, focus on docs --- headers/os/interface/Alert.h | 38 +- headers/os/interface/Button.h | 5 +- headers/os/interface/ChannelControl.h | 44 +- headers/os/interface/CheckBox.h | 2 +- headers/os/interface/ColorControl.h | 8 +- headers/os/interface/Control.h | 2 +- headers/os/interface/ListView.h | 6 +- headers/os/interface/MenuField.h | 2 +- headers/os/interface/OutlineListView.h | 36 +- headers/os/interface/PictureButton.h | 14 +- headers/os/interface/RadioButton.h | 4 +- headers/os/interface/Region.h | 4 +- headers/os/interface/ScrollBar.h | 58 +- headers/os/interface/ScrollView.h | 65 +- headers/os/interface/TextView.h | 12 +- headers/os/interface/View.h | 8 +- headers/os/interface/Window.h | 2 +- src/kits/interface/Alert.cpp | 24 +- src/kits/interface/Button.cpp | 8 +- src/kits/interface/ChannelControl.cpp | 290 +++---- src/kits/interface/CheckBox.cpp | 4 +- src/kits/interface/ColorControl.cpp | 44 +- src/kits/interface/Control.cpp | 8 +- src/kits/interface/ListView.cpp | 32 +- src/kits/interface/MenuField.cpp | 8 +- src/kits/interface/OutlineListView.cpp | 5 +- src/kits/interface/PictureButton.cpp | 23 +- src/kits/interface/RadioButton.cpp | 8 +- src/kits/interface/Region.cpp | 29 +- src/kits/interface/ScrollBar.cpp | 997 ++++++++++++------------- src/kits/interface/ScrollView.cpp | 384 +++++----- src/kits/interface/TextView.cpp | 35 +- src/kits/interface/View.cpp | 47 +- src/kits/interface/Window.cpp | 2 +- 34 files changed, 1141 insertions(+), 1117 deletions(-) diff --git a/headers/os/interface/Alert.h b/headers/os/interface/Alert.h index c6c66d5f3c..3020b41497 100644 --- a/headers/os/interface/Alert.h +++ b/headers/os/interface/Alert.h @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006, Haiku, Inc. All rights reserved. + * Copyright 2001-2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. */ #ifndef _ALERT_H @@ -9,11 +9,6 @@ #include -class BBitmap; -class BButton; -class BInvoker; -class BTextView; - // enum for flavors of alert enum alert_type { B_EMPTY_ALERT = 0, @@ -29,41 +24,46 @@ enum button_spacing { }; +class BBitmap; +class BButton; +class BInvoker; +class BTextView; + class BAlert : public BWindow { - public: +public: BAlert(const char* title, const char* text, const char* button1, const char* button2 = NULL, const char* button3 = NULL, button_width width = B_WIDTH_AS_USUAL, alert_type type = B_INFO_ALERT); - BAlert(const char *title, const char *text, - const char *button1, const char *button2, - const char *button3, button_width width, + BAlert(const char* title, const char* text, + const char* button1, const char* button2, + const char* button3, button_width width, button_spacing spacing, alert_type type = B_INFO_ALERT); virtual ~BAlert(); // Archiving - BAlert(BMessage *data); - static BArchivable *Instantiate(BMessage *data); - virtual status_t Archive(BMessage *data, bool deep = true) const; + BAlert(BMessage* data); + static BArchivable *Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; // BAlert guts void SetShortcut(int32 button_index, char key); char Shortcut(int32 button_index) const; int32 Go(); - status_t Go(BInvoker *invoker); + status_t Go(BInvoker* invoker); - virtual void MessageReceived(BMessage *an_event); + virtual void MessageReceived(BMessage* message); virtual void FrameResized(float new_width, float new_height); BButton* ButtonAt(int32 index) const; BTextView* TextView() const; virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, + BMessage* specifier, int32 what, const char* property); - virtual status_t GetSupportedSuites(BMessage *data); + virtual status_t GetSupportedSuites(BMessage* data); virtual void DispatchMessage(BMessage* message, BHandler* handler); virtual void Quit(); @@ -71,9 +71,9 @@ class BAlert : public BWindow { static BPoint AlertPosition(float width, float height); - virtual status_t Perform(perform_code d, void *arg); + virtual status_t Perform(perform_code d, void* arg); - private: +private: friend class _BAlertFilter_; virtual void _ReservedAlert1(); diff --git a/headers/os/interface/Button.h b/headers/os/interface/Button.h index 5cfcd98fad..703bb09e8c 100644 --- a/headers/os/interface/Button.h +++ b/headers/os/interface/Button.h @@ -66,9 +66,9 @@ public: virtual void ResizeToPreferred(); virtual status_t Invoke(BMessage* message = NULL); virtual void FrameMoved(BPoint newPosition); - virtual void FrameResized(float width, float height); + virtual void FrameResized(float newWidth, float newHeight); - virtual void MakeFocus(bool focused = true); + virtual void MakeFocus(bool focus = true); virtual void AllAttached(); virtual void AllDetached(); @@ -78,7 +78,6 @@ public: virtual status_t GetSupportedSuites(BMessage* message); virtual status_t Perform(perform_code d, void* arg); - virtual BSize MinSize(); virtual BSize MaxSize(); virtual BSize PreferredSize(); diff --git a/headers/os/interface/ChannelControl.h b/headers/os/interface/ChannelControl.h index d457d22ec0..3f9e5c8877 100644 --- a/headers/os/interface/ChannelControl.h +++ b/headers/os/interface/ChannelControl.h @@ -5,34 +5,36 @@ #ifndef _CHANNEL_CONTROL_H #define _CHANNEL_CONTROL_H + //! BChannelControl is the base class for controls that have several // independent values, with minima and maxima. #include #include + class BChannelControl : public BControl { public: BChannelControl(BRect frame, const char* name, const char* label, BMessage* model, int32 channelCount = 1, - uint32 resizeFlags + uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, - uint32 viewFlags = B_WILL_DRAW); + uint32 flags = B_WILL_DRAW); BChannelControl(const char* name, const char* label, BMessage* model, int32 channelCount = 1, - uint32 viewFlags = B_WILL_DRAW); + uint32 flags = B_WILL_DRAW); BChannelControl(BMessage* archive); virtual ~BChannelControl(); - virtual status_t Archive(BMessage* into, bool deep = true) const; + virtual status_t Archive(BMessage* data, bool deep = true) const; virtual void Draw(BRect updateRect) = 0; virtual void MouseDown(BPoint where) = 0; - virtual void KeyDown(const char* bytes, int32 size) = 0; + virtual void KeyDown(const char* bytes, int32 numBytes) = 0; - virtual void FrameResized(float width, float height); + virtual void FrameResized(float newWidth, float newHeight); virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL); @@ -45,14 +47,14 @@ public: virtual void MessageReceived(BMessage* message); virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, + BMessage* specifier, int32 what, const char* property); virtual status_t GetSupportedSuites(BMessage* data); virtual void SetModificationMessage(BMessage* message); BMessage* ModificationMessage() const; - - virtual status_t Invoke(BMessage* withMessage = NULL); + + virtual status_t Invoke(BMessage* message = NULL); //! These methods are similar to Invoke() Invoke() and InvokeNotify(), but // include additional information about all of the channels in the control. @@ -112,18 +114,18 @@ private: BChannelControl(const BChannelControl& other); BChannelControl& operator=(const BChannelControl& other); - virtual void _Reserverd_ChannelControl_0(void *, ...); - virtual void _Reserverd_ChannelControl_1(void *, ...); - virtual void _Reserverd_ChannelControl_2(void *, ...); - virtual void _Reserverd_ChannelControl_3(void *, ...); - virtual void _Reserverd_ChannelControl_4(void *, ...); - virtual void _Reserverd_ChannelControl_5(void *, ...); - virtual void _Reserverd_ChannelControl_6(void *, ...); - virtual void _Reserverd_ChannelControl_7(void *, ...); - virtual void _Reserverd_ChannelControl_8(void *, ...); - virtual void _Reserverd_ChannelControl_9(void *, ...); - virtual void _Reserverd_ChannelControl_10(void *, ...); - virtual void _Reserverd_ChannelControl_11(void *, ...); + virtual void _Reserverd_ChannelControl_0(void*, ...); + virtual void _Reserverd_ChannelControl_1(void*, ...); + virtual void _Reserverd_ChannelControl_2(void*, ...); + virtual void _Reserverd_ChannelControl_3(void*, ...); + virtual void _Reserverd_ChannelControl_4(void*, ...); + virtual void _Reserverd_ChannelControl_5(void*, ...); + virtual void _Reserverd_ChannelControl_6(void*, ...); + virtual void _Reserverd_ChannelControl_7(void*, ...); + virtual void _Reserverd_ChannelControl_8(void*, ...); + virtual void _Reserverd_ChannelControl_9(void*, ...); + virtual void _Reserverd_ChannelControl_10(void*, ...); + virtual void _Reserverd_ChannelControl_11(void*, ...); protected: inline int32* const& MinLimitList() const; diff --git a/headers/os/interface/CheckBox.h b/headers/os/interface/CheckBox.h index 15ec2e7d10..674a701555 100644 --- a/headers/os/interface/CheckBox.h +++ b/headers/os/interface/CheckBox.h @@ -36,7 +36,7 @@ public: virtual void AllDetached(); virtual void FrameMoved(BPoint newPosition); - virtual void FrameResized(float width, float height); + virtual void FrameResized(float newWidth, float newHeight); virtual void WindowActivated(bool active); virtual void MessageReceived(BMessage* message); diff --git a/headers/os/interface/ColorControl.h b/headers/os/interface/ColorControl.h index b68617706c..2bcf0a00a8 100644 --- a/headers/os/interface/ColorControl.h +++ b/headers/os/interface/ColorControl.h @@ -29,11 +29,11 @@ public: float cellSize, const char* name, BMessage* message = NULL, bool useOffscreen = false); - BColorControl(BMessage* archive); + BColorControl(BMessage* data); virtual ~BColorControl(); - static BArchivable* Instantiate(BMessage* archive); - virtual status_t Archive(BMessage* archive, + static BArchivable* Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; virtual void SetLayout(BLayout* layout); @@ -91,7 +91,7 @@ private: void _InitData(color_control_layout layout, float size, bool useOffscreen, - BMessage* archive = NULL); + BMessage* data = NULL); void _LayoutView(); void _InitOffscreen(); void _InvalidateSelector(int16 ramp, diff --git a/headers/os/interface/Control.h b/headers/os/interface/Control.h index a62190db33..94edfd7f9d 100644 --- a/headers/os/interface/Control.h +++ b/headers/os/interface/Control.h @@ -45,7 +45,7 @@ public: virtual void AllDetached(); virtual void MessageReceived(BMessage* message); - virtual void MakeFocus(bool focused = true); + virtual void MakeFocus(bool focus = true); virtual void KeyDown(const char* bytes, int32 numBytes); virtual void MouseDown(BPoint where); diff --git a/headers/os/interface/ListView.h b/headers/os/interface/ListView.h index bca5b930be..311fa77dd5 100644 --- a/headers/os/interface/ListView.h +++ b/headers/os/interface/ListView.h @@ -53,8 +53,8 @@ public: virtual void AllDetached(); virtual void FrameResized(float newWidth, float newHeight); virtual void FrameMoved(BPoint newPosition); - virtual void TargetedByScrollView(BScrollView* scroller); - virtual void WindowActivated(bool state); + virtual void TargetedByScrollView(BScrollView* view); + virtual void WindowActivated(bool active); virtual void MessageReceived(BMessage* message); virtual void KeyDown(const char* bytes, int32 numBytes); @@ -142,7 +142,7 @@ public: virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, - int32 form, const char* property); + int32 what, const char* property); virtual status_t GetSupportedSuites(BMessage* data); virtual status_t Perform(perform_code code, void* arg); diff --git a/headers/os/interface/MenuField.h b/headers/os/interface/MenuField.h index 55491d356e..bbc95abf2a 100644 --- a/headers/os/interface/MenuField.h +++ b/headers/os/interface/MenuField.h @@ -45,7 +45,7 @@ public: virtual void KeyDown(const char* bytes, int32 numBytes); virtual void MakeFocus(bool focused); virtual void MessageReceived(BMessage* message); - virtual void WindowActivated(bool state); + virtual void WindowActivated(bool active); virtual void MouseUp(BPoint where); virtual void MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage); diff --git a/headers/os/interface/OutlineListView.h b/headers/os/interface/OutlineListView.h index 08de397619..2dc58ce3f5 100644 --- a/headers/os/interface/OutlineListView.h +++ b/headers/os/interface/OutlineListView.h @@ -24,7 +24,7 @@ public: uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); BOutlineListView(BMessage* archive); - virtual ~BOutlineListView(); + virtual ~BOutlineListView(); static BArchivable* Instantiate(BMessage* archive); virtual status_t Archive(BMessage* archive, @@ -36,16 +36,16 @@ public: virtual void FrameResized(float newWidth, float newHeight); virtual void MouseUp(BPoint where); - virtual bool AddUnder(BListItem* item, BListItem* superItem); + virtual bool AddUnder(BListItem* item, BListItem* superItem); - virtual bool AddItem(BListItem* item); - virtual bool AddItem(BListItem* item, int32 fullListIndex); - virtual bool AddList(BList* newItems); - virtual bool AddList(BList* newItems, int32 fullListIndex); + virtual bool AddItem(BListItem* item); + virtual bool AddItem(BListItem* item, int32 fullListIndex); + virtual bool AddList(BList* newItems); + virtual bool AddList(BList* newItems, int32 fullListIndex); - virtual bool RemoveItem(BListItem* item); - virtual BListItem* RemoveItem(int32 fullListIndex); - virtual bool RemoveItems(int32 fullListIndex, int32 count); + virtual bool RemoveItem(BListItem* item); + virtual BListItem* RemoveItem(int32 fullListIndex); + virtual bool RemoveItems(int32 fullListIndex, int32 count); BListItem* FullListItemAt(int32 fullListIndex) const; int32 FullListIndexOf(BPoint where) const; @@ -70,19 +70,19 @@ public: bool IsExpanded(int32 fullListIndex); - virtual BHandler* ResolveSpecifier(BMessage* message, + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, int32 what, const char* property); - virtual status_t GetSupportedSuites(BMessage* data); - virtual status_t Perform(perform_code code, void* data); + virtual status_t GetSupportedSuites(BMessage* data); + virtual status_t Perform(perform_code code, void* data); - virtual void ResizeToPreferred(); - virtual void GetPreferredSize(float* _width, + virtual void ResizeToPreferred(); + virtual void GetPreferredSize(float* _width, float* _height); - virtual void MakeFocus(bool focus = true); - virtual void AllAttached(); - virtual void AllDetached(); - virtual void DetachedFromWindow(); + virtual void MakeFocus(bool focus = true); + virtual void AllAttached(); + virtual void AllDetached(); + virtual void DetachedFromWindow(); void FullListSortItems(int (*compareFunc)( const BListItem* first, diff --git a/headers/os/interface/PictureButton.h b/headers/os/interface/PictureButton.h index bf706504ea..904ff467bb 100644 --- a/headers/os/interface/PictureButton.h +++ b/headers/os/interface/PictureButton.h @@ -41,11 +41,11 @@ public: virtual void ResizeToPreferred(); virtual void GetPreferredSize(float* _width, float* _height); - virtual void FrameMoved(BPoint position); - virtual void FrameResized(float width, float height); + virtual void FrameMoved(BPoint newPosition); + virtual void FrameResized(float newWidth, float newHeight); - virtual void WindowActivated(bool state); - virtual void MakeFocus(bool state = true); + virtual void WindowActivated(bool active); + virtual void MakeFocus(bool focus = true); virtual void Draw(BRect updateRect); @@ -53,8 +53,8 @@ public: virtual void KeyDown(const char* bytes, int32 numBytes); virtual void MouseDown(BPoint where); virtual void MouseUp(BPoint where); - virtual void MouseMoved(BPoint where, uint32 transit, - const BMessage* message); + virtual void MouseMoved(BPoint where, uint32 code, + const BMessage* dragMessage); virtual void SetEnabledOn(BPicture* picture); virtual void SetEnabledOff(BPicture* picture); @@ -74,7 +74,7 @@ public: virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, - int32 form, const char* property); + int32 what, const char* property); virtual status_t GetSupportedSuites(BMessage* data); virtual status_t Perform(perform_code code, void* data); diff --git a/headers/os/interface/RadioButton.h b/headers/os/interface/RadioButton.h index 0f8b037945..6a218db1d9 100644 --- a/headers/os/interface/RadioButton.h +++ b/headers/os/interface/RadioButton.h @@ -46,13 +46,13 @@ public: const BMessage* dragMessage); virtual void DetachedFromWindow(); virtual void FrameMoved(BPoint newPosition); - virtual void FrameResized(float width, float height); + virtual void FrameResized(float newWidth, float newHeight); virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, int32 what, const char* property); - virtual void MakeFocus(bool focused = true); + virtual void MakeFocus(bool focus = true); virtual void AllAttached(); virtual void AllDetached(); virtual status_t GetSupportedSuites(BMessage* message); diff --git a/headers/os/interface/Region.h b/headers/os/interface/Region.h index 8872b4f402..9c1e1b0b86 100644 --- a/headers/os/interface/Region.h +++ b/headers/os/interface/Region.h @@ -34,8 +34,8 @@ public: BRegion& operator=(const BRegion& other); bool operator==(const BRegion& other) const; - void Set(BRect newBounds); - void Set(clipping_rect newBounds); + void Set(BRect rect); + void Set(clipping_rect clipping); BRect Frame() const; clipping_rect FrameInt() const; diff --git a/headers/os/interface/ScrollBar.h b/headers/os/interface/ScrollBar.h index 65a62e79be..873ab84535 100644 --- a/headers/os/interface/ScrollBar.h +++ b/headers/os/interface/ScrollBar.h @@ -33,11 +33,33 @@ public: virtual status_t Archive(BMessage* archive, bool deep = true) const; + virtual void AllAttached(); + virtual void AllDetached(); + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + + virtual void Draw(BRect updateRect); + virtual void FrameMoved(BPoint new_position); + virtual void FrameResized(float newWidth, float newHeight); + + virtual void MessageReceived(BMessage* message); + + virtual void MouseDown(BPoint where); + virtual void MouseUp(BPoint where); + virtual void MouseMoved(BPoint where, uint32 code, + const BMessage* dragMessage); + +#if DISABLES_ON_WINDOW_DEACTIVATION + virtual void WindowActivated(bool active); +#endif + void SetValue(float value); float Value() const; + void SetProportion(float); float Proportion() const; + virtual void ValueChanged(float newValue); void SetRange(float min, float max); @@ -45,10 +67,12 @@ public: void SetSteps(float smallStep, float largeStep); void GetSteps(float* _smallStep, float* _largeStep) const; + void SetTarget(BView *target); void SetTarget(const char* targetName); BView* Target() const; - void SetOrientation(orientation orientation); + + void SetOrientation(orientation direction); orientation Orientation() const; // TODO: Make this a virtual method, it should be one, @@ -56,39 +80,23 @@ public: // to be used in case the BScrollBar should draw part of // the focus indication of the target view for aesthetical // reasons. BScrollView will forward this method. - status_t SetBorderHighlighted(bool state); + status_t SetBorderHighlighted(bool highlight); - virtual void MessageReceived(BMessage* message); - virtual void MouseDown(BPoint pt); - virtual void MouseUp(BPoint pt); - virtual void MouseMoved(BPoint pt, uint32 code, - const BMessage* dragMessage); - virtual void DetachedFromWindow(); - virtual void Draw(BRect updateRect); - virtual void FrameMoved(BPoint new_position); - virtual void FrameResized(float newWidth, float newHeight); - - virtual BHandler* ResolveSpecifier(BMessage* message, - int32 index, BMessage* specifier, - int32 form, const char* property); - - virtual void ResizeToPreferred(); virtual void GetPreferredSize(float* _width, float* _height); - virtual void MakeFocus(bool state = true); - virtual void AllAttached(); - virtual void AllDetached(); - virtual status_t GetSupportedSuites(BMessage* data); + virtual void ResizeToPreferred(); + virtual void MakeFocus(bool focus = true); virtual BSize MinSize(); virtual BSize MaxSize(); virtual BSize PreferredSize(); - virtual status_t Perform(perform_code d, void* arg); + virtual status_t GetSupportedSuites(BMessage* message); + virtual BHandler* ResolveSpecifier(BMessage* message, + int32 index, BMessage* specifier, + int32 what, const char* property); -#if DISABLES_ON_WINDOW_DEACTIVATION - virtual void WindowActivated(bool active); -#endif + virtual status_t Perform(perform_code d, void* arg); private: class Private; diff --git a/headers/os/interface/ScrollView.h b/headers/os/interface/ScrollView.h index 8a0214e62b..8caf7cf570 100644 --- a/headers/os/interface/ScrollView.h +++ b/headers/os/interface/ScrollView.h @@ -1,6 +1,11 @@ /* - * Copyright 2004-2009, Haiku, Inc. All rights reserved. - * Distributed under the terms of the MIT license. + * Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2014 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Axel Dörfler, axeld@pinc-software.de + * John Scipione, jscpione@gmail.com */ #ifndef _SCROLL_VIEW_H #define _SCROLL_VIEW_H @@ -28,55 +33,57 @@ public: virtual ~BScrollView(); static BArchivable* Instantiate(BMessage* archive); - virtual status_t Archive(BMessage* archive, - bool deep = true) const; + virtual status_t Archive(BMessage* archive, bool deep = true) const; - virtual void AttachedToWindow(); - virtual void DetachedFromWindow(); + // Hook methods virtual void AllAttached(); virtual void AllDetached(); - virtual void Draw(BRect updateRect); + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); - virtual void WindowActivated(bool active); - virtual void MakeFocus(bool state = true); + virtual void Draw(BRect updateRect); + virtual void FrameMoved(BPoint newPosition); + virtual void FrameResized(float newWidth, float newHeight); + + virtual void MessageReceived(BMessage* message); + + virtual void MouseDown(BPoint where); + virtual void MouseMoved(BPoint where, uint32 code, + const BMessage* dragMessage); + virtual void MouseUp(BPoint where); + + virtual void WindowActivated(bool active); + + // Size + virtual void GetPreferredSize(float* _width, float* _height); + virtual void ResizeToPreferred(); + + virtual void MakeFocus(bool focus = true); - virtual void GetPreferredSize(float* _width, - float* _height); virtual BSize MinSize(); virtual BSize MaxSize(); virtual BSize PreferredSize(); - virtual void ResizeToPreferred(); - virtual void FrameMoved(BPoint position); - virtual void FrameResized(float width, float height); - - virtual void MessageReceived(BMessage* message); - - virtual void MouseDown(BPoint point); - virtual void MouseUp(BPoint point); - virtual void MouseMoved(BPoint point, uint32 code, - const BMessage* dragMessage); - - // BScrollView + // BScrollBar BScrollBar* ScrollBar(orientation posture) const; - virtual void SetBorder(border_style border); + virtual void SetBorder(border_style border); border_style Border() const; - virtual status_t SetBorderHighlighted(bool state); + virtual status_t SetBorderHighlighted(bool highlight); bool IsBorderHighlighted() const; void SetTarget(BView* target); BView* Target() const; // Scripting - virtual BHandler* ResolveSpecifier(BMessage* message, + virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, - int32 form, const char* property); - virtual status_t GetSupportedSuites(BMessage* data); + int32 what, const char* property); + virtual status_t GetSupportedSuites(BMessage* message); - virtual status_t Perform(perform_code d, void* arg); + virtual status_t Perform(perform_code d, void* arg); protected: virtual void LayoutInvalidated(bool descendants = false); diff --git a/headers/os/interface/TextView.h b/headers/os/interface/TextView.h index 85f344317a..10366a50df 100644 --- a/headers/os/interface/TextView.h +++ b/headers/os/interface/TextView.h @@ -75,11 +75,11 @@ public: virtual void MouseUp(BPoint where); virtual void MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage); - virtual void WindowActivated(bool state); + virtual void WindowActivated(bool active); virtual void KeyDown(const char* bytes, int32 numBytes); virtual void Pulse(); - virtual void FrameResized(float width, float height); - virtual void MakeFocus(bool focusState = true); + virtual void FrameResized(float newWidth, float newHeight); + virtual void MakeFocus(bool focus = true); virtual void MessageReceived(BMessage* message); virtual BHandler* ResolveSpecifier(BMessage* message, @@ -114,7 +114,7 @@ public: int32 CountLines() const; int32 CurrentLine() const; - void GoToLine(int32 lineIndex); + void GoToLine(int32 lineNumber); virtual void Cut(BClipboard* clipboard); virtual void Copy(BClipboard* clipboard); @@ -159,8 +159,8 @@ public: virtual bool CanEndLine(int32 offset); - float LineWidth(int32 lineIndex = 0) const; - float LineHeight(int32 lineIndex = 0) const; + float LineWidth(int32 lineNumber = 0) const; + float LineHeight(int32 lineNumber = 0) const; float TextHeight(int32 startLine, int32 endLine) const; diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h index 75cf80b5b6..49e7519d91 100644 --- a/headers/os/interface/View.h +++ b/headers/os/interface/View.h @@ -170,7 +170,7 @@ public: virtual void MouseUp(BPoint where); virtual void MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage); - virtual void WindowActivated(bool state); + virtual void WindowActivated(bool active); virtual void KeyDown(const char* bytes, int32 numBytes); virtual void KeyUp(const char* bytes, int32 numBytes); virtual void Pulse(); @@ -285,7 +285,7 @@ public: void SetFillRule(int32 rule); int32 FillRule() const; - void SetOrigin(BPoint pt); + void SetOrigin(BPoint where); void SetOrigin(float x, float y); BPoint Origin() const; @@ -522,7 +522,7 @@ public: void ScrollBy(float dh, float dv); void ScrollTo(float x, float y); virtual void ScrollTo(BPoint where); - virtual void MakeFocus(bool focusState = true); + virtual void MakeFocus(bool focus = true); bool IsFocus() const; virtual void Show(); @@ -536,7 +536,7 @@ public: virtual void GetPreferredSize(float* _width, float* _height); virtual void ResizeToPreferred(); - BScrollBar* ScrollBar(orientation posture) const; + BScrollBar* ScrollBar(orientation direction) const; virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, int32 form, diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index bc8eb16f62..2caec31fb4 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -149,7 +149,7 @@ public: BView* CurrentFocus() const; void Activate(bool = true); - virtual void WindowActivated(bool state); + virtual void WindowActivated(bool focus); void ConvertToScreen(BPoint* point) const; BPoint ConvertToScreen(BPoint point) const; diff --git a/src/kits/interface/Alert.cpp b/src/kits/interface/Alert.cpp index 16231f5048..19d093ab6a 100644 --- a/src/kits/interface/Alert.cpp +++ b/src/kits/interface/Alert.cpp @@ -1,13 +1,16 @@ /* - * Copyright 2001-2008, Haiku. + * Copyright 2001-2015 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: - * Erik Jaesler (erik@cgsoftware.com) * Axel Dörfler, axeld@pinc-software.de + * Erik Jaesler, erik@cgsoftware.com + * John Scipione, jscipione@gmail.com */ -//! BAlert displays a modal alert window. + +// BAlert displays a modal alert window. + #include #include @@ -304,13 +307,13 @@ BAlert::Go(BInvoker* invoker) void -BAlert::MessageReceived(BMessage* msg) +BAlert::MessageReceived(BMessage* message) { - if (msg->what != kAlertButtonMsg) - return BWindow::MessageReceived(msg); + if (message->what != kAlertButtonMsg) + return BWindow::MessageReceived(message); int32 which; - if (msg->FindInt32("which", &which) == B_OK) { + if (message->FindInt32("which", &which) == B_OK) { if (fAlertSem < B_OK) { // Semaphore hasn't been created; we're running asynchronous if (fInvoker) { @@ -361,10 +364,11 @@ BAlert::TextView() const BHandler* -BAlert::ResolveSpecifier(BMessage* msg, int32 index, - BMessage* specifier, int32 form, const char* property) +BAlert::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) { - return BWindow::ResolveSpecifier(msg, index, specifier, form, property); + return BWindow::ResolveSpecifier(message, index, specifier, what, + property); } diff --git a/src/kits/interface/Button.cpp b/src/kits/interface/Button.cpp index db149c6825..fc1dc41c8f 100644 --- a/src/kits/interface/Button.cpp +++ b/src/kits/interface/Button.cpp @@ -469,16 +469,16 @@ BButton::FrameMoved(BPoint newPosition) void -BButton::FrameResized(float width, float height) +BButton::FrameResized(float newWidth, float newHeight) { - BControl::FrameResized(width, height); + BControl::FrameResized(newWidth, newHeight); } void -BButton::MakeFocus(bool focused) +BButton::MakeFocus(bool focus) { - BControl::MakeFocus(focused); + BControl::MakeFocus(focus); } diff --git a/src/kits/interface/ChannelControl.cpp b/src/kits/interface/ChannelControl.cpp index 39170cddf3..1d1ccfa067 100644 --- a/src/kits/interface/ChannelControl.cpp +++ b/src/kits/interface/ChannelControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2005-2009, Haiku Inc. All Rights Reserved. + * Copyright 2005-2014 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. */ @@ -14,29 +14,31 @@ sPropertyInfo[] = { { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_INT32_TYPE } }, - + { "CurrentChannel", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, - { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_INT32_TYPE } + { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_INT32_TYPE } }, - + { "MaxLimitLabel", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, - { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_STRING_TYPE } + { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_STRING_TYPE } }, - + { "MinLimitLabel", { B_GET_PROPERTY, B_SET_PROPERTY, 0 }, - { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_STRING_TYPE } + { B_DIRECT_SPECIFIER, 0 }, NULL, 0, { B_STRING_TYPE } }, - + { 0 } }; -BChannelControl::BChannelControl(BRect frame, const char *name, const char *label, - BMessage *model, int32 channel_count, uint32 resizeMode, uint32 flags) - : BControl(frame, name, label, model, resizeMode, flags), +BChannelControl::BChannelControl(BRect frame, const char* name, + const char* label, BMessage* model, int32 channel_count, + uint32 resizingMode, uint32 flags) + : + BControl(frame, name, label, model, resizingMode, flags), fChannelCount(channel_count), fCurrentChannel(0), fChannelMin(NULL), @@ -47,7 +49,7 @@ BChannelControl::BChannelControl(BRect frame, const char *name, const char *labe { fChannelMin = new int32[channel_count]; memset(fChannelMin, 0, sizeof(int32) * channel_count); - + fChannelMax = new int32[channel_count]; for (int32 i = 0; i < channel_count; i++) fChannelMax[i] = 100; @@ -57,10 +59,11 @@ BChannelControl::BChannelControl(BRect frame, const char *name, const char *labe } -BChannelControl::BChannelControl(const char *name, const char *label, - BMessage *model, int32 channel_count, uint32 flags) - : BControl(name, label, model, flags), - fChannelCount(channel_count), +BChannelControl::BChannelControl(const char* name, const char* label, + BMessage* model, int32 channelCount, uint32 flags) + : + BControl(name, label, model, flags), + fChannelCount(channelCount), fCurrentChannel(0), fChannelMin(NULL), fChannelMax(NULL), @@ -68,20 +71,21 @@ BChannelControl::BChannelControl(const char *name, const char *label, fMultiLabels(NULL), fModificationMsg(NULL) { - fChannelMin = new int32[channel_count]; - memset(fChannelMin, 0, sizeof(int32) * channel_count); + fChannelMin = new int32[channelCount]; + memset(fChannelMin, 0, sizeof(int32) * channelCount); - fChannelMax = new int32[channel_count]; - for (int32 i = 0; i < channel_count; i++) + fChannelMax = new int32[channelCount]; + for (int32 i = 0; i < channelCount; i++) fChannelMax[i] = 100; - fChannelValues = new int32[channel_count]; - memset(fChannelValues, 0, sizeof(int32) * channel_count); + fChannelValues = new int32[channelCount]; + memset(fChannelValues, 0, sizeof(int32) * channelCount); } -BChannelControl::BChannelControl(BMessage *archive) - : BControl(archive), +BChannelControl::BChannelControl(BMessage* archive) + : + BControl(archive), fChannelCount(0), fCurrentChannel(0), fChannelMin(NULL), @@ -92,37 +96,37 @@ BChannelControl::BChannelControl(BMessage *archive) { archive->FindInt32("be:_m_channel_count", &fChannelCount); archive->FindInt32("be:_m_value_channel", &fCurrentChannel); - + if (fChannelCount > 0) { fChannelMin = new int32[fChannelCount]; memset(fChannelMin, 0, sizeof(int32) * fChannelCount); - + fChannelMax = new int32[fChannelCount]; for (int32 i = 0; i < fChannelCount; i++) fChannelMax[i] = 100; - + fChannelValues = new int32[fChannelCount]; memset(fChannelValues, 0, sizeof(int32) * fChannelCount); - + for (int32 c = 0; c < fChannelCount; c++) { archive->FindInt32("be:_m_channel_min", c, &fChannelMin[c]); archive->FindInt32("be:_m_channel_max", c, &fChannelMax[c]); archive->FindInt32("be:_m_channel_val", c, &fChannelValues[c]); } } - - const char *label = NULL; + + const char* label = NULL; if (archive->FindString("be:_m_min_label", &label) == B_OK) fMinLabel = label; + if (archive->FindString("be:_m_max_label", &label) == B_OK) fMaxLabel = label; - - BMessage *modificationMessage = new BMessage; + + BMessage* modificationMessage = new BMessage; if (archive->FindMessage("_mod_msg", modificationMessage) == B_OK) fModificationMsg = modificationMessage; else delete modificationMessage; - } @@ -136,28 +140,33 @@ BChannelControl::~BChannelControl() status_t -BChannelControl::Archive(BMessage *message, bool deep) const +BChannelControl::Archive(BMessage* data, bool deep) const { - status_t status = BControl::Archive(message, deep); + status_t status = BControl::Archive(data, deep); if (status == B_OK) - status = message->AddInt32("be:_m_channel_count", fChannelCount); + status = data->AddInt32("be:_m_channel_count", fChannelCount); + if (status == B_OK) - status = message->AddInt32("be:_m_value_channel", fCurrentChannel); + status = data->AddInt32("be:_m_value_channel", fCurrentChannel); + if (status == B_OK) - status = message->AddString("be:_m_min_label", fMinLabel.String()); + status = data->AddString("be:_m_min_label", fMinLabel.String()); + if (status == B_OK) - status = message->AddString("be:_m_max_label", fMaxLabel.String()); - + status = data->AddString("be:_m_max_label", fMaxLabel.String()); + if (status == B_OK && fChannelValues != NULL && fChannelMax != NULL && fChannelMin != NULL) { for (int32 i = 0; i < fChannelCount; i++) { - status = message->AddInt32("be:_m_channel_min", fChannelMin[i]); + status = data->AddInt32("be:_m_channel_min", fChannelMin[i]); if (status < B_OK) break; - status = message->AddInt32("be:_m_channel_max", fChannelMax[i]); + + status = data->AddInt32("be:_m_channel_max", fChannelMax[i]); if (status < B_OK) break; - status = message->AddInt32("be:_m_channel_val", fChannelValues[i]); + + status = data->AddInt32("be:_m_channel_val", fChannelValues[i]); if (status < B_OK) break; } @@ -168,14 +177,14 @@ BChannelControl::Archive(BMessage *message, bool deep) const void -BChannelControl::FrameResized(float width, float height) +BChannelControl::FrameResized(float newWidth, float newHeight) { - BView::FrameResized(width, height); + BView::FrameResized(newWidth, newHeight); } void -BChannelControl::SetFont(const BFont *font, uint32 mask) +BChannelControl::SetFont(const BFont* font, uint32 mask) { BView::SetFont(font, mask); } @@ -203,31 +212,34 @@ BChannelControl::ResizeToPreferred() void -BChannelControl::MessageReceived(BMessage *message) +BChannelControl::MessageReceived(BMessage* message) { BControl::MessageReceived(message); } -BHandler * -BChannelControl::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, - int32 form, const char *property) +BHandler* +BChannelControl::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) { - BHandler *target = this; + BHandler* target = this; BPropertyInfo propertyInfo(sPropertyInfo); - if (propertyInfo.FindMatch(msg, index, specifier, form, property) < B_OK) - target = BControl::ResolveSpecifier(msg, index, specifier, form, property); - + if (propertyInfo.FindMatch(message, index, specifier, what, property) + < B_OK) { + target = BControl::ResolveSpecifier(message, index, specifier, + what, property); + } + return target; } status_t -BChannelControl::GetSupportedSuites(BMessage *data) +BChannelControl::GetSupportedSuites(BMessage* data) { if (data == NULL) return B_BAD_VALUE; - + status_t err = data->AddString("suites", "suite/vnd.Be-channel-control"); BPropertyInfo propertyInfo(sPropertyInfo); @@ -236,19 +248,20 @@ BChannelControl::GetSupportedSuites(BMessage *data) if (err == B_OK) return BControl::GetSupportedSuites(data); + return err; } void -BChannelControl::SetModificationMessage(BMessage *message) +BChannelControl::SetModificationMessage(BMessage* message) { delete fModificationMsg; fModificationMsg = message; } -BMessage * +BMessage* BChannelControl::ModificationMessage() const { return fModificationMsg; @@ -256,13 +269,13 @@ BChannelControl::ModificationMessage() const status_t -BChannelControl::Invoke(BMessage *msg) +BChannelControl::Invoke(BMessage* message) { bool notify = false; BMessage invokeMessage(InvokeKind(¬ify)); - if (msg != NULL) - invokeMessage = *msg; + if (message != NULL) + invokeMessage = *message; else if (Message() != NULL) invokeMessage = *Message(); @@ -273,39 +286,39 @@ BChannelControl::Invoke(BMessage *msg) status_t -BChannelControl::InvokeChannel(BMessage *msg, int32 fromChannel, - int32 channelCount, const bool *inMask) +BChannelControl::InvokeChannel(BMessage* message, int32 fromChannel, + int32 channelCount, const bool* _mask) { bool notify = false; BMessage invokeMessage(InvokeKind(¬ify)); - if (msg != NULL) - invokeMessage = *msg; + if (message != NULL) + invokeMessage = *message; else if (Message() != NULL) invokeMessage = *Message(); - + invokeMessage.AddInt32("be:current_channel", fCurrentChannel); - if (channelCount < 0) channelCount = fChannelCount - fromChannel; - + for (int32 i = 0; i < channelCount; i++) { - invokeMessage.AddInt32("be:channel_value", fChannelValues[fromChannel + i]); - invokeMessage.AddBool("be:channel_changed", inMask ? inMask[i] : true); + invokeMessage.AddInt32("be:channel_value", + fChannelValues[fromChannel + i]); + invokeMessage.AddBool("be:channel_changed", _mask ? _mask[i] : true); } - + return BControl::Invoke(&invokeMessage); } status_t -BChannelControl::InvokeNotifyChannel(BMessage *msg, uint32 kind, - int32 fromChannel, int32 channelCount, const bool *inMask) +BChannelControl::InvokeNotifyChannel(BMessage* message, uint32 kind, + int32 fromChannel, int32 channelCount, const bool* _mask) { BeginInvokeNotify(kind); - status_t status = InvokeChannel(msg, fromChannel, channelCount, inMask); + status_t status = InvokeChannel(message, fromChannel, channelCount, _mask); EndInvokeNotify(); - + return status; } @@ -316,10 +329,10 @@ BChannelControl::SetValue(int32 value) // Get real if (value > fChannelMax[fCurrentChannel]) value = fChannelMax[fCurrentChannel]; - + if (value < fChannelMin[fCurrentChannel]) value = fChannelMin[fCurrentChannel]; - + if (value != fChannelValues[fCurrentChannel]) { StuffValues(fCurrentChannel, 1, &value); BControl::SetValue(value); @@ -332,12 +345,12 @@ BChannelControl::SetCurrentChannel(int32 channel) { if (channel < 0 || channel >= fChannelCount) return B_BAD_INDEX; - + if (channel != fCurrentChannel) { fCurrentChannel = channel; BControl::SetValue(fChannelValues[fCurrentChannel]); } - + return B_OK; } @@ -364,25 +377,25 @@ BChannelControl::SetChannelCount(int32 channel_count) // TODO: Currently we only grow the buffer. Test what BeOS does if (channel_count > fChannelCount) { - int32 *newMin = new int32[channel_count]; - int32 *newMax = new int32[channel_count]; - int32 *newVal = new int32[channel_count]; - + int32* newMin = new int32[channel_count]; + int32* newMax = new int32[channel_count]; + int32* newVal = new int32[channel_count]; + memcpy(newMin, fChannelMin, fChannelCount); memcpy(newMax, fChannelMax, fChannelCount); memcpy(newVal, fChannelValues, fChannelCount); - + delete[] fChannelMin; delete[] fChannelMax; delete[] fChannelValues; - + fChannelMin = newMin; fChannelMax = newMax; fChannelValues = newVal; } - + fChannelCount = channel_count; - + return B_OK; } @@ -393,13 +406,13 @@ BChannelControl::ValueFor(int32 channel) const int32 value = 0; if (GetValue(&value, channel, 1) <= 0) return -1; - + return value; } int32 -BChannelControl::GetValue(int32 *outValues, int32 fromChannel, +BChannelControl::GetValue(int32* outValues, int32 fromChannel, int32 channelCount) const { int32 i = 0; @@ -419,23 +432,23 @@ BChannelControl::SetValueFor(int32 channel, int32 value) status_t BChannelControl::SetValue(int32 fromChannel, int32 channelCount, - const int32 *inValues) + const int32* values) { - return StuffValues(fromChannel, channelCount, inValues); + return StuffValues(fromChannel, channelCount, values); } status_t BChannelControl::SetAllValue(int32 values) { - int32 *newValues = new int32[fChannelCount]; + int32* newValues = new int32[fChannelCount]; for (int32 i = 0; i < fChannelCount; i++) { int32 limitedValue = max_c(values, MinLimitList()[i]); limitedValue = min_c(limitedValue, MaxLimitList()[i]); - + newValues[i] = limitedValue; } - + delete[] fChannelValues; fChannelValues = newValues; BControl::SetValue(fChannelValues[fCurrentChannel]); @@ -452,7 +465,8 @@ BChannelControl::SetLimitsFor(int32 channel, int32 minimum, int32 maximum) status_t -BChannelControl::GetLimitsFor(int32 channel, int32 *minimum, int32 *maximum) const +BChannelControl::GetLimitsFor(int32 channel, int32* minimum, + int32* maximum) const { return GetLimitsFor(channel, 1, minimum, maximum); } @@ -460,13 +474,15 @@ BChannelControl::GetLimitsFor(int32 channel, int32 *minimum, int32 *maximum) con status_t BChannelControl::SetLimitsFor(int32 fromChannel, int32 channelCount, - const int32 *minimum, const int32 *maximum) + const int32* minimum, const int32* maximum) { if (fromChannel + channelCount > CountChannels()) channelCount = CountChannels() - fromChannel; - for (int i=0; i maximum[i]) return B_BAD_VALUE; + fChannelMin[fromChannel + i] = minimum[i]; fChannelMax[fromChannel + i] = maximum[i]; if (fChannelValues[fromChannel + i] < minimum[i]) @@ -474,13 +490,14 @@ BChannelControl::SetLimitsFor(int32 fromChannel, int32 channelCount, else if (fChannelValues[fromChannel + i] > maximum[i]) fChannelValues[fromChannel + i] = maximum[i]; } + return B_OK; } status_t BChannelControl::GetLimitsFor(int32 fromChannel, int32 channelCount, - int32 *minimum, int32 *maximum) const + int32* minimum, int32* maximum) const { if (minimum == NULL || maximum == NULL) return B_BAD_VALUE; @@ -489,11 +506,12 @@ BChannelControl::GetLimitsFor(int32 fromChannel, int32 channelCount, return B_ERROR; if (fromChannel + channelCount > CountChannels()) channelCount = CountChannels() - fromChannel; - for (int i=0; i maximum) return B_BAD_VALUE; - + int32 numChannels = CountChannels(); for (int32 c = 0; c < numChannels; c++) { @@ -520,7 +538,7 @@ BChannelControl::SetLimits(int32 minimum, int32 maximum) status_t -BChannelControl::GetLimits(int32 *outMinimum, int32 *outMaximum) const +BChannelControl::GetLimits(int32* outMinimum, int32* outMaximum) const { if (outMinimum == NULL || outMaximum == NULL) return B_BAD_VALUE; @@ -539,11 +557,11 @@ BChannelControl::GetLimits(int32 *outMinimum, int32 *outMaximum) const status_t -BChannelControl::SetLimitLabels(const char *minLabel, const char *maxLabel) +BChannelControl::SetLimitLabels(const char* minLabel, const char* maxLabel) { if (minLabel != fMinLabel) fMinLabel = minLabel; - + if (maxLabel != fMaxLabel) fMaxLabel = maxLabel; @@ -553,14 +571,14 @@ BChannelControl::SetLimitLabels(const char *minLabel, const char *maxLabel) } -const char * +const char* BChannelControl::MinLimitLabel() const { return fMinLabel.String(); } -const char * +const char* BChannelControl::MaxLimitLabel() const { return fMaxLabel.String(); @@ -568,67 +586,73 @@ BChannelControl::MaxLimitLabel() const status_t -BChannelControl::SetLimitLabelsFor(int32 channel, const char *minLabel, const char *maxLabel) +BChannelControl::SetLimitLabelsFor(int32 channel, const char* minLabel, + const char* maxLabel) { return B_ERROR; } status_t -BChannelControl::SetLimitLabelsFor(int32 from_channel, int32 channel_count, const char *minLabel, const char *maxLabel) +BChannelControl::SetLimitLabelsFor(int32 fromChannel, int32 channelCount, + const char* minLabel, const char* maxLabel) { return B_ERROR; } -const char * +const char* BChannelControl::MinLimitLabelFor(int32 channel) const { return NULL; } -const char * +const char* BChannelControl::MaxLimitLabelFor(int32 channel) const { return NULL; } -status_t +status_t BChannelControl::StuffValues(int32 fromChannel, int32 channelCount, - const int32 *inValues) + const int32* values) { - if (inValues == NULL) + if (values == NULL) return B_BAD_VALUE; if (fromChannel < 0 || fromChannel > fChannelCount - || fromChannel + channelCount > fChannelCount) + || fromChannel + channelCount > fChannelCount) { return B_BAD_INDEX; - - for (int32 i = 0; i < channelCount; i++) { - if (inValues[i] <= fChannelMax[fromChannel + i] - && inValues[i] >= fChannelMin[fromChannel + i]) - fChannelValues[fromChannel + i] = inValues[i]; } - // If the current channel was updated, update also the control value - if (fCurrentChannel >= fromChannel && fCurrentChannel <= fromChannel + channelCount) + for (int32 i = 0; i < channelCount; i++) { + if (values[i] <= fChannelMax[fromChannel + i] + && values[i] >= fChannelMin[fromChannel + i]) { + fChannelValues[fromChannel + i] = values[i]; + } + } + + // if the current channel was updated, update also the control value + if (fCurrentChannel >= fromChannel + && fCurrentChannel <= fromChannel + channelCount) { BControl::SetValue(fChannelValues[fCurrentChannel]); + } return B_OK; } -void BChannelControl::_Reserverd_ChannelControl_0(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_1(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_2(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_3(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_4(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_5(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_6(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_7(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_8(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_9(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_10(void *, ...) {} -void BChannelControl::_Reserverd_ChannelControl_11(void *, ...) {} +void BChannelControl::_Reserverd_ChannelControl_0(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_1(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_2(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_3(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_4(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_5(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_6(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_7(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_8(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_9(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_10(void*, ...) {} +void BChannelControl::_Reserverd_ChannelControl_11(void*, ...) {} diff --git a/src/kits/interface/CheckBox.cpp b/src/kits/interface/CheckBox.cpp index a537852612..c8fb055160 100644 --- a/src/kits/interface/CheckBox.cpp +++ b/src/kits/interface/CheckBox.cpp @@ -161,9 +161,9 @@ BCheckBox::FrameMoved(BPoint newPosition) void -BCheckBox::FrameResized(float width, float height) +BCheckBox::FrameResized(float newWidth, float newHeight) { - BControl::FrameResized(width, height); + BControl::FrameResized(newWidth, newHeight); } diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index 245bb916fe..777413f8b5 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -56,19 +56,19 @@ BColorControl::BColorControl(BPoint leftTop, color_control_layout layout, } -BColorControl::BColorControl(BMessage* archive) +BColorControl::BColorControl(BMessage* data) : - BControl(archive) + BControl(data) { int32 layout; float cellSize; bool useOffscreen; - archive->FindInt32("_layout", &layout); - archive->FindFloat("_csize", &cellSize); - archive->FindBool("_use_off", &useOffscreen); + data->FindInt32("_layout", &layout); + data->FindFloat("_csize", &cellSize); + data->FindBool("_use_off", &useOffscreen); - _InitData((color_control_layout)layout, cellSize, useOffscreen, archive); + _InitData((color_control_layout)layout, cellSize, useOffscreen, data); } @@ -80,7 +80,7 @@ BColorControl::~BColorControl() void BColorControl::_InitData(color_control_layout layout, float size, - bool useOffscreen, BMessage* archive) + bool useOffscreen, BMessage* data) { fPaletteMode = BScreen(B_MAIN_SCREEN_ID).ColorSpace() == B_CMAP8; //TODO: we don't support workspace and colorspace changing for now @@ -102,13 +102,13 @@ BColorControl::_InitData(color_control_layout layout, float size, green = gSystemCatalog.GetString(green, "ColorControl"); blue = gSystemCatalog.GetString(blue, "ColorControl"); - if (archive != NULL) { + if (data != NULL) { fRedText = (BTextControl*)FindView("_red"); fGreenText = (BTextControl*)FindView("_green"); fBlueText = (BTextControl*)FindView("_blue"); int32 value = 0; - archive->FindInt32("_val", &value); + data->FindInt32("_val", &value); SetValue(value); } else { @@ -219,26 +219,28 @@ BColorControl::_LayoutView() BArchivable* -BColorControl::Instantiate(BMessage* archive) +BColorControl::Instantiate(BMessage* data) { - if (validate_instantiation(archive, "BColorControl")) - return new BColorControl(archive); + if (validate_instantiation(data, "BColorControl")) + return new BColorControl(data); return NULL; } status_t -BColorControl::Archive(BMessage* archive, bool deep) const +BColorControl::Archive(BMessage* data, bool deep) const { - status_t status = BControl::Archive(archive, deep); + status_t status = BControl::Archive(data, deep); if (status == B_OK) - status = archive->AddInt32("_layout", Layout()); + status = data->AddInt32("_layout", Layout()); + if (status == B_OK) - status = archive->AddFloat("_csize", fCellSize); + status = data->AddFloat("_csize", fCellSize); + if (status == B_OK) - status = archive->AddBool("_use_off", fOffscreenView != NULL); + status = data->AddBool("_use_off", fOffscreenView != NULL); return status; } @@ -985,16 +987,16 @@ BColorControl::Invoke(BMessage* message) void -BColorControl::FrameMoved(BPoint new_position) +BColorControl::FrameMoved(BPoint newPosition) { - BControl::FrameMoved(new_position); + BControl::FrameMoved(newPosition); } void -BColorControl::FrameResized(float new_width, float new_height) +BColorControl::FrameResized(float newWidth, float newHeight) { - BControl::FrameResized(new_width, new_height); + BControl::FrameResized(newWidth, newHeight); } diff --git a/src/kits/interface/Control.cpp b/src/kits/interface/Control.cpp index a5b9f23f1e..6cef099db5 100644 --- a/src/kits/interface/Control.cpp +++ b/src/kits/interface/Control.cpp @@ -258,14 +258,14 @@ BControl::MessageReceived(BMessage* message) void -BControl::MakeFocus(bool focused) +BControl::MakeFocus(bool focus) { - if (focused == IsFocus()) + if (focus == IsFocus()) return; - BView::MakeFocus(focused); + BView::MakeFocus(focus); - if (Window()) { + if (Window() != NULL) { fFocusChanging = true; Invalidate(Bounds()); Flush(); diff --git a/src/kits/interface/ListView.cpp b/src/kits/interface/ListView.cpp index a13e5feedc..c2bdbd2692 100644 --- a/src/kits/interface/ListView.cpp +++ b/src/kits/interface/ListView.cpp @@ -160,22 +160,22 @@ BListView::Instantiate(BMessage* archive) status_t -BListView::Archive(BMessage* archive, bool deep) const +BListView::Archive(BMessage* data, bool deep) const { - status_t status = BView::Archive(archive, deep); + status_t status = BView::Archive(data, deep); if (status < B_OK) return status; - status = archive->AddInt32("_lv_type", fListType); + status = data->AddInt32("_lv_type", fListType); if (status == B_OK && deep) { BListItem* item; int32 i = 0; - while ((item = ItemAt(i++))) { + while ((item = ItemAt(i++)) != NULL) { BMessage subData; status = item->Archive(&subData, true); if (status >= B_OK) - status = archive->AddMessage("_l_items", &subData); + status = data->AddMessage("_l_items", &subData); if (status < B_OK) break; @@ -183,10 +183,10 @@ BListView::Archive(BMessage* archive, bool deep) const } if (status >= B_OK && InvocationMessage() != NULL) - status = archive->AddMessage("_msg", InvocationMessage()); + status = data->AddMessage("_msg", InvocationMessage()); if (status == B_OK && fSelectMessage != NULL) - status = archive->AddMessage("_2nd_msg", fSelectMessage); + status = data->AddMessage("_2nd_msg", fSelectMessage); return status; } @@ -250,21 +250,21 @@ BListView::AllDetached() void -BListView::FrameResized(float width, float height) +BListView::FrameResized(float newWidth, float newHeight) { _FixupScrollBar(); } void -BListView::FrameMoved(BPoint new_position) +BListView::FrameMoved(BPoint newPosition) { - BView::FrameMoved(new_position); + BView::FrameMoved(newPosition); } void -BListView::TargetedByScrollView(BScrollView *view) +BListView::TargetedByScrollView(BScrollView* view) { fScrollView = view; // TODO: We could SetFlags(Flags() | B_FRAME_EVENTS) here, but that @@ -274,9 +274,9 @@ BListView::TargetedByScrollView(BScrollView *view) void -BListView::WindowActivated(bool state) +BListView::WindowActivated(bool active) { - BView::WindowActivated(state); + BView::WindowActivated(active); } @@ -1306,12 +1306,12 @@ BListView::ItemFrame(int32 index) BHandler* BListView::ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, const char* property) + BMessage* specifier, int32 what, const char* property) { BPropertyInfo propInfo(sProperties); - if (propInfo.FindMatch(message, 0, specifier, form, property) < 0) { - return BView::ResolveSpecifier(message, index, specifier, form, + if (propInfo.FindMatch(message, 0, specifier, what, property) < 0) { + return BView::ResolveSpecifier(message, index, specifier, what, property); } diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index 476fadca16..8f3e4ed0e0 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -531,9 +531,9 @@ BMenuField::MessageReceived(BMessage* message) void -BMenuField::WindowActivated(bool state) +BMenuField::WindowActivated(bool active) { - BView::WindowActivated(state); + BView::WindowActivated(active); if (IsFocus()) Invalidate(); @@ -548,9 +548,9 @@ BMenuField::MouseMoved(BPoint point, uint32 code, const BMessage* message) void -BMenuField::MouseUp(BPoint point) +BMenuField::MouseUp(BPoint where) { - BView::MouseUp(point); + BView::MouseUp(where); } diff --git a/src/kits/interface/OutlineListView.cpp b/src/kits/interface/OutlineListView.cpp index e232878694..e39614823e 100644 --- a/src/kits/interface/OutlineListView.cpp +++ b/src/kits/interface/OutlineListView.cpp @@ -505,10 +505,11 @@ BOutlineListView::IsExpanded(int32 fullListIndex) BHandler* -BOutlineListView::ResolveSpecifier(BMessage* msg, int32 index, +BOutlineListView::ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier, int32 what, const char* property) { - return BListView::ResolveSpecifier(msg, index, specifier, what, property); + return BListView::ResolveSpecifier(message, index, specifier, what, + property); } diff --git a/src/kits/interface/PictureButton.cpp b/src/kits/interface/PictureButton.cpp index 613b893722..060e20cf5b 100644 --- a/src/kits/interface/PictureButton.cpp +++ b/src/kits/interface/PictureButton.cpp @@ -175,16 +175,16 @@ BPictureButton::FrameResized(float newWidth, float newHeight) void -BPictureButton::WindowActivated(bool state) +BPictureButton::WindowActivated(bool active) { - BControl::WindowActivated(state); + BControl::WindowActivated(active); } void -BPictureButton::MakeFocus(bool state) +BPictureButton::MakeFocus(bool focus) { - BControl::MakeFocus(state); + BControl::MakeFocus(focus); } @@ -291,16 +291,16 @@ BPictureButton::MouseUp(BPoint where) void -BPictureButton::MouseMoved(BPoint where, uint32 transit, - const BMessage* message) +BPictureButton::MouseMoved(BPoint where, uint32 code, + const BMessage* dragMessage) { if (IsEnabled() && IsTracking()) { - if (transit == B_EXITED_VIEW) + if (code == B_EXITED_VIEW) SetValue(B_CONTROL_OFF); - else if (transit == B_ENTERED_VIEW) + else if (code == B_ENTERED_VIEW) SetValue(B_CONTROL_ON); } else - BControl::MouseMoved(where, transit, message); + BControl::MouseMoved(where, code, dragMessage); } @@ -397,9 +397,10 @@ BPictureButton::Invoke(BMessage* message) BHandler* BPictureButton::ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, const char* property) + BMessage* specifier, int32 what, const char* property) { - return BControl::ResolveSpecifier(message, index, specifier, form, property); + return BControl::ResolveSpecifier(message, index, specifier, + what, property); } diff --git a/src/kits/interface/RadioButton.cpp b/src/kits/interface/RadioButton.cpp index b593b5aed1..6893ea4935 100644 --- a/src/kits/interface/RadioButton.cpp +++ b/src/kits/interface/RadioButton.cpp @@ -351,10 +351,10 @@ BRadioButton::FrameMoved(BPoint newPosition) void -BRadioButton::FrameResized(float width, float height) +BRadioButton::FrameResized(float newWidth, float newHeight) { Invalidate(); - BControl::FrameResized(width, height); + BControl::FrameResized(newWidth, newHeight); } @@ -368,9 +368,9 @@ BRadioButton::ResolveSpecifier(BMessage* message, int32 index, void -BRadioButton::MakeFocus(bool focused) +BRadioButton::MakeFocus(bool focus) { - BControl::MakeFocus(focused); + BControl::MakeFocus(focus); } diff --git a/src/kits/interface/Region.cpp b/src/kits/interface/Region.cpp index fd59aeeaea..678d34bc6c 100644 --- a/src/kits/interface/Region.cpp +++ b/src/kits/interface/Region.cpp @@ -117,24 +117,24 @@ BRegion::operator==(const BRegion& other) const // Set the region to contain just the given BRect. void -BRegion::Set(BRect newBounds) +BRegion::Set(BRect rect) { - Set(_Convert(newBounds)); + Set(_Convert(rect)); } //Set the region to contain just the given clipping_rect. void -BRegion::Set(clipping_rect newBounds) +BRegion::Set(clipping_rect clipping) { _SetSize(1); - if (valid_rect(newBounds) && fData) { + if (valid_rect(clipping) && fData != NULL) { fCount = 1; // cheap convert to internal rect format - newBounds.right++; - newBounds.bottom++; - fData[0] = fBounds = newBounds; + clipping.right++; + clipping.bottom++; + fData[0] = fBounds = clipping; } else MakeEmpty(); } @@ -425,7 +425,12 @@ BRegion::ExclusiveInclude(const BRegion* region) // #pragma mark - BRegion private methods -// Takes over the data of a region and marks that region empty. +/*! + \fn void BRegion::_AdoptRegionData(BRegion& region) + \brief Takes over the data of \a region and empties it. + + \param region The \a region to adopt data from. +*/ void BRegion::_AdoptRegionData(BRegion& region) { @@ -447,7 +452,13 @@ BRegion::_AdoptRegionData(BRegion& region) } -// Reallocate the memory in the region. +/*! + \fn bool BRegion::_SetSize(int32 newSize) + \brief Reallocate the memory in the region. + + \param newSize The amount of rectangles that the region should be + able to hold. +*/ bool BRegion::_SetSize(int32 newSize) { diff --git a/src/kits/interface/ScrollBar.cpp b/src/kits/interface/ScrollBar.cpp index eb2d9aa318..8049b990c2 100644 --- a/src/kits/interface/ScrollBar.cpp +++ b/src/kits/interface/ScrollBar.cpp @@ -316,510 +316,55 @@ BScrollBar::Archive(BMessage* data, bool deep) const status_t err = BView::Archive(data, deep); if (err != B_OK) return err; + err = data->AddFloat("_range", fMin); if (err != B_OK) return err; + err = data->AddFloat("_range", fMax); if (err != B_OK) return err; + err = data->AddFloat("_steps", fSmallStep); if (err != B_OK) return err; + err = data->AddFloat("_steps", fLargeStep); if (err != B_OK) return err; + err = data->AddFloat("_val", fValue); if (err != B_OK) return err; + err = data->AddInt32("_orient", (int32)fOrientation); if (err != B_OK) return err; + err = data->AddFloat("_prop", fProportion); return err; } -// #pragma mark - +void +BScrollBar::AllAttached() +{ + BView::AllAttached(); +} + + +void +BScrollBar::AllDetached() +{ + BView::AllDetached(); +} void BScrollBar::AttachedToWindow() { -} - -/* - From the BeBook (on ValueChanged()): - -Responds to a notification that the value of the scroll bar has changed to -newValue. For a horizontal scroll bar, this function interprets newValue -as the coordinate value that should be at the left side of the target -view's bounds rectangle. For a vertical scroll bar, it interprets -newValue as the coordinate value that should be at the top of the rectangle. -It calls ScrollTo() to scroll the target's contents into position, unless -they have already been scrolled. - -ValueChanged() is called as the result both of user actions -(B_VALUE_CHANGED messages received from the Application Server) and of -programmatic ones. Programmatically, scrolling can be initiated by the -target view (calling ScrollTo()) or by the BScrollBar -(calling SetValue() or SetRange()). - -In all these cases, the target view and the scroll bars need to be kept -in synch. This is done by a chain of function calls: ValueChanged() calls -ScrollTo(), which in turn calls SetValue(), which then calls -ValueChanged() again. It's up to ValueChanged() to get off this -merry-go-round, which it does by checking the target view's bounds -rectangle. If newValue already matches the left or top side of the -bounds rectangle, if forgoes calling ScrollTo(). - -ValueChanged() does nothing if a target BView hasn't been set—or -if the target has been set by name, but the name doesn't correspond to -an actual BView within the scroll bar's window. - -*/ - - -void -BScrollBar::SetValue(float value) -{ - if (value > fMax) - value = fMax; - else if (value < fMin) - value = fMin; - else if (isnan(value)) - return; - - value = roundf(value); - if (value == fValue) - return; - - TRACE("BScrollBar(%s)::SetValue(%.1f)\n", Name(), value); - - fValue = value; - - _UpdateThumbFrame(); - _UpdateArrowButtons(); - - ValueChanged(fValue); -} - - -float -BScrollBar::Value() const -{ - return fValue; -} - - -void -BScrollBar::ValueChanged(float newValue) -{ - TRACE("BScrollBar(%s)::ValueChanged(%.1f)\n", Name(), newValue); - - if (fTarget != NULL) { - // cache target bounds - BRect targetBounds = fTarget->Bounds(); - // if vertical, check bounds top and scroll if different from newValue - if (fOrientation == B_VERTICAL && targetBounds.top != newValue) - fTarget->ScrollBy(0.0, newValue - targetBounds.top); - - // if horizontal, check bounds left and scroll if different from newValue - if (fOrientation == B_HORIZONTAL && targetBounds.left != newValue) - fTarget->ScrollBy(newValue - targetBounds.left, 0.0); - } - - TRACE(" -> %.1f\n", newValue); - - SetValue(newValue); -} - - -void -BScrollBar::SetProportion(float value) -{ - if (value < 0.0f) - value = 0.0f; - else if (value > 1.0f) - value = 1.0f; - - if (value == fProportion) - return; - - TRACE("BScrollBar(%s)::SetProportion(%.1f)\n", Name(), value); - - bool oldEnabled = fPrivateData->fEnabled && fMin < fMax - && fProportion < 1.0f && fProportion >= 0.0f; - - fProportion = value; - - bool newEnabled = fPrivateData->fEnabled && fMin < fMax - && fProportion < 1.0f && fProportion >= 0.0f; - - _UpdateThumbFrame(); - - if (oldEnabled != newEnabled) - Invalidate(); -} - - -float -BScrollBar::Proportion() const -{ - return fProportion; -} - - -void -BScrollBar::SetRange(float min, float max) -{ - if (min > max || isnanf(min) || isnanf(max) - || isinff(min) || isinff(max)) { - min = 0.0f; - max = 0.0f; - } - - min = roundf(min); - max = roundf(max); - - if (fMin == min && fMax == max) - return; - TRACE("BScrollBar(%s)::SetRange(min=%.1f, max=%.1f)\n", Name(), min, max); - - fMin = min; - fMax = max; - - if (fValue < fMin || fValue > fMax) - SetValue(fValue); - else { - _UpdateThumbFrame(); - Invalidate(); - } -} - - -void -BScrollBar::GetRange(float* min, float* max) const -{ - if (min != NULL) - *min = fMin; - if (max != NULL) - *max = fMax; -} - - -void -BScrollBar::SetSteps(float smallStep, float largeStep) -{ - // Under R5, steps can be set only after being attached to a window, - // probably because the data is kept server-side. We'll just remove - // that limitation... :P - - // The BeBook also says that we need to specify an integer value even - // though the step values are floats. For the moment, we'll just make - // sure that they are integers - smallStep = roundf(smallStep); - largeStep = roundf(largeStep); - if (fSmallStep == smallStep && fLargeStep == largeStep) - return; - - TRACE("BScrollBar(%s)::SetSteps(small=%.1f, large=%.1f)\n", Name(), - smallStep, largeStep); - - fSmallStep = smallStep; - fLargeStep = largeStep; - - if (fProportion == 0.0) { - // special case, proportion is based on fLargeStep if it was never - // set, so it means we need to invalidate here - _UpdateThumbFrame(); - Invalidate(); - } - - // TODO: test use of fractional values and make them work properly if - // they don't -} - - -void -BScrollBar::GetSteps(float* smallStep, float* largeStep) const -{ - if (smallStep != NULL) - *smallStep = fSmallStep; - - if (largeStep != NULL) - *largeStep = fLargeStep; -} - - -void -BScrollBar::SetTarget(BView* target) -{ - if (fTarget) { - // unset the previous target's scrollbar pointer - if (fOrientation == B_VERTICAL) - fTarget->fVerScroller = NULL; - else - fTarget->fHorScroller = NULL; - } - - fTarget = target; - if (fTarget) { - if (fOrientation == B_VERTICAL) - fTarget->fVerScroller = this; - else - fTarget->fHorScroller = this; - } -} - - -void -BScrollBar::SetTarget(const char* targetName) -{ - // NOTE 1: BeOS implementation crashes for targetName == NULL - // NOTE 2: BeOS implementation also does not modify the target - // if it can't be found - if (!targetName) - return; - - if (!Window()) - debugger("Method requires window and doesn't have one"); - - BView* target = Window()->FindView(targetName); - if (target) - SetTarget(target); -} - - -BView* -BScrollBar::Target() const -{ - return fTarget; -} - - -void -BScrollBar::SetOrientation(orientation orientation) -{ - if (fOrientation == orientation) - return; - - fOrientation = orientation; - InvalidateLayout(); - Invalidate(); -} - - -orientation -BScrollBar::Orientation() const -{ - return fOrientation; -} - - -status_t -BScrollBar::SetBorderHighlighted(bool state) -{ - if (fPrivateData->fBorderHighlighted == state) - return B_OK; - - fPrivateData->fBorderHighlighted = state; - - BRect dirty(Bounds()); - if (fOrientation == B_HORIZONTAL) - dirty.bottom = dirty.top; - else - dirty.right = dirty.left; - - Invalidate(dirty); - - return B_OK; -} - - -void -BScrollBar::MessageReceived(BMessage* message) -{ - switch(message->what) { - case B_VALUE_CHANGED: - { - int32 value; - if (message->FindInt32("value", &value) == B_OK) - ValueChanged(value); - - break; - } - - case B_MOUSE_WHEEL_CHANGED: - { - // Must handle this here since BView checks for the existence of - // scrollbars, which a scrollbar itself does not have - float deltaX = 0.0f; - float deltaY = 0.0f; - message->FindFloat("be:wheel_delta_x", &deltaX); - message->FindFloat("be:wheel_delta_y", &deltaY); - - if (deltaX == 0.0f && deltaY == 0.0f) - break; - - if (deltaX != 0.0f && deltaY == 0.0f) - deltaY = deltaX; - - ScrollWithMouseWheelDelta(this, deltaY); - } - - default: - BView::MessageReceived(message); - } -} - - -void -BScrollBar::MouseDown(BPoint where) -{ - if (!fPrivateData->fEnabled || fMin == fMax) - return; - - SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); - - int32 buttons; - if (Looper() == NULL || Looper()->CurrentMessage() == NULL - || Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK) { - buttons = B_PRIMARY_MOUSE_BUTTON; - } - - if (buttons & B_SECONDARY_MOUSE_BUTTON) { - // special absolute scrolling: move thumb to where we clicked - fPrivateData->fButtonDown = THUMB; - fPrivateData->fClickOffset = fPrivateData->fThumbFrame.LeftTop() - where; - if (Orientation() == B_HORIZONTAL) - fPrivateData->fClickOffset.x = -fPrivateData->fThumbFrame.Width() / 2; - else - fPrivateData->fClickOffset.y = -fPrivateData->fThumbFrame.Height() / 2; - - SetValue(_ValueFor(where + fPrivateData->fClickOffset)); - return; - } - - // hit test for the thumb - if (fPrivateData->fThumbFrame.Contains(where)) { - fPrivateData->fButtonDown = THUMB; - fPrivateData->fClickOffset = fPrivateData->fThumbFrame.LeftTop() - where; - Invalidate(fPrivateData->fThumbFrame); - return; - } - - // hit test for arrows or empty area - float scrollValue = 0.0; - - // pressing the shift key scrolls faster - float buttonStepSize - = (modifiers() & B_SHIFT_KEY) != 0 ? fLargeStep : fSmallStep; - - fPrivateData->fButtonDown = _ButtonFor(where); - switch (fPrivateData->fButtonDown) { - case ARROW1: - scrollValue = -buttonStepSize; - break; - - case ARROW2: - scrollValue = buttonStepSize; - break; - - case ARROW3: - scrollValue = -buttonStepSize; - break; - - case ARROW4: - scrollValue = buttonStepSize; - break; - - case NOARROW: - // we hit the empty area, figure out which side of the thumb - if (fOrientation == B_VERTICAL) { - if (where.y < fPrivateData->fThumbFrame.top) - scrollValue = -fLargeStep; - else - scrollValue = fLargeStep; - } else { - if (where.x < fPrivateData->fThumbFrame.left) - scrollValue = -fLargeStep; - else - scrollValue = fLargeStep; - } - _UpdateTargetValue(where); - break; - } - if (scrollValue != 0.0) { - SetValue(fValue + scrollValue); - Invalidate(_ButtonRectFor(fPrivateData->fButtonDown)); - - // launch the repeat thread - if (fPrivateData->fRepeaterThread == -1) { - fPrivateData->fExitRepeater = false; - fPrivateData->fRepeaterDelay = system_time() + kRepeatDelay; - fPrivateData->fThumbInc = scrollValue; - fPrivateData->fDoRepeat = true; - fPrivateData->fRepeaterThread - = spawn_thread(fPrivateData->button_repeater_thread, - "scroll repeater", B_NORMAL_PRIORITY, fPrivateData); - resume_thread(fPrivateData->fRepeaterThread); - } else { - fPrivateData->fExitRepeater = false; - fPrivateData->fRepeaterDelay = system_time() + kRepeatDelay; - fPrivateData->fDoRepeat = true; - } - } -} - - -void -BScrollBar::MouseUp(BPoint pt) -{ - if (fPrivateData->fButtonDown == THUMB) - Invalidate(fPrivateData->fThumbFrame); - else - Invalidate(_ButtonRectFor(fPrivateData->fButtonDown)); - - fPrivateData->fButtonDown = NOARROW; - fPrivateData->fExitRepeater = true; - fPrivateData->fDoRepeat = false; -} - - -void -BScrollBar::MouseMoved(BPoint where, uint32 transit, const BMessage* message) -{ - if (!fPrivateData->fEnabled || fMin >= fMax || fProportion >= 1.0f - || fProportion < 0.0f) { - return; - } - - if (fPrivateData->fButtonDown != NOARROW) { - if (fPrivateData->fButtonDown == THUMB) { - SetValue(_ValueFor(where + fPrivateData->fClickOffset)); - } else { - // suspend the repeating if the mouse is not over the button - bool repeat = _ButtonRectFor(fPrivateData->fButtonDown).Contains( - where); - if (fPrivateData->fDoRepeat != repeat) { - fPrivateData->fDoRepeat = repeat; - Invalidate(_ButtonRectFor(fPrivateData->fButtonDown)); - } - } - } else { - // update the value at which we want to stop repeating - if (fPrivateData->fDoRepeat) { - _UpdateTargetValue(where); - // we might have to turn arround - if ((fValue < fPrivateData->fStopValue - && fPrivateData->fThumbInc < 0) - || (fValue > fPrivateData->fStopValue - && fPrivateData->fThumbInc > 0)) { - fPrivateData->fThumbInc = -fPrivateData->fThumbInc; - } - } - } + BView::AttachedToWindow(); } @@ -837,7 +382,7 @@ BScrollBar::Draw(BRect updateRect) rgb_color normal = ui_color(B_PANEL_BACKGROUND_COLOR); - // stroke a dark frame arround the entire scrollbar + // stroke a dark frame around the entire scrollbar // (independent of enabled state) // take care of border highlighting (scroll target is focus view) SetHighColor(tint_color(normal, B_DARKEN_2_TINT)); @@ -1049,18 +594,458 @@ BScrollBar::FrameResized(float newWidth, float newHeight) } -BHandler* -BScrollBar::ResolveSpecifier(BMessage* message, int32 index, - BMessage* specifier, int32 form, const char* property) +void +BScrollBar::MessageReceived(BMessage* message) { - return BView::ResolveSpecifier(message, index, specifier, form, property); + switch(message->what) { + case B_VALUE_CHANGED: + { + int32 value; + if (message->FindInt32("value", &value) == B_OK) + ValueChanged(value); + + break; + } + + case B_MOUSE_WHEEL_CHANGED: + { + // Must handle this here since BView checks for the existence of + // scrollbars, which a scrollbar itself does not have + float deltaX = 0.0f; + float deltaY = 0.0f; + message->FindFloat("be:wheel_delta_x", &deltaX); + message->FindFloat("be:wheel_delta_y", &deltaY); + + if (deltaX == 0.0f && deltaY == 0.0f) + break; + + if (deltaX != 0.0f && deltaY == 0.0f) + deltaY = deltaX; + + ScrollWithMouseWheelDelta(this, deltaY); + } + + default: + BView::MessageReceived(message); + } } void -BScrollBar::ResizeToPreferred() +BScrollBar::MouseDown(BPoint where) { - BView::ResizeToPreferred(); + if (!fPrivateData->fEnabled || fMin == fMax) + return; + + SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); + + int32 buttons; + if (Looper() == NULL || Looper()->CurrentMessage() == NULL + || Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK) { + buttons = B_PRIMARY_MOUSE_BUTTON; + } + + if (buttons & B_SECONDARY_MOUSE_BUTTON) { + // special absolute scrolling: move thumb to where we clicked + fPrivateData->fButtonDown = THUMB; + fPrivateData->fClickOffset = fPrivateData->fThumbFrame.LeftTop() - where; + if (Orientation() == B_HORIZONTAL) + fPrivateData->fClickOffset.x = -fPrivateData->fThumbFrame.Width() / 2; + else + fPrivateData->fClickOffset.y = -fPrivateData->fThumbFrame.Height() / 2; + + SetValue(_ValueFor(where + fPrivateData->fClickOffset)); + return; + } + + // hit test for the thumb + if (fPrivateData->fThumbFrame.Contains(where)) { + fPrivateData->fButtonDown = THUMB; + fPrivateData->fClickOffset = fPrivateData->fThumbFrame.LeftTop() - where; + Invalidate(fPrivateData->fThumbFrame); + return; + } + + // hit test for arrows or empty area + float scrollValue = 0.0; + + // pressing the shift key scrolls faster + float buttonStepSize + = (modifiers() & B_SHIFT_KEY) != 0 ? fLargeStep : fSmallStep; + + fPrivateData->fButtonDown = _ButtonFor(where); + switch (fPrivateData->fButtonDown) { + case ARROW1: + scrollValue = -buttonStepSize; + break; + + case ARROW2: + scrollValue = buttonStepSize; + break; + + case ARROW3: + scrollValue = -buttonStepSize; + break; + + case ARROW4: + scrollValue = buttonStepSize; + break; + + case NOARROW: + // we hit the empty area, figure out which side of the thumb + if (fOrientation == B_VERTICAL) { + if (where.y < fPrivateData->fThumbFrame.top) + scrollValue = -fLargeStep; + else + scrollValue = fLargeStep; + } else { + if (where.x < fPrivateData->fThumbFrame.left) + scrollValue = -fLargeStep; + else + scrollValue = fLargeStep; + } + _UpdateTargetValue(where); + break; + } + if (scrollValue != 0.0) { + SetValue(fValue + scrollValue); + Invalidate(_ButtonRectFor(fPrivateData->fButtonDown)); + + // launch the repeat thread + if (fPrivateData->fRepeaterThread == -1) { + fPrivateData->fExitRepeater = false; + fPrivateData->fRepeaterDelay = system_time() + kRepeatDelay; + fPrivateData->fThumbInc = scrollValue; + fPrivateData->fDoRepeat = true; + fPrivateData->fRepeaterThread = spawn_thread( + fPrivateData->button_repeater_thread, "scroll repeater", + B_NORMAL_PRIORITY, fPrivateData); + resume_thread(fPrivateData->fRepeaterThread); + } else { + fPrivateData->fExitRepeater = false; + fPrivateData->fRepeaterDelay = system_time() + kRepeatDelay; + fPrivateData->fDoRepeat = true; + } + } +} + + +void +BScrollBar::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) +{ + if (!fPrivateData->fEnabled || fMin >= fMax || fProportion >= 1.0f + || fProportion < 0.0f) { + return; + } + + if (fPrivateData->fButtonDown != NOARROW) { + if (fPrivateData->fButtonDown == THUMB) { + SetValue(_ValueFor(where + fPrivateData->fClickOffset)); + } else { + // suspend the repeating if the mouse is not over the button + bool repeat = _ButtonRectFor(fPrivateData->fButtonDown).Contains( + where); + if (fPrivateData->fDoRepeat != repeat) { + fPrivateData->fDoRepeat = repeat; + Invalidate(_ButtonRectFor(fPrivateData->fButtonDown)); + } + } + } else { + // update the value at which we want to stop repeating + if (fPrivateData->fDoRepeat) { + _UpdateTargetValue(where); + // we might have to turn arround + if ((fValue < fPrivateData->fStopValue + && fPrivateData->fThumbInc < 0) + || (fValue > fPrivateData->fStopValue + && fPrivateData->fThumbInc > 0)) { + fPrivateData->fThumbInc = -fPrivateData->fThumbInc; + } + } + } +} + + +void +BScrollBar::MouseUp(BPoint where) +{ + if (fPrivateData->fButtonDown == THUMB) + Invalidate(fPrivateData->fThumbFrame); + else + Invalidate(_ButtonRectFor(fPrivateData->fButtonDown)); + + fPrivateData->fButtonDown = NOARROW; + fPrivateData->fExitRepeater = true; + fPrivateData->fDoRepeat = false; +} + + +#if DISABLES_ON_WINDOW_DEACTIVATION +void +BScrollBar::WindowActivated(bool active) +{ + fPrivateData->fEnabled = active; + Invalidate(); +} +#endif // DISABLES_ON_WINDOW_DEACTIVATION + + +void +BScrollBar::SetValue(float value) +{ + if (value > fMax) + value = fMax; + else if (value < fMin) + value = fMin; + else if (isnan(value) || isinf(value)) + return; + + value = roundf(value); + if (value == fValue) + return; + + TRACE("BScrollBar(%s)::SetValue(%.1f)\n", Name(), value); + + fValue = value; + + _UpdateThumbFrame(); + _UpdateArrowButtons(); + + ValueChanged(fValue); +} + + +float +BScrollBar::Value() const +{ + return fValue; +} + + +void +BScrollBar::ValueChanged(float newValue) +{ + TRACE("BScrollBar(%s)::ValueChanged(%.1f)\n", Name(), newValue); + + if (fTarget != NULL) { + // cache target bounds + BRect targetBounds = fTarget->Bounds(); + // if vertical, check bounds top and scroll if different from newValue + if (fOrientation == B_VERTICAL && targetBounds.top != newValue) + fTarget->ScrollBy(0.0, newValue - targetBounds.top); + + // if horizontal, check bounds left and scroll if different from newValue + if (fOrientation == B_HORIZONTAL && targetBounds.left != newValue) + fTarget->ScrollBy(newValue - targetBounds.left, 0.0); + } + + TRACE(" -> %.1f\n", newValue); + + SetValue(newValue); +} + + +void +BScrollBar::SetProportion(float value) +{ + if (value < 0.0f) + value = 0.0f; + else if (value > 1.0f) + value = 1.0f; + + if (value == fProportion) + return; + + TRACE("BScrollBar(%s)::SetProportion(%.1f)\n", Name(), value); + + bool oldEnabled = fPrivateData->fEnabled && fMin < fMax + && fProportion < 1.0f && fProportion >= 0.0f; + + fProportion = value; + + bool newEnabled = fPrivateData->fEnabled && fMin < fMax + && fProportion < 1.0f && fProportion >= 0.0f; + + _UpdateThumbFrame(); + + if (oldEnabled != newEnabled) + Invalidate(); +} + + +float +BScrollBar::Proportion() const +{ + return fProportion; +} + + +void +BScrollBar::SetRange(float min, float max) +{ + if (min > max || isnanf(min) || isnanf(max) + || isinff(min) || isinff(max)) { + min = 0.0f; + max = 0.0f; + } + + min = roundf(min); + max = roundf(max); + + if (fMin == min && fMax == max) + return; + + TRACE("BScrollBar(%s)::SetRange(min=%.1f, max=%.1f)\n", Name(), min, max); + + fMin = min; + fMax = max; + + if (fValue < fMin || fValue > fMax) + SetValue(fValue); + else { + _UpdateThumbFrame(); + Invalidate(); + } +} + + +void +BScrollBar::GetRange(float* min, float* max) const +{ + if (min != NULL) + *min = fMin; + + if (max != NULL) + *max = fMax; +} + + +void +BScrollBar::SetSteps(float smallStep, float largeStep) +{ + // Under R5, steps can be set only after being attached to a window, + // probably because the data is kept server-side. We'll just remove + // that limitation... :P + + // The BeBook also says that we need to specify an integer value even + // though the step values are floats. For the moment, we'll just make + // sure that they are integers + smallStep = roundf(smallStep); + largeStep = roundf(largeStep); + if (fSmallStep == smallStep && fLargeStep == largeStep) + return; + + TRACE("BScrollBar(%s)::SetSteps(small=%.1f, large=%.1f)\n", Name(), + smallStep, largeStep); + + fSmallStep = smallStep; + fLargeStep = largeStep; + + if (fProportion == 0.0) { + // special case, proportion is based on fLargeStep if it was never + // set, so it means we need to invalidate here + _UpdateThumbFrame(); + Invalidate(); + } + + // TODO: test use of fractional values and make them work properly if + // they don't +} + + +void +BScrollBar::GetSteps(float* smallStep, float* largeStep) const +{ + if (smallStep != NULL) + *smallStep = fSmallStep; + + if (largeStep != NULL) + *largeStep = fLargeStep; +} + + +void +BScrollBar::SetTarget(BView* target) +{ + if (fTarget) { + // unset the previous target's scrollbar pointer + if (fOrientation == B_VERTICAL) + fTarget->fVerScroller = NULL; + else + fTarget->fHorScroller = NULL; + } + + fTarget = target; + if (fTarget) { + if (fOrientation == B_VERTICAL) + fTarget->fVerScroller = this; + else + fTarget->fHorScroller = this; + } +} + + +void +BScrollBar::SetTarget(const char* targetName) +{ + // NOTE 1: BeOS implementation crashes for targetName == NULL + // NOTE 2: BeOS implementation also does not modify the target + // if it can't be found + if (targetName == NULL) + return; + + if (Window() == NULL) + debugger("Method requires window and doesn't have one"); + + BView* target = Window()->FindView(targetName); + if (target != NULL) + SetTarget(target); +} + + +BView* +BScrollBar::Target() const +{ + return fTarget; +} + + +void +BScrollBar::SetOrientation(orientation direction) +{ + if (fOrientation == direction) + return; + + fOrientation = direction; + InvalidateLayout(); + Invalidate(); +} + + +orientation +BScrollBar::Orientation() const +{ + return fOrientation; +} + + +status_t +BScrollBar::SetBorderHighlighted(bool highlight) +{ + if (fPrivateData->fBorderHighlighted == highlight) + return B_OK; + + fPrivateData->fBorderHighlighted = highlight; + + BRect dirty(Bounds()); + if (fOrientation == B_HORIZONTAL) + dirty.bottom = dirty.top; + else + dirty.right = dirty.left; + + Invalidate(dirty); + + return B_OK; } @@ -1084,30 +1069,17 @@ BScrollBar::GetPreferredSize(float* _width, float* _height) void -BScrollBar::MakeFocus(bool state) +BScrollBar::ResizeToPreferred() { - BView::MakeFocus(state); + BView::ResizeToPreferred(); } + void -BScrollBar::AllAttached() +BScrollBar::MakeFocus(bool focus) { - BView::AllAttached(); -} - - -void -BScrollBar::AllDetached() -{ - BView::AllDetached(); -} - - -status_t -BScrollBar::GetSupportedSuites(BMessage* message) -{ - return BView::GetSupportedSuites(message); + BView::MakeFocus(focus); } @@ -1143,6 +1115,21 @@ BScrollBar::PreferredSize() } +status_t +BScrollBar::GetSupportedSuites(BMessage* message) +{ + return BView::GetSupportedSuites(message); +} + + +BHandler* +BScrollBar::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) +{ + return BView::ResolveSpecifier(message, index, specifier, what, property); +} + + status_t BScrollBar::Perform(perform_code code, void* _data) { @@ -1216,16 +1203,6 @@ BScrollBar::Perform(perform_code code, void* _data) } -#if DISABLES_ON_WINDOW_DEACTIVATION -void -BScrollBar::WindowActivated(bool active) -{ - fPrivateData->fEnabled = active; - Invalidate(); -} -#endif // DISABLES_ON_WINDOW_DEACTIVATION - - void BScrollBar::_ReservedScrollBar1() {} void BScrollBar::_ReservedScrollBar2() {} void BScrollBar::_ReservedScrollBar3() {} diff --git a/src/kits/interface/ScrollView.cpp b/src/kits/interface/ScrollView.cpp index ff26129208..6725b87f70 100644 --- a/src/kits/interface/ScrollView.cpp +++ b/src/kits/interface/ScrollView.cpp @@ -1,6 +1,13 @@ /* * Copyright 2004-2009, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2009 Stephan Aßmus, superstippi@gmx.de. + * Copyright 2014 Haiku, Inc. All rights reserved. * Distributed under the terms of the MIT License. + * + * Authors: + * Stephan Aßmus, superstippi@gmx.de + * Axel Dörfler, axeld@pinc-software.de + * John Scipione, jscpione@gmail.com */ @@ -14,13 +21,15 @@ #include + static const float kFancyBorderSize = 2; static const float kPlainBorderSize = 1; -BScrollView::BScrollView(const char *name, BView *target, uint32 resizingMode, - uint32 flags, bool horizontal, bool vertical, border_style border) - : BView(_ComputeFrame(target, horizontal, vertical, border), name, +BScrollView::BScrollView(const char* name, BView* target, uint32 resizingMode, + uint32 flags, bool horizontal, bool vertical, border_style border) + : + BView(_ComputeFrame(target, horizontal, vertical, border), name, resizingMode, _ModifyFlags(flags, border)), fTarget(target), fBorder(border) @@ -30,8 +39,9 @@ BScrollView::BScrollView(const char *name, BView *target, uint32 resizingMode, BScrollView::BScrollView(const char* name, BView* target, uint32 flags, - bool horizontal, bool vertical, border_style border) - : BView(name, _ModifyFlags(flags, border)), + bool horizontal, bool vertical, border_style border) + : + BView(name, _ModifyFlags(flags, border)), fTarget(target), fBorder(border) { @@ -39,15 +49,16 @@ BScrollView::BScrollView(const char* name, BView* target, uint32 flags, } -BScrollView::BScrollView(BMessage *archive) - : BView(archive), +BScrollView::BScrollView(BMessage* archive) + : + BView(archive), fHighlighted(false) { int32 border; fBorder = archive->FindInt32("_style", &border) == B_OK ? (border_style)border : B_FANCY_BORDER; - // In a shallow archive, we may not have a target anymore. We must + // in a shallow archive, we may not have a target anymore. We must // be prepared for this case // don't confuse our scroll bars with our (eventual) target @@ -63,7 +74,7 @@ BScrollView::BScrollView(BMessage *archive) fHorizontalScrollBar = NULL; fVerticalScrollBar = NULL; - BView *view; + BView* view; while ((view = ChildAt(firstBar++)) != NULL) { BScrollBar *bar = dynamic_cast(view); if (bar == NULL) @@ -85,7 +96,7 @@ BScrollView::~BScrollView() } -// #pragma mark - +// #pragma mark - Archiving BArchivable* @@ -121,6 +132,9 @@ BScrollView::Archive(BMessage* archive, bool deep) const } +// #pragma mark - Hook methods + + void BScrollView::AttachedToWindow() { @@ -128,8 +142,9 @@ BScrollView::AttachedToWindow() if ((fHorizontalScrollBar == NULL && fVerticalScrollBar == NULL) || (fHorizontalScrollBar != NULL && fVerticalScrollBar != NULL) - || Window()->Look() != B_DOCUMENT_WINDOW_LOOK) + || Window()->Look() != B_DOCUMENT_WINDOW_LOOK) { return; + } // If we have only one bar, we need to check if we are in the // bottom right edge of a window with the B_DOCUMENT_LOOK to @@ -139,8 +154,9 @@ BScrollView::AttachedToWindow() BRect windowBounds = Window()->Frame(); if (bounds.right - _BorderSize() != windowBounds.right - || bounds.bottom - _BorderSize() != windowBounds.bottom) + || bounds.bottom - _BorderSize() != windowBounds.bottom) { return; + } if (fHorizontalScrollBar) fHorizontalScrollBar->ResizeBy(-B_V_SCROLL_BAR_WIDTH, 0); @@ -173,60 +189,118 @@ BScrollView::AllDetached() void BScrollView::Draw(BRect updateRect) { - if (be_control_look != NULL) { - uint32 flags = 0; - if (fHighlighted && Window()->IsActive()) - flags |= BControlLook::B_FOCUSED; - BRect rect(Bounds()); - rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + uint32 flags = 0; + if (fHighlighted && Window()->IsActive()) + flags |= BControlLook::B_FOCUSED; - BRect verticalScrollBarFrame(0, 0, -1, -1); - if (fVerticalScrollBar) - verticalScrollBarFrame = fVerticalScrollBar->Frame(); - BRect horizontalScrollBarFrame(0, 0, -1, -1); - if (fHorizontalScrollBar) - horizontalScrollBarFrame = fHorizontalScrollBar->Frame(); + BRect rect(Bounds()); + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); - be_control_look->DrawScrollViewFrame(this, rect, updateRect, - verticalScrollBarFrame, horizontalScrollBarFrame, base, fBorder, - flags); + BRect verticalScrollBarFrame(0, 0, -1, -1); + if (fVerticalScrollBar) + verticalScrollBarFrame = fVerticalScrollBar->Frame(); - return; - } + BRect horizontalScrollBarFrame(0, 0, -1, -1); + if (fHorizontalScrollBar) + horizontalScrollBarFrame = fHorizontalScrollBar->Frame(); - if (fBorder == B_PLAIN_BORDER) { - SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DARKEN_2_TINT)); - StrokeRect(Bounds()); - return; - } else if (fBorder != B_FANCY_BORDER) - return; - - BRect bounds = Bounds(); - SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DARKEN_2_TINT)); - StrokeRect(bounds.InsetByCopy(1, 1)); - - if (fHighlighted && Window()->IsActive()) { - SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR)); - StrokeRect(bounds); - } else { - SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), - B_DARKEN_1_TINT)); - StrokeLine(bounds.LeftBottom(), bounds.LeftTop()); - bounds.left++; - StrokeLine(bounds.LeftTop(), bounds.RightTop()); - - SetHighColor(ui_color(B_SHINE_COLOR)); - StrokeLine(bounds.LeftBottom(), bounds.RightBottom()); - bounds.top++; - bounds.bottom--; - StrokeLine(bounds.RightBottom(), bounds.RightTop()); - } + be_control_look->DrawScrollViewFrame(this, rect, updateRect, + verticalScrollBarFrame, horizontalScrollBarFrame, base, fBorder, + flags); } -// #pragma mark - +void +BScrollView::FrameMoved(BPoint newPosition) +{ + BView::FrameMoved(newPosition); +} + + +void +BScrollView::FrameResized(float newWidth, float newHeight) +{ + BView::FrameResized(newWidth, newHeight); + + if (fBorder == B_NO_BORDER) + return; + + BRect bounds = Bounds(); + float border = _BorderSize() - 1; + + if (be_control_look && fHorizontalScrollBar && fVerticalScrollBar) { + BRect scrollCorner(bounds); + scrollCorner.left = min_c( + fPreviousWidth - fVerticalScrollBar->Frame().Height(), + fHorizontalScrollBar->Frame().right + 1); + scrollCorner.top = min_c( + fPreviousHeight - fHorizontalScrollBar->Frame().Width(), + fVerticalScrollBar->Frame().bottom + 1); + Invalidate(scrollCorner); + } + + // changes in newWidth + + if (bounds.Width() > fPreviousWidth) { + // invalidate the region between the old and the new right border + BRect rect = bounds; + rect.left += fPreviousWidth - border; + rect.right--; + Invalidate(rect); + } else if (bounds.Width() < fPreviousWidth) { + // invalidate the region of the new right border + BRect rect = bounds; + rect.left = rect.right - border; + Invalidate(rect); + } + + // changes in newHeight + + if (bounds.Height() > fPreviousHeight) { + // invalidate the region between the old and the new bottom border + BRect rect = bounds; + rect.top += fPreviousHeight - border; + rect.bottom--; + Invalidate(rect); + } else if (bounds.Height() < fPreviousHeight) { + // invalidate the region of the new bottom border + BRect rect = bounds; + rect.top = rect.bottom - border; + Invalidate(rect); + } + + fPreviousWidth = uint16(bounds.Width()); + fPreviousHeight = uint16(bounds.Height()); +} + + +void +BScrollView::MessageReceived(BMessage* message) +{ + BView::MessageReceived(message); +} + + +void +BScrollView::MouseDown(BPoint where) +{ + BView::MouseDown(where); +} + + +void +BScrollView::MouseMoved(BPoint where, uint32 code, + const BMessage* dragMessage) +{ + BView::MouseMoved(where, code, dragMessage); +} + + +void +BScrollView::MouseUp(BPoint where) +{ + BView::MouseUp(where); +} void @@ -239,28 +313,38 @@ BScrollView::WindowActivated(bool active) } -void -BScrollView::MakeFocus(bool state) -{ - BView::MakeFocus(state); -} - - -// #pragma mark - +// #pragma mark - Size methods void -BScrollView::GetPreferredSize(float *_width, float *_height) +BScrollView::GetPreferredSize(float* _width, float* _height) { BSize size = PreferredSize(); if (_width) *_width = size.width; + if (_height) *_height = size.height; } +void +BScrollView::ResizeToPreferred() +{ + if (Window() == NULL) + return; + BView::ResizeToPreferred(); +} + + +void +BScrollView::MakeFocus(bool focus) +{ + BView::MakeFocus(focus); +} + + BSize BScrollView::MinSize() { @@ -291,120 +375,13 @@ BScrollView::PreferredSize() } -void -BScrollView::ResizeToPreferred() -{ - if (Window() == NULL) - return; - BView::ResizeToPreferred(); -} - - -void -BScrollView::FrameMoved(BPoint position) -{ - BView::FrameMoved(position); -} - - -void -BScrollView::FrameResized(float width, float height) -{ - BView::FrameResized(width, height); - - if (fBorder == B_NO_BORDER) - return; - - BRect bounds = Bounds(); - float border = _BorderSize() - 1; - - if (be_control_look && fHorizontalScrollBar && fVerticalScrollBar) { - BRect scrollCorner(bounds); - scrollCorner.left = min_c( - fPreviousWidth - fVerticalScrollBar->Frame().Height(), - fHorizontalScrollBar->Frame().right + 1); - scrollCorner.top = min_c( - fPreviousHeight - fHorizontalScrollBar->Frame().Width(), - fVerticalScrollBar->Frame().bottom + 1); - Invalidate(scrollCorner); - } - - // changes in width - - if (bounds.Width() > fPreviousWidth) { - // invalidate the region between the old and the new right border - BRect rect = bounds; - rect.left += fPreviousWidth - border; - rect.right--; - Invalidate(rect); - } else if (bounds.Width() < fPreviousWidth) { - // invalidate the region of the new right border - BRect rect = bounds; - rect.left = rect.right - border; - Invalidate(rect); - } - - // changes in height - - if (bounds.Height() > fPreviousHeight) { - // invalidate the region between the old and the new bottom border - BRect rect = bounds; - rect.top += fPreviousHeight - border; - rect.bottom--; - Invalidate(rect); - } else if (bounds.Height() < fPreviousHeight) { - // invalidate the region of the new bottom border - BRect rect = bounds; - rect.top = rect.bottom - border; - Invalidate(rect); - } - - fPreviousWidth = uint16(bounds.Width()); - fPreviousHeight = uint16(bounds.Height()); -} - - -// #pragma mark - - - -void -BScrollView::MessageReceived(BMessage* message) -{ - switch (message->what) { - default: - BView::MessageReceived(message); - } -} - - -void -BScrollView::MouseDown(BPoint point) -{ - BView::MouseDown(point); -} - - -void -BScrollView::MouseUp(BPoint point) -{ - BView::MouseUp(point); -} - - -void -BScrollView::MouseMoved(BPoint point, uint32 code, const BMessage *dragMessage) -{ - BView::MouseMoved(point, code, dragMessage); -} - - -// #pragma mark - +// #pragma mark - BScrollView methods BScrollBar* -BScrollView::ScrollBar(orientation posture) const +BScrollView::ScrollBar(orientation direction) const { - if (posture == B_HORIZONTAL) + if (direction == B_HORIZONTAL) return fHorizontalScrollBar; return fVerticalScrollBar; @@ -482,21 +459,21 @@ BScrollView::Border() const status_t -BScrollView::SetBorderHighlighted(bool state) +BScrollView::SetBorderHighlighted(bool highlight) { - if (fHighlighted == state) + if (fHighlighted == highlight) return B_OK; if (fBorder != B_FANCY_BORDER) // highlighting only works for B_FANCY_BORDER return B_ERROR; - fHighlighted = state; + fHighlighted = highlight; if (fHorizontalScrollBar != NULL) - fHorizontalScrollBar->SetBorderHighlighted(state); + fHorizontalScrollBar->SetBorderHighlighted(highlight); if (fVerticalScrollBar != NULL) - fVerticalScrollBar->SetBorderHighlighted(state); + fVerticalScrollBar->SetBorderHighlighted(highlight); BRect bounds = Bounds(); if (be_control_look != NULL) @@ -521,7 +498,7 @@ BScrollView::IsBorderHighlighted() const void -BScrollView::SetTarget(BView *target) +BScrollView::SetTarget(BView* target) { if (fTarget == target) return; @@ -560,25 +537,28 @@ BScrollView::Target() const } -// #pragma mark - +// #pragma mark - Scripting methods BHandler* -BScrollView::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, - int32 form, const char* property) +BScrollView::ResolveSpecifier(BMessage* message, int32 index, + BMessage* specifier, int32 what, const char* property) { - return BView::ResolveSpecifier(msg, index, specifier, form, property); + return BView::ResolveSpecifier(message, index, specifier, what, property); } status_t -BScrollView::GetSupportedSuites(BMessage *data) +BScrollView::GetSupportedSuites(BMessage* message) { - return BView::GetSupportedSuites(data); + return BView::GetSupportedSuites(message); } +// #pragma mark - Perform + + status_t BScrollView::Perform(perform_code code, void* _data) { @@ -587,22 +567,27 @@ BScrollView::Perform(perform_code code, void* _data) ((perform_data_min_size*)_data)->return_value = BScrollView::MinSize(); return B_OK; + case PERFORM_CODE_MAX_SIZE: ((perform_data_max_size*)_data)->return_value = BScrollView::MaxSize(); return B_OK; + case PERFORM_CODE_PREFERRED_SIZE: ((perform_data_preferred_size*)_data)->return_value = BScrollView::PreferredSize(); return B_OK; + case PERFORM_CODE_LAYOUT_ALIGNMENT: ((perform_data_layout_alignment*)_data)->return_value = BScrollView::LayoutAlignment(); return B_OK; + case PERFORM_CODE_HAS_HEIGHT_FOR_WIDTH: ((perform_data_has_height_for_width*)_data)->return_value = BScrollView::HasHeightForWidth(); return B_OK; + case PERFORM_CODE_GET_HEIGHT_FOR_WIDTH: { perform_data_get_height_for_width* data @@ -611,12 +596,14 @@ BScrollView::Perform(perform_code code, void* _data) &data->preferred); return B_OK; } + case PERFORM_CODE_SET_LAYOUT: { perform_data_set_layout* data = (perform_data_set_layout*)_data; BScrollView::SetLayout(data->layout); return B_OK; } + case PERFORM_CODE_LAYOUT_INVALIDATED: { perform_data_layout_invalidated* data @@ -624,6 +611,7 @@ BScrollView::Perform(perform_code code, void* _data) BScrollView::LayoutInvalidated(data->descendants); return B_OK; } + case PERFORM_CODE_DO_LAYOUT: { BScrollView::DoLayout(); @@ -635,6 +623,9 @@ BScrollView::Perform(perform_code code, void* _data) } +// #pragma mark - Protected methods + + void BScrollView::LayoutInvalidated(bool descendants) { @@ -644,11 +635,11 @@ BScrollView::LayoutInvalidated(bool descendants) void BScrollView::DoLayout() { - if (!(Flags() & B_SUPPORTS_LAYOUT)) + if ((Flags() & B_SUPPORTS_LAYOUT) == 0) return; // If the user set a layout, we let the base class version call its hook. - if (GetLayout()) { + if (GetLayout() != NULL) { BView::DoLayout(); return; } @@ -667,9 +658,7 @@ BScrollView::DoLayout() } - - -// #pragma mark - +// #pragma mark - Private methods void @@ -882,10 +871,10 @@ BScrollView::_ModifyFlags(int32 flags, border_style border) } -// #pragma mark - +// #pragma mark - FBC and forbidden -BScrollView & +BScrollView& BScrollView::operator=(const BScrollView &) { return *this; @@ -907,4 +896,3 @@ B_IF_GCC_2(InvalidateLayout__11BScrollViewb, view->Perform(PERFORM_CODE_LAYOUT_INVALIDATED, &data); } - diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 15492efe62..d0879e5690 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -630,7 +630,7 @@ BTextView::MouseUp(BPoint where) // Hook method that is called whenever the mouse cursor enters, exits // or moves inside the view. void -BTextView::MouseMoved(BPoint where, uint32 code, const BMessage* message) +BTextView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) { // Check if it's a "click'n'move" if (_PerformMouseMoved(where, code)) @@ -639,18 +639,17 @@ BTextView::MouseMoved(BPoint where, uint32 code, const BMessage* message) switch (code) { case B_ENTERED_VIEW: case B_INSIDE_VIEW: - _TrackMouse(where, message, true); + _TrackMouse(where, dragMessage, true); break; case B_EXITED_VIEW: _DragCaret(-1); - if (Window()->IsActive() && message == NULL) + if (Window()->IsActive() && dragMessage == NULL) SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); break; default: - BView::MouseMoved(where, code, message); - break; + BView::MouseMoved(where, code, dragMessage); } } @@ -658,11 +657,11 @@ BTextView::MouseMoved(BPoint where, uint32 code, const BMessage* message) // Hook method that is called when the window becomes the active window // or gives up that status. void -BTextView::WindowActivated(bool state) +BTextView::WindowActivated(bool active) { - BView::WindowActivated(state); + BView::WindowActivated(active); - if (state && IsFocus()) { + if (active && IsFocus()) { if (!fActive) _Activate(); } else { @@ -779,9 +778,9 @@ BTextView::Pulse() // Hook method that is called when the frame is resized. void -BTextView::FrameResized(float width, float height) +BTextView::FrameResized(float newWidth, float newHeight) { - BView::FrameResized(width, height); + BView::FrameResized(newWidth, newHeight); _UpdateScrollbars(); } @@ -789,11 +788,11 @@ BTextView::FrameResized(float width, float height) // Highlight or unhighlight the selection when the view gets or loses its // focus state. void -BTextView::MakeFocus(bool focusState) +BTextView::MakeFocus(bool focus) { - BView::MakeFocus(focusState); + BView::MakeFocus(focus); - if (focusState && Window() && Window()->IsActive()) { + if (focus && Window() != NULL && Window()->IsActive()) { if (!fActive) _Activate(); } else { @@ -1964,12 +1963,12 @@ BTextView::CanEndLine(int32 offset) // Returns the width of the line at the given index. float -BTextView::LineWidth(int32 lineNum) const +BTextView::LineWidth(int32 lineNumber) const { - if (lineNum < 0 || lineNum >= fLines->NumLines()) + if (lineNumber < 0 || lineNumber >= fLines->NumLines()) return 0; - STELine* line = (*fLines)[lineNum]; + STELine* line = (*fLines)[lineNumber]; int32 length = (line + 1)->offset - line->offset; // skip newline at the end of the line, if any, as it does no contribute @@ -1983,9 +1982,9 @@ BTextView::LineWidth(int32 lineNum) const // Returns the height of the line at the given index. float -BTextView::LineHeight(int32 lineNum) const +BTextView::LineHeight(int32 lineNumber) const { - float lineHeight = TextHeight(lineNum, lineNum); + float lineHeight = TextHeight(lineNumber, lineNumber); if (lineHeight == 0.0) { // We probably don't have text content yet. Take the initial // style's font height or fall back to the plain font. diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 683b5419ac..a993b3b3a8 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -1328,7 +1328,7 @@ BView::TargetedByScrollView(BScrollView* scroll_view) void -BView::WindowActivated(bool state) +BView::WindowActivated(bool active) { // Hook function STRACE(("\tHOOK: BView(%s)::WindowActivated()\n", Name())); @@ -1602,33 +1602,34 @@ BView::GetMouse(BPoint* _location, uint32* _buttons, bool checkMessageQueue) void -BView::MakeFocus(bool focusState) +BView::MakeFocus(bool focus) { - if (fOwner) { - // TODO: If this view has focus and focusState==false, - // will there really be no other view with focus? No - // cycling to the next one? - BView* focus = fOwner->CurrentFocus(); - if (focusState) { - // Unfocus a previous focus view - if (focus && focus != this) - focus->MakeFocus(false); - // if we want to make this view the current focus view - fOwner->_SetFocus(this, true); - } else { - // we want to unfocus this view, but only if it actually has focus - if (focus == this) { - fOwner->_SetFocus(NULL, true); - } - } + if (fOwner == NULL) + return; + + // TODO: If this view has focus and focus == false, + // will there really be no other view with focus? No + // cycling to the next one? + BView* focusView = fOwner->CurrentFocus(); + if (focus) { + // Unfocus a previous focus view + if (focusView != NULL && focusView != this) + focusView->MakeFocus(false); + + // if we want to make this view the current focus view + fOwner->_SetFocus(this, true); + } else { + // we want to unfocus this view, but only if it actually has focus + if (focusView == this) + fOwner->_SetFocus(NULL, true); } } BScrollBar* -BView::ScrollBar(orientation posture) const +BView::ScrollBar(orientation direction) const { - switch (posture) { + switch (direction) { case B_VERTICAL: return fVerScroller; @@ -1795,9 +1796,9 @@ BView::PopState() void -BView::SetOrigin(BPoint pt) +BView::SetOrigin(BPoint where) { - SetOrigin(pt.x, pt.y); + SetOrigin(where.x, where.y); } diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index f23681f23d..534fc3aa29 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -2008,7 +2008,7 @@ BWindow::Activate(bool active) void -BWindow::WindowActivated(bool state) +BWindow::WindowActivated(bool focus) { // hook function // does nothing