From 434b2f7566d949c743a2011e2d8acce468199ef7 Mon Sep 17 00:00:00 2001 From: memson Date: Fri, 12 Apr 2002 23:32:56 +0000 Subject: [PATCH] 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!!) --- begui/begui/libbegui/BeGUITestApp2.proj | Bin 0 -> 13341 bytes begui/begui/libbegui/BeGuiAPI.cpp | 44 ++++- begui/begui/libbegui/BeGuiAPI.h | 8 + begui/begui/libbegui/BeGuiClasses.cpp | 132 ++++++++++---- begui/begui/libbegui/BeGuiClasses.h | 7 +- begui/begui/libbegui/BeTestApp.proj | Bin 11962 -> 11962 bytes begui/begui/libbegui/BeTestApp2.cpp | 217 +++++++++++++++++++++++ begui/begui/libbegui/MFile.cpp | 225 ++++++++++++++++++++++++ begui/begui/libbegui/MFile.h | 105 +++++++++++ begui/begui/libbegui/filetest.proj | Bin 0 -> 13212 bytes begui/begui/libbegui/libbegui.proj | Bin 12956 -> 13353 bytes begui/begui/libbegui/testfile.cpp | 37 ++++ 12 files changed, 733 insertions(+), 42 deletions(-) create mode 100644 begui/begui/libbegui/BeGUITestApp2.proj create mode 100644 begui/begui/libbegui/BeTestApp2.cpp create mode 100644 begui/begui/libbegui/MFile.cpp create mode 100644 begui/begui/libbegui/MFile.h create mode 100644 begui/begui/libbegui/filetest.proj create mode 100644 begui/begui/libbegui/testfile.cpp diff --git a/begui/begui/libbegui/BeGUITestApp2.proj b/begui/begui/libbegui/BeGUITestApp2.proj new file mode 100644 index 0000000000000000000000000000000000000000..9938039a149fbf87727f3e5481bb9ec73478a75c GIT binary patch literal 13341 zcmeHOUu+yl8J~?W<&rv$o!GIPq|FAWN!#drDUG10h}O;}j;ZaeatQ_T$JyH(+uPpV z9=q$rRfV+tQK_o7DpDVccYw7+2aGeR8xq2(X12_Z5cqFDateYR1% zEZ;qkdlvO$sG>09IJoto-a!~;GpbRv!a3ZCCyac_^TK>to|hG`o}ZI;S^7b~Bsth7 zC2bF}wmqDB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pp index d9d1b98..1a9ddd1 100644 --- a/begui/begui/libbegui/BeGuiAPI.cpp +++ b/begui/begui/libbegui/BeGuiAPI.cpp @@ -1,9 +1,13 @@ /* - $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.2 2002-04-02 20:42:15 memson Exp $ + $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.3 2002-04-12 23:32:56 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 + Revision 1.1.1.1 2002/03/31 10:36:07 memson initial import into sourceforge @@ -183,6 +187,28 @@ MMemo* MForm_AddMMemo(MForm *form, int32 left, int32 top, int32 right, int32 bot return form->Canvas()->AddMemo(btnRect, caption); } +int32 MForm_getWidth(MForm *frm){ + return 0; +} + +int32 MForm_getHeight(MForm *frm){ + return 0; +} + +void MForm_setWidth(MForm *frm, int32 value){ + if (frm->Lock()) { + frm->setWidth(value); + frm->Unlock(); + } +} + +void MForm_setHeight(MForm *frm, int32 value){ + if (frm->Lock()) { + frm->setHeight(value); + frm->Unlock(); + } +} + /// BButton* BButton_Create(float left, float top, float right, float bottom, char *caption, uint32 msg){ @@ -499,6 +525,20 @@ void GenericAlert(const char *message){ alert->Go(); } +#include + +status_t be_beep(){ + return beep(); +} + +status_t be_system_beep(const char * event_name){ + return system_beep(event_name); +} + +status_t be_add_system_beep_event(const char * event_name, uint32 flags){ + return add_system_beep_event(event_name, flags); +} + ///////////////////////////////////////// //Test the API diff --git a/begui/begui/libbegui/BeGuiAPI.h b/begui/begui/libbegui/BeGuiAPI.h index 2eff722..482d9b6 100644 --- a/begui/begui/libbegui/BeGuiAPI.h +++ b/begui/begui/libbegui/BeGuiAPI.h @@ -60,6 +60,10 @@ void MForm_AttachDrawDispatcher(MForm *form, drawAction_Message msg); void MForm_Show(MForm *frm); void MForm_Hide(MForm *frm); void MForm_AddPopUpMenu(MForm *frm, MPopUpMenu *mni); +int32 MForm_getWidth(MForm *frm); +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); @@ -136,6 +140,10 @@ 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 4a3567d..18d5157 100644 --- a/begui/begui/libbegui/BeGuiClasses.cpp +++ b/begui/begui/libbegui/BeGuiClasses.cpp @@ -1,12 +1,16 @@ /* - $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiClasses.cpp,v 1.1.1.1 2002-03-31 10:36:16 memson Exp $ + $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiClasses.cpp,v 1.2 2002-04-12 23:32:56 memson Exp $ - $Revision: 1.1.1.1 $ + $Revision: 1.2 $ $Log: not supported by cvs2svn $ + Revision 1.1.1.1 2002/03/31 10:36:16 memson + + initial import into sourceforge + Revision 1.19 2002/03/26 13:28:51 memson - added in combobox su[pport - flawed at the moment. + added in combobox support - flawed at the moment. Revision 1.18 2002/03/14 22:31:41 memson @@ -99,8 +103,10 @@ #define BEGUI_EXPORTS 1 #include "MList.h" +#include "MFile.h" #include "BeGuiClasses.h" #include +#include //clik - control click #define ClickMessage 'clik' @@ -788,8 +794,8 @@ void MButton::Draw(BRect updateArea) //Application Class... -MApplication::MApplication(): - BApplication("application/x-vnd.beguiapp"), +MApplication::MApplication(const char* signature): + BApplication(signature), MEventPlugin() { BRect tmpRect; @@ -797,7 +803,7 @@ MApplication::MApplication(): BString formname = "main"; fMainForm = new MForm(tmpRect); - fMainForm->Show(); + //fMainForm->Show(); fForms = new MGUIList(); fForms->AddItem(new MGUIListItem(formname, fMainForm)); @@ -807,28 +813,68 @@ MApplication::MApplication(): DoCreate( dynamic_cast(this) ); } -MApplication::MApplication(MForm* mainForm): - BApplication("application/x-vnd.beguiapp"), - MEventPlugin() -{ - BString formname = "main"; - - fMainForm = mainForm; - fMainForm->Show(); - - fForms = new MGUIList(); - fForms->AddItem(new MGUIListItem(formname, fMainForm)); - - fTerminating = false; //controls the act of shutting down - - DoCreate( dynamic_cast(this) ); -} - MApplication::~MApplication() { DoDestroy( dynamic_cast(this) ); } +thread_id MApplication::Run(void) +{ + if (fMainForm != NULL) fMainForm->Show(); + + return BApplication::Run(); + +} + +void MApplication::RefsReceived(BMessage *message) +{ + if (message->what == SAVE_PANEL_MESSAGE){ + printf("\nSave\n"); + } +} + +void MApplication::MessageReceived(BMessage *message) +{ + void *pointer; + MFilePanel *filepanel; + entry_ref ref; + const char *name; + BPath path; + BEntry entry; + status_t err = B_OK; + + if (message->what == SAVE_PANEL_MESSAGE || message->what == OPEN_PANEL_MESSAGE){ + printf("\nSave\n"); + if ( (err = message->FindRef("directory", &ref)) != B_OK ) { + 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); + return; + } + + if ( (err = entry.SetTo(&ref)) != B_OK ){ + printf("failed to create entr from path, error %d\n", err); + return; + } + + entry.GetPath(&path); + path.Append(name); + + printf( "%s\n", path.Path() ); + + if (message->FindPointer("source", &pointer) == B_OK){ + printf("works1\n"); + if ((filepanel = reinterpret_cast(pointer)) != NULL){ + printf("works2\n"); + filepanel->DoExecute( path ); + } + } + } + +} + void MApplication::Terminate(void) { //if main form is dead, we must not call this because... @@ -963,16 +1009,18 @@ bool MForm::QuitRequested() void MForm::UpdateBounds(void) { - fClientArea = this->Bounds(); + //fClientArea = this->Bounds(); } void MForm::setWidth(float w) { float h = fClientArea.Height(); - this->ResizeTo(h, w); + fClientArea.Set(fClientArea.left, fClientArea.top, fClientArea.left + w, fClientArea.top + h); - UpdateBounds(); + this->ResizeTo(w, h); + + //UpdateBounds(); } @@ -980,9 +1028,11 @@ void MForm::setHeight(float h) { float w = fClientArea.Width(); - this->ResizeTo(h, w); + fClientArea.Set(fClientArea.left, fClientArea.top, fClientArea.left + w, fClientArea.top + h); - UpdateBounds(); + this->ResizeTo(w, h); + + //UpdateBounds(); } float MForm::getWidth(void) @@ -1101,6 +1151,7 @@ void MCanvas::KeyUp(const char *bytes, int32 numBytes) void MCanvas::MouseDown(BPoint pt) { BPoint point; + int32 buttons = 0; BView::MouseDown(pt); @@ -1108,17 +1159,22 @@ void MCanvas::MouseDown(BPoint pt) fOnMouseDown( this, pt.x, pt.y ); } - if (fPopUpMenu != NULL){ - point = pt; - ConvertToScreen(&point); - BMenuItem *mni = fPopUpMenu->Go(point, true); + Looper()->CurrentMessage()->FindInt32("buttons", &buttons); + + + if (buttons == B_SECONDARY_MOUSE_BUTTON) { + if (fPopUpMenu != NULL){ + point = pt; + ConvertToScreen(&point); + BMenuItem *mni = fPopUpMenu->Go(point, true); - if (mni){ - MMenuItem *mmni = dynamic_cast(mni); - if(mmni){ - mmni->DoMenuClick(mmni); - } - } + if (mni){ + MMenuItem *mmni = dynamic_cast(mni); + if(mmni){ + mmni->DoMenuClick(mmni); + } + } + } } } diff --git a/begui/begui/libbegui/BeGuiClasses.h b/begui/begui/libbegui/BeGuiClasses.h index 4a40cfe..8b4da9b 100644 --- a/begui/begui/libbegui/BeGuiClasses.h +++ b/begui/begui/libbegui/BeGuiClasses.h @@ -16,6 +16,7 @@ #include #include #include +#include #include "MList.h" //////////////////////////////////////////////////////////////////// @@ -322,10 +323,12 @@ protected: MGUIList *fForms; bool fTerminating; public: - MApplication(); - MApplication(MForm* mainForm); + MApplication(const char* signature = "application/x-vnd.beguiapp"); virtual ~MApplication(); + virtual thread_id Run(void); virtual void Terminate(void); + virtual void RefsReceived(BMessage *message); + virtual void MessageReceived(BMessage *message); virtual MForm* AddForm(BRect ClientArea, BString name, bool showForm = false); virtual MForm* GetMainForm(void){ return fMainForm; }; virtual bool Terminating(void){ return fTerminating; }; diff --git a/begui/begui/libbegui/BeTestApp.proj b/begui/begui/libbegui/BeTestApp.proj index a04ef5870dd456b32da12f3b4191c5572d29ddf0..2cd02ccc40a23aa20b520cb950092c44021e441a 100644 GIT binary patch delta 130 zcmdlLyDN6X0XCL^X7z^23wRwjv$Ee;(KYz%5>S-3Pn!V@e#jgAy`0P2z@ljISLK~n jL(6S(FdHPD=t0Tf_(e&k!tM delta 130 zcmdlLyDN6X0XCKbPq~K43wRwjv$Ee;(Uth?5>S-3Pn!V@e#lGwy`0P2z@jMecgb7D jhL+pnU^YmyLqTG)ppFvrvM0Wi&2*lUrgO80ZV@8@#8oU@ diff --git a/begui/begui/libbegui/BeTestApp2.cpp b/begui/begui/libbegui/BeTestApp2.cpp new file mode 100644 index 0000000..17f7fa7 --- /dev/null +++ b/begui/begui/libbegui/BeTestApp2.cpp @@ -0,0 +1,217 @@ +/* + $Header: /home/haiku/befpc/begui/begui/libbegui/BeTestApp2.cpp,v 1.1 2002-04-12 23:32:56 memson Exp $ + + $Revision: 1.1 $ + + $Log: not supported by cvs2svn $ + Revision 1.15 2002/03/26 13:28:51 memson + added in combobox support - flawed at the moment. + + Revision 1.14 2002/03/14 22:31:41 memson + Got the Menubar/menu/menuitem and popupmenu/menuitem both working... Had a + bit of a slack night, so didn't really do much else. + + Revision 1.13 2002/03/14 00:12:38 memson + Revised the event and property class hierarchies... hopefully makes more + sense. + + Started to add in the Menu functionality. PopUpMenu is done and 'tested', + but the BMenuBar/BMenu (mainmenu) stuff is there but untested. + + Added in an OnCreate and OnDestroy event to the events, plust a wierd + offshoot class to handle the menuitem click. + + Revision 1.12 2002/03/12 23:12:37 memson + hashed out some details - stopped child windows from screwing up app, and + also added the close action to form and terminating functionality to the app. + + Revision 1.11 2002/03/12 18:39:16 memson + + Revision 1.10 2002/03/11 23:22:11 memson + + Revision 1.9 2002/02/19 17:49:54 memson + Added half arsed support for multiple windows - not working quite right yet, + but at least they seem to 'work' in so much as they don't wipe the app out. + The secondary forms Canvas is screwed up a little.. that is a priority I + guess. + + Revision 1.8 2002/02/14 23:39:53 memson + I've now added most of the events to the MButton, MCanvas, MMemo and MEdit.. + started a MPanel component. Again, the MCanvas is *not* tread safe!!! + This means the calling thread must create it. + + NB. Before I add much more functionality, I'm going to look at other GUI + libs to see if there are any controls worth borrowing. + + Next control will probably be a MLabel followed by a MMenuBar and MMenuItem. + MForm will own a MMenuBar. + + Revision 1.7 2002/02/14 20:33:19 memson + Got the MButton OnClick, OnMouseDown/Up, OnKeyDown/Up and OnMouseMoved + events working. Started to add the required code to the rest of the classes + (should be a cut/paste job). + + Revision 1.6 2002/02/14 14:00:16 memson + fiddled a bit.. nothing major. + + Revision 1.5 2002/02/13 23:26:25 memson + Got the MMemo working. + Got the MEdit working, including OnClick event signal + Got the MButton working with a signal + Added a few get/set accessor routined for captions/text. + + + Revision 1.4 2002/02/13 00:02:02 memson + Got the MTextControl basic functionality - annoying fact is that a text + control has to be added inside the thread that will display it!!!! + + Revision 1.3 2002/02/11 23:26:44 memson + Revision 1.2 2002/01/17 20:32:54 memson + +*/ + +#include "BeGuiAPI.h" +#include "MFile.h" +#include + +void *frm2 = 0; //need to add a 'parent' property?? Does BeAPI have equiv? + +/* button callback */ +void callback(void* Sender, uint32 msg){ + if (msg == 'clik') + if (Sender) { + GenericAlert(MButton_getCaption((MButton*)Sender)); + MButton_setCaption((MButton*)Sender, "X"); + } +} + +/* edit callback */ +void callback2(void* Sender, uint32 msg){ + if (msg == 'clik') + if (Sender) { + GenericAlert( MEdit_getText( (MEdit*)Sender ) ); + } +} + +void menuClick(void* Sender, uint32 msg){ + if (msg == 'clik') + GenericAlert( "Menu click" ); +} + +/* test mousemove */ +void mousemoved(void* Sender, float x, float y, uint32 code, uint32 msg){ + printf("mousemoved - x: %f, y: %f, code: %u\n", x, y, code); +} + +/* test mousedown */ +void mousedown(void* Sender, float x, float y){ + printf("mousedown - x: %f, y: %f\n", x, y); +} + +/* test mouseup */ +void mouseup(void* Sender, float x, float y){ + printf("mouseup - x: %f, y: %f\n", x, y); +} + +/* test button click */ +void doclick(void* Sender, uint32 msg){ + if (msg == 'clik') + if (Sender) { + printf("%s clicked\n", MButton_getCaption((MButton*)Sender)); + } + + if (frm2 != NULL){ + MForm_Show((MForm*)frm2); + } + + //dynamic_cast(be_app)->Terminate(); +} + +/* test form click */ +void doformclick(void* Sender, float x, float y){ + printf("mousedown - x: %f, y: %f\n", x, y); +} + + +int main(void){ + /* variables */ + void *app; + void *frm; + void *btn, *btn2; + void *edt, *edt2; + void *pnl; + void *mni, *mni2, *mnu; + void *pm, *mb; + void *cbx; + void *btncbx; + void *file; + + /* must create application first!! */ + app = MApplication_Create(); + + /* application automatically creates main form + so call this to get a reference to it.. */ + frm = MApplication_GetMainForm((MApplication*)app); + MForm_AttachMouseDownDispatcher((MForm*)frm, doformclick); + + /* create a second hidded form */ + frm2 = MApplication_AddForm((MApplication*)app, 100, 100, 100, 100, "testfrm", "testfrm"); + //MForm_Show((MForm*)frm2); + + MForm_setWidth((MForm*)frm, 250); + MForm_setHeight((MForm*)frm, 250); + + /* 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"); + + /* add buttons to main form */ + MForm_AddChild((MForm*)frm, (BControl*)btn); + MForm_AddChild((MForm*)frm, (BControl*)btn2); + //MForm_AddChild((MForm*)frm, (BControl*)cbx); + + pm = MPopUpMenu_Create("testmenu"); + mni = MMenuItem_Create("Test Item"); + MMenuItem_AttachMenuClickDispatcher((MMenuItem*)mni, menuClick); + MPopUpMenu_AddItem((MPopUpMenu*)pm, (MMenuItem*)mni); + MForm_AddPopUpMenu((MForm*)frm, (MPopUpMenu*)pm); + + + mb = BMenuBar_Create((MForm*)frm, "testmenubar"); + mni2 = MMenuItem_Create("Test mb item"); + MMenuItem_AttachMenuClickDispatcher((MMenuItem*)mni2, menuClick); + mnu = BMenu_Create("Form"); + BMenu_AddItem((BMenu*)mnu, (MMenuItem*)mni2); + BMenuBar_AddItem((BMenuBar*)mb, (BMenu*)mnu); + + /* set the button event callback routines */ + MButton_AttachClickDispatcher((MButton*)btn, callback); + MButton_AttachClickDispatcher((MButton*)btn2, doclick); + MButton_AttachMouseMovedDispatcher((MButton*)btn, mousemoved); + MButton_AttachMouseUpDispatcher((MButton*)btn2, mouseup); + MButton_AttachMouseDownDispatcher((MButton*)btn2, mousedown); + + /* add an edit - must be done in thread of main form */ + edt2 = MForm_AddMEdit((MForm*)frm, 30, 50, 100, 50, "test4"); + + /* set the edit event callback routines */ + MEdit_AttachClickDispatcher((MEdit*)edt2, callback2); + + /* 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); + + /* start things rolling */ + MApplication_Run((MApplication*)app); + + /* clean up after execution */ + MApplication_Free((MApplication*)app); + + printf("%d", test_func()); +} diff --git a/begui/begui/libbegui/MFile.cpp b/begui/begui/libbegui/MFile.cpp new file mode 100644 index 0000000..317fefd --- /dev/null +++ b/begui/begui/libbegui/MFile.cpp @@ -0,0 +1,225 @@ +#include "MFile.h" + +///////////////////////////////////////////////// +// Class MFile + +MFile::MFile(const char *path, uint32 openMode): + BFile(path, openMode) +{ + +} + +MFile::MFile(const entry_ref *ref, uint32 openMode): + BFile(ref, openMode) +{ + +} + +///////////////////////////////////////////////// +// Exported Functions + +MFile* MFile_Create(const char *path, uint32 openMode){ + return new MFile(path, openMode); +} + +MFile* MFile_Create_Ref(const entry_ref *ref, uint32 openMode){ + return new MFile(ref, openMode); +} + +void MFile_Free(MFile* file){ + delete file; +} + +off_t MFile_Seek(MFile* file, off_t offset, int32 seekMode){ + return file->Seek(offset, seekMode); +} + +off_t MFile_Position(MFile* file){ + return file->Position(); +} + +ssize_t MFile_Read(MFile* file, void *buffer, size_t size){ + return file->Read(buffer, size); +} + +ssize_t MFile_ReadAt(MFile* file, off_t pos, void *buffer, size_t size){ + return file->ReadAt(pos, buffer, size); +} + +ssize_t MFile_Write(MFile* file, const void *buffer, size_t size){ + return file->Write(buffer, size); +} + +ssize_t MFile_WriteAt(MFile* file, off_t pos, const void *buffer, size_t size){ + return file->WriteAt(pos, buffer, size); +} + +status_t MFile_SetSize(MFile* file, off_t size){ + return file->SetSize(size); +} + +status_t MFile_SetTo(MFile* file, const char *path, uint32 open_mode){ + return file->SetTo(path, open_mode); +} + +///////////////////////////////////////////////// +// Generic File Panel + +MFilePanel::MFilePanel(file_panel_mode panel_type, + bool allow_multiple_selection, + BMessage *msg = 0, + bool modal) : + BFilePanel(panel_type, + 0, + 0, + 0, + allow_multiple_selection, + msg, + 0, + modal, + true), + MDialogPlugin(panel_type) +{ + +} + +/// + +void MFilePanel_AttachDialogEvent(MFilePanel* dlg, dialog_Message msg) +{ + dlg->AttachDialogEvent(msg); +} + +///////////////////////////////////////////////// +// Open Panel + +MOpenPanel::MOpenPanel(bool allow_multiple_selection, + bool modal) : + MFilePanel(B_OPEN_PANEL, + allow_multiple_selection, + 0, + modal) +{ + BMessage *msg = new BMessage(OPEN_PANEL_MESSAGE); + + msg->AddPointer("source", this); + + SetMessage(msg); +} + +// flattened API + +MOpenPanel* MOpenPanel_Create() +{ + return new MOpenPanel(); +} + +void MOpenPanel_Free(MOpenPanel* dlg) +{ + delete &dlg; +} + +void MOpenPanel_Show(MOpenPanel* dlg) +{ + dlg->Show(); +} + +void MOpenPanel_Hide(MOpenPanel* dlg) +{ + dlg->Hide(); +} + +bool MOpenPanel_IsShowing(MOpenPanel* dlg) +{ + return dlg->IsShowing(); +} + + +///////////////////////////////////////////////// +// Save Panel + +MSavePanel::MSavePanel(bool allow_multiple_selection, + bool modal) : + MFilePanel(B_SAVE_PANEL, + allow_multiple_selection, + 0, + modal) +{ + BMessage *msg = new BMessage(SAVE_PANEL_MESSAGE); + + msg->AddPointer("source", this); + + SetMessage(msg); + +} + +//flattened API + +MSavePanel* MSavePanel_Create() +{ + return new MSavePanel(); +} + +void MSavePanel_Free(MSavePanel* dlg) +{ + delete &dlg; +} + +void MSavePanel_Show(MSavePanel* dlg) +{ + dlg->Show(); +} + +void MSavePanel_Hide(MSavePanel* dlg) +{ + dlg->Hide(); +} + +bool MSavePanel_IsShowing(MSavePanel* dlg) +{ + return dlg->IsShowing(); +} + +///////////////////////////////////////////////// +// Property + +MDialogPlugin::MDialogPlugin(const uint32 dialogType) +{ + fDialogType = dialogType; + fDialogMsg = 0; +} + +MDialogPlugin::~MDialogPlugin() +{ + fDialogMsg = 0; +} + +void MDialogPlugin::AttachDialogEvent(dialog_Message msg) +{ + fDialogMsg = msg; +} + +void MDialogPlugin::DoExecute(BPath path) +{ + uint32 amsg; + + switch (fDialogType){ + case B_SAVE_PANEL: + amsg = SAVE_PANEL_MESSAGE; //Matt 11/04/2002 : this is a bug... + break; + case B_OPEN_PANEL: + amsg = OPEN_PANEL_MESSAGE; //Matt 11/04/2002 : this is a bug... + break; + default: amsg = 0; + } + + if (fDialogMsg != NULL){ + fDialogMsg( this, amsg, path.Path() ); + } +} + +///////////////////////////////////////////////// +// Utility test function +uint test_func(void){ + return 1024; +} diff --git a/begui/begui/libbegui/MFile.h b/begui/begui/libbegui/MFile.h new file mode 100644 index 0000000..4107adc --- /dev/null +++ b/begui/begui/libbegui/MFile.h @@ -0,0 +1,105 @@ +/* + $Header: /home/haiku/befpc/begui/begui/libbegui/MFile.h,v 1.1 2002-04-12 23:32:56 memson Exp $ + + $Revision: 1.1 $ + + $Log: not supported by cvs2svn $ + +*/ + +#ifndef MFILE_H +#define MFILE_H + +#include +#include +#include +#include +#include + +typedef void (*dialog_Message)(void* sender, uint32 msg, const char *path);//, entry_ref ref); + +extern "C"{ + +#define SAVE_PANEL_MESSAGE 'svpm' +#define OPEN_PANEL_MESSAGE 'oppm' + +} + +class MFile : public BFile{ +public: + MFile(const char *path, uint32 openMode); + MFile(const entry_ref *ref, uint32 openMode); + //add whatever +}; + +class MFilePanel; //forward... + +class MDialogPlugin { +private: + dialog_Message fDialogMsg; + uint32 fDialogType; +public: + MDialogPlugin(const uint32 dialogType); + virtual ~MDialogPlugin(); + virtual void AttachDialogEvent(dialog_Message msg); + virtual void DoExecute(BPath path); +}; + +class MFilePanel : public BFilePanel, + public MDialogPlugin{ +public: + MFilePanel(file_panel_mode panel_type, + bool allow_multiple_selection = true, + BMessage *msg = 0, + bool modal = true); +}; + +class MOpenPanel : public MFilePanel{ +public: + MOpenPanel(bool allow_multiple_selection = true, + bool modal = true); +}; + +class MSavePanel : public MFilePanel{ +public: + MSavePanel(bool allow_multiple_selection = true, + bool modal = true); +}; + +extern "C"{ + +MFile* MFile_Create(const char *path, uint32 openMode); +MFile* MFile_Create_Ref(const entry_ref *ref, uint32 openMode); +void MFile_Free(MFile* file); + +off_t MFile_Seek(MFile* file, off_t offset, int32 seekMode); +off_t MFile_Position(MFile* file); + +ssize_t MFile_Read(MFile* file, void *buffer, size_t size); +ssize_t MFile_ReadAt(MFile* file, off_t pos, void *buffer, size_t size); +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_SetTo(MFile* file, const char *path, uint32 open_mode); + +//use this for both Save and Open Panels... +void MFilePanel_AttachDialogEvent(MFilePanel* dlg, dialog_Message msg); + +MOpenPanel* MOpenPanel_Create(); +void MOpenPanel_Free(MOpenPanel* dlg); +void MOpenPanel_Show(MOpenPanel* dlg); +void MOpenPanel_Hide(MOpenPanel* dlg); +bool MOpenPanel_IsShowing(MOpenPanel* dlg); + +MSavePanel* MSavePanel_Create(); +void MSavePanel_Free(MSavePanel* dlg); +void MSavePanel_Show(MSavePanel* dlg); +void MSavePanel_Hide(MSavePanel* dlg); +bool MSavePanel_IsShowing(MSavePanel* dlg); + +uint test_func(void); + +} + +#endif MFILE_H diff --git a/begui/begui/libbegui/filetest.proj b/begui/begui/libbegui/filetest.proj new file mode 100644 index 0000000000000000000000000000000000000000..6a37bfb6e2c49aae3adfaa01a6446d7cf9483d71 GIT binary patch literal 13212 zcmeHOUu+ab7@wsF9<@jdlpYmf39%^TdK!$;Xo4+QN@H6#9E!$2Wp8iVuI}BQyIZIs z#`RCs5Hy(ZpfM&q=&Mm*Bt94)8Z{A(35jCh!3Q-)PbJ1gLyqY0o1JU-+FHt8mBzbC zXLr7tZ|3{H-+Vj!-RyLrFWJM`_Tx#-8D?zTTbk38V~j=qLeiXj9V#O?XpVUh_bBpJ z$Sm1q7`QbfFC!XhDYBB%yiweUk12_?ZF`9fKgcaRpBUwOhC6N|&8e|QQWy_5J03

r-1T@iQFEARQ|oDiayakUk8s0# zVhXQXEA4YeMi^V(1iR@y)O_Ogc7Mb$hAcDpXvJ7475ALcQP1Zs)6hNB&Lzg<*+X$T zWiuH6siI-3p<27jbvc;JbawMNw}$yRH^w|YZC&a`{4eX$sXKAqF-FaUmr?|nEMbfS z4obi!C{%d$__&wYT487EM!Ia;3*lqI-eEJhD+7H zi!u24!UUWPp$mR2EJ#`qUA(Nd5Xw}oO9NxNR0O_T-Mg(?gP@DOSagXn#c`d5d5{(W z7gqvvrRS(u{C2hFOV${Tlslk9FnqJsH!p9nImxu85cDXZ@KoXZ~tLyQ1I^ zm!Ml@qhS~bts)Vav(wJzO^Z8w@)XFpi~^+iaNac3_@3=3*HayVIs&zYfLtc7%UF}k zL_dCXl`j&t1xel7Is$bB!U)I^q^);wPe1A-_vACW$2DwQi5NmQzmYv;&<^iWYQTP$ zh)>3EyH)U@-e=WrU37BvrlOobPU)dH*yIs&zZ zfLveNgJ6wCY4H-l+T_wDmy|7~aIS1gsRwqo<}h`8>j=z+fLu_v%7CR=L^&CbYVL@y zUG!0e(qyC~d#u^(COy|JG<0r+)YW-)m@io@jX)RRAR^|383L6_vX^ry_TKUEo@A>WPo6! z0;Pa863e-=h_Eu3(yrM7lmwa^p_QiF+__5ZBNB$8t#XS$dncN}Gc06`Z zfP?4@(5GV|d=K^7O10Sie6&!)gJ=!3(3vI+$@pF^u+uSrRX_^51@w{Q(ZUV8z@#o^ zgs*6BX6zWo_y}!u!j0-rfPVaFK+~!<0s2^PYvC1o0N-sFcJFRhi%H}U(H6mw=W&1S zxq#=-%?&>Ws~yhHfrofWKdPrO)`R|T4&G1t8h#|+ec+}1Qd`ikH13uZw{Up;-_{M zd}QNwpxOCWe;nVEZb3PQ`exYh#$bR=6Urx_Y4-s&JC59kyastU>TzRuMijWE@*wD6 z9$MkE&tm?*`v<$o$B3sNSwkk<#k0S+%_o}bslQx0O3TzY*+W(a)u)0eH?&C6dZP>t zxtRD`E(Wf({C^nQzCwnRaWCs#0Mw-?|U+F|D-{wl=bk2N_<^=sy*gQi?L#9Ps zBxQGS&X$O0&$jsoHpMQ|>D~{511s#$jj@ZTvn%`v>hFAJgHJqECjJ-H*u^`r|JFCM z%L4fTy$vW)8zmnr4BZFJEX8JR$g9QI?(w*5k2wa98+L}Xft2XJo>-{^0f|x*a&%x9 z;=0aJCPkzJ0hNl_OcFvOXh~Sv&3nhpofZWZ?v$j5tCO^GnxvJWuNIQJw7w}R{|aRN zrt3jOXttLMZE#Ui0(U`HI@_3$n=!xzMcWwl{%WBstqHAXa$X z^(c_dfm=XsE`PPndiYenCWN=r;}%{x@HL1Id#8CPPT5Gg zbf~2)`I4$ku5gWzT=DLZavl8RN=WipnOG3jN$#NGLXy{lTqPxYj&9(iItl+9S$4qt literal 0 HcmV?d00001 diff --git a/begui/begui/libbegui/libbegui.proj b/begui/begui/libbegui/libbegui.proj index e16f28603f909cfbf9f22d3f502967a121a5c500..240b290ed14b02d18f3a7371aead646b39db0c3a 100644 GIT binary patch delta 469 zcmbP}x-x^q*VDz7fx$#^BgYALmIalv4U;$UIc^r^IHJPHGWnK{l&;8Mmw=+Qb2ZJIY55&fJJP zQuQ(zf>V=AfZ_o_%mTzi+V>TuQM>X#xO82DgXtMWmf`a)h1un&trqQa`HL@)ye((?2`ix z#F)3|YynG8FmMKmNj5StaMc410C|BCh+$T2g{l%`0U0uRm4T8l7C%qEZ$M&rPF6Gg s$5=XfwV|J~8pt}3oqmbApx_b%VxbBPGyR;*q>`e<<{9 delta 345 zcmZ3PF(;M7*VDz7fx&3XMvfEgEFbR5HcZ~Y=eSvv^^I&gn3K z!4G+vzn61)8(0)&{>DsJX=u4E4rYTSI}~I#E9zP>)(591mjL+zK+Fu100G9}{L-T2 zR4^N)DFJ8z2?qbQW?*P=%giwZ8gPw)L1HzKegni{^BaH+n^j_ozL~io3nu?Cke?i- zKVNb)1B2@tpuhtlW&&b{1|YUsUh;hMM+3FV76y5fU+eQtzF{E7yu9QKP%M)N+2xbp R8 +#include + + + +void file_io(void* sender, uint32 msg, const char *path){ + char *buffer; //for output + void *file; //for MFile reference + + buffer = (char*) malloc(27); //create some space in the buffer + buffer = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //add domething to put in file + + //file output... + file = MFile_Create(path, B_READ_WRITE | B_CREATE_FILE); //file read/write and create if not already there + MFile_Write( (MFile*)file, buffer, strlen(buffer) ); //output buffer contents + MFile_Free((MFile*)file); //clear the file pointer +} + +int main(){ + void *savepanel; // MSavePanel reference + void *app; // MApplication reference + + // Matt 11/04/2002 : Must have a MApplication to use a MFilePanel of descendents + app = MApplication_Create(); //create an MApplication reference + + savepanel = MSavePanel_Create(); //create a MSavePanel reference + MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io); //attach callback for event + + MSavePanel_Show((MSavePanel*) savepanel); //show the panel (this is modal) + + MApplication_Run((MApplication*)app); //run the application + + MApplication_Free((MApplication*)app); //clean up the app + +}