XInterface.c 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526
  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 librararies 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 recieves 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. _DtHelpGetExactFontIndex(pDAS,lang,charset,xlfdSpec,ret_idx)!=0)
  784. result = __DtHelpFontIndexGet (pDAS, xrmList, ret_idx);
  785. return result;
  786. }
  787. /*****************************************************************************
  788. * Function: void DADrawLine ();
  789. *
  790. * Parameters:
  791. *
  792. * Returns:
  793. *
  794. * Purpose:
  795. *
  796. *****************************************************************************/
  797. static void
  798. DADrawLine (
  799. _DtCvPointer client_data,
  800. _DtCvUnit x1,
  801. _DtCvUnit y1,
  802. _DtCvUnit x2,
  803. _DtCvUnit y2,
  804. _DtCvUnit line_width)
  805. {
  806. int offset;
  807. Display *dpy;
  808. Window win;
  809. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  810. XGCValues saved, gcValues;
  811. gcValues.line_width = line_width;
  812. offset = line_width / 2;
  813. dpy = XtDisplay(pDAS->dispWid);
  814. win = XtWindow(pDAS->dispWid);
  815. /*
  816. * get the current value of the gc.
  817. */
  818. XGetGCValues(dpy, pDAS->normalGC, GCLineWidth, &saved);
  819. /*
  820. * does the old line width equal the width we want?
  821. * If no, then change it to the desired width.
  822. */
  823. if (line_width != saved.line_width)
  824. XChangeGC(dpy, pDAS->normalGC, GCLineWidth, &gcValues);
  825. /*
  826. * drawing a horizontal line?
  827. */
  828. if (x1 == x2)
  829. {
  830. x1 += offset;
  831. x2 = x1;
  832. }
  833. else
  834. {
  835. y1 += offset;
  836. y2 = y1;
  837. }
  838. y1 = y1 + pDAS->decorThickness - pDAS->firstVisible;
  839. x1 = x1 + pDAS->decorThickness - pDAS->virtualX;
  840. y2 = y2 + pDAS->decorThickness - pDAS->firstVisible;
  841. x2 = x2 + pDAS->decorThickness - pDAS->virtualX;
  842. XDrawLine (dpy, win, pDAS->normalGC, x1, y1, x2, y2);
  843. /*
  844. * did we change the gc's line_width? If so, change it back.
  845. */
  846. if (line_width != saved.line_width)
  847. XChangeGC(dpy, pDAS->normalGC, GCLineWidth, &saved);
  848. }
  849. /*****************************************************************************
  850. * Function: void DADrawString ();
  851. *
  852. * Parameters:
  853. * client_data Specifies the client specific data
  854. * associated with this canvas.
  855. * x Specifies the x unit at which the
  856. * string is to be rendered.
  857. * y Specifes the y unit at which the baseline
  858. * of the string is to be rendered.
  859. * string Specifies the string to render.
  860. * byte_len Specifies the number of bytes of the
  861. * string to render.
  862. * char_len Specifies the number of bytes that
  863. * comprise one character.
  864. * font_ptr Specifies the font associated with this
  865. * string.
  866. * box_x,box_y Specifies the upper left hand corner of
  867. * the bounding box for this string. This
  868. * includes any traversal and/or link offsets
  869. * relevent for the line this segment occupies.
  870. * box_height Specifies the maximum height of the bounding
  871. * box for this string. This includes any
  872. * traversal and/or offsets relevent to this
  873. * line.
  874. * old_flags Specifies .............
  875. * new_flags Specifies .............
  876. *
  877. * Returns: Nothing
  878. *
  879. * Purpose:
  880. *
  881. *****************************************************************************/
  882. static void
  883. DADrawString (
  884. _DtCvPointer client_data,
  885. _DtCvPointer data,
  886. _DtCvUnit x,
  887. _DtCvUnit y,
  888. const void *string,
  889. int byte_len,
  890. int wc,
  891. _DtCvPointer font_ptr,
  892. _DtCvPointer scd,
  893. _DtCvUnit box_x,
  894. _DtCvUnit box_y,
  895. _DtCvUnit box_height,
  896. _DtCvFlags old_flags,
  897. _DtCvFlags new_flags )
  898. {
  899. Boolean image_flag = False;
  900. int strWidth = 0;
  901. int width;
  902. Display *dpy;
  903. Window win;
  904. GC drawGC;
  905. GC fillGC;
  906. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  907. _DtCvStringClientData* pSCD = (_DtCvStringClientData*)scd;
  908. unsigned long mask1 = 0x00; /* to be replaced with highlight attrs */
  909. unsigned long mask2 = 0x00; /* to be replaced with stippling attrs */
  910. XGCValues gcValues;
  911. XGCValues saved1, saved2;
  912. /*
  913. * if this is outside our display area, ignore it.
  914. */
  915. if (box_y + box_height < pDAS->firstVisible ||
  916. box_y > pDAS->firstVisible + pDAS->dispHeight)
  917. return;
  918. y = y + pDAS->decorThickness - pDAS->firstVisible;
  919. x = x + pDAS->decorThickness - pDAS->virtualX;
  920. box_x = box_x + pDAS->decorThickness - pDAS->virtualX;
  921. box_y = box_y + pDAS->decorThickness - pDAS->firstVisible;
  922. if (byte_len)
  923. strWidth = _DtHelpDAGetStrWidth(client_data, _DtCvSTRING_TYPE, data);
  924. width = strWidth + (x - box_x);
  925. dpy = XtDisplay(pDAS->dispWid);
  926. win = XtWindow(pDAS->dispWid);
  927. /*
  928. * initial colors for rendering.
  929. */
  930. drawGC = pDAS->normalGC;
  931. fillGC = pDAS->invertGC;
  932. /*
  933. * is this a search hit or does this string have its own color?
  934. */
  935. if (strWidth && pDAS->dtinfo &&
  936. ((new_flags & _DtCvSEARCH_FLAG) ||
  937. (NULL != pSCD && (pSCD->fg_color || pSCD->bg_color))))
  938. {
  939. XColor screen, exact;
  940. /*
  941. * indicate that we are going to change the foreground and background.
  942. */
  943. mask1 = (GCForeground | GCBackground);
  944. mask2 = (GCForeground | GCBackground);
  945. /*
  946. * remember the current values of the gc.
  947. */
  948. XGetGCValues(dpy, drawGC, mask1, &saved1);
  949. XGetGCValues(dpy, fillGC, mask2, &saved2);
  950. /* search highlight should precede stylesheet-driven highlights */
  951. /*
  952. * is the search flag set? Set the foreground to the search color.
  953. */
  954. if (new_flags & _DtCvSEARCH_FLAG)
  955. {
  956. XSetForeground(dpy, drawGC, pDAS->searchColor);
  957. XSetBackground(dpy, fillGC, pDAS->searchColor);
  958. }
  959. /*
  960. * is there a foreground color specified?
  961. */
  962. else if (pSCD->fg_color)
  963. {
  964. /*
  965. * does the foreground color need allocating?
  966. */
  967. if (pSCD->fg_pixel == (unsigned long)-1)
  968. {
  969. if (XAllocNamedColor(dpy, pDAS->colormap, pSCD->fg_color,
  970. &screen, &exact))
  971. {
  972. XSetForeground(dpy, drawGC, screen.pixel);
  973. XSetBackground(dpy, fillGC, screen.pixel);
  974. }
  975. else /* the allocation went badly */
  976. {
  977. mask1 &= ~GCForeground;
  978. mask2 &= ~GCBackground;
  979. }
  980. }
  981. else /* dtinfo has calculated pSCD->fg_pixel */
  982. {
  983. XSetForeground(dpy, drawGC, pSCD->fg_pixel);
  984. XSetBackground(dpy, fillGC, pSCD->fg_pixel);
  985. }
  986. }
  987. else /* no foreground color specified */
  988. {
  989. mask1 &= ~GCForeground;
  990. mask2 &= ~GCBackground;
  991. }
  992. /*
  993. * was a background color specified?
  994. */
  995. if (pSCD->bg_color)
  996. {
  997. /*
  998. * does the background color need allocating?
  999. */
  1000. if (pSCD->bg_pixel == (unsigned long)-1)
  1001. {
  1002. if (XAllocNamedColor(dpy, pDAS->colormap, pSCD->bg_color,
  1003. &screen, &exact))
  1004. {
  1005. XSetBackground(dpy, drawGC, screen.pixel);
  1006. XSetForeground(dpy, fillGC, screen.pixel);
  1007. }
  1008. else /* the allocation went badly */
  1009. {
  1010. mask1 &= ~GCBackground;
  1011. mask2 &= ~GCForeground;
  1012. }
  1013. }
  1014. else /* the background color's been allocated */
  1015. {
  1016. XSetBackground(dpy, drawGC, pSCD->bg_pixel);
  1017. XSetForeground(dpy, fillGC, pSCD->bg_pixel);
  1018. }
  1019. }
  1020. else /* no background color specified */
  1021. {
  1022. mask1 &= ~GCBackground;
  1023. mask2 &= ~GCForeground;
  1024. }
  1025. }
  1026. /*
  1027. * if selected, reverse the foreground and background colors
  1028. */
  1029. if (IsSelected(new_flags))
  1030. {
  1031. unsigned long tmpMsk;
  1032. GC tmpGC;
  1033. /*
  1034. * swap the gc's
  1035. */
  1036. tmpGC = drawGC;
  1037. drawGC = fillGC;
  1038. fillGC = tmpGC;
  1039. /*
  1040. * swap the saved values!
  1041. */
  1042. if (mask1 || mask2)
  1043. {
  1044. /*
  1045. * swap the masks!
  1046. */
  1047. tmpMsk = mask1;
  1048. mask1 = mask2;
  1049. mask2 = tmpMsk;
  1050. /*
  1051. * swap the saved values
  1052. */
  1053. gcValues = saved1;
  1054. saved1 = saved2;
  1055. saved2 = gcValues;
  1056. }
  1057. }
  1058. /*
  1059. * if the segment had the hypertext/mark traversal, turn it off
  1060. * this has the added benefit of also turning of the search hit
  1061. * traversal.
  1062. */
  1063. if (HasTraversal(old_flags))
  1064. DrawTraversal (pDAS, x, box_y, strWidth, box_height,
  1065. (old_flags & (~_DtCvTRAVERSAL_FLAG)));
  1066. /*
  1067. * band-aid for Search traversal support (since it isn't there).
  1068. * simply draw a negative search traversal (if the link traversal
  1069. * hasn't already blanked it out) for *every* search hit because
  1070. * it may have had the current search flag and now doesn't.
  1071. */
  1072. else if (pDAS->dtinfo && (new_flags & _DtCvSEARCH_FLAG))
  1073. DrawSearchTraversal(pDAS, x, box_y, strWidth, box_height,
  1074. (new_flags & (~_DtCvTRAVERSAL_FLAG)) |
  1075. _DtCvTRAVERSAL_BEGIN | _DtCvTRAVERSAL_END);
  1076. /*
  1077. * if the item was selected or is selected, we need to draw the
  1078. * inverse video rectangle.
  1079. */
  1080. if (IsSelected(new_flags) || IsSelected(old_flags)
  1081. || IsMarkOn(new_flags) || IsMarkOn(old_flags))
  1082. image_flag = True;
  1083. /*
  1084. * do we need to allocate the stipple pattern?
  1085. */
  1086. if (IsMarkOn(new_flags) && None == pDAS->stipple)
  1087. pDAS->stipple = XCreateBitmapFromData(dpy, win, root_weave_bits,
  1088. root_weave_width, root_weave_height);
  1089. /*
  1090. * do we need to draw a rectangle?
  1091. */
  1092. if (image_flag)
  1093. {
  1094. _DtCvUnit eff_x, eff_width;
  1095. /*
  1096. * do we need to stipple the rectangle for marks?
  1097. */
  1098. if (pDAS->dtinfo && IsMarkOn(new_flags) && None != pDAS->stipple)
  1099. {
  1100. /*
  1101. * include the fill style and stipple in the mask.
  1102. * it will be used later to restore the gc.
  1103. *
  1104. * Don't bother to reset the stipple pattern. As long
  1105. * as FillStyle is set to FillSolid (or FillTiled)
  1106. * the stipple is ignored.
  1107. */
  1108. mask2 = mask2 | GCFillStyle;
  1109. XSetFillStyle(dpy, fillGC, FillOpaqueStippled);
  1110. XSetStipple(dpy, fillGC, pDAS->stipple);
  1111. /*
  1112. * initialize the saved fill_style and stipple fields
  1113. * to what they should be restored to.
  1114. */
  1115. saved2.fill_style = FillSolid;
  1116. }
  1117. if (HasTraversal(new_flags) && IsTraversalEnd(new_flags))
  1118. width += pDAS->lineThickness;
  1119. eff_x = box_x;
  1120. eff_width = width;
  1121. if (pDAS->dtinfo) {
  1122. /*
  1123. * search rending info
  1124. */
  1125. if (new_flags & _DtCvAPP_FLAG3) {
  1126. eff_x += pDAS->lineThickness;
  1127. eff_width -= pDAS->lineThickness;
  1128. }
  1129. else if (new_flags & _DtCvAPP_FLAG4)
  1130. eff_width += pDAS->lineThickness;
  1131. }
  1132. XFillRectangle (dpy, win, fillGC, eff_x, (int) box_y,
  1133. eff_width, box_height);
  1134. }
  1135. if (strWidth)
  1136. {
  1137. MyDrawString (dpy, win, drawGC,
  1138. (long) font_ptr,
  1139. (long) x, (long) y, string, byte_len,
  1140. wc, False, pDAS->font_info);
  1141. if (pDAS->dtinfo && NULL != pSCD) {
  1142. _DtCvUnit line_y;
  1143. if (pSCD->hilite_type & hilite_underline) {
  1144. line_y = box_y + box_height - pDAS->lineThickness / 2;
  1145. XDrawLine (dpy, win, drawGC, x, line_y, x + strWidth, line_y);
  1146. }
  1147. if (pSCD->hilite_type & hilite_strikethrough) {
  1148. line_y = box_y + box_height / 2;
  1149. XDrawLine (dpy, win, drawGC, x, line_y, x + strWidth, line_y);
  1150. }
  1151. if (pSCD->hilite_type & hilite_overline) {
  1152. line_y = box_y + pDAS->lineThickness / 2;
  1153. XDrawLine (dpy, win, drawGC, x, line_y, x + strWidth, line_y);
  1154. }
  1155. }
  1156. if (IsHyperLink(new_flags))
  1157. {
  1158. y = y + pDAS->underLine;
  1159. if (IsPopUp(new_flags))
  1160. {
  1161. gcValues.line_style = LineOnOffDash;
  1162. XChangeGC (dpy, drawGC, GCLineStyle, &gcValues);
  1163. }
  1164. XDrawLine (dpy, win, drawGC, (int) x, (int) y,
  1165. (int) (x + strWidth), (int) y);
  1166. if (IsPopUp(new_flags))
  1167. {
  1168. gcValues.line_style = LineSolid;
  1169. XChangeGC (dpy, drawGC, GCLineStyle, &gcValues);
  1170. }
  1171. }
  1172. }
  1173. /*
  1174. * draw the traversal first
  1175. */
  1176. if (HasTraversal(new_flags))
  1177. DrawTraversal (pDAS, x, box_y, strWidth, box_height, new_flags);
  1178. /*
  1179. * draw the search traversal
  1180. */
  1181. if (pDAS->dtinfo && (new_flags & _DtCvAPP_FLAG2)) {
  1182. _DtCvFlags eff_flags = new_flags;
  1183. eff_flags |= _DtCvTRAVERSAL_FLAG;
  1184. if (new_flags & _DtCvSEARCH_BEGIN)
  1185. eff_flags |= _DtCvTRAVERSAL_BEGIN;
  1186. else
  1187. eff_flags &= ~_DtCvTRAVERSAL_BEGIN;
  1188. if (new_flags & _DtCvSEARCH_END)
  1189. eff_flags |= _DtCvTRAVERSAL_END;
  1190. else
  1191. eff_flags &= ~_DtCvTRAVERSAL_END;
  1192. DrawSearchTraversal(pDAS, x, box_y, strWidth, box_height, eff_flags);
  1193. }
  1194. /*
  1195. * restore the gcs.
  1196. */
  1197. if (mask1)
  1198. XChangeGC(dpy, drawGC, mask1, &saved1);
  1199. if (mask2)
  1200. XChangeGC(dpy, fillGC, mask2, &saved2);
  1201. }
  1202. /*****************************************************************************
  1203. * Function: void DADrawSpc ();
  1204. *
  1205. * Parameters:
  1206. * client_data Specifies the client specific data
  1207. * associated with this canvas.
  1208. * spc_handle Specifies the handle of the special
  1209. * character to render.
  1210. * x Specifies the x unit at which the
  1211. * spc is to be rendered.
  1212. * y Specifes the y unit at which the baseline
  1213. * of the spc is to be rendered.
  1214. * box_x,box_y Specifies the upper left hand corner of
  1215. * the bounding box for this string. This
  1216. * includes any traversal and/or link offsets
  1217. * relevent for the line this segment occupies.
  1218. * box_height Specifies the maximum height of the bounding
  1219. * box for this string. This includes any
  1220. * traversal and/or offsets relevent to this
  1221. * line.
  1222. * link_type Specifies the link type if this spc is
  1223. * part of a link.
  1224. * old_flags Specifies .............
  1225. * new_flags Specifies .............
  1226. *
  1227. * Returns:
  1228. *
  1229. * Purpose:
  1230. *
  1231. *****************************************************************************/
  1232. static void
  1233. DADrawSpc (
  1234. _DtCvPointer client_data,
  1235. _DtCvPointer spc_handle,
  1236. _DtCvUnit x,
  1237. _DtCvUnit y,
  1238. _DtCvUnit box_x,
  1239. _DtCvUnit box_y,
  1240. _DtCvUnit box_height,
  1241. int link_type,
  1242. _DtCvFlags old_flags,
  1243. _DtCvFlags new_flags )
  1244. {
  1245. int i;
  1246. long spcLstIdx = (long) spc_handle;
  1247. _DtCvUnit ascent;
  1248. _DtCvUnit descent;
  1249. const char *spcStr;
  1250. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1251. _DtCvStringInfo strInfo;
  1252. if (pDAS->max_spc == 0)
  1253. return;
  1254. spcStr = SpcTable[pDAS->spc_chars[spcLstIdx].spc_idx].spc_string;
  1255. _DtHelpDAGetFontMetrics(client_data, pDAS->spc_chars[spcLstIdx].font_ptr,
  1256. &ascent, &descent, NULL, NULL, NULL);
  1257. do
  1258. {
  1259. /*
  1260. * display the string up to the next newline or backspace
  1261. */
  1262. i = 0;
  1263. while ('\0' != spcStr[i] && '\n' != spcStr[i] && '\b' != spcStr[i])
  1264. i++;
  1265. strInfo.string = (void *) spcStr;
  1266. strInfo.byte_len = i;
  1267. strInfo.wc = 0;
  1268. strInfo.font_ptr = (_DtCvPointer)(pDAS->spc_chars[spcLstIdx].font_ptr);
  1269. DADrawString (client_data, (_DtCvPointer) &strInfo, x, y,
  1270. spcStr, i, 0,
  1271. pDAS->spc_chars[spcLstIdx].font_ptr, NULL,
  1272. box_x, box_y, box_height, old_flags,
  1273. new_flags);
  1274. /*
  1275. * if we are looking at a newline character, that means that
  1276. * the special character takes up several 'lines' of height.
  1277. * So increment the next y position to go to the next 'line'.
  1278. */
  1279. if ('\n' == spcStr[i])
  1280. y = y + ascent + descent;
  1281. /*
  1282. * if we are looking at a newline or a backspace, skip over it.
  1283. */
  1284. if ('\n' == spcStr[i] || '\b' == spcStr[i])
  1285. i++;
  1286. /*
  1287. * reset the string pointer.
  1288. */
  1289. spcStr += i;
  1290. /*
  1291. * do this while there is any string to display.
  1292. */
  1293. } while ('\0' != *spcStr);
  1294. }
  1295. /*****************************************************************************
  1296. * Function: void DADrawGraphic ();
  1297. *
  1298. * Parameters:
  1299. *
  1300. * Returns:
  1301. *
  1302. * Purpose:
  1303. *
  1304. *****************************************************************************/
  1305. static void
  1306. DADrawGraphic (
  1307. _DtCvPointer client_data,
  1308. _DtCvPointer graphic_ptr,
  1309. _DtCvUnit x,
  1310. _DtCvUnit y,
  1311. _DtCvUnit box_width,
  1312. _DtCvUnit box_height,
  1313. _DtCvFlags old_flags,
  1314. _DtCvFlags new_flags )
  1315. {
  1316. int width;
  1317. int height;
  1318. int old_x;
  1319. int old_y;
  1320. int srcX;
  1321. int srcY;
  1322. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1323. DtHelpGraphicStruct *pGS = (DtHelpGraphicStruct *) graphic_ptr;
  1324. Display *dpy = XtDisplay(pDAS->dispWid);
  1325. Window win = XtWindow(pDAS->dispWid);
  1326. XGCValues gcValues;
  1327. /*
  1328. * adjust for the scrolled window.
  1329. */
  1330. y = y + pDAS->decorThickness - pDAS->firstVisible;
  1331. x = x + pDAS->decorThickness - pDAS->virtualX;
  1332. /*
  1333. * save away.
  1334. */
  1335. old_x = x;
  1336. old_y = y;
  1337. /*
  1338. * adjust to get the correct y position for the graphic.
  1339. */
  1340. y = y + box_height - pGS->height - 1;
  1341. /*
  1342. * add the line thickness of the traversal to the height.
  1343. */
  1344. if (HasTraversal(old_flags))
  1345. DrawTraversal (pDAS, old_x, old_y, pGS->width, box_height,
  1346. (old_flags & (~_DtCvTRAVERSAL_FLAG)));
  1347. srcX = 0;
  1348. srcY = 0;
  1349. width = pGS->width;
  1350. height = 0;
  1351. /*
  1352. * Check and adjust the width of the graphic if it is
  1353. * to be displayed
  1354. */
  1355. if (x < 0)
  1356. {
  1357. srcX = srcX - x;
  1358. width = width + x;
  1359. x = 0;
  1360. }
  1361. if (width > 0)
  1362. {
  1363. height = pGS->height;
  1364. if (y < pDAS->decorThickness)
  1365. {
  1366. srcY = pDAS->decorThickness - y;
  1367. height -= srcY;
  1368. y = pDAS->decorThickness;
  1369. }
  1370. if (y + height > ((int)(pDAS->dispHeight - pDAS->decorThickness)))
  1371. height = pDAS->dispHeight - pDAS->decorThickness - y;
  1372. }
  1373. /*
  1374. * If we found something to write out,
  1375. * height and width will/should be greater than zero.
  1376. */
  1377. if (height > 0 && width > 0)
  1378. XCopyArea (dpy, pGS->pix, win, pDAS->normalGC,
  1379. srcX, srcY, width, height, x, y);
  1380. if (HasTraversal(new_flags))
  1381. DrawTraversal (pDAS, old_x, old_y, pGS->width, box_height, new_flags);
  1382. else if (IsHyperLink(new_flags))
  1383. {
  1384. int x,y;
  1385. XSetFillStyle(dpy, pDAS->normalGC, FillTiled);
  1386. if (IsPopUp(new_flags))
  1387. {
  1388. gcValues.line_style = LineOnOffDash;
  1389. XChangeGC (dpy, pDAS->normalGC, GCLineStyle, &gcValues);
  1390. }
  1391. x = old_x + 2;
  1392. y = old_y + pDAS->lineThickness / 2;
  1393. XDrawLine(dpy, win, pDAS->normalGC, x, y, x + box_width - 4, y);
  1394. y = old_y + box_height - pDAS->lineThickness
  1395. + pDAS->lineThickness / 2;
  1396. XDrawLine(dpy, win, pDAS->normalGC, x, y, x + box_width - 4, y);
  1397. y = old_y + 2;
  1398. x = old_x - pDAS->lineThickness + pDAS->lineThickness / 2;
  1399. XDrawLine(dpy, win, pDAS->normalGC, x, y, x, y + box_height - 4);
  1400. x = old_x + box_width + pDAS->lineThickness / 2;
  1401. XDrawLine(dpy, win, pDAS->normalGC, x, y, x, y + box_height - 4);
  1402. if (IsPopUp(new_flags))
  1403. {
  1404. gcValues.line_style = LineSolid;
  1405. XChangeGC (dpy, pDAS->normalGC, GCLineStyle, &gcValues);
  1406. }
  1407. XSetFillStyle(dpy, pDAS->normalGC, FillSolid);
  1408. }
  1409. }
  1410. /*****************************************************************************
  1411. * Function: _DtCvPointer DABuildSelectedString ();
  1412. *
  1413. * Parameters:
  1414. *
  1415. * Returns:
  1416. *
  1417. * Purpose:
  1418. *
  1419. *****************************************************************************/
  1420. static _DtCvStatus
  1421. DABuildSelectedString (
  1422. _DtCvPointer client_data,
  1423. _DtCvPointer *prev_info,
  1424. const char *string,
  1425. int byte_len,
  1426. int wc,
  1427. _DtCvPointer font_ptr,
  1428. _DtCvUnit space,
  1429. _DtCvFlags flags )
  1430. {
  1431. int i;
  1432. int j;
  1433. int mbLen;
  1434. int totalLen;
  1435. int spaceNum = 0;
  1436. int stringLen = 0;
  1437. long spaceLong = space * 10;
  1438. char *myString = (char *)(*prev_info);
  1439. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1440. if (spaceLong > 0)
  1441. spaceNum = (int) (spaceLong / pDAS->charWidth +
  1442. ((spaceLong % pDAS->charWidth) < pDAS->charWidth / 2 ? 0 : 1));
  1443. if (string == NULL)
  1444. byte_len = 0;
  1445. /*
  1446. * if we are processing a wide character string, we need to
  1447. * allocate MB_CUR_MAX bytes per character
  1448. */
  1449. mbLen = 1;
  1450. if (0 != wc)
  1451. mbLen = MB_CUR_MAX;
  1452. totalLen = byte_len * mbLen + spaceNum + 1 + (IsEndOfLine(flags) ? 1 : 0);
  1453. /*
  1454. * allocate the string
  1455. */
  1456. if (myString == NULL)
  1457. myString = (char *) malloc (sizeof(char) * totalLen);
  1458. else
  1459. {
  1460. stringLen = strlen(myString);
  1461. myString = (char *) realloc ((void *) myString,
  1462. (sizeof(char) * (stringLen + totalLen)));
  1463. }
  1464. if (myString == NULL)
  1465. return _DtCvSTATUS_BAD;
  1466. /*
  1467. * tack on the leading spaces.
  1468. */
  1469. for (i = stringLen; spaceNum > 0; spaceNum--)
  1470. myString[i++] = ' ';
  1471. /*
  1472. * now tack on the characters.
  1473. */
  1474. if (0 != wc)
  1475. {
  1476. /*
  1477. * have to translate the wide character into a multi-byte
  1478. * character.
  1479. */
  1480. wchar_t *wStr = (wchar_t *) string;
  1481. for (j = 0; 0 < byte_len; byte_len--)
  1482. {
  1483. /*
  1484. * convert the next character
  1485. */
  1486. mbLen = wctomb(&myString[i], wStr[j++]);
  1487. /*
  1488. * if a valid character, increase the destination pointer
  1489. */
  1490. if (0 <= mbLen)
  1491. i += mbLen;
  1492. }
  1493. }
  1494. else
  1495. /*
  1496. * transfer the single byte string to the destination string
  1497. */
  1498. for (j = 0; byte_len > 0 && string[j] != '\0'; byte_len--)
  1499. myString[i++] = string[j++];
  1500. if (flags)
  1501. myString[i++] = '\n';
  1502. myString[i] = '\0';
  1503. *prev_info = (_DtCvPointer) myString;
  1504. return _DtCvSTATUS_OK;
  1505. }
  1506. /*****************************************************************************
  1507. * Function: _DtCvPointer DABuildSelectedSpc ();
  1508. *
  1509. * Parameters:
  1510. *
  1511. * Returns:
  1512. *
  1513. * Purpose:
  1514. *
  1515. *****************************************************************************/
  1516. static _DtCvStatus
  1517. DABuildSelectedSpc (
  1518. _DtCvPointer client_data,
  1519. _DtCvPointer *prev_info,
  1520. _DtCvPointer spc_handle,
  1521. _DtCvUnit space,
  1522. _DtCvFlags flags )
  1523. {
  1524. long spcIdx = (long) spc_handle;
  1525. int i;
  1526. int totalLen;
  1527. int spaceNum = 0;
  1528. int stringLen = 0;
  1529. long spaceLong = space * 10;
  1530. const char *spcStr;
  1531. char *myString = (char *)(*prev_info);
  1532. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1533. /*
  1534. * find the ascii version of this spc
  1535. */
  1536. spcIdx = pDAS->spc_chars[spcIdx].spc_idx;
  1537. spcStr = _DtHelpCeResolveSpcToAscii(SpcTable[spcIdx].symbol);
  1538. if (spcStr == NULL)
  1539. return _DtCvSTATUS_BAD;
  1540. /*
  1541. * get the length to realloc
  1542. */
  1543. totalLen = strlen(spcStr);
  1544. if (spaceLong > 0)
  1545. spaceNum = (int)(spaceLong / pDAS->charWidth +
  1546. ((spaceLong % pDAS->charWidth) < pDAS->charWidth / 2 ? 0 : 1));
  1547. totalLen = totalLen + spaceNum + 1 + (IsEndOfLine(flags) ? 1 : 0);
  1548. if (myString == NULL)
  1549. myString = (char *) malloc (sizeof(char) * totalLen);
  1550. else
  1551. {
  1552. stringLen = strlen(myString);
  1553. myString = (char *) realloc ((void *) myString,
  1554. (sizeof(char) * (stringLen + totalLen)));
  1555. }
  1556. if (myString == NULL)
  1557. return _DtCvSTATUS_BAD;
  1558. for (i = stringLen; spaceNum > 0; spaceNum--)
  1559. myString[i++] = ' ';
  1560. while (*spcStr != '\0')
  1561. myString[i++] = *spcStr++;
  1562. if (flags)
  1563. myString[i++] = '\n';
  1564. myString[i] = '\0';
  1565. *prev_info = (_DtCvPointer) myString;
  1566. return _DtCvSTATUS_OK;
  1567. }
  1568. /*****************************************************************************
  1569. * Semi-Public Functions
  1570. *****************************************************************************/
  1571. /*****************************************************************************
  1572. * Function: char * _DtHelpDAGetSpcString ();
  1573. *
  1574. * Parameters:
  1575. *
  1576. * Returns:
  1577. *
  1578. * Purpose:
  1579. *
  1580. *****************************************************************************/
  1581. const char *
  1582. _DtHelpDAGetSpcString (
  1583. int idx)
  1584. {
  1585. return (SpcTable[idx].spc_string);
  1586. }
  1587. /*****************************************************************************
  1588. * Function: void _DtHelpDAResolveFont ();
  1589. *
  1590. * Parameters:
  1591. *
  1592. * Returns:
  1593. *
  1594. * Purpose:
  1595. *
  1596. *****************************************************************************/
  1597. void
  1598. _DtHelpDAResolveFont (
  1599. _DtCvPointer client_data,
  1600. char *lang,
  1601. const char *charset,
  1602. _DtHelpFontHints font_attr,
  1603. _DtCvPointer *ret_font )
  1604. {
  1605. /*
  1606. * note - if the mod_string comes in with a NULL pointer,
  1607. * it came from our own call rather than the Core Engine.
  1608. */
  1609. long idx;
  1610. (void) ResolveFont(client_data, lang, charset, font_attr, &idx);
  1611. *ret_font = (_DtCvPointer) idx;
  1612. }
  1613. /*****************************************************************************
  1614. * Function: _DtCvStatus _DtHelpDAResolveSpc ();
  1615. *
  1616. * Parameters:
  1617. *
  1618. * Returns:
  1619. *
  1620. * Purpose:
  1621. *
  1622. *****************************************************************************/
  1623. _DtCvStatus
  1624. _DtHelpDAResolveSpc (
  1625. _DtCvPointer client_data,
  1626. char *lang,
  1627. const char *charset,
  1628. _DtHelpFontHints font_attr,
  1629. const char *spc_symbol,
  1630. _DtCvPointer *ret_handle,
  1631. _DtCvUnit *ret_width,
  1632. _DtCvUnit *ret_height,
  1633. _DtCvUnit *ret_ascent)
  1634. {
  1635. register int i = 0;
  1636. int result = -1;
  1637. long fontIdx;
  1638. long spcTbIdx = 0;
  1639. _DtCvUnit ascent;
  1640. _DtCvUnit descent;
  1641. const char *newSet;
  1642. const char *spcStr;
  1643. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1644. _DtCvStringInfo strInfo;
  1645. while (SpcTable[spcTbIdx].symbol != NULL &&
  1646. strcmp(SpcTable[spcTbIdx].symbol, spc_symbol) != 0)
  1647. spcTbIdx++;
  1648. newSet = SpcTable[spcTbIdx].spc_value;
  1649. spcStr = SpcTable[spcTbIdx].spc_string;
  1650. result = ResolveFont(client_data, lang, newSet, font_attr, &fontIdx);
  1651. if (result == 0)
  1652. {
  1653. long spcLstIdx = 0;
  1654. _DtCvUnit maxWidth;
  1655. _DtHelpDARegion *pReg;
  1656. pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion));
  1657. if (NULL == pReg)
  1658. return -1;
  1659. while (spcLstIdx < pDAS->cur_spc &&
  1660. pDAS->spc_chars[spcLstIdx].spc_idx != -1)
  1661. spcLstIdx++;
  1662. if (spcLstIdx == pDAS->cur_spc)
  1663. {
  1664. if (pDAS->cur_spc >= pDAS->max_spc)
  1665. {
  1666. pDAS->max_spc += GROW_SIZE;
  1667. if (pDAS->cur_spc > 0)
  1668. pDAS->spc_chars = (DtHelpSpecialChars *) realloc(
  1669. (void *)pDAS->spc_chars,
  1670. (sizeof(DtHelpSpecialChars)*pDAS->max_spc));
  1671. else
  1672. pDAS->spc_chars = (DtHelpSpecialChars *) malloc(
  1673. (sizeof(DtHelpSpecialChars)*pDAS->max_spc));
  1674. if (pDAS->spc_chars == NULL)
  1675. return -1;
  1676. for (i = pDAS->cur_spc; i < pDAS->max_spc; i++)
  1677. pDAS->spc_chars[i].spc_idx = -1;
  1678. }
  1679. pDAS->cur_spc++;
  1680. }
  1681. pDAS->spc_chars[spcLstIdx].font_ptr = (_DtCvPointer)fontIdx;
  1682. pDAS->spc_chars[spcLstIdx].spc_idx = spcTbIdx;
  1683. /*
  1684. * fill in the region information
  1685. */
  1686. pReg->inited = True;
  1687. pReg->type = _DtHelpDASpc;
  1688. pReg->handle = (_DtCvPointer) spcLstIdx;
  1689. /*
  1690. * fill out the return information
  1691. */
  1692. *ret_handle = (_DtCvPointer) pReg;
  1693. *ret_height = 0;
  1694. *ret_width = 0;
  1695. /*
  1696. * get the maximum ascent and descent for the font. Set the return
  1697. * ascent.
  1698. */
  1699. _DtHelpDAGetFontMetrics(client_data, (_DtCvPointer)fontIdx,
  1700. &ascent, &descent, NULL, NULL, NULL);
  1701. *ret_ascent = ascent;
  1702. /*
  1703. * now go through the string and get the maximum width
  1704. * and total height of the special character.
  1705. */
  1706. do
  1707. {
  1708. /*
  1709. * find the first 'break' in the string sequence.
  1710. */
  1711. i = 0;
  1712. while ('\0' != spcStr[i] && '\n' != spcStr[i] && '\b' != spcStr[i])
  1713. i++;
  1714. /*
  1715. * set the height if it is zero or if this is a multi-height
  1716. * special character.
  1717. */
  1718. if ('\n' == spcStr[i] || 0 == *ret_height)
  1719. *ret_height = *ret_height + ascent + descent;
  1720. /*
  1721. * now get the maximum width of the special character.
  1722. */
  1723. strInfo.string = spcStr;
  1724. strInfo.byte_len = i;
  1725. strInfo.wc = 0;
  1726. strInfo.font_ptr = (_DtCvPointer)fontIdx;
  1727. maxWidth = _DtHelpDAGetStrWidth (client_data, _DtCvSTRING_TYPE,
  1728. (_DtCvPointer) &strInfo);
  1729. if (*ret_width < maxWidth)
  1730. *ret_width = maxWidth;
  1731. /*
  1732. * if this is a multi-height or a composite character
  1733. * skip the newline or backspace.
  1734. */
  1735. if ('\n' == spcStr[i] || '\b' == spcStr[i])
  1736. i++;
  1737. /*
  1738. * reset the string pointer
  1739. */
  1740. spcStr += i;
  1741. } while (*spcStr != '\0');
  1742. result = 0;
  1743. }
  1744. else if (spc_symbol != DefaultStr)
  1745. result = _DtHelpDAResolveSpc (client_data, lang, charset,
  1746. font_attr, DefaultStr,
  1747. ret_handle, ret_width,
  1748. ret_height, ret_ascent);
  1749. return result;
  1750. }
  1751. /*****************************************************************************
  1752. * Function: _DtCvStatus GraphicLoad ();
  1753. *
  1754. * Parameters:
  1755. *
  1756. * Returns:
  1757. *
  1758. * Purpose:
  1759. *
  1760. *****************************************************************************/
  1761. _DtCvStatus
  1762. _DtHelpDALoadGraphic (
  1763. _DtCvPointer client_data,
  1764. char *vol_xid,
  1765. char *topic_xid,
  1766. char *file_xid,
  1767. char *format,
  1768. char *method,
  1769. _DtCvUnit *ret_width,
  1770. _DtCvUnit *ret_height,
  1771. _DtCvPointer *ret_region)
  1772. {
  1773. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1774. DtHelpGraphicStruct *pGS;
  1775. _DtHelpDARegion *pReg;
  1776. Widget wid;
  1777. Window win;
  1778. char *ptr;
  1779. char *extptr;
  1780. char *fileName = file_xid;
  1781. Screen *retScr;
  1782. int screen;
  1783. pGS = (DtHelpGraphicStruct *) malloc (sizeof(DtHelpGraphicStruct));
  1784. pReg = (_DtHelpDARegion *) malloc (sizeof(_DtHelpDARegion));
  1785. if (pGS == NULL || NULL == pReg)
  1786. {
  1787. if (NULL != pGS)
  1788. free(pGS);
  1789. if (NULL != pReg)
  1790. free(pReg);
  1791. return -1;
  1792. }
  1793. wid = pDAS->dispWid;
  1794. retScr = XtScreen(wid);
  1795. screen = XScreenNumberOfScreen(retScr);
  1796. while (!XtIsRealized(wid) && XtParent(wid) != NULL)
  1797. wid = XtParent(wid);
  1798. win = XtWindow(wid);
  1799. if (!XtIsRealized(wid))
  1800. win = RootWindow(XtDisplay(pDAS->dispWid), screen);
  1801. if (fileName != NULL && *fileName != '/')
  1802. {
  1803. fileName = (char *) malloc (strlen(vol_xid) + strlen (file_xid) + 2);
  1804. if (fileName == NULL)
  1805. return -1;
  1806. strcpy(fileName, vol_xid);
  1807. if (_DtHelpCeStrrchr(fileName, "/", MB_CUR_MAX, &ptr) != -1)
  1808. *ptr = '\0';
  1809. strcat(fileName, "/");
  1810. strcat(fileName, file_xid);
  1811. }
  1812. /*
  1813. * Find out if this is a X Pixmap graphic and set flag if it is.
  1814. * This will be used later when/if colors need to be freed.
  1815. */
  1816. if (fileName != NULL && _DtHelpCeStrrchr(fileName, ".", MB_CUR_MAX, &extptr) != -1)
  1817. if (strcmp (extptr, ".xpm") == 0 || strcmp (extptr, ".pm") == 0)
  1818. pGS->used = -1;
  1819. if (pDAS->context == NULL)
  1820. {
  1821. pDAS->context = (_DtGrContext *) XtMalloc(sizeof(_DtGrContext));
  1822. pDAS->context->image_type = NULL;
  1823. pDAS->context->context = NULL;
  1824. }
  1825. pGS->pix = _DtHelpProcessGraphic (XtDisplay(pDAS->dispWid), win,
  1826. XScreenNumberOfScreen(XtScreen(pDAS->dispWid)),
  1827. pDAS->depth,
  1828. pDAS->pixmapGC,
  1829. &(pDAS->def_pix),
  1830. &(pDAS->def_pix_width),
  1831. &(pDAS->def_pix_height),
  1832. pDAS->context,
  1833. pDAS->colormap,
  1834. pDAS->visual,
  1835. pDAS->foregroundColor,
  1836. pDAS->backgroundColor, fileName,
  1837. pDAS->media_resolution,
  1838. &(pGS->width), &(pGS->height), &(pGS->mask),
  1839. &(pGS->pixels), &(pGS->num_pixels));
  1840. if (pDAS->context->image_type == NULL)
  1841. {
  1842. XtFree((char *) pDAS->context);
  1843. pDAS->context = NULL;
  1844. }
  1845. if (fileName != file_xid)
  1846. free (fileName);
  1847. if (pGS->pix == 0)
  1848. {
  1849. free(pReg);
  1850. free(pGS);
  1851. return -1;
  1852. }
  1853. /*
  1854. * fill in the region information
  1855. */
  1856. pReg->inited = True;
  1857. pReg->type = _DtHelpDAGraphic;
  1858. pReg->handle = (_DtCvPointer) pGS;
  1859. /*
  1860. * fill out the return information
  1861. */
  1862. *ret_width = pGS->width;
  1863. *ret_height = pGS->height;
  1864. *ret_region = (_DtCvPointer) pReg;
  1865. return 0;
  1866. }
  1867. /*****************************************************************************
  1868. * Function: void _DtHelpDADestroyGraphic ();
  1869. *
  1870. * Parameters:
  1871. *
  1872. * Returns:
  1873. *
  1874. * Purpose:
  1875. *
  1876. *****************************************************************************/
  1877. void
  1878. _DtHelpDADestroyGraphic (
  1879. _DtCvPointer client_data,
  1880. _DtCvPointer graphic_ptr )
  1881. {
  1882. Arg args[5];
  1883. Colormap colormap;
  1884. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1885. DtHelpGraphicStruct *pGS = (DtHelpGraphicStruct *) graphic_ptr;
  1886. Display *dpy = XtDisplay(pDAS->dispWid);
  1887. if (pGS->pix != pDAS->def_pix)
  1888. XFreePixmap(dpy, pGS->pix);
  1889. if (pGS->mask != None)
  1890. XFreePixmap(dpy, pGS->mask);
  1891. if (pGS->num_pixels)
  1892. {
  1893. XtSetArg (args[0], XmNcolormap, &colormap);
  1894. XtGetValues (pDAS->dispWid, args, 1);
  1895. /*
  1896. * This will only be set to -1 if the original graphic was an X Pixmap,
  1897. * <filename>.pm or <filename>.xpm.
  1898. */
  1899. if (pGS->used != -1)
  1900. XFreeColors (dpy, colormap, pGS->pixels, pGS->num_pixels, 0);
  1901. free((void *) pGS->pixels);
  1902. }
  1903. free((char *) pGS);
  1904. }
  1905. /*****************************************************************************
  1906. * Function: void _DtHelpDADestroySpc ();
  1907. *
  1908. * Parameters:
  1909. *
  1910. * Returns:
  1911. *
  1912. * Purpose:
  1913. *
  1914. *****************************************************************************/
  1915. void
  1916. _DtHelpDADestroySpc (
  1917. _DtCvPointer client_data,
  1918. _DtCvPointer spc_handle)
  1919. {
  1920. long spc_index = (long) spc_handle;
  1921. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1922. if (pDAS->max_spc == 0)
  1923. return;
  1924. pDAS->spc_chars[spc_index].spc_idx = -1;
  1925. }
  1926. /*****************************************************************************
  1927. * Function: void _DtHelpDADestroyRegion ();
  1928. *
  1929. * Parameters:
  1930. *
  1931. * Returns:
  1932. *
  1933. * Purpose:
  1934. *
  1935. *****************************************************************************/
  1936. void
  1937. _DtHelpDADestroyRegion (
  1938. _DtCvPointer client_data,
  1939. _DtCvPointer reg_info)
  1940. {
  1941. _DtHelpDARegion *pReg = (_DtHelpDARegion *) reg_info;
  1942. if (True == pReg->inited)
  1943. {
  1944. if (_DtHelpDASpc == pReg->type)
  1945. _DtHelpDADestroySpc(client_data, pReg->handle);
  1946. else if (_DtHelpDAGraphic == pReg->type)
  1947. _DtHelpDADestroyGraphic(client_data, pReg->handle);
  1948. }
  1949. else if (False == pReg->inited && _DtHelpDASpc == pReg->type)
  1950. {
  1951. _DtHelpDASpcInfo *pSpc = (_DtHelpDASpcInfo *) pReg->handle;
  1952. free(pSpc->name);
  1953. _DtHelpFreeFontHints(&(pSpc->spc_fonts));
  1954. free(pReg->handle);
  1955. }
  1956. free (pReg);
  1957. }
  1958. /*****************************************************************************
  1959. * Function: Widget _DtHelpDATocMarker ();
  1960. *
  1961. * Parameters:
  1962. * client_data Specifies the display area pointer.
  1963. *
  1964. * Returns: nothing
  1965. *
  1966. * Purpose: Turns on/off the toc marker. This includes setting the correct
  1967. * bit in pDAS->toc_flag and doing a physical XDraw or XClearArea.
  1968. *
  1969. *****************************************************************************/
  1970. void
  1971. _DtHelpDATocMarker (
  1972. XtPointer client_data,
  1973. Boolean draw)
  1974. {
  1975. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  1976. if (pDAS->toc_flag & _DT_HELP_SHADOW_TRAVERSAL)
  1977. {
  1978. if (False == draw)
  1979. {
  1980. if (XtIsRealized(pDAS->dispWid))
  1981. ClearTocMarker(pDAS, 0);
  1982. TurnTocOff(pDAS->toc_flag);
  1983. }
  1984. else if (True == draw)
  1985. {
  1986. TurnTocOn(pDAS->toc_flag);
  1987. DrawTocIndicator(pDAS, 0);
  1988. }
  1989. }
  1990. }
  1991. /*****************************************************************************
  1992. * Virtual UI Functions
  1993. *****************************************************************************/
  1994. /*****************************************************************************
  1995. * Function: void _DtHelpDAGetCvsMetrics ();
  1996. *
  1997. * Parameters:
  1998. *
  1999. * Returns:
  2000. *
  2001. * Purpose:
  2002. *
  2003. *****************************************************************************/
  2004. void
  2005. _DtHelpDAGetCvsMetrics (
  2006. _DtCvPointer client_data,
  2007. _DtCvElemType elem_type,
  2008. _DtCvPointer ret_metrics)
  2009. {
  2010. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  2011. _DtCvSpaceMetrics *retSpace = (_DtCvSpaceMetrics *) ret_metrics;
  2012. if (_DtCvCANVAS_TYPE == elem_type)
  2013. {
  2014. _DtCvMetrics *retCanvas = (_DtCvMetrics *) ret_metrics;
  2015. retCanvas->width = pDAS->dispUseWidth;
  2016. retCanvas->height = pDAS->dispUseHeight;
  2017. retCanvas->top_margin = pDAS->marginHeight;
  2018. retCanvas->side_margin = pDAS->marginWidth;
  2019. retCanvas->line_height = pDAS->lineHeight;
  2020. retCanvas->horiz_pad_hint = pDAS->charWidth / 10;
  2021. }
  2022. else if (_DtCvLINK_TYPE == elem_type)
  2023. {
  2024. retSpace->space_before = 0;
  2025. retSpace->space_after = 0;
  2026. retSpace->space_above = 0;
  2027. retSpace->space_below = 0;
  2028. }
  2029. else if (_DtCvTRAVERSAL_TYPE == elem_type)
  2030. {
  2031. retSpace->space_before = pDAS->lineThickness;
  2032. if (pDAS->toc_flag & _DT_HELP_SHADOW_TRAVERSAL)
  2033. {
  2034. if (pDAS->toc_flag & _DT_HELP_NOT_INITIALIZED)
  2035. {
  2036. GetTocIndicator(pDAS);
  2037. pDAS->toc_flag &= (~(_DT_HELP_NOT_INITIALIZED));
  2038. }
  2039. retSpace->space_before += pDAS->toc_width;
  2040. }
  2041. retSpace->space_after = pDAS->lineThickness;
  2042. retSpace->space_above = pDAS->lineThickness;
  2043. retSpace->space_below = 0;
  2044. }
  2045. else if (_DtCvLOCALE_TYPE == elem_type)
  2046. {
  2047. _DtCvLocale *retLocale = (_DtCvLocale *) ret_metrics;
  2048. retLocale->line_wrap_mode = _DtCvModeWrapNone;
  2049. retLocale->cant_begin_chars = pDAS->cant_begin_chars;
  2050. retLocale->cant_end_chars = pDAS->cant_end_chars;
  2051. }
  2052. }
  2053. /*****************************************************************************
  2054. * Function: void _DtHelpDAGetFontMetrics ();
  2055. *
  2056. * Parameters:
  2057. *
  2058. * Returns:
  2059. *
  2060. * Purpose:
  2061. *
  2062. *****************************************************************************/
  2063. void
  2064. _DtHelpDAGetFontMetrics (
  2065. _DtCvPointer client_data,
  2066. _DtCvPointer font_ptr,
  2067. _DtCvUnit *ret_ascent,
  2068. _DtCvUnit *ret_descent,
  2069. _DtCvUnit *ret_width,
  2070. _DtCvUnit *ret_super,
  2071. _DtCvUnit *ret_sub)
  2072. {
  2073. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  2074. __DtHelpFontMetrics (pDAS->font_info, (long) font_ptr,
  2075. ret_ascent, ret_descent, ret_width, ret_super, ret_sub);
  2076. }
  2077. /*****************************************************************************
  2078. * Function: _DtCvUnit _DtHelpDAGetStrWidth ();
  2079. *
  2080. * Parameters:
  2081. *
  2082. * Returns:
  2083. *
  2084. * Purpose:
  2085. *
  2086. *****************************************************************************/
  2087. _DtCvUnit
  2088. _DtHelpDAGetStrWidth (
  2089. _DtCvPointer client_data,
  2090. _DtCvElemType elem_type,
  2091. _DtCvPointer data)
  2092. {
  2093. DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;
  2094. int length;
  2095. long font_index;
  2096. _DtCvStringInfo *strInfo;
  2097. if (elem_type != _DtCvSTRING_TYPE)
  2098. return 0;
  2099. /*
  2100. * cast the data to a string information structure.
  2101. */
  2102. strInfo = (_DtCvStringInfo *) data;
  2103. /*
  2104. * If the 'font_index' is a negative number, it indicates a font set
  2105. * was opened for this string. Use the X11R5 I18N routine to figure
  2106. * out its length. Otherwise use the standard X11 text width call.
  2107. */
  2108. font_index = (long) strInfo->font_ptr;
  2109. if (font_index < 0)
  2110. {
  2111. if (0 == strInfo->wc)
  2112. length = XmbTextEscapement(
  2113. __DtHelpFontSetGet(pDAS->font_info, font_index),
  2114. (char *) strInfo->string, strInfo->byte_len);
  2115. else
  2116. length = XwcTextEscapement(
  2117. __DtHelpFontSetGet(pDAS->font_info, font_index),
  2118. (wchar_t *) strInfo->string, strInfo->byte_len);
  2119. }
  2120. else
  2121. length = XTextWidth(__DtHelpFontStructGet(pDAS->font_info, font_index),
  2122. (char *) strInfo->string, strInfo->byte_len);
  2123. return ((_DtCvUnit) length);
  2124. }
  2125. /*****************************************************************************
  2126. * Function: void _DtHelpDARenderElem ();
  2127. *
  2128. * Parameters:
  2129. * client_data Specifies the client specific data
  2130. * associated with this canvas.
  2131. * elem_type Specifies the element type that will be
  2132. * rendered.
  2133. * x Specifies the x unit at which the
  2134. * string is to be rendered.
  2135. * y Specifes the y unit at which the baseline
  2136. * of the string is to be rendered.
  2137. * link_type Specifies the link type if this element is
  2138. * part of a link.
  2139. * old_flags Specifies the old flags.
  2140. * new_flags Specifies the new flags.
  2141. * data Contains a pointer to the element specific
  2142. * structures required for rendering.
  2143. *
  2144. * Returns: Nothing
  2145. *
  2146. * Purpose:
  2147. *
  2148. *****************************************************************************/
  2149. void
  2150. _DtHelpDARenderElem (
  2151. _DtCvPointer client_data,
  2152. _DtCvElemType elem_type,
  2153. _DtCvUnit x,
  2154. _DtCvUnit y,
  2155. int link_type,
  2156. _DtCvFlags old_flags,
  2157. _DtCvFlags new_flags,
  2158. _DtCvElemType trav_type,
  2159. _DtCvPointer trav_data,
  2160. _DtCvPointer data )
  2161. {
  2162. _DtCvStringInfo *strInfo;
  2163. _DtCvLineInfo *lnInfo = (_DtCvLineInfo *) data;
  2164. _DtCvRenderInfo *posInfo = (_DtCvRenderInfo *) data;
  2165. /*
  2166. * nothing is done with trav_type or trav_data for DtHelp.
  2167. */
  2168. /*
  2169. * render the element based on its type.
  2170. */
  2171. if (_DtCvSTRING_TYPE == elem_type)
  2172. {
  2173. strInfo = (_DtCvStringInfo *) posInfo->info;
  2174. DADrawString(client_data, posInfo->info, x, y, strInfo->string,
  2175. strInfo->byte_len, strInfo->wc,
  2176. strInfo->font_ptr, strInfo->csd,
  2177. posInfo->box_x, posInfo->box_y,
  2178. posInfo->box_height,
  2179. old_flags, new_flags);
  2180. }
  2181. else if (_DtCvLINE_TYPE == elem_type)
  2182. {
  2183. DADrawLine(client_data, x, y, lnInfo->x2, lnInfo->y2, lnInfo->width);
  2184. }
  2185. else if (_DtCvREGION_TYPE == elem_type)
  2186. {
  2187. _DtHelpDARegion *regInfo = (_DtHelpDARegion *) posInfo->info;
  2188. if (_DtHelpDAGraphic == regInfo->type)
  2189. {
  2190. DADrawGraphic(client_data, regInfo->handle,
  2191. posInfo->box_x,
  2192. posInfo->box_y,
  2193. posInfo->box_width,
  2194. posInfo->box_height,
  2195. old_flags, new_flags);
  2196. }
  2197. else if (_DtHelpDASpc == regInfo->type)
  2198. {
  2199. DADrawSpc (client_data, regInfo->handle, x, y,
  2200. posInfo->box_x ,
  2201. posInfo->box_y , posInfo->box_height,
  2202. link_type , old_flags,
  2203. new_flags);
  2204. }
  2205. }
  2206. }
  2207. /*****************************************************************************
  2208. * Function: _DtCvStatus _DtHelpDABuildSelection ();
  2209. *
  2210. * Parameters:
  2211. * client_data Specifies the client specific data
  2212. * associated with this canvas.
  2213. * elem_type Specifies the element type that will be
  2214. * rendered.
  2215. * x Specifies the x unit at which the
  2216. * string is to be rendered.
  2217. * y Specifes the y unit at which the baseline
  2218. * of the string is to be rendered.
  2219. * link_type Specifies the link type if this element is
  2220. * part of a link.
  2221. * old_flags Specifies the old flags.
  2222. * new_flags Specifies the new flags.
  2223. * data Contains a pointer to the element specific
  2224. * structures required for rendering.
  2225. *
  2226. * Returns: Nothing
  2227. *
  2228. * Purpose:
  2229. *
  2230. *****************************************************************************/
  2231. _DtCvStatus
  2232. _DtHelpDABuildSelection (
  2233. _DtCvPointer client_data,
  2234. _DtCvElemType elem_type,
  2235. unsigned int mask,
  2236. _DtCvPointer *prev_info,
  2237. _DtCvUnit space,
  2238. _DtCvUnit width,
  2239. _DtCvFlags flags,
  2240. _DtCvPointer data)
  2241. {
  2242. _DtCvStatus result = _DtCvSTATUS_NONE;
  2243. if (_DtCvSTRING_TYPE == elem_type)
  2244. {
  2245. _DtCvStringInfo *strInfo = (_DtCvStringInfo *) data;
  2246. result = DABuildSelectedString(client_data, prev_info,
  2247. strInfo->string , strInfo->byte_len,
  2248. strInfo->wc,
  2249. strInfo->font_ptr, space, flags);
  2250. }
  2251. else if (_DtCvREGION_TYPE == elem_type)
  2252. {
  2253. _DtHelpDARegion *regInfo = (_DtHelpDARegion *) data;
  2254. if (_DtHelpDASpc == regInfo->type)
  2255. result = DABuildSelectedSpc (client_data, prev_info,
  2256. regInfo->handle, space, flags);
  2257. }
  2258. return result;
  2259. }