WmIconBox.c 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * (c) Copyright 1989, 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
  25. * ALL RIGHTS RESERVED
  26. */
  27. /*
  28. * Motif Release 1.2.4
  29. */
  30. /*
  31. * (c) Copyright 1987, 1988, 1989, 1990, 1993, 1994 Hewlett-Packard Company
  32. * (c) Copyright 1993, 1994 International Business Machines Corp.
  33. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  34. * (c) Copyright 1993, 1994 Novell, Inc.
  35. */
  36. /*
  37. * Included Files:
  38. */
  39. #include "WmGlobal.h"
  40. #include "WmHelp.h"
  41. #include <X11/StringDefs.h>
  42. #include <X11/Intrinsic.h>
  43. #include <X11/Shell.h>
  44. #include <X11/Xutil.h>
  45. #include <X11/Vendor.h>
  46. #include <X11/keysymdef.h>
  47. #include <X11/keysym.h>
  48. #include <Xm/Xm.h>
  49. #include <Xm/DialogS.h>
  50. #include <Xm/Frame.h>
  51. #include <Xm/Label.h>
  52. #include <Xm/PushB.h>
  53. #include <Xm/DrawnB.h>
  54. #include <Xm/ScrolledW.h>
  55. #include <Xm/BulletinB.h>
  56. #include <Xm/ToggleB.h>
  57. #define MWM_NEED_IIMAGE
  58. #define MWM_NEED_GREYED75
  59. #define MWM_NEED_SLANT2
  60. #include "WmIBitmap.h"
  61. #include "WmResNames.h"
  62. #include <stdio.h>
  63. /*
  64. * include extern functions
  65. */
  66. #include "WmIconBox.h"
  67. #include "WmCDInfo.h"
  68. #include "WmError.h"
  69. #include "WmEvent.h"
  70. #include "WmFunction.h"
  71. #include "WmIDecor.h"
  72. #include "WmIPlace.h"
  73. #include "WmImage.h"
  74. #include "WmPanelP.h" /* for typedef in WmManage.h */
  75. #include "WmManage.h"
  76. #include "WmMenu.h"
  77. #include "WmResParse.h"
  78. #include "WmResource.h"
  79. #include "WmWinInfo.h"
  80. #include "WmWrkspace.h"
  81. #ifndef MAX
  82. #define MAX(a,b) ((a)>(b)?(a):(b))
  83. #endif
  84. /*
  85. * Global Variables:
  86. */
  87. Pixel select_color;
  88. Pixmap greyedPixmap;
  89. int frameShadowThickness;
  90. int firstTime = 1;
  91. Cardinal insertPosition = 0;
  92. #define DEFAULT_ICON_BOX_TITLE "Icons"
  93. Const char *szhorizontal = "horizontal";
  94. Const char *szvertical = "vertical";
  95. /*************************************<->*************************************
  96. *
  97. * InitIconBox (pSD)
  98. *
  99. *
  100. * Description:
  101. * -----------
  102. * This function controls creation of icon boxes
  103. *
  104. *
  105. *************************************<->***********************************/
  106. void InitIconBox (WmScreenData *pSD)
  107. {
  108. int iws;
  109. /*
  110. * Start the process of making the icon boxes
  111. */
  112. /*
  113. * Manage a separate icon box in every workspace
  114. * on this screen.
  115. */
  116. for (iws = 0; iws < pSD->numWorkspaces; iws++)
  117. {
  118. AddIconBoxForWorkspace (&pSD->pWS[iws]);
  119. }
  120. if (pSD->fadeNormalIcon)
  121. {
  122. MakeFadeIconGC (pSD);
  123. }
  124. } /* END OF FUNCTION InitIconBox */
  125. /*************************************<->*************************************
  126. *
  127. * AddIconBoxForWorkspace (pWS)
  128. *
  129. *
  130. * Description:
  131. * -----------
  132. * This function adds an iconbox to a workspace
  133. *
  134. *
  135. *************************************<->***********************************/
  136. void AddIconBoxForWorkspace (WmWorkspaceData *pWS)
  137. {
  138. extern WmWorkspaceData *pIconBoxInitialWS;
  139. pIconBoxInitialWS = pWS;
  140. ManageWindow (pWS->pSD, None, MANAGEW_ICON_BOX);
  141. } /* END OF FUNCTION AddIconBoxForWorkspace */
  142. /*************************************<->*************************************
  143. *
  144. * MakeIconBox (pWS, pCD);
  145. *
  146. *
  147. * Description:
  148. * -----------
  149. *
  150. *
  151. *
  152. * Inputs:
  153. * ------
  154. * pWS = pointer to workspace data
  155. * pCD = a pointer to ClientData
  156. *
  157. *
  158. * Outputs:
  159. * -------
  160. *
  161. * Return = (Boolean) True iff successful.
  162. *
  163. *
  164. * Comments:
  165. * --------
  166. * If fails, frees the ClientData structure pointed to by pCD.
  167. *
  168. *************************************<->***********************************/
  169. Boolean MakeIconBox (WmWorkspaceData *pWS, ClientData *pCD)
  170. {
  171. IconBoxData *pIBD;
  172. /*
  173. * Make an icon box and return the pCD
  174. */
  175. if (pCD)
  176. {
  177. if (!(pIBD = (IconBoxData *)XtMalloc (sizeof (IconBoxData))))
  178. {
  179. /*
  180. * We need a pointer to icon box data to add to the
  181. * list of icon boxes linked to pWS->pIconBox. If
  182. * we can't allocate space we need to free the space
  183. * allocated for the ClientData structure
  184. */
  185. Warning (((char *)GETMESSAGE(36, 1, "Insufficient memory to create icon box data")));
  186. XtFree ((char *)pCD);
  187. return (FALSE);
  188. }
  189. InitializeIconBoxData (pWS, pIBD);
  190. InitializeClientData (pCD, pIBD);
  191. if (!(pIBD->IPD.placeList =
  192. (IconInfo *)XtMalloc (pIBD->IPD.totalPlaces * sizeof (IconInfo))))
  193. {
  194. Warning (((char *)GETMESSAGE(36, 2, "Insufficient memory to create icon box data")));
  195. XtFree ((char *)pIBD);
  196. XtFree ((char *)pCD);
  197. return (FALSE);
  198. }
  199. memset (pIBD->IPD.placeList, 0,
  200. pIBD->IPD.totalPlaces * sizeof (IconInfo));
  201. /*
  202. * Make the top level shell for this icon box
  203. */
  204. MakeShell (pWS, pIBD);
  205. /*
  206. * Make the scrolled window for this icon box
  207. */
  208. MakeScrolledWindow (pWS, pIBD);
  209. /*
  210. * Make the row column manager for this icon box
  211. */
  212. MakeBulletinBoard (pWS, pIBD);
  213. /*
  214. * Realize the widget tree and set client data fields
  215. */
  216. RealizeIconBox (pWS, pIBD, pCD);
  217. /*
  218. * Link the new icon box to list of icon boxes
  219. */
  220. AddNewBox (pWS, pIBD);
  221. }
  222. return (TRUE);
  223. } /* END OF FUNCTION MakeIconBox */
  224. /*************************************<->*************************************
  225. *
  226. * DestroyIconBox (pWS)
  227. *
  228. *
  229. * Description:
  230. * -----------
  231. * Destroys an icon box
  232. *
  233. *
  234. * Inputs:
  235. * ------
  236. * pWS = pointer to workspace data
  237. *
  238. *
  239. * Outputs:
  240. * -------
  241. *
  242. * Return = none
  243. *
  244. *
  245. * Comments:
  246. * --------
  247. * Used when deleting a workspace
  248. * Should be called AFTER all clients have been removed from the
  249. * workspace -- there should be no icons in the icon box.
  250. *
  251. *************************************<->***********************************/
  252. void DestroyIconBox (WmWorkspaceData *pWS)
  253. {
  254. IconBoxData *pIBD;
  255. pIBD = pWS->pIconBox;
  256. XtDestroyWidget (pIBD->shellWidget);
  257. UnManageWindow (pIBD->pCD_iconBox);
  258. XtFree ((char *) pIBD);
  259. } /* END OF FUNCTION DestroyIconBox */
  260. /*************************************<->*************************************
  261. *
  262. * MakeShell (pWS, pIBD)
  263. *
  264. *
  265. * Description:
  266. * -----------
  267. *
  268. *
  269. *
  270. * Inputs:
  271. * ------
  272. * pWS = pointer to workspace data
  273. *
  274. * pIBD = pointer to IconBoxData
  275. *
  276. * XXinput = ...
  277. *
  278. *
  279. * Outputs:
  280. * -------
  281. *
  282. * pIBD->shellWidget
  283. *
  284. *
  285. * Comments:
  286. * --------
  287. * XXComments ...
  288. *
  289. *************************************<->***********************************/
  290. void MakeShell (WmWorkspaceData *pWS, IconBoxData *pIBD)
  291. {
  292. Arg setArgs[20];
  293. int i;
  294. char *pchIBTitle = NULL;
  295. /*
  296. * Create top level application shell for icon box
  297. */
  298. i=0;
  299. XtSetArg (setArgs[i], XmNallowShellResize, (XtArgVal)True); i++;
  300. XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal)0); i++;
  301. XtSetArg (setArgs[i], XmNkeyboardFocusPolicy, (XtArgVal)XmEXPLICIT); i++;
  302. if (pWS->pSD->iconBoxTitle)
  303. {
  304. pchIBTitle = WmXmStringToString (pWS->pSD->iconBoxTitle);
  305. XtSetArg (setArgs[i], XmNtitle, (XtArgVal)pchIBTitle); i++;
  306. XtSetArg (setArgs[i], XmNiconName, (XtArgVal)pchIBTitle); i++;
  307. }
  308. XtSetArg (setArgs[i], XmNmappedWhenManaged, (XtArgVal)False); i++;
  309. XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal)XmDIALOG_MODELESS); i++;
  310. XtSetArg (setArgs[i], XmNdepth,
  311. (XtArgVal) DefaultDepth (DISPLAY, pWS->pSD->screen)); i++;
  312. XtSetArg (setArgs[i], XmNscreen,
  313. (XtArgVal) ScreenOfDisplay (DISPLAY, pWS->pSD->screen)); i++;
  314. pIBD->shellWidget = (Widget) XtCreatePopupShell (WmNclient,
  315. topLevelShellWidgetClass,
  316. pWS->workspaceTopLevelW,
  317. (ArgList)setArgs, i);
  318. if (pchIBTitle != NULL) XtFree (pchIBTitle);
  319. } /* END OF FUNCTION MakeShell */
  320. /*************************************<->*************************************
  321. *
  322. * MakeScrolledWindow (pWS, pIBD)
  323. *
  324. *
  325. * Description:
  326. * -----------
  327. *
  328. *
  329. *
  330. * Inputs:
  331. * ------
  332. * pWS = pointer to workspace data
  333. * pIBD = pointer to IconBoxData
  334. * XXinput = ...
  335. *
  336. *
  337. * Outputs:
  338. * -------
  339. *
  340. * Return = pIBD with the pIBD->scrolledWidget set
  341. *
  342. *
  343. * Comments:
  344. * --------
  345. * XXComments ...
  346. *
  347. *************************************<->***********************************/
  348. void MakeScrolledWindow (WmWorkspaceData *pWS, IconBoxData *pIBD)
  349. {
  350. Arg setArgs[20];
  351. int i;
  352. /*
  353. * Create frame widget to give the scrolled window
  354. * an external bevel
  355. */
  356. i=0;
  357. XtSetArg (setArgs[i], XmNborderWidth, (XtArgVal) 0 ); i++;
  358. XtSetArg (setArgs[i], XmNmarginWidth, (XtArgVal) 0 ); i++;
  359. XtSetArg (setArgs[i], XmNmarginHeight, (XtArgVal) 0 ); i++;
  360. XtSetArg (setArgs[i], XmNshadowType, (XtArgVal) XmSHADOW_OUT); i++;
  361. XtSetArg (setArgs[i], XmNshadowThickness,
  362. (XtArgVal) frameShadowThickness); i++;
  363. pIBD->frameWidget = XtCreateManagedWidget ("IBframe",
  364. xmFrameWidgetClass,
  365. pIBD->shellWidget,
  366. (ArgList)setArgs, i);
  367. XtAddCallback (pIBD->frameWidget, XmNhelpCallback,
  368. WmDtWmTopicHelpCB, WM_DT_ICONBOX_TOPIC);
  369. /*
  370. * Create scrolled window to hold row column manager
  371. */
  372. i=0;
  373. XtSetArg (setArgs[i], XmNscrollingPolicy , (XtArgVal) XmAUTOMATIC ); i++;
  374. XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0 ); i++;
  375. XtSetArg (setArgs[i], XmNspacing , (XtArgVal) IB_MARGIN_WIDTH ); i++;
  376. /*
  377. * do we want to get these from a resource or set it here
  378. * to control the appearance of the iconBox
  379. */
  380. XtSetArg (setArgs[i], XmNscrolledWindowMarginWidth, (XtArgVal) 3); i++;
  381. XtSetArg (setArgs[i], XmNscrolledWindowMarginHeight, (XtArgVal) 3); i++;
  382. XtSetArg (setArgs[i], XmNshadowThickness,
  383. (XtArgVal) FRAME_EXTERNAL_SHADOW_WIDTH); i++;
  384. XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,(XtArgVal) XmSTATIC ); i++;
  385. XtSetArg (setArgs[i], XmNvisualPolicy, (XtArgVal) XmVARIABLE ); i++;
  386. pIBD->scrolledWidget = XtCreateManagedWidget ("IBsWindow",
  387. xmScrolledWindowWidgetClass,
  388. pIBD->frameWidget,
  389. (ArgList)setArgs, i);
  390. XtAddCallback(pIBD->scrolledWidget, XmNtraverseObscuredCallback,
  391. (XtCallbackProc) IconScrollVisibleCallback, (caddr_t)NULL);
  392. XtAddEventHandler(pIBD->scrolledWidget,
  393. StructureNotifyMask,
  394. False,
  395. (XtEventHandler)UpdateIncrements,
  396. (XtPointer) pIBD);
  397. } /* END OF FUNCTION MakeScrolledWindow */
  398. /*************************************<->*************************************
  399. *
  400. * MakeBulletinBoard (pWS, pIBD)
  401. *
  402. *
  403. * Description:
  404. * -----------
  405. *
  406. *
  407. *
  408. * Inputs:
  409. * ------
  410. * pWS = pointer to workspace data
  411. * pIBD = pointer to IconBoxData
  412. *
  413. * XXinput = ...
  414. *
  415. *
  416. * Outputs:
  417. * -------
  418. *
  419. * Return = pIBD with the pIBD->bBoardWidget
  420. *
  421. *
  422. * Comments:
  423. * --------
  424. * XXComments ...
  425. *
  426. *************************************<->***********************************/
  427. void MakeBulletinBoard (WmWorkspaceData *pWS, IconBoxData *pIBD)
  428. {
  429. int i;
  430. Arg setArgs[20];
  431. /*
  432. * Create bulletin board to hold icons
  433. */
  434. i=0;
  435. #ifdef DEBUG_ICON_BOX
  436. XtSetArg (setArgs[i], XmNborderWidth , 1); i++;
  437. #else
  438. XtSetArg (setArgs[i], XmNborderWidth , 0); i++;
  439. #endif /* DEBUG_ICON_BOX */
  440. XtSetArg (setArgs[i], XmNshadowThickness,(XtArgVal) 0); i++;
  441. XtSetArg (setArgs[i], XmNspacing , 0); i++;
  442. XtSetArg (setArgs[i], XmNmarginHeight , 0); i++;
  443. XtSetArg (setArgs[i], XmNmarginWidth , 0); i++;
  444. XtSetArg (setArgs[i], XmNdialogStyle, (XtArgVal) XmDIALOG_WORK_AREA); i++;
  445. XtSetArg (setArgs[i], XmNresizePolicy, (XtArgVal) XmRESIZE_NONE); i++;
  446. XtSetArg (setArgs[i], XmNdefaultPosition , (XtArgVal) False); i++;
  447. XtSetArg (setArgs[i], XtNinsertPosition , InsertPosition); i++;
  448. pIBD->bBoardWidget = XtCreateManagedWidget ("IBbBoard",
  449. xmBulletinBoardWidgetClass,
  450. pIBD->scrolledWidget,
  451. (ArgList)setArgs, i);
  452. } /* END OF FUNCTION MakeBulletinBoard */
  453. /*************************************<->*************************************
  454. *
  455. * RealizeIconBox (pWS, pIBD, pCD)
  456. *
  457. *
  458. * Description:
  459. * -----------
  460. *
  461. *
  462. *
  463. * Inputs:
  464. * ------
  465. * pWS = pointer to workspace data
  466. *
  467. * pIBD = pointer to IconBoxData
  468. *
  469. * pCD = pointer to ClientData
  470. *
  471. *
  472. * Outputs:
  473. * -------
  474. *
  475. * Return = pIBD with the pIBD->shellWin set
  476. * Return = pIBD with the pIBD->scrolledWin set
  477. * Return = pIBD with the pIBD->bBoardWin set
  478. *
  479. * Return = pCD with appropriate fields set
  480. *
  481. *
  482. * Comments:
  483. * --------
  484. * XXComments ...
  485. *
  486. *************************************<->***********************************/
  487. void RealizeIconBox (WmWorkspaceData *pWS, IconBoxData *pIBD, ClientData *pCD)
  488. {
  489. int i;
  490. Arg getArgs[10];
  491. Arg setArgs[2];
  492. Widget clipWidget;
  493. Pixmap bgPixmap;
  494. Pixmap defaultImage;
  495. XtRealizeWidget (pIBD->shellWidget);
  496. pCD->client = XtWindow (pIBD->shellWidget);
  497. /*
  498. * This will set the scrolling granularity for the icon box
  499. */
  500. SetGeometry (pWS, pCD, pIBD);
  501. /*
  502. * Point to the iconBox
  503. */
  504. pIBD->pCD_iconBox = pCD;
  505. pCD->thisIconBox = pIBD;
  506. /*
  507. * get the background color of the bulletin board for
  508. * greyed icon work
  509. */
  510. i=0;
  511. XtSetArg (setArgs[i], XmNbackground, (XtArgVal) select_color ); i++;
  512. XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
  513. i=0;
  514. XtSetArg (getArgs[i], XmNbackgroundPixmap, (XtArgVal) &bgPixmap ); i++;
  515. XtGetValues (pIBD->bBoardWidget, getArgs, i);
  516. i=0;
  517. XtSetArg (getArgs[i], XmNclipWindow, (XtArgVal) &clipWidget ); i++;
  518. XtGetValues (pIBD->scrolledWidget, getArgs, i);
  519. /*
  520. * Set the background of the clip window for the scrolled
  521. * window so the default widget background doesn't flash
  522. */
  523. i = 0;
  524. XtSetArg(setArgs[i], XmNbackground, (XtArgVal) select_color); i++;
  525. XtSetValues (clipWidget, (ArgList) setArgs, i);
  526. /*
  527. * Save the clipWidget id to use in constraining icon moves in box
  528. */
  529. pIBD->clipWidget = clipWidget;
  530. MakeShrinkWrapIconsGC (pWS->pSD, bgPixmap);
  531. if (pWS->pSD->iconDecoration & ICON_IMAGE_PART)
  532. {
  533. /*
  534. * Make a pixmap to use when iconWindows are unmapped
  535. */
  536. defaultImage = XCreateBitmapFromData (DISPLAY, pWS->pSD->rootWindow,
  537. (char*)iImage_bits, iImage_width,
  538. iImage_height);
  539. pWS->pSD->defaultPixmap = MakeIconPixmap (pCD,
  540. defaultImage,
  541. None, iImage_width,
  542. iImage_height, 1);
  543. }
  544. } /* END OF FUNCTION RealizeIconBox */
  545. /*************************************<->*************************************
  546. *
  547. * AddNewBox (pWS, pIBD)
  548. *
  549. *
  550. * Description:
  551. * -----------
  552. *
  553. *
  554. *
  555. * Inputs:
  556. * ------
  557. * pWS = pointer to workspace data
  558. *
  559. * pIBD = pointer to IconBoxData
  560. *
  561. *
  562. * Outputs:
  563. * -------
  564. *
  565. *
  566. * Comments:
  567. * --------
  568. * Finds the last iconbox on the list starting at pWS->pIconBox and
  569. * adds the new icon box to the end of the list.
  570. *
  571. *************************************<->***********************************/
  572. void AddNewBox (WmWorkspaceData *pWS, IconBoxData *pIBD)
  573. {
  574. IconBoxData *pibd;
  575. if (pWS->pIconBox)
  576. {
  577. pibd = pWS->pIconBox;
  578. while (pibd->pNextIconBox)
  579. {
  580. pibd = pibd->pNextIconBox;
  581. }
  582. pibd->pNextIconBox = pIBD;
  583. }
  584. else
  585. {
  586. pWS->pIconBox = pIBD;
  587. }
  588. } /* END OF FUNCTION AddNewBox */
  589. /*************************************<->*************************************
  590. *
  591. * InitializeIconBoxData (pWS, pIBD)
  592. *
  593. *
  594. * Description:
  595. * -----------
  596. *
  597. *
  598. *
  599. * Inputs:
  600. * ------
  601. * pWS = pointer to Workspace Data
  602. *
  603. * pIBD = pointer to IconBoxData
  604. *
  605. *
  606. * Outputs:
  607. * -------
  608. *
  609. *
  610. * Comments:
  611. * --------
  612. * Initializes all pIBD fields to NULL
  613. *
  614. *************************************<->***********************************/
  615. void InitializeIconBoxData (WmWorkspaceData *pWS, IconBoxData *pIBD)
  616. {
  617. int mask;
  618. int X;
  619. int Y;
  620. unsigned int width;
  621. unsigned int height;
  622. int sW, sH;
  623. frameShadowThickness = FRAME_INTERNAL_SHADOW_WIDTH;
  624. pIBD->numberOfIcons = 0;
  625. pIBD->currentRow = 0;
  626. pIBD->currentCol = 0;
  627. pIBD->lastRow = 0;
  628. pIBD->lastCol = 0;
  629. pIBD->IPD.placeList = NULL;
  630. pIBD->scrolledWidget = NULL;
  631. pIBD->bBoardWidget = NULL;
  632. pIBD->clipWidget = NULL;
  633. pIBD->wsID = pWS->id;
  634. ToLower (pWS->pSD->iconBoxSBDisplayPolicy);
  635. if (!((!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , "all")) ||
  636. (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)) ||
  637. (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))))
  638. {
  639. strcpy(pWS->pSD->iconBoxSBDisplayPolicy, "all");
  640. }
  641. /*
  642. * this will be set by the iconPlacement resource if
  643. * iconBoxGeometry width and height are not specified
  644. */
  645. if (pWS->iconBoxGeometry == NULL) /* not set by user */
  646. {
  647. /*
  648. * Use the iconPlacement resource
  649. */
  650. if (pWS->pSD->iconPlacement &
  651. (ICON_PLACE_TOP_PRIMARY | ICON_PLACE_BOTTOM_PRIMARY))
  652. {
  653. pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
  654. pIBD->IPD.placementCols = 1;
  655. pIBD->IPD.placementRows = 6;
  656. }
  657. else
  658. {
  659. pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
  660. pIBD->IPD.placementCols = 6;
  661. pIBD->IPD.placementRows = 1;
  662. }
  663. }
  664. else
  665. {
  666. mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y,
  667. &width, &height);
  668. if ((mask & WidthValue) && (width > 0))
  669. {
  670. pIBD->IPD.placementCols = (int)width;
  671. }
  672. else
  673. {
  674. pIBD->IPD.placementCols = 6;
  675. }
  676. if ((mask & HeightValue) && (height > 0))
  677. {
  678. pIBD->IPD.placementRows = (int)height;
  679. }
  680. else
  681. {
  682. pIBD->IPD.placementRows = 1;
  683. }
  684. /*
  685. * Set orientation
  686. */
  687. if (pIBD->IPD.placementRows <= pIBD->IPD.placementCols)
  688. {
  689. pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
  690. }
  691. else
  692. {
  693. pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
  694. }
  695. }
  696. /*
  697. * Override orientation if iconBoxSBDisplayPolicy is set to
  698. * horizontal or vertical
  699. */
  700. if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical)))
  701. {
  702. pIBD->IPD.iconPlacement = ICON_PLACE_LEFT_PRIMARY;
  703. }
  704. else if (!(strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal)))
  705. {
  706. pIBD->IPD.iconPlacement = ICON_PLACE_TOP_PRIMARY;
  707. }
  708. /*
  709. * set initial size of placement space to size of screen
  710. */
  711. sW = DisplayWidth (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconWidth;
  712. sH = DisplayHeight (DISPLAY, pWS->pSD->screen) / pWS->pSD->iconHeight;
  713. pIBD->IPD.totalPlaces = sW * sH;
  714. pIBD->IPD.onRootWindow = False;
  715. /*
  716. * The icon box does not live in an icon box in this version
  717. */
  718. pIBD->pNextIconBox =NULL;
  719. } /* END OF FUNCTION InitializeIconBoxData */
  720. /*************************************<->*************************************
  721. *
  722. * SetIconBoxInfo (pWS, pCD)
  723. *
  724. *
  725. * Description:
  726. * -----------
  727. *
  728. * Inputs:
  729. * ------
  730. * pCD
  731. *
  732. *
  733. * Comments:
  734. * --------
  735. *
  736. *************************************<->***********************************/
  737. void SetIconBoxInfo (WmWorkspaceData *pWS, ClientData *pCD)
  738. {
  739. pCD->clientClass = WmCIconBox;
  740. pCD->clientName = pWS->pSD->iconBoxName;
  741. ProcessClientResources (pCD);
  742. } /* END OF FUNCTION SetIconBoxInfo */
  743. /*************************************<->*************************************
  744. *
  745. * InitializeClientData (pCD)
  746. *
  747. *
  748. * Description:
  749. * -----------
  750. *
  751. *
  752. *
  753. * Inputs:
  754. * ------
  755. * pCD
  756. *
  757. *
  758. * Outputs:
  759. * -------
  760. *
  761. *
  762. * Comments:
  763. * --------
  764. * Initializes geometry, etc. fields
  765. *
  766. *************************************<->***********************************/
  767. void InitializeClientData (ClientData *pCD, IconBoxData *pIBD)
  768. {
  769. pCD->internalBevel = (wmGD.frameStyle == WmSLAB) ? 0 :
  770. FRAME_INTERNAL_SHADOW_WIDTH;
  771. pCD->clientX = 0;
  772. pCD->clientY = 0;
  773. pCD->clientFlags |= ICON_BOX ;
  774. pCD->widthInc = pIBD->IPD.iPlaceW = ICON_WIDTH(pCD)
  775. + IB_SPACING
  776. + (2 * IB_MARGIN_WIDTH);
  777. pCD->heightInc = pIBD->IPD.iPlaceH = ICON_HEIGHT(pCD)
  778. + IB_SPACING
  779. + (2 * IB_MARGIN_HEIGHT);
  780. pCD->clientWidth = pIBD->IPD.placementCols * pCD->widthInc;
  781. pCD->clientHeight = pIBD->IPD.placementRows * pCD->heightInc;
  782. if (!(pCD->pSD->iconBoxTitle))
  783. {
  784. #ifndef NO_MESSAGE_CATALOG
  785. pCD->pSD->iconBoxTitle =
  786. XmStringCreateLocalized(wmNLS.default_icon_box_title);
  787. #else
  788. pCD->pSD->iconBoxTitle =
  789. XmStringCreateLocalized(DEFAULT_ICON_BOX_TITLE);
  790. #endif
  791. }
  792. pCD->clientTitle = pCD->pSD->iconBoxTitle;
  793. pCD->iconTitle = pCD->pSD->iconBoxTitle;
  794. } /* END OF FUNCTION InitializeClientData */
  795. /*************************************<->*************************************
  796. *
  797. * MakeShrinkWrapIconsGC (pSD, bgPixmap)
  798. *
  799. *
  800. * Description:
  801. * -----------
  802. * Make an graphic context to shrink the icons in the icon box
  803. * box that are not in the MINIMIZED_STATE.
  804. *
  805. *
  806. * Inputs:
  807. * ------
  808. * pSD - pointer to screen data
  809. *
  810. * Outputs:
  811. * -------
  812. * Modifies global data
  813. *
  814. * Comments:
  815. * --------
  816. *
  817. *
  818. *************************************<->***********************************/
  819. void MakeShrinkWrapIconsGC (WmScreenData *pSD, Pixmap bgPixmap)
  820. {
  821. XtGCMask copyMask;
  822. if (!pSD->shrinkWrapGC)
  823. {
  824. pSD->shrinkWrapGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
  825. (XGCValues *) NULL);
  826. copyMask = ~0L;
  827. XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
  828. copyMask, pSD->shrinkWrapGC);
  829. if (bgPixmap != XmUNSPECIFIED_PIXMAP)
  830. {
  831. XSetTile (DISPLAY, pSD->shrinkWrapGC, bgPixmap);
  832. XSetFillStyle (DISPLAY, pSD->shrinkWrapGC, FillTiled);
  833. XSetBackground (DISPLAY, pSD->shrinkWrapGC, select_color);
  834. }
  835. else
  836. {
  837. XSetForeground (DISPLAY, pSD->shrinkWrapGC, select_color);
  838. }
  839. }
  840. } /* END OF FUNCTION MakeShrinkWrapIconsGC */
  841. /*************************************<->*************************************
  842. *
  843. * MakeFadeIconGC (pSD)
  844. *
  845. *
  846. * Description:
  847. * -----------
  848. * Make an graphic context for "greying" the icons in the icon
  849. * box that are not in the MINIMIZED_STATE.
  850. *
  851. *
  852. * Inputs:
  853. * ------
  854. * pSD = pointer to screen data
  855. *
  856. * Outputs:
  857. * -------
  858. * Modifies global data
  859. *
  860. * Comments:
  861. * --------
  862. *
  863. *
  864. *************************************<->***********************************/
  865. void MakeFadeIconGC (WmScreenData *pSD)
  866. {
  867. XtGCMask copyMask;
  868. static Pixmap tmpFontClipMask;
  869. pSD->fadeIconGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
  870. (XGCValues *) NULL);
  871. pSD->fadeIconTextGC = XCreateGC (DISPLAY, pSD->rootWindow, 0,
  872. (XGCValues *) NULL);
  873. copyMask = ~0L;
  874. XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
  875. copyMask, pSD->fadeIconGC);
  876. XCopyGC (DISPLAY, pSD->iconAppearance.inactiveGC,
  877. copyMask, pSD->fadeIconTextGC);
  878. tmpFontClipMask = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
  879. (char*)greyed75_bits, greyed75_width, greyed75_height);
  880. greyedPixmap = XCreateBitmapFromData (DISPLAY, pSD->rootWindow,
  881. (char*)slant2_bits, slant2_width, slant2_height);
  882. XSetStipple (DISPLAY, pSD->fadeIconTextGC, tmpFontClipMask);
  883. XSetFillStyle (DISPLAY, pSD->fadeIconTextGC, FillStippled);
  884. XSetStipple (DISPLAY, pSD->fadeIconGC, greyedPixmap);
  885. XSetFillStyle (DISPLAY, pSD->fadeIconGC, FillStippled);
  886. XSetForeground (DISPLAY, pSD->fadeIconGC, select_color);
  887. } /* END OF FUNCTION MakeFadeIconGC */
  888. /*************************************<->*************************************
  889. *
  890. * SetGeometry (pWS, pCD, pIBD)
  891. *
  892. *
  893. * Description:
  894. * -----------
  895. *
  896. *
  897. *
  898. * Inputs:
  899. * ------
  900. * pIBD = pointer to IconBoxData
  901. * pCD = pointer to ClientData
  902. * XXinput = ...
  903. *
  904. *
  905. * Outputs:
  906. * -------
  907. *
  908. *
  909. *
  910. *
  911. * Comments:
  912. * --------
  913. * XXComments ...
  914. *
  915. *************************************<->***********************************/
  916. void SetGeometry (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
  917. {
  918. int i;
  919. Arg setArgs[10];
  920. int mask;
  921. int X;
  922. int Y;
  923. unsigned int width;
  924. unsigned int height;
  925. unsigned int boxdim, tmpMin;
  926. int diff;
  927. unsigned long decoration;
  928. /*
  929. * Set horizontal and vertical scrolling granularity
  930. */
  931. SetGranularity (pWS, pCD, pIBD );
  932. /*
  933. * Set the initial width and height of the icon box bulletin board
  934. */
  935. i=0;
  936. XtSetArg (setArgs[i], XmNwidth, (XtArgVal) pCD->clientWidth); i++;
  937. XtSetArg (setArgs[i], XmNheight, (XtArgVal) pCD->clientHeight); i++;
  938. XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
  939. /*
  940. * Adjust icon box window height for height of
  941. * horizontal scroll bar etc.
  942. */
  943. pCD->clientHeight = pCD->clientHeight + pCD->baseHeight;
  944. pCD->oldMaxHeight = pCD->maxHeight = pCD->clientHeight;
  945. /*
  946. * Adjust iconbox window width for width of
  947. * vertical scroll bar etc.
  948. */
  949. pCD->clientWidth = pCD->clientWidth + pCD->baseWidth;
  950. pCD->oldMaxWidth = pCD->maxWidth = pCD->clientWidth;
  951. /*
  952. * Check that minWidth is large enough to disallow overlap
  953. * of title bar gadgets
  954. */
  955. /* compute for minimum frame size */
  956. if ((decoration = pCD->decor) & MWM_DECOR_TITLE)
  957. {
  958. boxdim = InitTitleBarHeight(pCD); /* macro not valid yet */
  959. tmpMin = boxdim +
  960. ((decoration & MWM_DECOR_MENU) ? boxdim : 0) +
  961. ((decoration & MWM_DECOR_MINIMIZE) ? boxdim : 0) +
  962. ((decoration & MWM_DECOR_MAXIMIZE) ? boxdim : 0) -
  963. 2*(pCD->matteWidth);
  964. }
  965. else {
  966. tmpMin = 0;
  967. }
  968. /* Make:
  969. * minWidth >= tmpMin
  970. * minWidth >= max (baseWidth, widthInc) > 0
  971. * & an integral number of widthInc from baseWidth.
  972. */
  973. if (pCD->minWidth < tmpMin)
  974. {
  975. if ((diff = ((tmpMin - pCD->baseWidth)%pCD->widthInc)) != 0)
  976. {
  977. pCD->minWidth = tmpMin + pCD->widthInc - diff;
  978. }
  979. else
  980. {
  981. pCD->minWidth = tmpMin;
  982. }
  983. }
  984. if (pCD->minWidth < pCD->baseWidth)
  985. {
  986. pCD->minWidth = pCD->baseWidth;
  987. }
  988. if (pCD->minWidth == 0)
  989. {
  990. pCD->minWidth = pCD->widthInc;
  991. }
  992. else if ((diff = ((pCD->minWidth - pCD->baseWidth)%pCD->widthInc)) != 0)
  993. {
  994. pCD->minWidth += pCD->widthInc - diff;
  995. }
  996. if (pCD->clientWidth < pCD->minWidth)
  997. {
  998. pCD->clientWidth = pCD->minWidth;
  999. }
  1000. pIBD->IPD.placementCols = (int)((pCD->clientWidth - pCD->baseWidth)
  1001. / pCD->widthInc);
  1002. /*
  1003. * Make:
  1004. *
  1005. * maxWidth >= minWidth
  1006. * & an integral number of widthInc from baseWidth.
  1007. */
  1008. if (pCD->maxWidth < pCD->minWidth)
  1009. {
  1010. pCD->maxWidth = pCD->minWidth;
  1011. }
  1012. pCD->maxWidthLimit = pCD->maxWidth;
  1013. pCD->maxWidth -= ((pCD->maxWidth - pCD->baseWidth)% pCD->widthInc);
  1014. pCD->oldMaxWidth = pCD->maxWidth;
  1015. pCD->maxHeightLimit = pCD->maxHeight;
  1016. /*
  1017. * Set the initial width and height of the icon box bulletin board
  1018. */
  1019. i=0;
  1020. XtSetArg (setArgs[i], XmNwidth, (XtArgVal) pCD->clientWidth
  1021. - pCD->baseWidth ); i++;
  1022. XtSetArg (setArgs[i], XmNheight, (XtArgVal) pCD->clientHeight
  1023. - pCD->baseHeight ); i++;
  1024. XtSetValues (pIBD->bBoardWidget, (ArgList) setArgs, i);
  1025. /*
  1026. * Set the initial width and height of the icon box scrolled Window
  1027. */
  1028. i=0;
  1029. XtSetArg (setArgs[i], XmNwidth, (XtArgVal)
  1030. (pCD->clientWidth - (2 * frameShadowThickness))); i++;
  1031. XtSetArg (setArgs[i], XmNheight, (XtArgVal)
  1032. (pCD->clientHeight - (2 * frameShadowThickness))); i++;
  1033. XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
  1034. /*
  1035. * Call SetFrameInfo with fake X and Y so we can get clientOffset
  1036. */
  1037. pCD->xBorderWidth = 0;
  1038. SetFrameInfo (pCD);
  1039. /*
  1040. * Set initial placement of icon box
  1041. */
  1042. mask = XParseGeometry(pWS->iconBoxGeometry, &X, &Y,
  1043. &width, &height);
  1044. if (mask & XValue)
  1045. {
  1046. if (mask & XNegative)
  1047. {
  1048. pCD->clientX = X
  1049. + DisplayWidth(DISPLAY, SCREEN_FOR_CLIENT(pCD))
  1050. - pCD->clientWidth
  1051. - pCD->clientOffset.x;
  1052. }
  1053. else
  1054. {
  1055. pCD->clientX = X + pCD->clientOffset.x;
  1056. }
  1057. }
  1058. else
  1059. {
  1060. pCD->clientX = pCD->clientOffset.x;
  1061. }
  1062. if (mask & YValue)
  1063. {
  1064. if (mask & YNegative)
  1065. {
  1066. pCD->clientY = Y
  1067. + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD))
  1068. - pCD->clientHeight
  1069. - pCD->clientOffset.x ;
  1070. }
  1071. else
  1072. {
  1073. pCD->clientY = Y + pCD->clientOffset.y;
  1074. }
  1075. }
  1076. else
  1077. {
  1078. pCD->clientY = pCD->clientOffset.x
  1079. + DisplayHeight(DISPLAY, SCREEN_FOR_CLIENT(pCD))
  1080. - pCD->clientHeight;
  1081. }
  1082. PlaceFrameOnScreen (pCD, &pCD->clientX, &pCD->clientY, pCD->clientWidth,
  1083. pCD->clientHeight);
  1084. pCD->clientX -= (wmGD.positionIsFrame
  1085. ? pCD->clientOffset.x
  1086. : 0);
  1087. pCD->clientY -= (wmGD.positionIsFrame
  1088. ? pCD->clientOffset.y
  1089. : 0);
  1090. i=0;
  1091. XtSetArg (setArgs[i], XmNx, (XtArgVal) pCD->clientX); i++;
  1092. XtSetArg (setArgs[i], XmNy, (XtArgVal) pCD->clientY); i++;
  1093. XtSetValues (pIBD->shellWidget, (ArgList) setArgs, i);
  1094. pCD->maxX = pCD->clientX;
  1095. pCD->maxY = pCD->clientY;
  1096. } /* END OF FUNCTION SetGeometry */
  1097. /*************************************<->*************************************
  1098. *
  1099. * SetGranularity (pWS, pCD, pIBD )
  1100. *
  1101. *
  1102. * Description:
  1103. * -----------
  1104. *
  1105. *
  1106. *
  1107. * Inputs:
  1108. * ------
  1109. * pIBD = pointer to IconBoxData
  1110. * pCD = pointer to ClientData
  1111. * XXinput = ...
  1112. *
  1113. *
  1114. * Outputs:
  1115. * -------
  1116. *
  1117. *
  1118. *
  1119. *
  1120. * Comments:
  1121. * --------
  1122. * XXComments ...
  1123. *
  1124. *************************************<->***********************************/
  1125. void SetGranularity (WmWorkspaceData *pWS, ClientData *pCD, IconBoxData *pIBD)
  1126. {
  1127. int i;
  1128. Dimension hScrollBarHeight = 0;
  1129. Dimension hBarHeight = 0;
  1130. Dimension vScrollBarWidth = 0;
  1131. Dimension vBarWidth = 0;
  1132. Dimension spacing;
  1133. short shadowThickness;
  1134. short marginWidth;
  1135. short marginHeight;
  1136. short hShighlightThickness;
  1137. short vShighlightThickness;
  1138. Arg setArgs[10];
  1139. Arg getArgs[10];
  1140. i=0;
  1141. XtSetArg(getArgs[i], XmNspacing, (XtArgVal) &spacing ); i++;
  1142. XtSetArg(getArgs[i], XmNshadowThickness, (XtArgVal) &shadowThickness); i++;
  1143. XtSetArg(getArgs[i], XmNscrolledWindowMarginWidth,
  1144. (XtArgVal) &marginWidth); i++;
  1145. XtSetArg(getArgs[i], XmNscrolledWindowMarginHeight,
  1146. (XtArgVal) &marginHeight); i++;
  1147. XtSetArg (getArgs[i], XmNverticalScrollBar,
  1148. (XtArgVal) &pIBD->vScrollBar); i++;
  1149. XtSetArg(getArgs[i], XmNhorizontalScrollBar,
  1150. (XtArgVal) &pIBD->hScrollBar); i++;
  1151. XtGetValues (pIBD->scrolledWidget, getArgs, i);
  1152. if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
  1153. {
  1154. /*
  1155. * Set horizontal scrolling granularity
  1156. */
  1157. i=0;
  1158. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hBarHeight ); i++;
  1159. XtSetArg (getArgs[i], XmNhighlightThickness,
  1160. (XtArgVal) &hShighlightThickness); i++;
  1161. XtGetValues (pIBD->hScrollBar, getArgs, i);
  1162. i=0;
  1163. XtSetArg(setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
  1164. XtSetArg (setArgs[i], XmNhighlightThickness ,
  1165. IB_HIGHLIGHT_BORDER); i++;
  1166. XtSetArg(setArgs[i], XmNheight,
  1167. (XtArgVal) (hBarHeight - (2 * hShighlightThickness)) +
  1168. (2 * IB_HIGHLIGHT_BORDER)); i++;
  1169. XtSetValues (pIBD->hScrollBar, (ArgList) setArgs, i);
  1170. /*
  1171. * Get hScrollBarHeight and troughColor
  1172. */
  1173. i=0;
  1174. XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
  1175. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &hScrollBarHeight ); i++;
  1176. XtGetValues (pIBD->hScrollBar, getArgs, i);
  1177. }
  1178. if (strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
  1179. {
  1180. /*
  1181. * Set vertical scrolling granularity
  1182. */
  1183. i=0;
  1184. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vBarWidth ); i++;
  1185. XtSetArg (getArgs[i], XmNhighlightThickness,
  1186. (XtArgVal) &vShighlightThickness); i++;
  1187. XtGetValues (pIBD->vScrollBar, getArgs, i);
  1188. i=0;
  1189. XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
  1190. XtSetArg (setArgs[i], XmNhighlightThickness ,
  1191. IB_HIGHLIGHT_BORDER); i++;
  1192. XtSetArg(setArgs[i], XmNwidth,
  1193. (XtArgVal) (vBarWidth - (2 * vShighlightThickness)) +
  1194. (2 * IB_HIGHLIGHT_BORDER)); i++;
  1195. XtSetValues (pIBD->vScrollBar, (ArgList) setArgs, i);
  1196. /*
  1197. * Get vScrollBarWidth
  1198. */
  1199. i=0;
  1200. XtSetArg (getArgs[i], XmNtroughColor, (XtArgVal) &select_color ); i++;
  1201. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &vScrollBarWidth ); i++;
  1202. XtGetValues (pIBD->vScrollBar, getArgs, i);
  1203. }
  1204. if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szvertical))
  1205. {
  1206. XtUnmanageChild(pIBD->hScrollBar);
  1207. hScrollBarHeight = 0;
  1208. i=0;
  1209. XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,
  1210. (XtArgVal) XmAS_NEEDED ); i++;
  1211. XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
  1212. }
  1213. else if (!strcmp(pWS->pSD->iconBoxSBDisplayPolicy , szhorizontal))
  1214. {
  1215. XtUnmanageChild(pIBD->vScrollBar);
  1216. vScrollBarWidth = 0;
  1217. i=0;
  1218. XtSetArg (setArgs[i], XmNscrollBarDisplayPolicy,
  1219. (XtArgVal) XmAS_NEEDED ); i++;
  1220. XtSetValues (pIBD->scrolledWidget, (ArgList) setArgs, i);
  1221. }
  1222. pCD->baseWidth = IB_SPACING
  1223. + 2 * IB_HIGHLIGHT_BORDER
  1224. #ifdef DEBUG_ICON_BOX
  1225. + 2
  1226. + spacing
  1227. #endif /* DEBUG_ICON_BOX */
  1228. + (int) vScrollBarWidth
  1229. + 2 * frameShadowThickness
  1230. + (int) 2 * marginWidth
  1231. + (marginWidth > 0
  1232. ? 2 * (int) shadowThickness
  1233. : shadowThickness);
  1234. pCD->baseHeight = IB_SPACING
  1235. + 2 * IB_HIGHLIGHT_BORDER
  1236. #ifdef DEBUG_ICON_BOX
  1237. + 2
  1238. #endif /* DEBUG_ICON_BOX */
  1239. + spacing
  1240. + (int) hScrollBarHeight
  1241. + 2 * frameShadowThickness
  1242. + (int) 2 * marginHeight
  1243. + (marginHeight > 0
  1244. ? 2 * (int) shadowThickness
  1245. : shadowThickness);
  1246. pCD->minWidth = pCD->baseWidth + pCD->widthInc;
  1247. pCD->minHeight = pCD->baseHeight + pCD->heightInc;
  1248. pCD->oldMaxWidth = pCD->maxWidth = pCD->minWidth;
  1249. pCD->oldMaxHeight = pCD->maxHeight = pCD->minHeight;
  1250. } /* END OF FUNCTION SetGranularity */
  1251. /*************************************<->*************************************
  1252. *
  1253. * GetIconBoxMenuItems ()
  1254. *
  1255. *
  1256. * Description:
  1257. * -----------
  1258. * XXDescription ...
  1259. *
  1260. *************************************<->***********************************/
  1261. MenuItem *GetIconBoxMenuItems (WmScreenData *pSD)
  1262. {
  1263. return(ParseMwmMenuStr (pSD,
  1264. (unsigned char *)((char *)GETMESSAGE(36, 3, "\"Pack Icons\" _P Alt Shift<Key>F7 f.pack_icons\n"))));
  1265. } /* END OF FUNCTION GetIconBoxMenuItems */
  1266. /*************************************<->*************************************
  1267. *
  1268. * MapIconBoxes ()
  1269. *
  1270. *
  1271. * Description:
  1272. * -----------
  1273. *
  1274. *
  1275. *
  1276. * Inputs:
  1277. * ------
  1278. *
  1279. *
  1280. * Outputs:
  1281. * -------
  1282. *
  1283. *
  1284. * Comments:
  1285. * --------
  1286. * Maps all iconboxes on the list starting at pWS->pIconBox
  1287. *
  1288. *************************************<->***********************************/
  1289. void MapIconBoxes (WmWorkspaceData *pWS)
  1290. {
  1291. IconBoxData *pibd;
  1292. if (pWS->pIconBox)
  1293. {
  1294. pibd = pWS->pIconBox;
  1295. while (pibd)
  1296. {
  1297. XtPopup(pibd->shellWidget, XtGrabNone);
  1298. pibd = pibd->pNextIconBox;
  1299. }
  1300. }
  1301. } /* END OF FUNCTION MapIconBoxes */
  1302. /*************************************<->*************************************
  1303. *
  1304. * UnmapIconBoxes (pWS)
  1305. *
  1306. *
  1307. * Description:
  1308. * -----------
  1309. * Unmaps all the iconboxes in the specified workspace
  1310. *
  1311. *
  1312. * Inputs:
  1313. * ------
  1314. * pWS = pointer to workspace data
  1315. *
  1316. * Outputs:
  1317. * -------
  1318. *
  1319. *
  1320. * Comments:
  1321. * --------
  1322. * Unmaps all iconboxes on the list starting at pWS->pIconBox
  1323. * Does not do anything with icon windows.
  1324. *
  1325. *************************************<->***********************************/
  1326. void UnmapIconBoxes (WmWorkspaceData *pWS)
  1327. {
  1328. IconBoxData *pibd;
  1329. if (pWS->pIconBox)
  1330. {
  1331. pibd = pWS->pIconBox;
  1332. while (pibd)
  1333. {
  1334. XUnmapWindow (DISPLAY, pibd->pCD_iconBox->clientFrameWin);
  1335. pibd = pibd->pNextIconBox;
  1336. }
  1337. }
  1338. } /* END OF FUNCTION UnmapIconBoxes */
  1339. /******************************<->*************************************
  1340. *
  1341. * IconBoxShowing ()
  1342. *
  1343. * Description:
  1344. * -----------
  1345. * Returns True if an icon box tied to a front panel button is
  1346. * showing.
  1347. *
  1348. * Inputs:
  1349. * ------
  1350. * pWS = pointer to workspace data
  1351. * pCW = pointer to control window data (for front panel button )
  1352. *
  1353. * Outputs:
  1354. * -------
  1355. * Return = True if icon box is up, False if it's invisible
  1356. *
  1357. * Comments:
  1358. * --------
  1359. *
  1360. ******************************<->***********************************/
  1361. Boolean
  1362. IconBoxShowing (WmWorkspaceData *pWS)
  1363. {
  1364. Boolean rval = False;
  1365. if (pWS->pIconBox &&
  1366. ClientInWorkspace (pWS, pWS->pIconBox->pCD_iconBox))
  1367. {
  1368. rval = True;
  1369. }
  1370. return (rval);
  1371. } /* END OF FUNCTION IconBoxShowing */
  1372. /******************************<->*************************************
  1373. *
  1374. * IconBoxPopUp (pWS, pCW, up)
  1375. *
  1376. * Description:
  1377. * -----------
  1378. * Sets the state of the icon box attached to a front panel control.
  1379. *
  1380. * Inputs:
  1381. * ------
  1382. * pWS = pointer to workspace data
  1383. * pCW = pointer to control window data (for front panel button )
  1384. * up = flag, if True, pop the icon box up; if False, hide it.
  1385. *
  1386. * Outputs:
  1387. * -------
  1388. * None
  1389. *
  1390. * Comments:
  1391. * --------
  1392. *
  1393. ******************************<->***********************************/
  1394. void
  1395. IconBoxPopUp (WmWorkspaceData *pWS, Boolean up)
  1396. {
  1397. IconBoxData *pibd;
  1398. if (pWS->pIconBox)
  1399. {
  1400. pibd = pWS->pIconBox;
  1401. while (pibd)
  1402. {
  1403. if (up)
  1404. {
  1405. if (ClientInWorkspace(pWS, pibd->pCD_iconBox))
  1406. {
  1407. F_Raise (NULL, pibd->pCD_iconBox, (XEvent *)NULL);
  1408. }
  1409. else
  1410. {
  1411. AddClientToWorkspaces (pibd->pCD_iconBox,
  1412. &pWS->id, 1);
  1413. return;
  1414. }
  1415. }
  1416. else if (!up && ClientInWorkspace (pWS, pibd->pCD_iconBox))
  1417. {
  1418. RemoveClientFromWorkspaces (pibd->pCD_iconBox,
  1419. &pWS->id, 1);
  1420. return;
  1421. }
  1422. pibd = pibd->pNextIconBox;
  1423. }
  1424. }
  1425. } /* END OF FUNCTION IconBoxPopUp */
  1426. /******************************<->*************************************
  1427. *
  1428. * InsertIconIntoBox
  1429. *
  1430. * Inputs
  1431. * ------
  1432. * pCD - pointer to data for client to insert
  1433. *
  1434. * Description:
  1435. * -----------
  1436. * XXDescription ...
  1437. *
  1438. *************************************<->***********************************/
  1439. Boolean InsertIconIntoBox (IconBoxData *pIBD, ClientData *pCD)
  1440. {
  1441. Boolean rval = False;
  1442. Arg setArgs[20];
  1443. int i;
  1444. int iconWidth, iconHeight;
  1445. IconBoxData *tmpPointerToIconBox;
  1446. Widget iconWidget;
  1447. IconInfo *pIconInfo;
  1448. static XmString dummyString = NULL;
  1449. WsClientData *pWsc;
  1450. WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
  1451. pWsc = GetWsClientData (pWS, pCD);
  1452. /*
  1453. * If we go to multiple icon boxes, find the box this client
  1454. * wants to live in. For now, we only have one, so point to
  1455. * the first one.
  1456. */
  1457. tmpPointerToIconBox = pIBD;
  1458. if (pCD->client)
  1459. {
  1460. pWsc->pIconBox = tmpPointerToIconBox;
  1461. iconWidth = ICON_WIDTH(pCD)
  1462. + (2 * IB_MARGIN_WIDTH);
  1463. iconHeight = ICON_HEIGHT(pCD)
  1464. + (2 * IB_MARGIN_HEIGHT);
  1465. pIconInfo = InsertIconInfo (pWsc->pIconBox, pCD, (Widget) NULL);
  1466. if (pIconInfo)
  1467. {
  1468. pWsc->pIconBox->numberOfIcons++;
  1469. i = 0;
  1470. XtSetArg (setArgs[i], XmNbackground,
  1471. (XtArgVal) ICON_APPEARANCE(pCD).background ); i++;
  1472. XtSetArg (setArgs[i], XmNforeground,
  1473. (XtArgVal) ICON_APPEARANCE(pCD).foreground ); i++;
  1474. XtSetArg (setArgs[i], XmNx , (XtArgVal) pWsc->iconX); i++;
  1475. XtSetArg (setArgs[i], XmNy , (XtArgVal) pWsc->iconY); i++;
  1476. XtSetArg (setArgs[i], XmNwidth , (XtArgVal) iconWidth); i++;
  1477. XtSetArg (setArgs[i], XmNheight , (XtArgVal) iconHeight); i++;
  1478. XtSetArg (setArgs[i], XmNborderWidth , (XtArgVal) 0); i++;
  1479. XtSetArg (setArgs[i], XmNhighlightThickness ,
  1480. IB_HIGHLIGHT_BORDER); i++;
  1481. XtSetArg (setArgs[i], XmNmarginHeight , (XtArgVal) 0); i++;
  1482. XtSetArg (setArgs[i], XmNmarginWidth , (XtArgVal) 0); i++;
  1483. /*
  1484. * Use type XmString so we don't get a message from XmLabel
  1485. */
  1486. XtSetArg (setArgs[i], XmNlabelType, (XtArgVal) XmSTRING); i++;
  1487. XtSetArg (setArgs[i], XmNrecomputeSize, (XtArgVal) False); i++;
  1488. XtSetArg (setArgs[i], XmNtraversalOn, (XtArgVal) True); i++;
  1489. XtSetArg (setArgs[i], XmNpushButtonEnabled, (XtArgVal) False); i++;
  1490. XtSetArg (setArgs[i], XmNshadowThickness, (XtArgVal) 0); i++;
  1491. iconWidget = XtCreateManagedWidget("iconInIconBox",
  1492. xmDrawnButtonWidgetClass,
  1493. pWsc->pIconBox->bBoardWidget,
  1494. (ArgList)setArgs, i);
  1495. if (dummyString == NULL)
  1496. {
  1497. dummyString =
  1498. XmStringCreateLocalized("");
  1499. }
  1500. i = 0;
  1501. XtSetArg (setArgs[i], XmNlabelString,
  1502. (XtArgVal) dummyString); i++;
  1503. XtSetValues (iconWidget, setArgs, i);
  1504. pIconInfo->theWidget = iconWidget;
  1505. pWsc->iconFrameWin = XtWindow (iconWidget);
  1506. XtAddCallback (iconWidget, XmNactivateCallback,
  1507. (XtCallbackProc)IconActivateCallback,
  1508. (XtPointer)NULL);
  1509. XtAddEventHandler(iconWidget,
  1510. SELECT_BUTTON_MOTION_MASK,
  1511. False,
  1512. (XtEventHandler)HandleIconBoxButtonMotion,
  1513. (XtPointer)NULL);
  1514. XtAddEventHandler(iconWidget,
  1515. DMANIP_BUTTON_MOTION_MASK,
  1516. False,
  1517. (XtEventHandler)HandleIconBoxButtonMotion,
  1518. (XtPointer)NULL);
  1519. XtAddEventHandler(iconWidget,
  1520. KeyPressMask,
  1521. False,
  1522. (XtEventHandler)HandleIconBoxIconKeyPress,
  1523. (XtPointer)NULL);
  1524. if (ICON_DECORATION(pCD) & ICON_ACTIVE_LABEL_PART)
  1525. {
  1526. XtAddEventHandler(iconWidget,
  1527. FocusChangeMask,
  1528. False,
  1529. (XtEventHandler)ChangeActiveIconboxIconText,
  1530. (XtPointer)NULL);
  1531. if (pCD->pSD->activeLabelParent != pCD->pSD->rootWindow)
  1532. {
  1533. XRaiseWindow (DISPLAY, pCD->pSD->activeIconTextWin);
  1534. }
  1535. }
  1536. ResetIconBoxMaxSize(pWsc->pIconBox->pCD_iconBox,
  1537. pWsc->pIconBox->bBoardWidget);
  1538. ResetArrowButtonIncrements (pWsc->pIconBox->pCD_iconBox);
  1539. rval = True;
  1540. }
  1541. }
  1542. return(rval);
  1543. } /* END FUNCTION InsertIconIntoBox() */
  1544. /*************************************<->*************************************
  1545. *
  1546. * InsertIconInfo (pIBD, pCD, theWidget)
  1547. *
  1548. *
  1549. * Description:
  1550. * -----------
  1551. * Finds next available spot and inserts the icon
  1552. *
  1553. *
  1554. * Inputs:
  1555. * ------
  1556. * pIBD - pointer to icon box data
  1557. * pCD - pointer to client data for this client
  1558. * theWidget - widget containing the icon (may be null)
  1559. *
  1560. * Outputs:
  1561. * -------
  1562. *
  1563. * Comments:
  1564. * --------
  1565. *
  1566. *************************************<->***********************************/
  1567. IconInfo *InsertIconInfo (IconBoxData *pIBD, ClientData *pCD, Widget theWidget)
  1568. {
  1569. IconInfo *pII;
  1570. int place;
  1571. int amt, i;
  1572. Arg setArgs[3];
  1573. Arg getArgs[4];
  1574. Dimension clipWidth, clipHeight;
  1575. WsClientData *pWsc;
  1576. place = GetNextIconPlace (&pIBD->IPD);
  1577. if (place == NO_ICON_PLACE)
  1578. {
  1579. if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
  1580. {
  1581. amt = pIBD->IPD.placementCols; /* add a new row */
  1582. }
  1583. else
  1584. {
  1585. amt = pIBD->IPD.placementRows; /* add a new column */
  1586. }
  1587. if (!ExtendIconList (pIBD, amt))
  1588. {
  1589. Warning (((char *)GETMESSAGE(36, 4, "Insufficient memory to create icon box data")));
  1590. return (NULL);
  1591. }
  1592. if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
  1593. {
  1594. pIBD->IPD.placementRows++;
  1595. }
  1596. else
  1597. {
  1598. pIBD->IPD.placementCols++;
  1599. }
  1600. place = GetNextIconPlace (&pIBD->IPD);
  1601. }
  1602. insertPosition = place;
  1603. /*
  1604. * Update icon info values
  1605. */
  1606. pII = &pIBD->IPD.placeList[place];
  1607. pII->theWidget = theWidget;
  1608. pII->pCD = pCD;
  1609. pWsc = GetWsClientData (GetWorkspaceData (pCD->pSD, pIBD->wsID), pCD);
  1610. pWsc->iconPlace = place;
  1611. CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
  1612. &pWsc->iconX, &pWsc->iconY);
  1613. /* update next free position */
  1614. pIBD->currentCol = pWsc->iconX / pIBD->pCD_iconBox->widthInc;
  1615. pIBD->currentRow = pWsc->iconY / pIBD->pCD_iconBox->heightInc;
  1616. /*
  1617. * Increase bboard size if necessary
  1618. */
  1619. i = 0;
  1620. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &clipWidth ); i++;
  1621. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &clipHeight ); i++;
  1622. XtGetValues (pIBD->clipWidget, getArgs, i);
  1623. i = 0;
  1624. if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
  1625. {
  1626. if (pIBD->currentCol > pIBD->lastCol)
  1627. {
  1628. pIBD->lastCol = pIBD->currentCol;
  1629. }
  1630. if (pIBD->currentRow > pIBD->lastRow)
  1631. {
  1632. pIBD->lastRow = pIBD->currentRow;
  1633. if (clipHeight <= (Dimension) (pWsc->iconY +
  1634. pIBD->pCD_iconBox->heightInc))
  1635. {
  1636. /*
  1637. * Increase bulletin board height as needed.
  1638. */
  1639. XtSetArg (setArgs[i], XmNheight, (XtArgVal)
  1640. pWsc->iconY + pIBD->pCD_iconBox->heightInc); i++;
  1641. }
  1642. }
  1643. }
  1644. else
  1645. {
  1646. if (pIBD->currentCol > pIBD->lastCol)
  1647. {
  1648. pIBD->lastCol = pIBD->currentCol;
  1649. if (clipWidth <= (Dimension)
  1650. (pWsc->iconX + pIBD->pCD_iconBox->widthInc))
  1651. {
  1652. /*
  1653. * Increase bulletin board width as needed
  1654. */
  1655. XtSetArg (setArgs[i], XmNwidth,
  1656. (XtArgVal) pWsc->iconX +
  1657. pIBD->pCD_iconBox->widthInc); i++;
  1658. }
  1659. }
  1660. if (pIBD->currentRow > pIBD->lastRow)
  1661. {
  1662. pIBD->lastRow = pIBD->currentRow;
  1663. }
  1664. }
  1665. if (i > 0)
  1666. {
  1667. XtSetValues (pIBD->bBoardWidget, setArgs, i);
  1668. }
  1669. return(pII);
  1670. } /* END OF FUNCTION InsertIconInfo */
  1671. /*************************************<->*************************************
  1672. *
  1673. * DeleteIconFromBox
  1674. *
  1675. *
  1676. * Description:
  1677. * -----------
  1678. * XXDescription ...
  1679. *
  1680. *************************************<->***********************************/
  1681. void DeleteIconFromBox (IconBoxData *pIBD, ClientData *pCD)
  1682. {
  1683. Widget theChild;
  1684. ClientData *pCD_tmp;
  1685. Arg args[4];
  1686. Dimension clipWidth, clipHeight;
  1687. Dimension oldWidth, oldHeight;
  1688. int newWidth, newHeight;
  1689. int i, newCols, newRows;
  1690. WmWorkspaceData *pWS = GetWorkspaceData (pCD->pSD, pIBD->wsID);
  1691. WsClientData *pWsc;
  1692. pWsc = GetWsClientData (pWS, pCD);
  1693. i = 0;
  1694. XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
  1695. XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
  1696. XtGetValues (pIBD->bBoardWidget, args, i);
  1697. i = 0;
  1698. XtSetArg (args[i], XmNwidth, (XtArgVal) &clipWidth); i++;
  1699. XtSetArg (args[i], XmNheight, (XtArgVal) &clipHeight ); i++;
  1700. XtGetValues (pIBD->clipWidget, args, i);
  1701. clipHeight /= (Dimension) pIBD->pCD_iconBox->heightInc;
  1702. clipWidth /= (Dimension) pIBD->pCD_iconBox->widthInc;
  1703. /*
  1704. * find context of the activeIconTextWin to get pCD and then
  1705. * if it is the same as this client, hide it.
  1706. */
  1707. if (!(XFindContext (DISPLAY, pCD->pSD->activeIconTextWin,
  1708. wmGD.windowContextType, (caddr_t *)&pCD_tmp)))
  1709. {
  1710. if (pCD == pCD_tmp)
  1711. {
  1712. /* hide activeIconTextWin */
  1713. HideActiveIconText ((WmScreenData *)NULL);
  1714. }
  1715. }
  1716. DeleteIconInfo (pWsc->pIconBox, pCD);
  1717. pWsc->pIconBox->numberOfIcons--;
  1718. theChild = XtWindowToWidget (DISPLAY, pWsc->iconFrameWin);
  1719. pWsc->pIconBox = NULL;
  1720. pWsc->iconPlace = NO_ICON_PLACE;
  1721. XtUnmanageChild (theChild);
  1722. XtDestroyWidget (theChild);
  1723. /* update last row and col */
  1724. SetNewBounds (pIBD);
  1725. /* resize Bulletin board (so scroll bars show correctly */
  1726. i = 0;
  1727. if (clipWidth <= (Dimension) (pIBD->lastCol + 1))
  1728. {
  1729. newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
  1730. XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
  1731. newCols = newWidth / pIBD->pCD_iconBox->widthInc;
  1732. }
  1733. else
  1734. {
  1735. newWidth = clipWidth * pIBD->pCD_iconBox->widthInc;
  1736. XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
  1737. newCols = newWidth / pIBD->pCD_iconBox->widthInc;
  1738. }
  1739. if (clipHeight <= (Dimension) (pIBD->lastRow + 1))
  1740. {
  1741. /* set height of bboard */
  1742. newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
  1743. XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
  1744. newRows = newHeight / pIBD->pCD_iconBox->heightInc;
  1745. }
  1746. else
  1747. {
  1748. newHeight = clipHeight * pIBD->pCD_iconBox->heightInc;
  1749. XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
  1750. newRows = newHeight / pIBD->pCD_iconBox->heightInc;
  1751. }
  1752. if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
  1753. {
  1754. XtSetValues (pIBD->bBoardWidget, args, i);
  1755. RealignIconList (pIBD, newCols, newRows);
  1756. pIBD->IPD.placementCols = newCols;
  1757. pIBD->IPD.placementRows = newRows;
  1758. }
  1759. /* reset max size for icon box */
  1760. ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
  1761. ResetArrowButtonIncrements (pIBD->pCD_iconBox);
  1762. } /* END FUNCTION DeleteIconFromBox */
  1763. /*************************************<->*************************************
  1764. *
  1765. * DeleteIconInfo (pIBD, pCD)
  1766. *
  1767. *
  1768. * Description:
  1769. * -----------
  1770. * Deletes an icon info record from the icon box list based on the
  1771. * client data pointer.
  1772. *
  1773. *
  1774. * Inputs:
  1775. * ------
  1776. * pIBD - pointer to icon box data
  1777. * pCD - pointer to client data
  1778. *
  1779. * Outputs:
  1780. * -------
  1781. *
  1782. *
  1783. * Comments:
  1784. * --------
  1785. * o The deleted item is freed
  1786. * o Is pCD the correct key???? !!!
  1787. *
  1788. *************************************<->***********************************/
  1789. void DeleteIconInfo (IconBoxData *pIBD, ClientData *pCD)
  1790. {
  1791. int ix, count;
  1792. IconInfo *pII;
  1793. /* find first matching entry in list */
  1794. pII = &pIBD->IPD.placeList[0];
  1795. count = pIBD->IPD.totalPlaces;
  1796. for (ix = 0; ix < count && pII->pCD != pCD; ix++, pII++)
  1797. {
  1798. }
  1799. if (ix < count)
  1800. {
  1801. /* found it, zero the entry out */
  1802. pII->theWidget = NULL;
  1803. pII->pCD = NULL;
  1804. }
  1805. } /* END FUNCTION DeleteIconInfo */
  1806. /*************************************<->*************************************
  1807. *
  1808. * ResetIconBoxMaxSize(pCD, bBoardWidget)
  1809. *
  1810. *
  1811. * Description:
  1812. * -----------
  1813. * XXDescription ...
  1814. *
  1815. *************************************<->***********************************/
  1816. void ResetIconBoxMaxSize (ClientData *pCD, Widget bBoardWidget)
  1817. {
  1818. int i;
  1819. Arg getArgs[3];
  1820. Dimension newWidth;
  1821. Dimension newHeight;
  1822. i=0;
  1823. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &newWidth ); i++;
  1824. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &newHeight ); i++;
  1825. XtGetValues (bBoardWidget, getArgs, i);
  1826. pCD->oldMaxWidth = pCD->maxWidth = newWidth + pCD->baseWidth;
  1827. pCD->oldMaxHeight = pCD->maxHeight = newHeight + pCD->baseHeight;
  1828. pCD->maxX = pCD->clientX;
  1829. pCD->maxY = pCD->clientY;
  1830. PlaceFrameOnScreen (pCD, &pCD->maxX, &pCD->maxY,
  1831. pCD->maxWidth, pCD->maxHeight);
  1832. } /* END OF FUNCTION ResetIconBoxMaxSize */
  1833. /*************************************<->*************************************
  1834. *
  1835. * CheckIconBoxSize(pIBD)
  1836. *
  1837. *
  1838. * Description:
  1839. * -----------
  1840. * XXDescription ...
  1841. *
  1842. *************************************<->***********************************/
  1843. Boolean CheckIconBoxSize (IconBoxData *pIBD)
  1844. {
  1845. int i;
  1846. Arg getArgs[3];
  1847. Arg setArgs[3];
  1848. Dimension oldWidth;
  1849. Dimension oldHeight;
  1850. Dimension newWidth;
  1851. Dimension newHeight;
  1852. int oldCol, oldRow;
  1853. Boolean rval = True;
  1854. i=0;
  1855. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
  1856. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
  1857. XtGetValues (pIBD->bBoardWidget, getArgs, i);
  1858. newWidth = oldWidth;
  1859. newHeight = oldHeight;
  1860. oldCol = oldWidth / (Dimension) pIBD->pCD_iconBox->widthInc;
  1861. oldRow = oldHeight / (Dimension) pIBD->pCD_iconBox->heightInc;
  1862. /*
  1863. * Increase bboard size if necessary
  1864. */
  1865. i = 0;
  1866. if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
  1867. {
  1868. if (oldRow < pIBD->lastRow + 1)
  1869. {
  1870. /*
  1871. * increase bulletin board height as needed
  1872. */
  1873. newHeight = (pIBD->lastRow * pIBD->pCD_iconBox->heightInc)
  1874. + pIBD->pCD_iconBox->heightInc;
  1875. XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight); i++;
  1876. }
  1877. }
  1878. else
  1879. {
  1880. if (oldCol < pIBD->lastCol + 1)
  1881. {
  1882. /*
  1883. * increase bulletin board width as needed
  1884. */
  1885. newWidth = (pIBD->lastCol * pIBD->pCD_iconBox->widthInc)
  1886. + pIBD->pCD_iconBox->widthInc;
  1887. XtSetArg (setArgs[i], XmNwidth, newWidth); i++;
  1888. }
  1889. }
  1890. if (i > 0)
  1891. {
  1892. if (! ExpandVirtualSpace(pIBD, newWidth, newHeight))
  1893. {
  1894. /*
  1895. * The user has resized the iconbox larger than
  1896. * memory will allow. Don't honor the resize request
  1897. */
  1898. rval = False;
  1899. return(rval);
  1900. }
  1901. XtSetValues (pIBD->bBoardWidget, setArgs, i);
  1902. }
  1903. ResetIconBoxMaxSize(pIBD->pCD_iconBox, pIBD->bBoardWidget);
  1904. return(rval);
  1905. } /* END OF FUNCTION CheckIconBoxSize */
  1906. /*************************************<->*************************************
  1907. *
  1908. * CheckIconBoxResize(pCD, changedValues)
  1909. *
  1910. *
  1911. * Description:
  1912. * -----------
  1913. * XXDescription ...
  1914. *
  1915. *************************************<->***********************************/
  1916. void CheckIconBoxResize (ClientData *pCD, unsigned int changedValues, int newWidth, int newHeight)
  1917. {
  1918. Boolean packVert = False;
  1919. Boolean packHorz = False;
  1920. WmScreenData *pSD;
  1921. IconBoxData *pIBD;
  1922. IconPlacementData *pIPD;
  1923. int i, newCols, newRows;
  1924. Arg getArgs[3];
  1925. Arg setArgs[3];
  1926. Dimension oldWidth;
  1927. Dimension oldHeight;
  1928. pIPD = &pCD->thisIconBox->IPD;
  1929. pIBD = pCD->thisIconBox;
  1930. pSD = &(wmGD.Screens[SCREEN_FOR_CLIENT(pCD)]);
  1931. i=0;
  1932. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
  1933. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &oldHeight ); i++;
  1934. XtGetValues (pIBD->bBoardWidget, getArgs, i);
  1935. newCols = pIPD->placementCols;
  1936. newRows = pIPD->placementRows;
  1937. newWidth = newWidth - pCD->baseWidth;
  1938. newHeight = newHeight - pCD->baseHeight;
  1939. i = 0;
  1940. if (changedValues & CWWidth)
  1941. {
  1942. /*
  1943. * There was a change in Width, see if we need to change the
  1944. * bulletin board
  1945. */
  1946. if (newWidth > (int) oldWidth)
  1947. {
  1948. newCols = newWidth / pCD->widthInc;
  1949. XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
  1950. }
  1951. if (newWidth < (int) oldWidth)
  1952. {
  1953. if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szvertical)) &&
  1954. (newWidth / pCD->widthInc < pIBD->lastCol + 1))
  1955. {
  1956. XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
  1957. newCols = newWidth / pCD->widthInc;
  1958. packVert = True;
  1959. }
  1960. else if (newWidth / pCD->widthInc < pIBD->lastCol + 1)
  1961. {
  1962. newWidth = (pIBD->lastCol +1) * pCD->widthInc;
  1963. XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
  1964. }
  1965. else
  1966. {
  1967. newCols = newWidth / pCD->widthInc;
  1968. XtSetArg (setArgs[i], XmNwidth, (XtArgVal) newWidth ); i++;
  1969. }
  1970. }
  1971. }
  1972. else
  1973. {
  1974. newWidth = oldWidth;
  1975. }
  1976. if (changedValues & CWHeight)
  1977. {
  1978. /*
  1979. * There was a change in Height, see if we need to change the
  1980. * bulletin board
  1981. */
  1982. if (newHeight > (int) oldHeight)
  1983. {
  1984. newRows = newHeight / pCD->heightInc;
  1985. XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
  1986. }
  1987. if (newHeight < (int) oldHeight)
  1988. {
  1989. if ((!strcmp(pSD->iconBoxSBDisplayPolicy, szhorizontal)) &&
  1990. (newHeight / pCD->heightInc < pIBD->lastRow + 1))
  1991. {
  1992. XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
  1993. newRows = newHeight / pCD->heightInc;
  1994. packHorz = True;
  1995. }
  1996. else if (newHeight / pCD->heightInc < pIBD->lastRow + 1)
  1997. {
  1998. newHeight = (pIBD->lastRow + 1) * pCD->heightInc;
  1999. XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
  2000. }
  2001. else
  2002. {
  2003. newRows = newHeight / pCD->heightInc;
  2004. XtSetArg (setArgs[i], XmNheight, (XtArgVal) newHeight ); i++;
  2005. }
  2006. }
  2007. }
  2008. else
  2009. {
  2010. newHeight = oldHeight;
  2011. }
  2012. if ( i >0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
  2013. {
  2014. XtSetValues (pIBD->bBoardWidget, setArgs, i);
  2015. }
  2016. RealignIconList (pIBD, newCols, newRows);
  2017. pIPD->placementCols = newCols;
  2018. pIPD->placementRows = newRows;
  2019. ResetIconBoxMaxSize(pCD, pIBD->bBoardWidget);
  2020. /*
  2021. * Pack the icon box if there are icons that can no longer
  2022. * be scrolled to due to iconBoxSBDisplayPolicy.
  2023. */
  2024. if (packVert)
  2025. {
  2026. PackIconBox (pIBD, packVert, False , newWidth, 0);
  2027. }
  2028. else if (packHorz)
  2029. {
  2030. PackIconBox (pIBD, False, packHorz , 0, newHeight);
  2031. }
  2032. } /* END OF FUNCTION CheckIconBoxResize */
  2033. /*************************************<->*************************************
  2034. *
  2035. * ExpandVirtualSpace (pIBD, newWidth, newHeight)
  2036. *
  2037. *
  2038. * Description:
  2039. * -----------
  2040. * Add virtural space (really the icon list )
  2041. *
  2042. *
  2043. * Inputs:
  2044. * ------
  2045. * pIBD - ptr to icon box data
  2046. *
  2047. *
  2048. * Outputs:
  2049. * -------
  2050. * Return - True if successful, False otherwise
  2051. *
  2052. * Comments:
  2053. * --------
  2054. *
  2055. *************************************<->***********************************/
  2056. Boolean ExpandVirtualSpace (IconBoxData *pIBD, int newWidth, int newHeight)
  2057. {
  2058. Boolean rval = True;
  2059. int newSize;
  2060. int increment;
  2061. newSize = (newWidth / pIBD->pCD_iconBox->widthInc) *
  2062. (newHeight / pIBD->pCD_iconBox->heightInc);
  2063. if (newSize > pIBD->IPD.totalPlaces )
  2064. {
  2065. increment = newSize - pIBD->IPD.totalPlaces;
  2066. rval = ExtendIconList (pIBD, increment);
  2067. }
  2068. return (rval);
  2069. } /* END OF FUNCTION ExpandVirtualSpace */
  2070. /*************************************<->*************************************
  2071. *
  2072. * ExtendIconList (pIBD, incr);
  2073. *
  2074. *
  2075. * Description:
  2076. * -----------
  2077. * Add space to the icon list
  2078. *
  2079. *
  2080. * Inputs:
  2081. * ------
  2082. * pIBD - ptr to icon box data
  2083. * incr - number of cells to add
  2084. *
  2085. *
  2086. * Outputs:
  2087. * -------
  2088. * Return - True if successful, False otherwise
  2089. *
  2090. * Comments:
  2091. * --------
  2092. *
  2093. *************************************<->***********************************/
  2094. Boolean ExtendIconList (IconBoxData *pIBD, int incr)
  2095. {
  2096. Boolean rval;
  2097. int newSize;
  2098. IconInfo *pTmp;
  2099. newSize = pIBD->IPD.totalPlaces + incr;
  2100. if ((pTmp = (IconInfo *) XtMalloc (newSize*sizeof(IconInfo))) != NULL)
  2101. {
  2102. /* copy data */
  2103. memcpy (pTmp, pIBD->IPD.placeList,
  2104. pIBD->IPD.totalPlaces*sizeof(IconInfo));
  2105. memset (&pTmp[pIBD->IPD.totalPlaces], 0, incr*sizeof(IconInfo));
  2106. /* out with the old, in with the new */
  2107. XtFree ((char *)pIBD->IPD.placeList);
  2108. pIBD->IPD.placeList = pTmp;
  2109. pIBD->IPD.totalPlaces = newSize;
  2110. rval = True;
  2111. }
  2112. else
  2113. {
  2114. rval = False;
  2115. }
  2116. return (rval);
  2117. } /* END OF FUNCTION ExtendIconList */
  2118. /*************************************<->*************************************
  2119. *
  2120. * PackIconBox(pIBD, packVert, packHorz, passedInWidth, passedInHeight)
  2121. *
  2122. *
  2123. * Description:
  2124. * -----------
  2125. * Packs the icons in the icon box
  2126. *
  2127. *
  2128. * Inputs:
  2129. * ------
  2130. * pIBD - pointer to icon box data
  2131. *
  2132. *
  2133. * Outputs:
  2134. * -------
  2135. *
  2136. *
  2137. * Comments:
  2138. * --------
  2139. *
  2140. *************************************<->***********************************/
  2141. void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int passedInWidth, int passedInHeight)
  2142. {
  2143. IconInfo *pII_2, *pII_1;
  2144. int ix1, ix2;
  2145. int count;
  2146. int newX, newY;
  2147. ClientData *pCD_tmp = NULL, *pMyCD;
  2148. int hasActiveText = 1;
  2149. Arg args[4];
  2150. Dimension majorDimension, minorDimension;
  2151. Dimension oldWidth, oldHeight;
  2152. int newWidth, newHeight;
  2153. int i;
  2154. Boolean rippling = False;
  2155. WsClientData *pWsc;
  2156. WmWorkspaceData *pWS;
  2157. i = 0;
  2158. XtSetArg (args[i], XmNwidth, (XtArgVal) &oldWidth ); i++;
  2159. XtSetArg (args[i], XmNheight, (XtArgVal) &oldHeight ); i++;
  2160. XtGetValues (pIBD->bBoardWidget, args, i);
  2161. /*
  2162. * packing to visual space, first update IconBoxData
  2163. */
  2164. i = 0;
  2165. if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
  2166. {
  2167. XtSetArg (args[i], XmNwidth, (XtArgVal) &majorDimension ); i++;
  2168. XtSetArg (args[i], XmNheight, (XtArgVal) &minorDimension ); i++;
  2169. XtGetValues (pIBD->clipWidget, args, i);
  2170. if (packVert)
  2171. {
  2172. majorDimension = passedInWidth;
  2173. }
  2174. minorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
  2175. majorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
  2176. if (majorDimension != pIBD->IPD.placementCols)
  2177. {
  2178. pIBD->IPD.placementCols = majorDimension;
  2179. }
  2180. }
  2181. else
  2182. {
  2183. XtSetArg (args[i], XmNheight, (XtArgVal) &majorDimension ); i++;
  2184. XtSetArg (args[i], XmNwidth, (XtArgVal) &minorDimension ); i++;
  2185. XtGetValues (pIBD->clipWidget, args, i);
  2186. if (packHorz)
  2187. {
  2188. majorDimension = passedInHeight;
  2189. }
  2190. minorDimension /= (Dimension) pIBD->pCD_iconBox->widthInc;
  2191. majorDimension /= (Dimension) pIBD->pCD_iconBox->heightInc;
  2192. if (majorDimension != pIBD->IPD.placementRows)
  2193. {
  2194. pIBD->IPD.placementRows = majorDimension;
  2195. }
  2196. }
  2197. /*
  2198. * find context of the activeIconTextWin to get pCD and then
  2199. * if it is the same as this client, hide it.
  2200. */
  2201. pMyCD = pIBD->pCD_iconBox;
  2202. if (ICON_DECORATION(pMyCD) & ICON_ACTIVE_LABEL_PART)
  2203. {
  2204. if (XFindContext (DISPLAY, pMyCD->pSD->activeIconTextWin,
  2205. wmGD.windowContextType, (caddr_t *)&pCD_tmp))
  2206. {
  2207. hasActiveText = 0;
  2208. }
  2209. }
  2210. pII_2 = pII_1 = pIBD->IPD.placeList;
  2211. ix1 = ix2 = 0;
  2212. count = pIBD->IPD.totalPlaces;
  2213. while (ix1 < count)
  2214. {
  2215. if (!rippling && (pII_2->pCD != NULL))
  2216. {
  2217. /*
  2218. * We need to start rippling the icons into new positions if
  2219. * their (x,y) position changed
  2220. */
  2221. pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
  2222. pWsc = GetWsClientData (pWS, pII_2->pCD);
  2223. CvtIconPlaceToPosition (&pIBD->IPD, pWsc->iconPlace,
  2224. &newX, &newY);
  2225. rippling = ((newX != pWsc->iconX) ||
  2226. (newY != pWsc->iconY));
  2227. }
  2228. if ((pII_2->pCD == NULL) || rippling)
  2229. {
  2230. /* find next one to move */
  2231. while ((ix1 < count) && (pII_1->pCD == NULL))
  2232. {
  2233. ix1++;
  2234. pII_1++;
  2235. }
  2236. if ((ix1 < count) && (pII_1->pCD != NULL))
  2237. {
  2238. if (ix1 != ix2)
  2239. {
  2240. MoveIconInfo (&pIBD->IPD, ix1, ix2);
  2241. }
  2242. CvtIconPlaceToPosition (&pIBD->IPD, ix2, &newX, &newY);
  2243. pWS = GetWorkspaceData (pII_2->pCD->pSD, pIBD->wsID);
  2244. pWsc = GetWsClientData (pWS, pII_2->pCD);
  2245. pWsc->iconX = newX;
  2246. pWsc->iconY = newY;
  2247. if (hasActiveText && (pII_2->pCD == pCD_tmp))
  2248. {
  2249. /* hide activeIconTextWin first */
  2250. HideActiveIconText ((WmScreenData *)NULL);
  2251. XtMoveWidget (pII_2->theWidget, newX, newY);
  2252. ShowActiveIconText (pII_2->pCD);
  2253. }
  2254. else
  2255. {
  2256. XtMoveWidget (pII_2->theWidget, newX, newY);
  2257. }
  2258. }
  2259. }
  2260. if (ix1 < count)
  2261. {
  2262. ix2++;
  2263. pII_2++;
  2264. }
  2265. ix1++;
  2266. pII_1++;
  2267. }
  2268. /* update last row and col */
  2269. SetNewBounds (pIBD);
  2270. /* resize Bulletin board (so scroll bars show correctly */
  2271. i = 0;
  2272. if (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)
  2273. {
  2274. if (majorDimension <= (Dimension) (pIBD->lastCol + 1))
  2275. {
  2276. newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
  2277. XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
  2278. }
  2279. else
  2280. {
  2281. newWidth = oldWidth;
  2282. }
  2283. if (minorDimension <= (Dimension) (pIBD->lastRow + 1))
  2284. {
  2285. /* set height of bboard */
  2286. newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
  2287. XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
  2288. }
  2289. else
  2290. {
  2291. newHeight = minorDimension * pIBD->pCD_iconBox->heightInc;
  2292. XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
  2293. }
  2294. }
  2295. else
  2296. {
  2297. if (majorDimension <= (Dimension) (pIBD->lastRow + 1))
  2298. {
  2299. newHeight = (pIBD->lastRow + 1) * pIBD->pCD_iconBox->heightInc;
  2300. XtSetArg (args[i], XmNheight, (XtArgVal) newHeight ); i++;
  2301. }
  2302. else
  2303. {
  2304. newHeight = oldHeight;
  2305. }
  2306. if (minorDimension <= (Dimension) (pIBD->lastCol + 1))
  2307. {
  2308. /* set width of bboard */
  2309. newWidth = (pIBD->lastCol + 1) * pIBD->pCD_iconBox->widthInc;
  2310. XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
  2311. }
  2312. else
  2313. {
  2314. newWidth = minorDimension * pIBD->pCD_iconBox->widthInc;
  2315. XtSetArg (args[i], XmNwidth, (XtArgVal) newWidth); i++;
  2316. }
  2317. }
  2318. if (i > 0 && ExpandVirtualSpace(pIBD, newWidth, newHeight))
  2319. {
  2320. XtSetValues (pIBD->bBoardWidget, args, i);
  2321. }
  2322. /* reset max size for icon box */
  2323. ResetIconBoxMaxSize (pIBD->pCD_iconBox, pIBD->bBoardWidget);
  2324. ResetArrowButtonIncrements (pIBD->pCD_iconBox);
  2325. } /* END FUNCTION PackIconBox */
  2326. /*************************************<->*************************************
  2327. *
  2328. * RealignIconList (pIBD, newRows, newCols)
  2329. *
  2330. *
  2331. * Description:
  2332. * -----------
  2333. * Realigns the icon list according to the new virtual space dimensions
  2334. *
  2335. *
  2336. * Inputs:
  2337. * ------
  2338. * pIBD - ptr to icon box data
  2339. * newRows - new number of rows
  2340. * newCols - new number of columns
  2341. *
  2342. *
  2343. * Outputs:
  2344. * -------
  2345. *
  2346. * Comments:
  2347. * --------
  2348. * o The placement data structure contains the old values.
  2349. *
  2350. *************************************<->***********************************/
  2351. void RealignIconList (IconBoxData *pIBD, int newCols, int newRows)
  2352. {
  2353. int c1, c2, ix1, ix2;
  2354. int oldRows, oldCols;
  2355. IconPlacementData ipdNew;
  2356. IconInfo *pII;
  2357. /*
  2358. * create new icon placement data for ease of calling conversion
  2359. * routines.
  2360. */
  2361. ipdNew.onRootWindow = pIBD->IPD.onRootWindow;
  2362. ipdNew.iconPlacement = pIBD->IPD.iconPlacement;
  2363. ipdNew.placementRows = newRows;
  2364. ipdNew.placementCols = newCols;
  2365. ipdNew.iPlaceW = pIBD->IPD.iPlaceW;
  2366. ipdNew.iPlaceH = pIBD->IPD.iPlaceH;
  2367. ipdNew.placeList = pIBD->IPD.placeList;
  2368. ipdNew.totalPlaces = pIBD->IPD.totalPlaces;
  2369. oldRows = pIBD->IPD.placementRows;
  2370. oldCols = pIBD->IPD.placementCols;
  2371. /*
  2372. * Use the new organization and placement discipline to
  2373. * determine how to move the icon info data around.
  2374. */
  2375. if (((oldRows < newRows) &&
  2376. (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
  2377. ((oldCols < newCols) &&
  2378. (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
  2379. {
  2380. /*
  2381. * work backwards
  2382. */
  2383. for (ix1 = pIBD->IPD.totalPlaces - 1,
  2384. pII = &pIBD->IPD.placeList[ix1]; ix1 >= 0; ix1--, pII--)
  2385. {
  2386. if (pII->pCD != NULL)
  2387. {
  2388. CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
  2389. ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
  2390. if (ix1 != ix2)
  2391. {
  2392. MoveIconInfo (&pIBD->IPD, ix1, ix2);
  2393. }
  2394. }
  2395. }
  2396. }
  2397. else
  2398. if (((oldRows > newRows) &&
  2399. (pIBD->IPD.iconPlacement & ICON_PLACE_TOP_PRIMARY)) ||
  2400. ((oldCols > newCols) &&
  2401. (pIBD->IPD.iconPlacement & ICON_PLACE_LEFT_PRIMARY)))
  2402. {
  2403. /*
  2404. * work forwards
  2405. */
  2406. for (ix1 = 0, pII = &pIBD->IPD.placeList[ix1];
  2407. ix1 < pIBD->IPD.totalPlaces; ix1++, pII++)
  2408. {
  2409. if (pII->pCD != NULL)
  2410. {
  2411. CvtIconPlaceToPosition (&pIBD->IPD, ix1, &c1, &c2);
  2412. ix2 = CvtIconPositionToPlace (&ipdNew, c1, c2);
  2413. if (ix1 != ix2)
  2414. {
  2415. MoveIconInfo (&pIBD->IPD, ix1, ix2);
  2416. }
  2417. }
  2418. }
  2419. }
  2420. /*
  2421. * update info in placement structure to reflect new reality
  2422. */
  2423. pIBD->IPD.placementRows = newRows;
  2424. pIBD->IPD.placementCols = newCols;
  2425. } /* END OF FUNCTION RealignIconList */
  2426. /*************************************<->*************************************
  2427. *
  2428. * SetNewBounds (pIBD)
  2429. *
  2430. *
  2431. * Description:
  2432. * -----------
  2433. *
  2434. *
  2435. * Inputs:
  2436. * ------
  2437. *
  2438. *
  2439. * Outputs:
  2440. * -------
  2441. *
  2442. * Comments:
  2443. * --------
  2444. *
  2445. *************************************<->***********************************/
  2446. void SetNewBounds (IconBoxData *pIBD)
  2447. {
  2448. int i;
  2449. int X = 0;
  2450. int Y = 0;
  2451. CompositeWidget cw;
  2452. WidgetList children;
  2453. cw = (CompositeWidget) pIBD->bBoardWidget;
  2454. children = cw->composite.children;
  2455. for (i = 0; i < cw->composite.num_children; i++)
  2456. {
  2457. if (children[i]->core.x > X)
  2458. {
  2459. X = children[i]->core.x;
  2460. }
  2461. if (children[i]->core.y > Y)
  2462. {
  2463. Y = children[i]->core.y;
  2464. }
  2465. }
  2466. pIBD->lastCol = X / pIBD->pCD_iconBox->widthInc;
  2467. pIBD->lastRow = Y / pIBD->pCD_iconBox->heightInc;
  2468. } /* END OF FUNCTION SetNewBounds */
  2469. /*************************************<->*************************************
  2470. *
  2471. * InsertPosition (w)
  2472. *
  2473. *
  2474. * Description:
  2475. * -----------
  2476. * This procedure is passed to the bulletin board at create time
  2477. * to be used when a child is inserted into the bulletin board
  2478. *
  2479. *
  2480. *************************************<->***********************************/
  2481. Cardinal InsertPosition (Widget w)
  2482. {
  2483. return (insertPosition);
  2484. } /* END OF FUNCTION InsertPosition */
  2485. /*************************************<->*************************************
  2486. *
  2487. * ShowClientIconState ();
  2488. *
  2489. *
  2490. * Description:
  2491. * -----------
  2492. * XXDescription ...
  2493. *
  2494. *************************************<->***********************************/
  2495. void ShowClientIconState (ClientData *pCD, int newState)
  2496. {
  2497. /*
  2498. * Changing the appearance of an icon window in the box to
  2499. * reflect the client's state
  2500. */
  2501. if ((newState == MINIMIZED_STATE) && (pCD->iconWindow))
  2502. XMapRaised (DISPLAY, pCD->iconWindow);
  2503. if (((newState == NORMAL_STATE) || (newState == MAXIMIZED_STATE ))
  2504. && (pCD->iconWindow))
  2505. {
  2506. XUnmapWindow (DISPLAY, pCD->iconWindow);
  2507. }
  2508. } /* END FUNCTION ShowClientIconState */
  2509. /*************************************<->*************************************
  2510. *
  2511. * IconScrollVisibleCallback
  2512. *
  2513. *
  2514. * Description:
  2515. * -----------
  2516. * for each icon in the icon box
  2517. *
  2518. *************************************<->***********************************/
  2519. void IconScrollVisibleCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
  2520. {
  2521. XmTraverseObscuredCallbackStruct *vis_data;
  2522. vis_data = (XmTraverseObscuredCallbackStruct *) call_data;
  2523. XmScrollVisible(ACTIVE_WS->pIconBox->scrolledWidget,
  2524. vis_data->traversal_destination,
  2525. 0,0);
  2526. /*
  2527. IB_MARGIN_WIDTH, IB_MARGIN_HEIGHT);
  2528. */
  2529. } /* END OF FUNCTION IconScrollVisibleCallback */
  2530. /*************************************<->*************************************
  2531. *
  2532. * IconActivateCallback
  2533. *
  2534. *
  2535. * Description:
  2536. * -----------
  2537. * for each icon in the icon box
  2538. *
  2539. *************************************<->***********************************/
  2540. void IconActivateCallback (Widget w, caddr_t client_data, XmAnyCallbackStruct *call_data)
  2541. {
  2542. ClientData *pCD;
  2543. Window theIcon;
  2544. theIcon = XtWindow(w);
  2545. /*
  2546. * find context to get pCD and then carry out
  2547. * default action.
  2548. */
  2549. if (!(XFindContext (DISPLAY, theIcon,
  2550. wmGD.windowContextType, (caddr_t *)&pCD)))
  2551. {
  2552. F_Restore_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
  2553. /* F_Normalize_And_Raise ((String)NULL, pCD, (XEvent *)NULL );
  2554. */ }
  2555. } /* END OF FUNCTION IconActivateCallback */
  2556. /*************************************<->*************************************
  2557. *
  2558. * UpdateIncrements
  2559. *
  2560. *
  2561. * Description:
  2562. * -----------
  2563. * XXDescription ...
  2564. *
  2565. *************************************<->***********************************/
  2566. void UpdateIncrements (Widget sWidget, IconBoxData *pIBD, XConfigureEvent *event)
  2567. {
  2568. ResetArrowButtonIncrements (pIBD->pCD_iconBox);
  2569. } /* END OF FUNCTION UpdateIncrements */
  2570. /*************************************<->*************************************
  2571. *
  2572. * ResetArrowButtonIncrements(pCD)
  2573. *
  2574. *************************************<->***********************************/
  2575. void ResetArrowButtonIncrements (ClientData *pCD)
  2576. {
  2577. int i;
  2578. Arg setArgs[2];
  2579. i=0;
  2580. XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->heightInc); i++;
  2581. XtSetValues (pCD->thisIconBox->vScrollBar, (ArgList) setArgs, i);
  2582. i=0;
  2583. XtSetArg (setArgs[i], XmNincrement, (XtArgVal) pCD->widthInc); i++;
  2584. XtSetValues (pCD->thisIconBox->hScrollBar, (ArgList) setArgs, i);
  2585. } /* END OF FUNCTION ResetArrowButtonIncrements */
  2586. /*************************************<->*************************************
  2587. *
  2588. * ChangeActiveIconboxIconText
  2589. *
  2590. *
  2591. * Description:
  2592. * -----------
  2593. * XXDescription ...
  2594. *
  2595. *************************************<->***********************************/
  2596. void ChangeActiveIconboxIconText (Widget icon, caddr_t dummy, XFocusChangeEvent *event)
  2597. {
  2598. ClientData *pCD;
  2599. Window theIcon;
  2600. /*
  2601. * find context to get pCD and then hide or show active icon text.
  2602. * Show/hide the active icon text only if the icon box is not
  2603. * iconified.
  2604. */
  2605. theIcon = XtWindow(icon);
  2606. if (!(XFindContext (DISPLAY, theIcon,
  2607. wmGD.windowContextType, (caddr_t *)&pCD)) &&
  2608. P_ICON_BOX(pCD) &&
  2609. P_ICON_BOX(pCD)->pCD_iconBox &&
  2610. P_ICON_BOX(pCD)->pCD_iconBox->clientState != MINIMIZED_STATE)
  2611. {
  2612. if (event->type == FocusIn)
  2613. {
  2614. if (event->send_event)
  2615. {
  2616. ShowActiveIconText (pCD);
  2617. }
  2618. }
  2619. else
  2620. {
  2621. if (event->send_event)
  2622. {
  2623. HideActiveIconText (pCD->pSD);
  2624. }
  2625. }
  2626. }
  2627. } /* END OF FUNCTION ChangeActiveIconboxIconText */
  2628. /*************************************<->*************************************
  2629. *
  2630. * HandleIconBoxIconKeyPress
  2631. *
  2632. *
  2633. * Description:
  2634. * -----------
  2635. * This event handler catches keyevents for icons in the icon box and
  2636. * passes them on to the standard key handling routine for mwm.
  2637. *
  2638. *************************************<->***********************************/
  2639. void HandleIconBoxIconKeyPress (Widget icon, caddr_t dummy, XKeyEvent *keyEvent)
  2640. {
  2641. Context context;
  2642. ClientData *pCD;
  2643. Window theIcon;
  2644. /*
  2645. * find context to get pCD and then post menu show active icon text.
  2646. */
  2647. theIcon = XtWindow(icon);
  2648. if (!(XFindContext (DISPLAY, theIcon,
  2649. wmGD.windowContextType, (caddr_t *)&pCD)))
  2650. {
  2651. SetClientWsIndex (pCD);
  2652. keyEvent->window = ICON_FRAME_WIN(pCD);
  2653. if (pCD->clientState == MINIMIZED_STATE)
  2654. {
  2655. context = F_SUBCONTEXT_IB_IICON;
  2656. pCD->grabContext = F_SUBCONTEXT_IB_IICON;
  2657. }
  2658. else
  2659. {
  2660. context = F_SUBCONTEXT_IB_WICON;
  2661. pCD->grabContext = F_SUBCONTEXT_IB_WICON;
  2662. }
  2663. if(!(HandleKeyPress (keyEvent, ACTIVE_PSD->keySpecs,
  2664. True, context, False, pCD)))
  2665. {
  2666. keyEvent->window = 0;
  2667. keyEvent->type = 0;
  2668. }
  2669. }
  2670. } /* END OF FUNCTION HandleIconBoxIconKeyPress */
  2671. /*************************************<->*************************************
  2672. *
  2673. * HandleIconBoxButtonMotion
  2674. *
  2675. *
  2676. * Description:
  2677. * -----------
  2678. * Event handler for button motion events on icon frame window in
  2679. * in icon box.
  2680. *
  2681. *
  2682. * Inputs:
  2683. * ------
  2684. * icon - widget for icon frame
  2685. * client_data - extra client data
  2686. * pev - ptr to event
  2687. *
  2688. *
  2689. * Outputs:
  2690. * -------
  2691. *
  2692. *
  2693. * Comments:
  2694. * --------
  2695. * o This is added to make sure that ButtonXMotion gets added to the
  2696. * event mask for icons in the icon box.
  2697. *
  2698. *************************************<->***********************************/
  2699. void HandleIconBoxButtonMotion (Widget icon, caddr_t client_data, XEvent *pev)
  2700. {
  2701. } /* END OF FUNCTION HandleIconBoxButtonMotion */
  2702. /*************************************<->*************************************
  2703. *
  2704. * GetIconBoxIconRootXY (pCD, pX, pY)
  2705. *
  2706. *
  2707. * Description:
  2708. * -----------
  2709. *
  2710. *
  2711. * Inputs:
  2712. * ------
  2713. * pCD - pointer to client data
  2714. * pX - pointer to X return value
  2715. * pY - pointer to Y return value
  2716. *
  2717. * Outputs:
  2718. * -------
  2719. *
  2720. *
  2721. * Comments:
  2722. * --------
  2723. * o returns root-window coords
  2724. *
  2725. *************************************<->***********************************/
  2726. void GetIconBoxIconRootXY (ClientData *pCD, int *pX, int *pY)
  2727. {
  2728. Window child;
  2729. WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
  2730. if (pCD->pSD->useIconBox && pWsc->pIconBox)
  2731. {
  2732. XTranslateCoordinates(DISPLAY,
  2733. XtWindow(pWsc->pIconBox->bBoardWidget),
  2734. ROOT_FOR_CLIENT(pCD),
  2735. pWsc->iconX + IB_MARGIN_WIDTH,
  2736. pWsc->iconY + IB_MARGIN_HEIGHT,
  2737. pX, pY, &child);
  2738. }
  2739. else
  2740. {
  2741. *pX = *pY = 0;
  2742. }
  2743. } /* END FUNCTION GetIconBoxIconRootXY */
  2744. /*************************************<->*************************************
  2745. *
  2746. * IconVisible (pCD)
  2747. *
  2748. *
  2749. * Description:
  2750. * -----------
  2751. *
  2752. * Inputs:
  2753. * ------
  2754. * pCD - pointer to client data
  2755. *
  2756. * Outputs:
  2757. * -------
  2758. *
  2759. *
  2760. * Comments:
  2761. * --------
  2762. *
  2763. *************************************<->***********************************/
  2764. Boolean IconVisible (ClientData *pCD)
  2765. {
  2766. /*
  2767. * May use icon->core.visible field if that gets fixed and
  2768. * we want to accept the Intrinsics idea of what is visible.
  2769. */
  2770. Boolean rval = True;
  2771. WsClientData *pWsc = GetWsClientData (pCD->pSD->pActiveWS, pCD);
  2772. int i;
  2773. Arg getArgs[5];
  2774. Dimension tmpWidth = 0;
  2775. Dimension tmpHeight = 0;
  2776. Position clipX = 0;
  2777. Position clipY = 0;
  2778. Position tmpX = 0;
  2779. Position tmpY = 0;
  2780. int iconX, iconY;
  2781. i=0;
  2782. XtSetArg (getArgs[i], XmNwidth, (XtArgVal) &tmpWidth ); i++;
  2783. XtSetArg (getArgs[i], XmNheight, (XtArgVal) &tmpHeight ); i++;
  2784. XtSetArg (getArgs[i], XmNx, (XtArgVal) &tmpX ); i++;
  2785. XtSetArg (getArgs[i], XmNy, (XtArgVal) &tmpY ); i++;
  2786. XtGetValues (pWsc->pIconBox->clipWidget, getArgs, i);
  2787. XtTranslateCoords(pWsc->pIconBox->scrolledWidget,
  2788. tmpX, tmpY,
  2789. &clipX, &clipY);
  2790. GetIconBoxIconRootXY(pCD, &iconX, &iconY);
  2791. /*
  2792. * demand at least 2 pixels of the
  2793. * real icon (not drawnButton) be showing
  2794. */
  2795. if (iconX + 2 > ((int)clipX + (int)tmpWidth))
  2796. {
  2797. return(False);
  2798. }
  2799. if (iconY + 2 > ((int)clipY + (int)tmpHeight))
  2800. {
  2801. return(False);
  2802. }
  2803. if ((iconX + (ICON_WIDTH(pCD) -2)) < (int)clipX)
  2804. {
  2805. return(False);
  2806. }
  2807. if ((iconY + (ICON_HEIGHT(pCD) -2)) < (int)clipY)
  2808. {
  2809. return(False);
  2810. }
  2811. return(rval);
  2812. } /* END OF FUNCTION IconVisible */
  2813. /*************************************<->*************************************
  2814. *
  2815. * WmXmStringToString (xmString
  2816. *
  2817. *
  2818. * Description:
  2819. * -----------
  2820. *
  2821. *
  2822. * Inputs:
  2823. * ------
  2824. *
  2825. * Outputs:
  2826. * -------
  2827. *
  2828. *
  2829. * Comments:
  2830. * --------
  2831. * Return the ascii part of the first segment of an XmString
  2832. * If xmString is NULL, then do nothing
  2833. *
  2834. *************************************<->***********************************/
  2835. String WmXmStringToString (XmString xmString)
  2836. {
  2837. XmStringContext xmStrContext;
  2838. char *asciiString = NULL;
  2839. XmStringCharSet ibTitleCharset;
  2840. XmStringDirection ibTitleDirection;
  2841. Boolean separator;
  2842. if (xmString)
  2843. {
  2844. XmStringInitContext (&xmStrContext, xmString);
  2845. XmStringGetNextSegment (xmStrContext, &asciiString,
  2846. &ibTitleCharset, &ibTitleDirection,
  2847. &separator);
  2848. if (ibTitleCharset != NULL)
  2849. {
  2850. XtFree ((char *)ibTitleCharset);
  2851. }
  2852. XmStringFreeContext (xmStrContext);
  2853. }
  2854. return(asciiString);
  2855. } /* END OF FUNCTION WmXmStringToString */