diff --git a/headers/os/app/Looper.h b/headers/os/app/Looper.h index 5d038ae645..e1def02c6a 100644 --- a/headers/os/app/Looper.h +++ b/headers/os/app/Looper.h @@ -181,13 +181,12 @@ static status_t _task0_(void* arg); BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT); virtual BMessage* ConvertToMessage(void* raw, int32 code); virtual void task_looper(); - void do_quit_requested(BMessage* msg); + void _QuitRequested(BMessage* msg); bool AssertLocked() const; - BHandler* top_level_filter(BMessage* msg, BHandler* t); - BHandler* handler_only_filter(BMessage* msg, BHandler* t); - BHandler* apply_filters( BList* list, - BMessage* msg, - BHandler* target); + BHandler* _TopLevelFilter(BMessage* msg, BHandler* target); + BHandler* _HandlerFilter(BMessage* msg, BHandler* target); + BHandler* _ApplyFilters(BList* list, BMessage* msg, + BHandler* target); void check_lock(); BHandler* resolve_specifier(BHandler* target, BMessage* msg); void UnlockFully(); diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h index c17cb25d98..ad20e57929 100644 --- a/headers/os/interface/View.h +++ b/headers/os/interface/View.h @@ -1,30 +1,10 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: View.h -// Author: Erik Jaesler (erik@cgsoftware.com) -// Description: BView is the base class for all views (clipped regions -// within a window). -//------------------------------------------------------------------------------ - +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Erik Jaesler (erik@cgsoftware.com) + */ #ifndef _VIEW_H #define _VIEW_H @@ -36,14 +16,14 @@ #include -// view definitions ------------------------------------------------------------ - +// mouse button enum { B_PRIMARY_MOUSE_BUTTON = 0x01, B_SECONDARY_MOUSE_BUTTON = 0x02, B_TERTIARY_MOUSE_BUTTON = 0x04 }; +// mouse transit enum { B_ENTERED_VIEW = 0, B_INSIDE_VIEW, @@ -51,11 +31,13 @@ enum { B_OUTSIDE_VIEW }; +// event mask enum { B_POINTER_EVENTS = 0x00000001, B_KEYBOARD_EVENTS = 0x00000002 }; +// event mask options enum { B_LOCK_WINDOW_FOCUS = 0x00000001, B_SUSPEND_VIEW_FOCUS = 0x00000002, @@ -67,6 +49,7 @@ enum { B_TRACK_RECT_CORNER }; +// set font mask enum { B_FONT_FAMILY_AND_STYLE = 0x00000001, B_FONT_SIZE = 0x00000002, @@ -79,6 +62,7 @@ enum { B_FONT_ALL = 0x000000FF }; +// view flags const uint32 B_FULL_UPDATE_ON_RESIZE = 0x80000000UL; /* 31 */ const uint32 _B_RESERVED1_ = 0x40000000UL; /* 30 */ const uint32 B_WILL_DRAW = 0x20000000UL; /* 29 */ @@ -90,12 +74,10 @@ const uint32 B_SUBPIXEL_PRECISE = 0x01000000UL; /* 24 */ const uint32 B_DRAW_ON_CHILDREN = 0x00800000UL; /* 23 */ const uint32 B_INPUT_METHOD_AWARE = 0x00400000UL; /* 23 */ const uint32 _B_RESERVED7_ = 0x00200000UL; /* 22 */ -/* -#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE|_B_RESERVED1_|B_WILL_DRAW|\ - B_PULSE_NEEDED|B_NAVIGABLE_JUMP|B_FRAME_EVENTS|B_NAVIGABLE|\ - B_SUBPIXEL_PRECISE|B_DRAW_ON_CHILDREN|B_INPUT_METHOD_AWARE|_B_RESERVED7_) -*/ -#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE|_B_RESERVED1_|B_WILL_DRAW|B_PULSE_NEEDED|B_NAVIGABLE_JUMP|B_FRAME_EVENTS|B_NAVIGABLE|B_SUBPIXEL_PRECISE|B_DRAW_ON_CHILDREN|B_INPUT_METHOD_AWARE|_B_RESERVED7_) + +#define _RESIZE_MASK_ ~(B_FULL_UPDATE_ON_RESIZE | _B_RESERVED1_ | B_WILL_DRAW \ + | B_PULSE_NEEDED | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE \ + | B_SUBPIXEL_PRECISE | B_DRAW_ON_CHILDREN | B_INPUT_METHOD_AWARE | _B_RESERVED7_) const uint32 _VIEW_TOP_ = 1UL; const uint32 _VIEW_LEFT_ = 2UL; @@ -107,18 +89,18 @@ inline uint32 _rule_(uint32 r1, uint32 r2, uint32 r3, uint32 r4) { return ((r1 << 12) | (r2 << 8) | (r3 << 4) | r4); } #define B_FOLLOW_NONE 0 -#define B_FOLLOW_ALL_SIDES _rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, _VIEW_RIGHT_) -#define B_FOLLOW_ALL B_FOLLOW_ALL_SIDES +#define B_FOLLOW_ALL_SIDES _rule_(_VIEW_TOP_, _VIEW_LEFT_, _VIEW_BOTTOM_, _VIEW_RIGHT_) +#define B_FOLLOW_ALL B_FOLLOW_ALL_SIDES -#define B_FOLLOW_LEFT _rule_(0, _VIEW_LEFT_, 0, _VIEW_LEFT_) -#define B_FOLLOW_RIGHT _rule_(0, _VIEW_RIGHT_, 0, _VIEW_RIGHT_) -#define B_FOLLOW_LEFT_RIGHT _rule_(0, _VIEW_LEFT_, 0, _VIEW_RIGHT_) -#define B_FOLLOW_H_CENTER _rule_(0, _VIEW_CENTER_, 0, _VIEW_CENTER_) +#define B_FOLLOW_LEFT _rule_(0, _VIEW_LEFT_, 0, _VIEW_LEFT_) +#define B_FOLLOW_RIGHT _rule_(0, _VIEW_RIGHT_, 0, _VIEW_RIGHT_) +#define B_FOLLOW_LEFT_RIGHT _rule_(0, _VIEW_LEFT_, 0, _VIEW_RIGHT_) +#define B_FOLLOW_H_CENTER _rule_(0, _VIEW_CENTER_, 0, _VIEW_CENTER_) -#define B_FOLLOW_TOP _rule_(_VIEW_TOP_, 0, _VIEW_TOP_, 0) -#define B_FOLLOW_BOTTOM _rule_(_VIEW_BOTTOM_, 0, _VIEW_BOTTOM_, 0) -#define B_FOLLOW_TOP_BOTTOM _rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0) -#define B_FOLLOW_V_CENTER _rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0) +#define B_FOLLOW_TOP _rule_(_VIEW_TOP_, 0, _VIEW_TOP_, 0) +#define B_FOLLOW_BOTTOM _rule_(_VIEW_BOTTOM_, 0, _VIEW_BOTTOM_, 0) +#define B_FOLLOW_TOP_BOTTOM _rule_(_VIEW_TOP_, 0, _VIEW_BOTTOM_, 0) +#define B_FOLLOW_V_CENTER _rule_(_VIEW_CENTER_, 0, _VIEW_CENTER_, 0) class BBitmap; class BCursor; @@ -166,7 +148,7 @@ public: BView* PreviousSibling() const; bool RemoveSelf(); - BWindow *Window() const; + BWindow* Window() const; virtual void Draw(BRect updateRect); virtual void MouseDown(BPoint where); @@ -514,11 +496,10 @@ public: virtual void DrawAfterChildren(BRect r); - // added by OBOS - DO NOT use this when programming BeOS R5!!! float Scale() const; + // new for Haiku private: - friend class BScrollBar; friend class BWindow; friend class BBitmap; @@ -533,8 +514,6 @@ private: virtual void _ReservedView6(); virtual void _ReservedView7(); virtual void _ReservedView8(); - -#if !_PR3_COMPATIBLE_ virtual void _ReservedView9(); virtual void _ReservedView10(); virtual void _ReservedView11(); @@ -543,57 +522,52 @@ private: virtual void _ReservedView14(); virtual void _ReservedView15(); virtual void _ReservedView16(); -#endif - BView(const BView&); - BView& operator=(const BView&); + BView(const BView&); + BView& operator=(const BView&); - void InitData(BRect f, const char* name, uint32 rs, uint32 fl); - status_t ArchiveChildren(BMessage* data, bool deep) const; - status_t UnarchiveChildren(BMessage* data, BWindow* w = NULL); - status_t setViewImage(const BBitmap* bitmap,BRect srcRect, BRect dstRect, - uint32 followFlags, uint32 options); - void BeginPicture_pr(BPicture* a_picture, BRect r); - void SetPattern(pattern pat); - void DoBezier(int32 gr, BPoint* controlPoints, pattern p); - void DoShape(int32 gr, BShape* shape, pattern p); - void DoPictureClip(BPicture* picture, BPoint where, bool invert, - bool sync); + void _InitData(BRect frame, const char* name, uint32 resizeMask, + uint32 flags); + status_t _SetViewImage(const BBitmap* bitmap,BRect srcRect, + BRect dstRect, uint32 followFlags, uint32 options); + void DoBezier(int32 gr, BPoint* controlPoints, pattern p); + void DoShape(int32 gr, BShape* shape, pattern p); + void DoPictureClip(BPicture* picture, BPoint where, bool invert, + bool sync); - bool do_owner_check() const; - void _SetOwner(BWindow* newOwner); - void check_lock() const; - void check_lock_no_pick() const; - void movesize(uint32 code, int32 h, int32 v); - void handle_tick(); - char *test_area(int32 length); - void removeCommArray(); - _array_hdr_ *new_comm_array(int32 cnt); - void SetScroller(BScrollBar* sb); - void UnsetScroller(BScrollBar* sb); - void RealScrollTo(BPoint); - void fetch_font(); - uchar font_encoding() const; - BShelf* shelf() const; - void set_shelf(BShelf* shelf); + bool do_owner_check() const; + bool do_owner_check_no_pick() const; + void check_lock() const; + void check_lock_no_pick() const; - void _Activate(bool state); - void _Pulse(); + void _SetOwner(BWindow* newOwner); + void handle_tick(); + char* test_area(int32 length); + void removeCommArray(); + void SetScroller(BScrollBar* sb); + void UnsetScroller(BScrollBar* sb); + void RealScrollTo(BPoint); + void fetch_font(); + uchar font_encoding() const; + BShelf* shelf() const; + void set_shelf(BShelf* shelf); - void _UpdateStateForRemove(); - void _UpdatePattern(::pattern pattern); + void _Activate(bool state); + void _Attach(); + void _Detach(); + void _Draw(BRect updateRect); + void _Pulse(); - void deleteView( BView* aView); - bool do_owner_check_no_pick() const; - bool attachView( BView *aView ); - bool _AddChildToList(BView* child, BView* before = NULL); - bool _RemoveChildFromList(BView* child); - void callAttachHooks( BView *aView ); - void callDetachHooks( BView *aView ); + void _UpdateStateForRemove(); + void _UpdatePattern(::pattern pattern); + + bool _CreateSelf(); + bool _AddChildToList(BView* child, BView* before = NULL); + bool _RemoveChildFromList(BView* child); // Debugging methods - void PrintToStream(); - void PrintTree(); + void PrintToStream(); + void PrintTree(); int32 server_token; uint32 fFlags; @@ -605,28 +579,23 @@ private: BView* fFirstChild; int16 fShowLevel; - bool top_level_view; // used + bool fTopLevelView; bool fNoISInteraction; - BPicture* cpicture; // used - _array_data_* comm; // used + BPicture* cpicture; + _array_data_* comm; - BScrollBar* fVerScroller; // used - BScrollBar* fHorScroller; // used + BScrollBar* fVerScroller; + BScrollBar* fHorScroller; bool f_is_printing; - bool _unused_bool0; // was: attached; + bool _unused_bool0; bool _unused_bool1; bool _unused_bool2; - 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 + uint32 _reserved[9]; }; diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index 99190bf84f..89f8f96f6a 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -1,32 +1,14 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2005, Haiku -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: Window.h -// Author: Adrian Oanca (adioanca@gmail.com) -// Description: BWindow is the base class for all windows (graphic areas -// displayed on-screen). -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * Adrian Oanca + */ #ifndef _WINDOW_H #define _WINDOW_H + #include #include #include @@ -35,13 +17,19 @@ #include #include +class BButton; +class BMenuBar; +class BMenuItem; +class BMessage; +class BMessageRunner; +class BMessenger; +class BView; + namespace BPrivate { class PortLink; }; -// window definitions ---------------------------------------------------------- - enum window_type { B_UNTYPED_WINDOW = 0, B_TITLED_WINDOW = 1, @@ -51,8 +39,6 @@ enum window_type { B_FLOATING_WINDOW = 21 }; -//---------------------------------------------------------------- - enum window_look { B_BORDERED_WINDOW_LOOK = 20, B_NO_BORDER_WINDOW_LOOK = 19, @@ -62,8 +48,6 @@ enum window_look { B_FLOATING_WINDOW_LOOK = 7 }; -//---------------------------------------------------------------- - enum window_feel { B_NORMAL_WINDOW_FEEL = 0, B_MODAL_SUBSET_WINDOW_FEEL = 2, @@ -74,15 +58,12 @@ enum window_feel { B_FLOATING_ALL_WINDOW_FEEL = 6 }; -//---------------------------------------------------------------- - enum window_alignment { B_BYTE_ALIGNMENT = 0, B_PIXEL_ALIGNMENT = 1 }; -//---------------------------------------------------------------- - +// window flags enum { B_NOT_MOVABLE = 0x00000001, B_NOT_CLOSABLE = 0x00000020, @@ -106,19 +87,6 @@ enum { //---------------------------------------------------------------- -class BButton; -class BMenuBar; -class BMenuItem; -class BMessage; -class BMessageRunner; -class BMessenger; -class BView; - -struct message; -struct _cmd_key_; -class ViewAttr; - -// BWindow class --------------------------------------------------------------- class BWindow : public BLooper { public: BWindow(BRect frame, const char* title, @@ -256,7 +224,6 @@ public: virtual bool QuitRequested(); virtual thread_id Run(); -// Private or reserved --------------------------------------------------------- private: typedef BLooper inherited; class Shortcut; @@ -292,16 +259,9 @@ private: window_look look, window_feel feel, uint32 flags, uint32 workspace, int32 bitmapToken = -1); - status_t ArchiveChildren(BMessage* data, bool deep) const; - status_t UnarchiveChildren(BMessage* data); void BitmapClose(); // to be implemented virtual void task_looper(); - void prepareView(BView* aView); - void attachView(BView* aView); - void detachView(BView* aView); - void handle_activate(BMessage* an_event); - void do_menu_event(BMessage* an_event); virtual BMessage *ConvertToMessage(void* raw, int32 code); void AddShortcut(uint32 key, uint32 modifiers, @@ -310,7 +270,7 @@ private: bool _DistributeMessage(BMessage* message); bool InUpdate(); - void DequeueAll(); + void _DequeueAll(); window_type _ComposeType(window_look look, window_feel feel) const; void _DecomposeType(window_type type, @@ -320,8 +280,8 @@ private: void SetIsFilePanel(bool yes); bool IsFilePanel() const; - void BuildTopView(); - void setFocus(BView *focusView, bool notifyIputServer = false); + void _CreateTopView(); + void _SetFocus(BView *focusView, bool notifyIputServer = false); Shortcut* _FindShortcut(uint32 key, uint32 modifiers); BView* _FindView(BView* view, BPoint point) const; @@ -332,18 +292,11 @@ private: BView* _FindPreviousNavigable(BView *focus, uint32 flags); bool _HandleKeyDown(char key, uint32 modifiers); void _KeyboardNavigation(); - void handleActivation(bool active); - void drawAllViews(BView* view); void DoUpdate(BView* view, BRect& area); - // Debug + // Debug (TODO: to be removed) void PrintToStream() const; - - // 3 deprecated calls - //void AddFloater(BWindow* a_floating_window); - //void RemoveFloater(BWindow* a_floating_window); - //window_type WindowType() const; private: char *fTitle; @@ -353,7 +306,6 @@ private: short fShowLevel; uint32 fFlags; - uint32 _unused0[2]; BView *fTopView; BView *fFocus; BView *fLastMouseMovedView; @@ -378,17 +330,13 @@ private: float fMaxWidth; BRect fFrame; window_look fLook; - ViewAttr *fCurDrawViewState; // not yet used window_feel fFeel; int32 fLastViewToken; BPrivate::PortLink *fLink; BMessageRunner *fPulseRunner; BRect fCurrentFrame; // not yet used - uint32 _reserved[2]; // was 8 -#if !_PR3_COMPATIBLE_ - uint32 _more_reserved[4]; -#endif + uint32 _reserved[9]; }; #endif // _WINDOW_H diff --git a/src/kits/app/Looper.cpp b/src/kits/app/Looper.cpp index 0f8fcb6789..197085a9df 100644 --- a/src/kits/app/Looper.cpp +++ b/src/kits/app/Looper.cpp @@ -286,7 +286,7 @@ BLooper::DispatchMessage(BMessage *message, BHandler *handler) case B_QUIT_REQUESTED: if (handler == this) { - do_quit_requested(message); + _QuitRequested(message); break; } @@ -1313,8 +1313,8 @@ BLooper::task_looper() if (handler) { // Do filtering - handler = top_level_filter(fLastMessage, handler); - PRINT(("LOOPER: top_level_filter(): %p\n", handler)); + handler = _TopLevelFilter(fLastMessage, handler); + PRINT(("LOOPER: _TopLevelFilter(): %p\n", handler)); if (handler && handler->Looper() == this) DispatchMessage(fLastMessage, handler); } @@ -1341,7 +1341,7 @@ BLooper::task_looper() void -BLooper::do_quit_requested(BMessage *msg) +BLooper::_QuitRequested(BMessage *msg) { bool isQuitting = QuitRequested(); @@ -1376,18 +1376,18 @@ BLooper::AssertLocked() const BHandler * -BLooper::top_level_filter(BMessage* msg, BHandler* target) +BLooper::_TopLevelFilter(BMessage* msg, BHandler* target) { if (msg) { // Apply the common filters first - target = apply_filters(CommonFilterList(), msg, target); + target = _ApplyFilters(CommonFilterList(), msg, target); if (target) { if (target->Looper() != this) { debugger("Targeted handler does not belong to the looper."); target = NULL; } else { // Now apply handler-specific filters - target = handler_only_filter(msg, target); + target = _HandlerFilter(msg, target); } } } @@ -1397,15 +1397,16 @@ BLooper::top_level_filter(BMessage* msg, BHandler* target) BHandler * -BLooper::handler_only_filter(BMessage* msg, BHandler* target) +BLooper::_HandlerFilter(BMessage* msg, BHandler* target) { // Keep running filters until our handler is NULL, or until the filtering // handler returns itself as the designated handler - BHandler* oldTarget = NULL; - while (target != NULL && target != oldTarget) { - oldTarget = target; - target = apply_filters(oldTarget->FilterList(), msg, oldTarget); - if (target && (target->Looper() != this)) { + BHandler* previousTarget = NULL; + while (target != NULL && target != previousTarget) { + previousTarget = target; + + target = _ApplyFilters(target->FilterList(), msg, target); + if (target != NULL && target->Looper() != this) { debugger("Targeted handler does not belong to the looper."); target = NULL; } @@ -1416,7 +1417,7 @@ BLooper::handler_only_filter(BMessage* msg, BHandler* target) BHandler * -BLooper::apply_filters(BList* list, BMessage* msg, BHandler* target) +BLooper::_ApplyFilters(BList* list, BMessage* msg, BHandler* target) { // This is where the action is! // Check the parameters @@ -1433,9 +1434,9 @@ BLooper::apply_filters(BList* list, BMessage* msg, BHandler* target) // Check delivery conditions message_delivery delivery = filter->MessageDelivery(); bool dropped = msg->WasDropped(); - if (delivery == B_ANY_DELIVERY || - ((delivery == B_DROPPED_DELIVERY) && dropped) || - ((delivery == B_PROGRAMMED_DELIVERY) && !dropped)) { + if (delivery == B_ANY_DELIVERY + || (delivery == B_DROPPED_DELIVERY && dropped) + || (delivery == B_PROGRAMMED_DELIVERY && !dropped)) { // Check source conditions message_source source = filter->MessageSource(); bool remote = msg->IsSourceRemote(); diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index d01463c5cf..dfa156195a 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -311,7 +311,7 @@ ViewState::UpdateFrom(BPrivate::PortLink &link) BView::BView(BRect frame, const char *name, uint32 resizingMode, uint32 flags) : BHandler(name) { - InitData(frame, name, resizingMode, flags); + _InitData(frame, name, resizingMode, flags); } @@ -329,7 +329,7 @@ BView::BView(BMessage *archive) if (archive->FindInt32("_flags", (int32 *)&flags) != B_OK) flags = 0; - InitData(frame, Name(), resizingMode, flags); + _InitData(frame, Name(), resizingMode, flags); font_family family; font_style style; @@ -377,8 +377,8 @@ BView::BView(BMessage *archive) SetPenSize(penSize); BPoint penLocation; - if ( archive->FindPoint("_ploc", &penLocation) == B_OK ) - MovePenTo( penLocation ); + if (archive->FindPoint("_ploc", &penLocation) == B_OK) + MovePenTo(penLocation); int16 lineCap; int16 lineJoin; @@ -526,27 +526,24 @@ BView::~BView() // TODO: see about BShelf! must I delete it here? is it deleted by the window? - // we also delete all its childern + // we also delete all our children BView *child = fFirstChild; while (child) { BView *nextChild = child->fNextSibling; - deleteView(child); + delete child; child = nextChild; } if (fVerScroller) - fVerScroller->SetTarget((BView *)NULL); - + fVerScroller->SetTarget((BView*)NULL); if (fHorScroller) - fHorScroller->SetTarget((BView *)NULL); + fHorScroller->SetTarget((BView*)NULL); SetName(NULL); - delete fPermanentState; delete fState; - free(pr_state); } @@ -3025,7 +3022,7 @@ void BView::SetViewBitmap(const BBitmap *bitmap, BRect srcRect, BRect dstRect, uint32 followFlags, uint32 options) { - setViewImage(bitmap, srcRect, dstRect, followFlags, options); + _SetViewImage(bitmap, srcRect, dstRect, followFlags, options); } @@ -3038,14 +3035,14 @@ BView::SetViewBitmap(const BBitmap *bitmap, uint32 followFlags, uint32 options) rect.OffsetTo(0, 0); - setViewImage(bitmap, rect, rect, followFlags, options); + _SetViewImage(bitmap, rect, rect, followFlags, options); } void BView::ClearViewBitmap() { - setViewImage(NULL, BRect(), BRect(), 0, 0); + _SetViewImage(NULL, BRect(), BRect(), 0, 0); } @@ -3053,7 +3050,7 @@ status_t BView::SetViewOverlay(const BBitmap *overlay, BRect srcRect, BRect dstRect, rgb_color *colorKey, uint32 followFlags, uint32 options) { - status_t err = setViewImage(overlay, srcRect, dstRect, followFlags, + status_t err = _SetViewImage(overlay, srcRect, dstRect, followFlags, options | 0x4); // TODO: Incomplete? @@ -3075,7 +3072,7 @@ BView::SetViewOverlay(const BBitmap *overlay, rgb_color *colorKey, rect.OffsetTo(0, 0); - status_t err = setViewImage(overlay, rect, rect, followFlags, + status_t err = _SetViewImage(overlay, rect, rect, followFlags, options | 0x4); // TODO: Incomplete? @@ -3090,7 +3087,7 @@ BView::SetViewOverlay(const BBitmap *overlay, rgb_color *colorKey, void BView::ClearViewOverlay() { - setViewImage(NULL, BRect(), BRect(), 0, 0); + _SetViewImage(NULL, BRect(), BRect(), 0, 0); } @@ -3271,10 +3268,10 @@ BView::AddChild(BView *child, BView *before) if (child->fParent != NULL) debugger("AddChild failed - the view already has a parent."); - bool lockedByAddChild = false; + bool lockedOwner = false; if (fOwner && !fOwner->IsLocked()) { fOwner->Lock(); - lockedByAddChild = true; + lockedOwner = true; } if (!_AddChildToList(child, before)) @@ -3287,16 +3284,12 @@ BView::AddChild(BView *child, BView *before) Name(), child ? child->Name() : "NULL", before ? before->Name() : "NULL")); child->_SetOwner(fOwner); - attachView(child); - callAttachHooks(child); + child->_CreateSelf(); + child->_Attach(); - if (lockedByAddChild) + if (lockedOwner) fOwner->Unlock(); } - -// BVTRACE; -// PrintTree(); -// PrintToStream(); } @@ -3366,6 +3359,7 @@ BView::RemoveSelf() if (fOwner) { _UpdateStateForRemove(); + _Detach(); } if (!fParent || !fParent->_RemoveChildFromList(this)) @@ -3381,6 +3375,9 @@ BView::RemoveSelf() // make sure our owner doesn't need us anymore + if (fOwner->CurrentFocus() == this) + MakeFocus(false); + if (fOwner->fDefaultButton == this) fOwner->SetDefaultButton(NULL); @@ -3393,8 +3390,6 @@ BView::RemoveSelf() if (fOwner->fLastViewToken == _get_object_token_(this)) fOwner->fLastViewToken = B_NULL_TOKEN; - callDetachHooks(this); - BWindow *owner = fOwner; _SetOwner(NULL); @@ -3410,7 +3405,7 @@ BView::RemoveSelf() BView * BView::Parent() const { - if (fParent && fParent->top_level_view) + if (fParent && fParent->fTopLevelView) return NULL; return fParent; @@ -3739,7 +3734,7 @@ BView::Perform(perform_code d, void* arg) void -BView::InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flags) +BView::_InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flags) { // Info: The name of the view is set by BHandler constructor @@ -3763,7 +3758,7 @@ BView::InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flags fFirstChild = NULL; fShowLevel = 0; - top_level_view = false; + fTopLevelView = false; cpicture = NULL; comm = NULL; @@ -3773,12 +3768,10 @@ BView::InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flags f_is_printing = false; - fPermanentState = NULL; fState = new BPrivate::ViewState; fBounds = frame.OffsetToCopy(B_ORIGIN); fShelf = NULL; - pr_state = NULL; fEventMask = 0; fEventOptions = 0; @@ -3819,7 +3812,7 @@ BView::_SetOwner(BWindow *newOwner) if (fShelf) newOwner->AddHandler(fShelf); - if (top_level_view) + if (fTopLevelView) SetNextHandler(newOwner); else SetNextHandler(fParent); @@ -3857,21 +3850,6 @@ BView::DoPictureClip(BPicture *picture, BPoint where, } -void -BView::callDetachHooks(BView *view) -{ - view->DetachedFromWindow(); - - BView *child = view->fFirstChild; - while (child != NULL) { - view->callDetachHooks(child); - child = child->fNextSibling; - } - - view->AllDetached(); -} - - bool BView::_RemoveChildFromList(BView* child) { @@ -3942,84 +3920,131 @@ BView::_AddChildToList(BView* view, BView* before) return true; } -void -BView::callAttachHooks(BView *view) -{ - view->AttachedToWindow(); - - BView *child = view->fFirstChild; - while (child != NULL) { - view->callAttachHooks(child); - child = child->fNextSibling; - } - - view->AllAttached(); -} - +/*! \brief Creates the server counterpart of this view. + This is only done for views that are part of the view hierarchy, ie. when + they are attached to a window. + RemoveSelf() deletes the server object again. +*/ bool -BView::attachView(BView *view) +BView::_CreateSelf() { // AS_LAYER_CREATE & AS_LAYER_CREATE_ROOT do not use the // current view mechanism via check_lock() - the token // of the view and its parent are both send to the server. - if (view->top_level_view) + if (fTopLevelView) fOwner->fLink->StartMessage(AS_LAYER_CREATE_ROOT); else fOwner->fLink->StartMessage(AS_LAYER_CREATE); - fOwner->fLink->Attach(_get_object_token_(view)); - fOwner->fLink->AttachString(view->Name()); - // send view's frame. the next line replaces: fOwner->fLink->Attach(view->Frame()); - fOwner->fLink->Attach(view->fBounds.OffsetToCopy(view->fParentOffset)); - fOwner->fLink->Attach(view->ResizingMode()); - fOwner->fLink->Attach(view->fEventMask); - fOwner->fLink->Attach(view->fEventOptions); - fOwner->fLink->Attach(view->Flags()); - fOwner->fLink->Attach(view->IsHidden(view)); - fOwner->fLink->Attach(view->fState->view_color); fOwner->fLink->Attach(_get_object_token_(this)); + fOwner->fLink->AttachString(Name()); + fOwner->fLink->Attach(Frame()); + fOwner->fLink->Attach(ResizingMode()); + fOwner->fLink->Attach(fEventMask); + fOwner->fLink->Attach(fEventOptions); + fOwner->fLink->Attach(Flags()); + fOwner->fLink->Attach(IsHidden(this)); + fOwner->fLink->Attach(fState->view_color); + if (fTopLevelView) + fOwner->fLink->Attach(B_NULL_TOKEN); + else + fOwner->fLink->Attach(_get_object_token_(fParent)); fOwner->fLink->Flush(); - view->do_owner_check(); - view->fState->UpdateServerState(*fOwner->fLink); + do_owner_check(); + fState->UpdateServerState(*fOwner->fLink); - // we attach all its children + // we create all its children, too - BView *child = view->fFirstChild; - while (child != NULL) { - view->attachView(child); - child = child->fNextSibling; + for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) { + child->_CreateSelf(); } fOwner->fLink->Flush(); - return true; } -void -BView::deleteView(BView* view) -{ - BView *child = view->fFirstChild; - while (child != NULL) { - BView *nextChild = child->fNextSibling; - deleteView(child); - child = nextChild; - } - - delete view; -} - - void BView::_Activate(bool active) { WindowActivated(active); - for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) + for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) { child->_Activate(active); + } +} + + +void +BView::_Attach() +{ + AttachedToWindow(); + + for (BView* child = fFirstChild; child != NULL; child = child->fNextSibling) { + child->_Attach(); + } + + AllAttached(); +} + + +void +BView::_Detach() +{ + DetachedFromWindow(); + + for (BView* child = fFirstChild; child != NULL; child = child->fNextSibling) { + child->_Detach(); + } + + AllDetached(); +} + + +void +BView::_Draw(BRect updateRect) +{ + if (IsHidden(this)) + return; + + check_lock(); + + if (Flags() & B_WILL_DRAW) { + // TODO: make states robust + PushState(); + Draw(updateRect); + PopState(); + } else { + // The code below is certainly not correct, because + // it redoes what the app_server already did + // Find out what happens on R5 if a view has ViewColor() = + // B_TRANSPARENT_COLOR but not B_WILL_DRAW +/* rgb_color c = aView->HighColor(); + aView->SetHighColor(aView->ViewColor()); + aView->FillRect(aView->Bounds(), B_SOLID_HIGH); + aView->SetHighColor(c);*/ + } + + for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) { + BRect rect = child->Frame(); + if (!updateRect.Intersects(rect)) + continue; + + // get new update rect in child coordinates + rect = updateRect & rect; + child->ConvertFromParent(&rect); + + child->_Draw(rect); + } + + if (Flags() & B_WILL_DRAW) { + PushState(); + DrawAfterChildren(updateRect); + PopState(); + } } @@ -4029,8 +4054,9 @@ BView::_Pulse() if (Flags() & B_PULSE_NEEDED) Pulse(); - for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) + for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) { child->_Pulse(); + } } @@ -4046,10 +4072,8 @@ BView::_UpdateStateForRemove() // update children as well - BView *child = fFirstChild; - while (child != NULL) { + for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) { child->_UpdateStateForRemove(); - child = child->fNextSibling; } } @@ -4057,8 +4081,19 @@ BView::_UpdateStateForRemove() inline void BView::_UpdatePattern(::pattern pattern) { - if (!fState->IsValid(B_VIEW_PATTERN_BIT) || pattern != fState->pattern) - SetPattern(pattern); + if (fState->IsValid(B_VIEW_PATTERN_BIT) && pattern == fState->pattern) + return; + + if (fOwner) { + check_lock(); + + fOwner->fLink->StartMessage(AS_LAYER_SET_PATTERN); + fOwner->fLink->Attach< ::pattern>(pattern); + + fState->valid_flags |= B_VIEW_PATTERN_BIT; + } + + fState->pattern = pattern; } @@ -4078,7 +4113,7 @@ BView::set_shelf(BShelf *shelf) status_t -BView::setViewImage(const BBitmap *bitmap, BRect srcRect, +BView::_SetViewImage(const BBitmap* bitmap, BRect srcRect, BRect dstRect, uint32 followFlags, uint32 options) { if (!do_owner_check()) @@ -4107,25 +4142,6 @@ BView::setViewImage(const BBitmap *bitmap, BRect srcRect, } -void -BView::SetPattern(::pattern pattern) -{ - if (fState->IsValid(B_VIEW_PATTERN_BIT) && pattern == fState->pattern) - return; - - if (fOwner) { - check_lock(); - - fOwner->fLink->StartMessage(AS_LAYER_SET_PATTERN); - fOwner->fLink->Attach< ::pattern>(pattern); - - fState->valid_flags |= B_VIEW_PATTERN_BIT; - } - - fState->pattern = pattern; -} - - bool BView::do_owner_check() const { @@ -4267,7 +4283,7 @@ BView::PrintToStream() fParentOffset.x, fParentOffset.y, fBounds.left, fBounds.top, fBounds.right, fBounds.bottom, fShowLevel, - top_level_view? "YES" : "NO", + fTopLevelView ? "YES" : "NO", cpicture? "YES" : "NULL", fVerScroller? "YES" : "NULL", fHorScroller? "YES" : "NULL", diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 7b8b5384fe..7a2d80b815 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -9,34 +9,25 @@ */ -#include -#include -#include -#include -#include #include -#include -#include +#include +#include #include #include -#include -#include -#include #include #include +#include #include -#include +#include +#include +#include -#include #include +#include +#include #include #include #include -#include - -#ifdef USING_MESSAGE4 -#include -#endif #include #include @@ -735,43 +726,52 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) } case B_WINDOW_ACTIVATED: - { - bool active; - if (msg->FindBool("active", &active) == B_OK) { - fActive = active; - handleActivation(active); - } + if (target == this) { + bool active; + if (msg->FindBool("active", &active) == B_OK + && active != fActive) { + fActive = active; + WindowActivated(active); + + // call hook function 'WindowActivated(bool)' for all + // views attached to this window. + fTopView->_Activate(active); + } + } else + target->MessageReceived(msg); break; - } case B_SCREEN_CHANGED: - { - BRect frame; - uint32 mode; - if (msg->FindRect("frame", &frame) == B_OK - && msg->FindInt32("mode", (int32 *)&mode) == B_OK) - ScreenChanged(frame, (color_space)mode); + if (target == this) { + BRect frame; + uint32 mode; + if (msg->FindRect("frame", &frame) == B_OK + && msg->FindInt32("mode", (int32 *)&mode) == B_OK) + ScreenChanged(frame, (color_space)mode); + } else + target->MessageReceived(msg); break; - } case B_WORKSPACE_ACTIVATED: - { - uint32 workspace; - bool active; - if (msg->FindInt32("workspace", (int32 *)&workspace) == B_OK - && msg->FindBool("active", &active) == B_OK) - WorkspaceActivated(workspace, active); + if (target == this) { + uint32 workspace; + bool active; + if (msg->FindInt32("workspace", (int32 *)&workspace) == B_OK + && msg->FindBool("active", &active) == B_OK) + WorkspaceActivated(workspace, active); + } else + target->MessageReceived(msg); break; - } case B_WORKSPACES_CHANGED: - { - uint32 oldWorkspace, newWorkspace; - if (msg->FindInt32("old", (int32 *)&oldWorkspace) == B_OK - && msg->FindInt32("new", (int32 *)&newWorkspace) == B_OK) - WorkspacesChanged(oldWorkspace, newWorkspace); + if (target == this) { + uint32 oldWorkspace, newWorkspace; + if (msg->FindInt32("old", (int32 *)&oldWorkspace) == B_OK + && msg->FindInt32("new", (int32 *)&newWorkspace) == B_OK) + WorkspacesChanged(oldWorkspace, newWorkspace); + } else + target->MessageReceived(msg); break; - } case B_KEY_DOWN: { @@ -782,12 +782,14 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) msg->FindInt32("raw_char", &rawChar); msg->FindString("bytes", &string); -// TODO: USE target !!!! + // TODO: cannot use "string" here if we support having different + // font encoding per view (it's supposed to be converted by + // _HandleKeyDown() one day) if (!_HandleKeyDown(string[0], (uint32)modifiers)) { - if (fFocus) - fFocus->KeyDown(string, strlen(string)); + if (BView* view = dynamic_cast(target)) + view->KeyDown(string, strlen(string)); else - printf("Adi: No Focus\n"); + target->MessageReceived(msg); } break; } @@ -797,24 +799,14 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) const char *string = NULL; msg->FindString("bytes", &string); -// TODO: USE target !!!! - if (fFocus) - fFocus->KeyUp(string, strlen(string)); + // TODO: same as above + if (BView* view = dynamic_cast(target)) + view->KeyUp(string, strlen(string)); + else + target->MessageReceived(msg); break; } - case B_UNMAPPED_KEY_DOWN: - case B_UNMAPPED_KEY_UP: - case B_MODIFIERS_CHANGED: - if (target != this && target != fTopView) - target->MessageReceived(msg); - break; - - case B_MOUSE_WHEEL_CHANGED: - if (target != this && target != fTopView) - target->MessageReceived(msg); - break; - case B_MOUSE_DOWN: { BPoint where; @@ -880,15 +872,11 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) } case B_PULSE: - if (fPulseEnabled) { + if (target == this && fPulseEnabled) { fTopView->_Pulse(); fLink->Flush(); - } - break; - - case B_QUIT_REQUESTED: - if (QuitRequested()) - Quit(); + } else + target->MessageReceived(msg); break; case _UPDATE_: @@ -898,9 +886,10 @@ BWindow::DispatchMessage(BMessage *msg, BHandler *target) int32 token; msg->FindRect("_rect", &updateRect); msg->FindInt32("_token", &token); + // TODO: why is "_token" ignored? fLink->StartMessage(AS_BEGIN_UPDATE); - DoUpdate(fTopView, updateRect); + fTopView->_Draw(updateRect); fLink->StartMessage(AS_END_UPDATE); fLink->Flush(); break; @@ -1302,7 +1291,7 @@ BWindow::UpdateIfNeeded() // Since we're blocking the event loop, we need to retrieve // all messages that are pending on the port. - DequeueAll(); + _DequeueAll(); BMessageQueue *queue = MessageQueue(); queue->Lock(); @@ -2013,6 +2002,7 @@ BWindow::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, // #pragma mark - Private Methods + void BWindow::_InitData(BRect frame, const char* title, window_look look, window_feel feel, uint32 flags, uint32 workspace, int32 bitmapToken) @@ -2158,16 +2148,13 @@ BWindow::_InitData(BRect frame, const char* title, window_look look, STRACE(("Server says that our send port is %ld\n", sendPort)); STRACE(("Window locked?: %s\n", IsLocked() ? "True" : "False")); - // build and register fTopView with app_server - BuildTopView(); + _CreateTopView(); } -/** Reads all pending messages from the window port and put them into the queue. - */ - +//! Reads all pending messages from the window port and put them into the queue. void -BWindow::DequeueAll() +BWindow::_DequeueAll() { // Get message count from port int32 count = port_count(fMsgPort); @@ -2180,16 +2167,15 @@ BWindow::DequeueAll() } -// TODO: This here is a nearly full code duplication to BLooper::task_loop -// but with one little difference: It uses the _DetermineTarget() method -// to tell what the later target of a message will be, if no explicit target -// is supplied. This is important because we need to call the right targets -// MessageFilter. For B_KEY_DOWN messages for example, not the BWindow but the -// focus view will be the target of the message. This means that also the -// focus views MessageFilters have to be checked before DispatchMessage and -// not the ones of this BWindow. - -void +/*! This here is a nearly full code duplication to BLooper::task_looper() + but with one little difference: It uses the _DetermineTarget() method + to tell what the later target of a message will be, if no explicit target + is supplied. + This is important because the app_server sends all events to the preferred + handler, and these must be correctly retargeted and eventually distributed + to several handlers using _DistributeMessage(). +*/ +void BWindow::task_looper() { STRACE(("info: BWindow::task_looper() started.\n")); @@ -2241,17 +2227,14 @@ BWindow::task_looper() dispatchNextMessage = false; } else { // Get the target handler + BHandler *handler = NULL; #ifdef USING_MESSAGE4 // Use the private BMessage accessor to determine if we are // using the preferred handler, or if a target has been // specified - BHandler *handler = NULL; BMessage::Private messagePrivate(fLastMessage); bool usePreferred = messagePrivate.UsePreferredTarget(); #else - // Use BMessage friend functions to determine if we are using the - // preferred handler, or if a target has been specified - BHandler* handler = NULL; bool usePreferred = _use_preferred_target_(fLastMessage); #endif if (usePreferred) { @@ -2266,8 +2249,6 @@ BWindow::task_looper() #endif } -//printf("handler = %p, usePreferred = %s\n", handler, usePreferred ? "yes" : "no"); - if (!usePreferred || _DistributeMessage(fLastMessage)) { // if a target was given, and we should not use the preferred // handler, we can just use that one @@ -2286,7 +2267,7 @@ BWindow::task_looper() if (handler) { // Do filtering and dispatch message - handler = top_level_filter(fLastMessage, handler); + handler = _TopLevelFilter(fLastMessage, handler); if (handler && handler->Looper() == this) DispatchMessage(fLastMessage, handler); } @@ -2383,14 +2364,14 @@ BWindow::_DecomposeType(window_type type, window_look *_look, void -BWindow::BuildTopView() +BWindow::_CreateTopView() { - STRACE(("BuildTopView(): enter\n")); + STRACE(("_CreateTopView(): enter\n")); BRect frame = fFrame.OffsetToCopy(B_ORIGIN); fTopView = new BView(frame, "fTopView", B_FOLLOW_ALL, B_WILL_DRAW); - fTopView->top_level_view = true; + fTopView->fTopLevelView = true; //inhibit check_lock() fLastViewToken = _get_object_token_(fTopView); @@ -2403,36 +2384,15 @@ BWindow::BuildTopView() fTopView->_SetOwner(this); - //we can't use AddChild() because this is the fTopView - fTopView->attachView(fTopView); + // we can't use AddChild() because this is the top view + fTopView->_CreateSelf(); STRACE(("BuildTopView ended\n")); } void -BWindow::prepareView(BView *view) -{ - // TODO: implement -} - - -void -BWindow::attachView(BView *view) -{ - // TODO: implement -} - - -void -BWindow::detachView(BView *view) -{ - // TODO: implement -} - - -void -BWindow::setFocus(BView *focusView, bool notifyInputServer) +BWindow::_SetFocus(BView *focusView, bool notifyInputServer) { if (fFocus == focusView) return; @@ -2450,19 +2410,9 @@ BWindow::setFocus(BView *focusView, bool notifyInputServer) } -void -BWindow::handleActivation(bool active) -{ - WindowActivated(active); - - // recursively call hook function 'WindowActivated(bool)' - // for all views attached to this window. - fTopView->_Activate(active); -} - - /*! - \brief Determines the target of a message received. + \brief Determines the target of a message received for the + focus view. */ BHandler * BWindow::_DetermineTarget(BMessage *message, BHandler *target) @@ -2472,6 +2422,17 @@ BWindow::_DetermineTarget(BMessage *message, BHandler *target) switch (message->what) { case B_KEY_DOWN: case B_KEY_UP: + { + // if we have a default button, it might want to hear + // about pressing the key + int32 rawChar; + if (DefaultButton() != NULL + && message->FindInt32("raw_char", &rawChar) == B_OK + && rawChar == B_ENTER) + return DefaultButton(); + + // supposed to fall through + } case B_UNMAPPED_KEY_DOWN: case B_UNMAPPED_KEY_UP: case B_MODIFIERS_CHANGED: @@ -2515,27 +2476,27 @@ BWindow::_DetermineTarget(BMessage *message, BHandler *target) \brief Distributes the message to its intended targets. This is done for all messages that should go to the preferred handler. - Returns \c false in case the message needs no more processing. + Returns \c true in case the message should still be dispatched */ bool BWindow::_DistributeMessage(BMessage* message) { -message->PrintToStream(); - int32 index = 0, count = 0; + bool suspend; + if (message->FindBool("_suspend_focus", &suspend) != B_OK) + suspend = false; + + int32 index = 0; int32 token; - for (; message->FindInt32("_token_", index, &token) == B_OK; index++) { -printf(" token = %ld\n", token); + for (; message->FindInt32("_token", index, &token) == B_OK; index++) { BView* target = _FindView(token); if (target == NULL) continue; -printf("distribute message %lx to: %s\n", message->what, target->Name()); BMessenger messenger(target); - if (messenger.SendMessage(message) == B_OK) - count++; + messenger.SendMessage(message); } - return count == 0; + return !suspend; } @@ -2600,16 +2561,6 @@ BWindow::_HandleKeyDown(char key, uint32 modifiers) // TODO: convert keys to the encoding of the target view - // if is pressed and we have a default button - // TODO: what happens if we have a focus view? This code looks wrong - if (DefaultButton() && key == B_ENTER) { - const char *chars; - CurrentMessage()->FindString("bytes", &chars); - - DefaultButton()->KeyDown(chars, strlen(chars)); - return true; - } - return false; } @@ -2637,7 +2588,7 @@ BWindow::_KeyboardNavigation() nextFocus = _FindNextNavigable(fFocus, jumpGroups); if (nextFocus && nextFocus != fFocus) - setFocus(nextFocus, false); + _SetFocus(nextFocus, false); } @@ -2784,64 +2735,6 @@ BWindow::_LastViewChild(BView *parent) } -void -BWindow::drawAllViews(BView* aView) -{ - if (Lock()) { - fTopView->Invalidate(); - Unlock(); - } - Sync(); -} - - -void -BWindow::DoUpdate(BView *view, BRect &area) -{ - STRACE(("info: BWindow::DoUpdate() BRect(%f,%f,%f,%f) called.\n", - area.left, area.top, area.right, area.bottom)); - - // don't draw hidden views or their children - if (view->IsHidden(view)) - return; - - view->check_lock(); - - if (view->Flags() & B_WILL_DRAW) { - // ToDo: make states robust - view->PushState(); - view->Draw(area); - view->PopState(); - } else { - // The code below is certainly not correct, because - // it redoes what the app_server already did - // Find out what happens on R5 if a view has ViewColor() = - // B_TRANSPARENT_COLOR but not B_WILL_DRAW -/* rgb_color c = aView->HighColor(); - aView->SetHighColor(aView->ViewColor()); - aView->FillRect(aView->Bounds(), B_SOLID_HIGH); - aView->SetHighColor(c);*/ - } - - BView *child = view->fFirstChild; - while (child) { - if (area.Intersects(child->Frame())) { - BRect newArea = area & child->Frame(); - child->ConvertFromParent(&newArea); - - DoUpdate(child, newArea); - } - child = child->fNextSibling; - } - - if (view->Flags() & B_WILL_DRAW) { - view->PushState(); - view->DrawAfterChildren(area); - view->PopState(); - } -} - - void BWindow::SetIsFilePanel(bool yes) { @@ -2929,7 +2822,7 @@ BWindow::PrintToStream() const look = %d\ feel = %d\ lastViewToken = %ld\ - pulseRUNNER = %s\n", + pulseRunner = %s\n", fTopViewToken, fPulseEnabled==true?"Yes":"No", fIsFilePanel==true?"Yes":"No", @@ -2948,13 +2841,11 @@ BWindow::PrintToStream() const (int16)fLook, (int16)fFeel, fLastViewToken, - fPulseRunner!=NULL?"In place":"NULL"); + fPulseRunner != NULL ? "In place" : "NULL"); } /* TODO list: - - *) take care of temporarely events mask!!! *) test arguments for SetWindowAligment *) call hook functions: MenusBeginning, MenusEnded. Add menu activation code. */