XInterface.c 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539
  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. /* $XConsortium: XInterface.c /main/37 1996/11/11 12:28:19 cde-hp $ */
  24. /************************************<+>*************************************
  25. ****************************************************************************
  26. **
  27. ** File: XInterface.c
  28. **
  29. ** Project: Cde Help System
  30. **
  31. ** Description: This is the UI dependant layer to the Help System.
  32. ** It receives requests from the Core Engine for
  33. ** information or to do rendering. It does the
  34. ** appropriate work based on a Motif and X Lib
  35. ** interface.
  36. **
  37. ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
  38. **
  39. ** (c) Copyright 1993, 1994 Hewlett-Packard Company
  40. ** (c) Copyright 1993, 1994 International Business Machines Corp.
  41. ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  42. ** (c) Copyright 1993, 1994 Novell, Inc.
  43. **
  44. ****************************************************************************
  45. ************************************<+>*************************************/
  46. /*
  47. * system includes
  48. */
  49. #include <stdlib.h>
  50. #include <limits.h>
  51. #include <errno.h>
  52. #include <X11/Xlib.h>
  53. #include <X11/Xos.h>
  54. #ifdef X_NOT_STDC_ENV
  55. extern int errno;
  56. #endif
  57. /*
  58. * Canvas Engine
  59. */
  60. #include "CanvasP.h"
  61. #include "CanvasSegP.h"
  62. /*
  63. * private includes
  64. */
  65. #include "AsciiSpcI.h"
  66. #include "DisplayAreaP.h"
  67. #include "HelpErrorP.h"
  68. #include "FontAttrI.h"
  69. #include "FontI.h"
  70. #include "GraphicsI.h"
  71. #include "RegionI.h"
  72. #include "StringFuncsI.h"
  73. #include "XInterfaceI.h"
  74. #include <X11/bitmaps/root_weave>
  75. #ifdef NLS16
  76. #endif
  77. /******** Private Function Declarations ********/
  78. static void DADrawSpc (
  79. _DtCvPointer client_data,
  80. _DtCvPointer spc_handle,
  81. _DtCvUnit x,
  82. _DtCvUnit y,
  83. _DtCvUnit box_x,
  84. _DtCvUnit box_y,
  85. _DtCvUnit box_height,
  86. int link_type,
  87. _DtCvFlags old_flags,
  88. _DtCvFlags new_flags );
  89. /******** End Private Function Declarations ********/
  90. /*****************************************************************************
  91. * Private Defines
  92. *****************************************************************************/
  93. #define GROW_SIZE 3
  94. /*****************************************************************************
  95. * Private Macros
  96. *****************************************************************************/
  97. #define IsHyperLink(x) ((x) & _DtCvLINK_FLAG)
  98. #define IsHyperBegin(x) ((x) & _DtCvLINK_BEGIN)
  99. #define IsHyperEnd(x) ((x) & _DtCvLINK_END)
  100. #define IsPopUp(x) ((x) & _DtCvLINK_POP_UP)
  101. #define IsNewWindow(x) ((x) & _DtCvLINK_NEW_WINDOW)
  102. #define HasTraversal(x) ((x) & _DtCvTRAVERSAL_FLAG)
  103. #define IsTraversalBegin(x) ((x) & _DtCvTRAVERSAL_BEGIN)
  104. #define IsTraversalEnd(x) ((x) & _DtCvTRAVERSAL_END)
  105. #define IsSelected(x) ((x) & _DtCvSELECTED_FLAG)
  106. #define IsMarkOn(x) (((x) & _DtCvMARK_FLAG) && ((x) & _DtCvMARK_ON))
  107. #define TocIsOn(x) ((x) & _DT_HELP_TOC_ON)
  108. #define TocIsOff(x) (!((x) & _DT_HELP_TOC_ON))
  109. #define TurnTocOn(x) (x) |= _DT_HELP_TOC_ON
  110. #define TurnTocOff(x) (x) &= ~(_DT_HELP_TOC_ON)
  111. #define IsEndOfLine(x) ((x) & _DtCvEND_OF_LINE)
  112. /*****************************************************************************
  113. * Private Variables
  114. *****************************************************************************/
  115. static const char IsoString[] = "ISO-8859-1";
  116. static const char SymbolString[] = "DT-SYMBOL-1";
  117. static const char DefaultStr[] = "default_spc";
  118. #define MAX_STR_LEN 5
  119. typedef struct {
  120. const char *symbol;
  121. const char spc_string[MAX_STR_LEN];
  122. const char *spc_value;
  123. } SpecialSymbolTable;
  124. static SpecialSymbolTable SpcTable[] =
  125. {
  126. {"[aacute]", {'\341','\0'}, IsoString }, /*ISOlat1, small a, acute accent */
  127. {"[acirc ]", {'\342','\0'}, IsoString }, /*ISOlat1, small a, circumflex */
  128. {"[aelig ]", {'\346','\0'}, IsoString }, /*ISOlat1, small ae diphthong */
  129. {"[agrave]", {'\340','\0'}, IsoString }, /*ISOlat1, small a, grave accent */
  130. {"[alpha ]", {'\141','\0'}, SymbolString}, /*ISOgrk3, Greek, small alpha */
  131. {"[aleph ]", {'\300','\0'}, SymbolString}, /*ISOtech, aleph, Hebrews */
  132. {"[amp ]", { '&' ,'\0'}, IsoString }, /*ISOnum , ampersand */
  133. {"[and ]", {'\331','\0'}, SymbolString}, /*ISOtech, wedge, logical and */
  134. {"[ang ]", {'\320','\0'}, SymbolString}, /*ISOamso, angle */
  135. {"[angst ]", {'\305','\0'}, IsoString }, /*ISOtech, Angstrom, cap A, ring */
  136. {"[ap ]", {'\273','\0'}, SymbolString}, /*ISOtech, approximately equal */
  137. {"[apos ]", { '\'' ,'\0'}, IsoString }, /*ISOnum , apostrophe */
  138. {"[aring ]", {'\345','\0'}, IsoString }, /*ISOlat1, small a, ring */
  139. {"[ast ]", { '*' ,'\0'}, IsoString }, /*ISOnum , asterisk */
  140. {"[atilde]", {'\343','\0'}, IsoString }, /*ISOlat1, small a, tilde */
  141. {"[auml ]", {'\344','\0'}, IsoString }, /*ISOlat1, small a, umlaut mark */
  142. {"[beta ]", {'\142','\0'}, SymbolString}, /*ISOgrk3, Greek, small beta */
  143. {"[blank ]", { ' ' ,'\0'}, IsoString }, /*ISOpub , significant blank */
  144. {"[bottom]", {'\136','\0'}, SymbolString}, /*ISOtech, bottom symbol */
  145. {"[brvbar]", {'\246','\0'}, IsoString }, /*ISOnum , broken vertical bar */
  146. {"[bsol ]", { '\\' ,'\0'}, IsoString }, /*ISOnum , backslash, rev solidus*/
  147. {"[bull ]", {'\267','\0'}, SymbolString}, /*ISOpub , round bullet,filled */
  148. {"[cap ]", {'\307','\0'}, SymbolString}, /*ISOtech, intersection */
  149. {"[ccedil]", {'\347','\0'}, IsoString }, /*ISOlat1, small c, cedilla */
  150. {"[cent ]", {'\242','\0'}, IsoString }, /*ISOnum , cent sign */
  151. {"[chi ]", {'\143','\0'}, SymbolString}, /*ISOgrk3, Greek, small chi */
  152. {"[clubs ]", {'\247','\0'}, SymbolString}, /*ISOpub , clubs suit symbol */
  153. {"[colon ]", { ':' ,'\0'}, IsoString }, /*ISOnum , colon */
  154. {"[comma ]", { ',' ,'\0'}, IsoString }, /*ISOnum , comma */
  155. {"[commat]", { '@' ,'\0'}, IsoString }, /*ISOnum , commercial at */
  156. {"[cong ]", {'\100','\0'}, SymbolString}, /*ISOtech, congruent with */
  157. {"[copy ]", {'\323','\0'}, SymbolString}, /*ISOnum , copyright symbol */
  158. {"[cup ]", {'\310','\0'}, SymbolString}, /*ISOtech, union or logical sum */
  159. {"[curren]", {'\244','\0'}, IsoString }, /*ISOnum , general currency sign */
  160. {"[darr ]", {'\257','\0'}, SymbolString}, /*ISOnum , downward arrow */
  161. {"[dArr ]", {'\337','\0'}, SymbolString}, /*ISOamsa, down double arrow */
  162. {"[dash ]", { '-' ,'\0'}, IsoString }, /*ISOpub , dash */
  163. {"[deg ]", {'\260','\0'}, SymbolString}, /*ISOnum , degree sign */
  164. {"[delta ]", {'\144','\0'}, SymbolString}, /*ISOgrk3, Greek, small delta */
  165. {"[diams ]", {'\250','\0'}, SymbolString}, /*ISOpub , diamond suit symbol */
  166. {"[divide]", {'\270','\0'}, SymbolString}, /*ISOnum , divide sign */
  167. {"[dollar]", { '$' ,'\0'}, IsoString }, /*ISOnum , dollar sign */
  168. {"[eacute]", {'\351','\0'}, IsoString }, /*ISOlat1, small e, acute accent */
  169. {"[ecirc ]", {'\352','\0'}, IsoString }, /*ISOlat1, small e, circumflex */
  170. {"[egrave]", {'\350','\0'}, IsoString }, /*ISOlat1, small e, grave accent */
  171. {"[empty ]", {'\370','\0'}, IsoString }, /*ISOamso, empty string */
  172. {"[epsiv ]", {'\145','\0'}, SymbolString}, /*ISOgrk3, Greek,sm epsilon, var */
  173. {"[equals]", { '=' ,'\0'}, IsoString }, /*ISOnum , equals sign */
  174. {"[equiv ]", {'\272','\0'}, SymbolString}, /*ISOtech, identical with */
  175. {"[eta ]", {'\150','\0'}, SymbolString}, /*ISOgrk3, Greek, small eta */
  176. {"[eth ]", {'\360','\0'}, IsoString }, /*ISOlat1, small eth, Icelandic */
  177. {"[euml ]", {'\353','\0'}, IsoString }, /*ISOlat1, small e, umlaut mark */
  178. {"[excl ]", { '!' ,'\0'}, IsoString }, /*ISOnum , exclamation mark */
  179. {"[exist ]", {'\044','\0'}, SymbolString}, /*ISOtech, at least one exists */
  180. {"[forall]", {'\042','\0'}, SymbolString}, /*ISOtech, for all */
  181. {"[frac12]", {'\275','\0'}, IsoString }, /*ISOnum , fraction one-half */
  182. {"[frac13]", {'1','/','3','\0'},
  183. IsoString }, /*ISOnum , fraction one-third */
  184. {"[frac14]", {'\274','\0'}, IsoString }, /*ISOnum , fraction one-quarter */
  185. {"[frac15]", {'1','/','5','\0'},
  186. IsoString }, /*ISOnum , fraction one-fifth */
  187. {"[frac16]", {'1','/','6','\0'},
  188. IsoString }, /*ISOnum , fraction one-sixth */
  189. {"[frac18]", {'1','/','8','\0'},
  190. IsoString }, /*ISOnum , fraction one-eight */
  191. {"[frac23]", {'2','/','3','\0'},
  192. IsoString }, /*ISOnum , fraction two-thirds */
  193. {"[frac25]", {'2','/','5','\0'},
  194. IsoString }, /*ISOnum , fraction two-fifths */
  195. {"[frac34]", {'\276','\0'}, IsoString }, /*ISOnum , fraction three-quarter*/
  196. {"[frac35]", {'3','/','5','\0'},
  197. IsoString }, /*ISOnum , fraction three-fifths */
  198. {"[frac38]", {'3','/','8','\0'},
  199. IsoString }, /*ISOnum , fraction three-eights */
  200. {"[frac45]", {'4','/','5','\0'},
  201. IsoString }, /*ISOnum , fraction four-fifths */
  202. {"[frac56]", {'5','/','6','\0'},
  203. IsoString }, /*ISOnum , fraction five-sixths */
  204. {"[frac58]", {'5','/','8','\0'},
  205. IsoString }, /*ISOnum , fraction five-eights */
  206. {"[frac78]", {'7','/','8','\0'},
  207. IsoString }, /*ISOnum , fraction seven-eights */
  208. {"[gamma ]", {'\147','\0'}, SymbolString}, /*ISOgrk3, Greek, small gamma */
  209. {"[ge ]", {'\263','\0'}, SymbolString}, /*ISOtech, greater-than-or-equal */
  210. {"[gt ]", { '>' ,'\0'}, IsoString }, /*ISOnum , greater than sign */
  211. {"[half ]", {'\275','\0'}, IsoString }, /*ISOnum , fraction one-half */
  212. {"[harr ]", {'\253','\0'}, SymbolString}, /*ISOamsa, left & right arrow */
  213. {"[hArr ]", {'\333','\0'}, SymbolString}, /*ISOamsa, l & r double arrow */
  214. {"[hearts]", {'\251','\0'}, SymbolString}, /*ISOpub , hearts suit symbol */
  215. {"[hellip]", {'\274','\0'}, SymbolString}, /*ISOpub , ellipsis(horizontal) */
  216. {"[horbar]", {'\276','\0'}, SymbolString}, /*ISOnum , horizontal bar */
  217. {"[hyphen]", { '-' ,'\0'}, IsoString }, /*ISOnum , hyphen */
  218. {"[iacute]", {'\355','\0'}, IsoString }, /*ISOlat1, small i, acute accent */
  219. {"[icirc ]", {'\356','\0'}, IsoString }, /*ISOlat1, small i, circumflex */
  220. {"[iexcl ]", {'\241','\0'}, IsoString }, /*ISOnum , inverted ! mark */
  221. {"[igrave]", {'\354','\0'}, IsoString }, /*ISOlat1, small i, grave accent */
  222. {"[image ]", {'\301','\0'}, SymbolString}, /*ISOamso,imaginary number symbol*/
  223. {"[infin ]", {'\245','\0'}, SymbolString}, /*ISOtech, infinity */
  224. {"[int ]", {'\246','\0'}, SymbolString}, /*ISOtech, intergral operator */
  225. {"[iota ]", {'\151','\0'}, SymbolString}, /*ISOgrk3, Greek, small iota */
  226. {"[iquest]", {'\277','\0'}, IsoString }, /*ISOnum , inverted ? mark */
  227. {"[isin ]", {'\316','\0'}, SymbolString}, /*ISOtech, set membership */
  228. {"[iuml ]", {'\357','\0'}, IsoString }, /*ISOlat1, small i, umlaut mark */
  229. {"[kappa ]", {'\153','\0'}, SymbolString}, /*ISOgrk3, Greek, small kappa */
  230. {"[lambda]", {'\154','\0'}, SymbolString}, /*ISOgrk3, Greek, small lambda */
  231. {"[lang ]", {'\341','\0'}, SymbolString}, /*ISOtech, left angle bracket */
  232. {"[laquo ]", {'\253','\0'}, IsoString }, /*ISOnum , left angle quotation */
  233. {"[larr ]", {'\254','\0'}, SymbolString}, /*ISOnum , leftward arrow */
  234. {"[lArr ]", {'\334','\0'}, SymbolString}, /*ISOtech, is implied by */
  235. {"[lcub ]", { '{' ,'\0'}, IsoString }, /*ISOnum , left curly brace */
  236. {"[ldquo ]", { '"' ,'\0'}, IsoString }, /*ISOnum , left double quote */
  237. {"[le ]", {'\243','\0'}, SymbolString}, /*ISOtech, less-than-or-equal */
  238. {"[lowbar]", { '_' ,'\0'}, IsoString }, /*ISOnum , low line */
  239. {"[lpar ]", { '(' ,'\0'}, IsoString }, /*ISOnum , left parenthesis */
  240. {"[lsqb ]", { '[' ,'\0'}, IsoString }, /*ISOnum , left square bracket */
  241. {"[lsquo ]", { '`' ,'\0'}, IsoString }, /*ISOnum , left single quote */
  242. {"[lsquor]", { ',' ,'\0'}, IsoString }, /*ISOnum,rising single quote(low)*/
  243. {"[lt ]", { '<' ,'\0'}, IsoString }, /*ISOnum , less-than sign */
  244. {"[mdash ]", {'\276','\0'}, SymbolString}, /*ISOpub , em dash(long dash) */
  245. {"[micro ]", {'\155','\0'}, SymbolString}, /*ISOnum , micro */
  246. {"[middot]", {'\267','\0'}, IsoString }, /*ISOnum , middle dot */
  247. {"[minus ]", { '-' ,'\0'}, IsoString }, /*ISOtech, minus sign */
  248. {"[mldr ]", {'.','.','.','.','\0'},
  249. IsoString }, /*ISOpub , em leader */
  250. {"[mnplus]", {'\140','\b','+','\0'},
  251. SymbolString}, /*ISOtech, minus-or-plus sign */
  252. {"[mu ]", {'\155','\0'}, SymbolString}, /*ISOgrk3, Greek, small mu */
  253. {"[nabla ]", {'\321','\0'}, SymbolString}, /*ISOtech, del, Hamilton operator*/
  254. {"[nbsp ]", { ' ' ,'\0'}, IsoString }, /*ISOnum , no break space */
  255. {"[ndash ]", { '-' ,'\0'}, IsoString }, /*ISOpub , en dash(short dash) */
  256. {"[ne ]", {'\271','\0'}, SymbolString}, /*ISOtech, not equal */
  257. {"[ni ]", {'\047','\0'}, SymbolString}, /*ISOtech, contains */
  258. {"[nldr ]", {'.','.','\0'},IsoString }, /*ISOpub , double baseline dot */
  259. {"[not ]", {'\330','\0'}, SymbolString}, /*ISOnum , not */
  260. {"[notin ]", {'\317','\0'}, SymbolString}, /*ISOtech, negated set membership*/
  261. {"[ntilde]", {'\361','\0'}, IsoString }, /*ISOlat1, small N, tilde */
  262. {"[nu ]", {'\156','\0'}, SymbolString}, /*ISOgrk3, Greek, small nu */
  263. {"[num ]", { '#' ,'\0'}, IsoString }, /*ISOnum , number sign */
  264. {"[oacute]", {'\363','\0'}, IsoString }, /*ISOlat1, small o, acute accent */
  265. {"[ocirc ]", {'\364','\0'}, IsoString }, /*ISOlat1, small o, circumflex */
  266. {"[ograve]", {'\362','\0'}, IsoString }, /*ISOlat1, small o, grave accent */
  267. {"[ohm ]", {'\127','\0'}, SymbolString}, /*ISOnum , ohm */
  268. {"[omega ]", {'\167','\0'}, SymbolString}, /*ISOgrk3, Greek, small omega */
  269. {"[oplus ]", {'\305','\0'}, SymbolString}, /*ISOamsb, plus sign in circle */
  270. {"[or ]", {'\332','\0'}, SymbolString}, /*ISOtech, vee, logical or */
  271. {"[ordf ]", {'\252','\0'}, IsoString }, /*ISOnum , ordinal indicator, fem*/
  272. {"[ordm ]", {'\272','\0'}, IsoString }, /*ISOnum , ordinal indicator,male*/
  273. {"[oslash]", {'\370','\0'}, IsoString }, /*ISOlat1, small o, slash */
  274. {"[osol ]", {'\306','\0'}, SymbolString}, /*ISOamsb, slash in circle */
  275. {"[otilde]", {'\365','\0'}, IsoString }, /*ISOlat1, small o, tilde */
  276. {"[otimes]", {'\304','\0'}, SymbolString}, /*ISOamsb,multiply sign in circle*/
  277. {"[ouml ]", {'\366','\0'}, IsoString }, /*ISOlat1, small o, umlaut mark */
  278. {"[over ]", {'\140','\0'}, SymbolString}, /*made up, over symbol */
  279. {"[par ]", {'\275', '\275', '\0'},
  280. SymbolString}, /*ISOtech, parallel */
  281. {"[para ]", {'\266','\0'}, IsoString }, /*ISOnum , paragraph sign */
  282. {"[part ]", {'\266','\0'}, SymbolString}, /*ISOtech, partial differential */
  283. {"[percnt]", { '%' ,'\0'}, IsoString }, /*ISOnum , percent sign */
  284. {"[period]", { '.' ,'\0'}, IsoString }, /*ISOnum , full stop, period */
  285. {"[perp ]", {'\136','\0'}, SymbolString}, /*ISOtech, perpendicular */
  286. {"[phis ]", {'\146','\0'}, SymbolString}, /*ISOgrk3, Greek, small phi */
  287. {"[pi ]", {'\160','\0'}, SymbolString}, /*ISOgrk3, Greek, small pi */
  288. {"[piv ]", {'\166','\0'}, SymbolString}, /*ISOgrk3, Greek, small pi, var */
  289. {"[plus ]", { '+' ,'\0'}, IsoString }, /*ISOnum , plus sign */
  290. {"[plusmn]", {'\261','\0'}, SymbolString}, /*ISOnum , plus or minus sign */
  291. {"[pound ]", {'\243','\0'}, IsoString }, /*ISOnum , pound sign */
  292. {"[prime ]", {'\242','\0'}, SymbolString}, /*ISOtech, prime or minute */
  293. {"[prop ]", {'\265','\0'}, SymbolString}, /*ISOtech, proportional to */
  294. {"[psi ]", {'\171','\0'}, SymbolString}, /*ISOgrk3, Greek, small psi */
  295. {"[quest ]", { '?' ,'\0'}, IsoString }, /*ISOnum , question mark */
  296. {"[quot ]", { '\'' ,'\0'}, IsoString }, /*ISOnum , quote mark */
  297. {"[radic ]", {'\326','\0'}, SymbolString}, /*ISOtech, radical */
  298. {"[rang ]", {'\361','\0'}, SymbolString}, /*ISOtech, right angle bracket */
  299. {"[raquo ]", {'\273','\0'}, IsoString }, /*ISOnum , right angle quotation */
  300. {"[rarr ]", {'\256','\0'}, SymbolString}, /*ISOnum , rightward arrow */
  301. {"[rArr ]", {'\336','\0'}, SymbolString}, /*ISOtech, rt dbl arrow,implies */
  302. {"[rcub ]", { '}' ,'\0'}, IsoString }, /*ISOnum , right curly brace */
  303. {"[rdquo ]", { '"' ,'\0'}, IsoString }, /*ISOnum , right double quote */
  304. {"[real ]", {'\302','\0'}, SymbolString}, /*ISOamso, real number symbol */
  305. {"[reg ]", {'\322','\0'}, SymbolString}, /*ISOnum,circledR,registered sign*/
  306. {"[rho ]", {'\162','\0'}, SymbolString}, /*ISOgrk3, Greek, small rho */
  307. {"[rpar ]", { ')' ,'\0'}, IsoString }, /*ISOnum , right parenthesis */
  308. {"[rsqb ]", { ']' ,'\0'}, IsoString }, /*ISOnum , right square bracket */
  309. {"[rsquo ]", { '\'' ,'\0'}, IsoString }, /*ISOnum , right single quote */
  310. {"[sect ]", {'\247','\0'}, IsoString }, /*ISOnum , section sign */
  311. {"[semi ]", { ';' ,'\0'}, IsoString }, /*ISOnum , semicolon */
  312. {"[shy ]", {'\255','\0'}, IsoString }, /*ISOnum , soft hypen */
  313. {"[sigma ]", {'\163','\0'}, SymbolString}, /*ISOgrk3, Greek, small sigma */
  314. {"[sim ]", { '~' ,'\0'}, IsoString }, /*ISOtech, similar to */
  315. {"[sime ]", {'\100','\0'}, SymbolString}, /*ISOtech, similar, equals */
  316. {"[sol ]", { '/' ,'\0'}, IsoString }, /*ISOnum , solidus */
  317. {"[spades]", {'\252','\0'}, SymbolString}, /*ISOpub , spades suit symbol */
  318. {"[sub ]", {'\314','\0'}, SymbolString}, /*ISOtech, subset/is implied by */
  319. {"[sube ]", {'\315','\0'}, SymbolString}, /*ISOtech, subset, equals */
  320. /*"[sung ]", { ?? ,'\0'}, }, *ISOnum , musical note(sung txt)*/
  321. {"[sup ]", {'\311','\0'}, SymbolString}, /*ISOtech, superset or implies */
  322. {"[sup1 ]", {'\271','\0'}, IsoString }, /*ISOnum , superscript one */
  323. {"[sup2 ]", {'\262','\0'}, IsoString }, /*ISOnum , superscript two */
  324. {"[sup3 ]", {'\263','\0'}, IsoString }, /*ISOnum , superscript three */
  325. {"[supe ]", {'\312','\0'}, SymbolString}, /*ISOtech, superset, equals */
  326. {"[szlig ]", {'\337','\0'}, IsoString }, /*ISOlat1, small sharp s, German */
  327. {"[tau ]", {'\164','\0'}, SymbolString}, /*ISOgrk3, Greek, small tau */
  328. {"[there4]", {'\134','\0'}, SymbolString}, /*ISOtech, therefore */
  329. {"[thetas]", {'\161','\0'}, SymbolString}, /*ISOgrk3, Greek, small theta */
  330. {"[thetav]", {'\112','\0'}, SymbolString}, /*ISOgrk3, Greek, small theta,var*/
  331. {"[times ]", {'\264','\0'}, SymbolString}, /*ISOnum , multipy sign */
  332. {"[thorn ]", {'\376','\0'}, IsoString }, /*ISOlat1, small thorn, Icelandic*/
  333. {"[tprime]", {'\242', '\242', '\242', '\0'},
  334. SymbolString}, /*ISOtech, triple prime */
  335. {"[trade ]", {'\324','\0'}, SymbolString}, /*ISOnum , trade mark sign */
  336. {"[uarr ]", {'\255','\0'}, SymbolString}, /*ISOnum , upward arrow */
  337. {"[uArr ]", {'\335','\0'}, SymbolString}, /*ISOamsa, up double arrow */
  338. {"[uacute]", {'\372','\0'}, IsoString }, /*ISOlat1, small u, acute accent */
  339. {"[ucirc ]", {'\373','\0'}, IsoString }, /*ISOlat1, small u, circumflex */
  340. {"[ugrave]", {'\371','\0'}, IsoString }, /*ISOlat1, small u, grave accent */
  341. {"[upsi ]", {'\165','\0'}, SymbolString}, /*ISOgrk3, Greek, small upsilon */
  342. {"[uuml ]", {'\374','\0'}, IsoString }, /*ISOlat1, small u, umlaut mark */
  343. {"[vellip]", {':','\n',':','\0'},
  344. SymbolString}, /*ISOpub , vertical ellipsis */
  345. {"[verbar]", {'\174','\0'}, IsoString }, /*ISOnum , vertical bar */
  346. {"[weierp]", {'\303','\0'}, SymbolString}, /*ISOamso, Weierstrass p */
  347. {"[xi ]", {'\170','\0'}, SymbolString}, /*ISOgrk3, Greek, small xi */
  348. {"[yacute]", {'\375','\0'}, IsoString }, /*ISOlat1, small y, acute accent */
  349. {"[yen ]", {'\245','\0'}, IsoString }, /*ISOnum , yen sign */
  350. {"[yuml ]", {'\377','\0'}, IsoString }, /*ISOlat1, small y, umlaut mark */
  351. {"[zeta ]", {'\172','\0'}, SymbolString}, /*ISOgrk3, Greek, small zeta */
  352. {"[Aacute]", {'\301','\0'}, IsoString }, /*ISOlat1, capital a,acute accent*/
  353. {"[Acirc ]", {'\302','\0'}, IsoString }, /*ISOlat1, capital a,circumflex */
  354. {"[AElig ]", {'\306','\0'}, IsoString }, /*ISOlat1, capital ae diphthong */
  355. {"[Agrave]", {'\300','\0'}, IsoString }, /*ISOlat1, capital a,grave accent*/
  356. {"[Aring ]", {'\305','\0'}, IsoString }, /*ISOlat1, capital a,ring */
  357. {"[Atilde]", {'\303','\0'}, IsoString }, /*ISOlat1, capital a,tilde */
  358. {"[Auml ]", {'\304','\0'}, IsoString }, /*ISOlat1, capital a,umlaut mark */
  359. {"[Ccedil]", {'\307','\0'}, IsoString }, /*ISOlat1, capital c, cedilla */
  360. {"[Delta ]", {'\104','\0'}, SymbolString}, /*ISOgrk3, Greek, large delta */
  361. {"[Dot ]", {'\250','\0'}, IsoString }, /*ISOtech, dieresis or umlaut mrk*/
  362. {"[DotDot]", {'\250', '\250', '\0'},
  363. IsoString }, /*ISOtech, four dots above */
  364. {"[Eacute]", {'\311','\0'}, IsoString }, /*ISOlat1, capital E,acute accent*/
  365. {"[Ecirc ]", {'\312','\0'}, IsoString }, /*ISOlat1, capital E,circumflex */
  366. {"[Egrave]", {'\310','\0'}, IsoString }, /*ISOlat1, capital E,grave accent*/
  367. {"[ETH ]", {'\320','\0'}, IsoString }, /*ISOlat1, capital Eth, Icelandic*/
  368. {"[Euml ]", {'\313','\0'}, IsoString }, /*ISOlat1, capital E,umlaut mark */
  369. {"[Gamma ]", {'\107','\0'}, SymbolString}, /*ISOgrk3, Greek, large gamma */
  370. {"[Iacute]", {'\315','\0'}, IsoString }, /*ISOlat1, capital I,acute accent*/
  371. {"[Icirc ]", {'\316','\0'}, IsoString }, /*ISOlat1, capital I,circumflex */
  372. {"[Igrave]", {'\314','\0'}, IsoString }, /*ISOlat1, capital I,grave accent*/
  373. {"[Iuml ]", {'\317','\0'}, IsoString }, /*ISOlat1, capital I,umlaut mark */
  374. {"[Lambda]", {'\114','\0'}, SymbolString}, /*ISOgrk3, Greek, large lambda */
  375. {"[Ntilde]", {'\321','\0'}, IsoString }, /*ISOlat1, capital N, tilde */
  376. {"[Oacute]", {'\323','\0'}, IsoString }, /*ISOlat1, capital O,acute accent*/
  377. {"[Ocirc ]", {'\324','\0'}, IsoString }, /*ISOlat1, capital O,circumflex */
  378. {"[Ograve]", {'\322','\0'}, IsoString }, /*ISOlat1, capital O,grave accent*/
  379. {"[Oslash]", {'\330','\0'}, IsoString }, /*ISOlat1, capital O, slash */
  380. {"[Otilde]", {'\325','\0'}, IsoString }, /*ISOlat1, capital O, tilde */
  381. {"[Omega ]", {'\127','\0'}, SymbolString}, /*ISOgrk3, Greek, large omega */
  382. {"[Ouml ]", {'\326','\0'}, IsoString }, /*ISOlat1, capital O,umlaut mark */
  383. {"[Pi ]", {'\120','\0'}, SymbolString}, /*ISOgrk3, Greek, large pi */
  384. {"[Prime ]", {'\262','\0'}, SymbolString}, /*ISOtech, double prime/second */
  385. {"[Phi ]", {'\106','\0'}, SymbolString}, /*ISOgrk3, Greek, large phi */
  386. {"[Psi ]", {'\131','\0'}, SymbolString}, /*ISOgrk3, Greek, large psi */
  387. {"[Sigma ]", {'\123','\0'}, SymbolString}, /*ISOgrk3, Greek, large sigma */
  388. {"[THORN ]", {'\336','\0'}, IsoString }, /*ISOlat1,capital THORN,Icelandic*/
  389. {"[Theta ]", {'\121','\0'}, SymbolString}, /*ISOgrk3, Greek, large theta */
  390. {"[Uacute]", {'\332','\0'}, IsoString }, /*ISOlat1, capital U,acute accent*/
  391. {"[Ucirc ]", {'\333','\0'}, IsoString }, /*ISOlat1, capital U,circumflex */
  392. {"[Ugrave]", {'\331','\0'}, IsoString }, /*ISOlat1, capital U,grave accent*/
  393. {"[Upsi ]", {'\125','\0'}, SymbolString}, /*ISOgrk3, Greek, large upsilon */
  394. {"[Uuml ]", {'\334','\0'}, IsoString }, /*ISOlat1, capital U,umlaut mark */
  395. {"[Verbar]", {'\174', '\174', '\0'},
  396. IsoString }, /*ISOtech, dbl vertical bar */
  397. {"[Xi ]", {'\130','\0'}, SymbolString}, /*ISOgrk3, Greek, large xi */
  398. {"[Yacute]", {'\335','\0'}, IsoString }, /*ISOlat1, capital Y,acute accent*/
  399. { NULL , {' ' ,'\0'}, IsoString }, /* default character to use */
  400. };
  401. /*****************************************************************************
  402. * Semi-Private Variables
  403. *****************************************************************************/
  404. /*****************************************************************************
  405. * Private Functions
  406. *****************************************************************************/
  407. /*****************************************************************************
  408. * Function: _DtCvUnit GetTocIndicator(pDAS);
  409. *
  410. * Parameters:
  411. *
  412. * Returns:
  413. *
  414. * Purpose:
  415. *
  416. *****************************************************************************/
  417. static _DtHelpFontHints DefFontAttrs = {
  418. NULL, NULL,
  419. 10, 10, NULL,
  420. NULL, NULL, NULL, NULL,
  421. NULL, NULL, NULL, NULL,
  422. _DtHelpFontStyleSerif,
  423. _DtHelpFontSpacingProp,
  424. _DtHelpFontWeightMedium,
  425. _DtHelpFontSlantRoman,
  426. _DtHelpFontSpecialNone };
  427. static void
  428. GetTocIndicator (
  429. DtHelpDispAreaStruct *pDAS)
  430. {
  431. _DtCvUnit ascent;
  432. pDAS->toc_width = 0;
  433. pDAS->toc_height = 0;
  434. pDAS->toc_indicator = NULL;
  435. if (_DtHelpDAResolveSpc (pDAS, "C", IsoString, DefFontAttrs, "[rArr ]",
  436. &(pDAS->toc_indicator), &(pDAS->toc_width),
  437. &(pDAS->toc_height), &ascent))
  438. _DtHelpDAResolveSpc (pDAS, "C", IsoString, DefFontAttrs, "[ndash ]",
  439. &(pDAS->toc_indicator), &(pDAS->toc_width),
  440. &(pDAS->toc_height), &ascent);
  441. }
  442. static void
  443. ClearTocMarker (
  444. DtHelpDispAreaStruct *pDAS,
  445. _DtCvFlags flag)
  446. {
  447. _DtCvUnit clearHeight;
  448. _DtCvUnit clearWidth;
  449. _DtCvUnit clearY = pDAS->toc_y + pDAS->decorThickness
  450. - pDAS->firstVisible;
  451. _DtCvUnit clearX = pDAS->decorThickness - pDAS->virtualX;
  452. clearHeight = pDAS->toc_height;
  453. clearWidth = pDAS->toc_width;
  454. if (clearY < pDAS->decorThickness)
  455. {
  456. clearHeight = clearHeight - pDAS->decorThickness + clearY;
  457. clearY = pDAS->decorThickness;
  458. }
  459. if (clearX < pDAS->decorThickness)
  460. {
  461. clearWidth = clearWidth - pDAS->decorThickness + clearX;
  462. clearX = pDAS->decorThickness;
  463. }
  464. if (clearWidth > 0 && clearHeight > 0)
  465. {
  466. if (IsSelected(flag))
  467. XFillRectangle (XtDisplay(pDAS->dispWid), XtWindow(pDAS->dispWid),
  468. pDAS->invertGC,
  469. clearX, clearY, clearWidth, clearHeight);
  470. else
  471. XClearArea(XtDisplay(pDAS->dispWid), XtWindow(pDAS->dispWid),
  472. clearX, clearY, clearWidth, clearHeight, False);
  473. }
  474. }
  475. /*****************************************************************************
  476. * Function: void DrawTocIndicator ();
  477. *
  478. * Parameters:
  479. *
  480. * Returns:
  481. *
  482. * Purpose:
  483. *
  484. *****************************************************************************/
  485. static void
  486. DrawTocIndicator (
  487. DtHelpDispAreaStruct *pDAS,
  488. _DtCvFlags flag)
  489. {
  490. if (XtIsRealized(pDAS->dispWid)
  491. && TocIsOn(pDAS->toc_flag)
  492. && ((int)(pDAS->toc_y+pDAS->toc_height)) >= ((int) pDAS->firstVisible)
  493. && ((int)pDAS->toc_y) < ((int)(pDAS->firstVisible+pDAS->dispUseHeight))
  494. && pDAS->toc_indicator)
  495. {
  496. _DtHelpDARegion *regInfo = (_DtHelpDARegion *) pDAS->toc_indicator;
  497. DADrawSpc (((_DtCvPointer) pDAS), regInfo->handle,
  498. 0, pDAS->toc_base,
  499. 0, pDAS->toc_y,
  500. pDAS->toc_height, 0, 0, 0);
  501. }
  502. }
  503. /*****************************************************************************
  504. * Function: void DrawTraversal ();
  505. *
  506. * Parameters:
  507. * pDAS Specifies the display area.
  508. * dst_x Specifies the inside boundary of the segment.
  509. * This is where the segment starts, so the
  510. * traversal box must end at dst_x - 1.
  511. * dst_y Specifies the upper pixel that the traversal
  512. * will cover.
  513. * width Specifies the inner width of the traversal box.
  514. * height Specifies the outer height of the traversal box
  515. * including the leading. But since the leading is
  516. * also used for the bottom traversal line, its
  517. * okay.
  518. * flag Specifies whether to turn the traversal box on
  519. * or off.
  520. *
  521. * Returns: Nothing.
  522. *
  523. * Purpose: Draw the traversal box.
  524. *
  525. *****************************************************************************/
  526. static void
  527. DrawTraversal (
  528. DtHelpDispAreaStruct *pDAS,
  529. _DtCvUnit dst_x,
  530. _DtCvUnit dst_y,
  531. _DtCvUnit width,
  532. _DtCvUnit height,
  533. _DtCvFlags flag)
  534. {
  535. int copyY1;
  536. int copyY2;
  537. int lineX1;
  538. int lineY1;
  539. int lineX2;
  540. int lineY2;
  541. int onLeftTop;
  542. int onRightBot;
  543. Display *dpy = XtDisplay(pDAS->dispWid);
  544. Window win = XtWindow(pDAS->dispWid);
  545. if (pDAS->neededFlags & _DT_HELP_FOCUS_FLAG)
  546. {
  547. XGCValues saved, gc_values;
  548. /*
  549. * SYSTEM
  550. * see the SYSTEM note in XUICreate.c
  551. */
  552. /*
  553. * how many pixels will be above or to the left of the
  554. * destination position.
  555. */
  556. onLeftTop = pDAS->lineThickness / 2;
  557. /*
  558. * how many pixels will be on and inside the destination.
  559. */
  560. onRightBot = pDAS->lineThickness - onLeftTop;
  561. /*
  562. * calculate the y position of the traversal lines
  563. * for the top and bottom lines.
  564. */
  565. lineY1 = dst_y + onLeftTop;
  566. lineY2 = dst_y + height - onRightBot;
  567. /*
  568. * get the extreme y positions.
  569. */
  570. copyY1 = dst_y;
  571. copyY2 = dst_y + height;
  572. /*
  573. * adjust the source and destination positions.
  574. */
  575. lineX1 = dst_x;
  576. if (IsTraversalBegin (flag))
  577. lineX1 = lineX1 - onRightBot;
  578. lineX2 = dst_x + width;
  579. if (IsTraversalEnd (flag))
  580. lineX2 = lineX2 + onLeftTop;
  581. XGetGCValues(dpy, pDAS->normalGC, GCLineStyle | GCForeground, &saved);
  582. gc_values.line_style = saved.line_style;
  583. if (HasTraversal(flag)) {
  584. if (flag & _DtCvAPP_FLAG2) {
  585. XSetForeground (dpy, pDAS->normalGC, pDAS->searchColor);
  586. gc_values.line_style = LineOnOffDash;
  587. }
  588. else
  589. XSetForeground (dpy, pDAS->normalGC, pDAS->traversalColor);
  590. }
  591. else
  592. XSetForeground (dpy, pDAS->normalGC, pDAS->backgroundColor);
  593. if (gc_values.line_style != saved.line_style)
  594. XChangeGC(dpy, pDAS->normalGC, GCLineStyle, &gc_values);
  595. /*
  596. * draw the top and bottom lines
  597. */
  598. if (lineX1 - onLeftTop < ((int) pDAS->dispWidth) &&
  599. lineX2 + onRightBot - 1 > 0)
  600. {
  601. /*
  602. * draw the top line
  603. */
  604. if (copyY1 < ((int) pDAS->dispHeight) &&
  605. copyY1 + ((int)pDAS->lineThickness) >
  606. ((int)pDAS->decorThickness))
  607. XDrawLine(dpy,win,pDAS->normalGC,lineX1,lineY1,lineX2,lineY1);
  608. /*
  609. * draw the bottom line
  610. */
  611. if (copyY2 - ((int)pDAS->lineThickness) < ((int)pDAS->dispHeight)
  612. && copyY2 > ((int)pDAS->decorThickness))
  613. XDrawLine(dpy,win,pDAS->normalGC,lineX1,lineY2,lineX2,lineY2);
  614. }
  615. /*
  616. * draw the left end
  617. */
  618. if (IsTraversalBegin(flag)
  619. && lineX1 - onLeftTop < ((int)pDAS->dispWidth)
  620. && lineX1 + onRightBot - 1 > 0
  621. && copyY1 < ((int) pDAS->dispHeight)
  622. && copyY2 > ((int)pDAS->decorThickness))
  623. XDrawLine(dpy, win, pDAS->normalGC, lineX1, copyY1, lineX1, copyY2);
  624. /*
  625. * draw the right end
  626. */
  627. if (IsTraversalEnd(flag)
  628. && lineX2 - onLeftTop < ((int) pDAS->dispWidth)
  629. && lineX2 + onRightBot - 1 > 0
  630. && copyY1 < ((int) pDAS->dispHeight)
  631. && copyY2 > ((int) pDAS->decorThickness))
  632. XDrawLine(dpy, win, pDAS->normalGC, lineX2, copyY1, lineX2, copyY2);
  633. XSetForeground (dpy, pDAS->normalGC, saved.foreground);
  634. XSetFillStyle(dpy, pDAS->normalGC, FillSolid);
  635. if (gc_values.line_style != saved.line_style)
  636. XChangeGC(dpy, pDAS->normalGC, GCLineStyle, &saved);
  637. }
  638. }
  639. static void
  640. DrawSearchTraversal(DtHelpDispAreaStruct* pDAS,
  641. _DtCvUnit dst_x, _DtCvUnit dst_y,
  642. _DtCvUnit width, _DtCvUnit height, _DtCvFlags flag)
  643. {
  644. short save = pDAS->neededFlags;
  645. pDAS->neededFlags |= _DT_HELP_FOCUS_FLAG;
  646. DrawTraversal(pDAS, dst_x, dst_y, width, height, flag);
  647. pDAS->neededFlags = save;
  648. }
  649. /*****************************************************************************
  650. * Function: void MyDrawString (Display *dpy, Drawable d, GC gc,
  651. * int font_index,
  652. * int x, int y, char *string, int length,
  653. * int wc, DtHelpDAFontInfo font_info)
  654. *
  655. * Parameters:
  656. * dpy Specifies the connection to the X Server.
  657. * d Specifies the drawable.
  658. * gc Specifies the graphic's context.
  659. * font_index Specifies the font structure or set to use.
  660. * If the value is positive, it indicates a
  661. * font structure. If negative, it indicates
  662. * a font set.
  663. * x Specifies the x coordinate.
  664. * y Specifies the y coordinate.
  665. * string Specifies the string to render.
  666. * length Specifies the number of bytes in 'string'
  667. * to render.
  668. * wc Flag to designate wide character data
  669. *
  670. * Return Value: Nothing
  671. *
  672. * Purpose: Renders an text string to the specified drawable.
  673. *
  674. *****************************************************************************/
  675. static void
  676. MyDrawString (
  677. Display *dpy,
  678. Drawable d,
  679. GC gc,
  680. long font_index,
  681. long x,
  682. long y,
  683. const void *string,
  684. int length,
  685. int wc,
  686. int image,
  687. DtHelpDAFontInfo font_info)
  688. {
  689. /*
  690. * If the 'font_index' is a negative number, it indicates a font set was
  691. * opened for this string. Use the X11R5 I18N routines to render the
  692. * glyphs. Otherwise use the standard X11 drawing routines.
  693. */
  694. if (font_index < 0)
  695. {
  696. XFontSet mySet;
  697. mySet = __DtHelpFontSetGet(font_info, font_index);
  698. if (wc) {
  699. if (image)
  700. XwcDrawImageString(dpy, d, mySet, gc, x, y,
  701. (wchar_t*)string, length);
  702. else
  703. XwcDrawString (dpy, d, mySet, gc, x, y,
  704. (wchar_t*)string, length);
  705. }
  706. else {
  707. /*
  708. * have to use XmbDrawString here instead of XDrawString
  709. * because we need to use a font set to render the string.
  710. */
  711. if (image)
  712. XmbDrawImageString (dpy, d, mySet, gc, x, y, string, length);
  713. else
  714. XmbDrawString (dpy, d, mySet, gc, x, y, string, length);
  715. }
  716. }
  717. else
  718. {
  719. XFontStruct *myFont;
  720. myFont = __DtHelpFontStructGet(font_info, font_index);
  721. XSetFont (dpy, gc, myFont->fid);
  722. if (image)
  723. XDrawImageString (dpy, d, gc, x, y, string, length);
  724. else
  725. XDrawString (dpy, d, gc, x, y, string, length);
  726. }
  727. }
  728. /*****************************************************************************
  729. * Function: void ResolveFont ();
  730. *
  731. * Parameters:
  732. *
  733. * Returns:
  734. *
  735. * Purpose:
  736. *
  737. *****************************************************************************/
  738. static int
  739. ResolveFont (
  740. _DtCvPointer client_data,
  741. char *lang,
  742. const char *charset,
  743. _DtHelpFontHints font_attr,
  744. long *ret_idx )
  745. {
  746. int result = -1;
  747. char *xlfdSpec = font_attr.xlfd;
  748. char buffer[10];
  749. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  750. XrmName xrmList[_DtHelpFontQuarkNumber];
  751. _DtHelpCopyDefaultList(xrmList);
  752. if (font_attr.spacing != _DtHelpFontSpacingProp)
  753. xrmList[_DT_HELP_FONT_SPACING] = XrmStringToQuark("m");
  754. sprintf(buffer, "%d", font_attr.pointsz);
  755. xrmList[_DT_HELP_FONT_SIZE] = XrmStringToQuark(buffer);
  756. if (font_attr.slant != _DtHelpFontSlantRoman)
  757. {
  758. xrmList[_DT_HELP_FONT_ANGLE] = XrmStringToQuark("italic");
  759. if (font_attr.xlfdi != NULL)
  760. xlfdSpec = font_attr.xlfdi;
  761. }
  762. if (font_attr.weight == _DtHelpFontWeightBold)
  763. {
  764. xrmList[_DT_HELP_FONT_WEIGHT] = XrmStringToQuark("bold");
  765. if (xrmList[_DT_HELP_FONT_ANGLE] == XrmStringToQuark("italic"))
  766. {
  767. if (font_attr.xlfdib != NULL)
  768. xlfdSpec = font_attr.xlfdib;
  769. }
  770. else if (font_attr.xlfdb != NULL)
  771. xlfdSpec = font_attr.xlfdb;
  772. }
  773. if (font_attr.style == _DtHelpFontStyleSerif)
  774. xrmList[_DT_HELP_FONT_TYPE] = XrmStringToQuark("serif");
  775. else if (font_attr.style == _DtHelpFontStyleSymbol)
  776. xrmList[_DT_HELP_FONT_TYPE] = XrmStringToQuark("symbol");
  777. xrmList[_DT_HELP_FONT_LANG_TER] = XrmStringToQuark ("C");
  778. if (lang != NULL)
  779. xrmList[_DT_HELP_FONT_LANG_TER] = XrmStringToQuark(lang);
  780. if (charset != NULL)
  781. xrmList[_DT_HELP_FONT_CHAR_SET] = XrmStringToQuark(charset);
  782. if (NULL != xlfdSpec)
  783. result = _DtHelpGetExactFontIndex(pDAS,lang,charset,xlfdSpec,ret_idx);
  784. if (result)
  785. result = __DtHelpFontIndexGet (pDAS, xrmList, ret_idx);
  786. if (result) {
  787. _DtHelpCopyCasualList(xrmList);
  788. result = __DtHelpFontIndexGet(pDAS, xrmList, ret_idx);
  789. }
  790. return result;
  791. }
  792. /*****************************************************************************
  793. * Function: void DADrawLine ();
  794. *
  795. * Parameters:
  796. *
  797. * Returns:
  798. *
  799. * Purpose:
  800. *
  801. *****************************************************************************/
  802. static void
  803. DADrawLine (
  804. _DtCvPointer client_data,
  805. _DtCvUnit x1,
  806. _DtCvUnit y1,
  807. _DtCvUnit x2,
  808. _DtCvUnit y2,
  809. _DtCvUnit line_width)
  810. {
  811. int offset;
  812. Display *dpy;
  813. Window win;
  814. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  815. XGCValues saved, gcValues;
  816. gcValues.line_width = line_width;
  817. offset = line_width / 2;
  818. dpy = XtDisplay(pDAS->dispWid);
  819. win = XtWindow(pDAS->dispWid);
  820. /*
  821. * get the current value of the gc.
  822. */
  823. XGetGCValues(dpy, pDAS->normalGC, GCLineWidth, &saved);
  824. /*
  825. * does the old line width equal the width we want?
  826. * If no, then change it to the desired width.
  827. */
  828. if (line_width != saved.line_width)
  829. XChangeGC(dpy, pDAS->normalGC, GCLineWidth, &gcValues);
  830. /*
  831. * drawing a horizontal line?
  832. */
  833. if (x1 == x2)
  834. {
  835. x1 += offset;
  836. x2 = x1;
  837. }
  838. else
  839. {
  840. y1 += offset;
  841. y2 = y1;
  842. }
  843. y1 = y1 + pDAS->decorThickness - pDAS->firstVisible;
  844. x1 = x1 + pDAS->decorThickness - pDAS->virtualX;
  845. y2 = y2 + pDAS->decorThickness - pDAS->firstVisible;
  846. x2 = x2 + pDAS->decorThickness - pDAS->virtualX;
  847. XDrawLine (dpy, win, pDAS->normalGC, x1, y1, x2, y2);
  848. /*
  849. * did we change the gc's line_width? If so, change it back.
  850. */
  851. if (line_width != saved.line_width)
  852. XChangeGC(dpy, pDAS->normalGC, GCLineWidth, &saved);
  853. }
  854. /*****************************************************************************
  855. * Function: void DADrawString ();
  856. *
  857. * Parameters:
  858. * client_data Specifies the client specific data
  859. * associated with this canvas.
  860. * x Specifies the x unit at which the
  861. * string is to be rendered.
  862. * y Specifes the y unit at which the baseline
  863. * of the string is to be rendered.
  864. * string Specifies the string to render.
  865. * byte_len Specifies the number of bytes of the
  866. * string to render.
  867. * char_len Specifies the number of bytes that
  868. * comprise one character.
  869. * font_ptr Specifies the font associated with this
  870. * string.
  871. * box_x,box_y Specifies the upper left hand corner of
  872. * the bounding box for this string. This
  873. * includes any traversal and/or link offsets
  874. * relevant for the line this segment occupies.
  875. * box_height Specifies the maximum height of the bounding
  876. * box for this string. This includes any
  877. * traversal and/or offsets relevant to this
  878. * line.
  879. * old_flags Specifies .............
  880. * new_flags Specifies .............
  881. *
  882. * Returns: Nothing
  883. *
  884. * Purpose:
  885. *
  886. *****************************************************************************/
  887. static void
  888. DADrawString (
  889. _DtCvPointer client_data,
  890. _DtCvPointer data,
  891. _DtCvUnit x,
  892. _DtCvUnit y,
  893. const void *string,
  894. int byte_len,
  895. int wc,
  896. _DtCvPointer font_ptr,
  897. _DtCvPointer scd,
  898. _DtCvUnit box_x,
  899. _DtCvUnit box_y,
  900. _DtCvUnit box_height,
  901. _DtCvFlags old_flags,
  902. _DtCvFlags new_flags )
  903. {
  904. Boolean image_flag = False;
  905. int strWidth = 0;
  906. int width;
  907. Display *dpy;
  908. Window win;
  909. GC drawGC;
  910. GC fillGC;
  911. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  912. _DtCvStringClientData* pSCD = (_DtCvStringClientData*)scd;
  913. unsigned long mask1 = 0x00; /* to be replaced with highlight attrs */
  914. unsigned long mask2 = 0x00; /* to be replaced with stippling attrs */
  915. XGCValues gcValues;
  916. XGCValues saved1, saved2;
  917. /*
  918. * if this is outside our display area, ignore it.
  919. */
  920. if (box_y + box_height < pDAS->firstVisible ||
  921. box_y > pDAS->firstVisible + pDAS->dispHeight)
  922. return;
  923. y = y + pDAS->decorThickness - pDAS->firstVisible;
  924. x = x + pDAS->decorThickness - pDAS->virtualX;
  925. box_x = box_x + pDAS->decorThickness - pDAS->virtualX;
  926. box_y = box_y + pDAS->decorThickness - pDAS->firstVisible;
  927. if (byte_len)
  928. strWidth = _DtHelpDAGetStrWidth(client_data, _DtCvSTRING_TYPE, data);
  929. width = strWidth + (x - box_x);
  930. dpy = XtDisplay(pDAS->dispWid);
  931. win = XtWindow(pDAS->dispWid);
  932. /*
  933. * initial colors for rendering.
  934. */
  935. drawGC = pDAS->normalGC;
  936. fillGC = pDAS->invertGC;
  937. /*
  938. * is this a search hit or does this string have its own color?
  939. */
  940. if (strWidth && pDAS->dtinfo &&
  941. ((new_flags & _DtCvSEARCH_FLAG) ||
  942. (NULL != pSCD && (pSCD->fg_color || pSCD->bg_color))))
  943. {
  944. XColor screen, exact;
  945. /*
  946. * indicate that we are going to change the foreground and background.
  947. */
  948. mask1 = (GCForeground | GCBackground);
  949. mask2 = (GCForeground | GCBackground);
  950. /*
  951. * remember the current values of the gc.
  952. */
  953. XGetGCValues(dpy, drawGC, mask1, &saved1);
  954. XGetGCValues(dpy, fillGC, mask2, &saved2);
  955. /* search highlight should precede stylesheet-driven highlights */
  956. /*
  957. * is the search flag set? Set the foreground to the search color.
  958. */
  959. if (new_flags & _DtCvSEARCH_FLAG)
  960. {
  961. XSetForeground(dpy, drawGC, pDAS->searchColor);
  962. XSetBackground(dpy, fillGC, pDAS->searchColor);
  963. }
  964. /*
  965. * is there a foreground color specified?
  966. */
  967. else if (pSCD->fg_color)
  968. {
  969. /*
  970. * does the foreground color need allocating?
  971. */
  972. if (pSCD->fg_pixel == (unsigned long)-1)
  973. {
  974. if (XAllocNamedColor(dpy, pDAS->colormap, pSCD->fg_color,
  975. &screen, &exact))
  976. {
  977. XSetForeground(dpy, drawGC, screen.pixel);
  978. XSetBackground(dpy, fillGC, screen.pixel);
  979. }
  980. else /* the allocation went badly */
  981. {
  982. mask1 &= ~GCForeground;
  983. mask2 &= ~GCBackground;
  984. }
  985. }
  986. else /* dtinfo has calculated pSCD->fg_pixel */
  987. {
  988. XSetForeground(dpy, drawGC, pSCD->fg_pixel);
  989. XSetBackground(dpy, fillGC, pSCD->fg_pixel);
  990. }
  991. }
  992. else /* no foreground color specified */
  993. {
  994. mask1 &= ~GCForeground;
  995. mask2 &= ~GCBackground;
  996. }
  997. /*
  998. * was a background color specified?
  999. */
  1000. if (pSCD->bg_color)
  1001. {
  1002. /*
  1003. * does the background color need allocating?
  1004. */
  1005. if (pSCD->bg_pixel == (unsigned long)-1)
  1006. {
  1007. if (XAllocNamedColor(dpy, pDAS->colormap, pSCD->bg_color,
  1008. &screen, &exact))
  1009. {
  1010. XSetBackground(dpy, drawGC, screen.pixel);
  1011. XSetForeground(dpy, fillGC, screen.pixel);
  1012. }
  1013. else /* the allocation went badly */
  1014. {
  1015. mask1 &= ~GCBackground;
  1016. mask2 &= ~GCForeground;
  1017. }
  1018. }
  1019. else /* the background color's been allocated */
  1020. {
  1021. XSetBackground(dpy, drawGC, pSCD->bg_pixel);
  1022. XSetForeground(dpy, fillGC, pSCD->bg_pixel);
  1023. }
  1024. }
  1025. else /* no background color specified */
  1026. {
  1027. mask1 &= ~GCBackground;
  1028. mask2 &= ~GCForeground;
  1029. }
  1030. }
  1031. /*
  1032. * if selected, reverse the foreground and background colors
  1033. */
  1034. if (IsSelected(new_flags))
  1035. {
  1036. unsigned long tmpMsk;
  1037. GC tmpGC;
  1038. /*
  1039. * swap the gc's
  1040. */
  1041. tmpGC = drawGC;
  1042. drawGC = fillGC;
  1043. fillGC = tmpGC;
  1044. /*
  1045. * swap the saved values!
  1046. */
  1047. if (mask1 || mask2)
  1048. {
  1049. /*
  1050. * swap the masks!
  1051. */
  1052. tmpMsk = mask1;
  1053. mask1 = mask2;
  1054. mask2 = tmpMsk;
  1055. /*
  1056. * swap the saved values
  1057. */
  1058. gcValues = saved1;
  1059. saved1 = saved2;
  1060. saved2 = gcValues;
  1061. }
  1062. }
  1063. /*
  1064. * if the segment had the hypertext/mark traversal, turn it off
  1065. * this has the added benefit of also turning of the search hit
  1066. * traversal.
  1067. */
  1068. if (HasTraversal(old_flags))
  1069. DrawTraversal (pDAS, x, box_y, strWidth, box_height,
  1070. (old_flags & (~_DtCvTRAVERSAL_FLAG)));
  1071. /*
  1072. * band-aid for Search traversal support (since it isn't there).
  1073. * simply draw a negative search traversal (if the link traversal
  1074. * hasn't already blanked it out) for *every* search hit because
  1075. * it may have had the current search flag and now doesn't.
  1076. */
  1077. else if (pDAS->dtinfo && (new_flags & _DtCvSEARCH_FLAG))
  1078. DrawSearchTraversal(pDAS, x, box_y, strWidth, box_height,
  1079. (new_flags & (~_DtCvTRAVERSAL_FLAG)) |
  1080. _DtCvTRAVERSAL_BEGIN | _DtCvTRAVERSAL_END);
  1081. /*
  1082. * if the item was selected or is selected, we need to draw the
  1083. * inverse video rectangle.
  1084. */
  1085. if (IsSelected(new_flags) || IsSelected(old_flags)
  1086. || IsMarkOn(new_flags) || IsMarkOn(old_flags))
  1087. image_flag = True;
  1088. /*
  1089. * do we need to allocate the stipple pattern?
  1090. */
  1091. if (IsMarkOn(new_flags) && None == pDAS->stipple)
  1092. pDAS->stipple = XCreateBitmapFromData(dpy, win, root_weave_bits,
  1093. root_weave_width, root_weave_height);
  1094. /*
  1095. * do we need to draw a rectangle?
  1096. */
  1097. if (image_flag)
  1098. {
  1099. _DtCvUnit eff_x, eff_width;
  1100. /*
  1101. * do we need to stipple the rectangle for marks?
  1102. */
  1103. if (pDAS->dtinfo && IsMarkOn(new_flags) && None != pDAS->stipple)
  1104. {
  1105. /*
  1106. * include the fill style and stipple in the mask.
  1107. * it will be used later to restore the gc.
  1108. *
  1109. * Don't bother to reset the stipple pattern. As long
  1110. * as FillStyle is set to FillSolid (or FillTiled)
  1111. * the stipple is ignored.
  1112. */
  1113. mask2 = mask2 | GCFillStyle;
  1114. XSetFillStyle(dpy, fillGC, FillOpaqueStippled);
  1115. XSetStipple(dpy, fillGC, pDAS->stipple);
  1116. /*
  1117. * initialize the saved fill_style and stipple fields
  1118. * to what they should be restored to.
  1119. */
  1120. saved2.fill_style = FillSolid;
  1121. }
  1122. if (HasTraversal(new_flags) && IsTraversalEnd(new_flags))
  1123. width += pDAS->lineThickness;
  1124. eff_x = box_x;
  1125. eff_width = width;
  1126. if (pDAS->dtinfo) {
  1127. /*
  1128. * search rending info
  1129. */
  1130. if (new_flags & _DtCvAPP_FLAG3) {
  1131. eff_x += pDAS->lineThickness;
  1132. eff_width -= pDAS->lineThickness;
  1133. }
  1134. else if (new_flags & _DtCvAPP_FLAG4)
  1135. eff_width += pDAS->lineThickness;
  1136. }
  1137. XFillRectangle (dpy, win, fillGC, eff_x, (int) box_y,
  1138. eff_width, box_height);
  1139. }
  1140. if (strWidth)
  1141. {
  1142. MyDrawString (dpy, win, drawGC,
  1143. (long) font_ptr,
  1144. (long) x, (long) y, string, byte_len,
  1145. wc, False, pDAS->font_info);
  1146. if (pDAS->dtinfo && NULL != pSCD) {
  1147. _DtCvUnit line_y;
  1148. if (pSCD->hilite_type & hilite_underline) {
  1149. line_y = box_y + box_height - pDAS->lineThickness / 2;
  1150. XDrawLine (dpy, win, drawGC, x, line_y, x + strWidth, line_y);
  1151. }
  1152. if (pSCD->hilite_type & hilite_strikethrough) {
  1153. line_y = box_y + box_height / 2;
  1154. XDrawLine (dpy, win, drawGC, x, line_y, x + strWidth, line_y);
  1155. }
  1156. if (pSCD->hilite_type & hilite_overline) {
  1157. line_y = box_y + pDAS->lineThickness / 2;
  1158. XDrawLine (dpy, win, drawGC, x, line_y, x + strWidth, line_y);
  1159. }
  1160. }
  1161. if (IsHyperLink(new_flags))
  1162. {
  1163. y = y + pDAS->underLine;
  1164. if (IsPopUp(new_flags))
  1165. {
  1166. gcValues.line_style = LineOnOffDash;
  1167. XChangeGC (dpy, drawGC, GCLineStyle, &gcValues);
  1168. }
  1169. XDrawLine (dpy, win, drawGC, (int) x, (int) y,
  1170. (int) (x + strWidth), (int) y);
  1171. if (IsPopUp(new_flags))
  1172. {
  1173. gcValues.line_style = LineSolid;
  1174. XChangeGC (dpy, drawGC, GCLineStyle, &gcValues);
  1175. }
  1176. }
  1177. }
  1178. /*
  1179. * draw the traversal first
  1180. */
  1181. if (HasTraversal(new_flags))
  1182. DrawTraversal (pDAS, x, box_y, strWidth, box_height, new_flags);
  1183. /*
  1184. * draw the search traversal
  1185. */
  1186. if (pDAS->dtinfo && (new_flags & _DtCvAPP_FLAG2)) {
  1187. _DtCvFlags eff_flags = new_flags;
  1188. eff_flags |= _DtCvTRAVERSAL_FLAG;
  1189. if (new_flags & _DtCvSEARCH_BEGIN)
  1190. eff_flags |= _DtCvTRAVERSAL_BEGIN;
  1191. else
  1192. eff_flags &= ~_DtCvTRAVERSAL_BEGIN;
  1193. if (new_flags & _DtCvSEARCH_END)
  1194. eff_flags |= _DtCvTRAVERSAL_END;
  1195. else
  1196. eff_flags &= ~_DtCvTRAVERSAL_END;
  1197. DrawSearchTraversal(pDAS, x, box_y, strWidth, box_height, eff_flags);
  1198. }
  1199. /*
  1200. * restore the gcs.
  1201. */
  1202. if (mask1)
  1203. XChangeGC(dpy, drawGC, mask1, &saved1);
  1204. if (mask2)
  1205. XChangeGC(dpy, fillGC, mask2, &saved2);
  1206. }
  1207. /*****************************************************************************
  1208. * Function: void DADrawSpc ();
  1209. *
  1210. * Parameters:
  1211. * client_data Specifies the client specific data
  1212. * associated with this canvas.
  1213. * spc_handle Specifies the handle of the special
  1214. * character to render.
  1215. * x Specifies the x unit at which the
  1216. * spc is to be rendered.
  1217. * y Specifes the y unit at which the baseline
  1218. * of the spc is to be rendered.
  1219. * box_x,box_y Specifies the upper left hand corner of
  1220. * the bounding box for this string. This
  1221. * includes any traversal and/or link offsets
  1222. * relevant for the line this segment occupies.
  1223. * box_height Specifies the maximum height of the bounding
  1224. * box for this string. This includes any
  1225. * traversal and/or offsets relevant to this
  1226. * line.
  1227. * link_type Specifies the link type if this spc is
  1228. * part of a link.
  1229. * old_flags Specifies .............
  1230. * new_flags Specifies .............
  1231. *
  1232. * Returns:
  1233. *
  1234. * Purpose:
  1235. *
  1236. *****************************************************************************/
  1237. static void
  1238. DADrawSpc (
  1239. _DtCvPointer client_data,
  1240. _DtCvPointer spc_handle,
  1241. _DtCvUnit x,
  1242. _DtCvUnit y,
  1243. _DtCvUnit box_x,
  1244. _DtCvUnit box_y,
  1245. _DtCvUnit box_height,
  1246. int link_type,
  1247. _DtCvFlags old_flags,
  1248. _DtCvFlags new_flags )
  1249. {
  1250. int i;
  1251. long spcLstIdx = (long) spc_handle;
  1252. _DtCvUnit ascent;
  1253. _DtCvUnit descent;
  1254. const char *spcStr;
  1255. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1256. _DtCvStringInfo strInfo;
  1257. if (pDAS->max_spc == 0)
  1258. return;
  1259. spcStr = SpcTable[pDAS->spc_chars[spcLstIdx].spc_idx].spc_string;
  1260. _DtHelpDAGetFontMetrics(client_data, pDAS->spc_chars[spcLstIdx].font_ptr,
  1261. &ascent, &descent, NULL, NULL, NULL);
  1262. do
  1263. {
  1264. /*
  1265. * display the string up to the next newline or backspace
  1266. */
  1267. i = 0;
  1268. while ('\0' != spcStr[i] && '\n' != spcStr[i] && '\b' != spcStr[i])
  1269. i++;
  1270. strInfo.string = (void *) spcStr;
  1271. strInfo.byte_len = i;
  1272. strInfo.wc = 0;
  1273. strInfo.font_ptr = (_DtCvPointer)(pDAS->spc_chars[spcLstIdx].font_ptr);
  1274. DADrawString (client_data, (_DtCvPointer) &strInfo, x, y,
  1275. spcStr, i, 0,
  1276. pDAS->spc_chars[spcLstIdx].font_ptr, NULL,
  1277. box_x, box_y, box_height, old_flags,
  1278. new_flags);
  1279. /*
  1280. * if we are looking at a newline character, that means that
  1281. * the special character takes up several 'lines' of height.
  1282. * So increment the next y position to go to the next 'line'.
  1283. */
  1284. if ('\n' == spcStr[i])
  1285. y = y + ascent + descent;
  1286. /*
  1287. * if we are looking at a newline or a backspace, skip over it.
  1288. */
  1289. if ('\n' == spcStr[i] || '\b' == spcStr[i])
  1290. i++;
  1291. /*
  1292. * reset the string pointer.
  1293. */
  1294. spcStr += i;
  1295. /*
  1296. * do this while there is any string to display.
  1297. */
  1298. } while ('\0' != *spcStr);
  1299. }
  1300. /*****************************************************************************
  1301. * Function: void DADrawGraphic ();
  1302. *
  1303. * Parameters:
  1304. *
  1305. * Returns:
  1306. *
  1307. * Purpose:
  1308. *
  1309. *****************************************************************************/
  1310. static void
  1311. DADrawGraphic (
  1312. _DtCvPointer client_data,
  1313. _DtCvPointer graphic_ptr,
  1314. _DtCvUnit x,
  1315. _DtCvUnit y,
  1316. _DtCvUnit box_width,
  1317. _DtCvUnit box_height,
  1318. _DtCvFlags old_flags,
  1319. _DtCvFlags new_flags )
  1320. {
  1321. int width;
  1322. int height;
  1323. int old_x;
  1324. int old_y;
  1325. int srcX;
  1326. int srcY;
  1327. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1328. DtHelpGraphicStruct *pGS = (DtHelpGraphicStruct *) graphic_ptr;
  1329. Display *dpy = XtDisplay(pDAS->dispWid);
  1330. Window win = XtWindow(pDAS->dispWid);
  1331. XGCValues gcValues;
  1332. /*
  1333. * adjust for the scrolled window.
  1334. */
  1335. y = y + pDAS->decorThickness - pDAS->firstVisible;
  1336. x = x + pDAS->decorThickness - pDAS->virtualX;
  1337. /*
  1338. * save away.
  1339. */
  1340. old_x = x;
  1341. old_y = y;
  1342. /*
  1343. * adjust to get the correct y position for the graphic.
  1344. */
  1345. y = y + box_height - pGS->height - 1;
  1346. /*
  1347. * add the line thickness of the traversal to the height.
  1348. */
  1349. if (HasTraversal(old_flags))
  1350. DrawTraversal (pDAS, old_x, old_y, pGS->width, box_height,
  1351. (old_flags & (~_DtCvTRAVERSAL_FLAG)));
  1352. srcX = 0;
  1353. srcY = 0;
  1354. width = pGS->width;
  1355. height = 0;
  1356. /*
  1357. * Check and adjust the width of the graphic if it is
  1358. * to be displayed
  1359. */
  1360. if (x < 0)
  1361. {
  1362. srcX = srcX - x;
  1363. width = width + x;
  1364. x = 0;
  1365. }
  1366. if (width > 0)
  1367. {
  1368. height = pGS->height;
  1369. if (y < pDAS->decorThickness)
  1370. {
  1371. srcY = pDAS->decorThickness - y;
  1372. height -= srcY;
  1373. y = pDAS->decorThickness;
  1374. }
  1375. if (y + height > ((int)(pDAS->dispHeight - pDAS->decorThickness)))
  1376. height = pDAS->dispHeight - pDAS->decorThickness - y;
  1377. }
  1378. /*
  1379. * If we found something to write out,
  1380. * height and width will/should be greater than zero.
  1381. */
  1382. if (height > 0 && width > 0)
  1383. XCopyArea (dpy, pGS->pix, win, pDAS->normalGC,
  1384. srcX, srcY, width, height, x, y);
  1385. if (HasTraversal(new_flags))
  1386. DrawTraversal (pDAS, old_x, old_y, pGS->width, box_height, new_flags);
  1387. else if (IsHyperLink(new_flags))
  1388. {
  1389. int x,y;
  1390. XSetFillStyle(dpy, pDAS->normalGC, FillTiled);
  1391. if (IsPopUp(new_flags))
  1392. {
  1393. gcValues.line_style = LineOnOffDash;
  1394. XChangeGC (dpy, pDAS->normalGC, GCLineStyle, &gcValues);
  1395. }
  1396. x = old_x + 2;
  1397. y = old_y + pDAS->lineThickness / 2;
  1398. XDrawLine(dpy, win, pDAS->normalGC, x, y, x + box_width - 4, y);
  1399. y = old_y + box_height - pDAS->lineThickness
  1400. + pDAS->lineThickness / 2;
  1401. XDrawLine(dpy, win, pDAS->normalGC, x, y, x + box_width - 4, y);
  1402. y = old_y + 2;
  1403. x = old_x - pDAS->lineThickness + pDAS->lineThickness / 2;
  1404. XDrawLine(dpy, win, pDAS->normalGC, x, y, x, y + box_height - 4);
  1405. x = old_x + box_width + pDAS->lineThickness / 2;
  1406. XDrawLine(dpy, win, pDAS->normalGC, x, y, x, y + box_height - 4);
  1407. if (IsPopUp(new_flags))
  1408. {
  1409. gcValues.line_style = LineSolid;
  1410. XChangeGC (dpy, pDAS->normalGC, GCLineStyle, &gcValues);
  1411. }
  1412. XSetFillStyle(dpy, pDAS->normalGC, FillSolid);
  1413. }
  1414. }
  1415. /*****************************************************************************
  1416. * Function: _DtCvPointer DABuildSelectedString ();
  1417. *
  1418. * Parameters:
  1419. *
  1420. * Returns:
  1421. *
  1422. * Purpose:
  1423. *
  1424. *****************************************************************************/
  1425. static _DtCvStatus
  1426. DABuildSelectedString (
  1427. _DtCvPointer client_data,
  1428. _DtCvPointer *prev_info,
  1429. const char *string,
  1430. int byte_len,
  1431. int wc,
  1432. _DtCvPointer font_ptr,
  1433. _DtCvUnit space,
  1434. _DtCvFlags flags )
  1435. {
  1436. int i;
  1437. int j;
  1438. int mbLen;
  1439. int totalLen;
  1440. int spaceNum = 0;
  1441. int stringLen = 0;
  1442. long spaceLong = space * 10;
  1443. char *myString = (char *)(*prev_info);
  1444. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1445. if (spaceLong > 0)
  1446. spaceNum = (int) (spaceLong / pDAS->charWidth +
  1447. ((spaceLong % pDAS->charWidth) < pDAS->charWidth / 2 ? 0 : 1));
  1448. if (string == NULL)
  1449. byte_len = 0;
  1450. /*
  1451. * if we are processing a wide character string, we need to
  1452. * allocate MB_CUR_MAX bytes per character
  1453. */
  1454. mbLen = 1;
  1455. if (0 != wc)
  1456. mbLen = MB_CUR_MAX;
  1457. totalLen = byte_len * mbLen + spaceNum + 1 + (IsEndOfLine(flags) ? 1 : 0);
  1458. /*
  1459. * allocate the string
  1460. */
  1461. if (myString == NULL)
  1462. myString = (char *) malloc (sizeof(char) * totalLen);
  1463. else
  1464. {
  1465. stringLen = strlen(myString);
  1466. myString = (char *) realloc ((void *) myString,
  1467. (sizeof(char) * (stringLen + totalLen)));
  1468. }
  1469. if (myString == NULL)
  1470. return _DtCvSTATUS_BAD;
  1471. /*
  1472. * tack on the leading spaces.
  1473. */
  1474. for (i = stringLen; spaceNum > 0; spaceNum--)
  1475. myString[i++] = ' ';
  1476. /*
  1477. * now tack on the characters.
  1478. */
  1479. if (0 != wc)
  1480. {
  1481. /*
  1482. * have to translate the wide character into a multi-byte
  1483. * character.
  1484. */
  1485. wchar_t *wStr = (wchar_t *) string;
  1486. for (j = 0; 0 < byte_len; byte_len--)
  1487. {
  1488. /*
  1489. * convert the next character
  1490. */
  1491. mbLen = wctomb(&myString[i], wStr[j++]);
  1492. /*
  1493. * if a valid character, increase the destination pointer
  1494. */
  1495. if (0 <= mbLen)
  1496. i += mbLen;
  1497. }
  1498. }
  1499. else
  1500. /*
  1501. * transfer the single byte string to the destination string
  1502. */
  1503. for (j = 0; byte_len > 0 && string[j] != '\0'; byte_len--)
  1504. myString[i++] = string[j++];
  1505. if (flags)
  1506. myString[i++] = '\n';
  1507. myString[i] = '\0';
  1508. *prev_info = (_DtCvPointer) myString;
  1509. return _DtCvSTATUS_OK;
  1510. }
  1511. /*****************************************************************************
  1512. * Function: _DtCvPointer DABuildSelectedSpc ();
  1513. *
  1514. * Parameters:
  1515. *
  1516. * Returns:
  1517. *
  1518. * Purpose:
  1519. *
  1520. *****************************************************************************/
  1521. static _DtCvStatus
  1522. DABuildSelectedSpc (
  1523. _DtCvPointer client_data,
  1524. _DtCvPointer *prev_info,
  1525. _DtCvPointer spc_handle,
  1526. _DtCvUnit space,
  1527. _DtCvFlags flags )
  1528. {
  1529. long spcIdx = (long) spc_handle;
  1530. int i;
  1531. int totalLen;
  1532. int spaceNum = 0;
  1533. int stringLen = 0;
  1534. long spaceLong = space * 10;
  1535. const char *spcStr;
  1536. char *myString = (char *)(*prev_info);
  1537. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1538. /*
  1539. * find the ascii version of this spc
  1540. */
  1541. spcIdx = pDAS->spc_chars[spcIdx].spc_idx;
  1542. spcStr = _DtHelpCeResolveSpcToAscii(SpcTable[spcIdx].symbol);
  1543. if (spcStr == NULL)
  1544. return _DtCvSTATUS_BAD;
  1545. /*
  1546. * get the length to realloc
  1547. */
  1548. totalLen = strlen(spcStr);
  1549. if (spaceLong > 0)
  1550. spaceNum = (int)(spaceLong / pDAS->charWidth +
  1551. ((spaceLong % pDAS->charWidth) < pDAS->charWidth / 2 ? 0 : 1));
  1552. totalLen = totalLen + spaceNum + 1 + (IsEndOfLine(flags) ? 1 : 0);
  1553. if (myString == NULL)
  1554. myString = (char *) malloc (sizeof(char) * totalLen);
  1555. else
  1556. {
  1557. stringLen = strlen(myString);
  1558. myString = (char *) realloc ((void *) myString,
  1559. (sizeof(char) * (stringLen + totalLen)));
  1560. }
  1561. if (myString == NULL)
  1562. return _DtCvSTATUS_BAD;
  1563. for (i = stringLen; spaceNum > 0; spaceNum--)
  1564. myString[i++] = ' ';
  1565. while (*spcStr != '\0')
  1566. myString[i++] = *spcStr++;
  1567. if (flags)
  1568. myString[i++] = '\n';
  1569. myString[i] = '\0';
  1570. *prev_info = (_DtCvPointer) myString;
  1571. return _DtCvSTATUS_OK;
  1572. }
  1573. /*****************************************************************************
  1574. * Semi-Public Functions
  1575. *****************************************************************************/
  1576. /*****************************************************************************
  1577. * Function: char * _DtHelpDAGetSpcString ();
  1578. *
  1579. * Parameters:
  1580. *
  1581. * Returns:
  1582. *
  1583. * Purpose:
  1584. *
  1585. *****************************************************************************/
  1586. const char *
  1587. _DtHelpDAGetSpcString (
  1588. int idx)
  1589. {
  1590. return (SpcTable[idx].spc_string);
  1591. }
  1592. /*****************************************************************************
  1593. * Function: void _DtHelpDAResolveFont ();
  1594. *
  1595. * Parameters:
  1596. *
  1597. * Returns:
  1598. *
  1599. * Purpose:
  1600. *
  1601. *****************************************************************************/
  1602. void
  1603. _DtHelpDAResolveFont (
  1604. _DtCvPointer client_data,
  1605. char *lang,
  1606. const char *charset,
  1607. _DtHelpFontHints font_attr,
  1608. _DtCvPointer *ret_font )
  1609. {
  1610. /*
  1611. * note - if the mod_string comes in with a NULL pointer,
  1612. * it came from our own call rather than the Core Engine.
  1613. */
  1614. long idx;
  1615. (void) ResolveFont(client_data, lang, charset, font_attr, &idx);
  1616. *ret_font = (_DtCvPointer) idx;
  1617. }
  1618. /*****************************************************************************
  1619. * Function: _DtCvStatus _DtHelpDAResolveSpc ();
  1620. *
  1621. * Parameters:
  1622. *
  1623. * Returns:
  1624. *
  1625. * Purpose:
  1626. *
  1627. *****************************************************************************/
  1628. _DtCvStatus
  1629. _DtHelpDAResolveSpc (
  1630. _DtCvPointer client_data,
  1631. char *lang,
  1632. const char *charset,
  1633. _DtHelpFontHints font_attr,
  1634. const char *spc_symbol,
  1635. _DtCvPointer *ret_handle,
  1636. _DtCvUnit *ret_width,
  1637. _DtCvUnit *ret_height,
  1638. _DtCvUnit *ret_ascent)
  1639. {
  1640. int i = 0;
  1641. int result = -1;
  1642. long fontIdx;
  1643. long spcTbIdx = 0;
  1644. _DtCvUnit ascent;
  1645. _DtCvUnit descent;
  1646. const char *newSet;
  1647. const char *spcStr;
  1648. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1649. _DtCvStringInfo strInfo;
  1650. while (SpcTable[spcTbIdx].symbol != NULL &&
  1651. strcmp(SpcTable[spcTbIdx].symbol, spc_symbol) != 0)
  1652. spcTbIdx++;
  1653. newSet = SpcTable[spcTbIdx].spc_value;
  1654. spcStr = SpcTable[spcTbIdx].spc_string;
  1655. result = ResolveFont(client_data, lang, newSet, font_attr, &fontIdx);
  1656. if (result == 0)
  1657. {
  1658. long spcLstIdx = 0;
  1659. _DtCvUnit maxWidth;
  1660. _DtHelpDARegion *pReg;
  1661. pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion));
  1662. if (NULL == pReg)
  1663. return -1;
  1664. while (spcLstIdx < pDAS->cur_spc &&
  1665. pDAS->spc_chars[spcLstIdx].spc_idx != -1)
  1666. spcLstIdx++;
  1667. if (spcLstIdx == pDAS->cur_spc)
  1668. {
  1669. if (pDAS->cur_spc >= pDAS->max_spc)
  1670. {
  1671. pDAS->max_spc += GROW_SIZE;
  1672. if (pDAS->cur_spc > 0)
  1673. pDAS->spc_chars = (DtHelpSpecialChars *) realloc(
  1674. (void *)pDAS->spc_chars,
  1675. (sizeof(DtHelpSpecialChars)*pDAS->max_spc));
  1676. else
  1677. pDAS->spc_chars = (DtHelpSpecialChars *) malloc(
  1678. (sizeof(DtHelpSpecialChars)*pDAS->max_spc));
  1679. if (pDAS->spc_chars == NULL)
  1680. {
  1681. free(pReg);
  1682. return -1;
  1683. }
  1684. for (i = pDAS->cur_spc; i < pDAS->max_spc; i++)
  1685. pDAS->spc_chars[i].spc_idx = -1;
  1686. }
  1687. pDAS->cur_spc++;
  1688. }
  1689. pDAS->spc_chars[spcLstIdx].font_ptr = (_DtCvPointer)fontIdx;
  1690. pDAS->spc_chars[spcLstIdx].spc_idx = spcTbIdx;
  1691. /*
  1692. * fill in the region information
  1693. */
  1694. pReg->inited = True;
  1695. pReg->type = _DtHelpDASpc;
  1696. pReg->handle = (_DtCvPointer) spcLstIdx;
  1697. /*
  1698. * fill out the return information
  1699. */
  1700. *ret_handle = (_DtCvPointer) pReg;
  1701. *ret_height = 0;
  1702. *ret_width = 0;
  1703. /*
  1704. * get the maximum ascent and descent for the font. Set the return
  1705. * ascent.
  1706. */
  1707. _DtHelpDAGetFontMetrics(client_data, (_DtCvPointer)fontIdx,
  1708. &ascent, &descent, NULL, NULL, NULL);
  1709. *ret_ascent = ascent;
  1710. /*
  1711. * now go through the string and get the maximum width
  1712. * and total height of the special character.
  1713. */
  1714. do
  1715. {
  1716. /*
  1717. * find the first 'break' in the string sequence.
  1718. */
  1719. i = 0;
  1720. while ('\0' != spcStr[i] && '\n' != spcStr[i] && '\b' != spcStr[i])
  1721. i++;
  1722. /*
  1723. * set the height if it is zero or if this is a multi-height
  1724. * special character.
  1725. */
  1726. if ('\n' == spcStr[i] || 0 == *ret_height)
  1727. *ret_height = *ret_height + ascent + descent;
  1728. /*
  1729. * now get the maximum width of the special character.
  1730. */
  1731. strInfo.string = spcStr;
  1732. strInfo.byte_len = i;
  1733. strInfo.wc = 0;
  1734. strInfo.font_ptr = (_DtCvPointer)fontIdx;
  1735. maxWidth = _DtHelpDAGetStrWidth (client_data, _DtCvSTRING_TYPE,
  1736. (_DtCvPointer) &strInfo);
  1737. if (*ret_width < maxWidth)
  1738. *ret_width = maxWidth;
  1739. /*
  1740. * if this is a multi-height or a composite character
  1741. * skip the newline or backspace.
  1742. */
  1743. if ('\n' == spcStr[i] || '\b' == spcStr[i])
  1744. i++;
  1745. /*
  1746. * reset the string pointer
  1747. */
  1748. spcStr += i;
  1749. } while (*spcStr != '\0');
  1750. result = 0;
  1751. }
  1752. else if (spc_symbol != DefaultStr)
  1753. result = _DtHelpDAResolveSpc (client_data, lang, charset,
  1754. font_attr, DefaultStr,
  1755. ret_handle, ret_width,
  1756. ret_height, ret_ascent);
  1757. return result;
  1758. }
  1759. /*****************************************************************************
  1760. * Function: _DtCvStatus GraphicLoad ();
  1761. *
  1762. * Parameters:
  1763. *
  1764. * Returns:
  1765. *
  1766. * Purpose:
  1767. *
  1768. *****************************************************************************/
  1769. _DtCvStatus
  1770. _DtHelpDALoadGraphic (
  1771. _DtCvPointer client_data,
  1772. char *vol_xid,
  1773. char *topic_xid,
  1774. char *file_xid,
  1775. char *format,
  1776. char *method,
  1777. _DtCvUnit *ret_width,
  1778. _DtCvUnit *ret_height,
  1779. _DtCvPointer *ret_region)
  1780. {
  1781. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1782. DtHelpGraphicStruct *pGS;
  1783. _DtHelpDARegion *pReg;
  1784. Widget wid;
  1785. Window win;
  1786. char *ptr;
  1787. char *extptr;
  1788. char *fileName = file_xid;
  1789. Screen *retScr;
  1790. int screen;
  1791. pGS = (DtHelpGraphicStruct *) malloc (sizeof(DtHelpGraphicStruct));
  1792. pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion));
  1793. if (pGS == NULL || NULL == pReg)
  1794. {
  1795. if (NULL != pGS)
  1796. free(pGS);
  1797. if (NULL != pReg)
  1798. free(pReg);
  1799. return -1;
  1800. }
  1801. wid = pDAS->dispWid;
  1802. retScr = XtScreen(wid);
  1803. screen = XScreenNumberOfScreen(retScr);
  1804. while (!XtIsRealized(wid) && XtParent(wid) != NULL)
  1805. wid = XtParent(wid);
  1806. win = XtWindow(wid);
  1807. if (!XtIsRealized(wid))
  1808. win = RootWindow(XtDisplay(pDAS->dispWid), screen);
  1809. if (fileName != NULL && *fileName != '/')
  1810. {
  1811. fileName = (char *) malloc (strlen(vol_xid) + strlen (file_xid) + 2);
  1812. if (fileName == NULL)
  1813. {
  1814. free(pGS);
  1815. return -1;
  1816. }
  1817. strcpy(fileName, vol_xid);
  1818. if (_DtHelpCeStrrchr(fileName, "/", MB_CUR_MAX, &ptr) != -1)
  1819. *ptr = '\0';
  1820. strcat(fileName, "/");
  1821. strcat(fileName, file_xid);
  1822. }
  1823. /*
  1824. * Find out if this is a X Pixmap graphic and set flag if it is.
  1825. * This will be used later when/if colors need to be freed.
  1826. */
  1827. if (fileName != NULL && _DtHelpCeStrrchr(fileName, ".", MB_CUR_MAX, &extptr) != -1)
  1828. if (strcmp (extptr, ".xpm") == 0 || strcmp (extptr, ".pm") == 0)
  1829. pGS->used = -1;
  1830. if (pDAS->context == NULL)
  1831. {
  1832. pDAS->context = (_DtGrContext *) XtMalloc(sizeof(_DtGrContext));
  1833. pDAS->context->image_type = NULL;
  1834. pDAS->context->context = NULL;
  1835. }
  1836. pGS->pix = _DtHelpProcessGraphic (XtDisplay(pDAS->dispWid), win,
  1837. XScreenNumberOfScreen(XtScreen(pDAS->dispWid)),
  1838. pDAS->depth,
  1839. pDAS->pixmapGC,
  1840. &(pDAS->def_pix),
  1841. &(pDAS->def_pix_width),
  1842. &(pDAS->def_pix_height),
  1843. pDAS->context,
  1844. pDAS->colormap,
  1845. pDAS->visual,
  1846. pDAS->foregroundColor,
  1847. pDAS->backgroundColor, fileName,
  1848. pDAS->media_resolution,
  1849. &(pGS->width), &(pGS->height), &(pGS->mask),
  1850. &(pGS->pixels), &(pGS->num_pixels));
  1851. if (pDAS->context->image_type == NULL)
  1852. {
  1853. XtFree((char *) pDAS->context);
  1854. pDAS->context = NULL;
  1855. }
  1856. if (fileName != file_xid)
  1857. free (fileName);
  1858. if (pGS->pix == 0)
  1859. {
  1860. free(pReg);
  1861. free(pGS);
  1862. return -1;
  1863. }
  1864. /*
  1865. * fill in the region information
  1866. */
  1867. pReg->inited = True;
  1868. pReg->type = _DtHelpDAGraphic;
  1869. pReg->handle = (_DtCvPointer) pGS;
  1870. /*
  1871. * fill out the return information
  1872. */
  1873. *ret_width = pGS->width;
  1874. *ret_height = pGS->height;
  1875. *ret_region = (_DtCvPointer) pReg;
  1876. return 0;
  1877. }
  1878. /*****************************************************************************
  1879. * Function: void _DtHelpDADestroyGraphic ();
  1880. *
  1881. * Parameters:
  1882. *
  1883. * Returns:
  1884. *
  1885. * Purpose:
  1886. *
  1887. *****************************************************************************/
  1888. void
  1889. _DtHelpDADestroyGraphic (
  1890. _DtCvPointer client_data,
  1891. _DtCvPointer graphic_ptr )
  1892. {
  1893. Arg args[5];
  1894. Colormap colormap;
  1895. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1896. DtHelpGraphicStruct *pGS = (DtHelpGraphicStruct *) graphic_ptr;
  1897. Display *dpy = XtDisplay(pDAS->dispWid);
  1898. if (pGS->pix != pDAS->def_pix)
  1899. XFreePixmap(dpy, pGS->pix);
  1900. if (pGS->mask != None)
  1901. XFreePixmap(dpy, pGS->mask);
  1902. if (pGS->num_pixels)
  1903. {
  1904. XtSetArg (args[0], XmNcolormap, &colormap);
  1905. XtGetValues (pDAS->dispWid, args, 1);
  1906. /*
  1907. * This will only be set to -1 if the original graphic was an X Pixmap,
  1908. * <filename>.pm or <filename>.xpm.
  1909. */
  1910. if (pGS->used != -1)
  1911. XFreeColors (dpy, colormap, pGS->pixels, pGS->num_pixels, 0);
  1912. free((void *) pGS->pixels);
  1913. }
  1914. free((char *) pGS);
  1915. }
  1916. /*****************************************************************************
  1917. * Function: void _DtHelpDADestroySpc ();
  1918. *
  1919. * Parameters:
  1920. *
  1921. * Returns:
  1922. *
  1923. * Purpose:
  1924. *
  1925. *****************************************************************************/
  1926. void
  1927. _DtHelpDADestroySpc (
  1928. _DtCvPointer client_data,
  1929. _DtCvPointer spc_handle)
  1930. {
  1931. long spc_index = (long) spc_handle;
  1932. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1933. if (pDAS->max_spc == 0)
  1934. return;
  1935. pDAS->spc_chars[spc_index].spc_idx = -1;
  1936. }
  1937. /*****************************************************************************
  1938. * Function: void _DtHelpDADestroyRegion ();
  1939. *
  1940. * Parameters:
  1941. *
  1942. * Returns:
  1943. *
  1944. * Purpose:
  1945. *
  1946. *****************************************************************************/
  1947. void
  1948. _DtHelpDADestroyRegion (
  1949. _DtCvPointer client_data,
  1950. _DtCvPointer reg_info)
  1951. {
  1952. _DtHelpDARegion *pReg = (_DtHelpDARegion *) reg_info;
  1953. if (True == pReg->inited)
  1954. {
  1955. if (_DtHelpDASpc == pReg->type)
  1956. _DtHelpDADestroySpc(client_data, pReg->handle);
  1957. else if (_DtHelpDAGraphic == pReg->type)
  1958. _DtHelpDADestroyGraphic(client_data, pReg->handle);
  1959. }
  1960. else if (False == pReg->inited && _DtHelpDASpc == pReg->type)
  1961. {
  1962. _DtHelpDASpcInfo *pSpc = (_DtHelpDASpcInfo *) pReg->handle;
  1963. free(pSpc->name);
  1964. _DtHelpFreeFontHints(&(pSpc->spc_fonts));
  1965. free(pReg->handle);
  1966. }
  1967. free (pReg);
  1968. }
  1969. /*****************************************************************************
  1970. * Function: Widget _DtHelpDATocMarker ();
  1971. *
  1972. * Parameters:
  1973. * client_data Specifies the display area pointer.
  1974. *
  1975. * Returns: nothing
  1976. *
  1977. * Purpose: Turns on/off the toc marker. This includes setting the correct
  1978. * bit in pDAS->toc_flag and doing a physical XDraw or XClearArea.
  1979. *
  1980. *****************************************************************************/
  1981. void
  1982. _DtHelpDATocMarker (
  1983. XtPointer client_data,
  1984. Boolean draw)
  1985. {
  1986. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1987. if (pDAS->toc_flag & _DT_HELP_SHADOW_TRAVERSAL)
  1988. {
  1989. if (False == draw)
  1990. {
  1991. if (XtIsRealized(pDAS->dispWid))
  1992. ClearTocMarker(pDAS, 0);
  1993. TurnTocOff(pDAS->toc_flag);
  1994. }
  1995. else if (True == draw)
  1996. {
  1997. TurnTocOn(pDAS->toc_flag);
  1998. DrawTocIndicator(pDAS, 0);
  1999. }
  2000. }
  2001. }
  2002. /*****************************************************************************
  2003. * Virtual UI Functions
  2004. *****************************************************************************/
  2005. /*****************************************************************************
  2006. * Function: void _DtHelpDAGetCvsMetrics ();
  2007. *
  2008. * Parameters:
  2009. *
  2010. * Returns:
  2011. *
  2012. * Purpose:
  2013. *
  2014. *****************************************************************************/
  2015. void
  2016. _DtHelpDAGetCvsMetrics (
  2017. _DtCvPointer client_data,
  2018. _DtCvElemType elem_type,
  2019. _DtCvPointer ret_metrics)
  2020. {
  2021. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  2022. _DtCvSpaceMetrics *retSpace = (_DtCvSpaceMetrics *) ret_metrics;
  2023. if (_DtCvCANVAS_TYPE == elem_type)
  2024. {
  2025. _DtCvMetrics *retCanvas = (_DtCvMetrics *) ret_metrics;
  2026. retCanvas->width = pDAS->dispUseWidth;
  2027. retCanvas->height = pDAS->dispUseHeight;
  2028. retCanvas->top_margin = pDAS->marginHeight;
  2029. retCanvas->side_margin = pDAS->marginWidth;
  2030. retCanvas->line_height = pDAS->lineHeight;
  2031. retCanvas->horiz_pad_hint = pDAS->charWidth / 10;
  2032. }
  2033. else if (_DtCvLINK_TYPE == elem_type)
  2034. {
  2035. retSpace->space_before = 0;
  2036. retSpace->space_after = 0;
  2037. retSpace->space_above = 0;
  2038. retSpace->space_below = 0;
  2039. }
  2040. else if (_DtCvTRAVERSAL_TYPE == elem_type)
  2041. {
  2042. retSpace->space_before = pDAS->lineThickness;
  2043. if (pDAS->toc_flag & _DT_HELP_SHADOW_TRAVERSAL)
  2044. {
  2045. if (pDAS->toc_flag & _DT_HELP_NOT_INITIALIZED)
  2046. {
  2047. GetTocIndicator(pDAS);
  2048. pDAS->toc_flag &= (~(_DT_HELP_NOT_INITIALIZED));
  2049. }
  2050. retSpace->space_before += pDAS->toc_width;
  2051. }
  2052. retSpace->space_after = pDAS->lineThickness;
  2053. retSpace->space_above = pDAS->lineThickness;
  2054. retSpace->space_below = 0;
  2055. }
  2056. else if (_DtCvLOCALE_TYPE == elem_type)
  2057. {
  2058. _DtCvLocale *retLocale = (_DtCvLocale *) ret_metrics;
  2059. retLocale->line_wrap_mode = _DtCvModeWrapNone;
  2060. retLocale->cant_begin_chars = pDAS->cant_begin_chars;
  2061. retLocale->cant_end_chars = pDAS->cant_end_chars;
  2062. }
  2063. }
  2064. /*****************************************************************************
  2065. * Function: void _DtHelpDAGetFontMetrics ();
  2066. *
  2067. * Parameters:
  2068. *
  2069. * Returns:
  2070. *
  2071. * Purpose:
  2072. *
  2073. *****************************************************************************/
  2074. void
  2075. _DtHelpDAGetFontMetrics (
  2076. _DtCvPointer client_data,
  2077. _DtCvPointer font_ptr,
  2078. _DtCvUnit *ret_ascent,
  2079. _DtCvUnit *ret_descent,
  2080. _DtCvUnit *ret_width,
  2081. _DtCvUnit *ret_super,
  2082. _DtCvUnit *ret_sub)
  2083. {
  2084. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  2085. __DtHelpFontMetrics (pDAS->font_info, (long) font_ptr,
  2086. ret_ascent, ret_descent, ret_width, ret_super, ret_sub);
  2087. }
  2088. /*****************************************************************************
  2089. * Function: _DtCvUnit _DtHelpDAGetStrWidth ();
  2090. *
  2091. * Parameters:
  2092. *
  2093. * Returns:
  2094. *
  2095. * Purpose:
  2096. *
  2097. *****************************************************************************/
  2098. _DtCvUnit
  2099. _DtHelpDAGetStrWidth (
  2100. _DtCvPointer client_data,
  2101. _DtCvElemType elem_type,
  2102. _DtCvPointer data)
  2103. {
  2104. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  2105. int length;
  2106. long font_index;
  2107. _DtCvStringInfo *strInfo;
  2108. if (elem_type != _DtCvSTRING_TYPE)
  2109. return 0;
  2110. /*
  2111. * cast the data to a string information structure.
  2112. */
  2113. strInfo = (_DtCvStringInfo *) data;
  2114. /*
  2115. * If the 'font_index' is a negative number, it indicates a font set
  2116. * was opened for this string. Use the X11R5 I18N routine to figure
  2117. * out its length. Otherwise use the standard X11 text width call.
  2118. */
  2119. font_index = (long) strInfo->font_ptr;
  2120. if (font_index < 0)
  2121. {
  2122. if (0 == strInfo->wc)
  2123. length = XmbTextEscapement(
  2124. __DtHelpFontSetGet(pDAS->font_info, font_index),
  2125. (char *) strInfo->string, strInfo->byte_len);
  2126. else
  2127. length = XwcTextEscapement(
  2128. __DtHelpFontSetGet(pDAS->font_info, font_index),
  2129. (wchar_t *) strInfo->string, strInfo->byte_len);
  2130. }
  2131. else
  2132. length = XTextWidth(__DtHelpFontStructGet(pDAS->font_info, font_index),
  2133. (char *) strInfo->string, strInfo->byte_len);
  2134. return ((_DtCvUnit) length);
  2135. }
  2136. /*****************************************************************************
  2137. * Function: void _DtHelpDARenderElem ();
  2138. *
  2139. * Parameters:
  2140. * client_data Specifies the client specific data
  2141. * associated with this canvas.
  2142. * elem_type Specifies the element type that will be
  2143. * rendered.
  2144. * x Specifies the x unit at which the
  2145. * string is to be rendered.
  2146. * y Specifes the y unit at which the baseline
  2147. * of the string is to be rendered.
  2148. * link_type Specifies the link type if this element is
  2149. * part of a link.
  2150. * old_flags Specifies the old flags.
  2151. * new_flags Specifies the new flags.
  2152. * data Contains a pointer to the element specific
  2153. * structures required for rendering.
  2154. *
  2155. * Returns: Nothing
  2156. *
  2157. * Purpose:
  2158. *
  2159. *****************************************************************************/
  2160. void
  2161. _DtHelpDARenderElem (
  2162. _DtCvPointer client_data,
  2163. _DtCvElemType elem_type,
  2164. _DtCvUnit x,
  2165. _DtCvUnit y,
  2166. int link_type,
  2167. _DtCvFlags old_flags,
  2168. _DtCvFlags new_flags,
  2169. _DtCvElemType trav_type,
  2170. _DtCvPointer trav_data,
  2171. _DtCvPointer data )
  2172. {
  2173. _DtCvStringInfo *strInfo;
  2174. _DtCvLineInfo *lnInfo = (_DtCvLineInfo *) data;
  2175. _DtCvRenderInfo *posInfo = (_DtCvRenderInfo *) data;
  2176. /*
  2177. * nothing is done with trav_type or trav_data for DtHelp.
  2178. */
  2179. /*
  2180. * render the element based on its type.
  2181. */
  2182. if (_DtCvSTRING_TYPE == elem_type)
  2183. {
  2184. strInfo = (_DtCvStringInfo *) posInfo->info;
  2185. DADrawString(client_data, posInfo->info, x, y, strInfo->string,
  2186. strInfo->byte_len, strInfo->wc,
  2187. strInfo->font_ptr, strInfo->csd,
  2188. posInfo->box_x, posInfo->box_y,
  2189. posInfo->box_height,
  2190. old_flags, new_flags);
  2191. }
  2192. else if (_DtCvLINE_TYPE == elem_type)
  2193. {
  2194. DADrawLine(client_data, x, y, lnInfo->x2, lnInfo->y2, lnInfo->width);
  2195. }
  2196. else if (_DtCvREGION_TYPE == elem_type)
  2197. {
  2198. _DtHelpDARegion *regInfo = (_DtHelpDARegion *) posInfo->info;
  2199. if (_DtHelpDAGraphic == regInfo->type)
  2200. {
  2201. DADrawGraphic(client_data, regInfo->handle,
  2202. posInfo->box_x,
  2203. posInfo->box_y,
  2204. posInfo->box_width,
  2205. posInfo->box_height,
  2206. old_flags, new_flags);
  2207. }
  2208. else if (_DtHelpDASpc == regInfo->type)
  2209. {
  2210. DADrawSpc (client_data, regInfo->handle, x, y,
  2211. posInfo->box_x ,
  2212. posInfo->box_y , posInfo->box_height,
  2213. link_type , old_flags,
  2214. new_flags);
  2215. }
  2216. }
  2217. }
  2218. /*****************************************************************************
  2219. * Function: _DtCvStatus _DtHelpDABuildSelection ();
  2220. *
  2221. * Parameters:
  2222. * client_data Specifies the client specific data
  2223. * associated with this canvas.
  2224. * elem_type Specifies the element type that will be
  2225. * rendered.
  2226. * x Specifies the x unit at which the
  2227. * string is to be rendered.
  2228. * y Specifes the y unit at which the baseline
  2229. * of the string is to be rendered.
  2230. * link_type Specifies the link type if this element is
  2231. * part of a link.
  2232. * old_flags Specifies the old flags.
  2233. * new_flags Specifies the new flags.
  2234. * data Contains a pointer to the element specific
  2235. * structures required for rendering.
  2236. *
  2237. * Returns: Nothing
  2238. *
  2239. * Purpose:
  2240. *
  2241. *****************************************************************************/
  2242. _DtCvStatus
  2243. _DtHelpDABuildSelection (
  2244. _DtCvPointer client_data,
  2245. _DtCvElemType elem_type,
  2246. unsigned int mask,
  2247. _DtCvPointer *prev_info,
  2248. _DtCvUnit space,
  2249. _DtCvUnit width,
  2250. _DtCvFlags flags,
  2251. _DtCvPointer data)
  2252. {
  2253. _DtCvStatus result = _DtCvSTATUS_NONE;
  2254. if (_DtCvSTRING_TYPE == elem_type)
  2255. {
  2256. _DtCvStringInfo *strInfo = (_DtCvStringInfo *) data;
  2257. result = DABuildSelectedString(client_data, prev_info,
  2258. strInfo->string , strInfo->byte_len,
  2259. strInfo->wc,
  2260. strInfo->font_ptr, space, flags);
  2261. }
  2262. else if (_DtCvREGION_TYPE == elem_type)
  2263. {
  2264. _DtHelpDARegion *regInfo = (_DtHelpDARegion *) data;
  2265. if (_DtHelpDASpc == regInfo->type)
  2266. result = DABuildSelectedSpc (client_data, prev_info,
  2267. regInfo->handle, space, flags);
  2268. }
  2269. return result;
  2270. }