From d230489402278bb900ae68703ff64585e1fb9c4c Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Sat, 15 Mar 2003 00:04:55 +0000 Subject: [PATCH] Check-in for Adrian Oanca git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2917 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/interface/View.h | 1335 +++++++++++++++--------------- headers/os/interface/Window.h | 948 +++++++++++---------- headers/os/interface/WindowAux.h | 54 ++ 3 files changed, 1211 insertions(+), 1126 deletions(-) create mode 100644 headers/os/interface/WindowAux.h diff --git a/headers/os/interface/View.h b/headers/os/interface/View.h index ebb1b28f55..686dfce05b 100644 --- a/headers/os/interface/View.h +++ b/headers/os/interface/View.h @@ -1,667 +1,668 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// 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). -//------------------------------------------------------------------------------ - -#ifndef _VIEW_H -#define _VIEW_H - -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- -#include -#include -#include -#include -#include - -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - - -// view definitions ------------------------------------------------------------ - -enum { - B_PRIMARY_MOUSE_BUTTON = 0x01, - B_SECONDARY_MOUSE_BUTTON = 0x02, - B_TERTIARY_MOUSE_BUTTON = 0x04 -}; - -enum { - B_ENTERED_VIEW = 0, - B_INSIDE_VIEW, - B_EXITED_VIEW, - B_OUTSIDE_VIEW -}; - -enum { - B_POINTER_EVENTS = 0x00000001, - B_KEYBOARD_EVENTS = 0x00000002 -}; - -enum { - B_LOCK_WINDOW_FOCUS = 0x00000001, - B_SUSPEND_VIEW_FOCUS = 0x00000002, - B_NO_POINTER_HISTORY = 0x00000004 -}; - -enum { - B_TRACK_WHOLE_RECT, - B_TRACK_RECT_CORNER -}; - -enum { - B_FONT_FAMILY_AND_STYLE = 0x00000001, - B_FONT_SIZE = 0x00000002, - B_FONT_SHEAR = 0x00000004, - B_FONT_ROTATION = 0x00000008, - B_FONT_SPACING = 0x00000010, - B_FONT_ENCODING = 0x00000020, - B_FONT_FACE = 0x00000040, - B_FONT_FLAGS = 0x00000080, - B_FONT_ALL = 0x000000FF -}; - -const uint32 B_FULL_UPDATE_ON_RESIZE = 0x80000000UL; /* 31 */ -const uint32 _B_RESERVED1_ = 0x40000000UL; /* 30 */ -const uint32 B_WILL_DRAW = 0x20000000UL; /* 29 */ -const uint32 B_PULSE_NEEDED = 0x10000000UL; /* 28 */ -const uint32 B_NAVIGABLE_JUMP = 0x08000000UL; /* 27 */ -const uint32 B_FRAME_EVENTS = 0x04000000UL; /* 26 */ -const uint32 B_NAVIGABLE = 0x02000000UL; /* 25 */ -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_) - -const uint32 _VIEW_TOP_ = 1UL; -const uint32 _VIEW_LEFT_ = 2UL; -const uint32 _VIEW_BOTTOM_ = 3UL; -const uint32 _VIEW_RIGHT_ = 4UL; -const uint32 _VIEW_CENTER_ = 5UL; - -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_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) - -class BBitmap; -class BCursor; -class BMessage; -class BPicture; -class BPolygon; -class BRegion; -class BScrollBar; -class BScrollView; -class BShape; -class BShelf; -class BString; -class BWindow; -struct _view_attr_; -struct _array_data_; -struct _array_hdr_; -struct overlay_restrictions; - -// BView class ----------------------------------------------------------------- -class BView : public BHandler { - -public: - BView(BRect frame, const char* name, - uint32 resizeMask, uint32 flags); - virtual ~BView(); - - BView(BMessage* data); - static BArchivable* Instantiate(BMessage* data); - virtual status_t Archive(BMessage* data, bool deep = true) const; - - virtual void AttachedToWindow(); - virtual void AllAttached(); - virtual void DetachedFromWindow(); - virtual void AllDetached(); - - virtual void MessageReceived(BMessage* msg); - - void AddChild(BView* child, BView* before = NULL); - bool RemoveChild(BView* child); - int32 CountChildren() const; - BView* ChildAt(int32 index) const; - BView* NextSibling() const; - BView* PreviousSibling() const; - bool RemoveSelf(); - - BWindow *Window() const; - - virtual void Draw(BRect updateRect); - virtual void MouseDown(BPoint where); - virtual void MouseUp(BPoint where); - virtual void MouseMoved(BPoint where, - uint32 code, - const BMessage* a_message); - virtual void WindowActivated(bool state); - virtual void KeyDown(const char* bytes, int32 numBytes); - virtual void KeyUp(const char* bytes, int32 numBytes); - virtual void Pulse(); - virtual void FrameMoved(BPoint new_position); - virtual void FrameResized(float new_width, float new_height); - - virtual void TargetedByScrollView(BScrollView* scroll_view); - void BeginRectTracking(BRect startRect, - uint32 style = B_TRACK_WHOLE_RECT); - void EndRectTracking(); - - void GetMouse(BPoint* location, - uint32* buttons, - bool checkMessageQueue = true); - - void DragMessage(BMessage* aMessage, - BRect dragRect, - BHandler* reply_to = NULL); - void DragMessage(BMessage* aMessage, - BBitmap* anImage, - BPoint offset, - BHandler* reply_to = NULL); - void DragMessage(BMessage* aMessage, - BBitmap* anImage, - drawing_mode dragMode, - BPoint offset, - BHandler* reply_to = NULL); - - BView* FindView(const char* name) const; - BView* Parent() const; - BRect Bounds() const; - BRect Frame() const; - void ConvertToScreen(BPoint* pt) const; - BPoint ConvertToScreen(BPoint pt) const; - void ConvertFromScreen(BPoint* pt) const; - BPoint ConvertFromScreen(BPoint pt) const; - void ConvertToScreen(BRect* r) const; - BRect ConvertToScreen(BRect r) const; - void ConvertFromScreen(BRect* r) const; - BRect ConvertFromScreen(BRect r) const; - void ConvertToParent(BPoint* pt) const; - BPoint ConvertToParent(BPoint pt) const; - void ConvertFromParent(BPoint* pt) const; - BPoint ConvertFromParent(BPoint pt) const; - void ConvertToParent(BRect* r) const; - BRect ConvertToParent(BRect r) const; - void ConvertFromParent(BRect* r) const; - BRect ConvertFromParent(BRect r) const; - BPoint LeftTop() const; - - void GetClippingRegion(BRegion* region) const; - virtual void ConstrainClippingRegion(BRegion* region); - void ClipToPicture(BPicture* picture, - BPoint where = B_ORIGIN, - bool sync = true); - void ClipToInversePicture(BPicture* picture, - BPoint where = B_ORIGIN, - bool sync = true); - - virtual void SetDrawingMode(drawing_mode mode); - drawing_mode DrawingMode() const; - - void SetBlendingMode(source_alpha srcAlpha, - alpha_function alphaFunc); - void GetBlendingMode(source_alpha* srcAlpha, - alpha_function* alphaFunc) const; - - virtual void SetPenSize(float size); - float PenSize() const; - - void SetViewCursor(const BCursor* cursor, bool sync=true); - - virtual void SetViewColor(rgb_color c); - void SetViewColor(uchar r, uchar g, uchar b, uchar a = 255); - rgb_color ViewColor() const; - - void SetViewBitmap(const BBitmap* bitmap, - BRect srcRect, BRect dstRect, - uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, - uint32 options = B_TILE_BITMAP); - void SetViewBitmap(const BBitmap* bitmap, - uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, - uint32 options = B_TILE_BITMAP); - void ClearViewBitmap(); - - status_t SetViewOverlay(const BBitmap* overlay, - BRect srcRect, BRect dstRect, - rgb_color* colorKey, - uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, - uint32 options = 0); - status_t SetViewOverlay(const BBitmap* overlay, rgb_color* colorKey, - uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, - uint32 options = 0); - void ClearViewOverlay(); - - virtual void SetHighColor(rgb_color a_color); - void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255); - rgb_color HighColor() const; - - virtual void SetLowColor(rgb_color a_color); - void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255); - rgb_color LowColor() const; - - void SetLineMode(cap_mode lineCap, - join_mode lineJoin, - float miterLimit = B_DEFAULT_MITER_LIMIT); - join_mode LineJoinMode() const; - cap_mode LineCapMode() const; - float LineMiterLimit() const; - - void SetOrigin(BPoint pt); - void SetOrigin(float x, float y); - BPoint Origin() const; - - void PushState(); - void PopState(); - - void MovePenTo(BPoint pt); - void MovePenTo(float x, float y); - void MovePenBy(float x, float y); - BPoint PenLocation() const; - void StrokeLine(BPoint toPt, - pattern p = B_SOLID_HIGH); - void StrokeLine(BPoint pt0, - BPoint pt1, - pattern p = B_SOLID_HIGH); - void BeginLineArray(int32 count); - void AddLine(BPoint pt0, BPoint pt1, rgb_color col); - void EndLineArray(); - - void StrokePolygon(const BPolygon* aPolygon, - bool closed = true, - pattern p = B_SOLID_HIGH); - void StrokePolygon(const BPoint* ptArray, - int32 numPts, - bool closed = true, - pattern p = B_SOLID_HIGH); - void StrokePolygon(const BPoint* ptArray, - int32 numPts, - BRect bounds, - bool closed = true, - pattern p = B_SOLID_HIGH); - void FillPolygon(const BPolygon* aPolygon, - pattern p = B_SOLID_HIGH); - void FillPolygon(const BPoint* ptArray, - int32 numPts, - pattern p = B_SOLID_HIGH); - void FillPolygon(const BPoint* ptArray, - int32 numPts, - BRect bounds, - pattern p = B_SOLID_HIGH); - - void StrokeTriangle(BPoint pt1, - BPoint pt2, - BPoint pt3, - BRect bounds, - pattern p = B_SOLID_HIGH); - void StrokeTriangle(BPoint pt1, - BPoint pt2, - BPoint pt3, - pattern p = B_SOLID_HIGH); - void FillTriangle(BPoint pt1, - BPoint pt2, - BPoint pt3, - pattern p = B_SOLID_HIGH); - void FillTriangle(BPoint pt1, - BPoint pt2, - BPoint pt3, - BRect bounds, - pattern p = B_SOLID_HIGH); - - void StrokeRect(BRect r, pattern p = B_SOLID_HIGH); - void FillRect(BRect r, pattern p = B_SOLID_HIGH); - void FillRegion(BRegion* a_region, pattern p= B_SOLID_HIGH); - void InvertRect(BRect r); - - void StrokeRoundRect(BRect r, - float xRadius, - float yRadius, - pattern p = B_SOLID_HIGH); - void FillRoundRect(BRect r, - float xRadius, - float yRadius, - pattern p = B_SOLID_HIGH); - - void StrokeEllipse(BPoint center, - float xRadius, - float yRadius, - pattern p = B_SOLID_HIGH); - void StrokeEllipse(BRect r, pattern p = B_SOLID_HIGH); - void FillEllipse(BPoint center, - float xRadius, - float yRadius, - pattern p = B_SOLID_HIGH); - void FillEllipse(BRect r, pattern p = B_SOLID_HIGH); - - void StrokeArc(BPoint center, - float xRadius, - float yRadius, - float start_angle, - float arc_angle, - pattern p = B_SOLID_HIGH); - void StrokeArc(BRect r, - float start_angle, - float arc_angle, - pattern p = B_SOLID_HIGH); - void FillArc(BPoint center, - float xRadius, - float yRadius, - float start_angle, - float arc_angle, - pattern p = B_SOLID_HIGH); - void FillArc(BRect r, - float start_angle, - float arc_angle, - pattern p = B_SOLID_HIGH); - - void StrokeBezier(BPoint* controlPoints, - pattern p = B_SOLID_HIGH); - void FillBezier(BPoint* controlPoints, - pattern p = B_SOLID_HIGH); - - void StrokeShape(BShape* shape, - pattern p = B_SOLID_HIGH); - void FillShape(BShape* shape, - pattern p = B_SOLID_HIGH); - - void CopyBits(BRect src, BRect dst); - void DrawBitmapAsync(const BBitmap* aBitmap, - BRect srcRect, - BRect dstRect); - void DrawBitmapAsync(const BBitmap* aBitmap); - void DrawBitmapAsync(const BBitmap* aBitmap, BPoint where); - void DrawBitmapAsync(const BBitmap* aBitmap, BRect dstRect); - void DrawBitmap(const BBitmap* aBitmap, - BRect srcRect, - BRect dstRect); - void DrawBitmap(const BBitmap* aBitmap); - void DrawBitmap(const BBitmap* aBitmap, BPoint where); - void DrawBitmap(const BBitmap* aBitmap, BRect dstRect); - - void DrawChar(char aChar); - void DrawChar(char aChar, BPoint location); - void DrawString(const char* aString, - escapement_delta* delta = NULL); - void DrawString(const char* aString, BPoint location, - escapement_delta* delta = NULL); - void DrawString(const char* aString, int32 length, - escapement_delta* delta = NULL); - void DrawString(const char* aString, - int32 length, - BPoint location, - escapement_delta* delta = 0L); - - virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL); - - #if !_PR3_COMPATIBLE_ - void GetFont(BFont* font) const; - #else - void GetFont(BFont* font); - #endif - void TruncateString(BString* in_out, - uint32 mode, - float width) const; - float StringWidth(const char* string) const; - float StringWidth(const char* string, int32 length) const; - void GetStringWidths(char* stringArray[], - int32 lengthArray[], - int32 numStrings, - float widthArray[]) const; - void SetFontSize(float size); - void ForceFontAliasing(bool enable); - void GetFontHeight(font_height* height) const; - - void Invalidate(BRect invalRect); - void Invalidate(const BRegion* invalRegion); - void Invalidate(); - - void SetDiskMode(char* filename, long offset); - - void BeginPicture(BPicture* a_picture); - void AppendToPicture(BPicture* a_picture); - BPicture* EndPicture(); - - void DrawPicture(const BPicture* a_picture); - void DrawPicture(const BPicture* a_picture, BPoint where); - void DrawPicture(const char* filename, long offset, BPoint where); - void DrawPictureAsync(const BPicture* a_picture); - void DrawPictureAsync(const BPicture* a_picture, BPoint where); - void DrawPictureAsync(const char* filename, long offset, - BPoint where); - - status_t SetEventMask(uint32 mask, uint32 options=0); - uint32 EventMask(); - status_t SetMouseEventMask(uint32 mask, uint32 options=0); - - virtual void SetFlags(uint32 flags); - uint32 Flags() const; - virtual void SetResizingMode(uint32 mode); - uint32 ResizingMode() const; - void MoveBy(float dh, float dv); - void MoveTo(BPoint where); - void MoveTo(float x, float y); - void ResizeBy(float dh, float dv); - void ResizeTo(float width, float height); - void ScrollBy(float dh, float dv); - void ScrollTo(float x, float y); - virtual void ScrollTo(BPoint where); - virtual void MakeFocus(bool focusState = true); - bool IsFocus() const; - - virtual void Show(); - virtual void Hide(); - bool IsHidden() const; - bool IsHidden(const BView* looking_from) const; - - void Flush() const; - void Sync() const; - - virtual void GetPreferredSize(float* width, float* height); - virtual void ResizeToPreferred(); - - BScrollBar* ScrollBar(orientation posture) const; - - virtual BHandler* ResolveSpecifier(BMessage* msg, - int32 index, - BMessage* specifier, - int32 form, - const char* property); - virtual status_t GetSupportedSuites(BMessage* data); - - bool IsPrinting() const; - void SetScale(float scale) const; - -// Private or reserved --------------------------------------------------------- - virtual status_t Perform(perform_code d, void* arg); - - virtual void DrawAfterChildren(BRect r); - -private: - - friend class BScrollBar; - friend class BWindow; - friend class BBitmap; - friend class BPrintJob; - friend class BShelf; - friend class BTabView; - - virtual void _ReservedView2(); - virtual void _ReservedView3(); - virtual void _ReservedView4(); - virtual void _ReservedView5(); - virtual void _ReservedView6(); - virtual void _ReservedView7(); - virtual void _ReservedView8(); - -#if !_PR3_COMPATIBLE_ - virtual void _ReservedView9(); - virtual void _ReservedView10(); - virtual void _ReservedView11(); - virtual void _ReservedView12(); - virtual void _ReservedView13(); - virtual void _ReservedView14(); - virtual void _ReservedView15(); - virtual void _ReservedView16(); -#endif - - 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); - bool remove_from_list(BView* a_view); - bool remove_self(); - bool do_owner_check() const; - void set_owner(BWindow* the_owner); - void do_activate(int32 state); - 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 remove_comm_array(); - _array_hdr_ *new_comm_array(int32 cnt); - BView *RealParent() const; - void SetScroller(BScrollBar* sb); - void UnsetScroller(BScrollBar* sb); - void RealScrollTo(BPoint); - void init_cache(); - void set_cached_state(); - void update_cached_state(); - void set_font_state(const BFont* font, uint32 mask); - void fetch_font(); - uchar font_encoding() const; - BShelf* shelf() const; - void set_shelf(BShelf* ); - - int32 server_token; - uint32 f_type; - float origin_h; - float origin_v; - BWindow* owner; - BView* parent; - BView* next_sibling; - BView* prev_sibling; - BView* first_child; - - int16 fShowLevel; - bool top_level_view; - bool fNoISInteraction; - BPicture* cpicture; - _array_data_* comm; - - BScrollBar* fVerScroller; - BScrollBar* fHorScroller; - bool f_is_printing; - bool attached; - bool _unused_bool1; - bool _unused_bool2; - _view_attr_* fPermanentState; - _view_attr_* fState; - BRect fCachedBounds; - BShelf* fShelf; - void* pr_state; - 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) -{ - ScrollTo(BPoint(x, y)); -} -//------------------------------------------------------------------------------ -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); -} -//------------------------------------------------------------------------------ -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); -} -//------------------------------------------------------------------------------ -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); -} -//------------------------------------------------------------------------------ - -#endif // _VIEW_H - -/* - * $Log $ - * - * $Id $ - * - */ - +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// 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). +//------------------------------------------------------------------------------ + +#ifndef _VIEW_H +#define _VIEW_H + +// Standard Includes ----------------------------------------------------------- + +// System Includes ------------------------------------------------------------- +#include +#include +#include +#include +#include + +// Project Includes ------------------------------------------------------------ + +// Local Includes -------------------------------------------------------------- + +// Local Defines --------------------------------------------------------------- + +// Globals --------------------------------------------------------------------- + + +// view definitions ------------------------------------------------------------ + +enum { + B_PRIMARY_MOUSE_BUTTON = 0x01, + B_SECONDARY_MOUSE_BUTTON = 0x02, + B_TERTIARY_MOUSE_BUTTON = 0x04 +}; + +enum { + B_ENTERED_VIEW = 0, + B_INSIDE_VIEW, + B_EXITED_VIEW, + B_OUTSIDE_VIEW +}; + +enum { + B_POINTER_EVENTS = 0x00000001, + B_KEYBOARD_EVENTS = 0x00000002 +}; + +enum { + B_LOCK_WINDOW_FOCUS = 0x00000001, + B_SUSPEND_VIEW_FOCUS = 0x00000002, + B_NO_POINTER_HISTORY = 0x00000004 +}; + +enum { + B_TRACK_WHOLE_RECT, + B_TRACK_RECT_CORNER +}; + +enum { + B_FONT_FAMILY_AND_STYLE = 0x00000001, + B_FONT_SIZE = 0x00000002, + B_FONT_SHEAR = 0x00000004, + B_FONT_ROTATION = 0x00000008, + B_FONT_SPACING = 0x00000010, + B_FONT_ENCODING = 0x00000020, + B_FONT_FACE = 0x00000040, + B_FONT_FLAGS = 0x00000080, + B_FONT_ALL = 0x000000FF +}; + +const uint32 B_FULL_UPDATE_ON_RESIZE = 0x80000000UL; /* 31 */ +const uint32 _B_RESERVED1_ = 0x40000000UL; /* 30 */ +const uint32 B_WILL_DRAW = 0x20000000UL; /* 29 */ +const uint32 B_PULSE_NEEDED = 0x10000000UL; /* 28 */ +const uint32 B_NAVIGABLE_JUMP = 0x08000000UL; /* 27 */ +const uint32 B_FRAME_EVENTS = 0x04000000UL; /* 26 */ +const uint32 B_NAVIGABLE = 0x02000000UL; /* 25 */ +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_) + +const uint32 _VIEW_TOP_ = 1UL; +const uint32 _VIEW_LEFT_ = 2UL; +const uint32 _VIEW_BOTTOM_ = 3UL; +const uint32 _VIEW_RIGHT_ = 4UL; +const uint32 _VIEW_CENTER_ = 5UL; + +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_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) + +class BBitmap; +class BCursor; +class BMessage; +class BPicture; +class BPolygon; +class BRegion; +class BScrollBar; +class BScrollView; +class BShape; +class BShelf; +class BString; +class BWindow; +struct _view_attr_; +struct _array_data_; +struct _array_hdr_; +struct overlay_restrictions; + +// BView class ----------------------------------------------------------------- +class BView : public BHandler { + +public: + BView(BRect frame, const char* name, + uint32 resizeMask, uint32 flags); + virtual ~BView(); + + BView(BMessage* data); + static BArchivable* Instantiate(BMessage* data); + virtual status_t Archive(BMessage* data, bool deep = true) const; + + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void DetachedFromWindow(); + virtual void AllDetached(); + + virtual void MessageReceived(BMessage* msg); + + void AddChild(BView* child, BView* before = NULL); + bool RemoveChild(BView* child); + int32 CountChildren() const; + BView* ChildAt(int32 index) const; + BView* NextSibling() const; + BView* PreviousSibling() const; + bool RemoveSelf(); + + BWindow *Window() const; + + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint where); + virtual void MouseUp(BPoint where); + virtual void MouseMoved(BPoint where, + uint32 code, + const BMessage* a_message); + virtual void WindowActivated(bool state); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void KeyUp(const char* bytes, int32 numBytes); + virtual void Pulse(); + virtual void FrameMoved(BPoint new_position); + virtual void FrameResized(float new_width, float new_height); + + virtual void TargetedByScrollView(BScrollView* scroll_view); + void BeginRectTracking(BRect startRect, + uint32 style = B_TRACK_WHOLE_RECT); + void EndRectTracking(); + + void GetMouse(BPoint* location, + uint32* buttons, + bool checkMessageQueue = true); + + void DragMessage(BMessage* aMessage, + BRect dragRect, + BHandler* reply_to = NULL); + void DragMessage(BMessage* aMessage, + BBitmap* anImage, + BPoint offset, + BHandler* reply_to = NULL); + void DragMessage(BMessage* aMessage, + BBitmap* anImage, + drawing_mode dragMode, + BPoint offset, + BHandler* reply_to = NULL); + + BView* FindView(const char* name) const; + BView* Parent() const; + BRect Bounds() const; + BRect Frame() const; + void ConvertToScreen(BPoint* pt) const; + BPoint ConvertToScreen(BPoint pt) const; + void ConvertFromScreen(BPoint* pt) const; + BPoint ConvertFromScreen(BPoint pt) const; + void ConvertToScreen(BRect* r) const; + BRect ConvertToScreen(BRect r) const; + void ConvertFromScreen(BRect* r) const; + BRect ConvertFromScreen(BRect r) const; + void ConvertToParent(BPoint* pt) const; + BPoint ConvertToParent(BPoint pt) const; + void ConvertFromParent(BPoint* pt) const; + BPoint ConvertFromParent(BPoint pt) const; + void ConvertToParent(BRect* r) const; + BRect ConvertToParent(BRect r) const; + void ConvertFromParent(BRect* r) const; + BRect ConvertFromParent(BRect r) const; + BPoint LeftTop() const; + + void GetClippingRegion(BRegion* region) const; + virtual void ConstrainClippingRegion(BRegion* region); + void ClipToPicture(BPicture* picture, + BPoint where = B_ORIGIN, + bool sync = true); + void ClipToInversePicture(BPicture* picture, + BPoint where = B_ORIGIN, + bool sync = true); + + virtual void SetDrawingMode(drawing_mode mode); + drawing_mode DrawingMode() const; + + void SetBlendingMode(source_alpha srcAlpha, + alpha_function alphaFunc); + void GetBlendingMode(source_alpha* srcAlpha, + alpha_function* alphaFunc) const; + + virtual void SetPenSize(float size); + float PenSize() const; + + void SetViewCursor(const BCursor* cursor, bool sync=true); + + virtual void SetViewColor(rgb_color c); + void SetViewColor(uchar r, uchar g, uchar b, uchar a = 255); + rgb_color ViewColor() const; + + void SetViewBitmap(const BBitmap* bitmap, + BRect srcRect, BRect dstRect, + uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, + uint32 options = B_TILE_BITMAP); + void SetViewBitmap(const BBitmap* bitmap, + uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, + uint32 options = B_TILE_BITMAP); + void ClearViewBitmap(); + + status_t SetViewOverlay(const BBitmap* overlay, + BRect srcRect, BRect dstRect, + rgb_color* colorKey, + uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, + uint32 options = 0); + status_t SetViewOverlay(const BBitmap* overlay, rgb_color* colorKey, + uint32 followFlags = B_FOLLOW_TOP|B_FOLLOW_LEFT, + uint32 options = 0); + void ClearViewOverlay(); + + virtual void SetHighColor(rgb_color a_color); + void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255); + rgb_color HighColor() const; + + virtual void SetLowColor(rgb_color a_color); + void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255); + rgb_color LowColor() const; + + void SetLineMode(cap_mode lineCap, + join_mode lineJoin, + float miterLimit = B_DEFAULT_MITER_LIMIT); + join_mode LineJoinMode() const; + cap_mode LineCapMode() const; + float LineMiterLimit() const; + + void SetOrigin(BPoint pt); + void SetOrigin(float x, float y); + BPoint Origin() const; + + void PushState(); + void PopState(); + + void MovePenTo(BPoint pt); + void MovePenTo(float x, float y); + void MovePenBy(float x, float y); + BPoint PenLocation() const; + void StrokeLine(BPoint toPt, + pattern p = B_SOLID_HIGH); + void StrokeLine(BPoint pt0, + BPoint pt1, + pattern p = B_SOLID_HIGH); + void BeginLineArray(int32 count); + void AddLine(BPoint pt0, BPoint pt1, rgb_color col); + void EndLineArray(); + + void StrokePolygon(const BPolygon* aPolygon, + bool closed = true, + pattern p = B_SOLID_HIGH); + void StrokePolygon(const BPoint* ptArray, + int32 numPts, + bool closed = true, + pattern p = B_SOLID_HIGH); + void StrokePolygon(const BPoint* ptArray, + int32 numPts, + BRect bounds, + bool closed = true, + pattern p = B_SOLID_HIGH); + void FillPolygon(const BPolygon* aPolygon, + pattern p = B_SOLID_HIGH); + void FillPolygon(const BPoint* ptArray, + int32 numPts, + pattern p = B_SOLID_HIGH); + void FillPolygon(const BPoint* ptArray, + int32 numPts, + BRect bounds, + pattern p = B_SOLID_HIGH); + + void StrokeTriangle(BPoint pt1, + BPoint pt2, + BPoint pt3, + BRect bounds, + pattern p = B_SOLID_HIGH); + void StrokeTriangle(BPoint pt1, + BPoint pt2, + BPoint pt3, + pattern p = B_SOLID_HIGH); + void FillTriangle(BPoint pt1, + BPoint pt2, + BPoint pt3, + pattern p = B_SOLID_HIGH); + void FillTriangle(BPoint pt1, + BPoint pt2, + BPoint pt3, + BRect bounds, + pattern p = B_SOLID_HIGH); + + void StrokeRect(BRect r, pattern p = B_SOLID_HIGH); + void FillRect(BRect r, pattern p = B_SOLID_HIGH); + void FillRegion(BRegion* a_region, pattern p= B_SOLID_HIGH); + void InvertRect(BRect r); + + void StrokeRoundRect(BRect r, + float xRadius, + float yRadius, + pattern p = B_SOLID_HIGH); + void FillRoundRect(BRect r, + float xRadius, + float yRadius, + pattern p = B_SOLID_HIGH); + + void StrokeEllipse(BPoint center, + float xRadius, + float yRadius, + pattern p = B_SOLID_HIGH); + void StrokeEllipse(BRect r, pattern p = B_SOLID_HIGH); + void FillEllipse(BPoint center, + float xRadius, + float yRadius, + pattern p = B_SOLID_HIGH); + void FillEllipse(BRect r, pattern p = B_SOLID_HIGH); + + void StrokeArc(BPoint center, + float xRadius, + float yRadius, + float start_angle, + float arc_angle, + pattern p = B_SOLID_HIGH); + void StrokeArc(BRect r, + float start_angle, + float arc_angle, + pattern p = B_SOLID_HIGH); + void FillArc(BPoint center, + float xRadius, + float yRadius, + float start_angle, + float arc_angle, + pattern p = B_SOLID_HIGH); + void FillArc(BRect r, + float start_angle, + float arc_angle, + pattern p = B_SOLID_HIGH); + + void StrokeBezier(BPoint* controlPoints, + pattern p = B_SOLID_HIGH); + void FillBezier(BPoint* controlPoints, + pattern p = B_SOLID_HIGH); + + void StrokeShape(BShape* shape, + pattern p = B_SOLID_HIGH); + void FillShape(BShape* shape, + pattern p = B_SOLID_HIGH); + + void CopyBits(BRect src, BRect dst); + void DrawBitmapAsync(const BBitmap* aBitmap, + BRect srcRect, + BRect dstRect); + void DrawBitmapAsync(const BBitmap* aBitmap); + void DrawBitmapAsync(const BBitmap* aBitmap, BPoint where); + void DrawBitmapAsync(const BBitmap* aBitmap, BRect dstRect); + void DrawBitmap(const BBitmap* aBitmap, + BRect srcRect, + BRect dstRect); + void DrawBitmap(const BBitmap* aBitmap); + void DrawBitmap(const BBitmap* aBitmap, BPoint where); + void DrawBitmap(const BBitmap* aBitmap, BRect dstRect); + + void DrawChar(char aChar); + void DrawChar(char aChar, BPoint location); + void DrawString(const char* aString, + escapement_delta* delta = NULL); + void DrawString(const char* aString, BPoint location, + escapement_delta* delta = NULL); + void DrawString(const char* aString, int32 length, + escapement_delta* delta = NULL); + void DrawString(const char* aString, + int32 length, + BPoint location, + escapement_delta* delta = 0L); + + virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL); + + #if !_PR3_COMPATIBLE_ + void GetFont(BFont* font) const; + #else + void GetFont(BFont* font); + #endif + void TruncateString(BString* in_out, + uint32 mode, + float width) const; + float StringWidth(const char* string) const; + float StringWidth(const char* string, int32 length) const; + void GetStringWidths(char* stringArray[], + int32 lengthArray[], + int32 numStrings, + float widthArray[]) const; + void SetFontSize(float size); + void ForceFontAliasing(bool enable); + void GetFontHeight(font_height* height) const; + + void Invalidate(BRect invalRect); + void Invalidate(const BRegion* invalRegion); + void Invalidate(); + + void SetDiskMode(char* filename, long offset); + + void BeginPicture(BPicture* a_picture); + void AppendToPicture(BPicture* a_picture); + BPicture* EndPicture(); + + void DrawPicture(const BPicture* a_picture); + void DrawPicture(const BPicture* a_picture, BPoint where); + void DrawPicture(const char* filename, long offset, BPoint where); + void DrawPictureAsync(const BPicture* a_picture); + void DrawPictureAsync(const BPicture* a_picture, BPoint where); + void DrawPictureAsync(const char* filename, long offset, + BPoint where); + + status_t SetEventMask(uint32 mask, uint32 options=0); + uint32 EventMask(); + status_t SetMouseEventMask(uint32 mask, uint32 options=0); + + virtual void SetFlags(uint32 flags); + uint32 Flags() const; + virtual void SetResizingMode(uint32 mode); + uint32 ResizingMode() const; + void MoveBy(float dh, float dv); + void MoveTo(BPoint where); + void MoveTo(float x, float y); + void ResizeBy(float dh, float dv); + void ResizeTo(float width, float height); + void ScrollBy(float dh, float dv); + void ScrollTo(float x, float y); + virtual void ScrollTo(BPoint where); + virtual void MakeFocus(bool focusState = true); + bool IsFocus() const; + + virtual void Show(); + virtual void Hide(); + bool IsHidden() const; + bool IsHidden(const BView* looking_from) const; + + void Flush() const; + void Sync() const; + + virtual void GetPreferredSize(float* width, float* height); + virtual void ResizeToPreferred(); + + BScrollBar* ScrollBar(orientation posture) const; + + virtual BHandler* ResolveSpecifier(BMessage* msg, + int32 index, + BMessage* specifier, + int32 form, + const char* property); + virtual status_t GetSupportedSuites(BMessage* data); + + bool IsPrinting() const; + void SetScale(float scale) const; + +// Private or reserved --------------------------------------------------------- + virtual status_t Perform(perform_code d, void* arg); + + virtual void DrawAfterChildren(BRect r); + +private: + + friend class BScrollBar; + friend class BWindow; + friend class BBitmap; + friend class BPrintJob; + friend class BShelf; + friend class BTabView; + + virtual void _ReservedView2(); + virtual void _ReservedView3(); + virtual void _ReservedView4(); + virtual void _ReservedView5(); + virtual void _ReservedView6(); + virtual void _ReservedView7(); + virtual void _ReservedView8(); + +#if !_PR3_COMPATIBLE_ + virtual void _ReservedView9(); + virtual void _ReservedView10(); + virtual void _ReservedView11(); + virtual void _ReservedView12(); + virtual void _ReservedView13(); + virtual void _ReservedView14(); + virtual void _ReservedView15(); + virtual void _ReservedView16(); +#endif + + 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); + bool remove_from_list(BView* a_view); + bool remove_self(); + bool do_owner_check() const; + void set_owner(BWindow* the_owner); + void do_activate(int32 state); + 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 remove_comm_array(); + _array_hdr_ *new_comm_array(int32 cnt); + BView *RealParent() const; + void SetScroller(BScrollBar* sb); + void UnsetScroller(BScrollBar* sb); + void RealScrollTo(BPoint); + void init_cache(); + void set_cached_state(); + void update_cached_state(); + void set_font_state(const BFont* font, uint32 mask); + void fetch_font(); + uchar font_encoding() const; + BShelf* shelf() const; + void set_shelf(BShelf* ); + + int32 server_token; + uint32 f_type; + float origin_h; + float origin_v; + BWindow* owner; + BView* parent; + BView* next_sibling; + BView* prev_sibling; + BView* first_child; + + int16 fShowLevel; + bool top_level_view; + bool fNoISInteraction; + BPicture* cpicture; + _array_data_* comm; + + BScrollBar* fVerScroller; + BScrollBar* fHorScroller; + bool f_is_printing; + bool attached; + bool _unused_bool1; + bool _unused_bool2; + _view_attr_* fPermanentState; + _view_attr_* fState; + BRect fCachedBounds; + BShelf* fShelf; + void* pr_state; + 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) +{ + ScrollTo(BPoint(x, y)); +} +//------------------------------------------------------------------------------ +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); +} +//------------------------------------------------------------------------------ +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); +} +//------------------------------------------------------------------------------ +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); +} +//------------------------------------------------------------------------------ + +#endif // _VIEW_H + +/* + * $Log $ + * + * $Id $ + * + */ + diff --git a/headers/os/interface/Window.h b/headers/os/interface/Window.h index fc6d2eba61..a2b2cfaea1 100644 --- a/headers/os/interface/Window.h +++ b/headers/os/interface/Window.h @@ -1,459 +1,489 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, OpenBeOS -// -// 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: Erik Jaesler (erik@cgsoftware.com) -// DarkWyrm -// Description: BWindow is the base class for all windows (graphic areas -// displayed on-screen). -//------------------------------------------------------------------------------ - -#ifndef _WINDOW_H -#define _WINDOW_H - -class PortLink; - -// Standard Includes ----------------------------------------------------------- - -// System Includes ------------------------------------------------------------- -#include -#include -#include -#include -#include -#include - -// Project Includes ------------------------------------------------------------ - -// Local Includes -------------------------------------------------------------- - -// Local Defines --------------------------------------------------------------- - -// Globals --------------------------------------------------------------------- - - -// window definitions ---------------------------------------------------------- - -enum window_type { - B_UNTYPED_WINDOW = 0, - B_TITLED_WINDOW = 1, - B_MODAL_WINDOW = 3, - B_DOCUMENT_WINDOW = 11, - B_BORDERED_WINDOW = 20, - B_FLOATING_WINDOW = 21 -}; - -//---------------------------------------------------------------- - -enum window_look { - B_BORDERED_WINDOW_LOOK = 20, - B_NO_BORDER_WINDOW_LOOK = 19, - B_TITLED_WINDOW_LOOK = 1, - B_DOCUMENT_WINDOW_LOOK = 11, - B_MODAL_WINDOW_LOOK = 3, - B_FLOATING_WINDOW_LOOK = 7 -}; - -//---------------------------------------------------------------- - -enum window_feel { - B_NORMAL_WINDOW_FEEL = 0, - B_MODAL_SUBSET_WINDOW_FEEL = 2, - B_MODAL_APP_WINDOW_FEEL = 1, - B_MODAL_ALL_WINDOW_FEEL = 3, - B_FLOATING_SUBSET_WINDOW_FEEL = 5, - B_FLOATING_APP_WINDOW_FEEL = 4, - B_FLOATING_ALL_WINDOW_FEEL = 6 -}; - -//---------------------------------------------------------------- - -enum window_alignment { - B_BYTE_ALIGNMENT = 0, - B_PIXEL_ALIGNMENT = 1 -}; - -//---------------------------------------------------------------- - -enum { - B_NOT_MOVABLE = 0x00000001, - B_NOT_CLOSABLE = 0x00000020, - B_NOT_ZOOMABLE = 0x00000040, - B_NOT_MINIMIZABLE = 0x00004000, - B_NOT_RESIZABLE = 0x00000002, - B_NOT_H_RESIZABLE = 0x00000004, - B_NOT_V_RESIZABLE = 0x00000008, - B_AVOID_FRONT = 0x00000080, - B_AVOID_FOCUS = 0x00002000, - B_WILL_ACCEPT_FIRST_CLICK = 0x00000010, - B_OUTLINE_RESIZE = 0x00001000, - B_NO_WORKSPACE_ACTIVATION = 0x00000100, - B_NOT_ANCHORED_ON_ACTIVATE = 0x00020000, - B_ASYNCHRONOUS_CONTROLS = 0x00080000, - B_QUIT_ON_WINDOW_CLOSE = 0x00100000 -}; - -#define B_CURRENT_WORKSPACE 0 -#define B_ALL_WORKSPACES 0xffffffff - -//---------------------------------------------------------------- - -class _BSession_; -class BButton; -class BMenuBar; -class BMenuItem; -class BMessage; -class BMessageRunner; -class BMessenger; -class BView; - -struct message; -struct _cmd_key_; -struct _view_attr_; - -// BWindow class --------------------------------------------------------------- -class BWindow : public BLooper { - -public: - BWindow(BRect frame, - const char* title, - window_type type, - uint32 flags, - uint32 workspace = B_CURRENT_WORKSPACE); - BWindow(BRect frame, - const char* title, - window_look look, - window_feel feel, - uint32 flags, - uint32 workspace = B_CURRENT_WORKSPACE); -virtual ~BWindow(); - - BWindow(BMessage* data); -static BArchivable *Instantiate(BMessage* data); -virtual status_t Archive(BMessage* data, bool deep = true) const; - -virtual void Quit(); - void Close(); // Synonym of Quit() - - void AddChild(BView* child, BView* before = NULL); - bool RemoveChild(BView* child); - int32 CountChildren() const; - BView *ChildAt(int32 index) const; - -virtual void DispatchMessage(BMessage* message, BHandler* handler); -virtual void MessageReceived(BMessage* message); -virtual void FrameMoved(BPoint new_position); -virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws); -virtual void WorkspaceActivated(int32 ws, bool state); -virtual void FrameResized(float new_width, float new_height); -virtual void Minimize(bool minimize); -virtual void Zoom( BPoint rec_position, - float rec_width, - float rec_height); - void Zoom(); - void SetZoomLimits(float max_h, float max_v); -virtual void ScreenChanged(BRect screen_size, color_space depth); - void SetPulseRate(bigtime_t rate); - bigtime_t PulseRate() const; - void AddShortcut( uint32 key, - uint32 modifiers, - BMessage* msg); - void AddShortcut( uint32 key, - uint32 modifiers, - BMessage* msg, - BHandler* target); - void RemoveShortcut(uint32 key, uint32 modifiers); - void SetDefaultButton(BButton* button); - BButton *DefaultButton() const; -virtual void MenusBeginning(); -virtual void MenusEnded(); - bool NeedsUpdate() const; - void UpdateIfNeeded(); - BView *FindView(const char* view_name) const; - BView *FindView(BPoint) const; - BView *CurrentFocus() const; - void Activate(bool = true); -virtual void WindowActivated(bool state); - void ConvertToScreen(BPoint* pt) const; - BPoint ConvertToScreen(BPoint pt) const; - void ConvertFromScreen(BPoint* pt) const; - BPoint ConvertFromScreen(BPoint pt) const; - void ConvertToScreen(BRect* rect) const; - BRect ConvertToScreen(BRect rect) const; - void ConvertFromScreen(BRect* rect) const; - BRect ConvertFromScreen(BRect rect) const; - void MoveBy(float dx, float dy); - void MoveTo(BPoint); - void MoveTo(float x, float y); - void ResizeBy(float dx, float dy); - void ResizeTo(float width, float height); -virtual void Show(); -virtual void Hide(); - bool IsHidden() const; - bool IsMinimized() const; - - void Flush() const; - void Sync() const; - - status_t SendBehind(const BWindow* window); - - void DisableUpdates(); - void EnableUpdates(); - - void BeginViewTransaction(); - void EndViewTransaction(); - - BRect Bounds() const; - BRect Frame() const; - const char *Title() const; - void SetTitle(const char* title); - bool IsFront() const; - bool IsActive() const; - void SetKeyMenuBar(BMenuBar* bar); - BMenuBar *KeyMenuBar() const; - void SetSizeLimits( float min_h, - float max_h, - float min_v, - float max_v); - void GetSizeLimits( float* min_h, - float* max_h, - float* min_v, - float* max_v); - uint32 Workspaces() const; - void SetWorkspaces(uint32); - BView *LastMouseMovedView() const; - -virtual BHandler *ResolveSpecifier(BMessage* msg, - int32 index, - BMessage* specifier, - int32 form, - const char* property); -virtual status_t GetSupportedSuites(BMessage* data); - - status_t AddToSubset(BWindow* window); - status_t RemoveFromSubset(BWindow* window); - -virtual status_t Perform(perform_code d, void* arg); - - status_t SetType(window_type type); - window_type Type() const; - - status_t SetLook(window_look look); - window_look Look() const; - - status_t SetFeel(window_feel feel); - window_feel Feel() const; - - status_t SetFlags(uint32); - uint32 Flags() const; - - bool IsModal() const; - bool IsFloating() const; - - status_t SetWindowAlignment(window_alignment mode, - int32 h, - int32 hOffset = 0, - int32 width = 0, - int32 widthOffset = 0, - int32 v = 0, - int32 vOffset = 0, - int32 height = 0, - int32 heightOffset = 0); - status_t GetWindowAlignment(window_alignment* mode = NULL, - int32* h = NULL, - int32* hOffset = NULL, - int32* width = NULL, - int32* widthOffset = NULL, - int32* v = NULL, - int32* vOffset = NULL, - int32* height = NULL, - int32* heightOffset = NULL) const; - -virtual bool QuitRequested(); -virtual thread_id Run(); - -// Private or reserved --------------------------------------------------------- -private: - -typedef BLooper inherited; - -friend class BApplication; -friend class BBitmap; -friend class BScrollBar; -friend class BView; -friend class BMenuItem; -friend class BWindowScreen; -friend class BDirectWindow; -friend class BFilePanel; -friend class _CEventPort_; -friend void _set_menu_sem_(BWindow* w, sem_id sem); -friend status_t _safe_get_server_token_(const BLooper* , int32* ); - -virtual void _ReservedWindow1(); -virtual void _ReservedWindow2(); -virtual void _ReservedWindow3(); -virtual void _ReservedWindow4(); -virtual void _ReservedWindow5(); -virtual void _ReservedWindow6(); -virtual void _ReservedWindow7(); -virtual void _ReservedWindow8(); - - BWindow(); - BWindow(BWindow&); - BWindow &operator=(BWindow&); - - BWindow(BRect frame, color_space depth, - uint32 bitmapFlags, int32 rowBytes); - void InitData(BRect frame, - const char* title, - window_look look, - window_feel feel, - uint32 flags, - uint32 workspace); - status_t ArchiveChildren(BMessage* data, bool deep) const; - status_t UnarchiveChildren(BMessage* data); - void BitmapClose(); -virtual void task_looper(); - void start_drag( BMessage* msg, - int32 token, - BPoint offset, - BRect track_rect, - BHandler* reply_to); - void start_drag( BMessage* msg, - int32 token, - BPoint offset, - int32 bitmap_token, - drawing_mode dragMode, - BHandler* reply_to); - void view_builder(BView* a_view); - void attach_builder(BView* a_view); - void detach_builder(BView* a_view); - int32 get_server_token() const; - BMessage *extract_drop(BMessage* an_event, BHandler* *target); - void movesize(uint32 opcode, float h, float v); - - BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT); - int32 MessagesWaiting(); - - void handle_activate(BMessage* an_event); - void do_view_frame(BMessage* an_event); - void do_value_change(BMessage* an_event, BHandler* handler); - void do_mouse_down(BMessage* an_event, BView* target); - void do_mouse_moved(BMessage* an_event, BView* target); - void do_key_down(BMessage* an_event, BHandler* handler); - void do_key_up(BMessage* an_event, BHandler* handler); - void do_menu_event(BMessage* an_event); - void do_draw_views(); -virtual BMessage *ConvertToMessage(void* raw, int32 code); - _cmd_key_ *allocShortcut(uint32 key, uint32 modifiers); - _cmd_key_ *FindShortcut(uint32 key, uint32 modifiers); - void AddShortcut(uint32 key, - uint32 modifiers, - BMenuItem* item); - void post_message(BMessage* message); - void SetLocalTitle(const char* new_title); - void enable_pulsing(bool enable); - BHandler *determine_target(BMessage* msg, BHandler* target, bool pref); - void kb_navigate(); - void navigate_to_next(int32 direction, bool group = false); - void set_focus(BView* focus, bool notify_input_server); - bool InUpdate(); - void DequeueAll(); - bool find_token_and_handler(BMessage* msg, - int32* token, - BHandler* *handler); - window_type compose_type(window_look look, - window_feel feel) const; - void decompose_type(window_type type, - window_look* look, - window_feel* feel) const; - - void SetIsFilePanel(bool panel); - bool IsFilePanel() const; - - // 3 deprecated calls - void AddFloater(BWindow* a_floating_window); - void RemoveFloater(BWindow* a_floating_window); - window_type WindowType() const; - - char *fTitle; - int32 server_token; - char fInUpdate; - char f_active; - short fShowLevel; - uint32 fFlags; - - port_id send_port; - port_id receive_port; - - BView *top_view; - BView *fFocus; - BView *fLastMouseMovedView; - PortLink *serverlink; - BMenuBar *fKeyMenuBar; - BButton *fDefaultButton; - BList accelList; - int32 top_view_token; - bool pulse_enabled; - bool fViewsNeedPulse; - bool fIsFilePanel; - bool fUnused1; - bigtime_t pulse_rate; - bool fWaitingForMenu; - bool fOffscreen; - sem_id fMenuSem; - float fMaxZoomH; - float fMaxZoomV; - float fMinWindH; - float fMinWindV; - float fMaxWindH; - float fMaxWindV; - BRect fFrame; - window_look fLook; - _view_attr_ *fCurDrawViewState; - window_feel fFeel; - int32 fLastViewToken; - _CEventPort_* fEventPort; - BMessageRunner *fPulseRunner; - BRect fCurrentFrame; - - uint32 _reserved[2]; // was 8 -#if !_PR3_COMPATIBLE_ - uint32 _more_reserved[4]; -#endif -}; - -// inline definitions ---------------------------------------------------------- -inline void BWindow::Close() -{ - Quit(); -} -//------------------------------------------------------------------------------ - -#endif // _WINDOW_H - -/* - * $Log $ - * - * $Id $ - * - */ - +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// 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: Erik Jaesler (erik@cgsoftware.com) +// Description: BWindow is the base class for all windows (graphic areas +// displayed on-screen). +// +// +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// NOTE(!!!) All private non virtual functions are to be renamed following +// this scheme: word_another_third <-> wordAnotherThird +// OBOS Team: If you use one of BWindow's private functions, please addapt to this code +//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +//------------------------------------------------------------------------------ + +#ifndef _WINDOW_H +#define _WINDOW_H + +// Standard Includes ----------------------------------------------------------- + +// System Includes ------------------------------------------------------------- +#include +#include +#include +#include +#include +#include + +// Project Includes ------------------------------------------------------------ + +// Local Includes -------------------------------------------------------------- + +// Local Defines --------------------------------------------------------------- + +// Globals --------------------------------------------------------------------- + + +// window definitions ---------------------------------------------------------- + +enum window_type { + B_UNTYPED_WINDOW = 0, + B_TITLED_WINDOW = 1, + B_MODAL_WINDOW = 3, + B_DOCUMENT_WINDOW = 11, + B_BORDERED_WINDOW = 20, + B_FLOATING_WINDOW = 21 +}; + +//---------------------------------------------------------------- + +enum window_look { + B_BORDERED_WINDOW_LOOK = 20, + B_NO_BORDER_WINDOW_LOOK = 19, + B_TITLED_WINDOW_LOOK = 1, + B_DOCUMENT_WINDOW_LOOK = 11, + B_MODAL_WINDOW_LOOK = 3, + B_FLOATING_WINDOW_LOOK = 7 +}; + +//---------------------------------------------------------------- + +enum window_feel { + B_NORMAL_WINDOW_FEEL = 0, + B_MODAL_SUBSET_WINDOW_FEEL = 2, + B_MODAL_APP_WINDOW_FEEL = 1, + B_MODAL_ALL_WINDOW_FEEL = 3, + B_FLOATING_SUBSET_WINDOW_FEEL = 5, + B_FLOATING_APP_WINDOW_FEEL = 4, + B_FLOATING_ALL_WINDOW_FEEL = 6 +}; + +//---------------------------------------------------------------- + +enum window_alignment { + B_BYTE_ALIGNMENT = 0, + B_PIXEL_ALIGNMENT = 1 +}; + +//---------------------------------------------------------------- + +enum { + B_NOT_MOVABLE = 0x00000001, + B_NOT_CLOSABLE = 0x00000020, + B_NOT_ZOOMABLE = 0x00000040, + B_NOT_MINIMIZABLE = 0x00004000, + B_NOT_RESIZABLE = 0x00000002, + B_NOT_H_RESIZABLE = 0x00000004, + B_NOT_V_RESIZABLE = 0x00000008, + B_AVOID_FRONT = 0x00000080, + B_AVOID_FOCUS = 0x00002000, + B_WILL_ACCEPT_FIRST_CLICK = 0x00000010, + B_OUTLINE_RESIZE = 0x00001000, + B_NO_WORKSPACE_ACTIVATION = 0x00000100, + B_NOT_ANCHORED_ON_ACTIVATE = 0x00020000, + B_ASYNCHRONOUS_CONTROLS = 0x00080000, + B_QUIT_ON_WINDOW_CLOSE = 0x00100000 +}; + +#define B_CURRENT_WORKSPACE 0 +#define B_ALL_WORKSPACES 0xffffffff + +//---------------------------------------------------------------- + +class PortLink; +class BButton; +class BMenuBar; +class BMenuItem; +class BMessage; +class BMessageRunner; +class BMessenger; +class BView; + +struct message; +struct _cmd_key_; +struct _view_attr_; + +// BWindow class --------------------------------------------------------------- +class BWindow : public BLooper { + +public: + BWindow(BRect frame, //done + const char* title, + window_type type, + uint32 flags, + uint32 workspace = B_CURRENT_WORKSPACE); + BWindow(BRect frame, //done, but must be maintained - call InitData(...) + const char* title, + window_look look, + window_feel feel, + uint32 flags, + uint32 workspace = B_CURRENT_WORKSPACE); +virtual ~BWindow(); //done + + BWindow(BMessage* data); //done +static BArchivable *Instantiate(BMessage* data); //done +virtual status_t Archive(BMessage* data, bool deep = true) const; //done + +virtual void Quit(); //done + void Close(); // Synonym of Quit() + + void AddChild(BView* child, BView* before = NULL); //done + bool RemoveChild(BView* child); //done + int32 CountChildren() const; //done + BView *ChildAt(int32 index) const; //done + +virtual void DispatchMessage(BMessage* message, BHandler* handler); //done +virtual void MessageReceived(BMessage* message); //done +virtual void FrameMoved(BPoint new_position); //done +virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws); //done +virtual void WorkspaceActivated(int32 ws, bool state); //done +virtual void FrameResized(float new_width, float new_height); //done +virtual void Minimize(bool minimize); //done +virtual void Zoom( BPoint rec_position, //done + float rec_width, + float rec_height); + void Zoom(); //done + void SetZoomLimits(float maxWidth, float maxHeight); //done // changed from: SetZoomLimits(float max_h, float max_v); +virtual void ScreenChanged(BRect screen_size, color_space depth); //done + void SetPulseRate(bigtime_t rate); //done + bigtime_t PulseRate() const; //done + void AddShortcut( uint32 key, //done + uint32 modifiers, + BMessage* msg); + void AddShortcut( uint32 key, //done + uint32 modifiers, + BMessage* msg, + BHandler* target); + void RemoveShortcut(uint32 key, uint32 modifiers); //done + void SetDefaultButton(BButton* button); //done + BButton *DefaultButton() const; //done +virtual void MenusBeginning(); //done +virtual void MenusEnded(); //done + bool NeedsUpdate() const; //done + void UpdateIfNeeded(); //done + BView *FindView(const char* viewName) const; //done // changed from: FindView( const char* view_name ); + BView *FindView(BPoint) const; //done + BView *CurrentFocus() const; //done + void Activate(bool = true); //done +virtual void WindowActivated(bool state); //done + void ConvertToScreen(BPoint* pt) const; //done + BPoint ConvertToScreen(BPoint pt) const; //done + void ConvertFromScreen(BPoint* pt) const; //done + BPoint ConvertFromScreen(BPoint pt) const; //done + void ConvertToScreen(BRect* rect) const; //done + BRect ConvertToScreen(BRect rect) const; //done + void ConvertFromScreen(BRect* rect) const; //done + BRect ConvertFromScreen(BRect rect) const; //done + void MoveBy(float dx, float dy); //done + void MoveTo(BPoint); //done + void MoveTo(float x, float y); //done + void ResizeBy(float dx, float dy); //done + void ResizeTo(float width, float height); //done +virtual void Show(); //done +virtual void Hide(); //done + bool IsHidden() const; //done + bool IsMinimized() const; //done + + void Flush() const; //done + void Sync() const; //done + + status_t SendBehind(const BWindow* window); //done + + void DisableUpdates(); //done + void EnableUpdates(); //done + + void BeginViewTransaction(); //done // referred as OpenViewTransaction() in BeBook + void EndViewTransaction(); //done // referred as CommitViewTransaction() in BeBook + + BRect Bounds() const; //done + BRect Frame() const; //done + const char *Title() const; //done + void SetTitle(const char* title); //done + bool IsFront() const; //done + bool IsActive() const; //done + void SetKeyMenuBar(BMenuBar* bar); //done + BMenuBar *KeyMenuBar() const; //done + void SetSizeLimits( float minWidth, //done // changed from: SetSizeLimits(float min_h, float max_h, float min_v, float max_v); + float maxWidth, + float minHeight, + float maxHeight); + void GetSizeLimits( float *minWidth, //done // changed from: SetSizeLimits(float* min_h, float* max_h, float* min_v, float* max_v); + float *maxWidth, + float *minHeight, + float *maxHeight); + uint32 Workspaces() const; //done + void SetWorkspaces(uint32); //done + BView *LastMouseMovedView() const; //done + +virtual BHandler *ResolveSpecifier(BMessage* msg, //done + int32 index, + BMessage* specifier, + int32 form, + const char* property); +virtual status_t GetSupportedSuites(BMessage* data); //done + + status_t AddToSubset(BWindow* window); //done + status_t RemoveFromSubset(BWindow* window); //done + +virtual status_t Perform(perform_code d, void* arg); //done + + status_t SetType(window_type type); //done + window_type Type() const; //done + + status_t SetLook(window_look look); //done + window_look Look() const; //done + + status_t SetFeel(window_feel feel); //done + window_feel Feel() const; //done + + status_t SetFlags(uint32); //done + uint32 Flags() const; //done + + bool IsModal() const; //done + bool IsFloating() const; //done + + status_t SetWindowAlignment(window_alignment mode, //done + int32 h, + int32 hOffset = 0, + int32 width = 0, + int32 widthOffset = 0, + int32 v = 0, + int32 vOffset = 0, + int32 height = 0, + int32 heightOffset = 0); + status_t GetWindowAlignment(window_alignment* mode = NULL, //done + int32* h = NULL, + int32* hOffset = NULL, + int32* width = NULL, + int32* widthOffset = NULL, + int32* v = NULL, + int32* vOffset = NULL, + int32* height = NULL, + int32* heightOffset = NULL) const; + +virtual bool QuitRequested(); //done +virtual thread_id Run(); //done + +// Private or reserved --------------------------------------------------------- +private: + +typedef BLooper inherited; + +friend class BApplication; +friend class BBitmap; +friend class BScrollBar; +friend class BView; +friend class BMenuItem; +friend class BWindowScreen; +friend class BDirectWindow; +friend class BFilePanel; +friend class BHandler; +friend class _BEventMask_; +friend void _set_menu_sem_(BWindow* w, sem_id sem); +friend status_t _safe_get_server_token_(const BLooper* , int32* ); + +virtual void _ReservedWindow1(); +virtual void _ReservedWindow2(); +virtual void _ReservedWindow3(); +virtual void _ReservedWindow4(); +virtual void _ReservedWindow5(); +virtual void _ReservedWindow6(); +virtual void _ReservedWindow7(); +virtual void _ReservedWindow8(); + + BWindow(); + BWindow(BWindow&); + BWindow &operator=(BWindow&); + + BWindow(BRect frame, color_space depth, // I'm realllly curious in the things that this funtion does + uint32 bitmapFlags, int32 rowBytes); // I think it's called from every constructor and sends its server counterpart (ServerWindow) the message for creating a surface(BBitmap) with certain parameters. + void InitData(BRect frame, + const char* title, + window_look look, + window_feel feel, + uint32 flags, + uint32 workspace); + status_t ArchiveChildren(BMessage* data, bool deep) const; // call made from within Archive + status_t UnarchiveChildren(BMessage* data); // Instantiate(BMessage* data)->BWindow(BMessage)->UnarchiveChildren(BMessage* data) + void BitmapClose(); +virtual void task_looper(); // thread function - it's here where app_server messages are received and converted to BMessages + void start_drag( BMessage* msg, + int32 token, + BPoint offset, + BRect track_rect, + BHandler* reply_to); + void start_drag( BMessage* msg, + int32 token, + BPoint offset, + int32 bitmap_token, + drawing_mode dragMode, + BHandler* reply_to); + void view_builder(BView* a_view); // It passes needed parameters to a BView allready created. + void attach_builder(BView* a_view); // Attaches the view + void detach_builder(BView* a_view); // Detaches the view + int32 get_server_token() const; + BMessage *extract_drop(BMessage* an_event, BHandler* *target); + void movesize(uint32 opcode, float h, float v); + + BMessage* ReadMessageFromPort(bigtime_t tout = B_INFINITE_TIMEOUT); // reads a message from receive_port and passes it along with the message body to CreateMessage(void*, int32) function + int32 MessagesWaiting(); // (?)# of messages waiting in the port queue + + void handle_activate(BMessage* an_event); + void do_view_frame(BMessage* an_event); + void do_value_change(BMessage* an_event, BHandler* handler); + void do_mouse_down(BMessage* an_event, BView* target); + void do_mouse_moved(BMessage* an_event, BView* target); + void do_key_down(BMessage* an_event, BHandler* handler); + void do_key_up(BMessage* an_event, BHandler* handler); + void do_menu_event(BMessage* an_event); + void do_draw_views(); +virtual BMessage *ConvertToMessage(void* raw, int32 code); // HUGE function - it convers PortLink messages into BMessage messages + _cmd_key_ *allocShortcut(uint32 key, uint32 modifiers); + _cmd_key_ *FindShortcut(uint32 key, uint32 modifiers); + void AddShortcut(uint32 key, // !!! - and menu shortcuts to list when a menu is added + uint32 modifiers, + BMenuItem* item); + void post_message(BMessage* message); + void SetLocalTitle(const char* new_title); + void enable_pulsing(bool enable); + BHandler *determine_target(BMessage* msg, BHandler* target, bool pref); + void kb_navigate(); + void navigate_to_next(int32 direction, bool group = false); + void set_focus(BView* focus, bool notify_input_server); // what does notify_input_server mean??? why??? + bool InUpdate(); + void DequeueAll(); + bool find_token_and_handler(BMessage* msg, + int32* token, + BHandler* *handler); + window_type composeType(window_look look, // changed from: compose_type(...) + window_feel feel) const; + void decomposeType(window_type type, // changed from: decompose_type(...) + window_look* look, + window_feel* feel) const; + + void SetIsFilePanel(bool yes); + bool IsFilePanel() const; +// OBOS BWindow's addon functions + uint32 WindowLookToInteger(window_look wl); + uint32 WindowFeelToInteger(window_feel wf); + BView* buildTopView(); + void attachTopView(); + void detachTopView(); + void setFocus(BView *focusView, bool notifyIputServer); + + bool handleBWindowKeys( BString, uint32); + + // message: B_MOUSE_UP, B_MOUSE_DOWN, B_MOUSE_MOVED + void sendMessageUsingEventMask( int32 message, BPoint where ); + void sendWillingBViewsPulseMsg( BView* ); + int32 findShortcut(int32 key, int32 modifiers); + bool findHandler( BView* start, BHandler* handler ); + BView* findView(BView* aView, const char* viewName) const; + BView* findView(BView* aView, BPoint point) const; + BView* findView(BView* aView, int32 token); + + void drawAllViews(BView* aView); +// END: OBOS addon functions + + // 3 deprecated calls + void AddFloater(BWindow* a_floating_window); + void RemoveFloater(BWindow* a_floating_window); + window_type WindowType() const; + + char *fTitle; // set + int32 server_token; + bool fInTransaction; // set // changed from: char fInUpdate; + bool fActive; // changed from: char f_active; + short fShowLevel; + uint32 fFlags; // set + + port_id send_port; // set + port_id receive_port; // set + + BView *top_view; + BView *fFocus; + BView *fLastMouseMovedView; // set + PortLink *serverLink; + BMenuBar *fKeyMenuBar; // set + BButton *fDefaultButton; // set + BList accelList; // set + int32 fTopViewToken; // // changed from: int32 top_view_token; + bool fPulseEnabled; // // changed from: bool pulse_enabled; + bool fViewsNeedPulse; + bool fIsFilePanel; + bool fUnused1; + bigtime_t fPulseRate; // // changed from: bigtime_t pulse_rate; + bool fWaitingForMenu; + bool fMinimized; // // changed from: bool fOffscreen; + sem_id fMenuSem; + float fMaxZoomHeight; // set // changed from: float fMaxZoomH; + float fMaxZoomWidth; // set // changed from: float fMaxZoomV; + float fMinWindHeight; // set // changed from: float fMinWindH; + float fMinWindWidth; // set // changed from: float fMinWindV; + float fMaxWindHeight; // set // changed from: float fMaxWindH; + float fMaxWindWidth; // set // changed from: float fMaxWindV; + BRect fFrame; // set + window_look fLook; // set + _view_attr_ *fCurDrawViewState; + window_feel fFeel; // set + int32 fLastViewToken; + _BEventMask_* fEventMask; // changed from: _CEventPort_* fEventPort; + BMessageRunner *fPulseRunner; + BRect fCurrentFrame; + + // dedicated for graphic calls + PortLink *srvGfxLink; // set + uint32 _reserved; + +// uint32 _reserved[2]; // was 8 +#if !_PR3_COMPATIBLE_ + uint32 _more_reserved[4]; +#endif +}; + +// inline definitions ---------------------------------------------------------- +inline void BWindow::Close() +{ + Quit(); +} +//------------------------------------------------------------------------------ + +#endif // _WINDOW_H + +/* + * $Log $ + * + * $Id $ + * + */ + diff --git a/headers/os/interface/WindowAux.h b/headers/os/interface/WindowAux.h new file mode 100644 index 0000000000..31766434d4 --- /dev/null +++ b/headers/os/interface/WindowAux.h @@ -0,0 +1,54 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// 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: WindowAux.h +// Author: Adrian Oanca (oancaadrian@yahoo.com) +// Description: BWindowAux.h contains helper definitions for BWindow class +// +//------------------------------------------------------------------------------ + +#ifndef _WINDOWAUX_H +#define _WINDOWAUX_H + +// Standard Includes ----------------------------------------------------------- + +// System Includes ------------------------------------------------------------- +#include +#include +#include + +// Project Includes ------------------------------------------------------------ + +// Local Includes -------------------------------------------------------------- + +// Local Defines --------------------------------------------------------------- + +// Globals --------------------------------------------------------------------- + + +struct _BCmdKey{ + uint32 key; + uint32 modifiers; + BMessage* message; + BHandler* target; +}; + +#endif // _WINDOWAUX_H \ No newline at end of file