MLTE Control in power plant
|
|
Thread rating:  |
vcmac - 13 Oct 2004 08:23 GMT I am new to power plant. I have to use RTF control in my application. I got the control MLTE but strugling for how to open the rtf file edited in text edit in that control. So anyone who is having any idea can pls help me.
Again when I am using the standard file open dialog the rtf file editd by text edit is disabled how to enable it?
Thanks in advance.
-Hemant
MW Ron - 18 Oct 2004 22:38 GMT In article <af1e73c080c2c412e7146efee2124f84@localhost.talkaboutmac.com>,
>I am new to power plant. > I have to use RTF control in my application. [quoted text clipped - 4 lines] >Again when I am using the standard file open dialog the rtf file editd by >text edit is disabled how to enable it? I'm not really sure what you are specifically having problems with. Assuming you can't open it and that is the only problem, can he post the code he's using for the open dialog?
 Signature Metrowerks Community Forum is a free online resource for developers to discuss CodeWarrior topics with other users and Metrowerks' staff -- http://www.metrowerks.com/community --
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
vcmac - 23 Oct 2004 06:20 GMT Follwoing is the code for open dialog.
FSSpec filespec; if(PP_StandardDialogs::AskChooseOneFile(ftRTFDocument,filespec,kNavDefaultNavDialogOptions,kNavSelectAllReadableItem) {
}
But when it is opening the dialog, All RTF documents edited by textedit are disable. So where is a problem? Can u pls explain? Thanks
-Hemant
David Phillip Oster - 23 Oct 2004 06:41 GMT In article <ec67ca10f0937ea73ac49b5deb6f5618@localhost.talkaboutmac.com>,
> Follwoing is the code for open dialog. > [quoted text clipped - 9 lines] > So where is a problem? > Can u pls explain? Probably because Apple's TextEdit fails to set the file's 4-byte type code to anything resembling 'RTF '. Apple's TextEdit just depends on the last few characters of the filename being ".rtf". To find such files, you'll need to write a function that filters based on the filename. You might actually open the file and verify that the data fork starts with:
{\rtf
vcmac - 25 Oct 2004 07:32 GMT But here Data fork get filled after launching the file Open Dialog. In file open dialog all rtf documents edited by text edit are disabled. So how can I filter the filename. Can u pls explain it in detail?
Thanks
-Hemant
David Phillip Oster - 26 Oct 2004 06:14 GMT In article <8533bbd8ca58b1dffbce3473521f825d@localhost.talkaboutmac.com>,
> But here Data fork get filled after launching the file Open Dialog. In > file open dialog all rtf documents edited by text edit are disabled. So > how can I filter the filename. > Can u pls explain it in detail? Here, I've written your program for you:
On my source code web page, <http://turbozen.com/sourcecode/> I've put a PowerPlant project, MLTEDoc, with complete source code that opens a RTF file into a LMLTEPane window.
Here's how you add a filter to PowerPlant's Open dialog box:
static pascal Boolean MyFilter(AEDesc *theItem, void * info, void * /*callBackUD*/, NavFilterModes filterMode){ switch(filterMode){ case kNavFilteringBrowserList: case kNavFilteringFavorites: case kNavFilteringRecents: return CanOpen(theItem, reinterpret_cast<NavFileOrFolderInfo*>(info)); default: return true; } return false; }
void CDocumentApp::ChooseDocument(){ PP_StandardDialogs::LFileChooser chooser; NavDialogOptions* options = chooser.GetDialogOptions(); if (options != nil) { options->dialogOptionFlags = kNavDefaultNavDlogOptions | kNavSelectAllReadableItem; } chooser.SetObjectFilterProc(MyFilter); // <- Notice LFileTypeList fileTypeList(fileTypes_All); if(chooser.AskOpenFile(fileTypeList)){ AEDescList docList; chooser.GetFileDescList(docList); SendAEOpenDocList(docList); } }
The complete source for "CanOpen" is in the example on my web site. It handles the fact that Mac HFS+ filenames are really 16-bit per character unicode, so you might like to filter by unicode suffixes.
I'll also submit it to the PowerPlant contributed class archives, but don't hold your breath waiting for it to appear there.
I've also written a CUnicodeEditText control that is a drop in replacement for LEditText: If you register it, instead of LEditText for the signature 'etxt', then all your PPobs get my class instead of the official LEditText. The advantage is that the new class uses Apple's built in Control Manager Unicode Edit Control (not to be confused with either MLTE or HITextView), so Unicode becomes as easy to work with for editing as LStaticCaption makes it for static text.
I redefine GetDescriptor and SetDescriptor for my wrappers for LWindows, and LAMControlImpl so that they assume they are working with UTF-8 strings, convert them to CFStrings, and pass them through PowerPlant's CFString accessors. That way, all my old data files are suddenly Unicode compatible, and even the 8-bit string manipulation in my app works right.
James W. Walker - 26 Oct 2004 07:45 GMT In article <oster-415BDF.22163925102004@newssvr13-ext.news.prodigy.com>, David Phillip Oster <oster@ieee.org> wrote:
> I've also written a CUnicodeEditText control that is a drop in > replacement for LEditText: Me too, <http://www.jwwalker.com/pages/ccarbonedittext.html>.
David Phillip Oster - 05 Nov 2004 19:50 GMT > In article > <oster-415BDF.22163925102004@newssvr13-ext.news.prodigy.com>, David [quoted text clipped - 4 lines] > > Me too, <http://www.jwwalker.com/pages/ccarbonedittext.html>. James Walker did a great job, but he left out one minor point. I took his code and edited it so that you can take an existing program, and change one line in RegisterClasses() and get unicode aware edit controls from all the LEditTexts in your existing PPobs. Constructor still thinks they are LEditTexts, but at runtime they reanimate to CUnicodeEditTexts.
I've also incorporated Brett Wood's CMultipleUndoer class, so the example has multiple undo in a multi-field dialog box: you can tab from field to field making changes, then undo as many as many as you like, with the focus moving back from field to field, then redo as many as you like.
I've compiled it with 8.3 and with 9.3, and it appears to work with either.
<http://www.TurboZen.com/sourceCode/>
I'm a little annoyed with Apple: MLTE, as wrapped by LMLTEPane doesn't give you support for the application's Services menu, but Apple's EditUnicodeText control as wrapped by CUnicodeEditText does give you support for the Services menu.
One tricky point: in PowerPlant, the destructor for LWindow destroys all the subviews then one more layer of the onion is unwrapped and LCommander's destructor is called, which calls LAttachable's destructor, which destroys the LMultipleUndoer attachment. The LMultipleUndoer in turn destroys its LArray of LActions, but the LActions refer to the LPanes, so when the LAction tries to tell the LPane that the LAction is going away, the LAction indirects through a dead pointer. Kaboom.
I fixed this by making the LActions LListeners, so they get notified (msg_BroadcasterDied) when the corresponding LPane is dieing, so they can set their reference to the LPane to NULL.
This allows either the LPane or the LAction to die first.
vcmac - 26 Oct 2004 13:16 GMT Thanks I will try it.
-Hemant
vcmac - 27 Oct 2004 12:24 GMT Thanks for ur valuable guidance. Filtering of rtf is working. I have download ur MLTE code from ur site. IT's zip file But some files in __MACOSX folder are . files which are hidden. So I am unable to see those files. So How to see those files? Can u pls explain. Thanks -Hemant
James W. Walker - 27 Oct 2004 16:51 GMT In article <b01a9f35687daee8d551f99d103225a8@localhost.talkaboutmac.com>, vcmac <projectleader@nospam.solutionnext.com> wrote:
> I have download ur MLTE code from ur site. > IT's zip file But some files in __MACOSX folder are . files > which are hidden. So I am unable to see those files. > So How to see those files? Use the OS X Finder, not StuffIt Expander, to unzip. The Finder uses a special method to preserve resource forks.
vcmac - 28 Oct 2004 10:44 GMT Not Getting u. Can u pls explain?
Again I have Mac machine having os MacOSX 1.3 So I am trying to open the RTF file in mlte control. But my OS Doesn't support function TXNFlattenObjectToCFDataRef() or TXNSetDataFromCFURLRef(). Because of the problem I mentioned, I couldn't see source code of you people. So Can u pls Suggest some alternative?
Thanks -Hemant
David Phillip Oster - 05 Nov 2004 19:23 GMT In article <oster-415BDF.22163925102004@newssvr13-ext.news.prodigy.com>,
> In article > <8533bbd8ca58b1dffbce3473521f825d@localhost.talkaboutmac.com>, [quoted text clipped - 9 lines] > I've put a PowerPlant project, MLTEDoc, with complete source code that > opens a RTF file into a LMLTEPane window. Since some people weren't able to cope with a Mac OS X archive file with a .zip extension, I've replaced the above sample code with a .sit file. That should cause fewer problems.
vcmac - 08 Nov 2004 05:20 GMT I have downloaded code for mlte. It's opening now. But It's giving link error like,
Undefined UClassicDialogs::LFileChooser(); Undefined LStsScrollBarImp::TrackLinThumb Undefined GetScrap().
I have included all header file as well as in setting also I add path of all these file.But still it's giving link error. Can u pls help me How to solve it?
Thanks
-Hemant
David Phillip Oster - 08 Nov 2004 08:24 GMT In article <700d170e6227e5909b8a461a52671084@localhost.talkaboutmac.com>,
> I have downloaded code for mlte. > It's opening now. But It's giving link error like, [quoted text clipped - 6 lines] > I add path of all these file.But still it's giving link error. > Can u pls help me How to solve it? What version of Codewarrior are you using? The project at <http://www.turbozen.com/sourceCode/>, <http://www.turbozen.com/sourceCode/mltedoc/mltedoc.sit> compiles for me, both targets, under Metrowerks Codewarrior 9.3.
vcmac - 08 Nov 2004 12:32 GMT I am using the codewarrior version 5.0. But on same version when I am using the same functions of UStandardDialogs in my sample program it is working fine. But when I am using your code on same version there are some linking errors as mentioned above. There may be setting problem I think so. can u plssssss help me?
Thnaks -Hemant
David Phillip Oster - 08 Nov 2004 16:44 GMT In article <a82028b370d2a818d53797a9683384fc@localhost.talkaboutmac.com>,
> I am using the codewarrior version 5.0. > But on same version when I am using the same functions of [quoted text clipped - 3 lines] > There may be setting problem I think so. > can u plssssss help me? I think you must mean Codewarrrior Pro 8.0, which used IDE 5.0. Codewarrior Pro 5 used IDE 4.0.4, and did not include LMTEPane.cp
So, I redid my sample for Codewarior Pro 8.0. It is in:
<http://www.turbozen.com/sourceCode/> as <http://www.turbozen.com/sourceCode/mltedoc/mltedoc8.sit>
I hope this helps. You do know how to add files that aren't already in your project into your project?
vcmac - 09 Nov 2004 13:08 GMT I have download the latest version from ur site. Mltedoc8.sit. But when I am trying to unzip it with stuff exapander,it is giving some data fork error. So How open it? Again I am unable to find BombArchiveExpander.
Thanks -Hemant
David Phillip Oster - 09 Nov 2004 17:38 GMT In article <037b1b3228cd5150ea4ed74dd4c44b83@localhost.talkaboutmac.com>,
> I have download the latest version from ur site. > Mltedoc8.sit. > But when I am trying to unzip it with stuff exapander,it is > giving some data fork error. Download <http://www.turbozen.com/sourcecode/mltedoc/mltedoc8.sit.hqx>. I think your browser is misconfigured, and the .hqx file should unstuff correctly for you.
David Phillip Oster - 09 Nov 2004 17:43 GMT In article <037b1b3228cd5150ea4ed74dd4c44b83@localhost.talkaboutmac.com>,
> Again I am unable to find BombArchiveExpander. if you <Control>-Click on a .zip file in OS X, you'll see "BOMArchiveHelper" listed as the default application under "Open With" for opening that kind of file. Mac .zip files, created using the "Create Archive" command on that some <Control>-Click menu, have a specific structure that BOMArchiveHelper knows how to correctly decode.
BOMArchiveHelper itself is in /System/Library/CoreServices/
vcmac - 18 Nov 2004 10:53 GMT Hi David, I am posting my LMLTPANE code for opening rtf file in MLTE control. Actually I am not getting any function for flattening RTF text from file so that I can preserve all formating. With this code all RTF tags are coming in MLTE control.Please see the following code.
LMLTEPane* mltPane; mltPane=dynamic_cast<LMLTPane*>(step3Dlg->FindPaneByID(228));
OSType fileType= nil; // Long len; TXNObject text; StHandleBlock theTextH; Handle h=nil;
FSSpec fileSpec; PP_StandardDialogs::LFileChooser chooser; NavDialogOptions* options = chooser.GetDialogOptions();
if(options != nil) { options->dialogOptionFlags= kNavDefaultNavDalogOptions+kNavSelectAllREadableItem;
LFileTypeList fileTypeList(fileTypes_All);
if(chooser.AskChooseOneFile(fileTypeList,fileSpect)) { LFile theFile(fileSpect); theFile.OpenDataFork(fsRdPerm); StHandleBlock textH(theFile.ReadDataFork()); StHandleLocker lock(textH); mltPane->SetTextPtr(*textH.::GetHandleSize(textH)); } }
Can u pls tell me the API's which will help me? I am using MacOSX10.1.4.
Thanks&Regards -Hemant
David Phillip Oster - 18 Nov 2004 14:35 GMT In article <f11f1062bba312e02638f8fb50e4ee21@localhost.talkaboutmac.com>,
> if(chooser.AskChooseOneFile(fileTypeList,fileSpect)) > { [quoted text clipped - 4 lines] > mltPane->SetTextPtr(*textH.::GetHandleSize(textH)); > } if(chooser.AskChooseOneFile(fileTypeList,fileSpect)){ LFile theFile(fileSpect); long len; ThrowIfOSStatus_(GetEOF(theFile.GetDataForkRefNum(), &len)); ThrowIfOSStatus_(TXNSetDataFromFile(mltPane->GetTextObject(), theFile.GetDataForkRefNum(), 'TEXT', len, kTXNStartOffset, kTXNEndOffset)); mltPane->Refresh(); }
Yes, it is the case that SetTextPtr(), which is a wrapper for TXNSetData() does not interpret the rich text format, but just inserts it literally, while TXNSetDataFromFile() does interpret it.
You might also look at the source code of Text Edit's file i/o, in:
/Developer/Examples/AppKit/TextEdit/DocumentReadWrite.m
which seems to show that the functions you'd need to make MLTE decide whether to read and write in RTF or not is not fully available in Carbon's MacTextEditor.h, but I am no expert.
vcmac - 19 Nov 2004 05:30 GMT I am using the function TXNSetDataFromFile() to get encoded data in TXNObject but It's coming null. -Hemant
vcmac - 19 Nov 2004 09:45 GMT When I am using the following API
TXNSetDataFromFile(mltPane->GetTextObject(),theFile.GetDataForkRefNum (),'TEXT',len,kTXNStartOffset,kTXNEndOffset);
It's returning the error code -39 (which is EOF error). What may be the reason for this?
Thanks -Hemant
David Phillip Oster - 19 Nov 2004 16:55 GMT In article <5e051678a97998d6e0691c241ee08cb8@localhost.talkaboutmac.com>,
> When I am using the following API > [quoted text clipped - 3 lines] > It's returning the error code -39 (which is EOF error). > What may be the reason for this? Did you open the file previously?
What is the value of "len" on entry to this call? Did you call:
GetEOF(mltPane->GetTextObject(),theFile.GetDataForkRefNum(), &len);
previously?
Is the .rtf well formed?
vcmac - 20 Nov 2004 05:38 GMT Yes I call GetEOF() function. value of len is coming 256. and this is returning 0 (Success). -Hemant
David Phillip Oster - 21 Nov 2004 20:39 GMT > In article > <5e051678a97998d6e0691c241ee08cb8@localhost.talkaboutmac.com>, [quoted text clipped - 7 lines] > > It's returning the error code -39 (which is EOF error). > > What may be the reason for this? I wrote:
> Did you open the file previously? > [quoted text clipped - 5 lines] > > Is the .rtf well formed? In article <3b08657535b99e2e12a1ee75ad9fc15d@localhost.talkaboutmac.com>,
> Yes I call GetEOF() function. > value of len is coming 256. > and this is returning 0 (Success). EOF means it is trading past the end of the file. Did you previously read the file? if so, stop it. Or use FSetFPos() to reset the DataForkRefNum to the beginning of the file.
David Phillip Oster - 21 Nov 2004 20:56 GMT In article <oster-1FD53D.12391821112004@newssvr21-ext.news.prodigy.com>,
> EOF means it is trading past the end of the file. EOF means it is reading past the end of the file.
Oops. Off-by-one finger error.
vcmac - 22 Nov 2004 09:17 GMT Thanks David It's coming now. But still one problem is there. It's displaying all font attributes but It's not displaying color if text is in color.(Dispalying fonts in default black color) Is there any seperate API for this? Thanks -Hemant
David Phillip Oster - 24 Nov 2004 05:14 GMT In article <79f3a3c178bccb05b5acf9f8812853d1@localhost.talkaboutmac.com>,
> Thanks David It's coming now. > But still one problem is there. > It's displaying all font attributes but It's not displaying color if text > is in color.(Dispalying fonts in default black color) > Is there any seperate API for this? I've not been able to reproduce this. I made a small file in Apple's TextEdit, colored some of the text, then read it with the MLTEDoc example I've previously posted, MLTEDoc, on <http://www.TurboZen.com/SourceCode/>, and the colors showed through just fine.
But, see my reply to your query about FontPanel.
Here is the test rtf file I used:
{\rtf1\mac\ansicpg10000\cocoartf102 {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fnil\fcharset77 Didot;} {\colortbl;\red255\green255\blue255;\red255\green39\blue66;\red8\green202\blue50;\red28\green42\blue255; } \margl1440\margr1440\vieww9000\viewh9000\viewkind0 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\fs24 \cf0 this is \f1\fs70 \cf2 red \f0\fs24 \cf0 text\ this is \cf3 green\cf0 text\ this is \cf4 blue\cf0 text\ and so is this}
vcmac - 26 Nov 2004 12:32 GMT Hi david I am posting my code for saving the MLTE contents into RTF file so that I can save it into RTF and that file should open with textedit. But It is making a palin file and loosing all RTF formating So can u pls give a look to this code. Pls suggest something.
TXNObject txt; StrFileName FileTitle=”\pUntitled”; FSSpec outFsspec; bool replace = true; ScriptCode.code=10; PP_StandardDialogs::AskSaveFile(FileTitle,ResType_Text,outFSSpec,replace);
LFile *saveFile; saveFile=new Lfile(outFSSpec); saveFile->CreateNewFile(Creator_DemoDoc1,Restype_Text); saveFile->OpenDataFork(fsRdWrPerm); saveFile->OpenResourceFork(fsRdWrPerm); LMTEPane * mltPane; Handle h=NULL; StHandleBlock theTextH; mltPane = dynamic_cast<LMLTEPane*>(Step3Dlg->FindPaneByID(228)); txt = MltPane->GetTextObjects();
::TXNGetDataEncoded(txt,kTXNStartOffset,kTXNEndOffset,&h,kTXNTextData); theTextH.Adopt(h); Size thextSize= ::GetHandleSize(theTextH); StHandleLocker theLOck(theTexhH); saveFile->WriteDataFork(*theTextH,textSize);
Thanks -Hemant
David Dunham - 27 Nov 2004 21:43 GMT In article <f11f1062bba312e02638f8fb50e4ee21@localhost.talkaboutmac.com>,
> I am posting my LMLTPANE code for opening rtf file in MLTE > control. Actually I am not getting any function for flattening RTF text > from file so that I can preserve all > formating. With this code all RTF tags are coming in MLTE > control.Please see the following code.
> I am using MacOSX10.1.4. My recollection is that MLTE didn't have very good flattening APIs back in 10.1.
 Signature David Dunham A Sharp, LLC http://www.a-sharp.com/ "I say we should listen to the customers and give them what they want." "What they want is better products for free." --Scott Adams
|
|
|