home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / src / rc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.6 KB  |  104 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.  * rc.cpp (RenderingContextObject)
  20.  *
  21.  * C++ implementation of the (rc) RenderingContextObject
  22.  *
  23.  * dp Suresh <dp@netscape.com>
  24.  */
  25.  
  26.  
  27. #include "rc.h"
  28.  
  29. // Constructor and Destructor
  30. RenderingContextObject::
  31. RenderingContextObject(jint majorType, jint minorType, void **arg, jsize nargs)
  32. {
  33.     rcData.majorType = NF_RC_INVALID;
  34.     rcData.minorType = 0;
  35.     rcData.displayer_data = NULL;
  36.     if (majorType == NF_RC_DIRECT)
  37.     {
  38.         rcData.majorType = majorType;
  39.         rcData.minorType = minorType;
  40. #if defined(XP_UNIX)
  41.         rcData.t.directRc.display = NULL;
  42.         rcData.t.directRc.d = NULL;
  43.         rcData.t.directRc.gc = NULL;
  44.         rcData.t.directRc.mask = 0;
  45.         if (nargs >= 1) rcData.t.directRc.display = arg[0];
  46.         if (nargs >= 2) rcData.t.directRc.d = arg[1];
  47.         if (nargs >= 3) rcData.t.directRc.gc = arg[2];
  48.         if (nargs >= 4) rcData.t.directRc.mask = (jint)arg[3];
  49. #elif defined(XP_WIN) || defined(XP_OS2)
  50.         rcData.t.directRc.dc = NULL;
  51.         if (nargs >= 1) rcData.t.directRc.dc = arg[0];
  52. #elif defined(XP_MAC)
  53.         rcData.t.directRc.port = NULL;
  54.         if (nargs >= 1) rcData.t.directRc.port = arg[0];
  55. #endif
  56.     }
  57. }
  58.  
  59.  
  60. RenderingContextObject::~RenderingContextObject()
  61. {
  62. }
  63.  
  64. jint
  65. RenderingContextObject::GetMajorType(void)
  66. {
  67.     return (rcData.majorType);
  68. }
  69.  
  70. jint
  71. RenderingContextObject::GetMinorType(void)
  72. {
  73.     return (rcData.minorType);
  74. }
  75.  
  76. jint
  77. RenderingContextObject::IsEquivalent(jint majorType, jint minorType)
  78. {
  79.     return ((minorType != NF_RC_ALWAYS_DIFFERENT) &&
  80.             (majorType == rcData.majorType) &&
  81.             (minorType == rcData.minorType));
  82. }
  83.  
  84. //
  85. // This will be used only by the Displayer & Consumers
  86. //
  87. struct rc_data
  88. RenderingContextObject::GetPlatformData(void)
  89. {
  90.     return (rcData);
  91. }
  92.  
  93. jint
  94. RenderingContextObject::SetPlatformData(struct rc_data *newRcData)
  95. {
  96.     jint ret = -1;
  97.     if (newRcData)
  98.     {
  99.         rcData = *newRcData;
  100.         ret = 0;
  101.     }
  102.     return (ret);
  103. }
  104.