From 721f38c5f0548fdb98d02038f37cdaeabfb81a93 Mon Sep 17 00:00:00 2001 From: memson Date: Tue, 23 Apr 2002 18:37:29 +0000 Subject: [PATCH] *** empty log message *** --- begui/begui/imports/pascal/begui.pas | 219 +++++++++--------- .../begui/imports/pascal/examples/testapp.pas | 32 ++- .../imports/pascal/examples/testapp4.pas | 32 ++- begui/begui/libbegui/BeGUITestApp2.proj | Bin 13341 -> 14385 bytes begui/begui/libbegui/BeGuiAPI.cpp | 122 ++++++++-- begui/begui/libbegui/BeGuiAPI.h | 61 ++++- begui/begui/libbegui/BeGuiClasses.cpp | 186 ++++++++++++--- begui/begui/libbegui/BeGuiClasses.h | 19 +- begui/begui/libbegui/BeTestApp2.cpp | 24 +- begui/begui/libbegui/MFile.cpp | 4 + begui/begui/libbegui/MFile.h | 14 +- begui/begui/libbegui/filetest.proj | Bin 13212 -> 13284 bytes begui/begui/libbegui/libbegui.proj | Bin 13353 -> 14397 bytes begui/begui/libbegui/testfile.cpp | 40 +++- 14 files changed, 556 insertions(+), 197 deletions(-) diff --git a/begui/begui/imports/pascal/begui.pas b/begui/begui/imports/pascal/begui.pas index 6e13865..a928812 100644 --- a/begui/begui/imports/pascal/begui.pas +++ b/begui/begui/imports/pascal/begui.pas @@ -1,15 +1,21 @@ unit BeGUI; { -$Header: /home/haiku/befpc/begui/begui/imports/pascal/begui.pas,v 1.2 2002-04-02 20:42:15 memson Exp $ +$Header: /home/haiku/befpc/begui/begui/imports/pascal/begui.pas,v 1.3 2002-04-23 18:37:29 memson Exp $ -$Revision: 1.2 $ +$Revision: 1.3 $ $Log: not supported by cvs2svn $ +Revision 1.2 2002/04/02 20:42:15 memson +updated for Eric + } interface +uses + beutils; + type MApplicationH = pointer; MFormH = pointer; @@ -17,11 +23,13 @@ type MEditH = pointer; MPanelH = pointer; MMemoH = pointer; - + MMenuBarH = pointer; MMenuItemH = pointer; MMenuH = pointer; + MCheckBoxH = pointer; + uint32 = longword; int32 = longint; @@ -34,142 +42,129 @@ type mouseAction_Message = procedure (sender:pointer; x:double; y:double);cdecl; keyAction_Message = procedure (sender:pointer; bytes:Pchar; numBytes:int32);cdecl; drawAction_Message = procedure (sender:pointer; left:double; top:double; right:double; bottom:double);cdecl; - -const - //Memson 30/03/2002 : changed this for FPC1.06 compatibility - BEGUILIB = 'begui'; //must be in /boot/home/config/lib and /boot/develop/lib/x86 {$PACKRECORDS C} - { MenuBar} -// Jourde 01/04/2002 : add menu and menuitems - - function BMenuBar_Create( form : MFormh ; caption : pchar) : MMenuBarH; cdecl; external BEGUILIB; - function MMenuItem_Create(caption : pchar): MMenuItemh;cdecl; external BEGUILIB; - function BMenu_Create(caption : Pchar):MmenuH ;cdecl; external BEGUILIB; - procedure BMenuBar_AddItem( menuBar : MMenuBarH; Menu : MMenuH);cdecl; external BEGUILIB; +//////////////////////////////////////////////////////////////////////////////////// +// check Box +//////////////////////////////////////////////////////////////////////////////////// - procedure BMenu_AddItem(Menu : MMenuBarH; item : MMenuItemH );cdecl; external BEGUILIB; - procedure MMenuItem_AttachMenuClickDispatcher(Menu: MMenuItemH; msg: mouseAction_Message);cdecl; external BEGUILIB; +function MCheckBox_Create(left: double; top : double;right: double;bottom:double;caption:pchar):MCheckBoxH;cdecl; external LIBBEGUI; +function MCheckBox_Create_int32( left:int32; top:int32;right:int32; bottom:int32; caption:pchar):MCheckBoxH;cdecl; external LIBBEGUI; +function MForm_AddMCheckBox( frm:MFormH; left:double; top:double;right:double; bottom:double; name:pchar):MCheckBoxH;cdecl; external LIBBEGUI; +function MForm_AddMCheckBox_int32( frm:MFormH; left:int32; top:int32;right:int32; bottom:int32; name:pchar):MCheckBoxH;cdecl; external LIBBEGUI; + + +//////////////////////////////////////////////////////////////////////////////////// +// MenuBar +//////////////////////////////////////////////////////////////////////////////////// + + + function BMenuBar_Create( form : MFormh ; caption : pchar) : MMenuBarH; cdecl; external LIBBEGUI; + function BMenu_Create(caption : Pchar):MmenuH ;cdecl; external LIBBEGUI; + procedure BMenuBar_AddItem( menuBar : MMenuBarH; Menu : MMenuH);cdecl; external LIBBEGUI; + procedure BMenu_AddItem(Menu : MMenuBarH; item : MMenuItemH );cdecl; external LIBBEGUI; + + function MMenuItem_Create(caption : pchar): MMenuItemh;cdecl; external LIBBEGUI; + procedure MMenuItem_AttachMenuClickDispatcher(Menu: MMenuItemH; msg: mouseAction_Message);cdecl; external LIBBEGUI; + + +//////////////////////////////////////////////////////////////////////////////////// +// Application +//////////////////////////////////////////////////////////////////////////////////// + + function MApplication_Create: MApplicationH; cdecl; external LIBBEGUI; + procedure MApplication_Free(app:MApplicationH); cdecl; external LIBBEGUI; + procedure MApplication_Run(app:MApplicationH); cdecl; external LIBBEGUI; + function MApplication_GetMainForm(app:MApplicationH):MFormH; cdecl; external LIBBEGUI; + function MApplication_AddForm(app:MApplicationH; left:double; top:double; right:double; bottom:double;name:Pchar; caption:Pchar):MFormH; cdecl; external LIBBEGUI; + function MApplication_AddForm_int32(app:MApplicationH; left:int32; top:int32; right:int32; bottom:int32;name:Pchar; caption:Pchar):MFormH; cdecl; external LIBBEGUI; - function MApplication_Create: MApplicationH; cdecl; external BEGUILIB; - procedure MApplication_Free(app:MApplicationH); cdecl; external BEGUILIB; +//////////////////////////////////////////////////////////////////////////////////// +// Form +//////////////////////////////////////////////////////////////////////////////////// + function MForm_AddMEdit_int32(form:MFormH; left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MEditH; external LIBBEGUI; + function MForm_AddMPanel_int32(frm:MFormH; left:int32; top:int32; right:int32; bottom:int32; name:Pchar):MPanelH;cdecl; external LIBBEGUI; + procedure MForm_AddChild(form:MFormH; ctrl:pointer); cdecl; external LIBBEGUI; + procedure MForm_AttachMouseMovedDispatcher(form:MFormH; msg:mouseMoved_Message);cdecl; external LIBBEGUI; + procedure MForm_AttachMouseDownDispatcher(form:MFormH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MForm_AttachMouseUpDispatcher(form:MFormH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MForm_AttachKeyDownDispatcher(form:MFormH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MForm_AttachKeyUpDispatcher(form:MFormH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MForm_AttachDrawDispatcher(form:MFormH; msg:drawAction_Message);cdecl; external LIBBEGUI; + procedure MForm_Show(frm:MFormH);cdecl; external LIBBEGUI; + procedure MForm_Hide(frm:MFormH);cdecl; external LIBBEGUI; - procedure MApplication_Run(app:MApplicationH); cdecl; external BEGUILIB; - function MApplication_GetMainForm(app:MApplicationH):MFormH; cdecl; external BEGUILIB; - function MApplication_AddForm(app:MApplicationH; left:double; top:double; right:double; bottom:double; - name:Pchar; caption:Pchar):MFormH; cdecl; external BEGUILIB; +//////////////////////////////////////////////////////////////////////////////////// +// button +//////////////////////////////////////////////////////////////////////////////////// + function MButton_Create(left:double; top:double; right:double; bottom:double; caption:Pchar):MButtonH;cdecl; external LIBBEGUI; + function MButton_Create_int32(left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MButtonH; external LIBBEGUI; + procedure MButton_AttachClickDispatcher(btn:MButtonH; msg:base_Message);cdecl; external LIBBEGUI; + function MButton_getCaption(btn:MButtonH):pchar;cdecl; external LIBBEGUI; + procedure MButton_setCaption(btn:MButtonH; caption:Pchar);cdecl; external LIBBEGUI; + procedure MButton_AttachMouseMovedDispatcher(btn:MButtonH; msg:mouseMoved_Message);cdecl; external LIBBEGUI; + procedure MButton_AttachMouseDownDispatcher(btn:MButtonH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MButton_AttachMouseUpDispatcher(btn:MButtonH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MButton_AttachKeyDownDispatcher(btn:MButtonH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MButton_AttachKeyUpDispatcher(btn:MButtonH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MButton_AttachDrawDispatcher(btn:MButtonH; msg:drawAction_Message);cdecl; external LIBBEGUI; - function MApplication_AddForm_int32(app:MApplicationH; left:int32; top:int32; right:int32; bottom:int32; - name:Pchar; caption:Pchar):MFormH; cdecl; external BEGUILIB; - {added to get round fpc's inability to pass 'float' params...} - function MButton_Create_int32(left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MButtonH; external BEGUILIB; +//////////////////////////////////////////////////////////////////////////////////// +// edit +//////////////////////////////////////////////////////////////////////////////////// + function MForm_AddMEdit(form:MFormH; left:double; top:double; right:double; bottom:double;caption:Pchar):MEditH;cdecl; external LIBBEGUI; + function MEdit_getText(edt:MEditH):Pchar;cdecl; external LIBBEGUI; + procedure MEdit_setText(edt:MEditH; text:Pchar);cdecl; external LIBBEGUI; + procedure MEdit_AttachClickDispatcher(edt:MEditH; msg:base_Message);cdecl; external LIBBEGUI; + procedure MEdit_AttachMouseMovedDispatcher(edt:MEditH; msg:mouseMoved_Message);cdecl; external LIBBEGUI; + procedure MEdit_AttachMouseDownDispatcher(edt:MEditH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MEdit_AttachMouseUpDispatcher(edt:MEditH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MEdit_AttachKeyDownDispatcher(edt:MEditH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MEdit_AttachKeyUpDispatcher(edt:MEditH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MEdit_AttachDrawDispatcher(edt:MEditH; msg:drawAction_Message);cdecl; external LIBBEGUI; - function MForm_AddMEdit_int32(form:MFormH; left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MEditH; external BEGUILIB; - function MForm_AddMMemo_int32(form:MFormH; left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MMemoH; cdecl; external BEGUILIB; - function MForm_AddMPanel_int32(frm:MFormH; left:int32; top:int32; right:int32; bottom:int32; name:Pchar):MPanelH;cdecl; external BEGUILIB; +//////////////////////////////////////////////////////////////////////////////////// +// memo +//////////////////////////////////////////////////////////////////////////////////// + function MForm_AddMMemo(form:MFormH; left:double; top:double; right:double; bottom:double; caption:Pchar):MMemoH;cdecl; external LIBBEGUI; + function MForm_AddMMemo_int32(form:MFormH; left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MMemoH; cdecl; external LIBBEGUI; + procedure MMemo_AttachMouseMovedDispatcher(memo:MMemoH; msg:mouseMoved_Message);cdecl; external LIBBEGUI; + procedure MMemo_AttachMouseDownDispatcher(memo:MMemoH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MMemo_AttachMouseUpDispatcher(memo:MMemoH; msg:mouseAction_Message);cdecl; external LIBBEGUI; + procedure MMemo_AttachKeyDownDispatcher(memo:MMemoH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MMemo_AttachKeyUpDispatcher(memo:MMemoH; msg:keyAction_Message);cdecl; external LIBBEGUI; + procedure MMemo_AttachDrawDispatcher(memo:MMemoH; msg:drawAction_Message);cdecl; external LIBBEGUI; + function MMemo_Text(memo:MMemoH) :pchar ;cdecl; external LIBBEGUI; + function MMemo_TextLength(memo:MMemoH) : Integer ;cdecl; external LIBBEGUI; + procedure MMemo_SetText(memo :MMemoH; text: Pchar);cdecl; external LIBBEGUI; - {form } - procedure MForm_AddChild(form:MFormH; ctrl:pointer); cdecl; external BEGUILIB; - procedure MForm_AttachMouseMovedDispatcher(form:MFormH; msg:mouseMoved_Message);cdecl; external BEGUILIB; +//////////////////////////////////////////////////////////////////////////////////// +// panel +//////////////////////////////////////////////////////////////////////////////////// + function MForm_AddMPanel(frm:MFormH; left:double; top:double; right:double; bottom:double;name:Pchar):MPanelH;cdecl; external LIBBEGUI; - procedure MForm_AttachMouseDownDispatcher(form:MFormH; msg:mouseAction_Message);cdecl; external BEGUILIB; - procedure MForm_AttachMouseUpDispatcher(form:MFormH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MForm_AttachKeyDownDispatcher(form:MFormH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MForm_AttachKeyUpDispatcher(form:MFormH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MForm_AttachDrawDispatcher(form:MFormH; msg:drawAction_Message);cdecl; external BEGUILIB; - - procedure MForm_Show(frm:MFormH);cdecl; external BEGUILIB; - - procedure MForm_Hide(frm:MFormH);cdecl; external BEGUILIB; - - {button } - function MButton_Create(left:double; top:double; right:double; bottom:double; caption:Pchar):MButtonH;cdecl; external BEGUILIB; - - procedure MButton_AttachClickDispatcher(btn:MButtonH; msg:base_Message);cdecl; external BEGUILIB; - - function MButton_getCaption(btn:MButtonH):pchar;cdecl; external BEGUILIB; - - procedure MButton_setCaption(btn:MButtonH; caption:Pchar);cdecl; external BEGUILIB; - - procedure MButton_AttachMouseMovedDispatcher(btn:MButtonH; msg:mouseMoved_Message);cdecl; external BEGUILIB; - - procedure MButton_AttachMouseDownDispatcher(btn:MButtonH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MButton_AttachMouseUpDispatcher(btn:MButtonH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MButton_AttachKeyDownDispatcher(btn:MButtonH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MButton_AttachKeyUpDispatcher(btn:MButtonH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MButton_AttachDrawDispatcher(btn:MButtonH; msg:drawAction_Message);cdecl; external BEGUILIB; - - {edit } - function MForm_AddMEdit(form:MFormH; left:double; top:double; right:double; bottom:double; - caption:Pchar):MEditH;cdecl; external BEGUILIB; - - function MEdit_getText(edt:MEditH):Pchar;cdecl; external BEGUILIB; - - procedure MEdit_setText(edt:MEditH; text:Pchar);cdecl; external BEGUILIB; - - procedure MEdit_AttachClickDispatcher(edt:MEditH; msg:base_Message);cdecl; external BEGUILIB; - - procedure MEdit_AttachMouseMovedDispatcher(edt:MEditH; msg:mouseMoved_Message);cdecl; external BEGUILIB; - - procedure MEdit_AttachMouseDownDispatcher(edt:MEditH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MEdit_AttachMouseUpDispatcher(edt:MEditH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MEdit_AttachKeyDownDispatcher(edt:MEditH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MEdit_AttachKeyUpDispatcher(edt:MEditH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MEdit_AttachDrawDispatcher(edt:MEditH; msg:drawAction_Message);cdecl; external BEGUILIB; - - {memo } - function MForm_AddMMemo(form:MFormH; left:double; top:double; right:double; bottom:double; - caption:Pchar):MMemoH;cdecl; external BEGUILIB; - - procedure MMemo_AttachMouseMovedDispatcher(memo:MMemoH; msg:mouseMoved_Message);cdecl; external BEGUILIB; - - procedure MMemo_AttachMouseDownDispatcher(memo:MMemoH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MMemo_AttachMouseUpDispatcher(memo:MMemoH; msg:mouseAction_Message);cdecl; external BEGUILIB; - - procedure MMemo_AttachKeyDownDispatcher(memo:MMemoH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MMemo_AttachKeyUpDispatcher(memo:MMemoH; msg:keyAction_Message);cdecl; external BEGUILIB; - - procedure MMemo_AttachDrawDispatcher(memo:MMemoH; msg:drawAction_Message);cdecl; external BEGUILIB; - - {panel } - function MForm_AddMPanel(frm:MFormH; left:double; top:double; right:double; bottom:double; - name:Pchar):MPanelH;cdecl; external BEGUILIB; {needed?? } - function GetBaseMessage:uint32;cdecl; external BEGUILIB; + function GetBaseMessage:uint32;cdecl; external LIBBEGUI; - function GetNextMessage:uint32;cdecl; external BEGUILIB; + function GetNextMessage:uint32;cdecl; external LIBBEGUI; -(* Const before type ignored *) - procedure GenericAlert(message:Pchar);cdecl; external BEGUILIB; + procedure GenericAlert(message:Pchar);cdecl; external LIBBEGUI; - procedure testfloat(f: integer);cdecl; external BEGUILIB; + procedure testfloat(f: integer);cdecl; external LIBBEGUI; implementation diff --git a/begui/begui/imports/pascal/examples/testapp.pas b/begui/begui/imports/pascal/examples/testapp.pas index 8bdf8da..32aff3e 100644 --- a/begui/begui/imports/pascal/examples/testapp.pas +++ b/begui/begui/imports/pascal/examples/testapp.pas @@ -2,19 +2,33 @@ program TespApp; uses BeGUI; +var + TestMsg: array[0..10] of char; + + Button1: MButtonH; + Button2: MButtonH; + Edit1: MEditH; + Memo : MMemoH; + MainForm: MFormH; + a: integer; + procedure EventTest(sender: pointer; msg: uint32); begin if sender <> nil then GenericAlert(MButton_getCaption(sender)); end; -var - TestMsg: array[0..10] of char; +procedure Eventlength(sender: pointer; msg: uint32); +Var test : Pchar; +begin + if sender <> nil then + Begin + MMemo_SetText(memo,pchar('Free Pascal Compiler v0.6.0')); + GenericAlert(MMemo_Text(memo)); + End; +end; + - Button1: MButtonH; - Edit1: MEditH; - MainForm: MFormH; - a: integer; begin TestMsg := 'Test'#0; @@ -26,6 +40,12 @@ begin MForm_AddChild(MainForm, Button1); Edit1 := MForm_AddMEdit_int32(MainForm, 30, 100, 150, 150, @TestMsg); + + Memo := MForm_AddMMemo_int32(MainForm,30,200,200,400,pchar('Memo')); + + Button2 := MButton_Create_int32(100, 120, 150, 140, pchar('Change')); + MButton_AttachClickDispatcher(Button2, base_Message(@Eventlength)); + MForm_AddChild(MainForm, Button2); MApplication_Run(Application); end. \ No newline at end of file diff --git a/begui/begui/imports/pascal/examples/testapp4.pas b/begui/begui/imports/pascal/examples/testapp4.pas index 99b2a08..41fca2c 100644 --- a/begui/begui/imports/pascal/examples/testapp4.pas +++ b/begui/begui/imports/pascal/examples/testapp4.pas @@ -3,6 +3,26 @@ program TespApp4; uses BeGUI,About,Strings; +Type TButton = Class(TObject) + private + MButton : pointer; + public + Top,Left,Width,heitgh : Integer; + Constructor Create(Form : MFormh;aTop,aLeft,aWidth,aheitgh : Integer); + //Property OnClick :base_Message Write Click_Action; + Click_action :base_Message; +End; + PButton = ^TButton; + +Constructor TButton.Create(Form : MFormh;aTop,aLeft,aWidth,aheitgh : Integer); +Begin + // GenericAlert(pchar('create')); + MButton:=MButton_Create_int32(170,20,190,30, pchar('C')); + MForm_AddChild(Form, MButton); +End; + +Var But : TButton; + procedure MenuClick(sender: pointer; x:double; y:double); begin if sender <> nil then @@ -36,6 +56,7 @@ Var Mem_Op : String[20]; Mem_Operande : integer; + Check1 : MCheckBoxH; Const Pos_X : Array[1..3] of integer=(20,60,100); @@ -262,6 +283,12 @@ begin MainForm := MApplication_GetMainForm(Application); + Check1:=MCheckBox_Create_int32(250,100,260,110,pchar('toto')); + MForm_AddChild(MainForm, Check1); + Check1:=MForm_AddMCheckBox_int32( MainForm,250,200,260,210,pchar('toto')); +// MForm_AddChild(MainForm, Check1); + + mb := BMenuBar_Create(MainForm, pchar('main')); Menu_Quit := MMenuItem_Create(pchar('Close')); MMenuItem_AttachMenuClickDispatcher(Menu_Quit, @menuClick_Quit); @@ -276,7 +303,10 @@ begin MMenuItem_AttachMenuClickDispatcher(Menu_About, @menuClick_About); BMenuBar_AddItem(mb, mnu_Help); - Create_Calculator(MainForm); + // test Object + //but := TButton.Create(MainForm,20,20,30,30); + + //Create_Calculator(MainForm); Create_About; MApplication_Run(Application); diff --git a/begui/begui/libbegui/BeGUITestApp2.proj b/begui/begui/libbegui/BeGUITestApp2.proj index 5dd912be631dbbdc0ddccbe680dc89b88197419b..42ff0b39c8cafc0f486b81b93af1fa0e095c2c2d 100644 GIT binary patch delta 402 zcmbQ6v9UnF*VDz7fx$x4C7>vcfkFS!L;($spuB)01_l zvtjZAUdPR>>^D^`WHQ7WPVChD3(|H;p8*VFc4+=(=HhM00g8WNk!k>`SppOTNqzv* zdl?uSCRggjOunzrzPVB-m@$G}Q`|Ch41tFJVPIfO0MaZ_%+LU2*z6BrpPXl?HrY$> zgsA!lpa>5TGXpVHI&gBLuKHv@{Y7E{0zg5K3S?O(ux1^DC88i%5MTrm4M1$O-{&Y$ c)@HJzp@rxJpnw4oqsw-hlI5$-Iz}HE0gY01asU7T delta 391 zcmdm3FgHWM*VDz7fx$%7C7>vcfkAuSL;;P>J}ezw1 zpy=`!q->uy0~q{}clmocm$!ihD8A;4b^}Nahz*kLP;mKc&A`wwxz`|ObDKdFV+6S- zxMk)T0uB7bz`zEi7*&7-3lK9j0I|*X0Canvas()->AddMemo(btnRect, caption); } +MMemo* MForm_AddMMemo_int32(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption){ + BRect btnRect(left, top, right, bottom); + return form->Canvas()->AddMemo(btnRect, caption); +} + int32 MForm_getWidth(MForm *frm){ return 0; } @@ -205,16 +215,16 @@ int32 MForm_getHeight(MForm *frm){ } void MForm_setWidth(MForm *frm, int32 value){ - if (frm->Lock()) { + if (frm->LockLooper()) { frm->setWidth(value); - frm->Unlock(); + frm->UnlockLooper(); } } void MForm_setHeight(MForm *frm, int32 value){ - if (frm->Lock()) { + if (frm->LockLooper()) { frm->setHeight(value); - frm->Unlock(); + frm->UnlockLooper(); } } @@ -326,6 +336,56 @@ bool MCheckBox_Checked(MCheckBox *cbx){ /// +MRadioButton* MRadioButton_Create(float left, float top, float right, float bottom, char *caption){ + BRect btnRect(left, top, right, bottom); + + return new MRadioButton( btnRect, caption ); +} + +MRadioButton* MRadioButton_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption){ + BRect btnRect(left, top, right, bottom); + + return new MRadioButton( btnRect, caption ); +} + +char* MRadioButton_getCaption(MRadioButton *rbtn){ + return const_cast(rbtn->Label()); +} + +void MRadioButton_setCaption(MRadioButton *rbtn, char* caption){ + rbtn->SetLabel(caption); +} + +void MRadioButton_AttachMouseMovedDispatcher(MRadioButton *rbtn, mouseMoved_Message msg){ + rbtn->AttachMouseMovedDispatcher(msg); +} + +void MRadioButton_AttachMouseDownDispatcher(MRadioButton *rbtn, mouseAction_Message msg){ + rbtn->AttachMouseDownDispatcher(msg); +} + +void MRadioButton_AttachMouseUpDispatcher(MRadioButton *rbtn, mouseAction_Message msg){ + rbtn->AttachMouseUpDispatcher(msg); +} + +void MRadioButton_AttachKeyDownDispatcher(MRadioButton *rbtn, keyAction_Message msg){ + rbtn->AttachKeyDownDispatcher(msg); +} + +void MRadioButton_AttachKeyUpDispatcher(MRadioButton *rbtn, keyAction_Message msg){ + rbtn->AttachKeyUpDispatcher(msg); +} + +void MRadioButton_AttachDrawDispatcher(MRadioButton *rbtn, drawAction_Message msg){ + rbtn->AttachDrawDispatcher(msg); +} + +bool MRadioButton_Checked(MRadioButton *rbtn){ + return rbtn->Checked(); +} + +/// + void MForm_AttachMouseMovedDispatcher(MForm *form, mouseMoved_Message msg){ form->Canvas()->AttachMouseMovedDispatcher(msg); } @@ -352,10 +412,10 @@ void MForm_AttachKeyUpDispatcher(MForm *form, keyAction_Message msg){ void MForm_Show(MForm *frm){ printf("about to lock\n"); - if (frm->Lock()) { + if (frm->LockLooper()) { frm->Show(); printf("after show\n"); - frm->Unlock(); + frm->UnlockLooper(); printf("unlocked\n"); } else printf("lock failed\n"); @@ -400,9 +460,10 @@ char* MEdit_getText(MEdit* edt){ } void MEdit_setText(MEdit* edt, char* text){ - edt->LockLooper(); - edt->SetText(text); - edt->UnlockLooper(); + if (edt->LockLooper()){ + edt->SetText(text); + edt->UnlockLooper(); + } } /// @@ -439,6 +500,13 @@ int32 MMemo_TextLength(MMemo *memo){ return memo->getTextView()->TextLength(); } +void MMemo_SetText(MMemo *memo, char *text){ + if (memo->LockLooper()){ + memo->getTextView()->SetText(text); + memo->UnlockLooper(); + } +} + /// MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, float bottom, char *name){ @@ -447,6 +515,12 @@ MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, fl return frm->Canvas()->AddCheckBox( cbxRect, name ); } +MCheckBox* MForm_AddMCheckBox_int32(MForm* frm, int32 left, int32 top, int32 right, int32 bottom, char *name){ + BRect cbxRect(left, top, right, bottom); + + return frm->Canvas()->AddCheckBox( cbxRect, name ); +} + /// MPanel* MForm_AddMPanel(MForm* frm, float left, float top, float right, float bottom, char *name){ @@ -461,12 +535,17 @@ MPanel* MForm_AddMPanel_int32(MForm* frm, int32 left, int32 top, int32 right, in return frm->Canvas()->AddPanel( pnlRect, name ); } +void MPanel_AddChild(MPanel *panel, BControl* ctrl){ + panel->AddChild(ctrl); +} + /// void MForm_AddPopUpMenu(MForm *frm, MPopUpMenu *mni){ - frm->Lock(); - frm->Canvas()->setPopUpMenu(mni); - frm->Unlock(); + if (frm->LockLooper()){ + frm->Canvas()->setPopUpMenu(mni); + frm->UnlockLooper(); + } } MPopUpMenu* MPopUpMenu_Create(const char *name){ @@ -496,10 +575,11 @@ BMenuBar* BMenuBar_Create(MForm* frm, const char *name) BRect menuBarRect; menuBarRect.Set(0.0, 0.0, 32000.0, MENU_BAR_HEIGHT); BMenuBar *mb = new BMenuBar(menuBarRect, "mainmenubar"); - frm->Lock(); - frm->ResizeBy(0.0, MENU_BAR_HEIGHT); - frm->Canvas()->AddChild(mb); - frm->Unlock(); + if (frm->LockLooper()){ + frm->ResizeBy(0.0, MENU_BAR_HEIGHT); + frm->Canvas()->AddChild(mb); + frm->UnlockLooper(); + } return mb; } @@ -544,15 +624,15 @@ void GenericAlert(const char *message){ #include -status_t be_beep(){ +status_t beapi_beep(){ return beep(); } -status_t be_system_beep(const char * event_name){ +status_t beapi_system_beep(const char * event_name){ return system_beep(event_name); } -status_t be_add_system_beep_event(const char * event_name, uint32 flags){ +status_t beapi_add_system_beep_event(const char * event_name, uint32 flags){ return add_system_beep_event(event_name, flags); } diff --git a/begui/begui/libbegui/BeGuiAPI.h b/begui/begui/libbegui/BeGuiAPI.h index c4e50cf..ab05815 100644 --- a/begui/begui/libbegui/BeGuiAPI.h +++ b/begui/begui/libbegui/BeGuiAPI.h @@ -16,6 +16,7 @@ #include #include #include +#include "MFont.h" #include "MList.h" #include "BeGuiClasses.h" @@ -40,16 +41,19 @@ int CTest_GetValue(CTest* ptr); void CTest_Free(CTest* ptr); void CTest_SetValue(CTest* ptr, int val); -//application +//////////////////////////////////////////////////////////////////////////////////// +// application +//////////////////////////////////////////////////////////////////////////////////// MApplication* MApplication_Create(void); void MApplication_Free(MApplication *app); void MApplication_Run(MApplication *app); MForm* MApplication_GetMainForm(MApplication *app); MForm* MApplication_AddForm(MApplication *app, float left, float top, float right, float bottom, char *name, char *caption); -//eric 27/03/2002 MForm* MApplication_AddForm_int32(MApplication *app, int32 left, int32 top, int32 right, int32 bottom, char *name, char *caption); -//form +//////////////////////////////////////////////////////////////////////////////////// +// form +//////////////////////////////////////////////////////////////////////////////////// void MForm_AddChild(MForm *form, BControl* ctrl); void MForm_AttachMouseMovedDispatcher(MForm *form, mouseMoved_Message msg); void MForm_AttachMouseDownDispatcher(MForm *form, mouseAction_Message msg); @@ -65,7 +69,9 @@ int32 MForm_getHeight(MForm *frm); void MForm_setWidth(MForm *frm, int32 value); void MForm_setHeight(MForm *frm, int32 value); +//////////////////////////////////////////////////////////////////////////////////// //button +//////////////////////////////////////////////////////////////////////////////////// MButton* MButton_Create(float left, float top, float right, float bottom, char *caption); MButton* MButton_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption); void MButton_AttachClickDispatcher(MButton *btn, base_Message msg); @@ -78,7 +84,9 @@ void MButton_AttachKeyDownDispatcher(MButton *btn, keyAction_Message msg); void MButton_AttachKeyUpDispatcher(MButton *btn, keyAction_Message msg); void MButton_AttachDrawDispatcher(MButton *btn, drawAction_Message msg); +//////////////////////////////////////////////////////////////////////////////////// //edit +//////////////////////////////////////////////////////////////////////////////////// MEdit* MForm_AddMEdit(MForm *form, float left, float top, float right, float bottom, char *caption); MEdit* MForm_AddMEdit_int32(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption); char* MEdit_getText(MEdit* edt); @@ -91,7 +99,9 @@ void MEdit_AttachKeyDownDispatcher(MEdit *edt, keyAction_Message msg); void MEdit_AttachKeyUpDispatcher(MEdit *edt, keyAction_Message msg); void MEdit_AttachDrawDispatcher(MEdit *edt, drawAction_Message msg); +//////////////////////////////////////////////////////////////////////////////////// //memo +//////////////////////////////////////////////////////////////////////////////////// MMemo* MForm_AddMMemo(MForm *form, float left, float top, float right, float bottom, char *caption); MMemo* MForm_AddMMemo_int32(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption); void MMemo_AttachMouseMovedDispatcher(MMemo *memo, mouseMoved_Message msg); @@ -102,31 +112,46 @@ void MMemo_AttachKeyUpDispatcher(MMemo *memo, keyAction_Message msg); void MMemo_AttachDrawDispatcher(MMemo *memo, drawAction_Message msg); const char* MMemo_Text(MMemo *memo); int32 MMemo_TextLength(MMemo *memo); +void MMemo_SetText(MMemo *memo, char *text); +//////////////////////////////////////////////////////////////////////////////////// //panel +//////////////////////////////////////////////////////////////////////////////////// MPanel* MForm_AddMPanel(MForm* frm, float left, float top, float right, float bottom, char *name); MPanel* MForm_AddMPanel_int32(MForm* frm, int32 left, int32 top, int32 right, int32 bottom, char *name); +void MPanel_AddChild(MPanel *panel, BControl* ctrl); +//////////////////////////////////////////////////////////////////////////////////// //popupmenu +//////////////////////////////////////////////////////////////////////////////////// MPopUpMenu* MPopUpMenu_Create(const char *name); void MPopUpMenu_AddItem(MPopUpMenu *mnu, MMenuItem *itm); +//////////////////////////////////////////////////////////////////////////////////// //menuitem +//////////////////////////////////////////////////////////////////////////////////// MMenuItem* MMenuItem_Create(const char *name); void MMenuItem_AttachMenuClickDispatcher(MMenuItem *mni, base_Message msg); +//////////////////////////////////////////////////////////////////////////////////// //menubar +//////////////////////////////////////////////////////////////////////////////////// BMenuBar* BMenuBar_Create(MForm* frm, const char *name); void BMenuBar_AddItem(BMenuBar *mnu, BMenu *itm); +//////////////////////////////////////////////////////////////////////////////////// //BMenu +//////////////////////////////////////////////////////////////////////////////////// BMenu* BMenu_Create(const char *name); void BMenu_AddItem(BMenu *mnu, MMenuItem *itm); +//////////////////////////////////////////////////////////////////////////////////// //checkbox +//////////////////////////////////////////////////////////////////////////////////// MCheckBox* MCheckBox_Create(float left, float top, float right, float bottom, char *caption); MCheckBox* MCheckBox_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption); MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, float bottom, char *name); +MCheckBox* MForm_AddMCheckBox_int32(MForm* frm, int32 left, int32 top, int32 right, int32 bottom, char *name); char* MCheckBox_getCaption(MCheckBox *cbx); void MCheckBox_setCaption(MCheckBox *cbx, char* caption); void MCheckBox_AttachMouseMovedDispatcher(MCheckBox *cbx, mouseMoved_Message msg); @@ -137,15 +162,37 @@ void MCheckBox_AttachKeyUpDispatcher(MCheckBox *cbx, keyAction_Message msg); void MCheckBox_AttachDrawDispatcher(MCheckBox *cbx, drawAction_Message msg); bool MCheckBox_Checked(MCheckBox *cbx); +//////////////////////////////////////////////////////////////////////////////////// +//radiobutton +//////////////////////////////////////////////////////////////////////////////////// +MRadioButton* MRadioButton_Create(float left, float top, float right, float bottom, char *caption); +MRadioButton* MRadioButton_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption); +MRadioButton* MForm_AddMRadioButton(MForm* frm, float left, float top, float right, float bottom, char *name); +MRadioButton* MForm_AddMRadioButton_int32(MForm* frm, int32 left, int32 top, int32 right, int32 bottom, char *name); +char* MRadioButton_getCaption(MRadioButton *cbx); +void MRadioButton_setCaption(MRadioButton *cbx, char* caption); +void MRadioButton_AttachMouseMovedDispatcher(MRadioButton *cbx, mouseMoved_Message msg); +void MRadioButton_AttachMouseDownDispatcher(MRadioButton *cbx, mouseAction_Message msg); +void MRadioButton_AttachMouseUpDispatcher(MRadioButton *cbx, mouseAction_Message msg); +void MRadioButton_AttachKeyDownDispatcher(MRadioButton *cbx, keyAction_Message msg); +void MRadioButton_AttachKeyUpDispatcher(MRadioButton *cbx, keyAction_Message msg); +void MRadioButton_AttachDrawDispatcher(MRadioButton *cbx, drawAction_Message msg); +bool MRadioButton_Checked(MRadioButton *cbx); + +//////////////////////////////////////////////////////////////////////////////////// +//api +//////////////////////////////////////////////////////////////////////////////////// + +status_t beapi_beep(); +status_t beapi_system_beep(const char * event_name); +status_t beapi_add_system_beep_event(const char * event_name, uint32 flags); +int beapi_testfunc(); + //needed?? uint32 GetBaseMessage(void); uint32 GetNextMessage(void); void GenericAlert(const char *message); -status_t be_beep(); -status_t be_system_beep(const char * event_name); -status_t be_add_system_beep_event(const char * event_name, uint32 flags); - #ifdef __cplusplus } #endif diff --git a/begui/begui/libbegui/BeGuiClasses.cpp b/begui/begui/libbegui/BeGuiClasses.cpp index 18d5157..e60e41d 100644 --- a/begui/begui/libbegui/BeGuiClasses.cpp +++ b/begui/begui/libbegui/BeGuiClasses.cpp @@ -1,9 +1,18 @@ /* - $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiClasses.cpp,v 1.2 2002-04-12 23:32:56 memson Exp $ + $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiClasses.cpp,v 1.3 2002-04-23 18:37:29 memson Exp $ - $Revision: 1.2 $ + $Revision: 1.3 $ $Log: not supported by cvs2svn $ + Revision 1.2 2002/04/12 23:32:56 memson + + Added quite a bit. + + Got basic file handling soeted out. Also got the FilePanel's working (see + example project) + + Popup menu now only responds to a right click (at last!!) + Revision 1.1.1.1 2002/03/31 10:36:16 memson initial import into sourceforge @@ -121,7 +130,6 @@ //////////////////////////////////////// //////////////////////////////////////// - // List classes... //List item for storing GUI classes... @@ -188,7 +196,6 @@ void MPropertyPlugin::setOwner(BArchivable *AOwner) } ////////////////////////////////////////// - // Property Plugin Class... MMenuPropertyPlugin::MMenuPropertyPlugin(BArchivable *AOwner): @@ -214,7 +221,6 @@ MPopUpMenu* MMenuPropertyPlugin::getPopUpMenu(void) } ////////////////////////////////////////// - // EventPlugin Class... MEventPlugin::MEventPlugin() @@ -254,7 +260,6 @@ void MEventPlugin::DoDestroy(BControl *self) } ////////////////////////////////////////// - // MMenuEventPlugin::MMenuEventPlugin() @@ -280,7 +285,6 @@ void MMenuEventPlugin::AttachMenuClickDispatcher(base_Message value) } ////////////////////////////////////////// - //BasicEventPlugin Class... MBasicEventPlugin::MBasicEventPlugin(): @@ -321,7 +325,6 @@ void MBasicEventPlugin::DoClick(BControl *self) } ////////////////////////////////////////// - //ControlEventPlugin Class... MControlEventPlugin::MControlEventPlugin(): @@ -390,7 +393,6 @@ void MControlEventPlugin::DoKeyPress(BControl *self, const char *bytes, int32 nu } ////////////////////////////////////////// - // Form Event Property MFormEventPlugin::MFormEventPlugin(): @@ -417,7 +419,6 @@ void MFormEventPlugin::DoClose(BView *self, MCloseAction &closeAction) } ////////////////////////////////////////// - //Panel Class... MPanel::MPanel(BRect ClientArea, char *name): @@ -433,7 +434,6 @@ void MPanel::Draw(BRect updateArea) ////////////////////////////////////////// - //Memo Class... MMemo::MMemo(char *name): @@ -547,7 +547,6 @@ void MMemo::Draw(BRect updateArea) } ////////////////////////////////////////// - // MComboBox MCheckBox::MCheckBox(BRect frame, char *name): @@ -565,7 +564,7 @@ MCheckBox::~MCheckBox() void MCheckBox::KeyDown(const char *bytes, int32 numBytes) { - BControl::KeyDown(bytes, numBytes); + BCheckBox::KeyDown(bytes, numBytes); if (fOnKeyDown != NULL){ fOnKeyDown( this, bytes, numBytes ); @@ -574,7 +573,7 @@ void MCheckBox::KeyDown(const char *bytes, int32 numBytes) void MCheckBox::KeyUp(const char *bytes, int32 numBytes) { - BControl::KeyUp(bytes, numBytes); + BCheckBox::KeyUp(bytes, numBytes); if (fOnKeyUp != NULL){ fOnKeyUp( this, bytes, numBytes ); @@ -584,7 +583,7 @@ void MCheckBox::KeyUp(const char *bytes, int32 numBytes) void MCheckBox::MouseDown(BPoint pt) { - BControl::MouseDown(pt); + BCheckBox::MouseDown(pt); if (fOnMouseDown != NULL){ fOnMouseDown( this, pt.x, pt.y ); @@ -593,7 +592,7 @@ void MCheckBox::MouseDown(BPoint pt) void MCheckBox::MouseUp(BPoint pt) { - BControl::MouseUp(pt); + BCheckBox::MouseUp(pt); if (fOnMouseUp != NULL){ fOnMouseUp( this, pt.x, pt.y ); @@ -603,7 +602,7 @@ void MCheckBox::MouseUp(BPoint pt) void MCheckBox::MouseMoved(BPoint pt, uint32 code, const BMessage *msg) { - BControl::MouseMoved(pt, code, msg); + BCheckBox::MouseMoved(pt, code, msg); if (fOnMouseMove != NULL){ fOnMouseMove( this, pt.x, pt.y, code, 0 ); @@ -612,7 +611,7 @@ void MCheckBox::MouseMoved(BPoint pt, uint32 code, const BMessage *msg) void MCheckBox::Draw(BRect updateArea) { - BControl::Draw(updateArea); + BCheckBox::Draw(updateArea); if (fOnDraw != NULL){ fOnDraw( this, updateArea.left, updateArea.top, updateArea.right, updateArea.bottom ); @@ -628,10 +627,89 @@ bool MCheckBox::Checked(void) return false; } +////////////////////////////////////////// +// MRadioButton + +MRadioButton::MRadioButton(BRect frame, char *name): + BRadioButton(frame, name, name, new BMessage(ClickMessage)), + MControlEventPlugin(), + MPropertyPlugin(NULL) +{ + DoCreate(dynamic_cast(this)); +} + +MRadioButton::~MRadioButton() +{ + DoDestroy(dynamic_cast(this)); +} + +void MRadioButton::KeyDown(const char *bytes, int32 numBytes) +{ + BRadioButton::KeyDown(bytes, numBytes); + + if (fOnKeyDown != NULL){ + fOnKeyDown( this, bytes, numBytes ); + } +} + +void MRadioButton::KeyUp(const char *bytes, int32 numBytes) +{ + BRadioButton::KeyUp(bytes, numBytes); + + if (fOnKeyUp != NULL){ + fOnKeyUp( this, bytes, numBytes ); + } + DoChange(dynamic_cast(this)); //simulate a 'change' event... +} + +void MRadioButton::MouseDown(BPoint pt) +{ + BRadioButton::MouseDown(pt); + + if (fOnMouseDown != NULL){ + fOnMouseDown( this, pt.x, pt.y ); + } +} + +void MRadioButton::MouseUp(BPoint pt) +{ + BRadioButton::MouseUp(pt); + + if (fOnMouseUp != NULL){ + fOnMouseUp( this, pt.x, pt.y ); + } + DoClick(dynamic_cast(this)); //simulate a click event +} + +void MRadioButton::MouseMoved(BPoint pt, uint32 code, const BMessage *msg) +{ + BRadioButton::MouseMoved(pt, code, msg); + + if (fOnMouseMove != NULL){ + fOnMouseMove( this, pt.x, pt.y, code, 0 ); + } +} + +void MRadioButton::Draw(BRect updateArea) +{ + BRadioButton::Draw(updateArea); + + if (fOnDraw != NULL){ + fOnDraw( this, updateArea.left, updateArea.top, updateArea.right, updateArea.bottom ); + } + +} + +bool MRadioButton::Checked(void) +{ + if (this->Value() == B_CONTROL_ON) + return true; + else + return false; +} ////////////////////////////////////////// - //Edit Class... MEdit::MEdit(char *name): @@ -712,7 +790,6 @@ void MEdit::Draw(BRect updateArea) } ////////////////////////////////////////// - //Button Class... MButton::MButton(char *name): @@ -791,7 +868,6 @@ void MButton::Draw(BRect updateArea) } ////////////////////////////////////////// - //Application Class... MApplication::MApplication(const char* signature): @@ -831,6 +907,10 @@ void MApplication::RefsReceived(BMessage *message) if (message->what == SAVE_PANEL_MESSAGE){ printf("\nSave\n"); } + + if (message->what == OPEN_PANEL_MESSAGE){ + printf("\nOpen\n"); + } } void MApplication::MessageReceived(BMessage *message) @@ -838,40 +918,78 @@ void MApplication::MessageReceived(BMessage *message) void *pointer; MFilePanel *filepanel; entry_ref ref; - const char *name; + const char *savename; + char *openname; BPath path; BEntry entry; + BString tmp; status_t err = B_OK; + uint32 type; + int32 count; - if (message->what == SAVE_PANEL_MESSAGE || message->what == OPEN_PANEL_MESSAGE){ - printf("\nSave\n"); + if (message->what == SAVE_PANEL_MESSAGE){ if ( (err = message->FindRef("directory", &ref)) != B_OK ) { - printf("failed to find dir, error %d\n", err); + //printf("failed to find dir, error %d\n", err); return; } - if ( (err = message->FindString("name", &name)) != B_OK ){ - printf("failed to find filename, error %d\n", err); + if ( (err = message->FindString("name", &savename)) != B_OK ){ + //printf("failed to find filename, error %d\n", err); return; } if ( (err = entry.SetTo(&ref)) != B_OK ){ - printf("failed to create entr from path, error %d\n", err); + //printf("failed to create entr from path, error %d\n", err); return; } entry.GetPath(&path); - path.Append(name); + path.Append(savename); printf( "%s\n", path.Path() ); if (message->FindPointer("source", &pointer) == B_OK){ - printf("works1\n"); + //printf("works1\n"); if ((filepanel = reinterpret_cast(pointer)) != NULL){ - printf("works2\n"); + //printf("works2\n"); filepanel->DoExecute( path ); } } } + + if (message->what == OPEN_PANEL_MESSAGE){ + printf("open\n"); + + message->GetInfo("refs", &type, &count); + if (type != B_REF_TYPE) { + printf("no refs found\n"); + return; + } + + for (int32 i = --count; i >= 0; --i) { + if ((err = message->FindRef("refs", i, &ref)) == B_OK) { + if (message->FindPointer("source", &pointer) == B_OK){ + printf("works1\n"); + + if ( (err = entry.SetTo(&ref)) != B_OK ){ + printf("failed to create entr from path, error %d\n", err); + return; + } + + entry.GetPath(&path); + + if ((filepanel = reinterpret_cast(pointer)) != NULL){ + printf("works2\n"); + printf( "before event ... %s\n", path.Path() ); + filepanel->DoExecute( path ); + } + } + } + else { + printf("processing ref %d there was an error %d", i, err); + return; + } + } + } } @@ -898,7 +1016,6 @@ MForm* MApplication::AddForm(BRect ClientArea, BString name, bool showForm = fal //////////////////////////////////////// - //Form Class... MForm::MForm(BRect ClientArea): @@ -1081,7 +1198,6 @@ void MForm::setCloseAction(MCloseAction ca) } //////////////////////////////////////// - //Canvas class... MCanvas::MCanvas(BRect ClientArea, char *name): @@ -1209,7 +1325,6 @@ void MCanvas::Draw(BRect updateArea) } ///////////////////////////////////////// - //MenuItem Class... MMenuItem::MMenuItem(const char *label): @@ -1219,7 +1334,6 @@ MMenuItem::MMenuItem(const char *label): MMenuItem::~MMenuItem(){} ///////////////////////////////////////// - //PopUpMenu Class... MPopUpMenu::MPopUpMenu(const char *name): @@ -1230,8 +1344,8 @@ MPopUpMenu::MPopUpMenu(const char *name): } ///////////////////////////////////////// - //Test the Library + CTest::CTest(void){ FValue = 33; } diff --git a/begui/begui/libbegui/BeGuiClasses.h b/begui/begui/libbegui/BeGuiClasses.h index 8b4da9b..3c6745e 100644 --- a/begui/begui/libbegui/BeGuiClasses.h +++ b/begui/begui/libbegui/BeGuiClasses.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "MList.h" @@ -242,7 +243,23 @@ public: virtual void Draw(BRect updateArea); virtual bool Checked(void); -}; +}; + +class MRadioButton : public BRadioButton, + public MControlEventPlugin, + public MPropertyPlugin{ +public: + MRadioButton(BRect frame, char *name); + virtual ~MRadioButton(); + virtual void KeyDown(const char *bytes, int32 numBytes); + virtual void KeyUp(const char *bytes, int32 numBytes); + virtual void MouseDown(BPoint pt); + virtual void MouseUp(BPoint pt); + virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg); + virtual void Draw(BRect updateArea); + virtual bool Checked(void); + +}; /////////////////////////////////////////////// diff --git a/begui/begui/libbegui/BeTestApp2.cpp b/begui/begui/libbegui/BeTestApp2.cpp index 17f7fa7..fc8636c 100644 --- a/begui/begui/libbegui/BeTestApp2.cpp +++ b/begui/begui/libbegui/BeTestApp2.cpp @@ -1,9 +1,18 @@ /* - $Header: /home/haiku/befpc/begui/begui/libbegui/BeTestApp2.cpp,v 1.1 2002-04-12 23:32:56 memson Exp $ + $Header: /home/haiku/befpc/begui/begui/libbegui/BeTestApp2.cpp,v 1.2 2002-04-23 18:37:29 memson Exp $ - $Revision: 1.1 $ + $Revision: 1.2 $ $Log: not supported by cvs2svn $ + Revision 1.1 2002/04/12 23:32:56 memson + + Added quite a bit. + + Got basic file handling soeted out. Also got the FilePanel's working (see + example project) + + Popup menu now only responds to a right click (at last!!) + Revision 1.15 2002/03/26 13:28:51 memson added in combobox support - flawed at the moment. @@ -164,12 +173,16 @@ int main(void){ /* create 2 buttons */ btn = MButton_Create(5, 25, 30, 20, "test"); btn2 = MButton_Create(5, 50, 30, 30, "test2"); - cbx = MForm_AddMCheckBox((MForm*)frm, 20, 20, 100, 50, "test cbx"); + cbx = MCheckBox_Create(5, 5, 30, 50, "test cbx"); /* add buttons to main form */ MForm_AddChild((MForm*)frm, (BControl*)btn); MForm_AddChild((MForm*)frm, (BControl*)btn2); - //MForm_AddChild((MForm*)frm, (BControl*)cbx); + + + /* create a panel */ + pnl = MForm_AddMPanel((MForm*)frm, 5, 180, 200, 200, "panel1"); + MPanel_AddChild((MPanel*)pnl, (BControl*)cbx); pm = MPopUpMenu_Create("testmenu"); mni = MMenuItem_Create("Test Item"); @@ -201,9 +214,6 @@ int main(void){ /* create a memo - like edit, must be done in main form's thread */ edt = MForm_AddMMemo((MForm*)frm, 30, 100, 150, 150, "test5"); - /* create a panel */ - //pnl = MForm_AddMPanel((MForm*)frm, 250, 200, 400, 400, "panel1"); - //MForm_Hide((MForm*)frm); //MForm_Show((MForm*)frm); diff --git a/begui/begui/libbegui/MFile.cpp b/begui/begui/libbegui/MFile.cpp index 317fefd..6294265 100644 --- a/begui/begui/libbegui/MFile.cpp +++ b/begui/begui/libbegui/MFile.cpp @@ -58,6 +58,10 @@ status_t MFile_SetSize(MFile* file, off_t size){ return file->SetSize(size); } +status_t MFile_GetSize(MFile* file, off_t *size){ + return file->GetSize(size); +} + status_t MFile_SetTo(MFile* file, const char *path, uint32 open_mode){ return file->SetTo(path, open_mode); } diff --git a/begui/begui/libbegui/MFile.h b/begui/begui/libbegui/MFile.h index 4107adc..5e77585 100644 --- a/begui/begui/libbegui/MFile.h +++ b/begui/begui/libbegui/MFile.h @@ -1,9 +1,18 @@ /* - $Header: /home/haiku/befpc/begui/begui/libbegui/MFile.h,v 1.1 2002-04-12 23:32:56 memson Exp $ + $Header: /home/haiku/befpc/begui/begui/libbegui/MFile.h,v 1.2 2002-04-23 18:37:29 memson Exp $ - $Revision: 1.1 $ + $Revision: 1.2 $ $Log: not supported by cvs2svn $ + Revision 1.1 2002/04/12 23:32:56 memson + + Added quite a bit. + + Got basic file handling soeted out. Also got the FilePanel's working (see + example project) + + Popup menu now only responds to a right click (at last!!) + */ @@ -81,6 +90,7 @@ ssize_t MFile_Write(MFile* file, const void *buffer, size_t size); ssize_t MFile_WriteAt(MFile* file, off_t pos, const void *buffer, size_t size); status_t MFile_SetSize(MFile* file, off_t size); +status_t MFile_GetSize(MFile* file, off_t *size); status_t MFile_SetTo(MFile* file, const char *path, uint32 open_mode); //use this for both Save and Open Panels... diff --git a/begui/begui/libbegui/filetest.proj b/begui/begui/libbegui/filetest.proj index 2b258207c54d7892a1c8a0d372eae0538be68547..0654313678297a121687737893b3d139b9eb7290 100644 GIT binary patch delta 278 zcmbP}{v@5l*VDz7fx-CBL=GKB#*L=kY%C44WE&`6QU$_L(;{yHRcuE# ziBIx614D>1P^kq_6*EFAfvO55uQ4!4Ndslx05LNV!_4T0njt!w&!7fqj-Z%p s3{bxUPz92*0(Y>o-v*1t7%l*%Kmgf}c%Zb+vcfkFS!L;($spuB)01_lMqK?`2?Um>j7W zv$;vviV?_&tReS(qW*~+t4^o-@(Limo zg~2xF{k}p#c8O>MP|^U18G#t83M^wYd7GiG0@U_KpeYwX3V;AfVdOoa5jM;~izgcx WDzktbF!_O@vME{Ny4k|$BO?HzOOtB= delta 732 zcmdm6urfoy*VDz7fx$%4C7>vcfk9{AL;(#67supe1_lNJAZ7z%5MTvjrp+lV32gNN z0VNp>42&E=5k^KmJ^iHA^wLZqCoMlDSOQ2dU}Ru80K_nm=;9u%0^|gR_yw>4X|Cd; z}4ChGB$xP0UFDL;?g24kv1_qycCy+u1pn$ty zurJ6$fsmra+BLAC74N1Z|C$YFVwK$|GJ)MDplLx4t z9f$=4IHVgUI|w;$mgGL7;tNp^6le5EO-xBG0$Ih-a$CG1K~d%}DA>>GfJ7J=e#p!G zy`0P2zycHx*(lopQUhXxU!j|Ct z(xT*4kS4Niam&mx1Zuy=z#w@VNWTGMW*}y00Aic%1p>aAxgZNBKR1-0e9&kj&_R5X z*BKaGV}PDi07@V$mYn>+P;K&I<892_3(UZ5ZBwzyJ4`G@>wzjkP6wxz1|S1yv=vl^ S^W^WQ3Z`U*(q //nasty global.. -void *savepanel; // MSavePanel reference +void *savepanel; // MSavePanel +void *openpanel; void *memo; void file_io(void* sender, uint32 msg, const char *path){ @@ -20,11 +21,28 @@ void file_io(void* sender, uint32 msg, const char *path){ MFile_Free((MFile*)file); //clear the file pointer } +void file_io3(void* sender, uint32 msg, const char *path){ + void *file; //for MFile reference + char *buffer; //for input + off_t size; + + //file output... + file = MFile_Create(path, B_READ_WRITE); //file read/write and create if not already there + + MFile_GetSize( (MFile*)file, &size ); + buffer = (char*) malloc(size); //create some space in the buffer + + MFile_Read( (MFile*)file, buffer, sizeof(char) * size ); //output buffer contents + MFile_Free((MFile*)file); //clear the file pointer + MMemo_SetText((MMemo*)memo, buffer); + //printf("\n input:\n%s\n", buffer); +} + void file_io2(void* sender, uint32 msg, const char *path){ void *file; //for MFile reference //file output... - file = MFile_Create(path, B_READ_WRITE | B_CREATE_FILE); //file read/write and create if not already there + file = MFile_Create(path, B_READ_WRITE | B_CREATE_FILE); //file read/write MFile_Write( (MFile*)file, MMemo_Text((MMemo*)memo), MMemo_TextLength((MMemo*)memo) ); //output buffer contents MFile_Free((MFile*)file); //clear the file pointer } @@ -34,9 +52,14 @@ void doclick(void* Sender, uint32 msg){ MSavePanel_Show((MSavePanel*) savepanel); //show the panel (this is modal) } +/* open button click */ +void doclick2(void* Sender, uint32 msg){ + MOpenPanel_Show((MOpenPanel*) openpanel); //show the panel (this is modal) +} + int main(){ void *app; // MApplication reference - void *btn; + void *btn, *btn2; void *frm; // Matt 11/04/2002 : Must have a MApplication to use a MFilePanel of descendents @@ -46,14 +69,23 @@ int main(){ MForm_setWidth((MForm*)frm, 250); MForm_setHeight((MForm*)frm, 250); - btn = MButton_Create(5, 25, 35, 20, "save"); + btn = MButton_Create(5, 25, 35, 20, "save"); MForm_AddChild((MForm*)frm, (BControl*)btn); MButton_AttachClickDispatcher((MButton*)btn, doclick); + btn2 = MButton_Create(40, 25, 75, 20, "open"); + MForm_AddChild((MForm*)frm, (BControl*)btn2); + MButton_AttachClickDispatcher((MButton*)btn2, doclick2); + + savepanel = MSavePanel_Create(); //create a MSavePanel reference //MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io); //attach callback for event MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io2); //attach callback for event + openpanel = MOpenPanel_Create(); //create a MSavePanel reference + //MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io); //attach callback for event + MFilePanel_AttachDialogEvent((MFilePanel*)openpanel, file_io3); //attach callback for event + /* create a memo - like edit, must be done in main form's thread */ memo = MForm_AddMMemo((MForm*)frm, 30, 100, 150, 150, "test5");