diff --git a/begui/begui/libbegui/BeGUITestApp2.proj b/begui/begui/libbegui/BeGUITestApp2.proj index 9938039..5dd912b 100644 Binary files a/begui/begui/libbegui/BeGUITestApp2.proj and b/begui/begui/libbegui/BeGUITestApp2.proj differ diff --git a/begui/begui/libbegui/BeGuiAPI.cpp b/begui/begui/libbegui/BeGuiAPI.cpp index 1a9ddd1..d44a775 100644 --- a/begui/begui/libbegui/BeGuiAPI.cpp +++ b/begui/begui/libbegui/BeGuiAPI.cpp @@ -1,9 +1,18 @@ /* - $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.3 2002-04-12 23:32:56 memson Exp $ + $Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.4 2002-04-13 00:32:16 memson Exp $ - $Revision: 1.3 $ + $Revision: 1.4 $ $Log: not supported by cvs2svn $ + Revision 1.3 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.2 2002/04/02 20:42:15 memson updated for Eric @@ -422,6 +431,14 @@ void MMemo_AttachKeyUpDispatcher(MMemo *memo, keyAction_Message msg){ memo->AttachKeyDownDispatcher(msg); } +const char* MMemo_Text(MMemo *memo){ + return memo->getTextView()->Text(); +} + +int32 MMemo_TextLength(MMemo *memo){ + return memo->getTextView()->TextLength(); +} + /// MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, float bottom, char *name){ diff --git a/begui/begui/libbegui/BeGuiAPI.h b/begui/begui/libbegui/BeGuiAPI.h index 482d9b6..c4e50cf 100644 --- a/begui/begui/libbegui/BeGuiAPI.h +++ b/begui/begui/libbegui/BeGuiAPI.h @@ -100,6 +100,8 @@ void MMemo_AttachMouseUpDispatcher(MMemo *memo, mouseAction_Message msg); void MMemo_AttachKeyDownDispatcher(MMemo *memo, keyAction_Message msg); 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); //panel MPanel* MForm_AddMPanel(MForm* frm, float left, float top, float right, float bottom, char *name); diff --git a/begui/begui/libbegui/filetest.proj b/begui/begui/libbegui/filetest.proj index 6a37bfb..2b25820 100644 Binary files a/begui/begui/libbegui/filetest.proj and b/begui/begui/libbegui/filetest.proj differ diff --git a/begui/begui/libbegui/libbegui.proj b/begui/begui/libbegui/libbegui.proj index 240b290..eeb9db8 100644 Binary files a/begui/begui/libbegui/libbegui.proj and b/begui/begui/libbegui/libbegui.proj differ diff --git a/begui/begui/libbegui/testfile.cpp b/begui/begui/libbegui/testfile.cpp index ba008e8..790b799 100644 --- a/begui/begui/libbegui/testfile.cpp +++ b/begui/begui/libbegui/testfile.cpp @@ -3,7 +3,9 @@ #include #include - +//nasty global.. +void *savepanel; // MSavePanel reference +void *memo; void file_io(void* sender, uint32 msg, const char *path){ char *buffer; //for output @@ -18,17 +20,42 @@ void file_io(void* sender, uint32 msg, const char *path){ MFile_Free((MFile*)file); //clear the file pointer } +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 + MFile_Write( (MFile*)file, MMemo_Text((MMemo*)memo), MMemo_TextLength((MMemo*)memo) ); //output buffer contents + MFile_Free((MFile*)file); //clear the file pointer +} + +/* save button click */ +void doclick(void* Sender, uint32 msg){ + MSavePanel_Show((MSavePanel*) savepanel); //show the panel (this is modal) +} + int main(){ - void *savepanel; // MSavePanel reference void *app; // MApplication reference + void *btn; + void *frm; // 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 + frm = MApplication_GetMainForm((MApplication*)app); + MForm_setWidth((MForm*)frm, 250); + MForm_setHeight((MForm*)frm, 250); - MSavePanel_Show((MSavePanel*) savepanel); //show the panel (this is modal) + btn = MButton_Create(5, 25, 35, 20, "save"); + MForm_AddChild((MForm*)frm, (BControl*)btn); + MButton_AttachClickDispatcher((MButton*)btn, doclick); + + 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 + + /* create a memo - like edit, must be done in main form's thread */ + memo = MForm_AddMMemo((MForm*)frm, 30, 100, 150, 150, "test5"); MApplication_Run((MApplication*)app); //run the application