PageRenderTime 62ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/timidity/interface/xaw_redef.c

https://github.com/MaDDoGo/xbmc
C | 824 lines | 517 code | 93 blank | 214 comment | 20 complexity | 20bef73ddf7eb474a8ea133a36074e93 MD5 | raw file
  1. /* Masanao Izumo <mo@goice.co.jp>:
  2. *
  3. * There is problem if both -lXm and -lXaw are linked.
  4. * This source code to re-define XAW vendorShell.
  5. * To change motif vendorShell to XAW vendorShell in runtime.
  6. *
  7. * #define vendorShellClassRec xaw_vendorShellClassRec
  8. * #define vendorShellWidgetClass xaw_vendorShellWidgetClass
  9. * #include "xaw_redef.c"
  10. * #undef vendorShellClassRec
  11. * #undef vendorShellWidgetClass
  12. * extern WidgetClass vendorShellWidgetClass;
  13. * extern VendorShellClassRec vendorShellClassRec;
  14. * static void xaw_vendor_setup(void)
  15. * {
  16. * memcpy(&vendorShellClassRec, &xaw_vendorShellClassRec,
  17. * sizeof(VendorShellClassRec));
  18. * vendorShellWidgetClass = (WidgetClass)&xaw_vendorShellWidgetClass;
  19. * }
  20. */
  21. /* $XConsortium: Vendor.c,v 1.27 94/04/17 20:13:25 kaleb Exp $ */
  22. /***********************************************************
  23. Copyright (c) 1987, 1988, 1994 X Consortium
  24. Permission is hereby granted, free of charge, to any person obtaining a copy
  25. of this software and associated documentation files (the "Software"), to deal
  26. in the Software without restriction, including without limitation the rights
  27. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  28. copies of the Software, and to permit persons to whom the Software is
  29. furnished to do so, subject to the following conditions:
  30. The above copyright notice and this permission notice shall be included in
  31. all copies or substantial portions of the Software.
  32. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  34. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  35. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  36. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  37. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  38. Except as contained in this notice, the name of the X Consortium shall not be
  39. used in advertising or otherwise to promote the sale, use or other dealings
  40. in this Software without prior written authorization from the X Consortium.
  41. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
  42. All Rights Reserved
  43. Permission to use, copy, modify, and distribute this software and its
  44. documentation for any purpose and without fee is hereby granted,
  45. provided that the above copyright notice appear in all copies and that
  46. both that copyright notice and this permission notice appear in
  47. supporting documentation, and that the name of Digital not be
  48. used in advertising or publicity pertaining to distribution of the
  49. software without specific, written prior permission.
  50. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  51. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  52. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  53. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  54. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  55. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  56. SOFTWARE.
  57. ******************************************************************/
  58. /*
  59. * This is a copy of Xt/Vendor.c with an additional ClassInitialize
  60. * procedure to register Xmu resource type converters, and all the
  61. * monkey business associated with input methods...
  62. *
  63. */
  64. /* Make sure all wm properties can make it out of the resource manager */
  65. #include <stdio.h>
  66. #include <X11/IntrinsicP.h>
  67. #include <X11/StringDefs.h>
  68. #include <X11/ShellP.h>
  69. #include <X11/VendorP.h>
  70. #include <X11/Xmu/Converters.h>
  71. #include <X11/Xmu/Atoms.h>
  72. #include <X11/Xmu/Editres.h>
  73. #ifdef HAVE_XMUREGISTEREXTERNALAGENT
  74. #ifdef HAVE_X11_XMU_EXTAGENT_H
  75. #include <X11/Xmu/ExtAgent.h>
  76. #else
  77. /* There is no ExtAgent.h in openwin package, but XmuRegisterExternalAgent
  78. * is surely defined in libXmu on Solaris 7.
  79. */
  80. extern void XmuRegisterExternalAgent(
  81. #if NeedFunctionPrototypes
  82. Widget /* w */,
  83. XtPointer /* data */,
  84. XEvent* /* event */,
  85. Boolean* /* cont */
  86. #endif
  87. );
  88. #endif /* HAVE_X11_XMU_EXTAGENT_H */
  89. #endif /* HAVE_XMUREGISTEREXTERNALAGENT */
  90. /* The following two headers are for the input method. */
  91. /* $XConsortium: VendorEP.h,v 1.2 94/04/17 20:13:25 kaleb Exp $ */
  92. /*
  93. * Copyright 1991 by OMRON Corporation
  94. *
  95. * Permission to use, copy, modify, distribute, and sell this software and its
  96. * documentation for any purpose is hereby granted without fee, provided that
  97. * the above copyright notice appear in all copies and that both that
  98. * copyright notice and this permission notice appear in supporting
  99. * documentation, and that the name of OMRON not be used in advertising or
  100. * publicity pertaining to distribution of the software without specific,
  101. * written prior permission. OMRON makes no representations about the
  102. * suitability of this software for any purpose. It is provided "as is"
  103. * without express or implied warranty.
  104. *
  105. * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  106. * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  107. * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  108. * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  109. * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
  110. * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  111. * SOFTWARE.
  112. *
  113. * Author: Seiji Kuwari OMRON Corporation
  114. * kuwa@omron.co.jp
  115. * kuwa%omron.co.jp@uunet.uu.net
  116. */
  117. /*
  118. Copyright (c) 1994 X Consortium
  119. Permission is hereby granted, free of charge, to any person obtaining a copy
  120. of this software and associated documentation files (the "Software"), to deal
  121. in the Software without restriction, including without limitation the rights
  122. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  123. copies of the Software, and to permit persons to whom the Software is
  124. furnished to do so, subject to the following conditions:
  125. The above copyright notice and this permission notice shall be included in
  126. all copies or substantial portions of the Software.
  127. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  128. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  129. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  130. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  131. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  132. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  133. Except as contained in this notice, the name of the X Consortium shall not be
  134. used in advertising or otherwise to promote the sale, use or other dealings
  135. in this Software without prior written authorization from the X Consortium.
  136. */
  137. #ifndef _VendorEP_h
  138. #define _VendorEP_h
  139. /* $XConsortium: XawImP.h,v 1.4 95/06/06 20:50:30 kaleb Exp $ */
  140. /*
  141. * Copyright 1991 by OMRON Corporation
  142. *
  143. * Permission to use, copy, modify, distribute, and sell this software and its
  144. * documentation for any purpose is hereby granted without fee, provided that
  145. * the above copyright notice appear in all copies and that both that
  146. * copyright notice and this permission notice appear in supporting
  147. * documentation, and that the name of OMRON not be used in advertising or
  148. * publicity pertaining to distribution of the software without specific,
  149. * written prior permission. OMRON makes no representations about the
  150. * suitability of this software for any purpose. It is provided "as is"
  151. * without express or implied warranty.
  152. *
  153. * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  154. * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  155. * OMRON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  156. * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  157. * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
  158. * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  159. * SOFTWARE.
  160. *
  161. * Author: Seiji Kuwari OMRON Corporation
  162. * kuwa@omron.co.jp
  163. * kuwa%omron.co.jp@uunet.uu.net
  164. */
  165. /*
  166. Copyright (c) 1994 X Consortium
  167. Permission is hereby granted, free of charge, to any person obtaining a copy
  168. of this software and associated documentation files (the "Software"), to deal
  169. in the Software without restriction, including without limitation the rights
  170. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  171. copies of the Software, and to permit persons to whom the Software is
  172. furnished to do so, subject to the following conditions:
  173. The above copyright notice and this permission notice shall be included in
  174. all copies or substantial portions of the Software.
  175. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  176. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  177. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  178. X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  179. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  180. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  181. Except as contained in this notice, the name of the X Consortium shall not be
  182. used in advertising or otherwise to promote the sale, use or other dealings
  183. in this Software without prior written authorization from the X Consortium.
  184. */
  185. #ifndef _XawImP_h
  186. #define _XawImP_h
  187. #define XtNinputMethod "inputMethod"
  188. #define XtCInputMethod "InputMethod"
  189. #define XtNpreeditType "preeditType"
  190. #define XtCPreeditType "PreeditType"
  191. #define XtNopenIm "openIm"
  192. #define XtCOpenIm "OpenIm"
  193. #define XtNsharedIc "sharedIc"
  194. #define XtCSharedIc "SharedIc"
  195. #include <X11/Xaw/Text.h>
  196. #define CIICFocus (1 << 0)
  197. #define CIFontSet (1 << 1)
  198. #define CIFg (1 << 2)
  199. #define CIBg (1 << 3)
  200. #define CIBgPixmap (1 << 4)
  201. #define CICursorP (1 << 5)
  202. #define CILineS (1 << 6)
  203. typedef struct _XawImPart
  204. {
  205. XIM xim;
  206. XrmResourceList resources;
  207. Cardinal num_resources;
  208. Boolean open_im;
  209. Boolean initialized;
  210. Dimension area_height;
  211. String input_method;
  212. String preedit_type;
  213. } XawImPart;
  214. typedef struct _XawIcTablePart
  215. {
  216. Widget widget;
  217. XIC xic;
  218. XIMStyle input_style;
  219. unsigned long flg;
  220. unsigned long prev_flg;
  221. Boolean ic_focused;
  222. XFontSet font_set;
  223. Pixel foreground;
  224. Pixel background;
  225. Pixmap bg_pixmap;
  226. XawTextPosition cursor_position;
  227. unsigned long line_spacing;
  228. Boolean openic_error;
  229. struct _XawIcTablePart *next;
  230. } XawIcTablePart, *XawIcTableList;
  231. typedef struct _XawIcPart
  232. {
  233. XIMStyle input_style;
  234. Boolean shared_ic;
  235. XawIcTableList shared_ic_table;
  236. XawIcTableList current_ic_table;
  237. XawIcTableList ic_table;
  238. } XawIcPart;
  239. typedef struct _contextDataRec
  240. {
  241. Widget parent;
  242. Widget ve;
  243. } contextDataRec;
  244. typedef struct _contextErrDataRec
  245. {
  246. Widget widget;
  247. XIM xim;
  248. } contextErrDataRec;
  249. void _XawImResizeVendorShell(
  250. #if NeedFunctionPrototypes
  251. Widget /* w */
  252. #endif
  253. );
  254. Dimension _XawImGetShellHeight(
  255. #if NeedFunctionPrototypes
  256. Widget /* w */
  257. #endif
  258. );
  259. void _XawImRealize(
  260. #if NeedFunctionPrototypes
  261. Widget /* w */
  262. #endif
  263. );
  264. void _XawImInitialize(
  265. #if NeedFunctionPrototypes
  266. Widget, /* w */
  267. Widget /* ext */
  268. #endif
  269. );
  270. void _XawImReconnect(
  271. #if NeedFunctionPrototypes
  272. Widget /* w */
  273. #endif
  274. );
  275. void _XawImRegister(
  276. #if NeedFunctionPrototypes
  277. Widget /* w */
  278. #endif
  279. );
  280. void _XawImUnregister(
  281. #if NeedFunctionPrototypes
  282. Widget /* w */
  283. #endif
  284. );
  285. void _XawImSetValues(
  286. #if NeedFunctionPrototypes
  287. Widget, /* w */
  288. ArgList, /* args */
  289. Cardinal /* num_args */
  290. #endif
  291. );
  292. /* DON'T USE THIS FUNCTION -- it's going away in the next release */
  293. void _XawImVASetValues(
  294. #if NeedVarargsPrototypes
  295. Widget, /* w */
  296. ...
  297. #endif
  298. );
  299. void _XawImSetFocusValues(
  300. #if NeedFunctionPrototypes
  301. Widget, /* w */
  302. ArgList, /* args */
  303. Cardinal /* num_args */
  304. #endif
  305. );
  306. /* DON'T USE THIS FUNCTION -- it's going away in the next release */
  307. void _XawImVASetFocusValues(
  308. #if NeedVarargsPrototypes
  309. Widget, /* w */
  310. ...
  311. #endif
  312. );
  313. void _XawImUnsetFocus(
  314. #if NeedFunctionPrototypes
  315. Widget /* w */
  316. #endif
  317. );
  318. int _XawImWcLookupString(
  319. #if NeedFunctionPrototypes
  320. Widget, /* w */
  321. XKeyPressedEvent*, /* event */
  322. wchar_t*, /* buffer_return */
  323. int, /* bytes_buffer */
  324. KeySym*, /* keysym_return */
  325. Status* /* status return */
  326. #endif
  327. );
  328. int _XawImGetImAreaHeight(
  329. #if NeedFunctionPrototypes
  330. Widget /* w */
  331. #endif
  332. );
  333. void _XawImCallVendorShellExtResize(
  334. #if NeedFunctionPrototypes
  335. Widget /* w */
  336. #endif
  337. );
  338. void _XawImDestroy(
  339. #if NeedFunctionPrototypes
  340. Widget, /* w */
  341. Widget /* ext */
  342. #endif
  343. );
  344. #endif /* _XawImP_h */
  345. typedef struct {
  346. XtPointer extension;
  347. } XawVendorShellExtClassPart;
  348. typedef struct _VendorShellExtClassRec {
  349. ObjectClassPart object_class;
  350. XawVendorShellExtClassPart vendor_shell_ext_class;
  351. } XawVendorShellExtClassRec;
  352. typedef struct {
  353. Widget parent;
  354. XawImPart im;
  355. XawIcPart ic;
  356. } XawVendorShellExtPart;
  357. typedef struct XawVendorShellExtRec {
  358. ObjectPart object;
  359. XawVendorShellExtPart vendor_ext;
  360. } XawVendorShellExtRec, *XawVendorShellExtWidget;
  361. #endif /* _VendorEP_h */
  362. static XtResource resources[] = {
  363. {XtNinput, XtCInput, XtRBool, sizeof(Bool),
  364. XtOffsetOf(VendorShellRec, wm.wm_hints.input),
  365. XtRImmediate, (XtPointer)True}
  366. };
  367. /***************************************************************************
  368. *
  369. * Vendor shell class record
  370. *
  371. ***************************************************************************/
  372. static void XawVendorShellClassInitialize();
  373. static void XawVendorShellClassPartInit();
  374. static void XawVendorShellInitialize();
  375. static Boolean XawVendorShellSetValues();
  376. static void Realize(), ChangeManaged();
  377. static XtGeometryResult GeometryManager();
  378. void XawVendorShellExtResize();
  379. static CompositeClassExtensionRec vendorCompositeExt = {
  380. /* next_extension */ NULL,
  381. /* record_type */ NULLQUARK,
  382. /* version */ XtCompositeExtensionVersion,
  383. /* record_size */ sizeof (CompositeClassExtensionRec),
  384. /* accepts_objects */ TRUE,
  385. /* allows_change_managed_set */ FALSE
  386. };
  387. #define SuperClass (&wmShellClassRec)
  388. externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = {
  389. {
  390. /* superclass */ (WidgetClass)SuperClass,
  391. /* class_name */ "VendorShell",
  392. /* size */ sizeof(VendorShellRec),
  393. /* class_initialize */ XawVendorShellClassInitialize,
  394. /* class_part_init */ XawVendorShellClassPartInit,
  395. /* Class init'ed ? */ FALSE,
  396. /* initialize */ XawVendorShellInitialize,
  397. /* initialize_hook */ NULL,
  398. /* realize */ Realize,
  399. /* actions */ NULL,
  400. /* num_actions */ 0,
  401. /* resources */ resources,
  402. /* resource_count */ XtNumber(resources),
  403. /* xrm_class */ NULLQUARK,
  404. /* compress_motion */ FALSE,
  405. /* compress_exposure */ TRUE,
  406. /* compress_enterleave*/ FALSE,
  407. /* visible_interest */ FALSE,
  408. /* destroy */ NULL,
  409. /* resize */ XawVendorShellExtResize,
  410. /* expose */ NULL,
  411. /* set_values */ XawVendorShellSetValues,
  412. /* set_values_hook */ NULL,
  413. /* set_values_almost */ XtInheritSetValuesAlmost,
  414. /* get_values_hook */ NULL,
  415. /* accept_focus */ NULL,
  416. /* intrinsics version */ XtVersion,
  417. /* callback offsets */ NULL,
  418. /* tm_table */ NULL,
  419. /* query_geometry */ NULL,
  420. /* display_accelerator*/ NULL,
  421. /* extension */ NULL
  422. },{
  423. /* geometry_manager */ GeometryManager,
  424. /* change_managed */ ChangeManaged,
  425. /* insert_child */ XtInheritInsertChild,
  426. /* delete_child */ XtInheritDeleteChild,
  427. /* extension */ (XtPointer) &vendorCompositeExt
  428. },{
  429. /* extension */ NULL
  430. },{
  431. /* extension */ NULL
  432. },{
  433. /* extension */ NULL
  434. }
  435. };
  436. externaldef(vendorshellwidgetclass) WidgetClass vendorShellWidgetClass =
  437. (WidgetClass) (&vendorShellClassRec);
  438. /***************************************************************************
  439. *
  440. * The following section is for the Vendor shell Extension class record
  441. *
  442. ***************************************************************************/
  443. static XtResource ext_resources[] = {
  444. {XtNinputMethod, XtCInputMethod, XtRString, sizeof(String),
  445. XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.input_method),
  446. XtRString, (XtPointer)NULL},
  447. {XtNpreeditType, XtCPreeditType, XtRString, sizeof(String),
  448. XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.preedit_type),
  449. XtRString, (XtPointer)"OverTheSpot,OffTheSpot,Root"},
  450. {XtNopenIm, XtCOpenIm, XtRBoolean, sizeof(Boolean),
  451. XtOffsetOf(XawVendorShellExtRec, vendor_ext.im.open_im),
  452. XtRImmediate, (XtPointer)TRUE},
  453. {XtNsharedIc, XtCSharedIc, XtRBoolean, sizeof(Boolean),
  454. XtOffsetOf(XawVendorShellExtRec, vendor_ext.ic.shared_ic),
  455. XtRImmediate, (XtPointer)FALSE}
  456. };
  457. static void XawVendorShellExtClassInitialize();
  458. static void XawVendorShellExtInitialize();
  459. static void XawVendorShellExtDestroy();
  460. static Boolean XawVendorShellExtSetValues();
  461. externaldef(vendorshellextclassrec) XawVendorShellExtClassRec
  462. xawvendorShellExtClassRec = {
  463. {
  464. /* superclass */ (WidgetClass)&objectClassRec,
  465. /* class_name */ "VendorShellExt",
  466. /* size */ sizeof(XawVendorShellExtRec),
  467. /* class_initialize */ XawVendorShellExtClassInitialize,
  468. /* class_part_initialize*/ NULL,
  469. /* Class init'ed ? */ FALSE,
  470. /* initialize */ XawVendorShellExtInitialize,
  471. /* initialize_hook */ NULL,
  472. /* pad */ NULL,
  473. /* pad */ NULL,
  474. /* pad */ 0,
  475. /* resources */ ext_resources,
  476. /* resource_count */ XtNumber(ext_resources),
  477. /* xrm_class */ NULLQUARK,
  478. /* pad */ FALSE,
  479. /* pad */ FALSE,
  480. /* pad */ FALSE,
  481. /* pad */ FALSE,
  482. /* destroy */ XawVendorShellExtDestroy,
  483. /* pad */ NULL,
  484. /* pad */ NULL,
  485. /* set_values */ XawVendorShellExtSetValues,
  486. /* set_values_hook */ NULL,
  487. /* pad */ NULL,
  488. /* get_values_hook */ NULL,
  489. /* pad */ NULL,
  490. /* version */ XtVersion,
  491. /* callback_offsets */ NULL,
  492. /* pad */ NULL,
  493. /* pad */ NULL,
  494. /* pad */ NULL,
  495. /* extension */ NULL
  496. },{
  497. /* extension */ NULL
  498. }
  499. };
  500. externaldef(xawvendorshellwidgetclass) WidgetClass
  501. xawvendorShellExtWidgetClass = (WidgetClass) (&xawvendorShellExtClassRec);
  502. /*ARGSUSED*/
  503. static Boolean
  504. XawCvtCompoundTextToString(dpy, args, num_args, fromVal, toVal, cvt_data)
  505. Display *dpy;
  506. XrmValuePtr args;
  507. Cardinal *num_args;
  508. XrmValue *fromVal;
  509. XrmValue *toVal;
  510. XtPointer *cvt_data;
  511. {
  512. XTextProperty prop;
  513. char **list;
  514. int count;
  515. static char *mbs = NULL;
  516. int len;
  517. prop.value = (unsigned char *)fromVal->addr;
  518. prop.encoding = XA_COMPOUND_TEXT(dpy);
  519. prop.format = 8;
  520. prop.nitems = fromVal->size;
  521. if(XmbTextPropertyToTextList(dpy, &prop, &list, &count) < Success) {
  522. XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
  523. "converter", "XmbTextPropertyToTextList", "XawError",
  524. "conversion from CT to MB failed.", NULL, 0);
  525. return False;
  526. }
  527. len = strlen(*list);
  528. toVal->size = len;
  529. mbs = XtRealloc(mbs, len + 1); /* keep buffer because no one call free :( */
  530. strcpy(mbs, *list);
  531. XFreeStringList(list);
  532. toVal->addr = (XtPointer)mbs;
  533. return True;
  534. }
  535. static void XawVendorShellClassInitialize()
  536. {
  537. static XtConvertArgRec screenConvertArg[] = {
  538. {XtWidgetBaseOffset, (XtPointer) XtOffsetOf(WidgetRec, core.screen),
  539. sizeof(Screen *)}
  540. };
  541. XtAddConverter(XtRString, XtRCursor, XmuCvtStringToCursor,
  542. screenConvertArg, XtNumber(screenConvertArg));
  543. XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
  544. screenConvertArg, XtNumber(screenConvertArg));
  545. XtSetTypeConverter("CompoundText", XtRString, XawCvtCompoundTextToString,
  546. NULL, 0, XtCacheNone, NULL);
  547. }
  548. static void XawVendorShellClassPartInit(class)
  549. WidgetClass class;
  550. {
  551. CompositeClassExtension ext;
  552. VendorShellWidgetClass vsclass = (VendorShellWidgetClass) class;
  553. if ((ext = (CompositeClassExtension)
  554. XtGetClassExtension (class,
  555. XtOffsetOf(CompositeClassRec,
  556. composite_class.extension),
  557. NULLQUARK, 1L, (Cardinal) 0)) == NULL) {
  558. ext = (CompositeClassExtension) XtNew (CompositeClassExtensionRec);
  559. if (ext != NULL) {
  560. ext->next_extension = vsclass->composite_class.extension;
  561. ext->record_type = NULLQUARK;
  562. ext->version = XtCompositeExtensionVersion;
  563. ext->record_size = sizeof (CompositeClassExtensionRec);
  564. ext->accepts_objects = TRUE;
  565. ext->allows_change_managed_set = FALSE;
  566. vsclass->composite_class.extension = (XtPointer) ext;
  567. }
  568. }
  569. }
  570. #ifdef __osf__
  571. /* stupid OSF/1 shared libraries have the wrong semantics */
  572. /* symbols do not get resolved external to the shared library */
  573. void _XawFixupVendorShell()
  574. {
  575. transientShellWidgetClass->core_class.superclass =
  576. (WidgetClass) &vendorShellClassRec;
  577. topLevelShellWidgetClass->core_class.superclass =
  578. (WidgetClass) &vendorShellClassRec;
  579. }
  580. #endif
  581. /* ARGSUSED */
  582. static void XawVendorShellInitialize(req, new, args, num_args)
  583. Widget req, new;
  584. ArgList args;
  585. Cardinal *num_args;
  586. {
  587. XtAddEventHandler(new, (EventMask) 0, TRUE, _XEditResCheckMessages, NULL);
  588. #ifdef HAVE_XMUREGISTEREXTERNALAGENT
  589. XtAddEventHandler(new, (EventMask) 0, TRUE, XmuRegisterExternalAgent, NULL);
  590. #endif /* HAVE_XMUREGISTEREXTERNALAGENT */
  591. XtCreateWidget("shellext", xawvendorShellExtWidgetClass,
  592. new, args, *num_args);
  593. }
  594. /* ARGSUSED */
  595. static Boolean XawVendorShellSetValues(old, ref, new)
  596. Widget old, ref, new;
  597. {
  598. return FALSE;
  599. }
  600. static void Realize(wid, vmask, attr)
  601. Widget wid;
  602. Mask *vmask;
  603. XSetWindowAttributes *attr;
  604. {
  605. WidgetClass super = wmShellWidgetClass;
  606. /* Make my superclass do all the dirty work */
  607. (*super->core_class.realize) (wid, vmask, attr);
  608. _XawImRealize(wid);
  609. }
  610. static void XawVendorShellExtClassInitialize()
  611. {
  612. }
  613. /* ARGSUSED */
  614. static void XawVendorShellExtInitialize(req, new)
  615. Widget req, new;
  616. {
  617. _XawImInitialize(new->core.parent, new);
  618. }
  619. /* ARGSUSED */
  620. static void XawVendorShellExtDestroy( w )
  621. Widget w;
  622. {
  623. _XawImDestroy( w->core.parent, w );
  624. }
  625. /* ARGSUSED */
  626. static Boolean XawVendorShellExtSetValues(old, ref, new)
  627. Widget old, ref, new;
  628. {
  629. return FALSE;
  630. }
  631. void XawVendorShellExtResize( w )
  632. Widget w;
  633. {
  634. ShellWidget sw = (ShellWidget) w;
  635. Widget childwid;
  636. int i;
  637. int core_height;
  638. _XawImResizeVendorShell( w );
  639. core_height = _XawImGetShellHeight( w );
  640. for( i = 0; i < sw->composite.num_children; i++ ) {
  641. if( XtIsManaged( sw->composite.children[ i ] ) ) {
  642. childwid = sw->composite.children[ i ];
  643. XtResizeWidget( childwid, sw->core.width, core_height,
  644. childwid->core.border_width );
  645. }
  646. }
  647. }
  648. /*ARGSUSED*/
  649. static XtGeometryResult GeometryManager( wid, request, reply )
  650. Widget wid;
  651. XtWidgetGeometry *request;
  652. XtWidgetGeometry *reply;
  653. {
  654. ShellWidget shell = (ShellWidget)(wid->core.parent);
  655. XtWidgetGeometry my_request;
  656. if(shell->shell.allow_shell_resize == FALSE && XtIsRealized(wid))
  657. return(XtGeometryNo);
  658. if (request->request_mode & (CWX | CWY))
  659. return(XtGeometryNo);
  660. /* %%% worry about XtCWQueryOnly */
  661. my_request.request_mode = 0;
  662. if (request->request_mode & CWWidth) {
  663. my_request.width = request->width;
  664. my_request.request_mode |= CWWidth;
  665. }
  666. if (request->request_mode & CWHeight) {
  667. my_request.height = request->height
  668. + _XawImGetImAreaHeight( wid );
  669. my_request.request_mode |= CWHeight;
  670. }
  671. if (request->request_mode & CWBorderWidth) {
  672. my_request.border_width = request->border_width;
  673. my_request.request_mode |= CWBorderWidth;
  674. }
  675. if (XtMakeGeometryRequest((Widget)shell, &my_request, NULL)
  676. == XtGeometryYes) {
  677. /* assert: if (request->request_mode & CWWidth) then
  678. * shell->core.width == request->width
  679. * assert: if (request->request_mode & CWHeight) then
  680. * shell->core.height == request->height
  681. *
  682. * so, whatever the WM sized us to (if the Shell requested
  683. * only one of the two) is now the correct child size
  684. */
  685. wid->core.width = shell->core.width;
  686. wid->core.height = shell->core.height;
  687. if (request->request_mode & CWBorderWidth) {
  688. wid->core.x = wid->core.y = -request->border_width;
  689. }
  690. _XawImCallVendorShellExtResize(wid);
  691. return XtGeometryYes;
  692. } else return XtGeometryNo;
  693. }
  694. static void ChangeManaged(wid)
  695. Widget wid;
  696. {
  697. ShellWidget w = (ShellWidget) wid;
  698. Widget* childP;
  699. int i;
  700. (*SuperClass->composite_class.change_managed)(wid);
  701. for (i = w->composite.num_children, childP = w->composite.children;
  702. i; i--, childP++) {
  703. if (XtIsManaged(*childP)) {
  704. XtSetKeyboardFocus(wid, *childP);
  705. break;
  706. }
  707. }
  708. }