* Made BScrollView work when using it with the layout system.
* Added a layout friendly constructor - it's not so nice to use, though, since the original one already doesn't get a BRect (we just don't need the resizing mode, and have to set the B_SUPPORTS_LAYOUT flag). * Refactored size/frame computation a bit. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28258 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,95 +1,114 @@
|
||||
/*
|
||||
** Copyright 2004-2008, Haiku Inc. All Rights Reserved.
|
||||
** Distributed under the terms of the MIT license.
|
||||
*/
|
||||
* Copyright 2004-2008, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*/
|
||||
#ifndef _SCROLL_VIEW_H
|
||||
#define _SCROLL_VIEW_H
|
||||
|
||||
/** The BScrollView is a convenience class to add a scrolling
|
||||
* mechanism to the target view.
|
||||
*/
|
||||
|
||||
#include <ScrollBar.h>
|
||||
|
||||
|
||||
/*! The BScrollView is a convenience class to add a scrolling
|
||||
mechanism to the target view.
|
||||
*/
|
||||
class BScrollView : public BView {
|
||||
public:
|
||||
BScrollView(const char *name, BView *target,
|
||||
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = 0, bool horizontal = false, bool vertical = false,
|
||||
border_style border = B_FANCY_BORDER);
|
||||
BScrollView(BMessage *archive);
|
||||
virtual ~BScrollView();
|
||||
public:
|
||||
BScrollView(const char* name, BView* target,
|
||||
uint32 resizingMode
|
||||
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||
uint32 flags = 0, bool horizontal = false,
|
||||
bool vertical = false,
|
||||
border_style border = B_FANCY_BORDER);
|
||||
BScrollView(const char* name, BView* target,
|
||||
uint32 flags, bool horizontal, bool vertical,
|
||||
border_style border = B_FANCY_BORDER);
|
||||
BScrollView(BMessage* archive);
|
||||
virtual ~BScrollView();
|
||||
|
||||
static BArchivable *Instantiate(BMessage *archive);
|
||||
virtual status_t Archive(BMessage *archive, bool deep = true) const;
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
virtual status_t Archive(BMessage* archive, bool deep = true) const;
|
||||
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void AttachedToWindow();
|
||||
|
||||
BScrollBar *ScrollBar(orientation posture) const;
|
||||
BScrollBar* ScrollBar(orientation posture) const;
|
||||
|
||||
virtual void SetBorder(border_style border);
|
||||
border_style Border() const;
|
||||
virtual void SetBorder(border_style border);
|
||||
border_style Border() const;
|
||||
|
||||
virtual status_t SetBorderHighlighted(bool state);
|
||||
bool IsBorderHighlighted() const;
|
||||
virtual status_t SetBorderHighlighted(bool state);
|
||||
bool IsBorderHighlighted() const;
|
||||
|
||||
void SetTarget(BView *target);
|
||||
BView *Target() const;
|
||||
void SetTarget(BView* target);
|
||||
BView* Target() const;
|
||||
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void MouseDown(BPoint point);
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual void MouseDown(BPoint point);
|
||||
|
||||
virtual void WindowActivated(bool active);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void MouseMoved(BPoint point, uint32 code, const BMessage *msg);
|
||||
virtual void WindowActivated(bool active);
|
||||
virtual void MouseUp(BPoint point);
|
||||
virtual void MouseMoved(BPoint point, uint32 code,
|
||||
const BMessage* dragMessage);
|
||||
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
virtual void DetachedFromWindow();
|
||||
virtual void AllAttached();
|
||||
virtual void AllDetached();
|
||||
|
||||
virtual void FrameMoved(BPoint position);
|
||||
virtual void FrameResized(float width, float height);
|
||||
virtual void FrameMoved(BPoint position);
|
||||
virtual void FrameResized(float width, float height);
|
||||
|
||||
virtual BHandler *ResolveSpecifier(BMessage *message, int32 index,
|
||||
BMessage *specifier, int32 form, const char *property);
|
||||
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 status_t GetSupportedSuites(BMessage *data);
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
virtual void MakeFocus(bool state = true);
|
||||
virtual status_t GetSupportedSuites(BMessage* data);
|
||||
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
virtual BSize MinSize();
|
||||
virtual BSize PreferredSize();
|
||||
|
||||
// private or reserved methods are following
|
||||
virtual void InvalidateLayout(bool descendants = false);
|
||||
virtual void DoLayout();
|
||||
|
||||
virtual status_t Perform(perform_code d, void *arg);
|
||||
// private or reserved methods are following
|
||||
|
||||
private:
|
||||
friend class BView;
|
||||
virtual status_t Perform(perform_code d, void* arg);
|
||||
|
||||
virtual void _ReservedScrollView1();
|
||||
virtual void _ReservedScrollView2();
|
||||
virtual void _ReservedScrollView3();
|
||||
virtual void _ReservedScrollView4();
|
||||
private:
|
||||
friend class BView;
|
||||
|
||||
BScrollView &operator=(const BScrollView &);
|
||||
virtual void _ReservedScrollView1();
|
||||
virtual void _ReservedScrollView2();
|
||||
virtual void _ReservedScrollView3();
|
||||
virtual void _ReservedScrollView4();
|
||||
|
||||
static BRect CalcFrame(BView *target, bool h, bool v, border_style);
|
||||
static float BorderSize(border_style border);
|
||||
static int32 ModifyFlags(int32 flags, border_style);
|
||||
BScrollView& operator=(const BScrollView& other);
|
||||
|
||||
BView *fTarget;
|
||||
BScrollBar *fHorizontalScrollBar;
|
||||
BScrollBar *fVerticalScrollBar;
|
||||
border_style fBorder;
|
||||
uint16 fPreviousWidth;
|
||||
uint16 fPreviousHeight;
|
||||
bool fHighlighted;
|
||||
void _Init(bool horizontal, bool vertical);
|
||||
float _BorderSize() const;
|
||||
BRect _InnerFrame() const;
|
||||
BSize _ComputeSize(BSize targetSize) const;
|
||||
BRect _ComputeFrame(BRect targetRect) const;
|
||||
|
||||
uint32 _reserved[3];
|
||||
static BRect _ComputeFrame(BRect frame, bool horizontal,
|
||||
bool vertical, border_style border);
|
||||
static BRect _ComputeFrame(BView* target, bool horizontal,
|
||||
bool vertical, border_style border);
|
||||
static float _BorderSize(border_style border);
|
||||
static int32 _ModifyFlags(int32 flags, border_style border);
|
||||
|
||||
BView* fTarget;
|
||||
BScrollBar* fHorizontalScrollBar;
|
||||
BScrollBar* fVerticalScrollBar;
|
||||
border_style fBorder;
|
||||
uint16 fPreviousWidth;
|
||||
uint16 fPreviousHeight;
|
||||
bool fHighlighted;
|
||||
|
||||
uint32 _reserved[3];
|
||||
};
|
||||
|
||||
#endif /* _SCROLL_VIEW_H */
|
||||
|
||||
@@ -175,7 +175,7 @@ public:
|
||||
virtual void ScrollToOffset(int32 inOffset);
|
||||
void ScrollToSelection();
|
||||
|
||||
void Highlight(int32 startOffset, int32 endOffset);
|
||||
void Highlight(int32 startOffset, int32 endOffset);
|
||||
|
||||
void SetTextRect(BRect rect);
|
||||
BRect TextRect() const;
|
||||
@@ -208,9 +208,9 @@ public:
|
||||
BView* resizeView = NULL);
|
||||
bool IsResizable() const;
|
||||
void SetDoesUndo(bool undo);
|
||||
bool DoesUndo() const;
|
||||
bool DoesUndo() const;
|
||||
void HideTyping(bool enabled);
|
||||
bool IsTypingHidden() const;
|
||||
bool IsTypingHidden() const;
|
||||
|
||||
virtual void ResizeToPreferred();
|
||||
virtual void GetPreferredSize(float* _width, float* _height);
|
||||
@@ -331,7 +331,7 @@ private:
|
||||
int32 startOffset = -1, bool erase = false);
|
||||
void _DrawCaret(int32 offset);
|
||||
void _ShowCaret();
|
||||
void _HideCaret();
|
||||
void _HideCaret();
|
||||
void _InvertCaret();
|
||||
void _DragCaret(int32 offset);
|
||||
|
||||
@@ -348,7 +348,7 @@ private:
|
||||
bool _MessageDropped(BMessage* inMessage,
|
||||
BPoint where, BPoint offset);
|
||||
|
||||
void _PerformAutoScrolling();
|
||||
void _PerformAutoScrolling();
|
||||
void _UpdateScrollbars();
|
||||
void _AutoResize(bool doRedraw = true);
|
||||
|
||||
@@ -418,7 +418,7 @@ private:
|
||||
|
||||
uint32 _reserved[8];
|
||||
|
||||
static BPrivate::WidthBuffer* sWidths;
|
||||
static BPrivate::WidthBuffer* sWidths;
|
||||
};
|
||||
|
||||
#endif // _TEXTVIEW_H
|
||||
|
||||
Reference in New Issue
Block a user