home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / utility / UUnicodeTextHandler.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.2 KB  |  56 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. // ===========================================================================
  20. //    UUnicodeTextHandler.cp
  21. // ===========================================================================
  22. //
  23. //    Authror: Frank Tang ftang@netscape.com
  24.  
  25. #pragma once
  26. #include "UMultiFontTextHandler.h"
  27. /*-----------------------------------------------------------------------------
  28.     UUnicodeTextHandler
  29.     Switch font to draw Unicode (UCS2)
  30.     It use Singleton (See Design Patterns by Erich Gamma )
  31. -----------------------------------------------------------------------------*/
  32.  
  33. class UUnicodeTextHandler : public UMultiFontTextHandler{
  34. public:
  35.     static UUnicodeTextHandler*    Instance();
  36.     UUnicodeTextHandler()    {};
  37.     virtual void DrawUnicode(UFontSwitcher* fs, INTL_Unicode* text, int len);
  38.     virtual short UnicodeWidth(UFontSwitcher* fs, INTL_Unicode* text, int len);
  39.  
  40.     virtual void DrawString    (UFontSwitcher* fs,  Str255 str) 
  41.         {     DrawUnicode(fs, (INTL_Unicode*)str+2, ((str[0] - 1 )/ 2)); };
  42.         
  43.     virtual void DrawText    (UFontSwitcher* fs,  char* text, int len)
  44.         {    DrawUnicode(fs, (INTL_Unicode*) text, (len / 2));    };
  45.         
  46.     virtual short StringWidth(UFontSwitcher* fs, Str255 str) 
  47.         { return UnicodeWidth(fs, (INTL_Unicode*)str+2, ((str[0] - 1 )/ 2)); };
  48.         
  49.     virtual short TextWidth(UFontSwitcher* fs, char* text, int len)
  50.         {    return UnicodeWidth(fs, (INTL_Unicode*) text, (len / 2));    };    
  51.     virtual void     GetFontInfo    (UFontSwitcher* fs, FontInfo* fi);
  52.  
  53. private:
  54.     static UUnicodeTextHandler*    fTheOnlyInstance;            
  55. };
  56.