From 41f6647332ce719b0807012355c38e0571132174 Mon Sep 17 00:00:00 2001 From: ocoursiere Date: Wed, 19 Jun 2002 22:44:22 +0000 Subject: [PATCH] first update with BView support --- bepascal/bepascal/be/app/Application.cpp | 1 + bepascal/bepascal/be/app/Message.cpp | 12 + bepascal/bepascal/be/app/application.pp | 2 +- bepascal/bepascal/be/app/handler.pp | 2 +- bepascal/bepascal/be/app/looper.pp | 4 +- bepascal/bepascal/be/interface/View.cpp | 444 +++++++++++++++++++ bepascal/bepascal/be/interface/Window.cpp | 20 + bepascal/bepascal/be/interface/view.pp | 492 ++++++++++++++++++++++ bepascal/bepascal/be/interface/window.pp | 20 +- 9 files changed, 990 insertions(+), 7 deletions(-) create mode 100644 bepascal/bepascal/be/interface/View.cpp create mode 100644 bepascal/bepascal/be/interface/view.pp diff --git a/bepascal/bepascal/be/app/Application.cpp b/bepascal/bepascal/be/app/Application.cpp index 1aff847..47b3bde 100644 --- a/bepascal/bepascal/be/app/Application.cpp +++ b/bepascal/bepascal/be/app/Application.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/bepascal/bepascal/be/app/Message.cpp b/bepascal/bepascal/be/app/Message.cpp index aad69ee..d8d3692 100644 --- a/bepascal/bepascal/be/app/Message.cpp +++ b/bepascal/bepascal/be/app/Message.cpp @@ -225,6 +225,18 @@ bool BMessage_WasDropped(TCPlusObject message) return reinterpret_cast(message)->WasDropped(); } +/*********************************************************************** + * Method: BMessage::operator= + * Params: const BMessage &msg + * Returns: BMessage & + * Effects: + ***********************************************************************/ +BMessage & +BMessage_operator_equal(BMessage *Message, const BMessage &msg) +{ + return Message->operator=(msg); +} + #if defined(__cplusplus) } #endif diff --git a/bepascal/bepascal/be/app/application.pp b/bepascal/bepascal/be/app/application.pp index 40941cc..b2193b4 100644 --- a/bepascal/bepascal/be/app/application.pp +++ b/bepascal/bepascal/be/app/application.pp @@ -111,7 +111,7 @@ begin Application.ReadyToRun; end; -procedure Application_MessageReceived_hook_func(Application : TApplication; aMessage : TCPlusObject); +procedure Application_MessageReceived_hook_func(Application : TApplication; aMessage : TCPlusObject); cdecl; var Message : TMessage; begin diff --git a/bepascal/bepascal/be/app/handler.pp b/bepascal/bepascal/be/app/handler.pp index 1dae223..64a79f7 100644 --- a/bepascal/bepascal/be/app/handler.pp +++ b/bepascal/bepascal/be/app/handler.pp @@ -42,7 +42,7 @@ begin WriteLn('Message reçue'); end; -procedure Handler_MessageReceived_hook_func(Handler : THandler; aMessage : TCPlusObject); +procedure Handler_MessageReceived_hook_func(Handler : THandler; aMessage : TCPlusObject); cdecl; var Message : TMessage; begin diff --git a/bepascal/bepascal/be/app/looper.pp b/bepascal/bepascal/be/app/looper.pp index f3c6d9c..adc5acf 100644 --- a/bepascal/bepascal/be/app/looper.pp +++ b/bepascal/bepascal/be/app/looper.pp @@ -70,7 +70,7 @@ end; // hooks procedure Looper_DispatchMessage_hook_func(Looper : TLooper; - aMessage : TCPlusObject; aTarget : TCPlusObject); + aMessage : TCPlusObject; aTarget : TCPlusObject); cdecl; var Message : TMessage; Target : THandler; @@ -89,7 +89,7 @@ begin end; end; -function Looper_QuitRequested_hook_func(Looper : TLooper) : boolean; +function Looper_QuitRequested_hook_func(Looper : TLooper) : boolean; cdecl; begin WriteLn('Hook QuitRequested !'); if Looper <> nil then diff --git a/bepascal/bepascal/be/interface/View.cpp b/bepascal/bepascal/be/interface/View.cpp new file mode 100644 index 0000000..3fc93a6 --- /dev/null +++ b/bepascal/bepascal/be/interface/View.cpp @@ -0,0 +1,444 @@ +/* BePascal - A pascal wrapper around the BeOS API + Copyright (C) 2002 Olivier Coursiere + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#ifndef _VIEW_CPP_ +#define _VIEW_CPP_ + +#include + +#include + +#include + +// definition of callback function in BView +typedef void (*BView_AllAttached_hook) (TPasObject PasObject); +typedef void (*BView_AllDetached_hook) (TPasObject PasObject); +typedef void (*BView_AttachedToWindow_hook) (TPasObject PasObject); +typedef void (*BView_DetachedFromWindow_hook) (TPasObject PasObject); +typedef void (*BView_Draw_hook) (TPasObject PasObject, TCPlusObject updateRect); +typedef void (*BView_DrawAfterChildren_hook) (TPasObject PasObject, TCPlusObject updateRect); +typedef void (*BView_FrameMoved_hook) (TPasObject PasObject, TCPlusObject parentPoint); +typedef void (*BView_FrameResized_hook) (TPasObject PasObject, float width, float height); +typedef void (*BView_GetPreferredSize_hook) (TPasObject PasObject, float *width, float *height); +typedef void (*BView_ResizeToPreferred_hook) (TPasObject PasObject); +typedef void (*BView_KeyDown_hook) (TPasObject PasObject, const char *bytes, int32 numBytes); +typedef void (*BView_KeyUp_hook) (TPasObject PasObject, const char *bytes, int32 numBytes); +typedef void (*BView_MouseDown_hook) (TPasObject PasObject, TCPlusObject point); +typedef void (*BView_MouseMoved_hook) (TPasObject PasObject, TCPlusObject point, uint32 transit, TCPlusObject message); +typedef void (*BView_MouseUp_hook) (TPasObject PasObject, TCPlusObject point); +typedef void (*BView_Pulse_hook) (TPasObject PasObject); +typedef void (*BView_TargetedByScrollView_hook) (TPasObject PasObject, TCPlusObject scroller); +typedef void (*BView_WindowActivated_hook) (TPasObject PasObject, bool active); + +#if defined(__cplusplus) +extern "C" { +#endif + +uint32 _B_FOLLOW_NONE = B_FOLLOW_NONE; +uint32 _B_FOLLOW_ALL_SIDES = B_FOLLOW_ALL_SIDES; +uint32 _B_FOLLOW_ALL = B_FOLLOW_ALL; + +uint32 _B_FOLLOW_LEFT = B_FOLLOW_LEFT; +uint32 _B_FOLLOW_RIGHT = B_FOLLOW_RIGHT; +uint32 _B_FOLLOW_LEFT_RIGHT = B_FOLLOW_LEFT_RIGHT; +uint32 _B_FOLLOW_H_CENTER = B_FOLLOW_H_CENTER; + +uint32 _B_FOLLOW_TOP = B_FOLLOW_TOP; +uint32 _B_FOLLOW_BOTTOM = B_FOLLOW_BOTTOM; +uint32 _B_FOLLOW_TOP_BOTTOM = B_FOLLOW_TOP_BOTTOM; +uint32 _B_FOLLOW_V_CENTER = B_FOLLOW_V_CENTER; + +BView_AllAttached_hook View_AllAttached_hook; +BView_AllDetached_hook View_AllDetached_hook; +BView_AttachedToWindow_hook View_AttachedToWindow_hook; +BView_DetachedFromWindow_hook View_DetachedFromWindow_hook; +BView_Draw_hook View_Draw_hook; +BView_DrawAfterChildren_hook View_DrawAfterChildren_hook; +BView_FrameMoved_hook View_FrameMoved_hook; +BView_FrameResized_hook View_FrameResized_hook; +BView_GetPreferredSize_hook View_GetPreferredSize_hook; +BView_ResizeToPreferred_hook View_ResizeToPreferred_hook; +BView_KeyDown_hook View_KeyDown_hook; +BView_KeyUp_hook View_KeyUp_hook; +BView_MouseDown_hook View_MouseDown_hook; +BView_MouseMoved_hook View_MouseMoved_hook; +BView_MouseUp_hook View_MouseUp_hook; +BView_Pulse_hook View_Pulse_hook; +BView_TargetedByScrollView_hook View_TargetedByScrollView_hook; +BView_WindowActivated_hook View_WindowActivated_hook; + +#if defined(__cplusplus) +} +#endif + +class BPView : public BView, public BPHandler +{ + public: + BPView(TPasObject PasObject, + BRect frame, + const char *name, + uint32 resizingMode, + uint32 flags); +// virtual void DispatchMessage(BMessage *message, BHandler *target); +// virtual bool QuitRequested(void); + virtual void AllAttached(void); + virtual void AttachedToWindow(void); + virtual void AllDetached(void); + virtual void DetachedFromWindow(void); + virtual void Draw(BRect updateRect); + virtual void DrawAfterChildren(BRect updateRect); + virtual void FrameMoved(BPoint parentPoint); + virtual void FrameResized(float width, float height); + virtual void GetPreferredSize(float *width, float *height); + virtual void ResizeToPreferred(void); + virtual void KeyDown(const char *bytes, int32 numBytes); + virtual void KeyUp(const char *bytes, int32 numBytes); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); + virtual void MouseUp(BPoint point); + virtual void Pulse(void); +// virtual void TargetedByScrollView(BScrollView *scroller); + virtual void WindowActivated(bool active); + private: +}; + +BPView::BPView(TPasObject PasObject, + BRect frame, + const char *name, + uint32 resizingMode, + uint32 flags) + : BView(frame, name, resizingMode, flags), + BPHandler(PasObject) +{ +} + +void BPView::AllAttached(void) +{ + View_AllAttached_hook(GetPasObject()); +} + +void BPView::AttachedToWindow(void) +{ + View_AttachedToWindow_hook(GetPasObject()); +} + +void BPView::AllDetached(void) +{ + View_AllDetached_hook(GetPasObject()); +} + +void BPView::DetachedFromWindow(void) +{ + View_DetachedFromWindow_hook(GetPasObject()); +} + +void BPView::Draw(BRect updateRect) +{ + View_Draw_hook(GetPasObject(), &updateRect); +} + +void BPView::DrawAfterChildren(BRect updateRect) +{ + View_DrawAfterChildren_hook(GetPasObject(), &updateRect); +} + +void BPView::FrameMoved(BPoint parentPoint) +{ + View_FrameMoved_hook(GetPasObject(), &parentPoint); +} + +void BPView::FrameResized(float width, float height) +{ + View_FrameResized_hook(GetPasObject(), width, height); +} + +void BPView::GetPreferredSize(float *width, float *height) +{ + View_GetPreferredSize_hook(GetPasObject(), width, height); +} + +void BPView::ResizeToPreferred(void) +{ + View_ResizeToPreferred_hook(GetPasObject()); +} + +void BPView::KeyDown(const char *bytes, int32 numBytes) +{ + View_KeyDown_hook(GetPasObject(), bytes, numBytes); +} + +void BPView::KeyUp(const char *bytes, int32 numBytes) +{ + View_KeyUp_hook(GetPasObject(), bytes, numBytes); +} + +void BPView::MouseDown(BPoint point) +{ + View_MouseDown_hook(GetPasObject(), &point); +} + +void BPView::MouseMoved(BPoint point, uint32 transit, const BMessage *message) +{ + View_MouseMoved_hook(GetPasObject(), &point, transit, &message); +} + +void BPView::MouseUp(BPoint point) +{ + View_MouseUp_hook(GetPasObject(), &point); +} + +void BPView::Pulse(void) +{ + View_Pulse_hook(GetPasObject()); +} + +//void BPView::TargetedByScrollView(BScrollView *scroller) +//{ +// View_TargetedByScrollView(GetPasObject(), scroller); +//} + +void BPView::WindowActivated(bool active) +{ + View_WindowActivated_hook(GetPasObject(), active); +} + +#if defined(__cplusplus) +extern "C" { +#endif + +TCPlusObject BView_Create_1(TPasObject PasObject, + BRect frame, + const char *name, + uint32 resizingMode, + uint32 flags) +{ + return new BPView(PasObject, frame, name, resizingMode, flags); +} + +void BView_Free(TCPlusObject View) +{ + delete View; +} + +/*********************************************************************** + * Method: BView::Instantiate + * Params: BMessage *data + * Returns: BArchivable * + * Effects: + ***********************************************************************/ +BArchivable * +BView_Instantiate(BView *View, BMessage *data) +{ + return View->Instantiate(data); +} + + +/*********************************************************************** + * Method: BView::Archive + * Params: BMessage *data, bool deep + * Returns: status_t + * Effects: + ***********************************************************************/ +status_t +BView_Archive(BView *View, BMessage *data, + bool deep) +{ + return View->Archive(data, + deep); +} + +// TODO : implement hook functions +/*********************************************************************** + * Method: BView::AttachedToWindow + * Params: + * Returns: void + * Effects: + ***********************************************************************/ +void +BView_AttachedToWindow(BView *View) +{ + View->AttachedToWindow(); +} + + +/*********************************************************************** + * Method: BView::AllAttached + * Params: + * Returns: void + * Effects: + ***********************************************************************/ +void +BView_AllAttached(BView *View) +{ + View->AllAttached(); +} + + +/*********************************************************************** + * Method: BView::DetachedFromWindow + * Params: + * Returns: void + * Effects: + ***********************************************************************/ +void +BView_DetachedFromWindow(BView *View) +{ + View->DetachedFromWindow(); +} + + +/*********************************************************************** + * Method: BView::AllDetached + * Params: + * Returns: void + * Effects: + ***********************************************************************/ +void +BView_AllDetached(BView *View) +{ + View->AllDetached(); +} + +// END TODO implement hook functions + +/*********************************************************************** + * Method: BView::AddChild + * Params: BView *child, BView *before + * Returns: void + * Effects: + ***********************************************************************/ +void +BView_AddChild(BView *View, BView *child, + BView *before) +{ + View->AddChild(child, + before); +} + + +/*********************************************************************** + * Method: BView::RemoveChild + * Params: BView *child + * Returns: bool + * Effects: + ***********************************************************************/ +bool +BView_RemoveChild(BView *View, BView *child) +{ + return View->RemoveChild(child); +} + + +/*********************************************************************** + * Method: BView::CountChildren + * Params: + * Returns: int32 + * Effects: + ***********************************************************************/ +int32 +BView_CountChildren(BView *View) +{ + return View->CountChildren(); +} + + +/*********************************************************************** + * Method: BView::ChildAt + * Params: int32 index + * Returns: BView * + * Effects: + ***********************************************************************/ +BView * +BView_ChildAt(BView *View, int32 index) +{ + return View->ChildAt(index); +} + + +/*********************************************************************** + * Method: BView::NextSibling + * Params: + * Returns: BView * + * Effects: + ***********************************************************************/ +BView * +BView_NextSibling(BView *View) +{ + return View->NextSibling(); +} + + +/*********************************************************************** + * Method: BView::PreviousSibling + * Params: + * Returns: BView * + * Effects: + ***********************************************************************/ +BView * +BView_PreviousSibling(BView *View) +{ + return View->PreviousSibling(); +} + + +/*********************************************************************** + * Method: BView::RemoveSelf + * Params: + * Returns: bool + * Effects: + ***********************************************************************/ +bool +BView_RemoveSelf(BView *View) +{ + return View->RemoveSelf(); +} + + +/*********************************************************************** + * Method: BView::Window + * Params: + * Returns: BWindow * + * Effects: + ***********************************************************************/ +BWindow * +BView_Window(BView *View) +{ + return View->Window(); +} + + +// TODO : implement hook function +/*********************************************************************** + * Method: BView::Draw + * Params: BRect updateRect + * Returns: void + * Effects: + ***********************************************************************/ +void +BView_Draw(BView *View, BRect updateRect) +{ + View->Draw(updateRect); +} + +// END TODO implement hook function + +#if defined(__cplusplus) +} +#endif + +#endif /* _VIEW_CPP_ */ \ No newline at end of file diff --git a/bepascal/bepascal/be/interface/Window.cpp b/bepascal/bepascal/be/interface/Window.cpp index 17ce488..7c31b3a 100644 --- a/bepascal/bepascal/be/interface/Window.cpp +++ b/bepascal/bepascal/be/interface/Window.cpp @@ -91,6 +91,26 @@ void BWindow_Hide(TCPlusObject Window) reinterpret_cast(Window)->Hide(); } +void BWindow_AddChild(BWindow* Window, BView* aView, BView* sibling) +{ + Window->AddChild(aView, sibling); +} + +bool BWindow_RemoveChild(BWindow* Window, BView* aView) +{ + return Window->RemoveChild(aView); +} + +BView* BWindow_ChildAt(BWindow* Window, int32 index) +{ + return Window->ChildAt(index); +} + +int32 BWindow_CountChildren(BWindow* Window, void) +{ + return Window->CountChildren(); +} + #if defined(__cplusplus) } #endif diff --git a/bepascal/bepascal/be/interface/view.pp b/bepascal/bepascal/be/interface/view.pp new file mode 100644 index 0000000..6ff7545 --- /dev/null +++ b/bepascal/bepascal/be/interface/view.pp @@ -0,0 +1,492 @@ +{ BePascal - A pascal wrapper around the BeOS API + Copyright (C) 2002 Olivier Coursiere + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +} + +unit View; + +interface + +uses + beobj, handler, rect, os, application, appdefs, message; + +type +// TWindow = class(TBeObject); + TView = class(THandler) + public + constructor Create(frame : TRect; name : PChar; resizingMode, flags : Cardinal); + destructor Destroy; override; + // hook functions + procedure AllAttached; virtual; + procedure AllDetached; virtual; + procedure AttachedToWindow; virtual; + procedure DetachedFromWindow; virtual; + procedure Draw(updateRect : TRect); virtual; + procedure DrawAfterChildren(updateRect : TRect); virtual; + procedure FrameMoved(parentPoint : TPoint); virtual; + procedure FrameResized(width, height : double); virtual; + procedure GetPreferredSize(var width : double; var height : double); virtual; + procedure ResizeToPreferred; virtual; + procedure KeyDown(bytes : PChar; numBytes : integer); virtual; + procedure KeyUp(bytes : PChar; numBytes : integer); virtual; + procedure MouseDown(point : TPoint); virtual; + procedure MouseMoved(point : TPoint; transit : Cardinal; message : TMessage); virtual; + procedure MouseUp(point : TPoint); virtual; + procedure Pulse; virtual; +// procedure TargetedByScrollView(scroller : TScrollView); virtual; // Need BScrollView + procedure WindowActivated(active : boolean); virtual; + // End hook functions + function RemoveSelf : boolean; + procedure AddChild(aView, before : TView); + function RemoveChild(aView : TView) : boolean; + function CountChildren : integer; + function ChildAt(index : integer) : TView; + function NextSibling : TView; + function PreviousSibling : TView; +// function Window : TWindow; + end; + +function BView_Create(AObject : TObject; frame : TCPlusObject; name : PChar; + resizingMode, flags : cardinal) : TCplusObject; cdecl; external BePascalLibName name 'BView_Create_1'; +procedure BView_Free(CPlusObject : TCPlusObject); cdecl; external BePascalLibName name 'BView_Free'; +function BView_RemoveSelf(CPlusObject : TCPlusObject) : boolean; cdecl; external BePascalLibName name 'BView_RemoveSelf'; +procedure BView_AddChild(CPlusObject : TCPlusObject; aView : TCPlusObject; before : TCPlusObject); cdecl; external BePascalLibName name 'BView_AddChild'; +function BView_RemoveChild(CPlusObject : TCPlusObject; aView : TCPlusObject) : boolean; cdecl; external BePascalLibName name 'BView_RemoveChild'; +function BView_CountChildren(CPlusObject : TCPlusObject) : integer; cdecl; external BePascalLibName name 'BView_CountChildren'; +function BView_NextSibling(CPlusObject : TCPlusObject) : TCPlusObject; cdecl; external BePascalLibName name 'BView_NextSibling'; +function BView_PreviousSibling(CPlusObject : TCPlusObject) : TCPlusObject; cdecl; external BePascalLibName name 'BView_NextSibling'; +function BView_ChildAt(CPlusObject : TCPlusObject; index : integer) : TCPlusObject; cdecl; external BePascalLibName name 'BView_ChildAt'; +function BView_Window(CPlusObject : TCPlusObject) : TCPlusObject; cdecl; external BePascalLibName name 'BView_Window'; +procedure BView_Draw(CPlusObject : TCPlusObject; aRect : TCPlusObject); cdecl; external BePascalLibName name 'BView_Draw'; + +var + // resizingMode mask + B_FOLLOW_NONE : Cardinal; + B_FOLLOW_ALL_SIDES : Cardinal; + + B_FOLLOW_ALL : Cardinal; + + B_FOLLOW_LEFT : Cardinal; + B_FOLLOW_RIGHT : Cardinal; + B_FOLLOW_LEFT_RIGHT : Cardinal; + B_FOLLOW_H_CENTER : Cardinal; + + B_FOLLOW_TOP : Cardinal; + B_FOLLOW_BOTTOM : Cardinal; + B_FOLLOW_TOP_BOTTOM : Cardinal; + B_FOLLOW_V_CENTER : Cardinal; + +const + // flags + B_FULL_UPDATE_ON_RESIZE : Cardinal = 31; + _B_RESERVED1_ : Cardinal = 30; + B_WILL_DRAW : Cardinal = 29; + B_PULSE_NEEDED : Cardinal = 28; + B_NAVIGABLE_JUMP : Cardinal = 27; + B_FRAME_EVENTS : Cardinal = 26; + B_NAVIGABLE : Cardinal = 25; + B_SUBPIXEL_PRECISE : Cardinal = 24; + B_DRAW_ON_CHILDREN : Cardinal = 23; + _B_RESERVED7_ : Cardinal = 22; + +implementation + +var + View_AllAttached_hook : Pointer; cvar; external; + View_AllDetached_hook : Pointer; cvar; external; + View_AttachedToWindow_hook : Pointer; cvar; external; + View_DetachedFromWindow_hook : Pointer; cvar; external; + View_Draw_hook : Pointer; cvar; external; + View_DrawAfterChildren_hook : Pointer; cvar; external; + View_FrameMoved_hook : Pointer; cvar; external; + View_FrameResized_hook : Pointer; cvar; external; + View_GetPreferredSize_hook : Pointer; cvar; external; + View_ResizeToPreferred_hook : Pointer; cvar; external; + View_KeyDown_hook : Pointer; cvar; external; + View_KeyUp_hook : Pointer; cvar; external; + View_MouseDown_hook : Pointer; cvar; external; + View_MouseMoved_hook : Pointer; cvar; external; + View_MouseUp_hook : Pointer; cvar; external; + View_Pulse_hook : Pointer; cvar; external; + View_TargetedByScrollView_hook : Pointer; cvar; external; + View_WindowActivated_hook : Pointer; cvar; external; + +// View hook functions +{ + View_AllAttached_hook + View_AllDetached_hook + View_AttachedToWindow_hook + View_DetachedFromWindow_hook + View_Draw_hook + View_DrawAfterChildren_hook + View_FrameMoved_hook + View_FrameResized_hook + View_GetPreferredSize_hook + View_ResizeToPreferred_hook + View_KeyDown_hook + View_KeyUp_hook + View_MouseDown_hook + View_MouseMoved_hook + View_MouseUp_hook + View_Pulse_hook + View_TargetedByScrollView_hook + View_WindowActivated_hook} + + +constructor TView.Create(frame : TRect; name : PChar; resizingMode, flags : Cardinal); +begin + inherited Create; + CPlusObject := BView_Create(Self, frame.CPlusObject, name, resizingMode, flags); +end; + +destructor TView.Destroy; +begin + BView_Free(Self.CPlusObject); + inherited; +end; + +// Hook functions +procedure TView.AllAttached; +begin +end; + +procedure TView.AllDetached; +begin +end; + +procedure TView.AttachedToWindow; +begin +end; + +procedure TView.DetachedFromWindow; +begin +end; + +procedure TView.Draw(updateRect : TRect); +begin +end; + +procedure TView.DrawAfterChildren(updateRect : TRect); +begin +end; + +procedure TView.FrameMoved(parentPoint : TPoint); +begin +end; + +procedure TView.FrameResized(width, height : double); +begin +end; + +procedure TView.GetPreferredSize(var width : double; var height : double); +begin +end; + +procedure TView.ResizeToPreferred; +begin +end; + +procedure TView.KeyDown(bytes : PChar; numBytes : integer); +begin +end; + +procedure TView.KeyUp(bytes : PChar; numBytes : integer); +begin +end; + +procedure TView.MouseDown(point : TPoint); +begin +end; + +procedure TView.MouseMoved(point : TPoint; transit : Cardinal; message : TMessage); +begin +end; + +procedure TView.MouseUp(point : TPoint); +begin +end; + +procedure TView.Pulse; +begin +end; + +// procedure TView.TargetedByScrollView(); // Need BScrollView +//begin +//end; + +procedure TView.WindowActivated(active : boolean); +begin + Writeln('WindowActivated in View'); +end; + + +function TView.RemoveSelf : boolean; +begin + Result := BView_RemoveSelf(Self.CPlusObject); +end; + +procedure TView.AddChild(aView, before : TView); +begin + BView_AddChild(Self.CPlusObject, aView.CPlusObject, before.CPlusObject); +end; + +function TView.RemoveChild(aView : TView) : boolean; +begin + Result := BView_RemoveChild(Self.CPlusObject, aView); +end; + +function TView.CountChildren : integer; +begin + Result := BView_CountChildren(Self.CPlusObject); +end; + +function TView.ChildAt(index : integer) : TView; +begin + Result := TView.Wrap(BView_ChildAt(Self.CPlusObject, index)); +end; + +function TView.NextSibling : TView; +begin + Result := TView.Wrap(BView_NextSibling(Self.CPlusObject)); +end; + +function TView.PreviousSibling : TView; +begin + Result := TView.Wrap(BView_PreviousSibling(Self.CPlusObject)); +end; + +{function TView.Window : TWindow; +begin + Result := TWindow.Wrap(BView_Window(Self.CPlusObject)); +end;} + +// Hook functions +procedure View_AllAttached_hook_func(View : TView); cdecl; +begin + if View <> nil then + View.AllAttached; +end; + +procedure View_AllDetached_hook_func(View : TView); cdecl; +begin + if View <> nil then + View.AllDetached; +end; + +procedure View_AttachedToWindow_hook_func(View : TView); cdecl; +begin + if View <> nil then + View.AttachedToWindow; +end; + +procedure View_DetachedFromWindow_hook_func(View : TView); cdecl; +begin + if View <> nil then + View.DetachedFromWindow; +end; + +procedure View_Draw_hook_func(View : TView; aRect : TCPlusObject); cdecl; +var + Rect : TRect; +begin + Rect := TRect.Wrap(aRect); + try + if View <> nil then + View.Draw(Rect); + finally + Rect.UnWrap; + end; +end; + +procedure View_DrawAfterChildren_hook_func(View : TView; aRect : TCPlusObject); cdecl; +var + Rect : TRect; +begin + Rect := TRect.Wrap(aRect); + try + if View <> nil then + View.DrawAfterChildren(Rect); + finally + Rect.UnWrap; + end; +end; + +procedure View_FrameMoved_hook_func(View : TView; aPoint : TCPlusObject); cdecl; +var + Point : TPoint; +begin + Point := TPoint.Wrap(aPoint); + try + if View <> nil then + View.FrameMoved(Point); + finally + Point.UnWrap; + end; +end; + +procedure View_FrameResized_hook_func(View : TView; width, height : double); cdecl; +begin + if View <> nil then + View.FrameResized(width, height); +end; + +procedure View_GetPreferredSize_hook_func(View : TView; var width, height : double); cdecl; +begin + if View <> nil then + View.GetPreferredSize(width, height); +end; + +procedure View_ResizeToPreferred_hook_func(View : TView); cdecl; +begin + if View <> nil then + View.ResizeToPreferred; +end; + +procedure View_KeyDown_hook_func(View : TView; bytes : PChar; numBytes : integer); cdecl; +begin + if View <> nil then + View.KeyDown(bytes, numBytes); +end; + +procedure View_KeyUp_hook_func(View : TView; bytes : PChar; numBytes : integer); cdecl; +begin + if View <> nil then + View.KeyUp(bytes, numBytes); +end; + +procedure View_MouseDown_hook_func(View : TView; aPoint : TCPlusObject); cdecl; +var + Point : TPoint; +begin + Point := TPoint.Wrap(aPoint); + try + if View <> nil then + View.MouseDown(Point); + finally + Point.UnWrap; + end; +end; + +procedure View_MouseMoved_hook_func(View : TView; aPoint : TCPlusObject; transit : Cardinal; aMessage : TCPlusObject); cdecl; +var + Point : TPoint; + Message : TMessage; +begin + Point := TPoint.Wrap(aPoint); + try + Message := TMessage.Wrap(aMessage); + try + if View <> nil then + View.MouseMoved(Point, transit, Message); + finally + Message.UnWrap; + end; + finally + Point.UnWrap; + end; +end; + +procedure View_MouseUp_hook_func(View : TView; aPoint : TCPlusObject); cdecl; +var + Point : TPoint; +begin + Point := TPoint.Wrap(aPoint); + try + if View <> nil then + View.MouseDown(Point); + finally + Point.UnWrap; + end; +end; + +procedure View_Pulse_hook_func(View : TView); cdecl; +begin + if View <> nil then + View.Pulse; +end; + +//procedure View_TargetedByScrollView_hook_func(View : TView; scroller : TScrollView); cdecl; +//var +// ScrollView : TScrollView; +//begin +// ScrollView := TScrollView.Wrap(scroller); +// try +// if View <> nil then +// View.TargetedByScrollView(ScrollView); +// finally +// ScrollView.UnWrap; +// end; +//end; + +procedure View_WindowActivated_hook_func(View : TView; active : boolean); cdecl; +begin + if View <> nil then + View.WindowActivated(active); +end; + +var + _B_FOLLOW_NONE : Cardinal; cvar; external; + _B_FOLLOW_ALL_SIDES : Cardinal; cvar; external; + + _B_FOLLOW_ALL : Cardinal; cvar; external; + + _B_FOLLOW_LEFT : Cardinal; cvar; external; + _B_FOLLOW_RIGHT : Cardinal; cvar; external; + _B_FOLLOW_LEFT_RIGHT : Cardinal; cvar; external; + _B_FOLLOW_H_CENTER : Cardinal; cvar; external; + + _B_FOLLOW_TOP : Cardinal; cvar; external; + _B_FOLLOW_BOTTOM : Cardinal; cvar; external; + _B_FOLLOW_TOP_BOTTOM : Cardinal; cvar; external; + _B_FOLLOW_V_CENTER : Cardinal; cvar; external; + +initialization + B_FOLLOW_NONE := _B_FOLLOW_NONE; + B_FOLLOW_ALL_SIDES := _B_FOLLOW_ALL_SIDES; + + B_FOLLOW_ALL := _B_FOLLOW_ALL; + + B_FOLLOW_LEFT := _B_FOLLOW_LEFT; + B_FOLLOW_RIGHT := _B_FOLLOW_RIGHT; + B_FOLLOW_LEFT_RIGHT := _B_FOLLOW_LEFT_RIGHT; + B_FOLLOW_H_CENTER := _B_FOLLOW_H_CENTER; + + B_FOLLOW_TOP := _B_FOLLOW_TOP; + B_FOLLOW_BOTTOM := _B_FOLLOW_BOTTOM; + B_FOLLOW_TOP_BOTTOM := _B_FOLLOW_TOP_BOTTOM; + B_FOLLOW_V_CENTER := _B_FOLLOW_V_CENTER; + + // Connecting hook functions + View_AllAttached_hook := @View_AllAttached_hook_func; + View_AllDetached_hook := @View_AllDetached_hook_func; + View_AttachedToWindow_hook := @View_AttachedToWindow_hook_func; + View_DetachedFromWindow_hook := @View_DetachedFromWindow_hook_func; + View_Draw_hook := @View_Draw_hook_func; + View_DrawAfterChildren_hook := @View_DrawAfterChildren_hook_func; + View_FrameMoved_hook := @View_FrameMoved_hook_func; + View_FrameResized_hook := @View_FrameResized_hook_func; + View_GetPreferredSize_hook := @View_GetPreferredSize_hook_func; + View_ResizeToPreferred_hook := @View_ResizeToPreferred_hook_func; + View_KeyDown_hook := @View_KeyDown_hook_func; + View_KeyUp_hook := @View_KeyUp_hook_func; + View_MouseDown_hook := @View_MouseDown_hook_func; + View_MouseMoved_hook := @View_MouseMoved_hook_func; + View_MouseUp_hook := @View_MouseUp_hook_func; + View_Pulse_hook := @View_Pulse_hook_func; +// View_TargetedByScrollView_hook := @View_TargetedByScrollView_hook_func; + View_WindowActivated_hook := @View_WindowActivated_hook_func; + +end. \ No newline at end of file diff --git a/bepascal/bepascal/be/interface/window.pp b/bepascal/bepascal/be/interface/window.pp index ed02a9d..6eeda3e 100644 --- a/bepascal/bepascal/be/interface/window.pp +++ b/bepascal/bepascal/be/interface/window.pp @@ -21,7 +21,7 @@ unit Window; interface uses - beobj, looper, rect, os, application, appdefs; + beobj, looper, rect, os, application, view, appdefs; const // window_type @@ -72,11 +72,13 @@ const type TWindow = class(TLooper) public - constructor Create(frame : TRect; title : PChar; atype, flags, workspaces : Cardinal); + constructor Create(frame : TRect; title : PChar; atype, flags, workspaces : Cardinal); virtual; destructor Destroy; override; procedure Show; procedure Hide; - function QuitRequested : boolean; override; + procedure AddChild(aView : TView; sibling : TCPlusObject); + function QuitRequested : boolean; override; + function RemoveChild(aView : TView) : boolean; end; function BWindow_Create(AObject : TObject; frame : TCPlusObject; title : PChar; @@ -84,6 +86,8 @@ function BWindow_Create(AObject : TObject; frame : TCPlusObject; title : PChar; procedure BWindow_Free(CPlusObject : TCPlusObject); cdecl; external BePascalLibName name 'BWindow_Free'; procedure BWindow_Show(CPlusObject : TCPlusObject); cdecl; external BePascalLibName name 'BWindow_Show'; procedure BWindow_Hide(CPlusObject : TCPlusObject); cdecl; external BePascalLibName name 'BWindow_Hide'; +procedure BWindow_AddChild(CPlusObject : TCPlusObject; aView : TCPlusObject; sibling : TCPlusObject); cdecl; external BePascalLibName name 'BWindow_AddChild'; +function BWindow_RemoveChild(CPlusObject : TCPlusObject; aView : TCPlusObject) : boolean; cdecl; external BePascalLibName name 'BWindow_RemoveChild'; implementation @@ -115,6 +119,16 @@ begin BWindow_Hide(Self.CPlusObject); end; +procedure TWindow.AddChild(aView : TView; sibling : TCPlusObject); +begin + BWindow_AddChild(Self.CPlusObject, aView.CPlusObject, sibling); +end; + +function TWindow.RemoveChild(aView : TView) : boolean; +begin + result := BWindow_RemoveChild(Self.CPlusObject, aView.CPlusObject); +end; + initialization end. \ No newline at end of file