UI.c 133 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291
  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. *
  25. * File: UI.c
  26. *
  27. * Project: CDE
  28. *
  29. * Description: This file contains the user interface creation and
  30. * processing code for the CDE front panel
  31. *
  32. * (c) Copyright 1993, 1994 Hewlett-Packard Company
  33. * (c) Copyright 1993, 1994 International Business Machines Corp.
  34. * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  35. * (c) Copyright 1993, 1994 Novell, Inc.
  36. *
  37. ****************************************************************************/
  38. #include <Dt/DtP.h>
  39. #include <Dt/DbReader.h>
  40. #include <Dt/Dnd.h>
  41. #include "PanelSP.h"
  42. #include <Dt/Control.h>
  43. #include "Clock.h"
  44. #include <Dt/ControlP.h>
  45. #include <Dt/IconFile.h>
  46. #include <Dt/Icon.h>
  47. #include "Button.h"
  48. #include <Dt/GetDispRes.h>
  49. #include <Dt/HourGlass.h>
  50. #include <Xm/Form.h>
  51. #include <Xm/ToggleBG.h>
  52. #include <Xm/MwmUtil.h>
  53. #include <Xm/AtomMgr.h>
  54. #include <Xm/DrawingA.h>
  55. #include <Xm/RowColumn.h>
  56. #include <Xm/SeparatoG.h>
  57. #include <Xm/DialogS.h>
  58. #include <Xm/ColorObjP.h>
  59. #include <Xm/TextF.h>
  60. #include <X11/Xatom.h>
  61. #include <X11/keysymdef.h>
  62. #include <langinfo.h>
  63. #include <stdint.h>
  64. #include "WmHelp.h"
  65. #include "DataBaseLoad.h"
  66. #include "PopupMenu.h"
  67. #include "UI.h"
  68. /************************************************************************
  69. *
  70. * External and static function declarations.
  71. *
  72. ************************************************************************/
  73. extern void PushCB (Widget, XtPointer, XtPointer);
  74. extern void ArrowCB (Widget, XtPointer, XtPointer);
  75. extern XtTranslations HandleInputTranslations (void);
  76. extern void HandleInputCB (Widget, XtPointer, XtPointer);
  77. extern void MinimizeInputCB (Widget, XtPointer, XtPointer);
  78. extern void MenuInputCB (Widget, XtPointer, XtPointer);
  79. extern void SwitchButtonCB (Widget, XtPointer, XtPointer);
  80. extern void SubpanelUnmapCB (Widget, XtPointer, XtPointer);
  81. extern void SubpanelTornEventHandler (Widget, XtPointer, XEvent *, Boolean *);
  82. extern void PushRecallRegister (ControlData *, Boolean);
  83. extern void EmbeddedClientRegister (ControlData *, Boolean);
  84. extern void EmbeddedClientReposition (Widget, Position, Dimension);
  85. extern void DropCB (Widget, XtPointer, XtPointer);
  86. extern void TransferDropCB (Widget, XtPointer, XtPointer);
  87. extern void CustomizeDropCB (Widget, XtPointer, XtPointer);
  88. extern void CustomizeTransferDropCB (Widget, XtPointer, XtPointer);
  89. extern void FrontPanelCreate (Widget);
  90. extern void EmbeddedClientReparent (char *, Widget);
  91. extern void DeleteControlActionList (ControlData *);
  92. extern Boolean CheckOtherMonitorsOn (SubpanelData *);
  93. static void Initialize (DtPanelShellWidget);
  94. static void BoxCreate ();
  95. static Widget PanelControlCreate (Widget, char *, String);
  96. static void MainControlCreate (int);
  97. static void SwitchCreate (BoxData *);
  98. static void SubpanelCreate (ControlData *, SubpanelData *);
  99. static void ControlCreate (Widget, ControlData **, int);
  100. static void ArrowCreate (Widget, ControlData **, int, Boolean, Boolean);
  101. static void SetupPushAnimation(ControlData *);
  102. static void SetupDropAnimation(ControlData *);
  103. void SubpanelControlCreate (SubpanelData *, ControlData *, ControlData *,
  104. Widget, Boolean, Boolean);
  105. void SwitchButtonCreate (SwitchData *, Boolean);
  106. void DeleteSubpanelControl (SubpanelData *, ControlData *);
  107. static char DTFP_CLASS_NAME[] = "Frontpanel";
  108. static char DTFP_APP_NAME[] = "frontpanel";
  109. static XtCallbackRec dropCB[] = { {DropCB, NULL}, {NULL, NULL} };
  110. static XtCallbackRec transferDropCB[] = { {TransferDropCB, NULL},{NULL, NULL} };
  111. static XtCallbackRec customizeDropCB[] = { {CustomizeDropCB, NULL}, {NULL, NULL} };
  112. static XtCallbackRec customizeTransferDropCB[] = { {CustomizeTransferDropCB, NULL},{NULL, NULL} };
  113. /************************************************************************
  114. *
  115. * File local globals.
  116. *
  117. ************************************************************************/
  118. String post_arrow_image = NULL;
  119. String unpost_arrow_image = NULL;
  120. String post_monitor_arrow_image = NULL;
  121. String unpost_monitor_arrow_image = NULL;
  122. String blank_arrow_image = NULL;
  123. String dropzone_image = NULL;
  124. String indicator_on_image = NULL;
  125. String indicator_off_image = NULL;
  126. String minimize_normal_image = NULL;
  127. String minimize_selected_image = NULL;
  128. String menu_normal_image = NULL;
  129. String menu_selected_image = NULL;
  130. String handle_image = NULL;
  131. Pixmap minimize_normal_pixmap;
  132. Pixmap minimize_selected_pixmap;
  133. Pixmap menu_normal_pixmap;
  134. Pixmap menu_selected_pixmap;
  135. #define HARD_CODED_PRIMARY 3
  136. #define _WS_HIGH_COLOR_COUNT 4
  137. static int _ws_high_color_map[] = { 3, 5, 6, 7 };
  138. static Dimension switch_height = 0;
  139. /************************************************************************
  140. *
  141. * FrontPanelCreate
  142. *
  143. ************************************************************************/
  144. void
  145. FrontPanelCreate (Widget toplevel)
  146. {
  147. DtPanelShellWidget panel_shell;
  148. char * panel_name = (char *) panel.element_values[PANEL_NAME].parsed_value;
  149. unsigned int display_height;
  150. Arg al[20];
  151. int ac;
  152. display_height = DisplayHeight (XtDisplay (toplevel),
  153. DefaultScreen (XtDisplay (toplevel)));
  154. /* Create panel shell. */
  155. ac = 0;
  156. XtSetArg (al[ac], XmNallowShellResize, True); ac++;
  157. XtSetArg (al[ac], XmNiconY, display_height); ac++;
  158. XtSetArg (al[ac], XmNmwmDecorations, MWM_DECOR_BORDER); ac++;
  159. panel.shell = XtCreatePopupShell (panel_name, dtPanelShellWidgetClass,
  160. toplevel, al, ac);
  161. panel_shell = (DtPanelShellWidget) panel.shell;
  162. /* Initialize the general data into the panel structure */
  163. Initialize (panel_shell);
  164. /* Set pixel resources. */
  165. ac = 0;
  166. XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
  167. XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
  168. XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
  169. XtSetArg (al[ac], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac++;
  170. XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
  171. /* Remove all of the tab groups */
  172. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  173. /* Create the outer form widget that will contain the entire panel */
  174. panel.form = XmCreateForm (panel.shell, panel_name, al, ac);
  175. XtManageChild (panel.form);
  176. /* Create the handles, menu and iconify */
  177. if ((intptr_t) panel.element_values[PANEL_DISPLAY_HANDLES].parsed_value)
  178. {
  179. XtTranslations handle_translations = HandleInputTranslations();
  180. panel.left_handle = PanelControlCreate (panel.form, "handle", handle_image);
  181. panel.right_handle = PanelControlCreate (panel.form, "handle", handle_image);
  182. XtOverrideTranslations(panel.left_handle, handle_translations);
  183. XtAddCallback (panel.left_handle, XmNinputCallback,
  184. (XtCallbackProc) HandleInputCB, NULL);
  185. XtAddCallback (panel.left_handle, XmNhelpCallback,
  186. (XtCallbackProc) GeneralTopicHelpCB, PANEL_HANDLE);
  187. XtOverrideTranslations(panel.right_handle, handle_translations);
  188. XtAddCallback (panel.right_handle, XmNinputCallback,
  189. (XtCallbackProc) HandleInputCB, NULL);
  190. XtAddCallback (panel.right_handle, XmNhelpCallback,
  191. (XtCallbackProc) GeneralTopicHelpCB, PANEL_HANDLE);
  192. if ((intptr_t) panel.element_values[PANEL_DISPLAY_MENU].parsed_value)
  193. {
  194. panel.menu = PanelControlCreate (panel.form, "menu", menu_normal_image);
  195. XtAddCallback (panel.menu, XmNinputCallback,
  196. (XtCallbackProc) MenuInputCB, NULL);
  197. XtAddCallback (panel.menu, XmNhelpCallback,
  198. (XtCallbackProc) GeneralTopicHelpCB, PANEL_MENU);
  199. ac = 0;
  200. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  201. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  202. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  203. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  204. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  205. XtSetArg (al[ac], XmNwidth, 21); ac++;
  206. XtSetArg (al[ac], XmNheight, 15); ac++;
  207. } else {
  208. XtSetArg (al[ac], XmNwidth, 17); ac++;
  209. XtSetArg (al[ac], XmNheight, 13); ac++;
  210. }
  211. XtSetValues (panel.menu, al, ac);
  212. ac = 0;
  213. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  214. XtSetArg (al[ac], XmNtopWidget, panel.menu); ac++;
  215. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  216. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  217. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  218. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  219. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  220. XtSetArg (al[ac], XmNwidth, 20); ac++;
  221. } else {
  222. XtSetArg (al[ac], XmNwidth, 16); ac++;
  223. }
  224. XtSetValues (panel.left_handle, al, ac);
  225. }
  226. else
  227. {
  228. panel.menu = NULL;
  229. ac = 0;
  230. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  231. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  232. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  233. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  234. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  235. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  236. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  237. XtSetArg (al[ac], XmNwidth, 20); ac++;
  238. } else {
  239. XtSetArg (al[ac], XmNwidth, 16); ac++;
  240. }
  241. XtSetValues (panel.left_handle, al, ac);
  242. }
  243. if ((intptr_t) panel.element_values[PANEL_DISPLAY_MINIMIZE].parsed_value)
  244. {
  245. panel.iconify =
  246. PanelControlCreate (panel.form, "minimize", minimize_normal_image);
  247. XtAddCallback (panel.iconify, XmNinputCallback,
  248. (XtCallbackProc) MinimizeInputCB, NULL);
  249. XtAddCallback (panel.iconify, XmNhelpCallback,
  250. (XtCallbackProc) GeneralTopicHelpCB, PANEL_ICONIFY);
  251. ac = 0;
  252. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  253. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  254. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  255. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  256. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  257. XtSetArg (al[ac], XmNwidth, 21); ac++;
  258. XtSetArg (al[ac], XmNheight, 15); ac++;
  259. } else {
  260. XtSetArg (al[ac], XmNwidth, 17); ac++;
  261. XtSetArg (al[ac], XmNheight, 13); ac++;
  262. }
  263. XtSetValues (panel.iconify, al, ac);
  264. ac = 0;
  265. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  266. XtSetArg (al[ac], XmNtopWidget, panel.iconify); ac++;
  267. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  268. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  269. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  270. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  271. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  272. XtSetArg (al[ac], XmNwidth, 20); ac++;
  273. } else {
  274. XtSetArg (al[ac], XmNwidth, 16); ac++;
  275. }
  276. XtSetValues (panel.right_handle, al, ac);
  277. }
  278. else
  279. {
  280. panel.iconify = NULL;
  281. ac = 0;
  282. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  283. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  284. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  285. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  286. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  287. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  288. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  289. XtSetArg (al[ac], XmNwidth, 20); ac++;
  290. } else {
  291. XtSetArg (al[ac], XmNwidth, 16); ac++;
  292. }
  293. XtSetValues (panel.right_handle, al, ac);
  294. }
  295. }
  296. else
  297. {
  298. panel.left_handle = NULL;
  299. panel.right_handle = NULL;
  300. }
  301. /* Create all of the boxes. This function, in turn, creates */
  302. /* all of the controls, switch, subpanels. */
  303. BoxCreate ();
  304. /* Manage the front panel to get it created and layed out */
  305. XtSetMappedWhenManaged (panel.shell, False);
  306. XtManageChild (panel.shell);
  307. }
  308. /************************************************************************
  309. *
  310. * Initialize
  311. * Get all of the default data needed for the panel and put it into
  312. * the panel structure.
  313. *
  314. ************************************************************************/
  315. static void
  316. Initialize (DtPanelShellWidget panel_shell)
  317. {
  318. Screen * screen = XtScreen (panel_shell);
  319. Display * display = XtDisplay (panel_shell);
  320. Pixmap busy_pixmap;
  321. Pixmap busy_pixmap_mask;
  322. Pixel black_pixel = BlackPixelOfScreen (screen);
  323. Pixel white_pixel = WhitePixelOfScreen (screen);
  324. Boolean use_mask_return;
  325. Boolean use_icon_file_cache_return;
  326. short active, inactive, primary, secondary;
  327. int color_use, resolution;
  328. unsigned int size;
  329. /* Create busy cursor. */
  330. _DtGetHourGlassCursor(display);
  331. panel.resolution = (int) (intptr_t) panel.element_values[PANEL_RESOLUTION].parsed_value;
  332. /* Extract and validate resolution. */
  333. if (panel.resolution == MATCH_DISPLAY ||
  334. (panel.resolution != HIGH &&
  335. panel.resolution != MEDIUM &&
  336. panel.resolution != LOW))
  337. {
  338. resolution =
  339. _DtGetDisplayResolution (display, XScreenNumberOfScreen(screen));
  340. switch (resolution)
  341. {
  342. case HIGH_RES_DISPLAY:
  343. panel.resolution = HIGH;
  344. break;
  345. case MED_RES_DISPLAY:
  346. panel.resolution = MEDIUM;
  347. break;
  348. case LOW_RES_DISPLAY:
  349. case NO_RES_DISPLAY:
  350. panel.resolution = LOW;
  351. break;
  352. }
  353. }
  354. if (panel.resolution == HIGH || panel.resolution == MEDIUM)
  355. {
  356. panel.main_icon_size = DtLARGE;
  357. panel.sub_icon_size = DtMEDIUM;
  358. panel.switch_icon_size = DtSMALL;
  359. }
  360. else
  361. {
  362. panel.main_icon_size = DtMEDIUM;
  363. panel.sub_icon_size = DtTINY;
  364. panel.switch_icon_size = DtTINY;
  365. }
  366. /* Set the font list based on the screen resolution */
  367. switch(panel.resolution) {
  368. case HIGH:
  369. panel.font_list = S_HighResFontList (panel_shell);
  370. panel.date_font_list = S_MediumResFontList (panel_shell);
  371. break;
  372. case MEDIUM:
  373. panel.font_list = S_MediumResFontList (panel_shell);
  374. panel.date_font_list = S_MediumResFontList (panel_shell);
  375. break;
  376. case LOW:
  377. panel.font_list = S_LowResFontList (panel_shell);
  378. panel.date_font_list = S_LowResFontList (panel_shell);
  379. break;
  380. }
  381. /* initialize popup_data to NULL */
  382. panel.popup_data = NULL;
  383. /* See if using bitonal or multicolor icons. If bitonal, set the */
  384. /* pixel set to black and white based on the colors of the parent */
  385. /* If color, use the color obj to get the color pixel set. */
  386. XmeGetIconControlInfo (screen,
  387. &use_mask_return, &panel.use_color_icons,
  388. &use_icon_file_cache_return);
  389. panel.pixel_set = (XmPixelSet *)
  390. XtMalloc (sizeof(XmPixelSet) * XmCO_NUM_COLORS);
  391. if (XmeGetPixelData (XScreenNumberOfScreen (screen),
  392. &color_use, panel.pixel_set,
  393. &active, &inactive, &primary, &secondary))
  394. {
  395. panel.color_use = color_use;
  396. panel.active_pixel_set = &(panel.pixel_set[active]);
  397. panel.inactive_pixel_set = &(panel.pixel_set[inactive]);
  398. panel.primary_pixel_set = &(panel.pixel_set[primary]);
  399. panel.secondary_pixel_set = &(panel.pixel_set[secondary]);
  400. }
  401. else
  402. {
  403. XtFree ((char *) panel.pixel_set);
  404. panel.pixel_set = (XmPixelSet *) XtMalloc (sizeof (XmPixelSet));
  405. panel.active_pixel_set = &(panel.pixel_set[0]);
  406. panel.pixel_set_count = 1;
  407. panel.active_pixel_set->bg = panel_shell->core.background_pixel;
  408. if (panel.active_pixel_set->bg == black_pixel)
  409. {
  410. panel.active_pixel_set->fg = white_pixel;
  411. panel.active_pixel_set->bg = black_pixel;
  412. panel.active_pixel_set->ts = white_pixel;
  413. panel.active_pixel_set->bs = white_pixel;
  414. panel.active_pixel_set->sc = black_pixel;
  415. panel.color_use = XmCO_BLACK_WHITE;
  416. }
  417. else
  418. {
  419. if (panel.active_pixel_set->bg == white_pixel)
  420. {
  421. panel.active_pixel_set->fg = black_pixel;
  422. panel.active_pixel_set->bg = white_pixel;
  423. panel.active_pixel_set->ts = black_pixel;
  424. panel.active_pixel_set->bs = black_pixel;
  425. panel.active_pixel_set->sc = white_pixel;
  426. panel.color_use = XmCO_BLACK_WHITE;
  427. }
  428. else
  429. {
  430. /* Get the Motif defaults and assign into a single allocated */
  431. /* pixel set which is then referenced throught the other 3 */
  432. /* pixel set datas. */
  433. XmGetColors (screen, DefaultColormapOfScreen (screen),
  434. panel.active_pixel_set->bg,
  435. &(panel.active_pixel_set->fg),
  436. &(panel.active_pixel_set->ts),
  437. &(panel.active_pixel_set->bs),
  438. &(panel.active_pixel_set->sc));
  439. panel.color_use = XmCO_LOW_COLOR;
  440. }
  441. }
  442. panel.inactive_pixel_set = panel.active_pixel_set;
  443. panel.primary_pixel_set = panel.active_pixel_set;
  444. panel.secondary_pixel_set = panel.active_pixel_set;
  445. }
  446. /* Initialize other panel specific information */
  447. panel.busy_light_data = NULL;
  448. panel.push_recall_list = NULL;
  449. panel.push_recall_count = 0;
  450. panel.max_push_recall_count = 0;
  451. panel.embedded_client_list = NULL;
  452. panel.embedded_client_count = 0;
  453. panel.max_embedded_client_count = 0;
  454. panel.dynamic_data_list = NULL;
  455. panel.dynamic_data_count = 0;
  456. panel.max_dynamic_data_count = 0;
  457. /* Get the names of the predefined images */
  458. /* Get icon size. */
  459. /* main panel icons */
  460. size = panel.main_icon_size;
  461. post_arrow_image = GetIconName (UP_ARROW_IMAGE_NAME, size);
  462. unpost_arrow_image = GetIconName (DOWN_ARROW_IMAGE_NAME, size);
  463. post_monitor_arrow_image = GetIconName (UP_MONITOR_ARROW_IMAGE_NAME, size);
  464. unpost_monitor_arrow_image= GetIconName(DOWN_MONITOR_ARROW_IMAGE_NAME, size);
  465. blank_arrow_image = GetIconName (BLANK_ARROW_IMAGE_NAME, size);
  466. minimize_normal_image = GetIconName (MINIMIZE_NORMAL_IMAGE_NAME, size);
  467. minimize_selected_image = GetIconName (MINIMIZE_SELECTED_IMAGE_NAME, size);
  468. menu_normal_image = GetIconName (MENU_NORMAL_IMAGE_NAME, size);
  469. menu_selected_image = GetIconName (MENU_SELECTED_IMAGE_NAME, size);
  470. handle_image = GetIconName (HANDLE_IMAGE_NAME, DtLARGE);
  471. /* subpanel icons */
  472. size = panel.sub_icon_size;
  473. indicator_off_image = GetIconName (INDICATOR_OFF_IMAGE_NAME, size);
  474. indicator_on_image = GetIconName (INDICATOR_ON_IMAGE_NAME, size);
  475. dropzone_image = GetIconName (DROPZONE_IMAGE_NAME, size);
  476. }
  477. /************************************************************************
  478. *
  479. * PanelControlCreate
  480. * Create the handles, menu or iconify buttons attached to the panel.
  481. *
  482. ************************************************************************/
  483. static Widget
  484. PanelControlCreate (Widget parent,
  485. char * control_name,
  486. String image_name)
  487. {
  488. Widget w;
  489. Pixmap pixmap;
  490. Pixel fg, bg;
  491. Arg al[15];
  492. int ac;
  493. if (panel.color_use != XmCO_BLACK_WHITE)
  494. {
  495. /* Use background for color set matching.
  496. * Use top shadow for clock hand color.
  497. */
  498. fg = panel.inactive_pixel_set->ts;
  499. bg = panel.inactive_pixel_set->bg;
  500. }
  501. else
  502. {
  503. fg = BlackPixelOfScreen (XtScreen (panel.form));
  504. bg = WhitePixelOfScreen (XtScreen (panel.form));
  505. }
  506. pixmap = XmGetPixmap (XtScreen (parent), image_name, fg, bg);
  507. if (strcmp (control_name, "minimize") == 0)
  508. {
  509. minimize_normal_pixmap = pixmap;
  510. minimize_selected_pixmap =
  511. XmGetPixmap (XtScreen (parent), minimize_selected_image, fg, bg);
  512. }
  513. else if (strcmp (control_name, "menu") == 0)
  514. {
  515. menu_normal_pixmap = pixmap;
  516. menu_selected_pixmap =
  517. XmGetPixmap (XtScreen (parent), menu_selected_image, fg, bg);
  518. }
  519. ac = 0;
  520. XtSetArg (al[ac], XmNforeground, fg); ac++;
  521. XtSetArg (al[ac], XmNbackground, bg); ac++;
  522. XtSetArg (al[ac], XmNwidth, 11); ac++;
  523. XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
  524. XtSetArg (al[ac], XmNborderWidth, 0); ac++;
  525. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  526. XtSetArg (al[ac], XmNtraversalOn, False); ac++;
  527. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  528. w = XmCreateDrawingArea (parent, control_name, al, ac);
  529. XtManageChild (w);
  530. return (w);
  531. }
  532. /************************************************************************
  533. *
  534. * BoxCreate
  535. * Create all of the boxes defined within the panel data structure.
  536. *
  537. ************************************************************************/
  538. static void
  539. BoxCreate (void)
  540. {
  541. int i, j;
  542. BoxData * box_data;
  543. BoxData * switch_box_data = NULL;
  544. Widget prev_form;
  545. int switch_position = POSITION_FIRST;
  546. Pixmap pixmap;
  547. Arg al[40];
  548. int ac;
  549. /* Loop through the panels boxes, creating the set outer forms */
  550. /* necessary to hold the inner forms for the controls, arrows... */
  551. prev_form = NULL;
  552. for (i = 0; i < panel.box_data_count; i++)
  553. {
  554. box_data = panel.box_data[i];
  555. /* Create the outer box form which will contain the inner box set */
  556. ac = 0;
  557. XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
  558. if (panel.left_handle != NULL)
  559. {
  560. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
  561. XtSetArg (al[ac], XmNrightWidget, panel.right_handle); ac++;
  562. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  563. XtSetArg (al[ac], XmNleftWidget, panel.left_handle); ac++;
  564. }
  565. else
  566. {
  567. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  568. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  569. }
  570. if (prev_form != NULL)
  571. {
  572. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  573. XtSetArg (al[ac], XmNtopWidget, prev_form); ac++;
  574. }
  575. else
  576. {
  577. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  578. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  579. }
  580. if (i == panel.box_data_count - 1)
  581. {
  582. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  583. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  584. }
  585. if (panel.color_use == XmCO_BLACK_WHITE)
  586. {
  587. XtSetArg (al[ac], XmNbottomShadowColor,
  588. BlackPixelOfScreen (XtScreen (panel.shell))); ac++;
  589. }
  590. /* Remove all of the tab groups */
  591. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  592. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  593. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  594. /* Create the outer form widget that will contain the entire panel */
  595. box_data->form =
  596. XmCreateForm (panel.form,
  597. (char *) box_data->element_values[BOX_NAME].parsed_value,
  598. al, ac);
  599. XtManageChild (box_data->form);
  600. prev_form = box_data->form;
  601. }
  602. /* Loop through the panels boxes, creating the set of forms needed */
  603. /* to contain the controls, arrows, or switch within the front panel */
  604. for (i = 0; i < panel.box_data_count; i++)
  605. {
  606. box_data = panel.box_data[i];
  607. if (box_data->switch_data != NULL)
  608. {
  609. switch_box_data = box_data;
  610. ac = 0;
  611. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  612. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  613. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  614. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  615. XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
  616. switch_position =
  617. (intptr_t) box_data->switch_data->element_values[SWITCH_POSITION_HINTS].parsed_value;
  618. /* Determine if the defined switch position is actually the */
  619. /* first or last position. */
  620. if (switch_position != POSITION_FIRST || switch_position != POSITION_LAST)
  621. {
  622. for (j = 0; j < box_data->control_data_count; j++)
  623. {
  624. if (switch_position < (intptr_t) ((box_data->control_data[j])->element_values[CONTROL_POSITION_HINTS].parsed_value))
  625. break;
  626. }
  627. if (j == 0)
  628. switch_position = POSITION_FIRST;
  629. else if (j == box_data->control_data_count)
  630. switch_position = POSITION_LAST;
  631. }
  632. if (switch_position == POSITION_FIRST)
  633. {
  634. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  635. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  636. }
  637. if (switch_position == POSITION_LAST ||
  638. box_data->control_data_count == 0)
  639. {
  640. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  641. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  642. }
  643. XtSetArg (al[ac], XmNuserData, SWITCH); ac++;
  644. /* Remove all of the tab groups */
  645. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  646. if (panel.color_use == XmCO_BLACK_WHITE)
  647. {
  648. XtSetArg (al[ac], XmNbottomShadowColor,
  649. BlackPixelOfScreen (XtScreen (panel.form))); ac++;
  650. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  651. panel.inactive_pixel_set->fg,
  652. panel.inactive_pixel_set->bg);
  653. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  654. }
  655. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  656. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  657. box_data->switch_form =
  658. XmCreateForm (box_data->form, "switch", al, ac);
  659. XtManageChild (box_data->switch_form);
  660. XtAddCallback (box_data->switch_form, XmNhelpCallback,
  661. (XtCallbackProc) SwitchTopicHelpCB,
  662. box_data->switch_data);
  663. if (box_data->control_data_count == 0)
  664. continue;
  665. }
  666. /* Create the arrow boxes */
  667. if (box_data->switch_form != NULL)
  668. {
  669. if (switch_position == POSITION_FIRST)
  670. {
  671. ac = 0;
  672. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  673. XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
  674. XtSetArg (al[ac], XmNleftOffset, -4); ac++;
  675. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  676. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  677. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  678. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  679. }
  680. else if (switch_position == POSITION_LAST)
  681. {
  682. ac = 0;
  683. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  684. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  685. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  686. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  687. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
  688. XtSetArg (al[ac], XmNrightWidget, box_data->switch_form); ac++;
  689. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  690. }
  691. else
  692. {
  693. ac = 0;
  694. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  695. XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
  696. XtSetArg (al[ac], XmNleftOffset, -6); ac++;
  697. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  698. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  699. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  700. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  701. XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
  702. XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
  703. XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
  704. XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
  705. if (panel.color_use == XmCO_BLACK_WHITE)
  706. {
  707. XtSetArg (al[ac], XmNbottomShadowColor,
  708. BlackPixelOfScreen (XtScreen (panel.form))); ac++;
  709. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  710. panel.inactive_pixel_set->fg,
  711. panel.inactive_pixel_set->bg);
  712. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  713. }
  714. else
  715. {
  716. XtSetArg (al[ac], XmNbottomShadowColor,
  717. panel.inactive_pixel_set->bs); ac++;
  718. }
  719. /* Remove all of the tab groups */
  720. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  721. if (i == 0)
  722. {
  723. XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
  724. }
  725. else
  726. {
  727. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  728. }
  729. box_data->right_arrow_form =
  730. XmCreateForm (box_data->form, "right_arrow_form", al, ac);
  731. if (box_data->subpanel_count != 0)
  732. XtManageChild (box_data->right_arrow_form);
  733. XtAddCallback (box_data->right_arrow_form, XmNhelpCallback,
  734. (XtCallbackProc) GeneralTopicHelpCB,
  735. SUBPANEL_ACCESS_AREA);
  736. ac = 0;
  737. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  738. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  739. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  740. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  741. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  742. XtSetArg (al[ac], XmNrightOffset, -2); ac++;
  743. }
  744. }
  745. else
  746. {
  747. ac = 0;
  748. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  749. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  750. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  751. if (i == 0)
  752. {
  753. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  754. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  755. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  756. }
  757. else
  758. {
  759. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  760. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  761. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  762. }
  763. }
  764. XtSetArg(al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
  765. XtSetArg(al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
  766. XtSetArg(al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts);ac++;
  767. XtSetArg(al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
  768. if (panel.color_use == XmCO_BLACK_WHITE)
  769. {
  770. XtSetArg (al[ac], XmNbottomShadowColor,
  771. BlackPixelOfScreen (XtScreen (panel.form))); ac++;
  772. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  773. panel.inactive_pixel_set->fg,
  774. panel.inactive_pixel_set->bg);
  775. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  776. }
  777. else
  778. {
  779. XtSetArg (al[ac], XmNbottomShadowColor,
  780. panel.inactive_pixel_set->bs); ac++;
  781. }
  782. /* Remove all of the tab groups */
  783. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  784. if (i == 0)
  785. {
  786. XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
  787. }
  788. else
  789. {
  790. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  791. }
  792. box_data->left_arrow_form =
  793. XmCreateForm (box_data->form, "left_arrow_form", al, ac);
  794. if (box_data->subpanel_count != 0)
  795. XtManageChild (box_data->left_arrow_form);
  796. XtAddCallback (box_data->left_arrow_form, XmNhelpCallback,
  797. (XtCallbackProc) GeneralTopicHelpCB,
  798. SUBPANEL_ACCESS_AREA);
  799. /* Now create the control boxes */
  800. if (box_data->switch_form != NULL)
  801. {
  802. if (switch_position == POSITION_FIRST ||
  803. switch_position == POSITION_LAST)
  804. {
  805. ac = 0;
  806. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  807. if (switch_position == POSITION_FIRST)
  808. {
  809. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  810. XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
  811. XtSetArg (al[ac], XmNleftOffset, -4); ac++;
  812. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  813. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  814. }
  815. else
  816. {
  817. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  818. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  819. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_WIDGET); ac++;
  820. XtSetArg (al[ac], XmNrightWidget, box_data->switch_form); ac++;
  821. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  822. }
  823. if (XtIsManaged(box_data->left_arrow_form))
  824. {
  825. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  826. XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
  827. }
  828. else
  829. {
  830. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  831. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  832. }
  833. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  834. XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
  835. XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
  836. /* Remove all of the tab groups */
  837. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  838. if (panel.color_use == XmCO_BLACK_WHITE)
  839. {
  840. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  841. panel.inactive_pixel_set->fg,
  842. panel.inactive_pixel_set->bg);
  843. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  844. }
  845. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  846. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  847. box_data->left_control_form =
  848. XmCreateForm (box_data->form, "left_control_form", al, ac);
  849. XtManageChild (box_data->left_control_form);
  850. }
  851. else
  852. {
  853. ac = 0;
  854. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  855. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  856. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  857. if (XtIsManaged (box_data->left_arrow_form))
  858. {
  859. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  860. XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
  861. }
  862. else
  863. {
  864. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  865. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  866. }
  867. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  868. XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
  869. XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
  870. /* Remove all of the tab groups */
  871. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  872. if (panel.color_use == XmCO_BLACK_WHITE)
  873. {
  874. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  875. panel.inactive_pixel_set->fg,
  876. panel.inactive_pixel_set->bg);
  877. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  878. }
  879. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  880. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  881. box_data->left_control_form =
  882. XmCreateForm (box_data->form, "left_control_form", al, ac);
  883. XtManageChild (box_data->left_control_form);
  884. ac = 0;
  885. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  886. XtSetArg (al[ac], XmNleftWidget, box_data->left_control_form); ac++;
  887. XtSetArg (al[ac], XmNleftOffset, -3); ac++;
  888. XtSetValues (box_data->switch_form, al, ac);
  889. ac = 0;
  890. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  891. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  892. XtSetArg (al[ac], XmNleftWidget, box_data->switch_form); ac++;
  893. XtSetArg (al[ac], XmNleftOffset, -4); ac++;
  894. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  895. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  896. if (XtIsManaged(box_data->right_arrow_form))
  897. {
  898. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  899. XtSetArg (al[ac], XmNtopWidget, box_data->right_arrow_form); ac++;
  900. }
  901. else
  902. {
  903. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  904. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  905. }
  906. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  907. XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
  908. XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
  909. /* Remove all of the tab groups */
  910. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  911. if (panel.color_use == XmCO_BLACK_WHITE)
  912. {
  913. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  914. panel.inactive_pixel_set->fg,
  915. panel.inactive_pixel_set->bg);
  916. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  917. }
  918. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  919. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  920. box_data->right_control_form =
  921. XmCreateForm (box_data->form, "right_control_form", al, ac);
  922. XtManageChild (box_data->right_control_form);
  923. }
  924. }
  925. else
  926. {
  927. ac = 0;
  928. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  929. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  930. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  931. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  932. XtSetArg (al[ac], XmNrightOffset, 0); ac++;
  933. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  934. XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
  935. if (XtIsManaged(box_data->left_arrow_form))
  936. {
  937. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  938. XtSetArg (al[ac], XmNtopWidget, box_data->left_arrow_form); ac++;
  939. }
  940. else
  941. {
  942. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  943. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  944. }
  945. XtSetArg (al[ac], XmNuserData, CONTROL); ac++;
  946. /* Remove all of the tab groups */
  947. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  948. if (panel.color_use == XmCO_BLACK_WHITE)
  949. {
  950. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  951. panel.inactive_pixel_set->fg,
  952. panel.inactive_pixel_set->bg);
  953. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  954. }
  955. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  956. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  957. box_data->left_control_form =
  958. XmCreateForm (box_data->form, "left_control_form", al, ac);
  959. XtManageChild (box_data->left_control_form);
  960. }
  961. if (box_data->left_control_form != NULL)
  962. {
  963. if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
  964. CreatePopupMenu(box_data->left_control_form);
  965. else
  966. XmAddToPostFromList(panel.popup_data->popup,
  967. box_data->left_control_form);
  968. /* Event handler for posting popup menu */
  969. XtAddEventHandler(box_data->left_control_form, ButtonPressMask, False,
  970. (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
  971. }
  972. if (box_data->right_control_form != NULL)
  973. {
  974. if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
  975. CreatePopupMenu(box_data->right_control_form);
  976. else
  977. XmAddToPostFromList(panel.popup_data->popup,
  978. box_data->right_control_form);
  979. /* Event handler for posting popup menu */
  980. XtAddEventHandler(box_data->right_control_form, ButtonPressMask,False,
  981. (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
  982. }
  983. }
  984. /* Once all of the boxes and switch form have been created within */
  985. /* the main panel, call the function to create the main panel */
  986. /* controls. This function also creates the arrows. */
  987. MainControlCreate (switch_position);
  988. /* Call a function to create the control and button set for the switch */
  989. if (switch_box_data != NULL)
  990. SwitchCreate (switch_box_data);
  991. for (i = 0; i < panel.box_data_count; i++)
  992. {
  993. box_data = panel.box_data[i];
  994. if (box_data->switch_data != NULL)
  995. {
  996. if (box_data->switch_form != NULL)
  997. {
  998. if (box_data->switch_data->popup_data == NULL ||
  999. box_data->switch_data->popup_data->popup == NULL)
  1000. CreateWorkspacePopupMenu (box_data->switch_form,
  1001. box_data->switch_data);
  1002. else
  1003. XmAddToPostFromList (box_data->switch_data->popup_data->popup,
  1004. box_data->switch_form);
  1005. /* Event handler for posting popup menu */
  1006. XtAddEventHandler (box_data->switch_form, ButtonPressMask,
  1007. False,
  1008. (XtEventHandler) PostWorkspacePopupMenu,
  1009. (XtPointer) NULL);
  1010. }
  1011. }
  1012. }
  1013. }
  1014. /************************************************************************
  1015. *
  1016. * MainControlCreate
  1017. *
  1018. ************************************************************************/
  1019. static void
  1020. MainControlCreate (int switch_position)
  1021. {
  1022. int i;
  1023. BoxData * box_data;
  1024. Boolean first_box;
  1025. Arg al[1];
  1026. /* Set up a loop to go through each box and create the set of controls */
  1027. /* subpanel arrows, and subpanels for each box. */
  1028. for (i = 0; i < panel.box_data_count; i++)
  1029. {
  1030. box_data = panel.box_data[i];
  1031. if (i == 0) first_box = True;
  1032. else first_box = False;
  1033. if (box_data->control_data_count == 0)
  1034. continue;
  1035. /* See if we need to split the control create for the box */
  1036. /* because the switch is centered between the controls. */
  1037. if (switch_position == POSITION_FIRST ||
  1038. switch_position == POSITION_LAST ||
  1039. box_data->switch_form == NULL)
  1040. {
  1041. ControlCreate (box_data->left_control_form, box_data->control_data,
  1042. box_data->control_data_count);
  1043. ArrowCreate (box_data->left_arrow_form, box_data->control_data,
  1044. box_data->control_data_count, False, first_box);
  1045. }
  1046. else
  1047. {
  1048. int j;
  1049. /* Find the position within the control list that is less than */
  1050. /* the switch position. */
  1051. for (j = 0; j < box_data->control_data_count; j++)
  1052. {
  1053. if (switch_position <
  1054. (intptr_t) ((box_data->control_data[j])->element_values[CONTROL_POSITION_HINTS].parsed_value))
  1055. {
  1056. ControlCreate (box_data->left_control_form,
  1057. &box_data->control_data[0], j);
  1058. ControlCreate (box_data->right_control_form,
  1059. &box_data->control_data[j],
  1060. box_data->control_data_count - j);
  1061. ArrowCreate (box_data->left_arrow_form,
  1062. &box_data->control_data[0], j, False, first_box);
  1063. ArrowCreate (box_data->right_arrow_form,
  1064. &box_data->control_data[j],
  1065. box_data->control_data_count - j, True, first_box);
  1066. break;
  1067. }
  1068. }
  1069. }
  1070. }
  1071. }
  1072. /************************************************************************
  1073. *
  1074. * ControlSetVisualData
  1075. * Set up the arg list elements for a controls color and font
  1076. * resources.
  1077. *
  1078. * Inputs: control_data - a pointer to the control to be created
  1079. * al - a pointer to the arg list to contain the resource data
  1080. * ac - a pointer to the arg list count
  1081. *
  1082. ************************************************************************/
  1083. static void
  1084. ControlSetVisualData (ControlData * control_data,
  1085. ArgList al,
  1086. int * ac)
  1087. {
  1088. XtSetArg (al[*ac], XmNbackground, panel.primary_pixel_set->bg); (*ac)++;
  1089. XtSetArg (al[*ac], XmNforeground, panel.primary_pixel_set->fg); (*ac)++;
  1090. if (panel.color_use == XmCO_BLACK_WHITE)
  1091. {
  1092. XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
  1093. XtSetArg (al[*ac], XmNarmColor, panel.primary_pixel_set->bg); (*ac)++;
  1094. }
  1095. else
  1096. {
  1097. XtSetArg (al[*ac], XmNarmColor, panel.primary_pixel_set->sc); (*ac)++;
  1098. }
  1099. if (panel.use_color_icons)
  1100. {
  1101. /* Use background for color set matching.
  1102. * Use top shadow for clock hand color.
  1103. */
  1104. XtSetArg (al[*ac], XmNpixmapBackground, panel.primary_pixel_set->bg);
  1105. (*ac)++;
  1106. XtSetArg (al[*ac], XmNpixmapForeground, panel.primary_pixel_set->ts);
  1107. (*ac)++;
  1108. }
  1109. else
  1110. {
  1111. if (control_data != NULL &&
  1112. (intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value ==
  1113. CONTROL_CLOCK)
  1114. {
  1115. if (panel.color_use != XmCO_BLACK_WHITE)
  1116. {
  1117. XtSetArg (al[*ac], XmNpixmapForeground, panel.primary_pixel_set->fg);
  1118. (*ac)++;
  1119. XtSetArg(al[*ac], XmNpixmapBackground, panel.primary_pixel_set->bg);
  1120. (*ac)++;
  1121. }
  1122. else
  1123. {
  1124. XtSetArg (al[*ac], XmNpixmapForeground,
  1125. BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1126. XtSetArg (al[*ac], XmNpixmapBackground,
  1127. WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1128. }
  1129. }
  1130. else
  1131. {
  1132. XtSetArg (al[*ac], XmNpixmapBackground,
  1133. WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1134. XtSetArg (al[*ac], XmNpixmapForeground,
  1135. BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1136. }
  1137. }
  1138. XtSetArg (al[*ac], XmNtopShadowColor, panel.primary_pixel_set->ts); (*ac)++;
  1139. XtSetArg (al[*ac], XmNbottomShadowColor, panel.primary_pixel_set->bs);(*ac)++;
  1140. XtSetArg (al[*ac], XmNselectColor, panel.primary_pixel_set->sc); (*ac)++;
  1141. if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value ==
  1142. CONTROL_DATE)
  1143. {
  1144. /*
  1145. XtSetArg (al[*ac], XmNfontList, panel.date_font_list); (*ac)++;
  1146. XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
  1147. XtSetArg (al[*ac], XmNforeground,
  1148. BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1149. */
  1150. if (panel.color_use == XmCO_BLACK_WHITE)
  1151. {
  1152. XtSetArg (al[*ac], XmNbackground,
  1153. WhitePixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1154. }
  1155. }
  1156. else
  1157. {
  1158. XtSetArg (al[*ac], XmNfontList, panel.font_list); (*ac)++;
  1159. }
  1160. XtSetArg (al[*ac], XmNbehavior, XmICON_DRAG); (*ac)++;
  1161. }
  1162. /************************************************************************
  1163. *
  1164. * ControlSetIconData
  1165. * Set up the arg list elements for a controls icon and label
  1166. * resources.
  1167. *
  1168. * Inputs: parent - the widget to be the parent of the control
  1169. * control_data - a pointer to the control to be created
  1170. * icon_label - a return for an XmString for the control's label
  1171. * container_type - the type of parent the control is going into
  1172. * al - a pointer to the arg list to contain the resource data
  1173. * ac - a pointer to the arg list count
  1174. * icon_name - a pointer to the icon name (free after widget
  1175. * is created)
  1176. * alternate_icon_name - a pointer to the icon name (free after widget
  1177. * is created)
  1178. *
  1179. ************************************************************************/
  1180. static void
  1181. ControlSetIconData (Widget parent,
  1182. ControlData * control_data,
  1183. XmString * icon_label,
  1184. int container_type,
  1185. ArgList al,
  1186. int * ac,
  1187. char ** icon_name,
  1188. char ** alternate_icon_name)
  1189. {
  1190. char * control_label;
  1191. int icon_size;
  1192. /* Set up the icon and alternate icon resources for the control */
  1193. if (container_type == BOX)
  1194. icon_size = panel.main_icon_size;
  1195. else if (container_type == SUBPANEL)
  1196. icon_size = panel.sub_icon_size;
  1197. else
  1198. icon_size = panel.switch_icon_size;
  1199. *icon_name =
  1200. (char *) control_data->element_values[CONTROL_NORMAL_ICON].parsed_value;
  1201. if (*icon_name != NULL)
  1202. {
  1203. *icon_name = GetIconName (*icon_name, icon_size);
  1204. XtSetArg (al[*ac], XmNimageName, *icon_name); (*ac)++;
  1205. }
  1206. *alternate_icon_name =
  1207. (char *) control_data->element_values[CONTROL_ALTERNATE_ICON].parsed_value;
  1208. if (*alternate_icon_name != NULL)
  1209. {
  1210. *alternate_icon_name = GetIconName (*alternate_icon_name, icon_size);
  1211. XtSetArg (al[*ac], XmNalternateImage, *alternate_icon_name); (*ac)++;
  1212. }
  1213. /* If this is not a subpanel control and the keyword is is set so that */
  1214. /* labels are not to be displayed, set the string resource to NULL. */
  1215. if (container_type != SUBPANEL && (intptr_t)
  1216. panel.element_values[PANEL_DISPLAY_CONTROL_LABELS].parsed_value == False)
  1217. {
  1218. XtSetArg (al[*ac], XmNstring, NULL); (*ac)++;
  1219. }
  1220. else
  1221. {
  1222. control_label =
  1223. (char *) control_data->element_values[CONTROL_LABEL].parsed_value;
  1224. if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value
  1225. != CONTROL_BLANK)
  1226. {
  1227. if (control_label != NULL)
  1228. {
  1229. *icon_label = XmStringCreateLocalized (control_label);
  1230. XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
  1231. }
  1232. else if (icon_name == NULL)
  1233. {
  1234. control_label =
  1235. (char *) control_data->element_values[CONTROL_NAME].parsed_value;
  1236. *icon_label = XmStringCreateLocalized (control_label);
  1237. XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
  1238. }
  1239. }
  1240. else
  1241. {
  1242. *icon_label = XmStringCreateLocalized ("");
  1243. XtSetArg (al[*ac], XmNstring, *icon_label); (*ac)++;
  1244. }
  1245. }
  1246. }
  1247. /************************************************************************
  1248. *
  1249. * ControlSetBehavior
  1250. * Use the control type value to set the behavior and some visual
  1251. * arg list data to be used to create or set values on a control.
  1252. *
  1253. * Inputs: control_data - a pointer to the control to be created
  1254. * al - the arg list to be set
  1255. * ac - a pointer to the count of the arg list elements
  1256. * in_subpanel - a boolean denoting the parent type of the control
  1257. *
  1258. ************************************************************************/
  1259. static void
  1260. ControlSetBehavior (ControlData * control_data,
  1261. ArgList al,
  1262. int * ac,
  1263. Boolean in_subpanel,
  1264. String * expanded_file_name)
  1265. {
  1266. Boolean sensitive;
  1267. Dimension shadow_thickness;
  1268. Dimension highlight_thickness;
  1269. Dimension margin_width;
  1270. /* Set local shadow thickness and sensitive values to be used */
  1271. /* to set the resources for the various control types. */
  1272. if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value != NULL)
  1273. {
  1274. if (panel.resolution == LOW)
  1275. shadow_thickness = 1;
  1276. else
  1277. shadow_thickness = 2;
  1278. }
  1279. else
  1280. shadow_thickness = 1;
  1281. if (control_data->element_values[CONTROL_PUSH_ACTION].parsed_value != NULL)
  1282. {
  1283. sensitive = True;
  1284. highlight_thickness = 1;
  1285. }
  1286. else
  1287. {
  1288. sensitive = False;
  1289. highlight_thickness = 0;
  1290. }
  1291. if (panel.resolution == HIGH &&
  1292. (intptr_t) control_data->element_values[CONTROL_CONTAINER_TYPE].parsed_value == BOX &&
  1293. in_subpanel == False)
  1294. margin_width = 5;
  1295. else
  1296. margin_width = 2;
  1297. /* All controls get their user data set to their control data */
  1298. /* to be used out of callback functions. */
  1299. XtSetArg (al[*ac], XmNuserData, control_data); (*ac)++;
  1300. /* Switch on the controls control type to set the behaviors */
  1301. /* specific to the individual control types. */
  1302. switch ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value)
  1303. {
  1304. case CONTROL_BLANK:
  1305. {
  1306. XtSetArg (al[*ac], XmNshadowThickness, 0); (*ac)++;
  1307. XtSetArg (al[*ac], XmNhighlightThickness, 0); (*ac)++;
  1308. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BLANK); (*ac)++;
  1309. XtSetArg (al[*ac], XmNbehavior, XmICON_LABEL); (*ac)++;
  1310. XtSetArg (al[*ac], XmNsensitive, False); (*ac)++;
  1311. }
  1312. break;
  1313. case CONTROL_BUSY:
  1314. {
  1315. XtSetArg (al[*ac], XmNshadowThickness, 0); (*ac)++;
  1316. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BUSY); (*ac)++;
  1317. XtSetArg (al[*ac], XmNhighlightThickness, 0); (*ac)++;
  1318. XtSetArg (al[*ac], XmNsensitive, False); (*ac)++;
  1319. XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
  1320. panel.busy_light_data = control_data;
  1321. }
  1322. break;
  1323. case CONTROL_ICON:
  1324. case CONTROL_FILE:
  1325. {
  1326. XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
  1327. XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
  1328. XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
  1329. XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
  1330. if ((intptr_t) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_NONE)
  1331. {
  1332. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_BUTTON); (*ac)++;
  1333. }
  1334. else if ((intptr_t) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_FILE)
  1335. {
  1336. String file_name;
  1337. file_name = (String) control_data->element_values[CONTROL_FILE_NAME].parsed_value;
  1338. *expanded_file_name = (String) _DtWmParseFilenameExpand ((unsigned char*) file_name);
  1339. XtSetArg (al[*ac], XmNfileName, *expanded_file_name); (*ac)++;
  1340. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_MONITOR); (*ac)++;
  1341. }
  1342. else if ((intptr_t) control_data->element_values[CONTROL_MONITOR_TYPE].parsed_value == MONITOR_MAIL)
  1343. {
  1344. String file_name;
  1345. file_name = (String) control_data->element_values[CONTROL_FILE_NAME].parsed_value;
  1346. /*
  1347. * Set fileName resource if specified; otherwise, leave
  1348. * unset and it will default to the user's mail file.
  1349. */
  1350. if ((file_name != (String)NULL) &&
  1351. (*file_name != '\0'))
  1352. {
  1353. *expanded_file_name = (String)
  1354. _DtWmParseFilenameExpand ((unsigned char*) file_name);
  1355. XtSetArg (al[*ac], XmNfileName, *expanded_file_name); (*ac)++;
  1356. }
  1357. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_MAIL); (*ac)++;
  1358. }
  1359. }
  1360. break;
  1361. case CONTROL_CLIENT:
  1362. {
  1363. GeometryData * geometry_data;
  1364. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_CLIENT); (*ac)++;
  1365. XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
  1366. XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
  1367. XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
  1368. geometry_data = (GeometryData *) control_data->
  1369. element_values[CONTROL_CLIENT_GEOMETRY].parsed_value;
  1370. if (geometry_data)
  1371. {
  1372. if (geometry_data->flags & WidthValue && geometry_data->width > 0)
  1373. {
  1374. XtSetArg (al[*ac], XmNwidth, geometry_data->width + 6); (*ac)++;
  1375. }
  1376. if (geometry_data->flags & HeightValue && geometry_data->height > 0)
  1377. {
  1378. XtSetArg (al[*ac], XmNheight, geometry_data->height + 6);(*ac)++;
  1379. }
  1380. }
  1381. }
  1382. break;
  1383. case CONTROL_CLOCK:
  1384. {
  1385. int inset;
  1386. XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
  1387. XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
  1388. XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
  1389. XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
  1390. /* Adjust the size of the clock hands to match the resolution */
  1391. if ((panel.resolution == HIGH || panel.resolution == MEDIUM) &&
  1392. in_subpanel == False)
  1393. inset = 8;
  1394. else
  1395. inset = 6;
  1396. XtSetArg (al[*ac], XmNleftInset, inset); (*ac)++;
  1397. XtSetArg (al[*ac], XmNrightInset, inset); (*ac)++;
  1398. XtSetArg (al[*ac], XmNtopInset, inset); (*ac)++;
  1399. XtSetArg (al[*ac], XmNbottomInset, inset); (*ac)++;
  1400. }
  1401. break;
  1402. case CONTROL_DATE:
  1403. {
  1404. int size;
  1405. XtSetArg (al[*ac], XmNcontrolType, XmCONTROL_DATE); (*ac)++;
  1406. XtSetArg (al[*ac], XmNshadowThickness, shadow_thickness); (*ac)++;
  1407. XtSetArg (al[*ac], XmNsensitive, sensitive); (*ac)++;
  1408. XtSetArg (al[*ac], XmNhighlightThickness,highlight_thickness); (*ac)++;
  1409. XtSetArg (al[*ac], XmNmarginWidth, margin_width); (*ac)++;
  1410. XtSetArg (al[*ac], XmNuseLabelAdjustment, False); (*ac)++;
  1411. if (!control_data->element_values[CONTROL_DATE_FORMAT].use_default)
  1412. {
  1413. XtSetArg (al[*ac], XmNformat,
  1414. control_data->element_values[CONTROL_DATE_FORMAT].parsed_value);
  1415. (*ac)++;
  1416. }
  1417. if (!in_subpanel)
  1418. {
  1419. XtSetArg (al[*ac], XmNpixmapPosition, XmPIXMAP_MIDDLE); (*ac)++;
  1420. XtSetArg (al[*ac], XmNfontList, panel.date_font_list); (*ac)++;
  1421. XtSetArg (al[*ac], XmNuseEmbossedText, False); (*ac)++;
  1422. XtSetArg (al[*ac], XmNforeground,
  1423. BlackPixelOfScreen (XtScreen (panel.form))); (*ac)++;
  1424. }
  1425. else
  1426. {
  1427. XtSetArg (al[*ac], XmNuseEmbossedText, True); (*ac)++;
  1428. }
  1429. }
  1430. break;
  1431. }
  1432. }
  1433. /************************************************************************
  1434. *
  1435. * ControlCreateAndRegister
  1436. * Create the control, add it callbacks, register it, as needed,
  1437. * as dropable, as an embedded client, as a push recall client, its
  1438. * animations.
  1439. *
  1440. * Inputs: parent - the widget to be the parent of the control
  1441. * control_data - a pointer to the control to be created
  1442. * main_copy - this is a boolean indicating that the control
  1443. * being created is a copy of the main panel control
  1444. * that will be contained within a subpanel
  1445. * al - a pointer to the arg list to contain the resource data
  1446. * ac - the arg list count
  1447. *
  1448. ************************************************************************/
  1449. static Widget
  1450. ControlCreateAndRegister (Widget parent,
  1451. ControlData * control_data,
  1452. Boolean main_copy,
  1453. ArgList al,
  1454. int ac)
  1455. {
  1456. Widget icon;
  1457. unsigned char operations = 0;
  1458. char *format, * next_seg;
  1459. Arg al2[4];
  1460. /* Create either a normal control or a clock */
  1461. if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value
  1462. == CONTROL_CLOCK)
  1463. icon = DtCreateClock (parent, "icon", al, ac);
  1464. else
  1465. icon = _DtCreateControl (parent, "icon", al, ac);
  1466. if ((intptr_t)control_data->element_values[CONTROL_TYPE].parsed_value
  1467. == CONTROL_DATE &&
  1468. (control_data->subpanel_data == NULL || main_copy) &&
  1469. (main_copy ||
  1470. (intptr_t)control_data->element_values[CONTROL_CONTAINER_TYPE].parsed_value
  1471. == SUBPANEL))
  1472. {
  1473. format = nl_langinfo(D_FMT);
  1474. XtSetArg (al2[0], XmNformat, format);
  1475. XtSetValues(icon, al2, 1);
  1476. }
  1477. XtManageChild (icon);
  1478. XtAddCallback (icon, XmNcallback, (XtCallbackProc) PushCB, control_data);
  1479. XtAddCallback (icon, XmNhelpCallback,
  1480. (XtCallbackProc) ControlTopicHelpCB, control_data);
  1481. if (!main_copy)
  1482. control_data->icon = icon;
  1483. /* Register the animations */
  1484. if (!main_copy)
  1485. {
  1486. SetupPushAnimation (control_data);
  1487. SetupDropAnimation (control_data);
  1488. }
  1489. /* Set the drop zone for the icon */
  1490. /* Since all file controls have CONTROL_DROP_ACTIONS by default, only */
  1491. /* register the ones that are either a data type that is an action or */
  1492. /* a file type the has either move, copy or link actions associated with */
  1493. /* it. Also register non-file controls that have drop actions as copy. */
  1494. if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value
  1495. != NULL)
  1496. {
  1497. if ((intptr_t)control_data->element_values[CONTROL_TYPE].parsed_value ==
  1498. CONTROL_FILE)
  1499. {
  1500. if (control_data->is_action)
  1501. {
  1502. operations = XmDROP_COPY;
  1503. }
  1504. else
  1505. {
  1506. if (control_data->move_action != NULL)
  1507. operations |= XmDROP_MOVE;
  1508. if (control_data->copy_action != NULL)
  1509. operations |= XmDROP_COPY;
  1510. if (control_data->link_action != NULL)
  1511. operations |= XmDROP_LINK;
  1512. }
  1513. }
  1514. else
  1515. {
  1516. operations = XmDROP_COPY;
  1517. }
  1518. if (operations != 0)
  1519. {
  1520. XtSetArg (al2[0], DtNdropAnimateCallback, dropCB);
  1521. XtSetArg (al2[1], DtNtextIsBuffer, True);
  1522. XtSetArg (al2[2], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
  1523. XtSetArg (al2[3], DtNpreserveRegistration, True);
  1524. /* Temporarily hard-coded to reject buffer drops on the trash
  1525. until the desktop clients have trash actions which can
  1526. take appropriate action on calendar appointments, mail
  1527. attachments, selected text, etc. File Manager is also
  1528. hard-coded to reject buffer drops on the trash window.
  1529. Any changes here should be coordinated with File Manager.
  1530. */
  1531. if (strcmp(control_data->element_values[CONTROL_NAME].parsed_value,
  1532. "Trash") == 0)
  1533. DtDndDropRegister(icon,
  1534. DtDND_FILENAME_TRANSFER,
  1535. operations, transferDropCB, al2, 4);
  1536. else
  1537. DtDndDropRegister(icon,
  1538. DtDND_FILENAME_TRANSFER|DtDND_BUFFER_TRANSFER,
  1539. operations, transferDropCB, al2, 4);
  1540. }
  1541. }
  1542. /* Install the control into the push recall and embedded client list. */
  1543. if (!main_copy)
  1544. {
  1545. if ((intptr_t) control_data->element_values[CONTROL_PUSH_RECALL].parsed_value)
  1546. PushRecallRegister (control_data, True);
  1547. if ((intptr_t) control_data->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
  1548. EmbeddedClientRegister (control_data, True);
  1549. }
  1550. return (icon);
  1551. }
  1552. /************************************************************************
  1553. *
  1554. * SwitchCreate
  1555. * Create the workspace switch area. This consists of three steps.
  1556. * First, call the window manager to get the set of workspace names.
  1557. * Next, create a row column and switch button set for the workspace
  1558. * switch functionality. Last, create the set of controls that
  1559. * surround the switch buttons.
  1560. *
  1561. ************************************************************************/
  1562. static void
  1563. SwitchCreate (BoxData * box_data)
  1564. {
  1565. SwitchData * switch_data = box_data->switch_data;
  1566. int switch_count = 1;
  1567. Atom * atom_names;
  1568. Atom current_workspace_atom;
  1569. int current_workspace = 0;
  1570. Widget switch_button;
  1571. XmString label_string;
  1572. XmPixelSet * pixel_set;
  1573. Pixmap pixmap;
  1574. Widget prev_left = NULL;
  1575. Widget prev_right = NULL;
  1576. char * icon_name = NULL;
  1577. char * alt_icon_name = NULL;
  1578. String exp_file_name = NULL;
  1579. int ac;
  1580. Arg al[40];
  1581. Arg al2[4];
  1582. int i;
  1583. /* Pre create the text field to be used for renaming the workspaces. */
  1584. box_data->switch_edit =
  1585. (Widget) XmCreateTextField (box_data->switch_form, "switch_edit", al, 0);
  1586. /* Get current workspace from the window manager. */
  1587. DtWsmGetCurrentWorkspace (XtDisplay (box_data->switch_form),
  1588. RootWindowOfScreen (XtScreen (box_data->switch_form)),
  1589. &current_workspace_atom);
  1590. /* Get current workspace list from the window manager. */
  1591. if (DtWsmGetWorkspaceList (XtDisplay (box_data->switch_form),
  1592. RootWindowOfScreen (XtScreen (box_data->switch_form)),
  1593. &atom_names, &switch_count) == 0)
  1594. {
  1595. switch_data->atom_names = atom_names;
  1596. switch_data->switch_count = switch_count;
  1597. switch_data->switch_names =
  1598. (char **) XtMalloc (sizeof(char *) * switch_count);
  1599. for (i = 0; i < switch_count; i++)
  1600. {
  1601. DtWsmWorkspaceInfo * workspace_info;
  1602. DtWsmGetWorkspaceInfo (XtDisplay (box_data->switch_form),
  1603. RootWindowOfScreen (XtScreen (box_data->switch_form)),
  1604. atom_names[i], &workspace_info);
  1605. switch_data->switch_names[i] = XtNewString (workspace_info->pchTitle);
  1606. DtWsmFreeWorkspaceInfo (workspace_info);
  1607. if (atom_names[i] == current_workspace_atom)
  1608. current_workspace = i;
  1609. }
  1610. }
  1611. else
  1612. {
  1613. switch_data->switch_names = NULL;
  1614. switch_data->switch_count = 0;
  1615. }
  1616. panel.switch_row_count =
  1617. (int) (intptr_t) (switch_data->element_values[SWITCH_NUMBER_OF_ROWS].parsed_value);
  1618. switch_data->buttons =
  1619. (Widget *) XtMalloc (sizeof (Widget) * switch_count);
  1620. switch_data->popup_data = NULL;
  1621. /* Create the row column within the switch form to contain the */
  1622. /* workspace buttons. */
  1623. ac = 0;
  1624. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  1625. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  1626. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  1627. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  1628. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  1629. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  1630. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  1631. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  1632. XtSetArg (al[ac], XmNnumColumns, panel.switch_row_count); ac++;
  1633. XtSetArg (al[ac], XmNpacking, XmPACK_COLUMN); ac++;
  1634. XtSetArg (al[ac], XmNorientation, XmHORIZONTAL); ac++;
  1635. XtSetArg (al[ac], XmNadjustLast, False); ac++;
  1636. /* Remove all of the tab groups */
  1637. XtSetArg (al[ac], XmNnavigationType, XmNONE); ac++;
  1638. if (panel.color_use == XmCO_BLACK_WHITE)
  1639. {
  1640. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  1641. panel.inactive_pixel_set->bg,
  1642. panel.inactive_pixel_set->fg);
  1643. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  1644. }
  1645. else
  1646. {
  1647. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  1648. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  1649. }
  1650. switch_data->rc =
  1651. XmCreateRowColumn (box_data->switch_form, "switch_rc", al, ac);
  1652. XtManageChild (switch_data->rc);
  1653. /* Create the switch buttons */
  1654. SwitchButtonCreate (switch_data, False);
  1655. /* Set the active switch button to the active workspace */
  1656. XtSetArg (al[0], XmNset, True);
  1657. switch_data->active_switch = current_workspace;
  1658. XtSetValues (switch_data->buttons[current_workspace], al, 1);
  1659. /* Initialize time stamp for catching multi-click events */
  1660. switch_data->time_stamp = 0;
  1661. /* Create each of the switch controls and adjust the switch_rc's */
  1662. /* constraints to position it properly. */
  1663. /* Set up a loop and create each control within the switch */
  1664. for (i = 0; i < switch_data->control_data_count; i++)
  1665. {
  1666. ControlData * control_data = switch_data->control_data[i];
  1667. XmString icon_label = NULL;
  1668. ac = 0;
  1669. ControlSetVisualData (control_data, al, &ac);
  1670. XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
  1671. if (i % 2)
  1672. {
  1673. if (prev_right == NULL)
  1674. {
  1675. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  1676. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  1677. }
  1678. else
  1679. {
  1680. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  1681. XtSetArg (al[ac], XmNtopWidget, prev_right); ac++;
  1682. }
  1683. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  1684. XtSetArg (al[ac], XmNleftWidget, switch_data->rc); ac++;
  1685. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  1686. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  1687. }
  1688. else
  1689. {
  1690. if (prev_left == NULL)
  1691. {
  1692. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  1693. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  1694. }
  1695. else
  1696. {
  1697. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  1698. XtSetArg (al[ac], XmNtopWidget, prev_left); ac++;
  1699. }
  1700. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  1701. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  1702. }
  1703. if (i >= switch_data->control_data_count - 2)
  1704. {
  1705. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  1706. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  1707. }
  1708. /* Call the function used to set the control's icon and label data */
  1709. ControlSetIconData (box_data->switch_form, control_data,
  1710. &icon_label, SWITCH, al, &ac, &icon_name,
  1711. &alt_icon_name);
  1712. /* Call the function used to set the control's behavioral aspects */
  1713. ControlSetBehavior (control_data, al, &ac, False, &exp_file_name);
  1714. /* Call the function used to create and register the control */
  1715. control_data->icon =
  1716. ControlCreateAndRegister (box_data->switch_form,
  1717. control_data, False, al, ac);
  1718. if (icon_label != NULL)
  1719. XmStringFree (icon_label);
  1720. if (icon_name != NULL)
  1721. XtFree(icon_name);
  1722. if (alt_icon_name != NULL)
  1723. XtFree(alt_icon_name);
  1724. if (exp_file_name != NULL)
  1725. XtFree(exp_file_name);
  1726. if (i % 2)
  1727. prev_right = control_data->icon;
  1728. else
  1729. prev_left = control_data->icon;
  1730. if (i == 0)
  1731. {
  1732. XtSetArg (al2[0], XmNleftAttachment, XmATTACH_WIDGET);
  1733. XtSetArg (al2[1], XmNleftWidget, prev_left);
  1734. XtSetArg (al2[2], XmNrightAttachment, XmATTACH_NONE);
  1735. XtSetValues (switch_data->rc, al2, 3);
  1736. }
  1737. }
  1738. }
  1739. /************************************************************************
  1740. *
  1741. * SwitchButtonCreate
  1742. * Create either the full set of switch button or one new one.
  1743. *
  1744. *************************************************************************/
  1745. void
  1746. SwitchButtonCreate (SwitchData * switch_data,
  1747. Boolean one)
  1748. {
  1749. BoxData * box_data;
  1750. XmPixelSet * pixel_set;
  1751. int switch_count;
  1752. XmString label_string;
  1753. Arg al[40];
  1754. int ac;
  1755. int ac_save;
  1756. int i;
  1757. /* Find the box data which contains the switch. This is needed */
  1758. /* for the switch callback processing. */
  1759. box_data = switch_data->box_data;
  1760. /* Calculate switch height */
  1761. if (!switch_height) {
  1762. Dimension ignore_width;
  1763. label_string = XmStringCreateLocalized (switch_data->switch_names[0]);
  1764. XmStringExtent(panel.font_list,label_string,
  1765. &ignore_width,&switch_height);
  1766. XmStringFree(label_string);
  1767. if (panel.resolution == HIGH || panel.resolution == MEDIUM) {
  1768. switch_height += 14;
  1769. if (switch_height < SWITCH_HIGH_BUTTON_HEIGHT) {
  1770. switch_height = SWITCH_HIGH_BUTTON_HEIGHT;
  1771. }
  1772. } else {
  1773. switch_height += 8;
  1774. if (switch_height < SWITCH_LOW_BUTTON_HEIGHT) {
  1775. switch_height = SWITCH_LOW_BUTTON_HEIGHT;
  1776. }
  1777. }
  1778. }
  1779. /* Create Switch Toggles */
  1780. ac = 0;
  1781. XtSetArg (al[ac], XmNfillOnArm, False); ac++;
  1782. if (panel.resolution == HIGH || panel.resolution == MEDIUM)
  1783. {
  1784. XtSetArg (al[ac], XmNwidth, SWITCH_HIGH_BUTTON_WIDTH); ac++;
  1785. XtSetArg (al[ac], XmNshadowThickness, 3); ac++;
  1786. XtSetArg (al[ac], XmNmarginWidth, 4); ac++;
  1787. }
  1788. else
  1789. {
  1790. XtSetArg (al[ac], XmNwidth, SWITCH_LOW_BUTTON_WIDTH); ac++;
  1791. XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
  1792. XtSetArg (al[ac], XmNmarginWidth, 2); ac++;
  1793. }
  1794. XtSetArg (al[ac], XmNheight, switch_height); ac++;
  1795. XtSetArg (al[ac], XmNbehavior, XmICON_TOGGLE); ac++;
  1796. XtSetArg (al[ac], XmNfillMode, XmFILL_SELF); ac++;
  1797. XtSetArg (al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
  1798. XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_BOTTOM); ac++;
  1799. XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
  1800. XtSetArg (al[ac], XmNmarginHeight, 0); ac++;
  1801. XtSetArg (al[ac], XmNspacing, 0); ac++;
  1802. XtSetArg (al[ac], XmNcontrolType, XmCONTROL_SWITCH); ac++;
  1803. XtSetArg (al[ac], XmNfontList, panel.font_list); ac++;
  1804. XtSetArg (al[ac], XmNrecomputeSize, False); ac++;
  1805. XtSetArg (al[ac], XmNuserData, box_data); ac++;
  1806. ac_save = ac;
  1807. /* Set up a loop to either create a full set of switch buttons */
  1808. /* or just one, depending on the input parameters. */
  1809. switch_count = switch_data->switch_count;
  1810. for (i = 0; i < switch_count; i++)
  1811. {
  1812. int pixel_set_index = 1, map_index;
  1813. if (one == True)
  1814. i = switch_count - 1;
  1815. ac = ac_save;
  1816. /* Set pixel resources. */
  1817. switch (panel.color_use)
  1818. {
  1819. case XmCO_BLACK_WHITE:
  1820. case XmCO_LOW_COLOR:
  1821. pixel_set_index = 1;
  1822. break;
  1823. case XmCO_MEDIUM_COLOR:
  1824. pixel_set_index = HARD_CODED_PRIMARY;
  1825. break;
  1826. case XmCO_HIGH_COLOR:
  1827. map_index = i % _WS_HIGH_COLOR_COUNT;
  1828. pixel_set_index = _ws_high_color_map[map_index];
  1829. break;
  1830. }
  1831. pixel_set = &panel.pixel_set[pixel_set_index - 1];
  1832. XtSetArg (al[ac], XmNforeground, pixel_set->fg); ac++;
  1833. XtSetArg (al[ac], XmNbackground, pixel_set->bg); ac++;
  1834. XtSetArg (al[ac], XmNarmColor, pixel_set->bg); ac++;
  1835. XtSetArg (al[ac], XmNfillOnArm, False); ac++;
  1836. if (panel.color_use == XmCO_BLACK_WHITE)
  1837. {
  1838. XtSetArg (al[ac], XmNuseEmbossedText, False); ac++;
  1839. XtSetArg (al[ac], XmNpixmapBackground,
  1840. WhitePixelOfScreen (XtScreen (panel.form))); ac++;
  1841. XtSetArg (al[ac], XmNpixmapForeground,
  1842. BlackPixelOfScreen (XtScreen (panel.form))); ac++;
  1843. }
  1844. else
  1845. {
  1846. XtSetArg (al[ac], XmNpixmapBackground, pixel_set->ts); ac++;
  1847. XtSetArg (al[ac], XmNpixmapForeground, pixel_set->bs); ac++;
  1848. }
  1849. /* Set label. */
  1850. label_string = XmStringCreateLocalized (switch_data->switch_names[i]);
  1851. XtSetArg (al[ac], XmNstring, label_string); ac++;
  1852. switch_data->buttons[i] =
  1853. _DtCreateControl (switch_data->rc, "toggle", al, ac);
  1854. XtManageChild (switch_data->buttons[i]);
  1855. XtAddCallback (switch_data->buttons[i], XmNcallback,
  1856. (XtCallbackProc) SwitchButtonCB, NULL);
  1857. XtAddCallback (switch_data->buttons[i], XmNhelpCallback,
  1858. (XtCallbackProc) GeneralTopicHelpCB, SWITCH_BUTTON);
  1859. XmStringFree (label_string);
  1860. }
  1861. }
  1862. /************************************************************************
  1863. *
  1864. * ControlCreate
  1865. *
  1866. ************************************************************************/
  1867. static void
  1868. ControlCreate (Widget parent,
  1869. ControlData ** control_data,
  1870. int control_count)
  1871. {
  1872. int i;
  1873. Arg al[40];
  1874. int ac;
  1875. Widget prev_icon = NULL;
  1876. char * icon_name = NULL;
  1877. char * alt_icon_name = NULL;
  1878. String exp_file_name = NULL;
  1879. XmString icon_label = NULL;
  1880. /* Set up a loop and create each control within the box */
  1881. for (i = 0; i < control_count; i++)
  1882. {
  1883. ac = 0;
  1884. ControlSetVisualData (control_data[i], al, &ac);
  1885. XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
  1886. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  1887. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  1888. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  1889. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  1890. if (prev_icon == NULL)
  1891. {
  1892. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  1893. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  1894. }
  1895. else
  1896. {
  1897. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  1898. XtSetArg (al[ac], XmNleftWidget, prev_icon); ac++;
  1899. }
  1900. if (i == control_count - 1)
  1901. {
  1902. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  1903. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  1904. }
  1905. /* Call the function used to set the control's icon and label data */
  1906. ControlSetIconData (parent, control_data[i], &icon_label, BOX, al, &ac,
  1907. &icon_name, &alt_icon_name);
  1908. /* Call the function used to set the control's behavioral aspects */
  1909. ControlSetBehavior (control_data[i], al, &ac, False, &exp_file_name);
  1910. /* Call the function used to create and register the control */
  1911. control_data[i]->icon =
  1912. ControlCreateAndRegister (parent, control_data[i], False, al, ac);
  1913. if (icon_label != NULL)
  1914. {
  1915. XmStringFree (icon_label);
  1916. icon_label = NULL;
  1917. }
  1918. if (icon_name != NULL)
  1919. {
  1920. XtFree(icon_name);
  1921. icon_name = NULL;
  1922. }
  1923. if (alt_icon_name != NULL)
  1924. {
  1925. XtFree(alt_icon_name);
  1926. alt_icon_name = NULL;
  1927. }
  1928. if (exp_file_name != NULL)
  1929. {
  1930. XtFree(exp_file_name);
  1931. exp_file_name = NULL;
  1932. }
  1933. prev_icon = control_data[i]->icon;
  1934. if (control_data[i]->subpanel_data != NULL)
  1935. SubpanelCreate (control_data[i], control_data[i]->subpanel_data);
  1936. }
  1937. }
  1938. /************************************************************************
  1939. *
  1940. * ArrowCreate
  1941. *
  1942. ************************************************************************/
  1943. static void
  1944. ArrowCreate (Widget parent,
  1945. ControlData ** control_data,
  1946. int arrow_count,
  1947. Boolean right_side,
  1948. Boolean first_box)
  1949. {
  1950. int i;
  1951. Widget prev_separator = NULL;
  1952. Arg al[40];
  1953. Arg al2[30];
  1954. Arg al3[1];
  1955. int ac;
  1956. int ac2;
  1957. int ac_save;
  1958. int ac2_save;
  1959. Dimension control_width;
  1960. Pixmap pixmap;
  1961. /* If there is no arrow form (there are no subpanels for the controls) */
  1962. /* then the parent widget will be null so just return. */
  1963. if (parent == NULL)
  1964. return;
  1965. ac = 0;
  1966. if (first_box)
  1967. {
  1968. XtSetArg (al[ac], XmNtopOffset, 0); ac++;
  1969. XtSetArg (al[ac], XmNbottomOffset, 0); ac++;
  1970. }
  1971. else
  1972. {
  1973. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  1974. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  1975. }
  1976. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  1977. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  1978. XtSetArg (al[ac], XmNbackground, panel.inactive_pixel_set->bg); ac++;
  1979. XtSetArg (al[ac], XmNforeground, panel.inactive_pixel_set->fg); ac++;
  1980. XtSetArg (al[ac], XmNtopShadowColor, panel.inactive_pixel_set->ts); ac++;
  1981. XtSetArg (al[ac], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac++;
  1982. XtSetArg (al[ac], XmNselectColor, panel.inactive_pixel_set->sc); ac++;
  1983. XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
  1984. XtSetArg (al[ac], XmNshadowThickness, 0); ac++;
  1985. if (panel.color_use == XmCO_BLACK_WHITE)
  1986. {
  1987. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  1988. panel.inactive_pixel_set->fg,
  1989. panel.inactive_pixel_set->bg);
  1990. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  1991. }
  1992. ac_save = ac;
  1993. ac2 = 0;
  1994. XtSetArg (al2[ac2], XmNtopAttachment, XmATTACH_FORM); ac2++;
  1995. XtSetArg (al2[ac2], XmNtopOffset, 0); ac2++;
  1996. XtSetArg (al2[ac2], XmNbottomAttachment, XmATTACH_FORM); ac2++;
  1997. XtSetArg (al2[ac2], XmNbottomOffset, 0); ac2++;
  1998. XtSetArg (al2[ac2], XmNbackground, panel.inactive_pixel_set->bg); ac2++;
  1999. XtSetArg (al2[ac2], XmNforeground, panel.inactive_pixel_set->fg); ac2++;
  2000. XtSetArg (al2[ac2], XmNtopShadowColor, panel.inactive_pixel_set->ts);ac2++;
  2001. XtSetArg (al2[ac2], XmNbottomShadowColor, panel.inactive_pixel_set->bs); ac2++;
  2002. XtSetArg (al2[ac2], XmNshadowThickness, 2); ac2++;
  2003. XtSetArg (al2[ac2], XmNorientation, XmVERTICAL); ac2++;
  2004. ac2_save = ac2;
  2005. for (i = 0; i < arrow_count; i++)
  2006. {
  2007. ac = ac_save;
  2008. ac2 = ac2_save;
  2009. if (prev_separator == NULL)
  2010. {
  2011. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  2012. if (first_box)
  2013. {
  2014. XtSetArg (al[ac], XmNleftOffset, 0); ac++;
  2015. }
  2016. else
  2017. {
  2018. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  2019. }
  2020. }
  2021. else
  2022. {
  2023. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  2024. XtSetArg (al[ac], XmNleftWidget, prev_separator); ac++;
  2025. }
  2026. control_width = XtWidth (control_data[i]->icon);
  2027. control_width += 2;
  2028. if (i == 0 && right_side == True)
  2029. control_width -= 2;
  2030. else if (i == 0 && right_side == False)
  2031. control_width -= 2;
  2032. else if (i != 0)
  2033. control_width -= 4;
  2034. if (i == 0 && first_box == False)
  2035. control_width -= 2;
  2036. XtSetArg (al[ac], XmNwidth, control_width); ac++;
  2037. if (control_data[i]->subpanel_data == NULL)
  2038. {
  2039. XtSetArg (al[ac], XmNimageName, blank_arrow_image); ac++;
  2040. }
  2041. else
  2042. {
  2043. if ((intptr_t) (control_data[i]->
  2044. element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
  2045. {
  2046. if (CheckOtherMonitorsOn(control_data[i]->subpanel_data))
  2047. {
  2048. XtSetArg (al[ac], XmNimageName, post_monitor_arrow_image); ac++;
  2049. }
  2050. else
  2051. {
  2052. XtSetArg (al[ac], XmNimageName, post_arrow_image); ac++;
  2053. }
  2054. }
  2055. else
  2056. {
  2057. XtSetArg (al[ac], XmNimageName, post_arrow_image); ac++;
  2058. }
  2059. }
  2060. XtSetArg (al[ac], XmNmultiClick, XmMULTICLICK_DISCARD); ac++;
  2061. control_data[i]->arrow =
  2062. DtCreateButtonGadget (parent, "arrow", al, ac);
  2063. XtManageChild (control_data[i]->arrow);
  2064. if (control_data[i]->subpanel_data == NULL)
  2065. XtSetSensitive (control_data[i]->arrow, False);
  2066. XtAddCallback (control_data[i]->arrow, XmNcallback,
  2067. ArrowCB,
  2068. (XtPointer) control_data[i]);
  2069. if (i < arrow_count - 1)
  2070. {
  2071. XtSetArg (al2[ac2], XmNleftAttachment, XmATTACH_WIDGET); ac2++;
  2072. XtSetArg (al2[ac2], XmNleftWidget, control_data[i]->arrow); ac2++;
  2073. if (i == 0 && right_side == False)
  2074. {
  2075. XtSetArg (al2[ac2], XmNleftOffset, 1); ac2++;
  2076. }
  2077. else if (i == 0 && right_side == True)
  2078. {
  2079. XtSetArg (al2[ac2], XmNleftOffset, 3); ac2++;
  2080. }
  2081. else
  2082. {
  2083. XtSetArg (al2[ac2], XmNleftOffset, 0); ac2++;
  2084. }
  2085. control_data[i]->arrow_separator =
  2086. XmCreateSeparatorGadget (parent, "arrow_separator", al2, ac2);
  2087. XtManageChild (control_data[i]->arrow_separator);
  2088. prev_separator = control_data[i]->arrow_separator;
  2089. }
  2090. }
  2091. }
  2092. /************************************************************************
  2093. *
  2094. * SubpanelCreate
  2095. *
  2096. ************************************************************************/
  2097. static void
  2098. SubpanelCreate (ControlData * main_control_data,
  2099. SubpanelData * subpanel_data)
  2100. {
  2101. DtPanelShellWidget subpanel_shell;
  2102. char * subpanel_name = (char *) subpanel_data->element_values[SUBPANEL_TITLE].parsed_value;
  2103. XmString icon_label;
  2104. ControlData * control_data;
  2105. Widget attach_widget;
  2106. Boolean control_install;
  2107. Boolean monitor = False;
  2108. Boolean main = False;
  2109. Pixmap pixmap;
  2110. int i;
  2111. Arg al[40];
  2112. Arg al2[3];
  2113. int ac;
  2114. int ac_save;
  2115. /* Create the subpanel shell. */
  2116. ac = 0;
  2117. XtSetArg (al[ac], XmNallowShellResize, True); ac++;
  2118. XtSetArg (al[ac], XmNmwmDecorations, MWM_DECOR_MENU | MWM_DECOR_TITLE); ac++;
  2119. XtSetArg (al[ac], XmNtitle, subpanel_name); ac++;
  2120. subpanel_data->shell =
  2121. XtCreatePopupShell (subpanel_name, xmDialogShellWidgetClass,
  2122. panel.shell, al, ac);
  2123. XtSetMappedWhenManaged (subpanel_data->shell, False);
  2124. /* Set pixel resources. */
  2125. ac = 0;
  2126. XtSetArg (al[ac], XmNforeground, panel.primary_pixel_set->fg); ac++;
  2127. XtSetArg (al[ac], XmNbackground, panel.primary_pixel_set->bg); ac++;
  2128. XtSetArg (al[ac], XmNtopShadowColor, panel.primary_pixel_set->ts); ac++;
  2129. XtSetArg (al[ac], XmNbottomShadowColor, panel.primary_pixel_set->bs);ac++;
  2130. XtSetArg (al[ac], XmNselectColor, panel.primary_pixel_set->sc); ac++;
  2131. if (panel.color_use == XmCO_BLACK_WHITE)
  2132. {
  2133. XtSetArg (al[ac], XmNuseEmbossedText, False); ac++;
  2134. XtSetArg (al[ac], XmNarmColor, panel.primary_pixel_set->bg); ac++;
  2135. XtSetArg (al[ac], XmNpixmapBackground,
  2136. WhitePixelOfScreen (XtScreen (panel.form))); ac++;
  2137. XtSetArg (al[ac], XmNpixmapForeground,
  2138. BlackPixelOfScreen (XtScreen (panel.form))); ac++;
  2139. }
  2140. if (panel.color_use == XmCO_LOW_COLOR)
  2141. {
  2142. XtSetArg (al[ac], XmNpixmapBackground,
  2143. WhitePixelOfScreen (XtScreen (panel.form))); ac++;
  2144. XtSetArg (al[ac], XmNpixmapForeground, panel.primary_pixel_set->bg); ac++;
  2145. XtSetArg (al[ac], XmNpixmapForeground, panel.primary_pixel_set->bg); ac++;
  2146. }
  2147. ac_save = ac;
  2148. XtSetArg (al[ac], XmNshadowThickness, 1); ac++;
  2149. /* Create the outer form widget that will contain the entire panel */
  2150. XtSetArg (al[ac], XmNuserData, SUBPANEL); ac++;
  2151. if (panel.color_use == XmCO_BLACK_WHITE)
  2152. {
  2153. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  2154. panel.inactive_pixel_set->fg,
  2155. panel.inactive_pixel_set->bg);
  2156. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  2157. }
  2158. subpanel_data->form =
  2159. XmCreateForm (subpanel_data->shell, subpanel_name, al, ac);
  2160. XtManageChild (subpanel_data->form);
  2161. XtAddCallback (subpanel_data->form, XmNhelpCallback,
  2162. (XtCallbackProc) SubpanelTopicHelpCB, subpanel_data);
  2163. if (panel.popup_data == NULL || panel.popup_data->popup == NULL)
  2164. CreatePopupMenu (subpanel_data->form);
  2165. else
  2166. XmAddToPostFromList (panel.popup_data->popup, subpanel_data->form);
  2167. /* Event handler for posting popup menu */
  2168. XtAddEventHandler (subpanel_data->form, ButtonPressMask, False,
  2169. (XtEventHandler) PostPopupMenu, (XtPointer) NULL);
  2170. /* If the value for subpanel control install is true, create */
  2171. /* the drop zone as the top child of the form */
  2172. control_install =
  2173. (Boolean) (intptr_t) subpanel_data->element_values[SUBPANEL_CONTROL_INSTALL].parsed_value;
  2174. if (control_install)
  2175. {
  2176. icon_label = XmStringCreateLocalized (GETMESSAGE (84, 1, "Install Icon"));
  2177. ac = ac_save;
  2178. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  2179. XtSetArg (al[ac], XmNtopOffset, 5); ac++;
  2180. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  2181. XtSetArg (al[ac], XmNleftOffset, 5); ac++;
  2182. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  2183. XtSetArg (al[ac], XmNrightOffset, 5); ac++;
  2184. XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
  2185. XtSetArg (al[ac], XmNhighlightThickness, 1); ac++;
  2186. XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
  2187. XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
  2188. XtSetArg (al[ac], XmNstring, icon_label); ac++;
  2189. XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_LEFT); ac++;
  2190. XtSetArg (al[ac], XmNbehavior, XmICON_LABEL); ac++;
  2191. XtSetArg (al[ac], XmNimageName, dropzone_image); ac++;
  2192. XtSetArg (al[ac], XmNuserData, subpanel_data); ac++;
  2193. XtSetArg (al[ac], XmNfontList, panel.font_list); ac++;
  2194. XtSetArg (al[ac], XmNtraversalOn, False); ac++;
  2195. if (panel.color_use == XmCO_BLACK_WHITE)
  2196. {
  2197. pixmap = XmGetPixmap (XtScreen (panel.form), "50_foreground",
  2198. panel.inactive_pixel_set->fg,
  2199. panel.inactive_pixel_set->bg);
  2200. XtSetArg (al[ac], XmNbackgroundPixmap, pixmap); ac++;
  2201. }
  2202. subpanel_data->dropzone =
  2203. _DtCreateControl (subpanel_data->form, "dropzone", al, ac);
  2204. XtManageChild (subpanel_data->dropzone);
  2205. XmStringFree (icon_label);
  2206. XtAddCallback (subpanel_data->dropzone, XmNhelpCallback,
  2207. (XtCallbackProc) GeneralTopicHelpCB, INSTALL_ZONE);
  2208. /* Set the drop zone for the install area. */
  2209. XtSetArg (al2[0], DtNdropAnimateCallback, customizeDropCB);
  2210. XtSetArg (al2[1], XmNanimationStyle, XmDRAG_UNDER_SHADOW_IN);
  2211. XtSetArg (al2[2], DtNpreserveRegistration, True);
  2212. DtDndDropRegister (subpanel_data->dropzone, DtDND_FILENAME_TRANSFER,
  2213. XmDROP_COPY, customizeTransferDropCB, al2, 3);
  2214. /* Create the separator that goes between the dropzone and controls */
  2215. ac = ac_save;
  2216. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  2217. XtSetArg (al[ac], XmNtopWidget, subpanel_data->dropzone); ac++;
  2218. XtSetArg (al[ac], XmNtopOffset, 5); ac++;
  2219. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  2220. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  2221. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  2222. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  2223. XtSetArg (al[ac], XmNshadowThickness, 2); ac++;
  2224. XtSetArg (al[ac], XmNorientation, XmHORIZONTAL); ac++;
  2225. subpanel_data->separator =
  2226. XmCreateSeparatorGadget (subpanel_data->form,
  2227. "subpanel_separator", al, ac);
  2228. XtManageChild (subpanel_data->separator);
  2229. }
  2230. /* Loop through the control set and see if any of the controls */
  2231. /* have monitor files attached to them. If so, the constraints */
  2232. /* for the form need to be set appropriately. */
  2233. if ((intptr_t) (main_control_data->
  2234. element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
  2235. monitor = True;
  2236. if (monitor == False)
  2237. {
  2238. for (i = 0; i < subpanel_data->control_data_count; i++)
  2239. {
  2240. if ((intptr_t) (subpanel_data->control_data[i]->
  2241. element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
  2242. {
  2243. monitor = True;
  2244. break;
  2245. }
  2246. }
  2247. }
  2248. if (control_install)
  2249. attach_widget = subpanel_data->separator;
  2250. else
  2251. attach_widget = subpanel_data->form;
  2252. /* Set up a loop and create each control within the subpanel */
  2253. for (i = -1; i < subpanel_data->control_data_count; i++)
  2254. {
  2255. if (i == -1)
  2256. {
  2257. control_data = main_control_data;
  2258. main = True;
  2259. }
  2260. else
  2261. {
  2262. control_data = subpanel_data->control_data[i];
  2263. main = False;
  2264. }
  2265. SubpanelControlCreate (subpanel_data, main_control_data, control_data,
  2266. attach_widget, main, monitor);
  2267. if (main)
  2268. attach_widget = subpanel_data->main_panel_icon_copy;
  2269. else
  2270. attach_widget = control_data->icon;
  2271. }
  2272. /* Pad the bottom of the last control in the subpanel */
  2273. ac = 0;
  2274. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  2275. XtSetArg (al[ac], XmNbottomOffset, 5); ac++;
  2276. XtSetValues (attach_widget, al, ac);
  2277. XtUnmanageChild (subpanel_data->form);
  2278. XtSetMappedWhenManaged (subpanel_data->shell, True);
  2279. /* Add the callback for handling subpanel unmaps from the system menu */
  2280. XtAddCallback (subpanel_data->form, XmNunmapCallback,
  2281. (XtCallbackProc) SubpanelUnmapCB,
  2282. (XtPointer) main_control_data);
  2283. /* Set subpanel posting state variables */
  2284. subpanel_data->torn = False;
  2285. /* Initialize the subpanels default control setting to the main */
  2286. /* panel control. */
  2287. subpanel_data->default_control = main_control_data;
  2288. /* Set the initial XmNcancelButton resource to the default control */
  2289. /* within the subpanel. */
  2290. if (subpanel_data->control_data)
  2291. XtSetArg (al[0], XmNcancelButton, subpanel_data->control_data[0]->icon);
  2292. else
  2293. XtSetArg (al[0], XmNcancelButton, subpanel_data->main_panel_icon_copy);
  2294. XtSetValues (subpanel_data->form, al, 1);
  2295. }
  2296. /************************************************************************
  2297. *
  2298. * SubpanelControlCreate
  2299. * Create a control within the subpanel
  2300. *
  2301. ************************************************************************/
  2302. void
  2303. SubpanelControlCreate (SubpanelData * subpanel_data,
  2304. ControlData * main_control_data,
  2305. ControlData * control_data,
  2306. Widget attach_widget,
  2307. Boolean main,
  2308. Boolean monitor)
  2309. {
  2310. XmString icon_label = NULL;
  2311. Widget control_icon;
  2312. Arg al[40];
  2313. int ac = 0;
  2314. int ac_save;
  2315. char m_state;
  2316. char * icon_name = NULL;
  2317. char * alt_icon_name = NULL;
  2318. String exp_file_name = NULL;
  2319. /* Call the function used to set the control's pixel and font data */
  2320. ControlSetVisualData (control_data, al, &ac);
  2321. ac_save = ac;
  2322. /* Set the control's positioning resources */
  2323. if (monitor)
  2324. {
  2325. XtSetArg (al[ac], XmNleftOffset, 20); ac++;
  2326. }
  2327. else
  2328. {
  2329. XtSetArg (al[ac], XmNleftOffset, 5); ac++;
  2330. }
  2331. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  2332. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
  2333. XtSetArg (al[ac], XmNtopWidget, attach_widget); ac++;
  2334. XtSetArg (al[ac], XmNtopOffset, 5); ac++;
  2335. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  2336. XtSetArg (al[ac], XmNrightOffset, 5); ac++;
  2337. XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
  2338. XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
  2339. /* Call the function used to set the control's icon and label data */
  2340. ControlSetIconData (subpanel_data->form, control_data,
  2341. &icon_label, SUBPANEL, al, &ac,
  2342. &icon_name, &alt_icon_name);
  2343. /* Call the function used to set the control's behavioral aspects */
  2344. ControlSetBehavior (control_data, al, &ac, True, &exp_file_name);
  2345. /* Call the function used to create and register the control */
  2346. control_icon =
  2347. ControlCreateAndRegister(subpanel_data->form, control_data, main, al, ac);
  2348. if (main)
  2349. subpanel_data->main_panel_icon_copy = control_icon;
  2350. else
  2351. control_data->icon = control_icon;
  2352. if (icon_label != NULL)
  2353. XmStringFree (icon_label);
  2354. if (icon_name != NULL)
  2355. XtFree(icon_name);
  2356. if (alt_icon_name != NULL)
  2357. XtFree(alt_icon_name);
  2358. if (exp_file_name != NULL)
  2359. XtFree(exp_file_name);
  2360. /* If there is a monitor file, create the indicator */
  2361. if ((intptr_t) (control_data->
  2362. element_values[CONTROL_MONITOR_TYPE].parsed_value) != MONITOR_NONE)
  2363. {
  2364. ac = ac_save;
  2365. m_state = _DtControlGetMonitorState(control_icon);
  2366. XtSetArg (al[ac], XmNleftOffset, 3); ac++;
  2367. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  2368. XtSetArg (al[ac], XmNtopOffset, 6); ac++;
  2369. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); ac++;
  2370. XtSetArg (al[ac], XmNtopWidget, control_icon); ac++;
  2371. XtSetArg (al[ac], XmNhighlightThickness, 0); ac++;
  2372. XtSetArg (al[ac], XmNmarginWidth, 1); ac++;
  2373. XtSetArg (al[ac], XmNmarginHeight, 1); ac++;
  2374. XtSetArg (al[ac], XmNstring, NULL); ac++;
  2375. if (m_state == DtMONITOR_ON)
  2376. {
  2377. XtSetArg (al[ac], XmNimageName, indicator_on_image); ac++;
  2378. }
  2379. else /* DtMONITOR_OFF */
  2380. {
  2381. XtSetArg (al[ac], XmNimageName, indicator_off_image); ac++;
  2382. }
  2383. control_data->indicator =
  2384. _DtCreateControl (subpanel_data->form, "indicator", al, ac);
  2385. XtManageChild (control_data->indicator);
  2386. XtAddCallback (control_data->indicator, XmNhelpCallback,
  2387. (XtCallbackProc) GeneralTopicHelpCB, MONITOR_INDICATOR);
  2388. XtSetSensitive (control_data->indicator, False);
  2389. }
  2390. }
  2391. /************************************************************************
  2392. *
  2393. * UpdateSwitchGeometry
  2394. * Updates the geometry of the switch area to layout the switch
  2395. * buttons and switch controls appropriately.
  2396. *
  2397. * Inputs:
  2398. * box_data: The box that contains the switch.
  2399. *
  2400. ************************************************************************/
  2401. void
  2402. UpdateSwitchGeometry (BoxData * box_data)
  2403. {
  2404. int new_margin;
  2405. Dimension switch_rc_height, switch_button_height;
  2406. Arg al[2];
  2407. if (box_data->switch_data == NULL) return;
  2408. XtSetArg (al[0], XmNheight, &switch_rc_height);
  2409. XtGetValues (box_data->switch_data->rc, al, 1);
  2410. XtSetArg (al[0], XmNheight, &switch_button_height);
  2411. XtGetValues (box_data->switch_data->buttons[0], al, 1);
  2412. new_margin = ((int)switch_rc_height -
  2413. (int)switch_button_height * panel.switch_row_count) /
  2414. (panel.switch_row_count + 1);
  2415. if (new_margin < 1) new_margin = 1;
  2416. XtSetArg (al[0], XmNmarginHeight, new_margin);
  2417. XtSetArg (al[1], XmNspacing, new_margin);
  2418. XtSetValues (box_data->switch_data->rc, al, 2);
  2419. }
  2420. /************************************************************************
  2421. *
  2422. * AddSubpanel
  2423. * Create and initialize a new subpanel and attach it to control_data
  2424. *
  2425. * Inputs:
  2426. * control_data: The main panel control to which the subpanel
  2427. * will be attached.
  2428. *
  2429. ************************************************************************/
  2430. void
  2431. AddSubpanel (ControlData * control_data)
  2432. {
  2433. ElementValue * element_values;
  2434. SubpanelData * subpanel_data = NULL;
  2435. BoxData * box_data = (BoxData *)control_data->parent_data;
  2436. DtWmHints vHints;
  2437. Arg al[2];
  2438. int i;
  2439. if (control_data->subpanel_data == NULL)
  2440. {
  2441. control_data->subpanel_data =
  2442. (SubpanelData *) XtMalloc (sizeof (SubpanelData));
  2443. subpanel_data = control_data->subpanel_data;
  2444. element_values = (ElementValue *) XtMalloc (sizeof(ElementValue) *
  2445. SUBPANEL_KEYWORD_COUNT);
  2446. for (i = 0; i < SUBPANEL_KEYWORD_COUNT; i++)
  2447. {
  2448. (element_values)[i].use_default = True;
  2449. (element_values)[i].string_value = NULL;
  2450. (element_values)[i].parsed_value = NULL;
  2451. }
  2452. element_values[SUBPANEL_NAME].string_value = XtNewString(
  2453. control_data->element_values[CONTROL_NAME].parsed_value);
  2454. element_values[SUBPANEL_CONTAINER_NAME].string_value = XtNewString(
  2455. control_data->element_values[CONTROL_NAME].parsed_value);
  2456. if (control_data->element_values[CONTROL_LABEL].parsed_value != NULL)
  2457. element_values[SUBPANEL_TITLE].string_value = XtNewString(
  2458. control_data->element_values[CONTROL_LABEL].parsed_value);
  2459. else
  2460. element_values[SUBPANEL_TITLE].string_value = XtNewString(
  2461. control_data->element_values[CONTROL_NAME].parsed_value);
  2462. subpanel_data->control_data = NULL;
  2463. subpanel_data->control_data_count = 0;
  2464. subpanel_data->parent_control_data = control_data;
  2465. InitializeSubpanelFields (element_values);
  2466. subpanel_data->element_values = element_values;
  2467. }
  2468. if (!XtIsManaged(XtParent(control_data->arrow)))
  2469. {
  2470. if (box_data->left_arrow_form)
  2471. {
  2472. XtSetArg (al[0], XmNtopAttachment, XmATTACH_WIDGET);
  2473. XtSetArg (al[1], XmNtopWidget, box_data->left_arrow_form);
  2474. XtSetValues(box_data->left_control_form, al, 2);
  2475. XtManageChild(box_data->left_arrow_form);
  2476. }
  2477. if (box_data->right_arrow_form)
  2478. {
  2479. XtManageChild(box_data->right_arrow_form);
  2480. XtSetArg (al[0], XmNtopAttachment, XmATTACH_WIDGET);
  2481. XtSetArg (al[1], XmNtopWidget, box_data->right_arrow_form);
  2482. XtSetValues(box_data->right_control_form, al, 2);
  2483. }
  2484. UpdateSwitchGeometry(box_data);
  2485. }
  2486. box_data->subpanel_count++;
  2487. if(subpanel_data) {
  2488. SubpanelCreate (control_data, subpanel_data);
  2489. }
  2490. XtSetArg (al[0], XmNimageName, post_arrow_image);
  2491. XtSetArg (al[1], XmNsensitive, True);
  2492. XtSetValues (control_data->arrow, al, 2);
  2493. /* Set the subpanels hint and transient behavior */
  2494. vHints.flags = DtWM_HINTS_BEHAVIORS | DtWM_HINTS_ATTACH_WINDOW;
  2495. vHints.behaviors = DtWM_BEHAVIOR_PANEL | DtWM_BEHAVIOR_SUBPANEL;
  2496. vHints.attachWindow = XtWindow (panel.shell);
  2497. XtSetArg (al[0], XmNtransientFor, panel.shell);
  2498. XtSetValues (subpanel_data->shell, al, 1);
  2499. XtRealizeWidget (subpanel_data->form);
  2500. _DtWsmSetDtWmHints (XtDisplay (panel.shell),
  2501. XtWindow (subpanel_data->shell), &vHints);
  2502. WriteSubpanelComponentFile(control_data->subpanel_data);
  2503. }
  2504. /************************************************************************
  2505. *
  2506. * DeleteControl
  2507. * Remove a control upon a menu request for deletion.
  2508. *
  2509. * Inputs: control_data - a pointer to the control to be deleted.
  2510. *
  2511. ************************************************************************/
  2512. void
  2513. DeleteControl (ControlData * control_data)
  2514. {
  2515. int i;
  2516. /* Remove the control from the push recall and embedded client list. */
  2517. PushRecallRegister (control_data, False);
  2518. EmbeddedClientRegister (control_data, False);
  2519. /* Destroy the widgets allocated by the control */
  2520. if (control_data->indicator)
  2521. XtDestroyWidget (control_data->indicator);
  2522. if (control_data->icon)
  2523. {
  2524. if (control_data->element_values[CONTROL_DROP_ACTION].parsed_value
  2525. != NULL)
  2526. DtDndDropUnregister(control_data->icon);
  2527. XtDestroyWidget (control_data->icon);
  2528. }
  2529. /* Remove the copy of the action set and delete the element values */
  2530. DeleteControlActionList (control_data);
  2531. RemoveEntry ((RecordData *)control_data, CONTROL);
  2532. }
  2533. /************************************************************************
  2534. *
  2535. * DeleteSubpanel
  2536. * Delete the subpanel attached to the control pointed to by
  2537. * control_data.
  2538. *
  2539. * Inputs: control_data - a pointer to the main panel control that the
  2540. * subpanel is attached to.
  2541. *
  2542. ************************************************************************/
  2543. void
  2544. DeleteSubpanel (ControlData * control_data)
  2545. {
  2546. SubpanelData * subpanel_data = control_data->subpanel_data;
  2547. BoxData * box_data = (BoxData *) control_data->parent_data;
  2548. Arg al[2];
  2549. int i;
  2550. /* If the current main control is not within the main panel, call */
  2551. /* the DeleteSubpanelControl function to delete the main control */
  2552. /* This will cause the current subpanel control within the main */
  2553. /* panel to be promoted to a main panel control. */
  2554. if (subpanel_data->parent_control_data != control_data)
  2555. {
  2556. subpanel_data->torn = True;
  2557. DeleteSubpanelControl (subpanel_data, subpanel_data->parent_control_data);
  2558. subpanel_data->parent_control_data->subpanel_data = NULL;
  2559. }
  2560. /* Set the main panel control's arrow to blank and insensitive */
  2561. XtSetArg (al[0], XmNimageName, blank_arrow_image);
  2562. XtSetValues (subpanel_data->parent_control_data->arrow, al, 1);
  2563. XtSetSensitive (subpanel_data->parent_control_data->arrow, False);
  2564. /* Either remove a dynamic .fp or write out the subpanel's .fp */
  2565. /* with the DELETE keyword set */
  2566. RemoveSubpanelComponentFile (subpanel_data);
  2567. /* Delete the controls within the subpanel, destroy the remaining */
  2568. /* widgets and free up the remaining data. */
  2569. for (i = 0; i < subpanel_data->control_data_count; i++)
  2570. {
  2571. RemoveControlComponentFile (subpanel_data->control_data[i]);
  2572. DeleteControl (subpanel_data->control_data[i]);
  2573. XtFree ((char *) subpanel_data->control_data[i]);
  2574. }
  2575. /* Remove install zones */
  2576. if (subpanel_data->element_values[SUBPANEL_CONTROL_INSTALL].parsed_value)
  2577. {
  2578. DtDndDropUnregister (subpanel_data->dropzone);
  2579. XtDestroyWidget (subpanel_data->dropzone);
  2580. }
  2581. XtDestroyWidget (subpanel_data->shell);
  2582. XtFree ((char *) subpanel_data->control_data);
  2583. RemoveEntry ((RecordData *)subpanel_data, SUBPANEL);
  2584. XtFree ((char *) subpanel_data);
  2585. control_data->subpanel_data = NULL;
  2586. box_data->subpanel_count--;
  2587. if (box_data->subpanel_count == 0)
  2588. {
  2589. if (box_data->left_arrow_form)
  2590. {
  2591. XtSetArg (al[0], XmNtopAttachment, XmATTACH_FORM);
  2592. XtSetArg (al[1], XmNtopOffset, 0);
  2593. XtSetValues(box_data->left_control_form, al, 2);
  2594. XtUnmanageChild(box_data->left_arrow_form);
  2595. }
  2596. if (box_data->right_arrow_form)
  2597. {
  2598. XtUnmanageChild(box_data->right_arrow_form);
  2599. XtSetArg (al[0], XmNtopAttachment, XmATTACH_FORM);
  2600. XtSetArg (al[1], XmNtopOffset, 0);
  2601. XtSetValues(box_data->right_control_form, al, 2);
  2602. }
  2603. UpdateSwitchGeometry(box_data);
  2604. }
  2605. }
  2606. /************************************************************************
  2607. *
  2608. * SwapElementValue
  2609. * Exchange the values between two element value structures.
  2610. *
  2611. * Inputs: to_value, from_value - pointer to the two element value
  2612. * structures in which to exchange the values.
  2613. *
  2614. ************************************************************************/
  2615. static void
  2616. SwapElementValue (ElementValue * to_value,
  2617. ElementValue * from_value)
  2618. {
  2619. Boolean use_default;
  2620. char * string_value;
  2621. void * parsed_value;
  2622. use_default = from_value->use_default;
  2623. string_value = from_value->string_value;
  2624. parsed_value = from_value->parsed_value;
  2625. from_value->use_default = to_value->use_default;
  2626. from_value->string_value = to_value->string_value;
  2627. from_value->parsed_value = to_value->parsed_value;
  2628. to_value->use_default = use_default;
  2629. to_value->string_value = string_value;
  2630. to_value->parsed_value = parsed_value;
  2631. }
  2632. /************************************************************************
  2633. *
  2634. * DeleteSubpanelControl
  2635. * This function removes a control contained in control_data from
  2636. * a subpanel.
  2637. *
  2638. * Inputs:
  2639. * subpanel_data: The subpanel the control is being deleted from
  2640. * control_data: The control to be deleted
  2641. *
  2642. ************************************************************************/
  2643. void
  2644. DeleteSubpanelControl (SubpanelData * subpanel_data,
  2645. ControlData * control_data)
  2646. {
  2647. ControlData * main_control_data = subpanel_data->parent_control_data;
  2648. int control_data_count;
  2649. Widget * child_list;
  2650. int num_children;
  2651. Widget attach_widget = NULL;
  2652. Widget target_widget = NULL;
  2653. Boolean last = False;
  2654. Dimension height;
  2655. Boolean control_monitor;
  2656. Arg al[2];
  2657. int i, j;
  2658. /* Put the subpanel down before mucking with the widget hierarchy */
  2659. if (subpanel_data->torn == False)
  2660. XtUnmanageChild (subpanel_data->shell);
  2661. /* There are 3 deletion cases. */
  2662. /* 1. Deletion of the main panel copy when there are 0 subpanel */
  2663. /* controls. This involves destroying the copy and deleting */
  2664. /* the subpanel. */
  2665. /* */
  2666. /* 2. Deletion of the main panel copy when there is subpanel */
  2667. /* controls. This involves the full deletion of the main */
  2668. /* panel control and the promotion of a subpanel control to */
  2669. /* a full main panel control. */
  2670. /* */
  2671. /* 3. Deletion of a subpanel control. This involves the full */
  2672. /* deletion of the subpanel control and if it has been */
  2673. /* toggled to the main panel another control is selected */
  2674. control_data_count = subpanel_data->control_data_count;
  2675. if (main_control_data == control_data && control_data_count == 0)
  2676. {
  2677. DeleteSubpanel (main_control_data);
  2678. return;
  2679. }
  2680. /* Look through the controls parent (form) child list to get */
  2681. /* the position of the control to be deleted and the previous */
  2682. /* and next control. This is needed for resetting constraints */
  2683. if (main_control_data == control_data)
  2684. {
  2685. height = XtHeight (subpanel_data->main_panel_icon_copy);
  2686. XtSetArg (al[0], XmNtopWidget, &target_widget);
  2687. XtGetValues (subpanel_data->main_panel_icon_copy, al, 1);
  2688. }
  2689. else
  2690. {
  2691. height = XtHeight (control_data->icon);
  2692. XtSetArg (al[0], XmNtopWidget, &target_widget);
  2693. XtGetValues (control_data->icon, al, 1);
  2694. }
  2695. XtSetArg (al[0], XmNchildren, &child_list);
  2696. XtSetArg (al[1], XmNnumChildren, &num_children);
  2697. XtGetValues (subpanel_data->form, al, 2);
  2698. for (i = 0; i < num_children; i++)
  2699. {
  2700. XtSetArg (al[0], XmNtopWidget, &attach_widget);
  2701. XtGetValues (child_list[i], al, 1);
  2702. if ((main_control_data == control_data &&
  2703. attach_widget == subpanel_data->main_panel_icon_copy) ||
  2704. (main_control_data != control_data &&
  2705. attach_widget == control_data->icon))
  2706. {
  2707. attach_widget = child_list[i];
  2708. break;
  2709. }
  2710. }
  2711. if (i == num_children)
  2712. {
  2713. attach_widget = NULL;
  2714. last = True;
  2715. }
  2716. if (main_control_data == control_data)
  2717. {
  2718. ControlData * subpanel_control_data;
  2719. int subpanel_control_position;
  2720. if (main_control_data == subpanel_data->default_control)
  2721. ToggleDefaultControl (main_control_data, subpanel_data,
  2722. subpanel_data->control_data[0]);
  2723. subpanel_control_data = subpanel_data->default_control;
  2724. /* Remove the .fp or write a Delete .fp for both the main panel */
  2725. /* control and subpanel control. The subpanel data will then */
  2726. /* be moved the the main panel data and the new control will be */
  2727. /* written. */
  2728. /* For the main panel control, if a dynamic .fp exists, remove */
  2729. /* it otherwize, do nothing since a new one will be written. */
  2730. if (SessionFileNameLookup ((char *) main_control_data->element_values[CONTROL_NAME].parsed_value,
  2731. (int) CONTROL,
  2732. (char *) main_control_data->element_values[CONTROL_CONTAINER_NAME].parsed_value,
  2733. (int) BOX) != NULL)
  2734. RemoveControlComponentFile (main_control_data);
  2735. RemoveControlComponentFile (subpanel_control_data);
  2736. /* Find the position of the subpanel control data */
  2737. /* within their parent list, for latter processing */
  2738. for (subpanel_control_position = 0;
  2739. subpanel_control_position < subpanel_data->control_data_count;
  2740. subpanel_control_position++)
  2741. {
  2742. if (subpanel_data->control_data[subpanel_control_position] == subpanel_control_data)
  2743. break;
  2744. }
  2745. /* Reset the subpanel values that were switch from the deleted */
  2746. /* main control when ToggleDefaultControl was called above. */
  2747. XtDestroyWidget (subpanel_data->main_panel_icon_copy);
  2748. subpanel_data->main_panel_icon_copy = subpanel_control_data->icon;
  2749. subpanel_data->default_control = main_control_data;
  2750. /* Move the necessary data from the MP control to the SP control */
  2751. /* and write out the new control file. */
  2752. SwapElementValue (&subpanel_control_data->element_values[CONTROL_NAME],
  2753. &main_control_data->element_values[CONTROL_NAME]);
  2754. SwapElementValue (&subpanel_control_data->element_values[CONTROL_CONTAINER_NAME],
  2755. &main_control_data->element_values[CONTROL_CONTAINER_NAME]);
  2756. SwapElementValue (&subpanel_control_data->element_values[CONTROL_CONTAINER_TYPE],
  2757. &main_control_data->element_values[CONTROL_CONTAINER_TYPE]);
  2758. SwapElementValue (&subpanel_control_data->element_values[CONTROL_POSITION_HINTS],
  2759. &main_control_data->element_values[CONTROL_POSITION_HINTS]);
  2760. WriteControlComponentFile (subpanel_control_data);
  2761. /* Delete the main panel control. Null out the icon field */
  2762. /* since it is being used within the subpanel_control_data. */
  2763. subpanel_control_data->icon = main_control_data->icon;
  2764. main_control_data->icon = NULL;
  2765. DeleteControl (main_control_data);
  2766. /* Set the main control to the subpanel control values */
  2767. main_control_data->element_values = subpanel_control_data->element_values;
  2768. main_control_data->icon = subpanel_control_data->icon;
  2769. main_control_data->indicator = subpanel_control_data->indicator;
  2770. main_control_data->actions = subpanel_control_data->actions;
  2771. /* Remove and readd the callbacks from the main control and */
  2772. /* the main panel icon copy. */
  2773. XtRemoveCallback (main_control_data->icon, XmNcallback,
  2774. (XtCallbackProc) PushCB, subpanel_control_data);
  2775. XtRemoveCallback (main_control_data->icon, XmNhelpCallback,
  2776. (XtCallbackProc) ControlTopicHelpCB, subpanel_control_data);
  2777. XtAddCallback (main_control_data->icon, XmNcallback,
  2778. (XtCallbackProc) PushCB, main_control_data);
  2779. XtAddCallback (main_control_data->icon, XmNhelpCallback,
  2780. (XtCallbackProc) ControlTopicHelpCB, main_control_data);
  2781. XtRemoveCallback (subpanel_data->main_panel_icon_copy, XmNcallback,
  2782. (XtCallbackProc) PushCB, subpanel_control_data);
  2783. XtRemoveCallback (subpanel_data->main_panel_icon_copy, XmNhelpCallback,
  2784. (XtCallbackProc) ControlTopicHelpCB, subpanel_control_data);
  2785. XtAddCallback (subpanel_data->main_panel_icon_copy, XmNcallback,
  2786. (XtCallbackProc) PushCB, main_control_data);
  2787. XtAddCallback (subpanel_data->main_panel_icon_copy, XmNhelpCallback,
  2788. (XtCallbackProc) ControlTopicHelpCB, main_control_data);
  2789. /* Move the subpanel control data's up one position within the */
  2790. /* subpanel's list to denote the removal of the subpanel control */
  2791. /* and free up the remaining subpanel data. */
  2792. for (i = subpanel_control_position; i < subpanel_data->control_data_count - 1; i++)
  2793. subpanel_data->control_data[i] = subpanel_data->control_data[i + 1];
  2794. subpanel_data->control_data_count--;
  2795. XtFree ((char *) subpanel_control_data);
  2796. if (subpanel_data->control_data_count == 0)
  2797. {
  2798. XtFree ((char *) subpanel_data->control_data);
  2799. subpanel_data->control_data = NULL;
  2800. }
  2801. }
  2802. else
  2803. {
  2804. /* Call a function which either unlinks the dynamic .fp file or */
  2805. /* writes a Delete = True dynamic .fp file. The function also */
  2806. /* updates the session tables. */
  2807. RemoveControlComponentFile (control_data);
  2808. for (i = 0; i < subpanel_data->control_data_count; i++)
  2809. {
  2810. if (control_data == subpanel_data->control_data[i]) break;
  2811. }
  2812. if (subpanel_data->default_control == control_data)
  2813. {
  2814. if (i < subpanel_data->control_data_count - 1)
  2815. {
  2816. ToggleDefaultControl (main_control_data, subpanel_data,
  2817. subpanel_data->control_data[i + 1]);
  2818. }
  2819. else
  2820. {
  2821. if (i > 0)
  2822. ToggleDefaultControl (main_control_data, subpanel_data,
  2823. subpanel_data->control_data[i - 1]);
  2824. else if (subpanel_data->main_panel_icon_copy != NULL)
  2825. ToggleDefaultControl (main_control_data, subpanel_data,
  2826. main_control_data);
  2827. }
  2828. }
  2829. DeleteControl (control_data);
  2830. /* Loop through the control list and move the controls down */
  2831. /* one position. */
  2832. for (j = i + 1 ; j < subpanel_data->control_data_count; j++)
  2833. {
  2834. subpanel_data->control_data[j - 1] = subpanel_data->control_data[j];
  2835. }
  2836. subpanel_data->control_data_count--;
  2837. }
  2838. /* If the subpanel is empty, delete it. */
  2839. if (subpanel_data->main_panel_icon_copy == NULL &&
  2840. subpanel_data->control_data_count == 0)
  2841. {
  2842. DeleteSubpanel (subpanel_data->parent_control_data);
  2843. return;
  2844. }
  2845. /* Get the control positioning constraints reset */
  2846. if (attach_widget != NULL && target_widget != NULL)
  2847. {
  2848. XtSetArg (al[0], XmNtopWidget, target_widget);
  2849. XtSetValues (attach_widget, al, 1);
  2850. }
  2851. if (last)
  2852. {
  2853. XtSetArg (al[0], XmNbottomAttachment, XmATTACH_FORM);
  2854. XtSetArg (al[1], XmNbottomOffset, 5);
  2855. XtSetValues (target_widget, al, 2);
  2856. XtSetArg (al[0], XmNheight, XtHeight (subpanel_data->form) -
  2857. (XtHeight (target_widget) - height));
  2858. XtSetValues (subpanel_data->form, al, 1);
  2859. }
  2860. /* Loop through the remaining controls and see if any left are */
  2861. /* monitors. If not, adjust the left pad of the controls */
  2862. control_monitor = False;
  2863. for (j = 0; j < subpanel_data->control_data_count; j++)
  2864. {
  2865. if ((intptr_t) subpanel_data->control_data[j]->
  2866. element_values[CONTROL_MONITOR_TYPE].parsed_value != MONITOR_NONE)
  2867. {
  2868. control_monitor = True;
  2869. break;
  2870. }
  2871. }
  2872. if ((intptr_t) main_control_data->
  2873. element_values[CONTROL_MONITOR_TYPE].parsed_value != MONITOR_NONE)
  2874. {
  2875. control_monitor = True;
  2876. }
  2877. if (control_monitor == False)
  2878. {
  2879. XtSetArg (al[0], XmNleftOffset, 5);
  2880. for (j = 0; j < subpanel_data->control_data_count; j++)
  2881. XtSetValues (subpanel_data->control_data[j]->icon, al, 1);
  2882. if (subpanel_data->main_panel_icon_copy != NULL)
  2883. XtSetValues (subpanel_data->main_panel_icon_copy, al, 1);
  2884. }
  2885. /* Pop the subpanel back up and resume processing */
  2886. if (subpanel_data->torn == False)
  2887. ArrowCB (main_control_data->arrow,
  2888. (XtPointer)main_control_data, (XtPointer)NULL);
  2889. /* Set the XmNcancelButton resource to the default control */
  2890. /* within the subpanel. */
  2891. if (subpanel_data->control_data)
  2892. XtSetArg (al[0], XmNcancelButton, subpanel_data->control_data[0]->icon);
  2893. else
  2894. XtSetArg (al[0], XmNcancelButton, subpanel_data->main_panel_icon_copy);
  2895. XtSetValues (subpanel_data->form, al, 1);
  2896. }
  2897. /************************************************************************
  2898. *
  2899. * ToggleDefaultControl
  2900. * This is used to switch the main panel control to the control
  2901. * attached to the selected toggle.
  2902. *
  2903. * Inputs:
  2904. * main_control_data - a pointer to the main panel's control data.
  2905. * subpanel_data - a pointer to the subpanel where the control to
  2906. * be put in the main panel is coming from.
  2907. * control_data - a pointer to the control in the subpanel to be
  2908. * toggled into the main panel.
  2909. *
  2910. ************************************************************************/
  2911. void
  2912. ToggleDefaultControl (ControlData * main_control_data,
  2913. SubpanelData * subpanel_data,
  2914. ControlData * control_data)
  2915. {
  2916. BoxData * box_data;
  2917. Widget prev_icon = NULL;
  2918. Widget next_icon = NULL;
  2919. Widget old_main_icon = main_control_data->icon;
  2920. Widget main_subpanel_icon;
  2921. Widget parent = XtParent (old_main_icon);
  2922. Widget control_icon;
  2923. char * icon_name = NULL;
  2924. char * alt_icon_name = NULL;
  2925. String exp_file_name = NULL;
  2926. XmString icon_label = NULL;
  2927. Dimension width;
  2928. Dimension new_width;
  2929. Arg al[40];
  2930. int ac;
  2931. int i;
  2932. /* If the selection occurred on the currently selected toggle */
  2933. /* do nothing. */
  2934. if (subpanel_data->default_control == control_data)
  2935. return;
  2936. /* Update the main panel control's push recall and embedded client */
  2937. /* lists, and reparent the embedded client if necessary. */
  2938. if (main_control_data == subpanel_data->default_control)
  2939. {
  2940. control_icon = main_control_data->icon;
  2941. main_control_data->icon = subpanel_data->main_panel_icon_copy;
  2942. if ((intptr_t) main_control_data->element_values[CONTROL_PUSH_RECALL].parsed_value)
  2943. PushRecallRegister (main_control_data, True);
  2944. if ((intptr_t) main_control_data->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
  2945. EmbeddedClientRegister (main_control_data, True);
  2946. main_control_data->icon = control_icon;
  2947. if ((intptr_t) main_control_data->
  2948. element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
  2949. {
  2950. EmbeddedClientReparent ((char *) main_control_data->
  2951. element_values[CONTROL_CLIENT_NAME].parsed_value,
  2952. subpanel_data->main_panel_icon_copy);
  2953. }
  2954. }
  2955. else
  2956. {
  2957. if ((intptr_t) subpanel_data->default_control->element_values[CONTROL_PUSH_RECALL].parsed_value)
  2958. PushRecallRegister (subpanel_data->default_control, True);
  2959. if ((intptr_t) subpanel_data->default_control->element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
  2960. EmbeddedClientRegister (subpanel_data->default_control, True);
  2961. if ((intptr_t) subpanel_data->default_control->
  2962. element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
  2963. {
  2964. EmbeddedClientReparent ((char *) subpanel_data->default_control->
  2965. element_values[CONTROL_CLIENT_NAME].parsed_value,
  2966. subpanel_data->default_control->icon);
  2967. }
  2968. }
  2969. subpanel_data->default_control = control_data;
  2970. control_data->subpanel_data = subpanel_data;
  2971. main_control_data->is_action = control_data->is_action;
  2972. /* Get the width of the current main control to be used to */
  2973. /* possible adjust the new control when it is created. */
  2974. width = XtWidth (main_control_data->icon);
  2975. /* Disallow geometry changes of the main control's parent until */
  2976. /* after the controls have been destroyed and created */
  2977. XtSetArg (al[0], XmNresizePolicy, XmRESIZE_NONE);
  2978. XtSetValues (parent, al, 1);
  2979. /* Create the new control using the control data from the */
  2980. /* control within the subpanel */
  2981. /* Loop through the main controls parent data (box_data) to */
  2982. /* find its position relative to controls around it */
  2983. box_data = (BoxData *) main_control_data->parent_data;
  2984. for (i = 0; i < box_data->control_data_count; i++)
  2985. {
  2986. if (box_data->control_data[i] == main_control_data)
  2987. {
  2988. if (i != 0)
  2989. prev_icon = box_data->control_data[i - 1]->icon;
  2990. if (i != box_data->control_data_count - 1)
  2991. next_icon = box_data->control_data[i + 1]->icon;
  2992. break;
  2993. }
  2994. }
  2995. /* Call the function used to set the control's pixel and font data */
  2996. ac = 0;
  2997. ControlSetVisualData (control_data, al, &ac);
  2998. XtSetArg (al[ac], XmNpixmapPosition, XmPIXMAP_TOP); ac++;
  2999. /* Set up the attachment constraints for the control */
  3000. XtSetArg (al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
  3001. XtSetArg (al[ac], XmNtopOffset, 1); ac++;
  3002. XtSetArg (al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
  3003. XtSetArg (al[ac], XmNbottomOffset, 1); ac++;
  3004. if (prev_icon == NULL)
  3005. {
  3006. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
  3007. XtSetArg (al[ac], XmNleftOffset, 1); ac++;
  3008. }
  3009. else
  3010. {
  3011. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  3012. XtSetArg (al[ac], XmNleftWidget, prev_icon); ac++;
  3013. }
  3014. if (next_icon == NULL)
  3015. {
  3016. XtSetArg (al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
  3017. XtSetArg (al[ac], XmNrightOffset, 1); ac++;
  3018. }
  3019. /* Call the function used to set the control's icon and label data */
  3020. ControlSetIconData (parent, control_data, &icon_label, BOX, al, &ac,
  3021. &icon_name, &alt_icon_name);
  3022. /* Call the function used to set the control's behavioral aspects */
  3023. ControlSetBehavior (control_data, al, &ac, False, &exp_file_name);
  3024. /* Call the function used to create and register the control */
  3025. control_icon = control_data->icon;
  3026. main_control_data->icon =
  3027. ControlCreateAndRegister (parent, control_data, False, al, ac);
  3028. /* If this in not the main control copy then restore the subpanel icon */
  3029. if (main_control_data != control_data)
  3030. control_data->icon = control_icon;
  3031. /* If this is a toggle of a client control from the subpanel to */
  3032. /* the main panel, call the reparenting function. */
  3033. if ((intptr_t) control_data->
  3034. element_values[CONTROL_TYPE].parsed_value == CONTROL_CLIENT)
  3035. {
  3036. EmbeddedClientReparent ((char *) control_data->
  3037. element_values[CONTROL_CLIENT_NAME].parsed_value,
  3038. main_control_data->icon);
  3039. }
  3040. if (icon_label != NULL)
  3041. XmStringFree (icon_label);
  3042. if (icon_name != NULL)
  3043. XtFree(icon_name);
  3044. if (alt_icon_name != NULL)
  3045. XtFree(alt_icon_name);
  3046. if (exp_file_name != NULL)
  3047. XtFree(exp_file_name);
  3048. /* If this is not the right most control within its parent, */
  3049. /* reset the poistioning constraints of the control to the */
  3050. /* right of this one. */
  3051. if (next_icon != NULL)
  3052. {
  3053. ac = 0;
  3054. XtSetArg (al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++;
  3055. XtSetArg (al[ac], XmNleftWidget, main_control_data->icon); ac++;
  3056. XtSetValues (next_icon, al, ac);
  3057. }
  3058. /* Now destroy the original main panel icon */
  3059. XtDestroyWidget (old_main_icon);
  3060. /* Get the width of the new icon and increase its size to minimize */
  3061. /* the degree of resizing of the main panel. */
  3062. new_width = XtWidth (main_control_data->icon);
  3063. if (new_width < width)
  3064. {
  3065. Dimension normal_size;
  3066. Dimension margin_width;
  3067. if (panel.resolution == HIGH)
  3068. normal_size = ICON_HIGH_WIDTH;
  3069. else if (panel.resolution == MEDIUM)
  3070. normal_size = ICON_MEDIUM_WIDTH;
  3071. else
  3072. normal_size = ICON_LOW_WIDTH;
  3073. if (new_width < normal_size)
  3074. {
  3075. XtSetArg (al[0], XmNwidth, normal_size);
  3076. XtSetArg (al[1], XmNmarginWidth, (Dimension)(normal_size-new_width)/2);
  3077. XtSetValues (main_control_data->icon, al, 2);
  3078. }
  3079. }
  3080. /* Get the width of the icon again for arrow and embedded client */
  3081. /* processing. */
  3082. new_width = XtWidth (main_control_data->icon);
  3083. /* Call a function to reposition embedded clients to the right */
  3084. /* of the main panel control. */
  3085. if (new_width != width)
  3086. EmbeddedClientReposition (main_control_data->icon,
  3087. XtX (main_control_data->icon) + 3,
  3088. new_width - width);
  3089. /* Reset the geometry policy for the main control parent */
  3090. XtSetArg (al[0], XmNresizePolicy, XmRESIZE_ANY);
  3091. XtSetValues (parent, al, 1);
  3092. /* Set the width of the arrow */
  3093. new_width += 2;
  3094. if (prev_icon != NULL) new_width -= 2;
  3095. if (next_icon != NULL) new_width -= 2;
  3096. XtSetArg (al[0], XmNwidth, new_width);
  3097. XtSetValues (main_control_data->arrow, al, 1);
  3098. }
  3099. /************************************************************************
  3100. *
  3101. * SetupPushAnimation
  3102. * Add the sequence of images that make up a push animation for a
  3103. * control.
  3104. *
  3105. * Inputs: control_data - a pointer to the control to which to add
  3106. * the animation.
  3107. *
  3108. ************************************************************************/
  3109. static void
  3110. SetupPushAnimation (ControlData * control_data)
  3111. {
  3112. char * animation_name = control_data->
  3113. element_values[CONTROL_PUSH_ANIMATION].parsed_value;
  3114. int count;
  3115. int delay;
  3116. String image_name;
  3117. int i, j;
  3118. count = panel.animation_count;
  3119. if (animation_name == NULL) return;
  3120. for (i = 0; i < count; i++)
  3121. {
  3122. if (!strcmp (panel.animation_data[i].name, animation_name))
  3123. break;
  3124. }
  3125. if (i < count)
  3126. {
  3127. for (j = 0; j < panel.animation_data[i].item_count; j++)
  3128. {
  3129. image_name = GetIconName (panel.animation_data[i].items[j].image_name,
  3130. panel.main_icon_size);
  3131. delay = panel.animation_data[i].items[j].delay;
  3132. _DtControlAddPushAnimationImage (control_data->icon, image_name, delay);
  3133. XtFree(image_name);
  3134. }
  3135. }
  3136. }
  3137. /************************************************************************
  3138. *
  3139. * SetupDropAnimation
  3140. * Add the sequence of images that make up a drop animation for a
  3141. * control.
  3142. *
  3143. * Inputs: control_data - a pointer to the control to which to add
  3144. * the animation.
  3145. *
  3146. ************************************************************************/
  3147. static void
  3148. SetupDropAnimation (ControlData * control_data)
  3149. {
  3150. char * animation_name = control_data->
  3151. element_values[CONTROL_DROP_ANIMATION].parsed_value;
  3152. int count;
  3153. int delay;
  3154. String image_name;
  3155. int i, j;
  3156. count = panel.animation_count;
  3157. if (animation_name == NULL) return;
  3158. for (i = 0; i < count; i++)
  3159. {
  3160. if (!strcmp (panel.animation_data[i].name, animation_name))
  3161. break;
  3162. }
  3163. if (i < count)
  3164. {
  3165. for (j = 0; j < panel.animation_data[i].item_count; j++)
  3166. {
  3167. image_name = GetIconName (panel.animation_data[i].items[j].image_name,
  3168. panel.main_icon_size);
  3169. delay = panel.animation_data[i].items[j].delay;
  3170. _DtControlAddDropAnimationImage (control_data->icon, image_name, delay);
  3171. XtFree(image_name);
  3172. }
  3173. }
  3174. }
  3175. /************************************************************************
  3176. *
  3177. * GetIconName
  3178. * Get the file name for an icon by extracting the panel resolution
  3179. * and then looking up the image name.
  3180. *
  3181. * Inputs: image_name - the base name of the image to be found
  3182. * icon_size - the size requested (t, s, m, l) for the
  3183. * icon.
  3184. *
  3185. ************************************************************************/
  3186. String
  3187. GetIconName (String image_name,
  3188. unsigned int icon_size)
  3189. {
  3190. String return_name = NULL;
  3191. Screen * screen = XtScreen (panel.shell);
  3192. unsigned int next_size;
  3193. /* Get name. */
  3194. next_size = icon_size;
  3195. /* Loop through until all sizes are exhausted */
  3196. while (return_name == NULL)
  3197. {
  3198. return_name =
  3199. _DtGetIconFileName (screen, image_name, NULL, NULL, next_size);
  3200. if (next_size == DtLARGE)
  3201. next_size = DtMEDIUM;
  3202. else if (next_size == DtMEDIUM)
  3203. next_size = DtSMALL;
  3204. else if (next_size == DtSMALL)
  3205. next_size = DtTINY;
  3206. else
  3207. break; /* tried all sizes, exit loop */
  3208. }
  3209. if (return_name == NULL)
  3210. return_name =
  3211. _DtGetIconFileName (screen, image_name, NULL, NULL, DtUNSPECIFIED);
  3212. if (return_name == NULL)
  3213. return_name =
  3214. _DtGetIconFileName (screen, DEFAULT_IMAGE_NAME, NULL, NULL, icon_size);
  3215. if (return_name == NULL)
  3216. return_name = XtNewString (image_name);
  3217. /* Return value to be freed by caller. */
  3218. return (return_name);
  3219. }