2009-06-21 17:04:51 +04:00
|
|
|
/*
|
2014-12-20 03:43:26 +03:00
|
|
|
* Copyright 2001-2009 Haiku, Inc. All rights reserved.
|
2009-08-27 15:12:41 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
2009-06-21 17:04:51 +04:00
|
|
|
*/
|
2002-09-26 18:53:19 +04:00
|
|
|
#ifndef _TAB_VIEW_H
|
|
|
|
#define _TAB_VIEW_H
|
2007-09-27 11:55:16 +04:00
|
|
|
|
|
|
|
|
|
|
|
#include <View.h>
|
|
|
|
|
|
|
|
|
2015-07-14 04:28:20 +03:00
|
|
|
class BTabView;
|
|
|
|
|
|
|
|
|
2007-09-27 11:55:16 +04:00
|
|
|
enum tab_position {
|
|
|
|
B_TAB_FIRST = 999,
|
|
|
|
B_TAB_FRONT,
|
|
|
|
B_TAB_ANY
|
2002-09-26 18:53:19 +04:00
|
|
|
};
|
2007-09-27 11:55:16 +04:00
|
|
|
|
|
|
|
|
|
|
|
class BTab : public BArchivable {
|
|
|
|
public:
|
2015-07-14 18:15:36 +03:00
|
|
|
BTab(BView* contentsView = NULL);
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual ~BTab();
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
BTab(BMessage* archive);
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2014-12-20 03:43:26 +03:00
|
|
|
virtual status_t Archive(BMessage* data, bool deep = true) const;
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual status_t Perform(uint32 d, void* arg);
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
const char* Label() const;
|
|
|
|
virtual void SetLabel(const char* label);
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
bool IsSelected() const;
|
|
|
|
virtual void Select(BView* owner);
|
|
|
|
virtual void Deselect();
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2014-12-20 03:43:26 +03:00
|
|
|
virtual void SetEnabled(bool enable);
|
2009-06-21 17:04:51 +04:00
|
|
|
bool IsEnabled() const;
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2014-12-20 03:43:26 +03:00
|
|
|
void MakeFocus(bool focus = true);
|
2009-06-21 17:04:51 +04:00
|
|
|
bool IsFocus() const;
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
// sets/gets the view to be displayed for this tab
|
|
|
|
virtual void SetView(BView* view);
|
|
|
|
BView* View() const;
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual void DrawFocusMark(BView* owner, BRect frame);
|
|
|
|
virtual void DrawLabel(BView* owner, BRect frame);
|
|
|
|
virtual void DrawTab(BView* owner, BRect frame,
|
|
|
|
tab_position position, bool full = true);
|
2007-09-27 11:55:16 +04:00
|
|
|
|
2015-07-14 18:04:39 +03:00
|
|
|
class Private;
|
|
|
|
|
2007-09-27 11:55:16 +04:00
|
|
|
private:
|
2015-07-14 18:04:39 +03:00
|
|
|
friend class Private;
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
// FBC padding and forbidden methods
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual void _ReservedTab1();
|
|
|
|
virtual void _ReservedTab2();
|
|
|
|
virtual void _ReservedTab3();
|
|
|
|
virtual void _ReservedTab4();
|
|
|
|
virtual void _ReservedTab5();
|
|
|
|
virtual void _ReservedTab6();
|
|
|
|
virtual void _ReservedTab7();
|
|
|
|
virtual void _ReservedTab8();
|
|
|
|
virtual void _ReservedTab9();
|
|
|
|
virtual void _ReservedTab10();
|
|
|
|
virtual void _ReservedTab11();
|
|
|
|
virtual void _ReservedTab12();
|
|
|
|
|
|
|
|
BTab& operator=(const BTab&);
|
|
|
|
|
BeControlLook: Fix app integration drawing issues
Update BTab::DrawTab() to pass the current index, the index of the
selected tab, and the index of the first and last tabs into
BControlLook::DrawActiveTab() and BControlLook::DrawInactiveTab().
This allows you to draw tabs differently in your BTab or BControlLook
subclass in many different circumstances.
Modify BControlLook API to add indexes to DrawActiveTab() and
DrawInactiveTab() like so:
void DrawActiveTab(..., int32 index = 0, int32 selected = -1,
int32 first = 0, int32 last = 0);
void DrawInactiveTab(..., int32 index = 0, int32 selected = -1,
int32 first = 0, int32 last = 0);
These extra indexes are not used by HaikuControlLook which relies only
on if the tab is active or inactive to draw.
Add IndexOf(BTab* tab) method to BTabView and document it to get the
index of the current tab in BTab::DrawTab(). Also add a warning in the
BTabView::DrawTab() method not to use the position and full parameters
anymore, use BTabView::IndexOf(), BTabView::Selection(), and
BTabView::TabCount() to get the info you need.
Using a dynamic_cast to a BTabView in BeControlLook to determine if the
view is derived from a BTabView didn't work in the case of WebPositive.
Furthermore, WebPositive does custom tab drawing which needed to be
updated for alternative control look. These index parameters passed from
BTab to BeControlLook allow us to draw the tab like BeOS without relying
on a dynamic_cast to BTabView to get the info.
Reproduce the functionality described above for BTab in WebPositive's
custom tabs. Eliminate no longer needed code in favor of using indexes.
Update WebPositive custom tabs to use BControlLook::DrawTabFrame()
instead of BControlLook::DrawInactiveTab() matching the update made in
BTabView.
In BeControlLook::DrawTabFrame() fill rect with base color, WebPositive
doesn't draw any tab background, so it expects this work to be done for
it.
Eliminate hasFrames variable from WebPositive.
Rename TabSelected(index) to UpdateSelection(index) in WebPositive to
better reflect its purpose.
Adjusted HaikuControlLook::DrawInactiveTab() to draw the tab borders more
selectively. Only draw border if left border is set for top and bottom tabs
or top border is set for left and right tabs. Undo no longer needed frame
manipulation border drawing workaround in HaikuControlLook::DrawTabFrame().
Draw scroll bar triangle without using DrawArrowShape().
Unlike in HaikuControlLook, DrawArrowShape() is used to draw arrows in
BOutlineListView and menus distinctly from how it draws arrows in scroll
bars. Draw our distinct arrows in DrawSrollBarButtons() instead.
This fixes overflow of time edit up-down arrows in Clock prefs and the
collapse-expand arrow in Deskbar not being vertically centered.
In DrawBorders() only inset if we actually draw the border.
Fix alignment issues with DrawSliderThumb dots for example in
MediaPlayer volume knobs.
Draw using line arrays calling AddLine instead of StrokeLine in
several places.
DrawMenuBar() extends to draw final pixel which eliminates an extra
lines at the end of menu bars.
Truncate button labels better fixing a few issues for example keymap
keyboard layout button labels. Button insets has been updated a bit
to fix drawing issues with buttons missing a border.
Using a dynamic_cast to a BButton to determine if a view is a button
in BeControlLook didn't work in the case of the keymap label. Look for
B_FLAT, B_HOVER, or B_DEFAULT_BUTTON flag in BeControlLook::DrawLabel()
to draw the label inverted on click. Pass the B_FLAT flag from Keymap
keys when drawing using BControlLook so that the label is inverted.
Change-Id: I07631f4b006bdb9aeca2adc9cbdf2da54dae8e92
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2866
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-02 00:15:29 +03:00
|
|
|
private:
|
|
|
|
uint32 _Borders(BView* owner, BRect frame);
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
private:
|
2009-06-21 17:04:51 +04:00
|
|
|
bool fEnabled;
|
|
|
|
bool fSelected;
|
|
|
|
bool fFocus;
|
|
|
|
BView* fView;
|
2015-07-14 04:28:20 +03:00
|
|
|
BTabView* fTabView;
|
2009-06-21 17:04:51 +04:00
|
|
|
|
2015-07-14 04:28:20 +03:00
|
|
|
uint32 _reserved[11];
|
2007-09-27 11:55:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
class BTabView : public BView {
|
2002-09-26 18:53:19 +04:00
|
|
|
public:
|
2017-08-19 20:32:31 +03:00
|
|
|
enum tab_side {
|
|
|
|
kLeftSide = 1 << 0,
|
|
|
|
kRightSide = 1 << 1,
|
|
|
|
kTopSide = 1 << 2,
|
|
|
|
kBottomSide = 1 << 3
|
|
|
|
};
|
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
BTabView(const char* name,
|
2019-01-22 21:04:44 +03:00
|
|
|
button_width width = B_WIDTH_FROM_WIDEST,
|
2009-08-27 15:12:41 +04:00
|
|
|
uint32 flags = B_FULL_UPDATE_ON_RESIZE
|
|
|
|
| B_WILL_DRAW | B_NAVIGABLE_JUMP
|
|
|
|
| B_FRAME_EVENTS | B_NAVIGABLE);
|
2009-06-21 17:04:51 +04:00
|
|
|
BTabView(BRect frame, const char* name,
|
|
|
|
button_width width = B_WIDTH_AS_USUAL,
|
2014-12-20 03:43:26 +03:00
|
|
|
uint32 resizeMask = B_FOLLOW_ALL,
|
2009-08-27 15:12:41 +04:00
|
|
|
uint32 flags = B_FULL_UPDATE_ON_RESIZE
|
|
|
|
| B_WILL_DRAW | B_NAVIGABLE_JUMP
|
|
|
|
| B_FRAME_EVENTS | B_NAVIGABLE);
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual ~BTabView();
|
|
|
|
|
|
|
|
BTabView(BMessage* archive);
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
|
|
virtual status_t Archive(BMessage* into,
|
|
|
|
bool deep = true) const;
|
2010-07-29 00:03:41 +04:00
|
|
|
virtual status_t AllUnarchived(const BMessage* from);
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual status_t Perform(perform_code d, void* arg);
|
|
|
|
|
|
|
|
virtual void AttachedToWindow();
|
2009-08-27 15:12:41 +04:00
|
|
|
virtual void DetachedFromWindow();
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual void AllAttached();
|
|
|
|
virtual void AllDetached();
|
|
|
|
|
|
|
|
virtual void MessageReceived(BMessage* message);
|
|
|
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
2014-12-20 03:43:26 +03:00
|
|
|
virtual void MouseDown(BPoint where);
|
|
|
|
virtual void MouseUp(BPoint where);
|
|
|
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
2009-06-21 17:04:51 +04:00
|
|
|
const BMessage* dragMessage);
|
|
|
|
virtual void Pulse();
|
|
|
|
|
2014-12-20 03:58:56 +03:00
|
|
|
virtual void Select(int32 index);
|
2009-06-21 17:04:51 +04:00
|
|
|
int32 Selection() const;
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
virtual void WindowActivated(bool active);
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual void MakeFocus(bool focused = true);
|
|
|
|
virtual void SetFocusTab(int32 tab, bool focused);
|
|
|
|
int32 FocusTab() const;
|
|
|
|
|
|
|
|
virtual void Draw(BRect updateRect);
|
|
|
|
virtual BRect DrawTabs();
|
|
|
|
virtual void DrawBox(BRect selectedTabRect);
|
|
|
|
virtual BRect TabFrame(int32 index) const;
|
|
|
|
|
|
|
|
virtual void SetFlags(uint32 flags);
|
|
|
|
virtual void SetResizingMode(uint32 mode);
|
|
|
|
|
|
|
|
virtual void ResizeToPreferred();
|
2014-12-20 03:43:26 +03:00
|
|
|
virtual void GetPreferredSize(float* _width, float* _height);
|
2009-06-21 17:04:51 +04:00
|
|
|
|
|
|
|
virtual BSize MinSize();
|
|
|
|
virtual BSize MaxSize();
|
|
|
|
virtual BSize PreferredSize();
|
|
|
|
|
2014-12-20 03:43:26 +03:00
|
|
|
virtual void FrameMoved(BPoint newPosition);
|
|
|
|
virtual void FrameResized(float newWidth, float newHeight);
|
2009-08-27 15:12:41 +04:00
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual BHandler* ResolveSpecifier(BMessage* message,
|
|
|
|
int32 index, BMessage* specifier,
|
|
|
|
int32 what, const char* property);
|
|
|
|
virtual status_t GetSupportedSuites(BMessage* message);
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
// BTabView
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual void AddTab(BView* target, BTab* tab = NULL);
|
|
|
|
virtual BTab* RemoveTab(int32 tabIndex);
|
|
|
|
|
|
|
|
virtual BTab* TabAt(int32 index) const;
|
|
|
|
|
|
|
|
virtual void SetTabWidth(button_width width);
|
|
|
|
button_width TabWidth() const;
|
|
|
|
|
|
|
|
virtual void SetTabHeight(float height);
|
|
|
|
float TabHeight() const;
|
|
|
|
|
2016-04-29 23:57:50 +03:00
|
|
|
virtual void SetBorder(border_style borderStyle);
|
2010-02-21 23:15:21 +03:00
|
|
|
border_style Border() const;
|
|
|
|
|
2017-08-19 20:32:31 +03:00
|
|
|
virtual void SetTabSide(tab_side tabSide);
|
|
|
|
tab_side TabSide() const;
|
|
|
|
|
2009-06-21 17:04:51 +04:00
|
|
|
BView* ContainerView() const;
|
|
|
|
|
|
|
|
int32 CountTabs() const;
|
|
|
|
BView* ViewForTab(int32 tabIndex) const;
|
2007-09-27 11:55:16 +04:00
|
|
|
|
BeControlLook: Fix app integration drawing issues
Update BTab::DrawTab() to pass the current index, the index of the
selected tab, and the index of the first and last tabs into
BControlLook::DrawActiveTab() and BControlLook::DrawInactiveTab().
This allows you to draw tabs differently in your BTab or BControlLook
subclass in many different circumstances.
Modify BControlLook API to add indexes to DrawActiveTab() and
DrawInactiveTab() like so:
void DrawActiveTab(..., int32 index = 0, int32 selected = -1,
int32 first = 0, int32 last = 0);
void DrawInactiveTab(..., int32 index = 0, int32 selected = -1,
int32 first = 0, int32 last = 0);
These extra indexes are not used by HaikuControlLook which relies only
on if the tab is active or inactive to draw.
Add IndexOf(BTab* tab) method to BTabView and document it to get the
index of the current tab in BTab::DrawTab(). Also add a warning in the
BTabView::DrawTab() method not to use the position and full parameters
anymore, use BTabView::IndexOf(), BTabView::Selection(), and
BTabView::TabCount() to get the info you need.
Using a dynamic_cast to a BTabView in BeControlLook to determine if the
view is derived from a BTabView didn't work in the case of WebPositive.
Furthermore, WebPositive does custom tab drawing which needed to be
updated for alternative control look. These index parameters passed from
BTab to BeControlLook allow us to draw the tab like BeOS without relying
on a dynamic_cast to BTabView to get the info.
Reproduce the functionality described above for BTab in WebPositive's
custom tabs. Eliminate no longer needed code in favor of using indexes.
Update WebPositive custom tabs to use BControlLook::DrawTabFrame()
instead of BControlLook::DrawInactiveTab() matching the update made in
BTabView.
In BeControlLook::DrawTabFrame() fill rect with base color, WebPositive
doesn't draw any tab background, so it expects this work to be done for
it.
Eliminate hasFrames variable from WebPositive.
Rename TabSelected(index) to UpdateSelection(index) in WebPositive to
better reflect its purpose.
Adjusted HaikuControlLook::DrawInactiveTab() to draw the tab borders more
selectively. Only draw border if left border is set for top and bottom tabs
or top border is set for left and right tabs. Undo no longer needed frame
manipulation border drawing workaround in HaikuControlLook::DrawTabFrame().
Draw scroll bar triangle without using DrawArrowShape().
Unlike in HaikuControlLook, DrawArrowShape() is used to draw arrows in
BOutlineListView and menus distinctly from how it draws arrows in scroll
bars. Draw our distinct arrows in DrawSrollBarButtons() instead.
This fixes overflow of time edit up-down arrows in Clock prefs and the
collapse-expand arrow in Deskbar not being vertically centered.
In DrawBorders() only inset if we actually draw the border.
Fix alignment issues with DrawSliderThumb dots for example in
MediaPlayer volume knobs.
Draw using line arrays calling AddLine instead of StrokeLine in
several places.
DrawMenuBar() extends to draw final pixel which eliminates an extra
lines at the end of menu bars.
Truncate button labels better fixing a few issues for example keymap
keyboard layout button labels. Button insets has been updated a bit
to fix drawing issues with buttons missing a border.
Using a dynamic_cast to a BButton to determine if a view is a button
in BeControlLook didn't work in the case of the keymap label. Look for
B_FLAT, B_HOVER, or B_DEFAULT_BUTTON flag in BeControlLook::DrawLabel()
to draw the label inverted on click. Pass the B_FLAT flag from Keymap
keys when drawing using BControlLook so that the label is inverted.
Change-Id: I07631f4b006bdb9aeca2adc9cbdf2da54dae8e92
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2866
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2020-06-02 00:15:29 +03:00
|
|
|
int32 IndexOf(BTab* tab) const;
|
|
|
|
|
2007-09-27 11:55:16 +04:00
|
|
|
private:
|
2009-08-27 15:12:41 +04:00
|
|
|
// FBC padding and forbidden methods
|
2009-06-21 17:04:51 +04:00
|
|
|
virtual void _ReservedTabView3();
|
|
|
|
virtual void _ReservedTabView4();
|
|
|
|
virtual void _ReservedTabView5();
|
|
|
|
virtual void _ReservedTabView6();
|
|
|
|
virtual void _ReservedTabView7();
|
|
|
|
virtual void _ReservedTabView8();
|
|
|
|
virtual void _ReservedTabView9();
|
|
|
|
virtual void _ReservedTabView10();
|
|
|
|
virtual void _ReservedTabView11();
|
|
|
|
virtual void _ReservedTabView12();
|
|
|
|
|
|
|
|
BTabView(const BTabView&);
|
|
|
|
BTabView& operator=(const BTabView&);
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
private:
|
|
|
|
void _InitObject(bool layouted, button_width width);
|
2010-07-29 00:03:41 +04:00
|
|
|
void _InitContainerView(bool layouted);
|
2009-08-27 15:12:41 +04:00
|
|
|
BSize _TabsMinSize() const;
|
2010-02-21 23:15:21 +03:00
|
|
|
float _BorderWidth() const;
|
|
|
|
void _LayoutContainerView(bool layouted);
|
2009-08-27 15:12:41 +04:00
|
|
|
|
|
|
|
private:
|
2009-06-21 17:04:51 +04:00
|
|
|
BList* fTabList;
|
|
|
|
BView* fContainerView;
|
|
|
|
button_width fTabWidthSetting;
|
|
|
|
float fTabWidth;
|
|
|
|
float fTabHeight;
|
|
|
|
int32 fSelection;
|
|
|
|
int32 fInitialSelection;
|
|
|
|
int32 fFocus;
|
|
|
|
float fTabOffset;
|
2010-02-21 23:15:21 +03:00
|
|
|
border_style fBorderStyle;
|
2017-08-19 20:32:31 +03:00
|
|
|
tab_side fTabSide;
|
2009-06-21 17:04:51 +04:00
|
|
|
|
2017-08-19 20:32:31 +03:00
|
|
|
uint32 _reserved[9];
|
2007-09-27 11:55:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _TAB_VIEW_H
|