From 8317aa12bfde3d623e642ecc572b282294e8fd80 Mon Sep 17 00:00:00 2001 From: memson Date: Sat, 13 Apr 2002 00:32:16 +0000 Subject: [PATCH] Added MMemo_Text and MMemo_TextLength. Updated the testfile demo to save text from a MMemo when button clicked. --- begui/begui/libbegui/BeGUITestApp2.proj | Bin 13341 -> 13341 bytes begui/begui/libbegui/BeGuiAPI.cpp | 21 ++++++++++++-- begui/begui/libbegui/BeGuiAPI.h | 2 ++ begui/begui/libbegui/filetest.proj | Bin 13212 -> 13212 bytes begui/begui/libbegui/libbegui.proj | Bin 13353 -> 13353 bytes begui/begui/libbegui/testfile.cpp | 37 ++++++++++++++++++++---- 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/begui/begui/libbegui/BeGUITestApp2.proj b/begui/begui/libbegui/BeGUITestApp2.proj index 9938039a149fbf87727f3e5481bb9ec73478a75c..5dd912be631dbbdc0ddccbe680dc89b88197419b 100644 GIT binary patch delta 224 zcmbQ6F*jqw0XCKfdCi8&3wRwjv$Ee;(RKOj5>S-3Pn!V@e#pE0y`0P2z@q5#cg+{= zhL+pnU^YmyL&0UUpw2-?(zHzeudB>dpfx$qP;Ii8-W{d_H!#yre;ZRl0+^{|u$`%( Z49K*ZtZ3-XR8RqA_LFAGW-X)7i~s`}PW%7> delta 224 zcmbQ6F*jqw0XCKwdP)tG7w|f6W@W#xqO0=PC7>v6pEd&+{E%1qdpVc4fkjc}?~==^ z4K26D!EBIZhl0vxL7jt)q-mM_Ussta*I;s?h5V&00pE838X>OlSZA 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 6a37bfb6e2c49aae3adfaa01a6446d7cf9483d71..2b258207c54d7892a1c8a0d372eae0538be68547 100644 GIT binary patch delta 156 zcmbP}J|}&{0XCKoKV=&xFW`0D%*y^#g?Wvs?q)`v*Nh;>WJVoP1-Hx`Lk0$hUknUP zG7Joi8bCG+5HmCYvCa0H=E>{zttZFp9c3!e1Txho`{?_MNl61G-vBW)5W`e<1EudU d6}W>{Z8q4>R1goDf?H;eAp--$FCf0d zz`&>gq*;KNp#g|(w&y&Uyk6gWa=hMArktlhrrKm5eP1!j(?H2LK+FupFqJQW(s!70 c-h)+bHrURT^9!m$Z1M`jT$qKMb&c{F0gD?jV*mgE diff --git a/begui/begui/libbegui/libbegui.proj b/begui/begui/libbegui/libbegui.proj index 240b290ed14b02d18f3a7371aead646b39db0c3a..eeb9db8222022791929c1fd46555470b60adaf3e 100644 GIT binary patch delta 213 zcmZ3Pu`*-B1$Gtz4(W!;8~7YIi*npo(Utk@5>S+OPKN;ue#p!Gy`0P2z@jMgH)Nx1 zL(6S(FdHPnk%A2u%KHpf)*5e;ZSQB$#Pou$`&E49IL}DzE}l RHj}p*29sv;W;3JDi~#;hN1y-z delta 213 zcmZ3Pu`*-B1$LGNm9hwnoDKsR{E!#oBSupvdf!gFK{cTJ+E5S?)gY8T?TY$`Vrkt%n S%4YI5!(h@(-fU*{nGpa}W=ekm 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