12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796 |
- /*
- * CDE - Common Desktop Environment
- *
- * Copyright (c) 1993-2012, The Open Group. All rights reserved.
- *
- * These libraries and programs are free software; you can
- * redistribute them and/or modify them under the terms of the GNU
- * Lesser General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * These libraries and programs are distributed in the hope that
- * they will be useful, but WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU Lesser General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with these libraries and programs; if not, write
- * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301 USA
- */
- /* $TOG: PrintSetupB.c /main/27 1998/08/06 17:28:56 mgreess $ */
- /*
- * DtPrint/PrintSetupB.c
- */
- /* (c) Copyright 1990, 1991, 1992, 1993, 1994 OPEN SOFTWARE FOUNDATION, INC.
- * ALL RIGHTS RESERVED
- * (c) Copyright 1989, 1996 DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
- * (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1995, 1996,
- * HEWLETT-PACKARD COMPANY
- * (c) Copyright 1996 International Business Machines Corp.
- * (c) Copyright 1996 Sun Microsystems, Inc.
- * (c) Copyright 1996 Novell, Inc.
- * (c) Copyright 1996 FUJITSU LIMITED.
- * (c) Copyright 1996 Hitachi.
- */
- /*
- * ------------------------------------------------------------------------
- * Include Files
- *
- */
- #include <Dt/DtNlUtils.h>
- #ifdef MAXINT
- #undef MAXINT
- #endif
- #include <ctype.h>
- #include <stdlib.h>
- #if defined(CSRG_BASED)
- #define MAXINT INT_MAX
- #else
- #include <values.h>
- #endif
- #include <stdio.h>
- #include <stdint.h>
- #include <Xm/XmAll.h>
- #include <Xm/ActivatableT.h>
- #include <Xm/RowColumnP.h>
- #include <Xm/TraitP.h>
- #include <Xm/TakesDefT.h>
- #include <Xm/XmPrivate.h>
- #include <Dt/PrintSetupBP.h>
- #include <Dt/PsubDefProcI.h>
- #include <Dt/PsubUtilI.h>
- #include <Dt/PrintI.h>
- /*
- * ------------------------------------------------------------------------
- * Constant Definitions
- *
- */
- #define IsButton(w) \
- (((XtPointer) XmeTraitGet((XtPointer) XtClass((w)), XmQTactivatable) != NULL))
- #define IsAutoButton(psub, w) ( \
- w == PSUB_PrinterInfoButton(psub) || \
- w == PSUB_SelectPrinterButton(psub) || \
- w == PSUB_SelectFileButton(psub) || \
- w == PSUB_PrintButton(psub) || \
- w == PSUB_SetupButton(psub) || \
- w == PSUB_CancelButton(psub) || \
- w == PSUB_HelpButton(psub))
- /*
- * value to indicate initially unspecified resources
- */
- #define DtUNSPECIFIED (~0)
- /*
- * limits
- */
- #define MAX_COPIES MAXINT
- /*
- * defaults
- */
- #define WORK_AREA_DEFAULT DtWORK_AREA_BOTTOM
- #define SETUP_MODE_DEFAULT DtPRINT_SETUP_XP
- #define DESCRIPTION_COLUMNS 35
- #define FILE_NAME_COLUMNS 27
- #define PRINTER_NAME_COLUMNS 25
- /*
- * Xp Attributes
- */
- #define XpATTR_DESCRIPTOR "descriptor"
- #define XpATTR_DOC_ATTRS_SUPPORTED "document-attributes-supported"
- #define XpATTR_COPY_COUNT "copy-count"
- #define XpATTR_SETUP_PROVISO "xp-setup-proviso"
- #define XpATTR_SETUP_STATE "xp-setup-state"
- /*
- * ------------------------------------------------------------------------
- * Type Definitions
- *
- */
- typedef enum {
- DtPRINT_NULL_CHILD,
- DtPRINT_CANCEL_BUTTON,
- DtPRINT_FILES_BUTTON,
- DtPRINT_HELP_BUTTON,
- DtPRINT_INFO_BUTTON,
- DtPRINT_PRINT_BUTTON,
- DtPRINT_PRINTERS_BUTTON,
- DtPRINT_SETUP_BUTTON
- } DtPrintSetupBoxChild;
- /*
- * column oriented geometry definitions
- */
- #define PSUB_GEO_COL_COUNT 3
- #define PSUB_GEO_MAX_ROW 4
- typedef enum {
- PSUB_GEO_ALIGN_LEFT = 0, /* default */
- PSUB_GEO_ALIGN_RIGHT,
- PSUB_GEO_ALIGN_EXPAND
- } PSUB_GeoBoxAlignment;
- typedef struct
- {
- XmKidGeometry geo;
- PSUB_GeoBoxAlignment align;
- Dimension orig_width;
- } PSUB_GeoBoxRec, *PSUB_GeoBox;
- typedef struct
- {
- int row_count;
- PSUB_GeoBoxRec pbox[PSUB_GEO_MAX_ROW][PSUB_GEO_COL_COUNT];
- XmGeoRowLayout layout_ptr[PSUB_GEO_MAX_ROW];
- Dimension col_width[PSUB_GEO_COL_COUNT];
- } PSUB_GeoExtensionRec, *PSUB_GeoExtension ;
- /*
- * ------------------------------------------------------------------------
- * External Function Declarations
- *
- */
- /*
- * Geometry management functions defined in Xm/GeoUtils
- */
- extern XmGeoMatrix _XmGeoMatrixAlloc(
- unsigned int numRows,
- unsigned int numBoxes,
- unsigned int extSize);
- extern Boolean _XmGeoSetupKid(
- XmKidGeometry geo,
- Widget kidWid);
- /*
- * ------------------------------------------------------------------------
- * Static Function Declarations
- *
- */
- static void ClassInitialize(
- void);
- static void ClassPartInitialize(
- WidgetClass w_class);
- static void ClosePrintConnection(
- DtPrintSetupBoxWidget psub,
- String old_printer_name,
- Boolean update_gui);
- static void ClosePrintConnectionCallback(Widget w,
- XtPointer client_data,
- XtPointer call_data);
- static void ColumnGeoFixUp(
- XmGeoMatrix geoSpec,
- int action,
- XmGeoMajorLayout layoutPtr,
- XmKidGeometry rowPtr);
- static void ColumnGeoPreSet(
- PSUB_GeoExtension ext,
- int row);
- static void ColumnGeoRestoreWidths(
- PSUB_GeoExtension ext,
- int row);
- static void ColumnGeoSaveWidths(
- PSUB_GeoExtension ext,
- int row);
- static void ColumnGeoSetPreferredWidths(
- PSUB_GeoExtension ext,
- int row);
- static Boolean ConvertStringToEnum(
- Display *dpy,
- XrmValuePtr args,
- Cardinal *num_args,
- XrmValuePtr from,
- XrmValuePtr to,
- XtPointer *data);
- static void CopiesTextValueChangedCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data);
- static Widget CreateButton(Widget parent,
- String label,
- String name,
- XmNavigationType nav_type);
- static Widget CreateButtonGadget(
- Widget parent,
- String label,
- String name,
- XmNavigationType nav_type);
- static Widget CreateLabelGadget(
- Widget parent,
- String label,
- String name);
- static String CreateModalPrinterSpec(
- XtEnum name_mode,
- const String full_printer_name);
- static void DeleteChild(
- Widget child);
- static void DestinationChangedCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data);
- static void Destroy(
- Widget w);
- static XtEnum EstablishPrinter(
- DtPrintSetupBoxWidget psub,
- DtPrintSetupData* psd);
- static void GetPrintAttributes(
- DtPrintSetupBoxWidget psub);
- static void Initialize(
- Widget rw,
- Widget nw,
- ArgList args,
- Cardinal *num_args);
- static void InsertChild(
- Widget child);
- static Boolean IsSetupRequired(
- DtPrintSetupBoxWidget psub);
- static void MenuBarFixUp(
- XmGeoMatrix geoSpec,
- int action,
- XmGeoMajorLayout layoutPtr,
- XmKidGeometry rowPtr);
- static void PrintSetupBoxCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data);
- static void SeparatorFixUp(
- XmGeoMatrix geoSpec,
- int action,
- XmGeoMajorLayout layoutPtr,
- XmKidGeometry rowPtr);
- static void SetNewPrinterName(
- DtPrintSetupBoxWidget psub,
- String new_printer_name,
- String old_printer_name);
- static void SetPrintAttributes(
- DtPrintSetupBoxWidget psub);
- static void SetPSDDestination(
- DtPrintSetupBoxWidget psub,
- DtPrintSetupData* psd);
- static XmImportOperator SetSyntheticResForChild(
- Widget widget,
- int offset,
- XtArgVal *value);
- static Boolean SetValues(
- Widget cw,
- Widget rw,
- Widget nw,
- ArgList args,
- Cardinal *num_args) ;
- static int SpanNonWhitespace(
- const char* string);
- static int SpanWhitespace(
- const char* string);
- static void SynthGetFileName(
- DtPrintSetupBoxWidget psub);
- static void SynthGetPrinterName(
- DtPrintSetupBoxWidget psub);
- static void SynthSetCopies(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current);
- static void SynthSetFileName(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current);
- static void SynthSetPrintDestination(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current);
- static void SynthSetPrinterName(
- DtPrintSetupBoxWidget psub,
- String new_printer_name,
- String old_printer_name);
- static void UpdatePrinterNameCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data);
- static void UpdatePrinterNameTimeoutProc(XtPointer client_data,
- XtIntervalId* id);
- static void UpdateString(
- Widget w,
- XmString string,
- XmStringDirection direction) ;
- static void ValidatePrintSetupMode(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current);
- static void ValidateWorkAreaLocation(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current);
- /*
- * ------------------------------------------------------------------------
- * Static Global Variable Definitions
- *
- */
- /*
- * Synthetic Resource Definitions
- */
- static XmSyntheticResource syn_resources[] =
- {
- {
- DtNcopies,
- sizeof(int),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.copies),
- _DtPrintSetupBoxGetCopies,
- SetSyntheticResForChild
- },
- {
- DtNdescription,
- sizeof(XmString),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.description_string),
- _DtPrintSetupBoxGetDescription,
- SetSyntheticResForChild
- },
- {
- DtNfileName,
- sizeof(String),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.file_name),
- _DtPrintSetupBoxGetFileName,
- SetSyntheticResForChild
- },
- {
- DtNprinterName,
- sizeof(String),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.printer_name),
- _DtPrintSetupBoxGetPrinterName,
- SetSyntheticResForChild
- }
- };
- /*
- * Resource Definitions
- */
- static XtResource resources[] =
- {
- {
- XmNnoResize, XmNnoResize,
- XmRBoolean, sizeof(Boolean),
- XtOffsetOf(XmBulletinBoardRec, bulletin_board.no_resize),
- XmRImmediate, (XtPointer) True
- },
- {
- DtNcancelCallback, DtCCancelCallback,
- XmRCallback, sizeof(XtCallbackList),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.cancel_callback),
- XmRImmediate, (XtPointer) NULL
- },
- {
- DtNclosePrintDisplayCallback, DtCClosePrintDisplayCallback,
- XmRCallback, sizeof(XtCallbackList),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.close_display_callback),
- XmRImmediate, (XtPointer) NULL
- },
- {
- DtNcopies, DtCCopies,
- XmRInt, sizeof(int),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.copies),
- XmRImmediate, (XtPointer) 1
- },
- {
- DtNdescription, DtCDescription,
- XmRXmString, sizeof(XmString),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.description_string),
- XmRString, (XtPointer) NULL
- },
- {
- DtNfileName, DtCFileName,
- XmRString, sizeof(String),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.file_name),
- XmRString, (XtPointer) NULL
- },
- {
- DtNminimizeButtons, DtCMinimizeButtons,
- XmRBoolean, sizeof(Boolean),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.minimize_buttons),
- XmRImmediate, (XtPointer) False
- },
- {
- DtNprintCallback, DtCPrintCallback,
- XmRCallback, sizeof(XtCallbackList),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.print_callback),
- XmRImmediate, (XtPointer) NULL
- },
- {
- DtNoptionCount, DtCOptionCount,
- XmRCardinal, sizeof(Cardinal),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.option_count),
- XmRImmediate, (XtPointer) 0
- },
- {
- DtNoptions, DtCOptions,
- XmRPointer, sizeof(XtPointer),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.options),
- XmRImmediate, (XtPointer) NULL
- },
- {
- DtNprintDestination, DtCPrintDestination,
- XmREnum, sizeof(XtEnum),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.print_destination),
- XmRImmediate, (XtPointer) DtPRINT_TO_PRINTER,
- },
- {
- DtNprinterInfoProc, DtCPrinterInfoProc,
- DtRPrintSetupProc, sizeof(DtPrintSetupProc),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.printer_info_proc),
- XmRImmediate, (XtPointer)DtUNSPECIFIED
- },
- {
- DtNprinterName, DtCPrinterName,
- XmRString, sizeof(String),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.printer_name),
- XmRString, (XtPointer) NULL
- },
- {
- DtNprintSetupMode, DtCPrintSetupMode,
- XmREnum, sizeof(XtEnum),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.print_setup_mode),
- XmRImmediate, (XtPointer)SETUP_MODE_DEFAULT,
- },
- {
- DtNselectFileProc, DtCSelectFileProc,
- DtRPrintSetupProc, sizeof(DtPrintSetupProc),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.select_file_proc),
- XmRImmediate, (XtPointer) _DtPrintSetupBoxSelectFileProc
- },
- {
- DtNselectPrinterProc, DtCSelectPrinterProc,
- DtRPrintSetupProc, sizeof(DtPrintSetupProc),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.select_printer_proc),
- XmRImmediate, (XtPointer)DtUNSPECIFIED
- },
- {
- DtNsetupCallback, DtCSetupCallback,
- XmRCallback, sizeof(XtCallbackList),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.setup_callback),
- XmRImmediate, (XtPointer) NULL
- },
- {
- DtNverifyPrinterProc, DtCVerifyPrinterProc,
- DtRPrintSetupProc, sizeof(DtPrintSetupProc),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.verify_printer_proc),
- XmRImmediate, (XtPointer)DtUNSPECIFIED
- },
- {
- DtNworkAreaLocation, DtCWorkAreaLocation,
- XmREnum, sizeof(XtEnum),
- XtOffsetOf(DtPrintSetupBoxRec,
- print_setup_box.work_area_location),
- XmRImmediate, (XtPointer)WORK_AREA_DEFAULT,
- },
- };
- externaldef(dtprintsetupboxclassrec) DtPrintSetupBoxClassRec
- dtPrintSetupBoxClassRec =
- {
- {
- /* superclass */ (WidgetClass)&xmBulletinBoardClassRec,
- /* class_name */ "DtPrintSetupBox",
- /* widget_size */ sizeof(DtPrintSetupBoxRec),
- /* class_initialize */ ClassInitialize,
- /* chained class init */ ClassPartInitialize,
- /* class_inited */ FALSE,
- /* initialize */ Initialize,
- /* initialize hook */ NULL,
- /* realize */ XtInheritRealize,
- /* actions */ NULL,
- /* num_actions */ 0,
- /* resources */ resources,
- /* num_resources */ XtNumber(resources),
- /* xrm_class */ NULLQUARK,
- /* compress_motion */ TRUE,
- /* compress_exposure */ XtExposeCompressMaximal,
- /* compress enter/exit*/ TRUE,
- /* visible_interest */ FALSE,
- /* destroy */ Destroy,
- /* resize */ XtInheritResize,
- /* expose */ XtInheritExpose,
- /* set_values */ SetValues,
- /* set_values_hook */ NULL,
- /* set_values_almost */ XtInheritSetValuesAlmost,
- /* get_values_hook */ NULL,
- /* accept_focus */ NULL,
- /* version */ XtVersion,
- /* callback_offsets */ NULL,
- /* tm_table */ XtInheritTranslations,
- /* query_geometry */ XtInheritGeometryManager,
- /* display_accelerator*/ NULL,
- /* extension */ NULL,
- },
- { /* composite class record */
- /* childrens geo mgr proc */ XtInheritGeometryManager,
- /* set changed proc */ XtInheritChangeManaged,
- /* insert_child */ InsertChild,
- /* delete_child */ DeleteChild,
- /* extension */ NULL,
- },
- { /* constraint class record */
- /* no additional resources */ NULL,
- /* num additional resources */ 0,
- /* size of constraint rec */ 0,
- /* constraint_initialize */ NULL,
- /* constraint_destroy */ NULL,
- /* constraint_setvalue */ NULL,
- /* extension */ NULL,
- },
- { /* manager class record */
- XmInheritTranslations, /* default translations */
- syn_resources, /* syn_resources */
- XtNumber (syn_resources), /* num_syn_resources */
- NULL, /* syn_cont_resources */
- 0, /* num_syn_cont_resources */
- XmInheritParentProcess, /* parent_process */
- NULL, /* extension */
- },
- { /* bulletin board class record */
- TRUE, /*always_install_accelerators*/
- _DtPrintSetupBoxGeoMatrixCreate, /* geo_matrix_create */
- XmInheritFocusMovedProc, /* focus_moved_proc */
- NULL, /* extension */
- },
- { /* print setup box class record */
- NULL, /* extension */
- },
- };
- externaldef(dtprintsetupboxwidgetclass) WidgetClass dtPrintSetupBoxWidgetClass = (WidgetClass) &dtPrintSetupBoxClassRec ;
- /*
- * ------------------------------------------------------------------------
- * Name: ClassInitialize - Core class method
- *
- * Description:
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ClassInitialize(void)
- {
- /*
- * Register a type converter for String to Enum
- */
- XtSetTypeConverter("String", "Enum", ConvertStringToEnum,
- NULL, 0, XtCacheAll, NULL);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ClassPartInitialize - Core class method
- *
- * Description:
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ClassPartInitialize(WidgetClass w_class)
- {
- DtPrintSetupBoxWidgetClass wc = (DtPrintSetupBoxWidgetClass) w_class;
- DtPrintSetupBoxWidgetClass super =
- (DtPrintSetupBoxWidgetClass) wc->core_class.superclass;
- if (wc->print_setup_box_class.list_callback == XmInheritCallbackProc)
- wc->print_setup_box_class.list_callback =
- super->print_setup_box_class.list_callback;
- }
-
- /*
- * ------------------------------------------------------------------------
- * Name: ClosePrintConnection
- *
- * Description:
- *
- * Call the DtNclosePrintDisplayCallback list, and destroy the print
- * context and X print display connection managed by the widget.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ClosePrintConnection(
- DtPrintSetupBoxWidget psub,
- String old_printer_name,
- Boolean update_gui)
- {
- DtPrintSetupCallbackStruct cbs;
- DtPrintSetupData psd;
- XmString empty_label;
-
- memset(&cbs, 0, sizeof(DtPrintSetupCallbackStruct));
- memset(&psd, 0, sizeof(DtPrintSetupData));
- cbs.print_data = &psd;
- /*
- * call DtNclosePrintDisplayCallback before closing the
- * current print display
- */
- cbs.reason = DtPRINT_CR_CLOSE_PRINT_DISPLAY;
- psd.printer_name = old_printer_name;
- psd.print_display = PSUB_Display(psub);
- #if 0 && defined(PRINTING_SUPPORTED)
- psd.print_context = PSUB_Context(psub);
- #endif /* PRINTING_SUPPORTED */
- XtCallCallbackList((Widget)psub,
- PSUB_CloseDisplayCallback(psub),
- (XtPointer)&cbs);
- /*
- * unset the printer description
- */
- if(update_gui)
- {
- empty_label = XmStringGenerate((XtPointer)"", (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- UpdateString(PSUB_Description((Widget)psub),
- empty_label, PSUB_StringDirection((Widget)psub));
- XmStringFree(empty_label);
- }
- /*
- * reset copy_count_supported flag
- */
- if(!PSUB_CopyCountSupported(psub))
- {
- PSUB_CopyCountSupported(psub) = True;
- if(PSUB_PrintDestination(psub) == DtPRINT_TO_PRINTER && update_gui)
- {
- if(PSUB_CopiesSpinBox(psub))
- XtSetSensitive(PSUB_CopiesSpinBox(psub), True);
- if(PSUB_CopiesControl(psub))
- {
- Widget copies_label =
- XtNameToWidget(PSUB_CopiesControl(psub), "CopiesLabel");
- XtSetSensitive(copies_label, True);
- }
- }
- }
- /*
- * destroy the print context
- */
- #if 0 && defined(PRINTING_SUPPORTED)
- XpDestroyContext(PSUB_Display(psub), PSUB_Context(psub));
- PSUB_Context(psub) = (XPContext)NULL;
- #endif /* PRINTING_SUPPORTED */
- /*
- * close the print display
- */
- XtCloseDisplay(PSUB_Display(psub));
- PSUB_Display(psub) = (Display*)NULL;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ClosePrintConnectionCallback
- *
- * Description:
- *
- * Calls ClosePrintConnection if there is an existing connection.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ClosePrintConnectionCallback(Widget w,
- XtPointer client_data,
- XtPointer call_data)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)client_data;
- /*
- * close the Xp connection if open
- */
- if(PSUB_Display(psub) != (Display*)NULL)
- {
- ClosePrintConnection(psub, PSUB_PrinterName(psub), True);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ColumnGeoFixUp
- *
- * Description:
- *
- * This routine is a fixup routine which can be used for groups of
- * rows containing entries that can be organized into columns.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ColumnGeoFixUp(
- XmGeoMatrix geo_spec,
- int action,
- XmGeoMajorLayout layout_ptr,
- XmKidGeometry row_ptr)
- {
- PSUB_GeoExtension ext = geo_spec->extension;
- int row;
- /*
- * determine which row we're on
- */
- for(row = 0; row < ext->row_count; row++)
- if((ext->layout_ptr)[row] == &(layout_ptr->row))
- break;
- if(row == ext->row_count)
- /*
- * shouldn't happen
- */
- return;
- switch(action)
- {
- case XmGET_PREFERRED_SIZE:
- ColumnGeoSaveWidths(ext, row);
- ColumnGeoSetPreferredWidths(ext, row);
- break;
-
- case XmGEO_PRE_SET:
- ColumnGeoPreSet(ext, row);
- break;
- case XmGEO_POST_SET:
- ColumnGeoRestoreWidths(ext, row);
- break;
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ColumnGeoPreSet
- *
- * Description:
- *
- * Update origins and widths based on alignment.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ColumnGeoPreSet(
- PSUB_GeoExtension ext,
- int row)
- {
- Dimension delta = 0;
- Dimension slack = 0;
- int col;
-
- for(col = 0; col < PSUB_GEO_COL_COUNT; col++)
- {
- PSUB_GeoBox pbox = &(ext->pbox)[row][col];
- if(pbox->geo)
- {
- pbox->geo->box.x += slack;
-
- switch(pbox->align)
- {
- case PSUB_GEO_ALIGN_RIGHT:
- delta += (ext->col_width)[col] - pbox->geo->box.width;
- pbox->geo->box.x += (ext->col_width)[col] - pbox->orig_width;
- pbox->geo->box.width = pbox->orig_width;
- break;
-
- case PSUB_GEO_ALIGN_LEFT:
- pbox->geo->box.x += delta;
- delta += (ext->col_width)[col] - pbox->geo->box.width;
- pbox->geo->box.width = pbox->orig_width;
- break;
-
- case PSUB_GEO_ALIGN_EXPAND:
- pbox->geo->box.x += delta;
- pbox->geo->box.width = (ext->col_width)[col];
- break;
- }
- }
- else
- slack += (ext->col_width)[col];
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ColumnGeoRestoreWidths
- *
- * Description:
- *
- * Restore the original widths for items in the current row.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ColumnGeoRestoreWidths(
- PSUB_GeoExtension ext,
- int row)
- {
- int col;
-
- for(col = 0; col < PSUB_GEO_COL_COUNT; col++)
- {
- PSUB_GeoBox pbox = &(ext->pbox)[row][col];
- if(pbox->geo)
- {
- /*
- * restore the original box width
- */
- pbox->geo->box.width = pbox->orig_width;
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ColumnGeoSaveWidths
- *
- * Description:
- *
- * Save the original widths for items in the current row, and
- * increase a given column width if an item in a corresponding column
- * in this row is wider.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ColumnGeoSaveWidths(
- PSUB_GeoExtension ext,
- int row)
- {
- int col;
-
- for(col = 0; col < PSUB_GEO_COL_COUNT; col++)
- {
- PSUB_GeoBox pbox = &(ext->pbox)[row][col];
- if(pbox->geo)
- {
- /*
- * save the original box width
- */
- pbox->orig_width = pbox->geo->box.width;
- /*
- * update the overall column width
- */
- if(pbox->geo->box.width > (ext->col_width)[col])
- (ext->col_width)[col] = pbox->geo->box.width;
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ColumnGeoSetPreferredWidths
- *
- * Description:
- *
- * Ensure the overall width of the current row is equal to the
- * overall width of all of the columns.
- *
- * Assumes at least one box is defined in the row.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ColumnGeoSetPreferredWidths(
- PSUB_GeoExtension ext,
- int row)
- {
- Dimension slack = 0;
- int last_non_empty_col = 0;
- int col;
-
- for(col = 0; col < PSUB_GEO_COL_COUNT; col++)
- {
- PSUB_GeoBox pbox = &(ext->pbox)[row][col];
- if(pbox->geo)
- {
- pbox->geo->box.width = (ext->col_width)[col] + slack;
- slack = 0;
- last_non_empty_col = col;
- }
- else
- {
- slack += (ext->col_width)[col];
- }
- }
- if(slack)
- (ext->pbox)[row][last_non_empty_col].geo->box.width += slack;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ConvertStringToEnum
- *
- * Description:
- *
- * This type converter converts from type String to Enum. It is
- * used for the DtNprintDestination, DtNworkAreaLocation, and
- * DtNprintSetupMode resources.
- *
- */
- static Boolean
- ConvertStringToEnum(
- Display *dpy,
- XrmValuePtr args,
- Cardinal *num_args,
- XrmValuePtr from,
- XrmValuePtr to,
- XtPointer *data)
- {
- char *from_str;
- static unsigned char to_value;
- if(*num_args !=0 )
- {
- XtError(WARN_CONVERSION_ARGS);
- }
- from_str = (char *)from->addr;
- if(strcmp(from_str, "PRINT_TO_FILE")==0 ||
- strcmp(from_str, "DtPRINT_TO_FILE")==0)
- to_value = DtPRINT_TO_FILE;
- else if(strcmp(from_str, "PRINT_TO_PRINTER")==0 ||
- strcmp(from_str, "DtPRINT_TO_PRINTER")==0)
- to_value = DtPRINT_TO_PRINTER;
- else if(strcmp(from_str, "PRINT_SETUP_PLAIN")==0 ||
- strcmp(from_str, "DtPRINT_SETUP_PLAIN")==0)
- to_value = DtPRINT_SETUP_PLAIN;
- else if(strcmp(from_str, "PRINT_SETUP_XP")==0 ||
- strcmp(from_str, "DtPRINT_SETUP_XP")==0)
- to_value = DtPRINT_SETUP_XP;
- else if(strcmp(from_str, "WORK_AREA_BOTTOM")==0 ||
- strcmp(from_str, "DtWORK_AREA_BOTTOM")==0)
- to_value = DtWORK_AREA_BOTTOM;
- else if(strcmp(from_str, "WORK_AREA_TOP")==0 ||
- strcmp(from_str, "DtWORK_AREA_TOP")==0)
- to_value = DtWORK_AREA_TOP;
- else if(strcmp(from_str, "WORK_AREA_TOP_AND_BOTTOM")==0 ||
- strcmp(from_str, "DtWORK_AREA_TOP_AND_BOTTOM")==0)
- to_value = DtWORK_AREA_TOP_AND_BOTTOM;
- else if(strcmp(from_str, "SHORT_NAME")==0 ||
- strcmp(from_str, "DtSHORT_NAME")==0)
- to_value = DtSHORT_NAME;
- else if(strcmp(from_str, "MEDIUM_NAME")==0 ||
- strcmp(from_str, "DtMEDIUM_NAME")==0)
- to_value = DtMEDIUM_NAME;
- else if(strcmp(from_str, "LONG_NAME")==0 ||
- strcmp(from_str, "DtLONG_NAME")==0)
- to_value = DtLONG_NAME;
- else
- {
- XtDisplayStringConversionWarning(dpy, from->addr, "Enum");
- return False;
- }
- if(to->addr == NULL)
- to->addr = (caddr_t) &to_value;
- else if(to->size <sizeof(unsigned char))
- {
- XtDisplayStringConversionWarning(dpy, from->addr, "Enum");
- return False;
- }
- else
- *(unsigned char *) to->addr = to_value;
- to->size = sizeof(unsigned char);
- return True;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: CopiesTextValueChangedCallback
- *
- * Description:
- *
- * Process a change in the textfield of the copies simple spin box.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- CopiesTextValueChangedCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)client_data;
- XmAnyCallbackStruct* cbs = (XmAnyCallbackStruct*)call_data;
- if (NULL == psub || NULL == cbs) return;
- if(XmCR_VALUE_CHANGED == cbs->reason)
- {
- char *value = NULL;
- int value_int = 0;
-
- XtVaGetValues(w, XmNvalue, &value, NULL);
- if (value) value_int = strtol(value, (char**)NULL, 10);
- if (1 <= value_int || value_int <= MAX_COPIES)
- {
- PSUB_Copies(psub) = value_int;
- XtVaSetValues(
- PSUB_CopiesSpinBox(psub),
- XmNposition, value_int,
- NULL);
- }
- else
- {
- XmeWarning((Widget)w, WARN_COPY_COUNT);
- XtVaGetValues(
- PSUB_CopiesSpinBox(psub),
- XmNposition, &value_int,
- NULL);
- value = (char*) XtMalloc(64);
- if (value)
- {
- sprintf(value, "%d", value_int);
- XtVaSetValues(w, XmNvalue, value, NULL);
- XtFree(value);
- }
- }
- if (value) XtVaSetValues(w, XmNcursorPosition, strlen(value), NULL);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: CreateButton
- *
- * Description:
- *
- * Return value:
- *
- * Widget ID of the new button widget.
- *
- */
- static Widget
- CreateButton(Widget parent,
- String label,
- String name,
- XmNavigationType nav_type)
- {
- XmString label_string;
- Widget w;
- XmTakesDefaultTrait trait_default ;
-
- label_string = XmStringGenerate((XtPointer)label, (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- w = XtVaCreateWidget(name,
- xmPushButtonWidgetClass,
- parent,
- XmNlabelString, label_string,
- XmNnavigationType, nav_type,
- NULL);
- if(label_string) XmStringFree(label_string);
- trait_default = (XmTakesDefaultTrait)
- XmeTraitGet((XtPointer)XtClass(w), XmQTtakesDefault) ;
- if(trait_default)
- trait_default->showAsDefault(w, XmDEFAULT_READY);
- return w;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: CreateButtonGadget
- *
- * Description:
- *
- * Return value:
- *
- * Widget ID of the new button gadget.
- *
- */
- static Widget
- CreateButtonGadget(Widget parent,
- String label,
- String name,
- XmNavigationType nav_type)
- {
- XmString label_string;
- Widget w;
- XmTakesDefaultTrait trait_default ;
-
- label_string = XmStringGenerate((XtPointer)label, (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- w = XtVaCreateWidget(name,
- xmPushButtonGadgetClass,
- parent,
- XmNlabelString, label_string,
- XmNnavigationType, nav_type,
- NULL);
- if(label_string) XmStringFree(label_string);
- trait_default = (XmTakesDefaultTrait)
- XmeTraitGet((XtPointer)XtClass(w), XmQTtakesDefault) ;
- if(trait_default)
- trait_default->showAsDefault(w, XmDEFAULT_READY);
- return w;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: CreateLabelGadget
- *
- * Description:
- *
- * Return value:
- *
- * Widget ID of the new label gadget.
- *
- */
- static Widget
- CreateLabelGadget(
- Widget parent,
- String label,
- String name)
- {
- XmString label_string;
- Widget w;
-
- label_string = XmStringGenerate((XtPointer)label, (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- w = XtVaCreateWidget(name,
- xmLabelGadgetClass,
- parent,
- XmNlabelString, label_string,
- NULL);
- if(label_string) XmStringFree(label_string);
- return w;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: CreateModalPrinterSpec
- *
- * Arguments:
- *
- * name_mode
- * A valid X Printer Specifier Display Mode (see the
- * XpPrinterNameMode resource definition).
- *
- * full_printer_name
- * The fully qualified printer name
- *
- * Description:
- *
- * Creates an X Printer Specifier appropriate to an X Printer
- * Specifier Display Mode, given a full printer name
- *
- * Return value:
- *
- * A newly allocated string containing the resulting X Printer
- * specifier. It is the resposibility of the caller to free the
- * memory using XtFree(1).
- *
- * NULL is returned if:
- * * the passed printer_name is NULL
- * * if memory allocation fails.
- *
- */
- static String
- CreateModalPrinterSpec(
- XtEnum name_mode,
- const String full_printer_name)
- {
- String modal_printer_spec;
- String printer_name;
- String display_spec;
- /*
- * check for NULL passed parms
- */
- if(full_printer_name == (String)NULL)
- {
- return (String)NULL;
- }
- /*
- * break the fully qualified printer name into printer and display
- * name components
- */
- _DtPrintParseXPrinterSpecifier(full_printer_name,
- &printer_name, &display_spec);
- /*
- * if display mode is SHORT, just the printer name will do
- */
- if(name_mode == DtSHORT_NAME)
- {
- modal_printer_spec = XtNewString(printer_name);
- }
- else
- {
- String host_name;
- DtPrintSpecNet spec_net;
- int display_num;
- int screen_num;
- /*
- * break up the display specifier
- */
- _DtPrintParseXDisplaySpecifier(display_spec, &host_name,
- &spec_net, &display_num, &screen_num);
- /*
- * create the modal specifier
- */
- switch(name_mode)
- {
- case DtMEDIUM_NAME:
- modal_printer_spec =
- _DtPrintCreateXPrinterSpecifier(printer_name, host_name,
- DtPRINT_NET_UNSPECIFIED,
- -1, -1);
- break;
- case DtLONG_NAME:
- modal_printer_spec =
- _DtPrintCreateXPrinterSpecifier(printer_name, host_name,
- spec_net,
- display_num, screen_num);
- break;
-
- default:
- /*
- * invalid name mode; default to short name
- */
- modal_printer_spec = XtNewString(printer_name);
- break;
- }
- XtFree(host_name);
- }
- /*
- * clean up and return
- */
- XtFree(printer_name);
- XtFree(display_spec);
- return modal_printer_spec;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DeleteChild - Composite class method
- *
- * Description:
- *
- * Remove child from setup box widget
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- DeleteChild(
- Widget child)
- {
- DtPrintSetupBoxWidget psub ;
- XtWidgetProc delete_child;
- if(XtIsRectObj(child))
- {
- psub = (DtPrintSetupBoxWidget) XtParent(child);
- /*
- * Clear widget fields (BulletinBoard does default and cancel).
- */
- if(child == PSUB_BottomSeparator(psub))
- {
- PSUB_BottomSeparator(psub) = NULL;
- }
- else if(child == PSUB_ButtonSeparator(psub))
- {
- PSUB_ButtonSeparator(psub) = NULL;
- }
- else if(child == PSUB_DescriptionLabel(psub))
- {
- PSUB_DescriptionLabel(psub) = NULL;
- }
- else if(child == PSUB_Description(psub))
- {
- PSUB_Description(psub) = NULL;
- }
- else if(child == PSUB_PrinterNameLabel(psub))
- {
- PSUB_PrinterNameLabel(psub) = NULL;
- }
- else if(child == PSUB_CopiesControl(psub))
- {
- PSUB_CopiesControl(psub) = NULL;
- PSUB_CopiesSpinBox(psub) = NULL;
- }
- else if(child == PSUB_TopWorkArea(psub))
- {
- PSUB_TopWorkArea(psub) = NULL;
- }
- else if(child == PSUB_BottomWorkArea(psub))
- {
- PSUB_BottomWorkArea(psub) = NULL;
- }
- else if(child == PSUB_PrintButton(psub))
- {
- PSUB_PrintButton(psub) = NULL;
- }
- else if(child == PSUB_PrinterInfoButton(psub))
- {
- PSUB_PrinterInfoButton(psub) = NULL;
- }
- else if(child == PSUB_PrinterNameCombo(psub))
- {
- PSUB_PrinterNameCombo(psub) = NULL;
- PSUB_PrinterNameText(psub) = NULL;
- }
- else if(child == PSUB_SetupButton(psub))
- {
- PSUB_SetupButton(psub) = NULL;
- }
- else if(child == PSUB_HelpButton(psub))
- {
- PSUB_HelpButton(psub) = NULL;
- }
- else if(child == PSUB_TopSeparator(psub))
- {
- PSUB_TopSeparator(psub) = NULL;
- }
- else if(child == PSUB_DestinationRadioBox(psub))
- {
- PSUB_DestinationRadioBox(psub) = NULL;
- }
- else if(child == PSUB_FileNameLabel(psub))
- {
- PSUB_FileNameLabel(psub) = NULL;
- }
- else if(child == PSUB_FileNameText(psub))
- {
- PSUB_FileNameText(psub) = NULL;
- }
- else if(child == PSUB_SelectFileButton(psub))
- {
- PSUB_SelectFileButton(psub) = NULL;
- }
- else if(child == PSUB_SelectPrinterButton(psub))
- {
- PSUB_SelectPrinterButton(psub) = NULL;
- }
- }
- _DtPrintProcessLock();
- delete_child = ((XmBulletinBoardWidgetClass)xmBulletinBoardWidgetClass)
- ->composite_class.delete_child;
- _DtPrintProcessUnlock();
- (*delete_child)(child) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DestinationChangedCallback
- *
- * Description:
- *
- * Process a change in the print destination generated by the GUI user.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- DestinationChangedCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)client_data;
- XmToggleButtonCallbackStruct* cbs =
- (XmToggleButtonCallbackStruct*)call_data;
- if(cbs->set)
- {
- XtPointer user_data;
- /*
- * set the print destination according to the selected radio
- * button
- */
- XtVaGetValues(w, XmNuserData, &user_data, NULL);
- PSUB_PrintDestination(psub) = (XtEnum) (intptr_t) user_data;
- /*
- * Update the print setup box controls sensitivity accordingly
- */
- if(PSUB_SelectFileButton(psub))
- XtSetSensitive(PSUB_SelectFileButton(psub),
- PSUB_PrintDestination(psub) == DtPRINT_TO_FILE);
- if(PSUB_FileNameLabel(psub))
- XtSetSensitive(PSUB_FileNameLabel(psub),
- PSUB_PrintDestination(psub) == DtPRINT_TO_FILE);
- if(PSUB_FileNameText(psub))
- XtSetSensitive(PSUB_FileNameText(psub),
- PSUB_PrintDestination(psub) == DtPRINT_TO_FILE);
- if(PSUB_CopyCountSupported(psub))
- {
- if(PSUB_CopiesSpinBox(psub))
- XtSetSensitive(PSUB_CopiesSpinBox(psub),
- PSUB_PrintDestination(psub) == DtPRINT_TO_PRINTER);
- if(PSUB_CopiesControl(psub))
- {
- Widget copies_label =
- XtNameToWidget(PSUB_CopiesControl(psub), "CopiesLabel");
- XtSetSensitive(copies_label,
- PSUB_PrintDestination(psub) == DtPRINT_TO_PRINTER);
- }
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: Destroy - Core class method
- *
- * Description:
- *
- * Clean up resources allocated by the PrintSetupBox widget.
- *
- * Return Value:
- *
- * None.
- */
- static void
- Destroy(
- Widget w)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)w;
- /*
- * close the Xp connection
- */
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP
- &&
- PSUB_Display(psub) != (Display*)NULL)
- {
- ClosePrintConnection(psub, PSUB_PrinterName(psub), False);
- }
- /*
- * synthetic resources
- */
- XtFree(PSUB_FileName(psub));
- XtFree(PSUB_PrinterName(psub));
- /*
- * internal data
- */
- XtFree(PSUB_ModalPrinterSpec(psub));
- }
- /*
- * ------------------------------------------------------------------------
- * Name: EstablishPrinter
- *
- * Description:
- *
- *
- * Return Value:
- *
- * DtPRINT_SUCCESS
- * if a valid printer has been established
- * (i.e. for Xp, a connection has been set up)
- *
- * DtPRINT_FAILURE
- * if the printer could not be established
- *
- * DtPRINT_BAD_PARM
- * if any passed parameter is invalid
- *
- */
- static XtEnum
- EstablishPrinter(
- DtPrintSetupBoxWidget psub,
- DtPrintSetupData* psd)
- {
- switch(PSUB_VerifyPrinterState(psub))
- {
- case DtPRINT_NOT_VERIFIED:
- /*
- * if there's a printer connection timer waiting, remove it
- * to avoid conflict
- */
- if(PSUB_TimeoutId(psub) != (XtIntervalId)NULL)
- {
- XtRemoveTimeOut(PSUB_TimeoutId(psub));
- PSUB_TimeoutId(psub) = (XtIntervalId)NULL;
- }
- /*
- * call the verify printer proc for the new printer
- */
- if(PSUB_VerifyPrinterProc(psub) != NULL)
- {
- int status;
-
- psd->printer_name = PSUB_PrinterName(psub);
- PSUB_VerifyPrinterState(psub) = DtPRINT_IN_VERIFY;
- status = (*PSUB_VerifyPrinterProc(psub))((Widget)psub, psd);
- if(status != DtPRINT_SUCCESS)
- {
- /*
- * the printer isn't valid - set the verify printer state
- * back to "not verified" and return
- */
- PSUB_VerifyPrinterState(psub) = DtPRINT_NOT_VERIFIED;
- return status;
- }
- PSUB_VerifyPrinterState(psub) = DtPRINT_VERIFIED;
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP)
- {
- /*
- * set the new display and context in the widget
- */
- PSUB_Display(psub) = psd->print_display;
- #if 0 && defined(PRINTING_SUPPORTED)
- PSUB_Context(psub) = psd->print_context;
- #endif /* PRINTING_SUPPORTED */
- /*
- * initialize the display for use with Xt
- */
- {
- String *argv = NULL, *argv_copy;
- int argc = 0, i;
- String video_name, video_class;
- Widget video_widget = (Widget)psub;
- XtAppContext app_context;
- /*
- * get to the video app root shell
- */
- while((Widget)NULL != video_widget)
- {
- if(XtIsApplicationShell(video_widget))
- break;
- else
- video_widget = XtParent(video_widget);
- }
- if((Widget)NULL == video_widget)
- video_widget = (Widget)psub;
- /*
- * if not an applicationShell, argc/argv will stay
- * NULL in the GetValues call, no need to check
- * explicitly
- */
- XtVaGetValues(video_widget,
- XmNargc, &argc, XmNargv, &argv,
- NULL);
- /* copy argv, modified by XtDisplayInitialize below */
- argv_copy =
- (String *) XtMalloc(sizeof(String) * (argc + 1));
- for (i = 0; i < argc; i++) {
- argv_copy[i] = argv[i];
- }
- argv_copy[argc] = NULL;
- /*
- * now add the print display in our app context, so
- * that event dispatching works
- */
- XtGetApplicationNameAndClass(XtDisplay(video_widget),
- &video_name, &video_class);
- app_context = XtWidgetToApplicationContext(video_widget);
- XtDisplayInitialize(app_context,
- PSUB_Display(psub),
- video_name, video_class,
- PSUB_Options(psub),
- PSUB_OptionCount(psub),
- &argc, argv_copy);
- XtFree((char *) argv_copy);
- }
- /*
- * pick up attributes for the new printer
- */
- GetPrintAttributes(psub);
- }
- }
- else
- {
- PSUB_VerifyPrinterState(psub) = DtPRINT_VERIFIED;
- }
- /*
- * no break
- */
-
- case DtPRINT_VERIFIED:
- /*
- * fill out current printer info in setup data
- */
- psd->printer_name = PSUB_PrinterName(psub);
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP)
- {
- psd->print_display = PSUB_Display(psub);
- #if 0 && defined(PRINTING_SUPPORTED)
- psd->print_context = PSUB_Context(psub);
- #endif /* PRINTING_SUPPORTED */
- }
- break;
- case DtPRINT_IN_VERIFY:
- /*
- * EstablishPrinter should not be called recursively
- */
- return DtPRINT_BAD_PARM;
- break;
- }
-
- return DtPRINT_SUCCESS;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: GetPrintAttributes
- *
- * Description:
- *
- * Get printing attributes relevant to the PrintSetupBox from the
- * current print context.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- GetPrintAttributes(
- DtPrintSetupBoxWidget psub)
- {
- #if 0 && defined(PRINTING_SUPPORTED)
- char* attr_value;
- XTextProperty text_prop;
- char** list;
- int count;
- XmString description = (XmString)NULL;
- char* ptr;
- /*
- * get the printer description, and set the description field
- */
- attr_value = XpGetOneAttribute(PSUB_Display(psub),
- PSUB_Context(psub),
- XPPrinterAttr,
- XpATTR_DESCRIPTOR);
- if(attr_value != (char*)NULL)
- {
- /*
- * convert the description from COMPOUND_TEXT into the
- * codeset of the current locale
- */
- text_prop.value = (unsigned char*)attr_value;
- text_prop.encoding =
- XInternAtom(XtDisplay((Widget)psub), "COMPOUND_TEXT", False);
- text_prop.format = 8;
- text_prop.nitems = strlen((char*)text_prop.value);
- if(Success ==
- XmbTextPropertyToTextList(XtDisplay((Widget)psub),
- &text_prop, &list, &count))
- {
- if(count > 0)
- {
- if((String)NULL != list[0] && '\0' != *(list[0]))
- {
- /*
- * chop the description after the 1st line
- */
- char* ptr = Dt_strchr(list[0], '\n');
- if((char*)NULL != ptr)
- *ptr = '\0';
- }
- description =
- XmStringGenerate((XtPointer)list[0], (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- }
- XFreeStringList(list);
- }
- else
- {
- XmeWarning((Widget)psub, WARN_CT_CONVERSION);
- }
- XFree(attr_value);
- }
- /*
- * update the printer description
- */
- if((XmString)NULL == description)
- description = XmStringGenerate((XtPointer)"", (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- UpdateString(PSUB_Description(psub),
- description,
- PSUB_StringDirection(psub));
- XmStringFree(description);
- /*
- * determine if copy-count is supported
- */
- PSUB_CopyCountSupported(psub) = False;
- attr_value = XpGetOneAttribute(PSUB_Display(psub), PSUB_Context(psub),
- XPPrinterAttr, XpATTR_DOC_ATTRS_SUPPORTED);
- if(attr_value != (char*)NULL)
- {
- int token_len;
- for(ptr = attr_value + SpanWhitespace(attr_value);
- *ptr != '\0';
- ptr += SpanWhitespace(ptr+=token_len))
- {
- token_len = SpanNonWhitespace(ptr);
- if(0 == strncmp(ptr, XpATTR_COPY_COUNT, token_len))
- {
- PSUB_CopyCountSupported(psub) = True;
- break;
- }
- }
- XFree(attr_value);
- }
- if(!PSUB_CopyCountSupported(psub))
- {
- /*
- * copy-count not supported; disable the copies control
- */
- if(PSUB_CopiesSpinBox(psub))
- XtSetSensitive(PSUB_CopiesSpinBox(psub), False);
- if(PSUB_CopiesControl(psub))
- {
- Widget copies_label =
- XtNameToWidget(PSUB_CopiesControl(psub), "CopiesLabel");
- XtSetSensitive(copies_label, False);
- }
- }
- #endif /* PRINTING_SUPPORTED */
- }
- /*
- * ------------------------------------------------------------------------
- * Name: Initialize - Core class method
- *
- * Description:
- *
- * Create a PrintSetupBox widget instance.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- Initialize(
- Widget rw,
- Widget nw,
- ArgList args,
- Cardinal *num_args)
- {
- DtPrintSetupBoxWidget new_w = (DtPrintSetupBoxWidget) nw ;
- /*
- * Validate the Print Setup Mode
- */
- ValidatePrintSetupMode(new_w, (DtPrintSetupBoxWidget)NULL);
- /*
- * set the Xp-mode default resource procedure if the resource is
- * unspecified
- */
- if(PSUB_PrintSetupMode(new_w) == DtPRINT_SETUP_XP)
- {
- if(PSUB_PrinterInfoProc(new_w) == (DtPrintSetupProc)DtUNSPECIFIED)
- PSUB_PrinterInfoProc(new_w) = _DtPrintSetupBoxXPrinterInfoProc;
- if(PSUB_SelectPrinterProc(new_w) == (DtPrintSetupProc)DtUNSPECIFIED)
- PSUB_SelectPrinterProc(new_w) = _DtPrintSetupBoxSelectXPrinterProc;
- if(PSUB_VerifyPrinterProc(new_w) == (DtPrintSetupProc)DtUNSPECIFIED)
- PSUB_VerifyPrinterProc(new_w) = _DtPrintSetupBoxVerifyXPrinterProc;
- }
- else
- {
- /*
- * for the plain setup mode, unspecified procedure resources
- * default to NULL
- */
- if(PSUB_PrinterInfoProc(new_w) == (DtPrintSetupProc)DtUNSPECIFIED)
- PSUB_PrinterInfoProc(new_w) = (DtPrintSetupProc)NULL;
- if(PSUB_SelectPrinterProc(new_w) == (DtPrintSetupProc)DtUNSPECIFIED)
- PSUB_SelectPrinterProc(new_w) = (DtPrintSetupProc)NULL;
- if(PSUB_VerifyPrinterProc(new_w) == (DtPrintSetupProc)DtUNSPECIFIED)
- PSUB_VerifyPrinterProc(new_w) = (DtPrintSetupProc)NULL;
- }
- /*
- * initialize internal flags
- */
- PSUB_VerifyPrinterState(new_w) = DtPRINT_NOT_VERIFIED;
- PSUB_CopyCountSupported(new_w) = True;
- /*
- * initialize internal data
- */
- PSUB_ModalPrinterSpec(new_w) = (String)NULL;
- PSUB_Display(new_w) = (Display*)NULL;
- #if 0 && defined(PRINTING_SUPPORTED)
- PSUB_Context(new_w) = (XPContext)NULL;
- #endif /* PRINTING_SUPPORTED */
- PSUB_TimeoutId(new_w) = (XtIntervalId)NULL;
- /*
- * retrieve the XpPrinterNameMode application resource for this
- * widget
- */
- {
- XtResource res_struct;
- res_struct.resource_name = "xpPrinterNameMode";
- res_struct.resource_class = "XpPrinterNameMode";
- res_struct.resource_type = XmREnum;
- res_struct.resource_size = sizeof(XtEnum);
- res_struct.resource_offset = 0;
- res_struct.default_type = XmRImmediate;
- res_struct.default_addr = (XtPointer)DtSHORT_NAME;
- XtGetApplicationResources(nw,
- (XtPointer)&PSUB_XpPrinterNameMode(new_w),
- &res_struct, 1, (ArgList)NULL, 0);
- }
- /*
- * Initialize work area children variables
- */
- PSUB_TopWorkArea(new_w) = (Widget)NULL;
- PSUB_BottomWorkArea(new_w) = (Widget)NULL;
- ValidateWorkAreaLocation(new_w, (DtPrintSetupBoxWidget)NULL);
- /*
- * Initialize default resource procedures private data
- */
- _DtPrintDefProcInitialize((Widget)new_w);
- /*
- * Create child widgets.
- */
- PSUB_AddingSelWidgets(new_w) = True;
- _DtPrintSetupBoxCreateTopSeparator(new_w);
- _DtPrintSetupBoxCreateDescriptionLabel(new_w);
- _DtPrintSetupBoxCreateDescription(new_w);
- _DtPrintSetupBoxCreatePrinterInfoButton (new_w);
-
- _DtPrintSetupBoxCreatePrinterNameLabel(new_w);
- _DtPrintSetupBoxCreatePrinterNameCombo(new_w);
- _DtPrintSetupBoxCreateSelectPrinterButton(new_w);
- _DtPrintSetupBoxCreateFileNameLabel(new_w);
- _DtPrintSetupBoxCreateFileNameText(new_w);
- _DtPrintSetupBoxCreateSelectFileButton(new_w);
- _DtPrintSetupBoxCreateDestinationRadioBox(new_w);
- _DtPrintSetupBoxCreateCopiesControl(new_w);
- _DtPrintSetupBoxCreateBottomSeparator(new_w);
- _DtPrintSetupBoxCreateButtonSeparator (new_w);
- _DtPrintSetupBoxCreatePrintButton (new_w);
- _DtPrintSetupBoxCreateSetupButton (new_w);
- _DtPrintSetupBoxCreateCancelButton (new_w);
- _DtPrintSetupBoxCreateHelpButton (new_w);
- /*
- * Validate/update copies spin box
- */
- SynthSetCopies(new_w, (DtPrintSetupBoxWidget)NULL);
- /*
- * Update Printer Description
- */
- if((XmString)NULL != PSUB_DescriptionString(new_w))
- {
- UpdateString(PSUB_Description(new_w),
- PSUB_DescriptionString(new_w),
- PSUB_StringDirection(new_w));
- PSUB_DescriptionString(new_w) = NULL ;
- }
- /*
- * Initialize printer information
- */
- SynthSetPrinterName(new_w,
- XtNewString(PSUB_PrinterName(new_w)),
- (String)NULL);
- /*
- * Validate print destination / update print to file checkbox
- */
- SynthSetPrintDestination(new_w, (DtPrintSetupBoxWidget)NULL);
- /*
- * Update the file name text box
- */
- SynthSetFileName(new_w, (DtPrintSetupBoxWidget)NULL);
- /*
- * specify the Print button as the default button
- */
- BB_DefaultButton(new_w) = PSUB_PrintButton(new_w) ;
- _XmBulletinBoardSetDynDefaultButton((Widget) new_w,
- BB_DefaultButton(new_w)) ;
- PSUB_AddingSelWidgets(new_w) = False;
- XtManageChildren (new_w->composite.children,
- new_w->composite.num_children) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: InsertChild - Composite class method
- *
- * Description:
- *
- * The Print Setup widget supports up to TWO work area children. This
- * routine handles adding a child to the Print Setup widget.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- InsertChild(
- Widget child)
- {
- DtPrintSetupBoxWidget psub ;
- XtWidgetProc insert_child;
- /*
- * Use the dialog class insert proc to do all the dirty work
- */
- _DtPrintProcessLock();
- insert_child = ((XmBulletinBoardWidgetClass)xmBulletinBoardWidgetClass)
- ->composite_class.insert_child;
- _DtPrintProcessUnlock();
- (*insert_child)(child) ;
- if(!XtIsRectObj(child))
- {
- return ;
- }
- psub = (DtPrintSetupBoxWidget) XtParent(child) ;
- /*
- * check if this child is to be the one of the work areas
- */
- if(!PSUB_AddingSelWidgets(psub)
- && !(XmIsRowColumn(child)
- && ((XmRowColumnWidget)child)->row_column.type == XmMENU_BAR
- )
- && !XtIsShell(child)
- && !IsButton(child))
- {
- if(PSUB_TopWorkArea(psub) == (Widget)NULL
- &&
- (PSUB_WorkAreaLocation(psub) == DtWORK_AREA_TOP
- ||
- PSUB_WorkAreaLocation(psub) == DtWORK_AREA_TOP_AND_BOTTOM)
- )
- {
- PSUB_TopWorkArea(psub) = child;
- }
- else if(PSUB_BottomWorkArea(psub) == (Widget)NULL
- &&
- (PSUB_WorkAreaLocation(psub) == DtWORK_AREA_BOTTOM
- ||
- PSUB_WorkAreaLocation(psub) == DtWORK_AREA_TOP_AND_BOTTOM)
- )
- {
- PSUB_BottomWorkArea(psub) = child;
- }
- }
- }
- static Boolean
- IsSetupRequired(
- DtPrintSetupBoxWidget psub)
- {
- #if 0 && defined(PRINTING_SUPPORTED)
- char* setup_proviso;
- #endif /* PRINTING_SUPPORTED */
- Boolean required = False;
- #if 0 && defined(PRINTING_SUPPORTED)
- setup_proviso = XpGetOneAttribute(PSUB_Display(psub),
- PSUB_Context(psub),
- XPPrinterAttr,
- XpATTR_SETUP_PROVISO);
- if((char*)NULL != setup_proviso)
- {
- char* ptr;
- int token_len;
- ptr = setup_proviso + SpanWhitespace(setup_proviso);
- token_len = SpanNonWhitespace(ptr);
- if(token_len && 0 == strncmp(ptr, "xp-setup-mandatory", token_len))
- {
- char* setup_state;
- /*
- * setup is mandatory; check to see if it has been performed
- */
- setup_state = XpGetOneAttribute(PSUB_Display(psub),
- PSUB_Context(psub),
- XPJobAttr,
- XpATTR_SETUP_STATE);
- if((char*)NULL == setup_state)
- required = True;
- else
- {
- ptr = setup_state + SpanWhitespace(setup_state);
- token_len = SpanNonWhitespace(ptr);
- if(token_len)
- {
- /*
- * if the value of the setup state attribute is
- * xp-setup-ok then setup is not required
- */
- if(0 != strncmp(ptr, "xp-setup-ok", token_len))
- required = True;
- }
- else
- required = True;
- XFree(setup_state);
- }
- }
- XFree(setup_proviso);
- }
- #endif /* PRINTING_SUPPORTED */
- return required;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: MenuBarFixUp
- *
- * Description:
- *
- * This routine is a fixup routine which can be used for rows which
- * consist of a single MenuBar RowColumn. The effect of this routine
- * is to have the RowColumn ignore the margin width and height.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- MenuBarFixUp(
- XmGeoMatrix geoSpec,
- int action,
- XmGeoMajorLayout layoutPtr,
- XmKidGeometry rowPtr)
- {
- Dimension marginW ;
- Dimension marginH ;
- Dimension twoMarginW ;
- marginW = geoSpec->margin_w ;
- twoMarginW = (marginW << 1) ;
- marginH = geoSpec->margin_h ;
- switch( action )
- {
- case XmGEO_PRE_SET:
- {
- rowPtr->box.x -= marginW ;
- rowPtr->box.width += twoMarginW ;
- rowPtr->box.y -= marginH ;
- break ;
- }
- default:
- {
- if( rowPtr->box.width > twoMarginW )
- {
- /*
- * Avoid subtracting a margin from box width which would
- * result in underflow.
- */
- rowPtr->box.x += marginW ;
- rowPtr->box.width -= twoMarginW ;
- }
- if( action == XmGET_PREFERRED_SIZE )
- {
- /*
- * Set width to some small value so it does not effect
- * total width of matrix.
- */
- rowPtr->box.width = 1 ;
- }
- break ;
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: PrintSetupBoxCallback
- *
- * Description:
- *
- * Call the callbacks for a PrintSetupBox button.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- PrintSetupBoxCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data)
- {
- DtPrintSetupBoxChild which_button = (DtPrintSetupBoxChild)client_data;
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)XtParent(w);
- XmAnyCallbackStruct* callback = (XmAnyCallbackStruct*)call_data;
- DtPrintSetupCallbackStruct cbs;
- DtPrintSetupData psd;
- memset(&cbs, 0, sizeof(DtPrintSetupCallbackStruct));
- memset(&psd, 0, sizeof(DtPrintSetupData));
- cbs.print_data = &psd;
- cbs.event = callback->event;
- /*
- * we want to see any error messages that may pop up when
- * establishing the printer connection
- */
- psd.messages_hint = DtPRINT_HINT_MESSAGES_OK;
-
- switch(which_button)
- {
- case DtPRINT_CANCEL_BUTTON:
- cbs.reason = DtPRINT_CR_CANCEL;
- XtCallCallbackList((Widget)psub,
- PSUB_CancelCallback(psub),
- (XtPointer)&cbs);
- break;
- case DtPRINT_FILES_BUTTON:
- if(PSUB_SelectFileProc(psub))
- {
- /*
- * setup the destination info
- */
- SetPSDDestination(psub, &psd);
- /*
- * call select file proc
- */
- (*PSUB_SelectFileProc(psub))((Widget)psub, &psd);
- }
- break;
- case DtPRINT_HELP_BUTTON:
- /*
- * Invoke the help system.
- */
- _XmManagerHelp((Widget)psub, callback->event, NULL, NULL) ;
- break;
- case DtPRINT_INFO_BUTTON:
- if(PSUB_PrinterInfoProc(psub))
- {
- /*
- * pick up the printer name from the widget's Printer Name text
- * field
- */
- SynthGetPrinterName(psub);
- /*
- * establish a connection to the X printer
- */
- if(EstablishPrinter(psub, &psd) == DtPRINT_SUCCESS)
- {
- /*
- * For X printing, set printing attributes
- */
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP)
- {
- SetPrintAttributes(psub);
- }
- /*
- * call printer info proc
- */
- (*PSUB_PrinterInfoProc(psub))((Widget)psub, &psd);
- }
- }
- break;
-
- case DtPRINT_PRINT_BUTTON:
- /*
- * pick up the printer name from the widget's Printer Name text
- * field
- */
- SynthGetPrinterName(psub);
- /*
- * establish a connection to the X printer
- */
- if(EstablishPrinter(psub, &psd) == DtPRINT_SUCCESS)
- {
- /*
- * For X printing, set printing attributes
- */
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP)
- {
- SetPrintAttributes(psub);
- }
- /*
- * setup the destination info
- */
- SetPSDDestination(psub, &psd);
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP
- &&
- IsSetupRequired(psub))
- {
- /*
- * setup is needed; call the setup callback instead
- */
- cbs.reason = DtPRINT_CR_SETUP;
- XtCallCallbackList((Widget)psub,
- PSUB_SetupCallback(psub),
- (XtPointer)&cbs);
- }
- else
- {
- /*
- * The printer name is OK. Go ahead and unmanage the print
- * setup box if the auto-unmanage resource is set.
- */
- if(PSUB_AutoUnmanage(psub) && PSUB_Shell(psub))
- XtUnmanageChild((Widget)psub);
- /*
- * call the Print callback list
- */
- cbs.reason = DtPRINT_CR_PRINT;
- XtCallCallbackList((Widget)psub,
- PSUB_PrintCallback(psub),
- (XtPointer)&cbs);
- }
- }
- break;
- case DtPRINT_PRINTERS_BUTTON:
- if(PSUB_SelectPrinterProc(psub))
- {
- /*
- * call the printer selection proc
- */
- psd.printer_name = PSUB_PrinterName(psub);
- (*PSUB_SelectPrinterProc(psub))((Widget)psub, &psd);
- }
- break;
- case DtPRINT_SETUP_BUTTON:
- /*
- * pick up the printer name from the widget's Printer Name text
- * field
- */
- SynthGetPrinterName(psub);
- /*
- * establish a connection to the X printer
- */
- if(EstablishPrinter(psub, &psd) == DtPRINT_SUCCESS)
- {
- /*
- * For X printing, set printing attributes
- */
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP)
- {
- SetPrintAttributes(psub);
- }
- /*
- * setup the destination info
- */
- SetPSDDestination(psub, &psd);
- /*
- * Call setup callback
- */
- cbs.reason = DtPRINT_CR_SETUP;
- XtCallCallbackList((Widget)psub,
- PSUB_SetupCallback(psub),
- (XtPointer)&cbs);
- }
- break;
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SeparatorFixUp
- *
- * Description:
- *
- * This routine is a fixup routine which can be used for rows which
- * consist of a single separator widget. The effect of this routine
- * is to have the separator ignore the margin width.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SeparatorFixUp(
- XmGeoMatrix geoSpec,
- int action,
- XmGeoMajorLayout layoutPtr,
- XmKidGeometry rowPtr )
- {
- Dimension marginW ;
- Dimension twoMarginW ;
- marginW = geoSpec->margin_w ;
- twoMarginW = (marginW << 1) ;
- switch( action )
- {
- case XmGEO_PRE_SET:
- {
- rowPtr->box.x -= marginW ;
- rowPtr->box.width += twoMarginW ;
- break ;
- }
- default:
- {
- if( rowPtr->box.width > twoMarginW )
- {
- /*
- * Avoid subtracting a margin from box width which would
- * result in underflow.
- */
- rowPtr->box.x += marginW ;
- rowPtr->box.width -= twoMarginW ;
- }
- if( action == XmGET_PREFERRED_SIZE )
- {
- /*
- * Set width to some small value so it does not
- * effect total width of matrix.
- */
- rowPtr->box.width = 1 ;
- }
- break ;
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SetNewPrinterName
- *
- * Description:
- *
- * For Xp, if there is an existing open Xp connection, the
- * connection is closed, and the DtNclosePrintDisplayCallback list is
- * called using old_printer_name.
- *
- * old_printer_name is then freed using XtFree.
- *
- * The printer_name instance variable is set to new_printer_name
- * which must point to memory previously allocated using one of the
- * Xt memory allocation functions.
- *
- * This function unsets the printer name verified flag.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SetNewPrinterName(
- DtPrintSetupBoxWidget psub,
- String new_printer_name,
- String old_printer_name)
- {
- /*
- * close the existing Xp connection
- */
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP
- &&
- PSUB_Display(psub) != (Display*)NULL)
- {
- ClosePrintConnection(psub, old_printer_name, True);
- }
- /*
- * free the old printer name
- */
- XtFree(old_printer_name);
- /*
- * update the printer name instance data
- */
- PSUB_PrinterName(psub) = new_printer_name;
- /*
- * ensure the new printer name will be verified
- */
- if(PSUB_VerifyPrinterState(psub) == DtPRINT_VERIFIED)
- PSUB_VerifyPrinterState(psub) = DtPRINT_NOT_VERIFIED;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SetPrintAttributes
- *
- * Description:
- *
- * Set printing attributes relevant to the PrintSetupBox into the
- * current print context.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SetPrintAttributes(
- DtPrintSetupBoxWidget psub)
- {
- /*
- * Set the copy-count document attribute in the current context
- */
- if((Widget)NULL != PSUB_CopiesSpinBox(psub))
- {
- char str[48];
-
- XtVaGetValues(PSUB_CopiesSpinBox(psub),
- XmNposition, &PSUB_Copies(psub),
- NULL);
- sprintf(str, "*%s: %d\n", XpATTR_COPY_COUNT, PSUB_Copies(psub));
- #if 0 && defined(PRINTING_SUPPORTED)
- XpSetAttributes(PSUB_Display(psub), PSUB_Context(psub),
- XPDocAttr, str, XPAttrMerge);
- #endif /* PRINTING_SUPPORTED */
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SetPSDDestination
- *
- * Description:
- *
- * Set print destination information in the passed setup data
- * struct for use in callbacks.
- *
- * Return value:
- *
- * None.
- *
- */
- static void SetPSDDestination(
- DtPrintSetupBoxWidget psub,
- DtPrintSetupData* psd)
- {
- psd->destination = PSUB_PrintDestination(psub);
- switch(PSUB_PrintDestination(psub))
- {
- case DtPRINT_TO_PRINTER:
- psd->dest_info = PSUB_ModalPrinterSpec(psub);
- break;
-
- case DtPRINT_TO_FILE:
- SynthGetFileName(psub);
- psd->dest_info = PSUB_FileName(psub);
- break;
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SetSyntheticResForChild
- *
- * Description:
- *
- * Indicate to the synthetic resource mechanism that it should copy
- * the resource value.
- *
- * Return value:
- *
- * Always XmSYNTHETIC_LOAD.
- *
- */
- static XmImportOperator
- SetSyntheticResForChild(
- Widget widget,
- int offset,
- XtArgVal *value)
- {
- return XmSYNTHETIC_LOAD;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SetValues - Core class method
- *
- * Description:
- *
- * Update widget when values change.
- *
- * Return value:
- *
- * Always False, because this widget will redraw itself.
- *
- */
- static Boolean
- SetValues(
- Widget cw,
- Widget rw,
- Widget nw,
- ArgList args,
- Cardinal *num_args)
- {
- DtPrintSetupBoxWidget current = (DtPrintSetupBoxWidget) cw ;
- DtPrintSetupBoxWidget new_w = (DtPrintSetupBoxWidget) nw ;
- Boolean need_layout = False;
- BB_InSetValues(new_w) = True;
- /*
- * Validate the Print Setup Mode
- */
- if(PSUB_PrintSetupMode(new_w) != PSUB_PrintSetupMode(current))
- ValidatePrintSetupMode(new_w, current);
- /*
- * Validate work area location
- */
- if(PSUB_WorkAreaLocation(new_w) != PSUB_WorkAreaLocation(current))
- ValidateWorkAreaLocation(new_w, current);
- /*
- * Update Printer Description
- */
- if(PSUB_DescriptionString(new_w) != PSUB_DescriptionString(current))
- {
- UpdateString(PSUB_Description(new_w),
- PSUB_DescriptionString(new_w),
- PSUB_StringDirection(new_w));
- PSUB_DescriptionString(new_w) = NULL ;
- }
- /*
- * Validate print destination / update print to file checkbox
- */
- if(PSUB_PrintDestination(new_w) != PSUB_PrintDestination(current))
- SynthSetPrintDestination(new_w, current);
- /*
- * Update the file name
- */
- if(PSUB_FileName(new_w) != PSUB_FileName(current))
- SynthSetFileName(new_w, current);
- /*
- * Validate/update copies spin box
- */
- if(PSUB_Copies(new_w) != PSUB_Copies(current))
- SynthSetCopies(new_w, current);
- /*
- * Update the Printer Name text field
- */
- if(PSUB_PrinterName(new_w) != PSUB_PrinterName(current))
- {
- if((PSUB_PrinterName(new_w) == NULL
- ||
- PSUB_PrinterName(current) == NULL)
- ? True
- : strcmp(PSUB_PrinterName(new_w), PSUB_PrinterName(current)) != 0)
- {
- /*
- * the printer names are different; set the new printer name
- * into the instance structure and the printer name text
- * field
- */
- SynthSetPrinterName(new_w,
- XtNewString(PSUB_PrinterName(new_w)),
- PSUB_PrinterName(current));
- }
- else
- {
- /*
- * printer names are identical; keep current
- */
- PSUB_PrinterName(new_w) = PSUB_PrinterName(current);
- }
- }
- if(PSUB_MinimizeButtons(new_w) != PSUB_MinimizeButtons(current))
- {
- need_layout = True;
- }
- /*
- * finished setting values
- */
- BB_InSetValues (new_w) = False;
- /*
- * If this is the instantiated class then do layout.
- */
- if(need_layout && XtClass(new_w) == dtPrintSetupBoxWidgetClass)
- {
- _XmBulletinBoardSizeUpdate((Widget) new_w) ;
- }
- return False;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SpanNonWhitespace
- *
- * Description:
- *
- * Returns the length of the initial segment of the passed string
- * that consists entirely of non-whitespace characters.
- *
- *
- */
- static int
- SpanNonWhitespace(const char* string)
- {
- const char* ptr;
- for(ptr = string;
- *ptr != '\0' && !DtIsspace((char*)ptr);
- ptr = DtNextChar((char*)ptr));
- return ptr - string;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SpanWhitespace
- *
- * Description:
- *
- * Returns the length of the initial segment of the passed string
- * that consists entirely of whitespace characters.
- *
- *
- */
- static int
- SpanWhitespace(const char* string)
- {
- const char* ptr;
- for(ptr = string;
- *ptr != '\0' && DtIsspace((char*)ptr);
- ptr = DtNextChar((char*)ptr));
- return ptr - string;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SynthGetFileName
- *
- * Description:
- *
- * Updates the file_name element of the PrintSetupBox instance
- * structure based on the current state of the File Name text field.
- *
- * Return Value:
- *
- * None.
- *
- */
- static void SynthGetFileName(
- DtPrintSetupBoxWidget psub)
- {
- /*
- * free the existing file name
- */
- XtFree(PSUB_FileName(psub));
- /*
- * set the file name widget instance value based on the File Name
- * text field value
- */
- if(PSUB_FileNameText(psub) != (Widget)NULL)
- XtVaGetValues((Widget)PSUB_FileNameText(psub),
- XmNvalue, &PSUB_FileName(psub),
- NULL);
- else
- PSUB_FileName(psub) = (String)NULL;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SynthGetPrinterName
- *
- * Description:
- *
- * Updates the modal_printer_spec and the printer_name elements of
- * the PrintSetupBox instance structure based on the current state of
- * the Printer Name text field. The verify printer state will be set
- * to "not verified" if the printer_name is updated.
- *
- * Return Value:
- *
- * None.
- *
- */
- static void
- SynthGetPrinterName(
- DtPrintSetupBoxWidget psub)
- {
- Boolean printer_spec_changed = False;
- String previous_modal_spec;
-
- if(PSUB_PrinterNameText(psub) != (Widget)NULL)
- {
- /*
- * get the modal Printer Specifier from the Printer Name text
- * field
- */
- previous_modal_spec = PSUB_ModalPrinterSpec(psub);
- XtVaGetValues((Widget)PSUB_PrinterNameText(psub),
- XmNvalue, &PSUB_ModalPrinterSpec(psub),
- NULL);
- /*
- * determine if we have a new printer name
- */
- switch(PSUB_PrintSetupMode(psub))
- {
- case DtPRINT_SETUP_PLAIN:
- if((PSUB_ModalPrinterSpec(psub) == (String)NULL
- ||
- PSUB_PrinterName(psub) == (String)NULL))
- {
- printer_spec_changed = True;
- }
- else if(strcmp(PSUB_ModalPrinterSpec(psub), PSUB_PrinterName(psub))
- != 0)
- {
- printer_spec_changed = True;
- }
- break;
- case DtPRINT_SETUP_XP:
- if(PSUB_PrinterName(psub) == (String)NULL
- ||
- PSUB_ModalPrinterSpec(psub) == (String)NULL
- ||
- (Display*)NULL == PSUB_Display(psub)
- ||
- strcmp(previous_modal_spec, PSUB_ModalPrinterSpec(psub)) != 0)
- {
- printer_spec_changed = True;
- }
- break;
- }
- XtFree(previous_modal_spec);
- }
- if(printer_spec_changed)
- {
- SetNewPrinterName(psub,
- XtNewString(PSUB_ModalPrinterSpec(psub)),/*new name*/
- PSUB_PrinterName(psub)); /* old name */
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SynthSetCopies
- *
- * Description:
- *
- * Validate the DtNcopies resource, and use it to update the Copies
- * spin box.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SynthSetCopies(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current)
- {
- if(PSUB_Copies(new_w) < 1 || PSUB_Copies(new_w) > MAX_COPIES)
- {
- XmeWarning((Widget)new_w, WARN_COPY_COUNT);
- if(current == (DtPrintSetupBoxWidget)NULL)
- PSUB_Copies(new_w) = 1;
- else
- PSUB_Copies(new_w) = PSUB_Copies(current);
- }
- if(PSUB_CopiesSpinBox(new_w) != (Widget)NULL)
- XtVaSetValues(PSUB_CopiesSpinBox(new_w),
- XmNposition, PSUB_Copies(new_w),
- NULL);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SynthSetFileName
- *
- * Description:
- *
- * Update the file name text field.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SynthSetFileName(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current)
- {
- /*
- * free the old file name
- */
- if(current != (DtPrintSetupBoxWidget)NULL)
- {
- XtFree(PSUB_FileName(current));
- }
- /*
- * make a copy of the new file name
- */
- PSUB_FileName(new_w) = XtNewString(PSUB_FileName(new_w));
- /*
- * update the file name text box
- */
- if(PSUB_FileNameText(new_w) != (Widget)NULL)
- {
- XmTextPosition last_position;
- XmTextFieldSetString(PSUB_FileNameText(new_w), PSUB_FileName(new_w));
- last_position = XmTextFieldGetLastPosition(PSUB_FileNameText(new_w));
- XmTextFieldSetInsertionPosition(PSUB_FileNameText(new_w),
- last_position);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SynthSetPrintDestination
- *
- * Description:
- *
- * Validate the DtNprintDestination resource, and use it to update
- * the print destination radio buttons.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SynthSetPrintDestination(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current)
- {
- if(PSUB_PrintDestination(new_w) != DtPRINT_TO_PRINTER
- &&
- PSUB_PrintDestination(new_w) != DtPRINT_TO_FILE)
- {
- XmeWarning((Widget)new_w, WARN_PRINT_DESTINATION);
- if(current == (DtPrintSetupBoxWidget)NULL)
- PSUB_PrintDestination(new_w) = DtPRINT_TO_PRINTER;
- else
- PSUB_PrintDestination(new_w) = PSUB_PrintDestination(current);
- }
- if((Widget)NULL != PSUB_DestinationRadioBox(new_w))
- {
- Widget button;
-
- switch(PSUB_PrintDestination(new_w))
- {
- case DtPRINT_TO_PRINTER:
- button =
- XtNameToWidget(PSUB_DestinationRadioBox(new_w), "button_0");
- XmToggleButtonSetState(button, True, True);
- break;
-
- case DtPRINT_TO_FILE:
- button =
- XtNameToWidget(PSUB_DestinationRadioBox(new_w), "button_1");
- XmToggleButtonSetState(button, True, True);
- break;
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: SynthSetPrinterName
- *
- * Description:
- *
- * Set the passed new_printer_name into the print setup box by
- * updating the Printer Name text field and the modal_printer_name
- * and printer_name instance variables. The verify printer state will
- * be set to DtPRINT_NOT_VERIFIED if the printer_name was updated.
- *
- * new_printer_name must have been previously allocated using one of
- * the Xt memory allocation functions. If the passed new_printer_name
- * is NULL, a default printer name will be used.
- *
- * The old_printer_name is passed to the DtNclosePrintDisplayCallback
- * list, if it is called. The old_printer_name is freed using XtFree.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- SynthSetPrinterName(
- DtPrintSetupBoxWidget psub,
- String new_printer_name,
- String old_printer_name)
- {
- /*
- * update the printer name in the widget instance structure
- */
- SetNewPrinterName(psub, new_printer_name, old_printer_name);
- /*
- * create a new modal printer name
- */
- XtFree(PSUB_ModalPrinterSpec(psub));
- switch(PSUB_PrintSetupMode(psub))
- {
- case DtPRINT_SETUP_PLAIN:
- /*
- * Ignore the name mode
- */
- PSUB_ModalPrinterSpec(psub) = XtNewString(PSUB_PrinterName(psub));
- break;
- case DtPRINT_SETUP_XP:
- /*
- * Create a modal X Printer Specifier
- */
- PSUB_ModalPrinterSpec(psub) =
- CreateModalPrinterSpec(PSUB_XpPrinterNameMode(psub),
- PSUB_PrinterName(psub));
- break;
- }
- /*
- * Set the modal printer specifier in the Printer Name text field
- */
- if(PSUB_PrinterNameText(psub))
- {
- XtVaSetValues(PSUB_PrinterNameText(psub),
- XmNvalue, PSUB_ModalPrinterSpec(psub),
- NULL);
- XmComboBoxUpdate(PSUB_PrinterNameCombo(psub));
- }
- /*
- * verify the printer; get intial attributes for a new X printer
- * connection
- */
- if(PSUB_VerifyPrinterState(psub) == DtPRINT_NOT_VERIFIED)
- {
- DtPrintSetupData psd;
- Window window;
-
- memset(&psd, 0, sizeof(DtPrintSetupData));
- /*
- * don't show any messages if this widget isn't mapped
- */
- psd.messages_hint = DtPRINT_HINT_NO_MESSAGES;
- window = XtWindow((Widget)psub);
- if(window)
- {
- XWindowAttributes attr;
- Status status = XGetWindowAttributes(XtDisplay((Widget)psub),
- window, &attr);
- if(status != 0 && attr.map_state == IsViewable)
- psd.messages_hint = DtPRINT_HINT_MESSAGES_OK;
- }
- /*
- * establish a connection to the X printer
- */
- EstablishPrinter(psub, &psd);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: UpdatePrinterNameCallback
- *
- * Description:
- *
- * Kick off a timer proc to establish the selected printer in the
- * widget. This allows the hourglass to be visible while the
- * connection is being established. The hourglass can't be set inside
- * the callback because the combo box list is still popped up with
- * the pointer grabbed... Of course if the user is traversing through
- * the list with the cursor keys, ie. without popping it down,
- * there's nothing we can do to change the cursor...
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- UpdatePrinterNameCallback(
- Widget w,
- XtPointer client_data,
- XtPointer call_data)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)client_data;
- if(PSUB_TimeoutId(psub) != (XtIntervalId)NULL)
- XtRemoveTimeOut(PSUB_TimeoutId(psub));
- PSUB_TimeoutId(psub) =
- XtAppAddTimeOut(XtWidgetToApplicationContext(w),
- (unsigned long)0,
- UpdatePrinterNameTimeoutProc,
- (XtPointer)psub);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: UpdatePrinterNameCallback
- *
- * Description:
- *
- * Timeout proc that establishes a printer connection in response to
- * a user selection in the printer name combo box.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- UpdatePrinterNameTimeoutProc(XtPointer client_data,
- XtIntervalId* id)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)client_data;
- DtPrintSetupData psd;
- /*
- * the timeout seems to happen before expose events from the
- * popdown
- */
- XmUpdateDisplay((Widget)psub);
- /*
- * the timeout proc is only called once per XtAppAddTimeOut
- */
- PSUB_TimeoutId(psub) = (XtIntervalId)NULL;
- /*
- * check to see if the printer name has changed (if so,
- * SynthGetPrinterName will close an existing print connection)
- */
- SynthGetPrinterName(psub);
- /*
- * try to establish a connection to a new printer name
- * (the message hint is set so that we don't see error messages from
- * here)
- */
- memset(&psd, 0, sizeof(DtPrintSetupData));
- psd.messages_hint = DtPRINT_HINT_NO_MESSAGES;
- EstablishPrinter(psub, &psd);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: UpdateString
- *
- * Description:
- *
- * Set the label string of a label or button
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- UpdateString(
- Widget w,
- XmString string,
- XmStringDirection direction)
- {
- Arg al[3];
- int ac = 0;
- if (w)
- {
- XtSetArg (al[ac], XmNstringDirection, direction); ac++;
- XtSetArg (al[ac], XmNlabelString, string); ac++;
- XtSetValues (w, al, ac);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ValidatePrintSetupMode
- *
- * Description:
- *
- * Validate the DtNprintSetupMode resource.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ValidatePrintSetupMode(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current)
- {
- if(current == (DtPrintSetupBoxWidget)NULL)
- {
- switch(PSUB_PrintSetupMode(new_w))
- {
- case DtPRINT_SETUP_PLAIN:
- case DtPRINT_SETUP_XP:
- break;
- default:
- PSUB_PrintSetupMode(new_w) = SETUP_MODE_DEFAULT;
- XmeWarning((Widget)new_w, WARN_SETUP_MODE);
- break;
- }
- }
- else
- {
- /*
- * prevent changes to the mode
- */
- PSUB_PrintSetupMode(new_w) = PSUB_PrintSetupMode(current);
- XmeWarning((Widget)new_w, WARN_SETUP_MODE_CHANGE);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: ValidateWorkAreaLocation
- *
- * Description:
- *
- * Validate the DtNworkAreaLocation resource.
- *
- * Return value:
- *
- * None.
- *
- */
- static void
- ValidateWorkAreaLocation(
- DtPrintSetupBoxWidget new_w,
- DtPrintSetupBoxWidget current)
- {
- switch(PSUB_WorkAreaLocation(new_w))
- {
- case DtWORK_AREA_NONE:
- case DtWORK_AREA_TOP:
- case DtWORK_AREA_TOP_AND_BOTTOM:
- case DtWORK_AREA_BOTTOM:
- break;
-
- default:
- XmeWarning((Widget)new_w, WARN_WORK_AREA_LOCATION);
- if(current == (DtPrintSetupBoxWidget)NULL)
- PSUB_WorkAreaLocation(new_w) = WORK_AREA_DEFAULT;
- else
- PSUB_WorkAreaLocation(new_w) = PSUB_WorkAreaLocation(current);
- break;
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateBottomSeparator
- *
- * Description:
- *
- * Create the Separator displayed above the bottom work area
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateBottomSeparator(DtPrintSetupBoxWidget psub)
- {
- Arg al[10];
- int ac = 0;
- XtSetArg(al[ac], XmNhighlightThickness, 0); ac++;
- PSUB_BottomSeparator(psub) =
- XmCreateSeparatorGadget((Widget) psub,
- "BottomWorkAreaSeparator",
- al, ac);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateButtonSeparator
- *
- * Description:
- *
- * Create the Separator displayed above the buttons.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateButtonSeparator(DtPrintSetupBoxWidget sel)
- {
- Arg al[10];
- int ac = 0;
- XtSetArg(al[ac], XmNhighlightThickness, 0); ac++;
- PSUB_ButtonSeparator(sel) =
- XmCreateSeparatorGadget((Widget) sel, "ButtonSeparator", al, ac);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateCancelButton
- *
- * Description:
- *
- * Create the "Cancel" PushButton.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateCancelButton(
- DtPrintSetupBoxWidget psub)
- {
- PSUB_CancelButton(psub) =
- CreateButtonGadget((Widget)psub, CANCEL_LABEL, "Cancel", XmNONE);
- XtAddCallback(PSUB_CancelButton(psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer) DtPRINT_CANCEL_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateCopiesControl
- *
- * Description:
- *
- * Create the copy count label and spin box.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateCopiesControl(DtPrintSetupBoxWidget psub)
- {
- Widget copies_label;
- Widget copies_text;
- Boolean copies_text_editable;
- /*
- * create a row column to contain the copy count label and spin box
- */
- PSUB_CopiesControl(psub) =
- XtVaCreateWidget("CopiesControl",
- xmRowColumnWidgetClass,
- (Widget)psub,
- XmNorientation, XmHORIZONTAL,
- NULL);
- /*
- * create the label
- */
- copies_label = CreateLabelGadget(PSUB_CopiesControl(psub),
- COPIES_LABEL, "CopiesLabel");
- XtManageChild(copies_label);
- /*
- * spin box
- */
- PSUB_CopiesSpinBox(psub) =
- XtVaCreateManagedWidget("Copies",
- xmSimpleSpinBoxWidgetClass,
- PSUB_CopiesControl(psub) ,
- XmNspinBoxChildType, XmNUMERIC,
- XmNminimumValue, 1,
- XmNmaximumValue, MAX_COPIES,
- XmNposition, 1,
- XmNpositionType, XmPOSITION_VALUE,
- XmNcolumns, 5,
- XmNwrap, False,
- NULL);
- copies_text = NULL;
- copies_text_editable = FALSE;
- XtVaGetValues(
- PSUB_CopiesSpinBox(psub),
- XmNtextField, &copies_text,
- XmNeditable, &copies_text_editable,
- NULL);
- if (copies_text && copies_text_editable)
- XtAddCallback(
- copies_text, XmNvalueChangedCallback,
- CopiesTextValueChangedCallback, (XtPointer) psub);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateDescription
- *
- * Description:
- *
- * Create the printer description.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateDescription(
- DtPrintSetupBoxWidget psub)
- {
- XmRenderTable render_table;
- XFontStruct* font;
- unsigned long char_width;
- XmString empty_label;
- /*
- * create the description label gadget
- */
- empty_label = XmStringCreateLocalized(" ");
- PSUB_Description(psub) =
- XtVaCreateWidget("Description",
- xmLabelWidgetClass,
- (Widget)psub,
- XmNalignment, XmALIGNMENT_BEGINNING,
- XmNlabelString, empty_label,
- NULL);
- XmStringFree(empty_label);
- /*
- * get the maximum character width for the default font of the gadget
- */
- XtVaGetValues(PSUB_Description(psub), XmNrenderTable, &render_table, NULL);
- if(XmeRenderTableGetDefaultFont(render_table, &font))
- {
- Bool success;
- success = XGetFontProperty(font, XA_QUAD_WIDTH, &char_width);
- if(!success || char_width == 0)
- {
- if(font->per_char
- && font->min_char_or_byte2 <= '0'
- && font->max_char_or_byte2 >= '0'
- )
- char_width =
- font->per_char['0' - font->min_char_or_byte2].width;
- else
- char_width = font->max_bounds.width;
- }
- /*
- * set and lock the width of description gadget
- */
- XtVaSetValues(PSUB_Description(psub),
- XmNwidth, (Dimension)(DESCRIPTION_COLUMNS*char_width),
- XmNrecomputeSize, False,
- NULL);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateDescriptionLabel
- *
- * Description:
- *
- * Create the Label for the printer description.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateDescriptionLabel(DtPrintSetupBoxWidget psub)
- {
- PSUB_DescriptionLabel(psub) =
- CreateLabelGadget((Widget) psub,
- DESCRIPTION_LABEL,
- "DescriptionLabel") ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateDestinationRadioBox
- *
- * Description:
- *
- * Create the "Print to Printer" and "Print to File" radio buttons.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateDestinationRadioBox(DtPrintSetupBoxWidget psub)
- {
- Widget button;
- XmString label;
-
- PSUB_DestinationRadioBox(psub) =
- XtVaCreateWidget(
- "DestRadioBox",
- xmRowColumnWidgetClass,
- (Widget)psub,
- XmNradioBehavior, True,
- XmNorientation, XmHORIZONTAL,
- XmNpacking, XmPACK_TIGHT,
- NULL);
- label =
- XmStringGenerate((XtPointer)PRINT_TO_PRINTER_LABEL, (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- button =
- XtVaCreateManagedWidget("button_0",
- xmToggleButtonWidgetClass,
- PSUB_DestinationRadioBox(psub),
- XmNlabelString, label,
- XmNuserData, (XtPointer)DtPRINT_TO_PRINTER,
- NULL);
- XmStringFree(label);
- XtAddCallback(button, XmNvalueChangedCallback,
- DestinationChangedCallback, (XtPointer)psub);
- label = XmStringGenerate((XtPointer)PRINT_TO_FILE_LABEL, (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- button =
- XtVaCreateManagedWidget("button_1",
- xmToggleButtonWidgetClass,
- PSUB_DestinationRadioBox(psub),
- XmNlabelString, label,
- XmNuserData, (XtPointer)DtPRINT_TO_FILE,
- NULL);
- XmStringFree(label);
- XtAddCallback(button, XmNvalueChangedCallback,
- DestinationChangedCallback, (XtPointer)psub);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateFileNameLabel
- *
- * Description:
- *
- * Create the "Print to File" check box.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateFileNameLabel(DtPrintSetupBoxWidget psub)
- {
- PSUB_FileNameLabel(psub) =
- CreateLabelGadget((Widget)psub, FILE_NAME_LABEL, "FileNameLabel") ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateFileNameText
- *
- * Description:
- *
- * Create the print to file name text field.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateFileNameText(DtPrintSetupBoxWidget psub)
- {
- PSUB_FileNameText(psub) =
- XtVaCreateWidget("FileName",
- xmTextFieldWidgetClass,
- (Widget)psub,
- XmNcolumns, FILE_NAME_COLUMNS,
- NULL);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateHelpButton
- *
- * Description:
- * Create the "Help" PushButton.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateHelpButton(DtPrintSetupBoxWidget psub)
- {
- PSUB_HelpButton(psub) =
- CreateButtonGadget((Widget)psub, HELP_LABEL, "Help", XmNONE) ;
- /*
- * Remove BulletinBoard Unmanage callback
- */
- XtRemoveAllCallbacks(PSUB_HelpButton(psub), XmNactivateCallback) ;
- XtAddCallback(PSUB_HelpButton (psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer)DtPRINT_HELP_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreatePrintButton
- *
- * Description:
- * Create the "Print" PushButton.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreatePrintButton(DtPrintSetupBoxWidget psub)
- {
- PSUB_PrintButton(psub) =
- CreateButton((Widget)psub, PRINT_LABEL, "Print", XmNONE) ;
- /*
- * Remove the BulletinBoard unmanage callback. The
- * PrintSetupBoxCallback routine will unmanage the widget if the
- * AutoUnmanage resource is set, but only if the printer name is
- * successfully verified.
- */
- XtRemoveAllCallbacks(PSUB_PrintButton(psub), XmNactivateCallback);
- XtAddCallback(PSUB_PrintButton(psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer)DtPRINT_PRINT_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreatePrinterInfoButton
- *
- * Description:
- *
- * Create the "Info..." PushButton
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreatePrinterInfoButton(DtPrintSetupBoxWidget psub)
- {
- PSUB_PrinterInfoButton(psub) =
- CreateButton((Widget)psub, PRINTER_INFO_LABEL, "Info", XmTAB_GROUP);
- XtRemoveAllCallbacks(PSUB_PrinterInfoButton(psub), XmNactivateCallback);
- XtAddCallback(PSUB_PrinterInfoButton(psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer) DtPRINT_INFO_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreatePrinterNameCombo
- *
- * Description:
- *
- * Create the combo box containing the printer name text field and
- * the short printer list.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreatePrinterNameCombo(DtPrintSetupBoxWidget psub)
- {
- PSUB_PrinterNameCombo(psub) =
- XtVaCreateWidget("Name", xmComboBoxWidgetClass, (Widget)psub,
- XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX,
- XmNcolumns, PRINTER_NAME_COLUMNS,
- XmNpositionMode, XmZERO_BASED,
- NULL);
- PSUB_PrinterNameText(psub) =
- XtNameToWidget(PSUB_PrinterNameCombo(psub), "*Text");
- /*
- * add a selection callback to the combo box that will cause the
- * selected printer to be set in the PSUB (verified, etc).
- */
- XtAddCallback(PSUB_PrinterNameCombo(psub), XmNselectionCallback,
- UpdatePrinterNameCallback, (XtPointer)psub);
- /*
- * Xp Setup Mode specific initialization
- */
- if(PSUB_PrintSetupMode(psub) == DtPRINT_SETUP_XP)
- {
- String* printer_list;
- Boolean hide_arrow = True;
- /*
- * add a callback to close an existing connection whenever the
- * user modifies the text field.
- */
- XtAddCallback(PSUB_PrinterNameText(psub), XmNvalueChangedCallback,
- ClosePrintConnectionCallback, (XtPointer)psub);
- /*
- * initialize the combo box list
- */
- printer_list = _DtPrintGetXpPrinterList((Widget)psub);
- if(printer_list != (String*)NULL)
- {
- int count;
- /*
- * count the number of printer names in the returned list,
- */
- for(count = 0; printer_list[count] != (String)NULL; count++);
- if(count > 0)
- {
- XmString* printer_xmstr_list;
- int i;
- Widget combo_list;
- /*
- * build a XmString version of the printer list
- */
- printer_xmstr_list =
- (XmString*)XtCalloc(count, sizeof(XmString));
- for(i = 0; i < count; i++)
- printer_xmstr_list[i] =
- XmStringGenerate((XtPointer)printer_list[i],
- (XmStringTag)NULL,
- XmMULTIBYTE_TEXT, (XmStringTag)NULL);
- /*
- * get the widget ID of the combo box list
- */
- combo_list =
- XtNameToWidget(PSUB_PrinterNameCombo(psub), "*List");
- if(combo_list)
- {
- int visible_item_count;
- /*
- * get the initial visible item count
- */
- XtVaGetValues(combo_list,
- XmNvisibleItemCount, &visible_item_count,
- NULL);
- /*
- * reduce the visible item count if needed
- */
- if(count < visible_item_count)
- visible_item_count = count;
- /*
- * set the XmString printer list in the combo box list
- */
- XtVaSetValues(combo_list,
- XmNitemCount, count,
- XmNitems, printer_xmstr_list,
- XmNvisibleItemCount, visible_item_count,
- NULL);
- hide_arrow = False;
- }
- for(i = 0; i < count; i++)
- XmStringFree(printer_xmstr_list[i]);
- XtFree((char*)printer_xmstr_list);
- }
- _DtPrintFreeStringList(printer_list);
- }
- if(hide_arrow)
- {
- Dimension text_shadow_thickness;
- XtVaGetValues(PSUB_PrinterNameText(psub),
- XmNshadowThickness, &text_shadow_thickness,
- NULL);
- XtVaSetValues(PSUB_PrinterNameCombo(psub),
- XmNarrowSize, 0,
- XmNarrowSpacing, 0,
- XmNmarginWidth, 0,
- XmNmarginHeight, 0,
- XmNshadowThickness, 0,
- NULL);
- XtVaSetValues(PSUB_PrinterNameText(psub),
- XmNshadowThickness, text_shadow_thickness,
- NULL);
- }
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreatePrinterNameLabel
- *
- * Description:
- *
- * Create the Label for the printer name.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreatePrinterNameLabel(DtPrintSetupBoxWidget psub)
- {
- PSUB_PrinterNameLabel(psub) =
- CreateLabelGadget((Widget) psub,
- PRINTER_NAME_LABEL,
- "NameLabel") ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateSelectFileButton
- *
- * Description:
- *
- * Create the "Select File..." PushButton
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateSelectFileButton(DtPrintSetupBoxWidget psub)
- {
- PSUB_SelectFileButton(psub) =
- CreateButtonGadget((Widget)psub, SELECT_FILE_LABEL,
- "SelectFile", XmTAB_GROUP);
- XtRemoveAllCallbacks(PSUB_SelectFileButton(psub), XmNactivateCallback) ;
- XtAddCallback(PSUB_SelectFileButton(psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer) DtPRINT_FILES_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateSelectPrinterButton
- *
- * Description:
- *
- * Create the "Select Printer..." PushButton
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateSelectPrinterButton(DtPrintSetupBoxWidget psub)
- {
- PSUB_SelectPrinterButton(psub) =
- CreateButtonGadget((Widget)psub, SELECT_PRINTER_LABEL,
- "SelectPrinter", XmTAB_GROUP);
- XtRemoveAllCallbacks(PSUB_SelectPrinterButton(psub), XmNactivateCallback);
- XtAddCallback(PSUB_SelectPrinterButton(psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer) DtPRINT_PRINTERS_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateSetupButton
- *
- * Description:
- *
- * Create the "Setup" PushButton.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateSetupButton(DtPrintSetupBoxWidget psub)
- {
- PSUB_SetupButton(psub) =
- CreateButton((Widget) psub, SETUP_LABEL, "Setup", XmNONE);
- /*
- * Remove BulletinBoard Unmanage callback from Setup button
- */
- XtRemoveAllCallbacks(PSUB_SetupButton(psub), XmNactivateCallback) ;
- XtAddCallback(PSUB_SetupButton (psub), XmNactivateCallback,
- PrintSetupBoxCallback, (XtPointer) DtPRINT_SETUP_BUTTON) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxCreateTopSeparator
- *
- * Description:
- *
- * Create the Separator displayed below the top work area
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxCreateTopSeparator(DtPrintSetupBoxWidget psub)
- {
- Arg al[10];
- int ac = 0;
- XtSetArg(al[ac], XmNhighlightThickness, 0); ac++;
- PSUB_TopSeparator(psub) =
- XmCreateSeparatorGadget((Widget) psub,
- "TopWorkAreaSeparator",
- al, ac);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxGeoMatrixCreate - BulletinBoard class method
- *
- * Description:
- *
- * Return value:
- *
- */
- XmGeoMatrix
- _DtPrintSetupBoxGeoMatrixCreate(
- Widget wid,
- Widget instigator,
- XtWidgetGeometry *desired)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget) wid ;
- XmGeoMatrix geoSpec ;
- XmGeoRowLayout layoutPtr ;
- XmKidGeometry boxPtr ;
- XmKidGeometry firstButtonBox ;
- XmKidGeometry boxMark;
- Dimension vspace = BB_MarginHeight(psub);
- int i;
- PSUB_GeoExtension ext;
- int psub_geo_fill = XmGEO_PACK;
- int psub_geo_fit = XmGEO_PROPORTIONAL;
- /*
- * Layout PrintSetupBox XmGeoMatrix.
- * Each row is terminated by leaving an empty XmKidGeometry and
- * moving to the next XmGeoRowLayout.
- */
- geoSpec = _XmGeoMatrixAlloc(DtPSUB_MAX_WIDGETS_VERT,
- psub->composite.num_children,
- sizeof(PSUB_GeoExtensionRec));
- ext = geoSpec->extension;
- geoSpec->composite = (Widget) psub ;
- geoSpec->instigator = (Widget) instigator ;
- if(desired)
- {
- geoSpec->instig_request = *desired ;
- }
- geoSpec->margin_w = BB_MarginWidth(psub) + psub->manager.shadow_thickness;
- geoSpec->margin_h = BB_MarginHeight(psub) + psub->manager.shadow_thickness;
- geoSpec->no_geo_request = _DtPrintSetupBoxNoGeoRequest ;
- layoutPtr = &(geoSpec->layouts->row) ;
- boxPtr = geoSpec->boxes ;
- /*
- * menu bar
- */
- for (i = 0; i < psub->composite.num_children; i++)
- {
- Widget w = psub->composite.children[i];
- if(XmIsRowColumn(w)
- && ((XmRowColumnWidget)w)->row_column.type == XmMENU_BAR
- && w != PSUB_TopWorkArea(psub)
- && w != PSUB_BottomWorkArea(psub)
- && _XmGeoSetupKid(boxPtr, w))
- {
- layoutPtr->fix_up = MenuBarFixUp;
- boxPtr += 2;
- ++layoutPtr;
- vspace = 0; /* fixup space_above of next row. */
- break;
- }
- }
- /*
- * top work area + separator
- */
- if(PSUB_TopWorkArea(psub) != (Widget)NULL)
- {
- if(_XmGeoSetupKid(boxPtr, PSUB_TopWorkArea(psub)))
- {
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- boxPtr += 2;
- ++layoutPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_TopSeparator(psub)))
- {
- layoutPtr->fix_up = SeparatorFixUp;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- boxPtr += 2 ;
- ++layoutPtr ;
- }
- }
- /*
- * printer description label, printer description and printer info
- * button
- */
- boxMark = boxPtr;
- if(_XmGeoSetupKid(boxPtr, PSUB_DescriptionLabel(psub)))
- {
- (ext->pbox)[ext->row_count][0].geo = boxPtr;
- (ext->pbox)[ext->row_count][0].align = PSUB_GEO_ALIGN_RIGHT;
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_Description(psub)))
- {
- (ext->pbox)[ext->row_count][1].geo = boxPtr;
- (ext->pbox)[ext->row_count][1].align = PSUB_GEO_ALIGN_LEFT;
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_PrinterInfoButton(psub)))
- {
- (ext->pbox)[ext->row_count][2].geo = boxPtr;
- (ext->pbox)[ext->row_count][2].align = PSUB_GEO_ALIGN_EXPAND;
- ++boxPtr;
- }
- if(boxPtr != boxMark)
- {
- (ext->layout_ptr)[ext->row_count++] = layoutPtr;
- layoutPtr->fix_up = ColumnGeoFixUp;
- layoutPtr->even_width = 0;
- layoutPtr->even_height = 0;
- layoutPtr->fill_mode = psub_geo_fill ;
- layoutPtr->fit_mode = psub_geo_fit ;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- ++boxPtr;
- ++layoutPtr ;
- }
- /*
- * printer name label, printer name, select printer button
- */
- boxMark = boxPtr;
- if(_XmGeoSetupKid(boxPtr, PSUB_PrinterNameLabel(psub)))
- {
- (ext->pbox)[ext->row_count][0].geo = boxPtr;
- (ext->pbox)[ext->row_count][0].align = PSUB_GEO_ALIGN_RIGHT;
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_PrinterNameCombo(psub)))
- {
- (ext->pbox)[ext->row_count][1].geo = boxPtr;
- (ext->pbox)[ext->row_count][1].align = PSUB_GEO_ALIGN_LEFT;
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_SelectPrinterButton(psub)))
- {
- (ext->pbox)[ext->row_count][2].geo = boxPtr;
- (ext->pbox)[ext->row_count][2].align = PSUB_GEO_ALIGN_EXPAND;
- ++boxPtr;
- }
- if(boxPtr != boxMark)
- {
- (ext->layout_ptr)[ext->row_count++] = layoutPtr;
- layoutPtr->fix_up = ColumnGeoFixUp;
- layoutPtr->even_width = 0;
- layoutPtr->even_height = 0;
- layoutPtr->fill_mode = psub_geo_fill ;
- layoutPtr->fit_mode = psub_geo_fit ;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- ++boxPtr;
- ++layoutPtr ;
- }
- /*
- * file name label, file name text, select file button
- */
- boxMark = boxPtr;
- if(_XmGeoSetupKid(boxPtr, PSUB_FileNameLabel(psub)))
- {
- (ext->pbox)[ext->row_count][0].geo = boxPtr;
- (ext->pbox)[ext->row_count][0].align = PSUB_GEO_ALIGN_RIGHT;
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_FileNameText(psub)))
- {
- (ext->pbox)[ext->row_count][1].geo = boxPtr;
- (ext->pbox)[ext->row_count][1].align = PSUB_GEO_ALIGN_LEFT;
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_SelectFileButton(psub)))
- {
- (ext->pbox)[ext->row_count][2].geo = boxPtr;
- (ext->pbox)[ext->row_count][2].align = PSUB_GEO_ALIGN_EXPAND;
- ++boxPtr;
- }
- if(boxPtr != boxMark)
- {
- (ext->layout_ptr)[ext->row_count++] = layoutPtr;
- layoutPtr->fix_up = ColumnGeoFixUp;
- layoutPtr->even_width = 0;
- layoutPtr->even_height = 0;
- layoutPtr->fill_mode = psub_geo_fill ;
- layoutPtr->fit_mode = psub_geo_fit ;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- ++boxPtr;
- ++layoutPtr ;
- }
- /*
- * copies label and copies field
- */
- boxMark = boxPtr;
- if(_XmGeoSetupKid(boxPtr, PSUB_DestinationRadioBox(psub)))
- {
- ++boxPtr;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_CopiesControl(psub)))
- {
- ++boxPtr;
- }
- if(boxPtr != boxMark)
- {
- layoutPtr->fill_mode = XmGEO_CENTER ;
- layoutPtr->fit_mode = XmGEO_WRAP ;
- layoutPtr->even_width = 0;
- layoutPtr->even_height = 0;
- layoutPtr->space_between = 10;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- ++boxPtr;
- ++layoutPtr ;
- }
- /*
- * bottom work area + separator
- */
- if(PSUB_BottomWorkArea(psub) != (Widget)NULL)
- {
- if(_XmGeoSetupKid(boxPtr, PSUB_BottomSeparator(psub)))
- {
- layoutPtr->fix_up = SeparatorFixUp;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- boxPtr += 2 ;
- ++layoutPtr ;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_BottomWorkArea(psub)))
- {
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- boxPtr += 2;
- ++layoutPtr;
- }
- }
- /*
- * button separator
- */
- if(_XmGeoSetupKid(boxPtr, PSUB_ButtonSeparator(psub)))
- {
- layoutPtr->fix_up = SeparatorFixUp;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- boxPtr += 2 ;
- ++layoutPtr ;
- }
- /*
- * button row
- */
- firstButtonBox = boxPtr ;
- if(_XmGeoSetupKid(boxPtr, PSUB_PrintButton(psub)))
- {
- ++boxPtr ;
- }
- for(i = 0; i < psub->composite.num_children; i++)
- {
- Widget w = psub->composite.children[i];
- if(IsButton(w)
- &&
- !IsAutoButton(psub,w)
- &&
- w != PSUB_TopWorkArea(psub)
- &&
- w != PSUB_BottomWorkArea(psub)
- )
- {
- if(_XmGeoSetupKid(boxPtr, w))
- {
- ++boxPtr ;
- }
- }
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_SetupButton(psub)))
- {
- ++boxPtr ;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_CancelButton(psub)))
- {
- ++boxPtr ;
- }
- if(_XmGeoSetupKid(boxPtr, PSUB_HelpButton(psub)))
- {
- ++boxPtr ;
- }
- if(boxPtr != firstButtonBox)
- {
- layoutPtr->fill_mode = XmGEO_CENTER ;
- layoutPtr->fit_mode = XmGEO_WRAP ;
- layoutPtr->space_above = vspace;
- vspace = BB_MarginHeight(psub);
- if(!(psub->print_setup_box.minimize_buttons))
- {
- layoutPtr->even_width = 1 ;
- }
- layoutPtr->even_height = 1 ;
- ++layoutPtr ;
- }
- /*
- * the end.
- */
- layoutPtr->space_above = vspace;
- layoutPtr->end = TRUE ;
- return(geoSpec) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxNoGeoRequest
- *
- * Description:
- *
- * Return value:
- *
- */
- Boolean
- _DtPrintSetupBoxNoGeoRequest(
- XmGeoMatrix geoSpec)
- {
- if(BB_InSetValues(geoSpec->composite)
- && (XtClass(geoSpec->composite) == dtPrintSetupBoxWidgetClass))
- {
- return(TRUE) ;
- }
- return(FALSE) ;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxGetCopies
- *
- * Description:
- *
- * Update the location pointed to by "value" with the current value
- * of the Copies spin box.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxGetCopies(
- Widget wid,
- int resource_offset,
- XtArgVal *value)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget) wid ;
- int copies;
- if(PSUB_CopiesSpinBox(psub) != (Widget)NULL)
- {
- XtVaGetValues(PSUB_CopiesSpinBox(psub),
- XmNposition, &copies,
- NULL);
- *value = (XtArgVal)copies;
- }
- else
- {
- *value = (XtArgVal)PSUB_Copies(psub);
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxGetDescription
- *
- * Description:
- *
- * Update the description instance variable based on the current
- * value of the Printer Description label gadget.
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxGetDescription(
- Widget wid,
- int resource_offset,
- XtArgVal *value)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget) wid ;
- XmString data ;
- if(PSUB_Description(psub) != (Widget)NULL)
- {
- XtVaGetValues((Widget)PSUB_Description(psub),
- XmNlabelString, &data,
- NULL);
- *value = (XtArgVal)data;
- }
- else
- {
- *value = (XtArgVal)NULL;
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxGetFileName
- *
- * Description:
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxGetFileName(
- Widget w,
- int resource_offset,
- XtArgVal *value)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)w;
- SynthGetFileName(psub);
- *value = (XtArgVal)PSUB_FileName(psub);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: _DtPrintSetupBoxGetPrinterName
- *
- * Description:
- *
- * Return value:
- *
- * None.
- *
- */
- void
- _DtPrintSetupBoxGetPrinterName(
- Widget w,
- int resource_offset,
- XtArgVal *value)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)w;
- SynthGetPrinterName(psub);
- *value = (XtArgVal)PSUB_PrinterName(psub);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DtCreatePrintSetupBox
- *
- * Description:
- *
- * DtCreatePrintSetupBox is a convenience function that creates an
- * unmanaged instance of a DtPrintSetupBox widget, and returns its
- * widget ID.
- *
- * Arguments:
- *
- * parent
- * Specifies the parent widget ID.
- *
- * name
- * Specifies the name of the created widget.
- *
- * args
- * Specifies the argument list.
- *
- * n
- * Specifies the number of attribute/value pairs in arglist.
- *
- * Return value:
- *
- * Returns the DtPrintSetupBox widget ID.
- *
- */
- Widget
- DtCreatePrintSetupBox(
- Widget p,
- String name,
- ArgList args,
- Cardinal n)
- {
- return XtCreateWidget(name, dtPrintSetupBoxWidgetClass, p, args, n);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DtCreatePrintSetupDialog
- *
- * Description:
- *
- * DtCreatePrintSetupDialog is a convenience function that creates an
- * instance of a dialog containing a DtPrintSetupBox widget, and
- * returns the DtPrintSetupBox widget ID.
- *
- * Arguments:
- *
- * parent
- * Specifies the parent widget ID.
- *
- * name
- * Specifies the name of the created widget.
- *
- * args
- * Specifies the argument list.
- *
- * n
- * Specifies the number of attribute/value pairs in arglist.
- *
- * Return value:
- *
- * Returns the DtPrintSetupBox widget ID.
- *
- */
- Widget
- DtCreatePrintSetupDialog(
- Widget parent,
- String name,
- ArgList args,
- Cardinal n)
- {
- return XmeCreateClassDialog(dtPrintSetupBoxWidgetClass,
- parent, name, args, n);
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DtPrintCopySetupData
- *
- * Description:
- *
- * DtPrintCopySetupData is used to copy the DtPrintSetupData
- * structure pointed to by 'source' to the DtPrintSetupData structure
- * pointed to by 'target'. Elements in 'target' are updated only if
- * different than the corresponding element in 'source'. For elements
- * that point to allocated memory, DtPrintCopySetupData allocates new
- * memory for those elements updated in 'target'. Existing elements
- * in 'target' are freed using XtFree. All elements in a
- * DtPrintSetupData structure can be freed by calling
- * DtPrintFreeSetupData.
- *
- * If 'source' or 'target' is NULL the copy will not be performed.
- *
- * Arguments:
- *
- * target
- * A pointer to the DtPrintSetupData structure to copy to.
- *
- * source
- * A pointer to the DtPrintSetupData structure to copy from.
- *
- * Return value:
- *
- * The target pointer.
- *
- */
- DtPrintSetupData*
- DtPrintCopySetupData(
- DtPrintSetupData* target,
- const DtPrintSetupData* source)
- {
- if(source != (DtPrintSetupData*)NULL
- &&
- target != (DtPrintSetupData*)NULL)
- {
- if((source->printer_name == (String)NULL
- ||
- target->printer_name == (String)NULL)
- ? True
- : strcmp(source->printer_name, target->printer_name) != 0)
- {
- XtFree(target->printer_name);
- target->printer_name = XtNewString(source->printer_name);
- }
- target->print_display = source->print_display;
- #if 0 && defined(PRINTING_SUPPORTED)
- target->print_context = source->print_context;
- #endif /* PRINTING_SUPPORTED */
- target->destination = source->destination;
- target->messages_hint = source->messages_hint;
- if((source->dest_info == (String)NULL
- ||
- target->dest_info == (String)NULL)
- ? True
- : strcmp(source->dest_info, target->dest_info) != 0)
- {
- XtFree(target->dest_info);
- target->dest_info = XtNewString(source->dest_info);
- }
- }
- return target;
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DtPrintFillSetupData
- *
- * Description:
- *
- * DtPrintFillSetupData is used to obtain an X printer connection in
- * order to initiate an X printing job in situations other than
- * direct interaction with a DtPrintSetupBox (e.g. a "quick print"
- * button on a toolbar). This printer connection information can be
- * obtained from an existing DtPrintSetupBox widget instance, or if a
- * DtPrintSetupBox widget instance is unavailable,
- * DtPrintFillSetupData will provide a new X printer connection.
- *
- * Arguments:
- *
- * psub
- * The widget ID of a DtPrintSetupBox, or NULL if no
- * DtPrintSetupBox is available.
- *
- * print_data
- * A pointer to an existing DtPrintSetupData structure that
- * DtPrintFillSetupData will update with valid X printer
- * connection information.
- *
- * Return value:
- *
- * DtPRINT_SUCCESS
- * The X printer connection was successfully obtained.
- *
- * DtPRINT_FAILURE
- * The X printer connection could not be established. The
- * specific reason has been reported by the print setup box to
- * the user.
- *
- * DtPRINT_INVALID_DISPLAY
- * The indicated X print server could not be found.
- *
- * DtPRINT_NOT_XP_DISPLAY
- * The indicated X server does not support the X Printing
- * Extension.
- *
- * DtPRINT_NO_PRINTER
- * The indicated printer could not be found on the X print
- * server.
- *
- * DtPRINT_NO_DEFAULT
- * A default printer could not be determined.
- *
- * DtPRINT_BAD_PARM
- * The value passed for print_data is NULL.
- *
- */
- XtEnum DtPrintFillSetupData(
- Widget w,
- DtPrintSetupData* print_data)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)w;
-
- if(print_data == (DtPrintSetupData*)NULL)
- return DtPRINT_BAD_PARM;
-
- if(psub == (DtPrintSetupBoxWidget)NULL)
- {
- XtEnum status;
- String new_printer_spec;
- Display* new_display;
- #if 0 && defined(PRINTING_SUPPORTED)
- XPContext new_context;
- #endif /* PRINTING_SUPPORTED */
- /*
- * GUI-less printing; verify the printer name and establish the
- * print connection without involving the print setup box.
- */
- status = _DtPrintVerifyXPrinter(NULL,
- print_data->printer_name,
- &new_printer_spec,
- &new_display
- #if 0 && defined(PRINTING_SUPPORTED)
- ,&new_context
- #endif /* PRINTING_SUPPORTED */
- );
- if(status == DtPRINT_SUCCESS)
- {
- print_data->print_display = new_display;
- #if 0 && defined(PRINTING_SUPPORTED)
- print_data->print_context = new_context;
- #endif /* PRINTING_SUPPORTED */
- }
- if(new_printer_spec != (String)NULL)
- {
- XtFree(print_data->printer_name);
- print_data->printer_name = new_printer_spec;
- }
- return status;
- }
- else
- {
- DtPrintSetupData psd;
- XtEnum status;
- _DtPrintWidgetToAppContext((Widget)psub);
- /*
- * return if the passed widget's setup mode is not Xp
- */
- if(PSUB_PrintSetupMode(psub) != DtPRINT_SETUP_XP)
- return DtPRINT_BAD_PARM;
- /*
- * intialize an internal version of the print setup data struct
- */
- memset(&psd, 0, sizeof(DtPrintSetupData));
- /*
- * get the latest printer name from the widget
- */
- _DtPrintAppLock(app);
- SynthGetPrinterName(psub);
- /*
- * check to see if the passed printer name is different than
- * the psub printer name
- */
- if(print_data->printer_name != (String)NULL)
- {
- if((PSUB_PrinterName(psub) == NULL)
- ? True
- : strcmp(print_data->printer_name, PSUB_PrinterName(psub)) != 0)
- {
- /*
- * if different, set the passed printer name into the
- * passed print setup box widget
- */
- SynthSetPrinterName(psub,
- XtNewString(print_data->printer_name),
- PSUB_PrinterName(psub));
- }
- }
- /*
- * establish a connection to the X printer
- */
- psd.messages_hint = DtPRINT_HINT_NO_MESSAGES;
- status = EstablishPrinter(psub, &psd);
- if(status == DtPRINT_SUCCESS)
- {
- /*
- * set printing attributes
- */
- SetPrintAttributes(psub);
- /*
- * setup the destination info
- */
- SetPSDDestination(psub, &psd);
- /*
- * update the passed print setup data struct based on the
- * internal version of the print setup data struct
- */
- DtPrintCopySetupData(print_data, &psd);
- }
- else
- {
- /*
- * Unable to establish the printer connection; manage the
- * print setup box in order to present the error box created
- * by EstablishPrinter() to the user, allowing the user to
- * select a new printer or cancel.
- */
- XtManageChild((Widget)psub);
- /*
- * if the default verifyPrintProc created an error box,
- * display it. If the app installed its own verify proc, the
- * app will need to check the return status of
- * DtPrintFillSetupData, and manage its error dialog itself.
- */
- _DtPrintDefProcManageErrorBox(&PSUB_DefaultProcData(psub));
- }
- _DtPrintAppUnlock(app);
- return status;
- }
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DtPrintFreeSetupData
- *
- * Description:
- *
- * DtPrintFreeSetupData calls XtFree to deallocate memory pointed to
- * by elements of the DtPrintSetupData structure indicated by
- * 'target'. 'target' is then re-initialized to zeros.
- *
- * Arguments:
- *
- * target
- * points to the DtPrintSetupData structure whose elements are to
- * be freed.
- *
- * Return value:
- *
- * None.
- *
- */
- void DtPrintFreeSetupData(
- DtPrintSetupData* target)
- {
- XtFree(target->printer_name);
- XtFree(target->dest_info);
- memset(target, 0, sizeof(DtPrintSetupData));
- }
- /*
- * ------------------------------------------------------------------------
- * Name: DtPrintResetConnection
- *
- * Arguments:
- *
- * psub
- * The DtPrintSetupBox widget ID.
- *
- * mode
- * Indicates whether DtPrintResetConnection should close the X
- * print server connection, or simply cause the DtPrintSetupBox
- * to cease managing the connection.
- *
- * Description:
- *
- * DtPrintResetConnection is intended to be used by applications that
- * fork a child process to perform the print rendering
- * operation. After the fork is performed, the parent process will
- * close its X print server connection, and maintain its connection
- * to the video X server. The forked child on the other hand will
- * close its video X server connection and perform the rendering
- * operation on the X print server connection.
- *
- * Valid values for the 'mode' parameter are:
- *
- * DtPRINT_CLOSE_CONNECTION
- * Set by the parent process when the application forks a
- * child to perform the print rendering. This will cause the
- * DtNclosePrintDisplayCallback list set for the passed
- * DtPrintSetupBox to be called.
- *
- * DtPRINT_RELEASE_CONNECTION
- * Set when the application wishes to destroy the
- * DtPrintSetupBox widget instance and still perform print
- * rendering using the X print server connection initiated by
- * the widget. For example, the child process of an
- * application that forks to perform print rendering will
- * close the video display connection (thereby destroying the
- * DtPrintSetupBox widget) prior to print rendering.
- *
- * Return value:
- *
- * DtPRINT_SUCCESS
- * DtPrintResetConnection was successful.
- *
- * DtPRINT_NO_CONNECTION
- * An open X print server connection is not currently being
- * managed by the DtPrintSetupBox.
- *
- * DtPRINT_BAD_PARM
- * The value passed for wid is NULL, or an invalid mode was
- * passed.
- *
- */
- XtEnum
- DtPrintResetConnection(
- Widget w,
- DtPrintResetConnectionMode mode)
- {
- DtPrintSetupBoxWidget psub = (DtPrintSetupBoxWidget)w;
- _DtPrintWidgetToAppContext((Widget)psub);
- if(psub == (DtPrintSetupBoxWidget)NULL)
- return DtPRINT_BAD_PARM;
- _DtPrintAppLock(app);
- if(PSUB_PrintSetupMode(psub) != DtPRINT_SETUP_XP)
- {
- _DtPrintAppUnlock(app);
- return DtPRINT_BAD_PARM;
- }
- if(PSUB_Display(psub) == (Display*)NULL)
- {
- _DtPrintAppUnlock(app);
- return DtPRINT_NO_CONNECTION;
- }
-
- switch(mode)
- {
- case DtPRINT_RELEASE_CONNECTION:
- /*
- * simply disavow knowledge of the X print connection
- */
- PSUB_Display(psub) = (Display*)NULL;
- #if 0 && defined(PRINTING_SUPPORTED)
- PSUB_Context(psub) = (XPContext)NULL;
- #endif /* PRINTING_SUPPORTED */
- break;
-
- case DtPRINT_CLOSE_CONNECTION:
- /*
- * call the widget's close print connection routine
- */
- ClosePrintConnection(psub, PSUB_PrinterName(psub), True);
- break;
- default:
- _DtPrintAppUnlock(app);
- return DtPRINT_BAD_PARM;
- }
- /*
- * cause the printer to be re-verified if new connection is
- * is required later, and return
- */
- PSUB_VerifyPrinterState(psub) = DtPRINT_NOT_VERIFIED;
- _DtPrintAppUnlock(app);
- return DtPRINT_SUCCESS;
- }
|