GetBitmap.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
源码类别:

通讯编程

开发平台:

Visual C++

  1. '"
  2. '" Copyright (c) 1990 The Regents of the University of California.
  3. '" Copyright (c) 1994-1998 Sun Microsystems, Inc.
  4. '"
  5. '" See the file "license.terms" for information on usage and redistribution
  6. '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  7. '" 
  8. '" RCS: @(#) $Id: GetBitmap.3,v 1.5.2.1 2005/06/21 23:01:36 dkf Exp $
  9. '" 
  10. .so man.macros
  11. .TH Tk_AllocBitmapFromObj 3 8.1 Tk "Tk Library Procedures"
  12. .BS
  13. .SH NAME
  14. Tk_AllocBitmapFromObj, Tk_GetBitmap, Tk_GetBitmapFromObj, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmapFromObj, Tk_FreeBitmap - maintain database of single-plane pixmaps
  15. .SH SYNOPSIS
  16. .nf
  17. fB#include <tk.h>fR
  18. .sp
  19. .VS 8.1
  20. Pixmap
  21. fBTk_AllocBitmapFromObj(fIinterp, tkwin, objPtrfB)fR
  22. .sp
  23. Pixmap
  24. fBTk_GetBitmap(fIinterp, tkwin, infofB)fR
  25. .sp
  26. Pixmap
  27. fBTk_GetBitmapFromObj(fItkwin, objPtrfB)fR
  28. .VE
  29. .sp
  30. int
  31. fBTk_DefineBitmap(fIinterp, name, source, width, heightfB)fR
  32. .sp
  33. CONST char *
  34. fBTk_NameOfBitmap(fIdisplay, bitmapfB)fR
  35. .sp
  36. fBTk_SizeOfBitmap(fIdisplay, bitmap, widthPtr, heightPtrfB)fR
  37. .sp
  38. .VS 8.1
  39. fBTk_FreeBitmapFromObj(fItkwin, objPtrfB)fR
  40. .VE
  41. .sp
  42. fBTk_FreeBitmap(fIdisplay, bitmapfB)fR
  43. .SH ARGUMENTS
  44. .AS "unsigned long" *pixelPtr
  45. .AP Tcl_Interp *interp in
  46. Interpreter to use for error reporting; if NULL then no error message
  47. is left after errors.
  48. .AP Tk_Window tkwin in
  49. Token for window in which the bitmap will be used.
  50. .VS 8.1 br
  51. .AP Tcl_Obj *objPtr in/out
  52. String value describes desired bitmap; internal rep will be
  53. modified to cache pointer to corresponding Pixmap.
  54. .AP "CONST char" *info in
  55. Same as fIobjPtrfR except description of bitmap is passed as a string and
  56. resulting Pixmap isn't cached.
  57. .VE
  58. .AP "CONST char" *name in
  59. Name for new bitmap to be defined.
  60. .AP "CONST char" *source in
  61. Data for bitmap, in standard bitmap format.
  62. Must be stored in static memory whose value will never change.
  63. .AP "int" width in
  64. Width of bitmap.
  65. .AP "int" height in
  66. Height of bitmap.
  67. .AP "int" *widthPtr out
  68. Pointer to word to fill in with fIbitmapfR's width.
  69. .AP "int" *heightPtr out
  70. Pointer to word to fill in with fIbitmapfR's height.
  71. .AP Display *display in
  72. Display for which fIbitmapfR was allocated.
  73. .AP Pixmap bitmap in
  74. Identifier for a bitmap allocated by fBTk_AllocBitmapFromObjfR or
  75. fBTk_GetBitmapfR.
  76. .BE
  77. .SH DESCRIPTION
  78. .PP
  79. These procedures manage a collection of bitmaps (one-plane pixmaps)
  80. being used by an application.  The procedures allow bitmaps to be
  81. re-used efficiently, thereby avoiding server overhead, and also
  82. allow bitmaps to be named with character strings.
  83. .PP
  84. .VS 8.1
  85. fBTk_AllocBitmapFromObjfR returns a Pixmap identifier for a bitmap
  86. that matches the description in fIobjPtrfR and is suitable for use
  87. in fItkwinfR.  It re-uses an existing bitmap, if possible, and
  88. creates a new one otherwise.  fIObjPtrfR's value must have one
  89. of the following forms:
  90. .VE
  91. .TP 20
  92. fB@fIfileNamefR
  93. fIFileNamefR must be the name of a file containing a bitmap
  94. description in the standard X11 or X10 format.
  95. .TP 20
  96. fInamefR
  97. fINamefR must be the name of a bitmap defined previously with
  98. a call to fBTk_DefineBitmapfR.  The following names are pre-defined
  99. by Tk:
  100. .RS
  101. .TP 12
  102. fBerrorfR
  103. The international "don't" symbol:  a circle with a diagonal line
  104. across it.
  105. .VS "" br
  106. .TP 12
  107. fBgray75fR
  108. 75% gray: a checkerboard pattern where three out of four bits are on.
  109. .VE
  110. .TP 12
  111. fBgray50fR
  112. 50% gray: a checkerboard pattern where every other bit is on.
  113. .VS "" br
  114. .TP 12
  115. fBgray25fR
  116. 25% gray: a checkerboard pattern where one out of every four bits is on.
  117. .VE
  118. .TP 12
  119. fBgray12fR
  120. 12.5% gray: a pattern where one-eighth of the bits are on, consisting of
  121. every fourth pixel in every other row.
  122. .TP 12
  123. fBhourglassfR
  124. An hourglass symbol.
  125. .TP 12
  126. fBinfofR
  127. A large letter ``i''.
  128. .TP 12
  129. fBquestheadfR
  130. The silhouette of a human head, with a question mark in it.
  131. .TP 12
  132. fBquestionfR
  133. A large question-mark.
  134. .TP 12
  135. fBwarningfR
  136. A large exclamation point.
  137. .PP
  138. In addition, the following pre-defined names are available only on the
  139. fBMacintoshfR platform:
  140. .TP 12
  141. fBdocumentfR
  142. A generic document.
  143. .TP 12
  144. fBstationeryfR
  145. Document stationery.
  146. .TP 12
  147. fBeditionfR
  148. The fIeditionfR symbol.
  149. .TP 12
  150. fBapplicationfR
  151. Generic application icon.
  152. .TP 12
  153. fBaccessoryfR
  154. A desk accessory.
  155. .TP 12
  156. fBfolderfR
  157. Generic folder icon.
  158. .TP 12
  159. fBpfolderfR
  160. A locked folder.
  161. .TP 12
  162. fBtrashfR
  163. A trash can.
  164. .TP 12
  165. fBfloppyfR
  166. A floppy disk.
  167. .TP 12
  168. fBramdiskfR
  169. A floppy disk with chip.
  170. .TP 12
  171. fBcdromfR
  172. A cd disk icon.
  173. .TP 12
  174. fBpreferencesfR
  175. A folder with prefs symbol.
  176. .TP 12
  177. fBquerydocfR
  178. A database document icon.
  179. .TP 12
  180. fBstopfR
  181. A stop sign.
  182. .TP 12
  183. fBnotefR
  184. A face with ballon words.
  185. .TP 12
  186. fBcautionfR
  187. A triangle with an exclamation point.
  188. .RE
  189. .LP
  190. .VS 8.1
  191. Under normal conditions, fBTk_AllocBitmapFromObjfR
  192. returns an identifier for the requested bitmap.  If an error
  193. occurs in creating the bitmap, such as when fIobjPtrfR refers
  194. to a non-existent file, then fBNonefR is returned and an error
  195. message is left in fIinterpfR's result if fIinterpfR isn't
  196. NULL. fBTk_AllocBitmapFromObjfR caches information about the return
  197. value in fIobjPtrfR, which speeds up future calls to procedures
  198. such as fBTk_AllocBitmapFromObjfR and fBTk_GetBitmapFromObjfR.
  199. .PP
  200. fBTk_GetBitmapfR is identical to fBTk_AllocBitmapFromObjfR except
  201. that the description of the bitmap is specified with a string instead
  202. of an object.  This prevents fBTk_GetBitmapfR from caching the
  203. return value, so fBTk_GetBitmapfR is less efficient than
  204. fBTk_AllocBitmapFromObjfR.
  205. .PP
  206. fBTk_GetBitmapFromObjfR returns the token for an existing bitmap, given
  207. the window and description used to create the bitmap.
  208. fBTk_GetBitmapFromObjfR doesn't actually create the bitmap; the bitmap
  209. must already have been created with a previous call to
  210. fBTk_AllocBitmapFromObjfR or fBTk_GetBitmapfR.  The return
  211. value is cached in fIobjPtrfR, which speeds up
  212. future calls to fBTk_GetBitmapFromObjfR with the same fIobjPtrfR
  213. and fItkwinfR.
  214. .VE
  215. .PP
  216. fBTk_DefineBitmapfR associates a name with
  217. in-memory bitmap data so that the name can be used in later
  218. calls to fBTk_AllocBitmapFromObjfR or fBTk_GetBitmapfR.  The fInameIdfR
  219. argument gives a name for the bitmap;  it must not previously
  220. have been used in a call to fBTk_DefineBitmapfR.
  221. The arguments fIsourcefR, fIwidthfR, and fIheightfR
  222. describe the bitmap.
  223. fBTk_DefineBitmapfR normally returns TCL_OK;  if an error occurs
  224. (e.g. a bitmap named fInameIdfR has already been defined) then
  225. TCL_ERROR is returned and an error message is left in
  226. fIinterp->resultfR.
  227. Note:  fBTk_DefineBitmapfR expects the memory pointed to by
  228. fIsourcefR to be static:  fBTk_DefineBitmapfR doesn't make
  229. a private copy of this memory, but uses the bytes pointed to
  230. by fIsourcefR later in calls to fBTk_AllocBitmapFromObjfR or
  231. fBTk_GetBitmapfR.
  232. .PP
  233. Typically fBTk_DefineBitmapfR is used by fB#includefR-ing a
  234. bitmap file directly into a C program and then referencing
  235. the variables defined by the file.
  236. For example, suppose there exists a file fBstip.bitmapfR,
  237. which was created by the fBbitmapfR program and contains
  238. a stipple pattern.
  239. The following code uses fBTk_DefineBitmapfR to define a
  240. new bitmap named fBfoofR:
  241. .VS
  242. .CS
  243. Pixmap bitmap;
  244. #include "stip.bitmap"
  245. Tk_DefineBitmap(interp, "foo", stip_bits,
  246. stip_width, stip_height);
  247. &...
  248. bitmap = Tk_GetBitmap(interp, tkwin, "foo");
  249. .CE
  250. .VE
  251. This code causes the bitmap file to be read
  252. at compile-time and incorporates the bitmap information into
  253. the program's executable image.  The same bitmap file could be
  254. read at run-time using fBTk_GetBitmapfR:
  255. .VS
  256. .CS
  257. Pixmap bitmap;
  258. bitmap = Tk_GetBitmap(interp, tkwin, "@stip.bitmap");
  259. .CE
  260. .VE
  261. The second form is a bit more flexible (the file could be modified
  262. after the program has been compiled, or a different string could be
  263. provided to read a different file), but it is a little slower and
  264. requires the bitmap file to exist separately from the program.
  265. .PP
  266. Tk maintains a database of all the bitmaps that are currently in use.
  267. Whenever possible, it will return an existing bitmap rather
  268. than creating a new one.
  269. When a bitmap is no longer used, Tk will release it automatically.
  270. This approach can substantially reduce server overhead, so
  271. fBTk_AllocBitmapFromObjfR and fBTk_GetBitmapfR should generally
  272. be used in preference to Xlib procedures like fBXReadBitmapFilefR.
  273. .PP
  274. The bitmaps returned by fBTk_AllocBitmapFromObjfR and fBTk_GetBitmapfR
  275. are shared, so callers should never modify them.
  276. If a bitmap must be modified dynamically, then it should be
  277. created by calling Xlib procedures such as fBXReadBitmapFilefR
  278. or fBXCreatePixmapfR directly.
  279. .PP
  280. The procedure fBTk_NameOfBitmapfR is roughly the inverse of
  281. fBTk_GetBitmapfR.
  282. Given an X Pixmap argument, it returns the textual description that was
  283. passed to fBTk_GetBitmapfR when the bitmap was created.
  284. fIBitmapfR must have been the return value from a previous
  285. call to fBTk_AllocBitmapFromObjfR or fBTk_GetBitmapfR.
  286. .PP
  287. fBTk_SizeOfBitmapfR returns the dimensions of its fIbitmapfR
  288. argument in the words pointed to by the fIwidthPtrfR and
  289. fIheightPtrfR arguments.  As with fBTk_NameOfBitmapfR,
  290. fIbitmapfR must have been created by fBTk_AllocBitmapFromObjfR or
  291. fBTk_GetBitmapfR.
  292. .PP
  293. .VS 8.1
  294. When a bitmap is no longer needed, fBTk_FreeBitmapFromObjfR or
  295. fBTk_FreeBitmapfR should be called to release it.
  296. For fBTk_FreeBitmapFromObjfR the bitmap to release is specified
  297. with the same information used to create it; for
  298. fBTk_FreeBitmapfR the bitmap to release is specified
  299. with its Pixmap token.
  300. There should be exactly one call to fBTk_FreeBitmapFromObjfR
  301. or fBTk_FreeBitmapfR for each call to fBTk_AllocBitmapFromObjfR or
  302. fBTk_GetBitmapfR.
  303. .VE
  304. .SH BUGS
  305. In determining whether an existing bitmap can be used to satisfy
  306. a new request, fBTk_AllocBitmapFromObjfR and fBTk_GetBitmapfR
  307. consider only the immediate value of the string description.  For
  308. example, when a file name is passed to fBTk_GetBitmapfR,
  309. fBTk_GetBitmapfR will assume it is safe to re-use an existing
  310. bitmap created from the same file name:  it will not check to
  311. see whether the file itself has changed, or whether the current
  312. directory has changed, thereby causing the name to refer to
  313. a different file.
  314. .SH KEYWORDS
  315. bitmap, pixmap