XmWrap.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $TOG: XmWrap.c /main/10 1998/09/21 10:57:11 mgreess $ */
  24. /*
  25. * (c) Copyright 1993, 1994 Hewlett-Packard Company *
  26. * (c) Copyright 1993, 1994 International Business Machines Corp. *
  27. * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
  28. * (c) Copyright 1993, 1994 Novell, Inc. *
  29. */
  30. #include <Xm/XmP.h>
  31. #include <Xm/IconFile.h>
  32. #include <Xm/XmPrivate.h>
  33. #ifdef DtUse_XmFunctions
  34. /* Prototypes for internal functions we steal from <Xm/ImageCachI.h>. */
  35. extern Boolean _XmInstallImage(
  36. XImage *image,
  37. char *image_name,
  38. int hot_x,
  39. int hot_y) ;
  40. extern Boolean _XmGetImage(
  41. Screen *screen,
  42. char *image_name,
  43. XImage **image) ;
  44. extern Boolean _XmCachePixmap(
  45. Pixmap pixmap,
  46. Screen *screen,
  47. char *image_name,
  48. Pixel foreground,
  49. Pixel background,
  50. int depth,
  51. Dimension width,
  52. Dimension height) ;
  53. #endif
  54. /************************************************************************
  55. *
  56. * _DtGetPixmapByDepth
  57. * Public wrapper around __DtGetPixmap with parameter order changed.
  58. *
  59. ************************************************************************/
  60. Pixmap
  61. _DtGetPixmapByDepth(
  62. Screen *screen,
  63. char *image_name,
  64. Pixel foreground,
  65. Pixel background,
  66. int depth)
  67. {
  68. return(XmGetPixmapByDepth(screen, image_name,
  69. foreground, background, depth));
  70. }
  71. /************************************************************************
  72. *
  73. * _DtGetPixmap
  74. * Create a pixmap of screen depth, using the image referenced
  75. * by the name and the foreground and background colors
  76. * specified. Ensure that multiple pixmaps of the same attributes
  77. * are not created by maintaining a cache of the pixmaps.
  78. *
  79. ************************************************************************/
  80. Pixmap
  81. _DtGetPixmap(
  82. Screen *screen,
  83. char *image_name,
  84. Pixel foreground,
  85. Pixel background )
  86. {
  87. return (XmGetPixmap(screen, image_name, foreground, background));
  88. }
  89. /************************************************************************
  90. *
  91. * _DtGetMask
  92. *
  93. ************************************************************************/
  94. Pixmap
  95. _DtGetMask(
  96. Screen *screen,
  97. char *image_name)
  98. {
  99. return XmeGetMask( screen, image_name );
  100. }
  101. /************************************************************************
  102. *
  103. * __DtInstallPixmap
  104. * Install a pixmap into the pixmap cache. This is used to add
  105. * cached pixmaps which have no image associated with them.
  106. *
  107. ************************************************************************/
  108. Boolean
  109. __DtInstallPixmap(
  110. Pixmap pixmap,
  111. Screen *screen,
  112. char *image_name,
  113. Pixel foreground,
  114. Pixel background )
  115. {
  116. #ifdef DtUse_XmFunctions
  117. return _XmCachePixmap(pixmap, screen, image_name, foreground, background,
  118. 0, 0, 0);
  119. #else
  120. XtWarning("__DtInstallPixmap: unsupported interface");
  121. return False;
  122. #endif
  123. }
  124. /************************************************************************
  125. *
  126. * _DtDestroyPixmap
  127. * Locate a pixmap in the cache and decrement its reference count.
  128. * When the reference count is at zero, free the pixmap.
  129. *
  130. ************************************************************************/
  131. Boolean
  132. _DtDestroyPixmap(
  133. Screen *screen,
  134. Pixmap pixmap )
  135. {
  136. return XmDestroyPixmap( screen, pixmap );
  137. }
  138. /************************************************************************
  139. *
  140. * _DtInstallImage
  141. * Add the provided image for the image set and return an
  142. * tile id to be used for further referencing. Keep the
  143. * allocation of the image_set array straight.
  144. *
  145. ************************************************************************/
  146. Boolean
  147. _DtInstallImage(
  148. XImage *image,
  149. char *image_name,
  150. int hot_x,
  151. int hot_y)
  152. {
  153. #ifdef DtUse_XmFunctions
  154. return _XmInstallImage(image, image_name, hot_x, hot_y);
  155. #else
  156. XtWarning("_DtInstallImage: unsupported interface");
  157. return False;
  158. #endif
  159. }
  160. /************************************************************************
  161. *
  162. * _DtUninstallImage
  163. * Remove an image from the image set.
  164. * Return a boolean (True) if the uninstall succeeded. Return
  165. * a boolean (False) if an error condition occurs.
  166. *
  167. ************************************************************************/
  168. Boolean
  169. _DtUninstallImage(
  170. XImage *image )
  171. {
  172. return XmUninstallImage( image );
  173. }
  174. XImage *
  175. _DtGetImage(
  176. Screen *screen,
  177. char *image_name,
  178. XImage **image)
  179. {
  180. Boolean result;
  181. #ifdef DtUse_XmFunctions
  182. if( (result=_XmGetImage(screen, image_name, image)) == False )
  183. return False;
  184. else
  185. return *image;
  186. #else
  187. XtWarning("_DtGetImage: unsupported interface");
  188. return False;
  189. #endif
  190. }
  191. /*
  192. * see if this pixmap is in the cache. If it is then return all the
  193. * gory details about it
  194. */
  195. /*ARGSUSED*/
  196. Boolean
  197. __DtGetPixmapData(
  198. Screen *screen,
  199. Pixmap pixmap,
  200. char **image_name,
  201. int *depth,
  202. Pixel *foreground,
  203. Pixel *background,
  204. int *hot_x,
  205. int *hot_y,
  206. unsigned int *width,
  207. unsigned int *height)
  208. {
  209. return XmeGetPixmapData(screen, pixmap, image_name, depth, foreground,
  210. background, hot_x, hot_y, width, height);
  211. }
  212. String
  213. _DtGetIconFileName(
  214. Screen *screen,
  215. String imageInstanceName,
  216. String imageClassName,
  217. String hostPrefix,
  218. unsigned int size)
  219. {
  220. return XmGetIconFileName(screen, imageInstanceName, imageClassName,
  221. hostPrefix, size);
  222. }
  223. void
  224. _DtFlushIconFileCache(String path)
  225. {
  226. XmeFlushIconFileCache(path);
  227. }