home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / src / fmi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.0 KB  |  99 lines

  1. /* -*- Mode: C++; tab-width: 8; 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.  * fmi.h (FontMatchInfoObject.h)
  20.  *
  21.  * C++ implementation of the (fmi) FontMatchInfoObject
  22.  *
  23.  * dp Suresh <dp@netscape.com>
  24.  */
  25.  
  26.  
  27. #ifndef _fmi_H_
  28. #define _fmi_H_
  29.  
  30. #include "libfont.h"
  31. #include "nf.h"
  32.  
  33. #include "Mnffmi.h"
  34.  
  35. #include "wfList.h"
  36.  
  37. #define FMI_FONTPART_DEFAULT        '*'
  38. #define FMI_FONTPART_SEPERATOR        '-'
  39. #define FMI_FONTPART_ESCAPE            '\\'
  40. #define FMI_FONTPART_ATTRSEPERATOR    ':'
  41.  
  42. #define FMI_TYPE_CSTRING    1
  43. #define FMI_TYPE_JINT        2
  44.  
  45. struct fmi_attr_store {
  46.   const char *attr;
  47.   int valueType;
  48.   union {
  49.     void *genericValue;
  50.     const char *stringValue;
  51.     jint intValue;
  52.   } u;
  53. };
  54.  
  55. class FontMatchInfoObject : public wfList {
  56. protected:
  57.   // A string representation of this FMI
  58.   const char *stringRepresentation;
  59.   int stringLen;
  60.   int stringMaxLen;
  61.  
  62.   int addAttribute(const char *attr, const char *value);
  63.   int addAttribute(const char *attr, jint value);
  64.  
  65.   // These are used to keep the stringRepresentaion insync with the attributes.
  66.   int addToString(const char *&str, int &strLen, int &strMaxLen, struct fmi_attr_store *ele);
  67.   int addToString(const char *&str, int &strLen, int &strMaxLen, const char *value);
  68.   int addToString(const char *&str, int &strLen, int &strMaxLen, const char value);
  69.   const char *scanFontpart(const char *str, char *fontpart, const char *&attr, const char *&value);
  70.   int releaseStringRepresentation(void);
  71.  
  72.  
  73. public:
  74.   FontMatchInfoObject(const char *name, const char *charset,
  75.                       const char *encoding, jint weight, jint pitch,
  76.                       jint style, jint underline, jint strikeOut,
  77.                       jint resolutionX, jint resolutionY);
  78.   FontMatchInfoObject(const char *reconstructString);
  79.   ~FontMatchInfoObject();
  80.   
  81.   void *GetValue(const char *attr);
  82.   const char ** ListAttributes();
  83.  
  84.   // Checks if this fmi is equivalent to the passed in fmi
  85.   // Comparison takes care of dont cares
  86.   jint IsEquivalent(struct nffmi *fmi);
  87.  
  88.   // Check if two FontMatchInfoObjects are EQUAL. (All values including
  89.   // wildcards should match)
  90.   int isEqual(FontMatchInfoObject *fob);
  91.  
  92.   const char *describe(void);
  93.   int reconstruct(const char *describeString);
  94.  
  95.   friend void free_fmi_attr_store (wfList *object, void *item);
  96. };
  97.  
  98. #endif /* _fmi_H_ */
  99.