Some refactoring and cleanup:
- renamed some members and methods to fit our style guide - moved removeSelf() to RemoveSelf() (as those two are essentially the same), and fixed it on the way: the state of the child views is now also updated by the new _UpdateStateForRemove() method - Moved BWindow::sendPulse() and activateView() to BView::_Pulse() and BView::_Activate() - some minor stuff This also fixes the broken previous commit - I forgot to update View.h; this update contains the previous changes as well. Sorry for the inconvenience. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13334 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
3783821c25
commit
bb1336b44f
@ -132,15 +132,16 @@ class BShape;
|
||||
class BShelf;
|
||||
class BString;
|
||||
class BWindow;
|
||||
class ViewAttr;
|
||||
struct _view_attr_;
|
||||
struct _array_data_;
|
||||
struct _array_hdr_;
|
||||
struct overlay_restrictions;
|
||||
|
||||
// BView class -----------------------------------------------------------------
|
||||
class BView : public BHandler {
|
||||
namespace BPrivate {
|
||||
class ViewState;
|
||||
};
|
||||
|
||||
|
||||
class BView : public BHandler {
|
||||
public:
|
||||
BView(BRect frame, const char* name,
|
||||
uint32 resizeMask, uint32 flags);
|
||||
@ -558,11 +559,9 @@ private:
|
||||
void DoShape(int32 gr, BShape* shape, pattern p);
|
||||
void DoPictureClip(BPicture* picture, BPoint where, bool invert,
|
||||
bool sync);
|
||||
bool removeFromList(BView* a_view);
|
||||
bool removeSelf();
|
||||
|
||||
bool do_owner_check() const;
|
||||
void setOwner(BWindow* the_owner);
|
||||
void do_activate(int32 state);
|
||||
void _SetOwner(BWindow* newOwner);
|
||||
void check_lock() const;
|
||||
void check_lock_no_pick() const;
|
||||
void movesize(uint32 code, int32 h, int32 v);
|
||||
@ -570,42 +569,42 @@ private:
|
||||
char *test_area(int32 length);
|
||||
void removeCommArray();
|
||||
_array_hdr_ *new_comm_array(int32 cnt);
|
||||
BView *RealParent() const;
|
||||
void SetScroller(BScrollBar* sb);
|
||||
void UnsetScroller(BScrollBar* sb);
|
||||
void RealScrollTo(BPoint);
|
||||
void initCachedState();
|
||||
void setCachedState();
|
||||
void updateCachedState();
|
||||
void setFontState(const BFont* font, uint16 mask);
|
||||
void fetch_font();
|
||||
uchar font_encoding() const;
|
||||
BShelf* shelf() const;
|
||||
void set_shelf(BShelf* );
|
||||
void set_shelf(BShelf* shelf);
|
||||
|
||||
void _Activate(bool state);
|
||||
void _Pulse();
|
||||
|
||||
void _UpdateStateForRemove();
|
||||
void _UpdatePattern(::pattern pattern);
|
||||
|
||||
void deleteView( BView* aView);
|
||||
bool do_owner_check_no_pick() const;
|
||||
bool attachView( BView *aView );
|
||||
bool addToList( BView *aView, BView *before = NULL);
|
||||
bool removeFromList();
|
||||
bool _AddChildToList(BView* child, BView* before = NULL);
|
||||
bool _RemoveChildFromList(BView* child);
|
||||
void callAttachHooks( BView *aView );
|
||||
void callDetachHooks( BView *aView );
|
||||
|
||||
// Debugging methods
|
||||
// Debugging methods
|
||||
void PrintToStream();
|
||||
void PrintTree();
|
||||
|
||||
int32 server_token;
|
||||
uint32 fFlags; // used // was: f_type
|
||||
float originX; // used // was: origin_h
|
||||
float originY; // used // was: origin_v
|
||||
BWindow* owner; // used
|
||||
BView* parent; // used
|
||||
BView* next_sibling; // used
|
||||
BView* prev_sibling; // used
|
||||
BView* first_child; // used
|
||||
uint32 fFlags;
|
||||
BPoint fParentOffset;
|
||||
BWindow* fOwner;
|
||||
BView* fParent;
|
||||
BView* fNextSibling;
|
||||
BView* fPreviousSibling;
|
||||
BView* fFirstChild;
|
||||
|
||||
int16 fShowLevel; // used
|
||||
int16 fShowLevel;
|
||||
bool top_level_view; // used
|
||||
bool fNoISInteraction;
|
||||
BPicture* cpicture; // used
|
||||
@ -617,50 +616,53 @@ private:
|
||||
bool _unused_bool0; // was: attached;
|
||||
bool _unused_bool1;
|
||||
bool _unused_bool2;
|
||||
ViewAttr* fPermanentState;// used
|
||||
ViewAttr* fState; // used
|
||||
BRect fBounds; // used
|
||||
BShelf* fShelf; // used
|
||||
void* pr_state;
|
||||
uint32 fEventMask; // used
|
||||
uint32 fEventOptions; // used
|
||||
BPrivate::ViewState* fPermanentState; // not used
|
||||
BPrivate::ViewState* fState;
|
||||
BRect fBounds;
|
||||
BShelf* fShelf;
|
||||
void* pr_state; // not used
|
||||
uint32 fEventMask;
|
||||
uint32 fEventOptions;
|
||||
uint32 _reserved[4];
|
||||
#if !_PR3_COMPATIBLE_
|
||||
uint32 _more_reserved[3];
|
||||
#endif
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// inline definitions ----------------------------------------------------------
|
||||
inline void BView::ScrollTo(float x, float y)
|
||||
|
||||
inline void
|
||||
BView::ScrollTo(float x, float y)
|
||||
{
|
||||
ScrollTo(BPoint(x, y));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
inline void BView::SetViewColor(uchar r, uchar g, uchar b, uchar a)
|
||||
|
||||
inline void
|
||||
BView::SetViewColor(uchar r, uchar g, uchar b, uchar a)
|
||||
{
|
||||
rgb_color a_color;
|
||||
a_color.red = r; a_color.green = g;
|
||||
a_color.blue = b; a_color.alpha = a;
|
||||
SetViewColor(a_color);
|
||||
rgb_color color;
|
||||
color.red = r; color.green = g;
|
||||
color.blue = b; color.alpha = a;
|
||||
SetViewColor(color);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
inline void BView::SetHighColor(uchar r, uchar g, uchar b, uchar a)
|
||||
|
||||
inline void
|
||||
BView::SetHighColor(uchar r, uchar g, uchar b, uchar a)
|
||||
{
|
||||
rgb_color a_color;
|
||||
a_color.red = r; a_color.green = g;
|
||||
a_color.blue = b; a_color.alpha = a;
|
||||
SetHighColor(a_color);
|
||||
rgb_color color;
|
||||
color.red = r; color.green = g;
|
||||
color.blue = b; color.alpha = a;
|
||||
SetHighColor(color);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
inline void BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
|
||||
|
||||
inline void
|
||||
BView::SetLowColor(uchar r, uchar g, uchar b, uchar a)
|
||||
{
|
||||
rgb_color a_color;
|
||||
a_color.red = r; a_color.green = g;
|
||||
a_color.blue = b; a_color.alpha = a;
|
||||
SetLowColor(a_color);
|
||||
rgb_color color;
|
||||
color.red = r; color.green = g;
|
||||
color.blue = b; color.alpha = a;
|
||||
SetLowColor(color);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif // _VIEW_H
|
||||
|
@ -358,7 +358,6 @@ private:
|
||||
// message: B_MOUSE_UP, B_MOUSE_DOWN, B_MOUSE_MOVED
|
||||
void sendMessageUsingEventMask(int32 message, BPoint where);
|
||||
BView* sendMessageUsingEventMask2(BView* aView, int32 message, BPoint where);
|
||||
void sendPulse(BView *view);
|
||||
int32 findShortcut(uint32 key, uint32 modifiers);
|
||||
bool findHandler(BView* start, BHandler* handler);
|
||||
BView* findView(BView* aView, const char* viewName) const;
|
||||
@ -370,7 +369,6 @@ private:
|
||||
BView* findLastChild(BView *parent);
|
||||
bool handleKeyDown(const char key, uint32 modifiers);
|
||||
void handleActivation( bool active);
|
||||
void activateView(BView *aView, bool active);
|
||||
|
||||
void drawAllViews(BView* aView);
|
||||
void DoUpdate(BView* aView, BRect& area);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -787,7 +787,7 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target)
|
||||
|
||||
case B_PULSE:
|
||||
if (fPulseEnabled) {
|
||||
sendPulse(top_view);
|
||||
top_view->_Pulse();
|
||||
fLink->Flush();
|
||||
}
|
||||
break;
|
||||
@ -2353,7 +2353,7 @@ BWindow::BuildTopView()
|
||||
STRACE(("Calling setowner top_view = %p this = %p.\n",
|
||||
top_view, this));
|
||||
|
||||
top_view->setOwner(this);
|
||||
top_view->_SetOwner(this);
|
||||
|
||||
//we can't use AddChild() because this is the top_view
|
||||
top_view->attachView(top_view);
|
||||
@ -2414,20 +2414,7 @@ BWindow::handleActivation(bool active)
|
||||
|
||||
// recursively call hook function 'WindowActivated(bool)'
|
||||
// for all views attached to this window.
|
||||
activateView(top_view, active);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BWindow::activateView(BView *view, bool active)
|
||||
{
|
||||
view->WindowActivated(active);
|
||||
|
||||
BView *child = view->first_child;
|
||||
while (child) {
|
||||
activateView(child, active);
|
||||
child = child->next_sibling;
|
||||
}
|
||||
top_view->_Activate(active);
|
||||
}
|
||||
|
||||
|
||||
@ -2585,7 +2572,7 @@ BWindow::sendMessageUsingEventMask2(BView *view, int32 message, BPoint where)
|
||||
}
|
||||
|
||||
// Code for Event Masks
|
||||
BView *child = view->first_child;
|
||||
BView *child = view->fFirstChild;
|
||||
while (child) {
|
||||
// see if a BView registered for mouse events and it's not the current focus view
|
||||
if (view != fFocus
|
||||
@ -2623,7 +2610,7 @@ BWindow::sendMessageUsingEventMask2(BView *view, int32 message, BPoint where)
|
||||
// one of the children contains the point
|
||||
if (target)
|
||||
destView = target;
|
||||
child = child->next_sibling;
|
||||
child = child->fNextSibling;
|
||||
}
|
||||
|
||||
return destView;
|
||||
@ -2679,7 +2666,7 @@ BWindow::sendMessageUsingEventMask(int32 message, BPoint where)
|
||||
// TODO: Do research on mouse capturing -- maybe it has something to do
|
||||
// with this
|
||||
if (fFocus != destView)
|
||||
fFocus->MouseMoved( ConvertFromScreen(where), B_OUTSIDE_VIEW, dragMessage);
|
||||
fFocus->MouseMoved(ConvertFromScreen(where), B_OUTSIDE_VIEW, dragMessage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2693,21 +2680,6 @@ BWindow::ConvertToMessage(void *raw, int32 code)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BWindow::sendPulse(BView *view)
|
||||
{
|
||||
BView *child = view->first_child;
|
||||
|
||||
while (child) {
|
||||
if (child->Flags() & B_PULSE_NEEDED)
|
||||
child->Pulse();
|
||||
|
||||
sendPulse(child);
|
||||
child = child->next_sibling;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BWindow::findShortcut(uint32 key, uint32 modifiers)
|
||||
{
|
||||
@ -2730,13 +2702,13 @@ BWindow::findView(BView *view, int32 token)
|
||||
if (_get_object_token_(view) == token)
|
||||
return view;
|
||||
|
||||
BView *child = view->first_child;
|
||||
BView *child = view->fFirstChild;
|
||||
|
||||
while (child != NULL) {
|
||||
if ((view = findView(child, token)) != NULL)
|
||||
return view;
|
||||
|
||||
child = child->next_sibling;
|
||||
child = child->fNextSibling;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -2749,13 +2721,13 @@ BWindow::findView(BView *view, const char *name) const
|
||||
if (!strcmp(name, view->Name()))
|
||||
return view;
|
||||
|
||||
BView *child = view->first_child;
|
||||
BView *child = view->fFirstChild;
|
||||
|
||||
while (child != NULL) {
|
||||
if ((view = findView(child, name)) != NULL)
|
||||
return view;
|
||||
|
||||
child = child->next_sibling;
|
||||
child = child->fNextSibling;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -2765,16 +2737,16 @@ BWindow::findView(BView *view, const char *name) const
|
||||
BView *
|
||||
BWindow::findView(BView *view, BPoint point) const
|
||||
{
|
||||
if (view->Bounds().Contains(point) && !view->first_child)
|
||||
if (view->Bounds().Contains(point) && !view->fFirstChild)
|
||||
return view;
|
||||
|
||||
BView *child = view->first_child;
|
||||
BView *child = view->fFirstChild;
|
||||
|
||||
while (child != NULL) {
|
||||
if ((view = findView(child, point)) != NULL)
|
||||
return view;
|
||||
|
||||
child = child->next_sibling;
|
||||
child = child->fNextSibling;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -2792,18 +2764,18 @@ BWindow::findNextView(BView *focus, uint32 flags)
|
||||
// Ufff... this took me some time... this is the best form I've reached.
|
||||
// This algorithm searches the tree for BViews that accept focus.
|
||||
while (true) {
|
||||
if (nextFocus->first_child)
|
||||
nextFocus = nextFocus->first_child;
|
||||
else if (nextFocus->next_sibling)
|
||||
nextFocus = nextFocus->next_sibling;
|
||||
if (nextFocus->fFirstChild)
|
||||
nextFocus = nextFocus->fFirstChild;
|
||||
else if (nextFocus->fNextSibling)
|
||||
nextFocus = nextFocus->fNextSibling;
|
||||
else {
|
||||
while (!nextFocus->next_sibling && nextFocus->parent)
|
||||
nextFocus = nextFocus->parent;
|
||||
while (!nextFocus->fNextSibling && nextFocus->fParent)
|
||||
nextFocus = nextFocus->fParent;
|
||||
|
||||
if (nextFocus == top_view)
|
||||
nextFocus = nextFocus->first_child;
|
||||
nextFocus = nextFocus->fFirstChild;
|
||||
else
|
||||
nextFocus = nextFocus->next_sibling;
|
||||
nextFocus = nextFocus->fNextSibling;
|
||||
}
|
||||
|
||||
// It means that the hole tree has been searched and there is no
|
||||
@ -2826,16 +2798,16 @@ BWindow::findPrevView(BView *focus, uint32 flags)
|
||||
BView *view;
|
||||
if ((view = findLastChild(prevFocus)) != NULL)
|
||||
prevFocus = view;
|
||||
else if (prevFocus->prev_sibling)
|
||||
prevFocus = prevFocus->prev_sibling;
|
||||
else if (prevFocus->fPreviousSibling)
|
||||
prevFocus = prevFocus->fPreviousSibling;
|
||||
else {
|
||||
while (!prevFocus->prev_sibling && prevFocus->parent)
|
||||
prevFocus = prevFocus->parent;
|
||||
while (!prevFocus->fPreviousSibling && prevFocus->fParent)
|
||||
prevFocus = prevFocus->fParent;
|
||||
|
||||
if (prevFocus == top_view)
|
||||
prevFocus = findLastChild(prevFocus);
|
||||
else
|
||||
prevFocus = prevFocus->prev_sibling;
|
||||
prevFocus = prevFocus->fPreviousSibling;
|
||||
}
|
||||
|
||||
// It means that the hole tree has been searched and there is no
|
||||
@ -2852,12 +2824,12 @@ BWindow::findPrevView(BView *focus, uint32 flags)
|
||||
BView *
|
||||
BWindow::findLastChild(BView *parent)
|
||||
{
|
||||
BView *last = parent->first_child;
|
||||
BView *last = parent->fFirstChild;
|
||||
if (last == NULL)
|
||||
return NULL;
|
||||
|
||||
while (last->next_sibling)
|
||||
last = last->next_sibling;
|
||||
while (last->fNextSibling)
|
||||
last = last->fNextSibling;
|
||||
|
||||
return last;
|
||||
}
|
||||
@ -2902,7 +2874,7 @@ BWindow::DoUpdate(BView *view, BRect &area)
|
||||
aView->SetHighColor(c);*/
|
||||
}
|
||||
|
||||
BView *child = view->first_child;
|
||||
BView *child = view->fFirstChild;
|
||||
while (child) {
|
||||
if (area.Intersects(child->Frame())) {
|
||||
BRect newArea = area & child->Frame();
|
||||
@ -2910,7 +2882,7 @@ BWindow::DoUpdate(BView *view, BRect &area)
|
||||
|
||||
DoUpdate(child, newArea);
|
||||
}
|
||||
child = child->next_sibling;
|
||||
child = child->fNextSibling;
|
||||
}
|
||||
|
||||
if (view->Flags() & B_WILL_DRAW) {
|
||||
|
Loading…
Reference in New Issue
Block a user