textedit.c

Go to the documentation of this file.
00001 
00002 /*  $Id: textedit.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /******************************************************************************
00005 
00006     UserLand Frontier(tm) -- High performance Web content management,
00007     object database, system-level and Internet scripting environment,
00008     including source code editing and debugging.
00009 
00010     Copyright (C) 1992-2004 UserLand Software, Inc.
00011 
00012     This program is free software; you can redistribute it and/or modify
00013     it under the terms of the GNU General Public License as published by
00014     the Free Software Foundation; either version 2 of the License, or
00015     (at your option) any later version.
00016 
00017     This program is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020     GNU General Public License for more details.
00021 
00022     You should have received a copy of the GNU General Public License
00023     along with this program; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 ******************************************************************************/
00027 
00028 #include "frontier.h"
00029 #include "standard.h"
00030 
00031 #include "font.h"
00032 #include "quickdraw.h"
00033 #include "memory.h"
00034 #include "strings.h"
00035 #include "textedit.h"
00036 
00037 
00038 
00039 void edittextbox (bigstring bs, Rect r, short fontnum, short fontsize, short fontstyle) {
00040     
00041     pushstyle (fontnum, fontsize, fontstyle);
00042     
00043     #ifdef MACVERSION
00044         TETextBox (stringbaseaddress (bs), (long) stringlength (bs), &r, teJustLeft);
00045     #endif
00046 
00047     #ifdef WIN95VERSION
00048         setWindowsFont();
00049     
00050         DrawText (getcurrentDC(), stringbaseaddress (bs), stringlength (bs), &r, 
00051                 DT_LEFT | DT_END_ELLIPSIS | DT_WORDBREAK);
00052     
00053         clearWindowsFont();
00054     #endif
00055     
00056     popstyle ();
00057     } /*edittextbox*/
00058 
00059 
00060 boolean edittwostringbox (bigstring bs1, bigstring bs2, Rect r, short fontnum, short fontsize) {
00061     
00062     /*
00063     a front-end for the textedit routine TextBox.  we take two strings, concatenate
00064     them in a buffer with two carriage returns between the strings, display the
00065     result, dispose the buffer.
00066     */
00067     
00068     long len;
00069     Handle hbuffer;
00070     bigstring bs;
00071     
00072     if (!newtexthandle (bs1, &hbuffer))
00073         return (false);
00074     
00075     if (stringlength (bs2) > 0) {
00076         
00077         setstringlength (bs, 2);
00078         
00079         bs [1] = bs [2] = chreturn;
00080         
00081         if (!pushtexthandle (bs, hbuffer)) {
00082             
00083             disposehandle (hbuffer);
00084             
00085             return (false);
00086             }
00087             
00088         if (!pushtexthandle (bs2, hbuffer)){
00089             
00090             disposehandle (hbuffer);
00091             
00092             return (false);
00093             }
00094         }
00095         
00096     len = gethandlesize (hbuffer);
00097         
00098     pushstyle (fontnum, fontsize, 0);
00099     
00100     lockhandle (hbuffer);
00101     
00102     #ifdef MACVERSION
00103         TETextBox (*hbuffer, len, &r, teJustLeft);
00104     #endif
00105 
00106     #ifdef WIN95VERSION
00107         setWindowsFont();
00108         
00109         DrawText (getcurrentDC(), *hbuffer, len, &r, DT_LEFT | DT_END_ELLIPSIS | DT_WORDBREAK);
00110         
00111         clearWindowsFont();
00112     #endif
00113     
00114     
00115     unlockhandle (hbuffer);
00116     
00117     disposehandle (hbuffer);
00118     
00119     popstyle ();
00120     
00121     return (true);
00122     } /*edittwostringbox*/
00123 
00124 

Generated on Wed May 31 18:20:03 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6