1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
|
/*
* Motif Tools Library, Version 3.1
* $Id$
*
* Written by David Flanagan.
* Copyright (c) 1992-2001 by David Flanagan.
* All Rights Reserved. See the file COPYRIGHT for details.
* This is open source software. See the file LICENSE for details.
* There is no warranty for this software. See NO_WARRANTY for details.
*
* $Log$
* Revision 1.1.1.1 2001/07/18 11:06:02 root
* Initial checkin.
*
* Revision 1.2 2001/06/12 16:25:28 andre
* *** empty log message ***
*
*
*/
#include <Xmt/Xmt.h>
#include <Xmt/Create.h>
#include <Xmt/WidgetType.h>
#include <Xmt/Include.h>
#include <Xmt/Template.h>
#include <Xmt/DialogP.h>
#include <Xmt/Lexer.h>
#include <Xmt/ConvertersP.h>
#include <Xmt/AppResP.h>
#include <Xm/DialogS.h>
#include <X11/IntrinsicP.h>
#include <X11/CompositeP.h>
#include <unistd.h>
#if NeedFunctionPrototypes
static void ConvertCallbackList(Widget w, StringConst s,
XtCallbackList *list_return,
XtCacheRef *ref_return)
#else
static void ConvertCallbackList(w, s, list_return, ref_return)
Widget w;
StringConst s;
XtCallbackList *list_return;
XtCacheRef *ref_return;
#endif
{
XrmValue from, to;
if (_XmtCallbackConverter == NULL) {
XmtWarningMsg("CreateWidget", "noConverter",
"no String to XtCallbackList converter registered.\n\tCall XmtRegisterCallbackConverter().");
return;
}
from.addr = (XPointer) s;
from.size = strlen(s)+1;
to.addr = (XPointer) list_return;
to.size = sizeof(XtCallbackList);
XtCallConverter(XtDisplayOfObject(w), _XmtCallbackConverter, NULL, 0,
&from, &to, ref_return);
}
#if NeedFunctionPrototypes
static void FreeCallbackList(Widget w, XtCacheRef ref)
#else
static void FreeCallbackList(w, ref)
Widget w;
XtCacheRef ref;
#endif
{
XtCacheRef refs[2];
if (ref == NULL) return;
refs[0] = ref;
refs[1] = NULL;
XtAppReleaseCacheRefs(XtWidgetToApplicationContext(w), refs);
}
#if NeedFunctionPrototypes
static void CallCallbackList(Widget w, XtCallbackList list)
#else
static void CallCallbackList(w, list)
Widget w;
XtCallbackList list;
#endif
{
for(; list->callback; list++)
(*list->callback)(w, list->closure, NULL);
}
typedef struct {
XrmQuark nameq;
Widget *widgetp;
} WidgetName;
/* forward declaration */
#if NeedFunctionPrototypes
static void CreateChildren(Widget, XmtDialogInfo *, WidgetName *, Cardinal);
static Widget _XmtCreateChild(Widget, StringConst, XmtDialogInfo *,
WidgetName *, Cardinal);
#else
static void CreateChildren();
static Widget _XmtCreateChild();
#endif
typedef struct {
String create;
String children;
String managed;
} CallbackStringsType;
static XtResource callback_resources[] = {
{XmtNxmtCreationCallback, XmtCXmtCreationCallback, XtRString,
sizeof(String), XtOffsetOf(CallbackStringsType, create),
XtRString, (XtPointer) NULL},
{XmtNxmtChildrenCreationCallback, XmtCXmtChildrenCreationCallback, XtRString,
sizeof(String), XtOffsetOf(CallbackStringsType, children),
XtRString, (XtPointer) NULL},
{XmtNxmtManagedCreationCallback, XmtCXmtManagedCreationCallback, XtRString,
sizeof(String), XtOffsetOf(CallbackStringsType, managed),
XtRString, (XtPointer) NULL},
};
static XtResource requires_resource[] = {
{XmtNxmtRequires, XmtCXmtRequires, XtRString,
sizeof(String), 0, XtRString, NULL}
};
#if NeedFunctionPrototypes
static Widget CreateChild(Widget parent, StringConst name, XmtWidgetType *type,
String template, Boolean managed,
String *styles, Cardinal num_styles, Boolean load,
XmtDialogInfo *dialog_info,
WidgetName *names, Cardinal num_names)
#else
static Widget CreateChild(parent, name, type, template, managed,
styles, num_styles, load, dialog_info,
names, num_names)
Widget parent;
StringConst name;
XmtWidgetType *type;
String template;
Boolean managed;
String *styles;
Cardinal num_styles;
Boolean load;
XmtDialogInfo *dialog_info;
WidgetName *names;
Cardinal num_names;
#endif
{
Widget w = NULL;
String requires_string;
CallbackStringsType callback_strings;
XrmQuark nameq;
XtCallbackList create_callback_list = NULL;
XtCallbackList children_callback_list = NULL;
XtCallbackList managed_callback_list = NULL;
XtCacheRef create_callback_ref;
XtCacheRef children_callback_ref;
XtCacheRef managed_callback_ref;
int i;
/* first, load any required files, unless already loaded */
if (load) {
XtGetSubresources(parent, (XtPointer)&requires_string,
(String)name, (String)name,
requires_resource, (Cardinal)1,
NULL, (Cardinal) 0);
if (requires_string) XmtLoadResourceFileList(parent, requires_string);
}
/* apply any styles that were specified */
if (num_styles)
for(i=0; i < num_styles; i++)
XmtTemplateInstantiate(parent, name, styles[i], NULL, 0);
/* now create the widget */
if (type)
w = XmtCreateWidgetType(name, type, parent, NULL, 0);
else if (template) {
/*
* if the widget is a template type, instantiate the template,
* and then start the creation process over to read the xmtType
* resource. Note that we recurse and then return immediately.
* If we don't return the callbacks will be called twice and
* the children created twice.
*/
XmtTemplateInstantiate(parent, name, template, NULL, 0);
w = _XmtCreateChild(parent, name, dialog_info, names, num_names);
return w;
}
/*
* if we don't have a widget now, something went wrong.
* Assume that someone else printed a warning message, and return.
*/
if (w == NULL) return NULL;
/*
* see if the widget matches any in the names list, and if so,
* store the widget pointer at the given address
*/
nameq = XrmStringToQuark(name);
for(i=0; i < num_names; i++) {
if (nameq == names[i].nameq) {
*names[i].widgetp = w;
break;
}
}
/*
* A widget has just been created. Next we:
* (0) fetch and convert the creation callback resources
* (1) invoke the xmtCreationCallback list
* (2) call CreateChildren to create the widget's children (reg. or popup)
* (2a) invoke the xmtChildrenCreationCallback list
* (3) manage it, unless a shell or unmanaged
* (3a) invoke the xmtManagedCreationCallback list
* (4) free any creation callbacks.
*/
/* (0) fetch and convert the creation callback resources */
XtGetApplicationResources(w, (XtPointer)&callback_strings,
callback_resources, XtNumber(callback_resources),
NULL, (Cardinal)0);
if (callback_strings.create)
ConvertCallbackList(w, callback_strings.create,
&create_callback_list, &create_callback_ref);
if (callback_strings.children)
ConvertCallbackList(w, callback_strings.children,
&children_callback_list, &children_callback_ref);
if (callback_strings.managed)
ConvertCallbackList(w, callback_strings.managed,
&managed_callback_list, &managed_callback_ref);
/* (1) invoke the xmtCreationCallback list */
if (create_callback_list) CallCallbackList(w, create_callback_list);
/* (2) call CreateChildren, to create regular or popup children */
CreateChildren(w, dialog_info, names, num_names);
/* (2a) invoke the xmtChildrenCreationCallback list */
if (children_callback_list) CallCallbackList(w,children_callback_list);
/* (3) manage it, unless a shell or unmanaged */
if (managed && !XtIsShell(w)) {
XtManageChild(w);
/* (3a) invoke the xmtManagedCreationCallback list */
if (managed_callback_list) CallCallbackList(w, managed_callback_list);
}
/* (4) free any creation callbacks. */
if (create_callback_list) FreeCallbackList(w, create_callback_ref);
if (children_callback_list) FreeCallbackList(w, children_callback_ref);
if (managed_callback_list) FreeCallbackList(w, managed_callback_ref);
return w;
}
static String keywords[] = {
"managed",
"unmanaged",
};
#define MANAGED 0
#define UNMANAGED 1
#define MAX_TEMPLATE_ARGS 10
#if NeedFunctionPrototypes
static Boolean ParseType(Widget w, StringConst name, XmtLexer l,
XmtWidgetType **type, String *template,
Boolean *managed,
String **styles, Cardinal *num_styles)
#else
static Boolean ParseType(w, name, l, type, template, managed,
styles, num_styles)
Widget w;
StringConst name;
XmtLexer l;
XmtWidgetType **type;
String *template;
Boolean *managed;
String **styles;
Cardinal *num_styles;
#endif
{
XmtLexerToken tok;
int max_styles = 0;
String style;
String args[MAX_TEMPLATE_ARGS];
Cardinal num_args;
Cardinal expected_args;
String template_name;
int i;
/* set defaults and parse any modifiers or styles */
*managed = True;
*num_styles = 0;
*styles = NULL;
while (1) {
tok = XmtLexerGetToken(l);
if (tok == XmtLexerKeyword) {
switch(XmtLexerKeyValue(l)) {
case MANAGED:
*managed = True;
break;
case UNMANAGED:
*managed = False;
break;
}
XmtLexerConsumeToken(l);
}
else if ((tok == XmtLexerIdent) &&
((style = XmtLookupStyle(w, XmtLexerStrValue(l))) != NULL)) {
if (*num_styles == max_styles) {
max_styles += 4;
*styles = (String *)XtRealloc((char *)*styles,
max_styles * sizeof(String));
}
template_name = XmtLexerStrValue(l);
XmtLexerConsumeToken(l);
XmtLexerGetArgList(l, args, MAX_TEMPLATE_ARGS, &num_args);
style = XmtTemplateSubstituteArgs(style, args, num_args,
&expected_args);
(*styles)[*num_styles] = style;
*num_styles += 1;
if (num_args > expected_args)
XmtWarningMsg("XmtParseWidgetType", "styleArgs",
"widget '%s':\n\tstyle '%s' expects up to %d args; %d passed.",
name, template_name, expected_args, num_args);
for(i=0; i < num_args; i++) XtFree(args[i]);
XtFree(template_name);
}
else
break;
}
/* now we expect a widget type or template */
*type = NULL;
*template = NULL;
if (XmtLexerGetToken(l) != XmtLexerIdent) {
XmtWarningMsg("XmtParseWidgetType", "syntax",
"syntax error in xmtChildren or xmtType resource\n\tof widget '%s'.",
name);
return False;
}
*type = XmtLookupWidgetType(XmtLexerStrValue(l));
if (!*type) {
*template = XmtLookupTemplate(w, XmtLexerStrValue(l));
if (*template) {
template_name = XmtLexerStrValue(l);
XmtLexerConsumeToken(l);
XmtLexerGetArgList(l, args, MAX_TEMPLATE_ARGS, &num_args);
*template = XmtTemplateSubstituteArgs(*template, args, num_args,
&expected_args);
if (num_args > expected_args)
XmtWarningMsg("XmtParseWidgetType", "templateArgs",
"widget '%s':\n\ttemplate '%s' expects up to %d args; %d passed.",
name, template_name, expected_args, num_args);
for(i=0; i < num_args; i++) XtFree(args[i]);
XtFree(template_name);
}
}
if (!*type && !*template)
XmtWarningMsg("XmtParseWidgetType", "type",
"unknown widget type %s\n\tin xmtChildren or xmtType resource of widget %s.",
XmtLexerStrValue(l), name);
if (!*template) {
XtFree(XmtLexerStrValue(l));
XmtLexerConsumeToken(l);
}
if (*type || *template) return True;
else {
if (*num_styles) {
for(i=0; i < *num_styles; i++) XtFree(*styles[i]);
XtFree((char *)*styles);
*styles = NULL;
*num_styles = 0;
}
return False;
}
}
#if NeedFunctionPrototypes
static void SetDialogInfo(XmtDialogInfo *info, String resource,
Widget w, XmtWidgetType *type)
#else
static void SetDialogInfo(info, resource, w, type)
XmtDialogInfo *info;
String resource;
Widget w;
XmtWidgetType *type;
#endif
{
int i;
XrmQuark resourceq = XrmStringToQuark(resource);
if ((type->get_value_proc == NULL) && (type->set_value_proc == NULL)) {
XmtWarningMsg("XmtCreateChildren", "notype",
"Can't associate resource '%s' with child '%s';\n\twidget class '%s' has no get value nor set value procedure.",
resource, XtName(w), type->name);
return;
}
for(i = 0; i < info->num_resources; i++)
if (info->resources[i].resource_name == (String)resourceq) break;
if (i < info->num_resources) {
info->widgets[i] = w;
info->types[i] = type;
}
else
XmtWarningMsg("XmtCreateChildren", "noname",
"Child '%s': resource name '%s' not found.",
XtName(w), resource);
}
#if NeedFunctionPrototypes
static void CreateWidgetList(Widget parent, XmtLexer l,
XmtDialogInfo *dialog_info,
WidgetName *names, Cardinal num_names)
#else
static void CreateWidgetList(parent, l, dialog_info, names, num_names)
Widget parent;
XmtLexer l;
XmtDialogInfo *dialog_info;
WidgetName *names;
Cardinal num_names;
#endif
{
Boolean managed;
XmtWidgetType *type;
String template;
String *styles;
Cardinal num_styles;
XmtLexerToken tok;
Widget child;
int i;
if (ParseType(parent, XtName(parent), l, &type, &template,
&managed, &styles, &num_styles) == False)
goto error;
/* now read a list of names, and create them */
/* grammar: id [= name] (',' id[= name])* ';' */
while (1) {
if (XmtLexerGetToken(l) != XmtLexerIdent) goto syntax;
child = CreateChild(parent, XmtLexerStrValue(l), type, template,
managed, styles, num_styles, True, dialog_info,
names, num_names);
XtFree(XmtLexerStrValue(l));
tok = XmtLexerNextToken(l);
if (tok == XmtLexerEqual) {
tok = XmtLexerNextToken(l);
if (tok != XmtLexerIdent) goto syntax;
if (!type) {
XmtWarningMsg("XmtCreateChildren", "resource",
"child '%s' cannot have a resource name '%s':\n\tchild's type is a template, not a registered widget type.",
XtName(child), XmtLexerStrValue(l));
}
else if (dialog_info)
SetDialogInfo(dialog_info, XmtLexerStrValue(l), child, type);
else
XmtWarningMsg("XmtCreateChildren", "resource",
"child '%s' cannot have a resource name '%s':\n\tthere is no resource list associated with this widget tree.",
XtName(child), XmtLexerStrValue(l));
XtFree(XmtLexerStrValue(l));
tok = XmtLexerNextToken(l);
}
if (tok == XmtLexerSemicolon) break;
else if (tok != XmtLexerComma) goto syntax;
XmtLexerConsumeToken(l);
}
XmtLexerConsumeToken(l); /* skip the semicolon */
if (template) XtFree(template);
if (num_styles) {
for(i=0; i < num_styles; i++) XtFree(styles[i]);
XtFree((char *)styles);
}
/* eat the final semicolon, and we're done */
XmtLexerConsumeToken(l);
return;
syntax:
XmtWarningMsg("XmtCreateChildren", "syntax",
"syntax error in xmtChildren resource\n\t of widget %s",
XtName(parent));
error: /* read till semicolon */
while(((tok = XmtLexerNextToken(l)) != XmtLexerSemicolon) &&
(tok != XmtLexerEndOfString));
XmtLexerConsumeToken(l);
}
static XtResource children_resource[] = {
{XmtNxmtChildren, XmtCXmtChildren, XtRString,
sizeof(String), 0, XtRString, NULL}
};
#if NeedFunctionPrototypes
static void CreateChildren(Widget parent, XmtDialogInfo *dialog_info,
WidgetName *names, Cardinal num_names)
#else
static void CreateChildren(parent, dialog_info, names, num_names)
Widget parent;
XmtDialogInfo *dialog_info;
WidgetName *names;
Cardinal num_names;
#endif
{
String children_string;
XmtLexer lexer;
/* fetch the value of the xmtChildren resource */
XtGetApplicationResources(parent, (XtPointer)&children_string,
children_resource, (Cardinal) 1,
NULL, (Cardinal)0);
/* XXX should we issue a warning here? */
if (children_string == NULL) return;
/*
* get ready to parse the string.
* we copy the string because the process of parsing it can cause
* new resource files to be loaded, which could cause it to be freed
* from underneath us.
*/
children_string = XtNewString(children_string);
lexer = XmtLexerCreate(keywords, XtNumber(keywords));
XmtLexerInit(lexer, children_string);
while(XmtLexerGetToken(lexer) != XmtLexerEndOfString)
CreateWidgetList(parent, lexer, dialog_info, names, num_names);
XmtLexerDestroy(lexer);
XtFree(children_string);
}
#if NeedFunctionPrototypes
static void _XmtCreateChildren(Widget parent,
WidgetName *names, Cardinal num_names)
#else
static void _XmtCreateChildren(parent, names, num_names)
Widget parent;
WidgetName *names;
Cardinal num_names;
#endif
{
XmtDialogInfo *dialog_info;
String requires_string;
/* see if there is a resource list associated with this parent */
dialog_info = _XmtDialogLookupDialogInfo(parent);
/* first, load any required files */
XtGetApplicationResources(parent, (XtPointer)&requires_string,
requires_resource, (Cardinal)1,
NULL, (Cardinal) 0);
if (requires_string) XmtLoadResourceFileList(parent, requires_string);
/* do the rest */
CreateChildren(parent, dialog_info, names, num_names);
}
#if NeedFunctionPrototypes
void XmtCreateChildren(Widget parent)
#else
void XmtCreateChildren(parent)
Widget parent;
#endif
{
_XmtCreateChildren(parent, NULL, 0);
}
#if NeedFunctionPrototypes
static void GetWidgetNames(va_list var,
WidgetName **names_return, Cardinal *num_return)
#else
static void GetWidgetNames(var, names_return, num_return)
va_list var;
WidgetName **names_return;
Cardinal *num_return;
#endif
{
WidgetName *names;
String name;
Cardinal num, max;
num = max = 0;
names = NULL;
while((name = va_arg(var, String)) != NULL) {
if (num == max) {
max += 10;
names = (WidgetName *)XtRealloc((char *)names,
max * sizeof(WidgetName));
}
names[num].nameq = XrmStringToQuark(name);
names[num].widgetp = va_arg(var, Widget *);
/* initialize *widgetp to NULL in case it is not found */
*names[num].widgetp = NULL;
num++;
}
*names_return = names;
*num_return = num;
}
#if NeedVarargsPrototypes
void XmtCreateQueryChildren(Widget parent, ...)
#else
void XmtCreateQueryChildren(parent, va_alist)
Widget parent;
va_dcl
#endif
{
va_list var;
WidgetName *names;
Cardinal num_names;
Va_start(var, parent);
GetWidgetNames(var, &names, &num_names);
va_end(var);
_XmtCreateChildren(parent, names, num_names);
XtFree((char *)names);
}
static XtResource type_resource[] = {
{XmtNxmtType, XmtCXmtType, XtRString,
sizeof(String), 0, XtRString, NULL}
};
#if NeedFunctionPrototypes
static Widget _XmtCreateChild(Widget parent, StringConst name,
XmtDialogInfo *dialog_info,
WidgetName *names, Cardinal num_names)
#else
static Widget _XmtCreateChild(parent, name, dialog_info, names, num_names)
Widget parent;
StringConst name;
XmtDialogInfo *dialog_info;
WidgetName *names;
Cardinal num_names;
#endif
{
String requires_string, type_string;
XmtLexer lexer;
XmtWidgetType *type;
String template;
Boolean managed;
String *styles;
Cardinal num_styles;
Widget w;
int i;
/* first, load any required files XXX ?*/
XtGetSubresources(parent, (XtPointer)&requires_string,
(String)name, (String)name,
requires_resource, (Cardinal)1,
NULL, (Cardinal) 0);
if (requires_string) XmtLoadResourceFileList(parent, requires_string);
/* fetch the value of the xmtType resource */
XtGetSubresources(parent, (XtPointer)&type_string,
(String)name, (String)name,
type_resource, (Cardinal) 1,
NULL, (Cardinal)0);
if (type_string == NULL) {
XmtWarningMsg("XmtCreateChild", "noType",
"widget '%s' has no xmtType resource.",
name);
return NULL;
}
/* get ready to parse the string */
lexer = XmtLexerCreate(keywords, XtNumber(keywords));
XmtLexerInit(lexer, type_string);
/*
* if we parse it sucessfully, create the child.
* Note that CreateChild won't re-load the required files.
*/
if (ParseType(parent, name, lexer, &type, &template,
&managed, &styles, &num_styles)) {
w = CreateChild(parent, name, type, template,
managed, styles, num_styles, False,
dialog_info, names, num_names);
if (template) XtFree(template);
if (num_styles) {
for(i=0; i < num_styles; i++) XtFree(styles[i]);
XtFree((char *)styles);
}
}
else
w = NULL;
XmtLexerDestroy(lexer);
return w;
}
#if NeedFunctionPrototypes
Widget XmtCreateChild(Widget parent, StringConst name)
#else
Widget XmtCreateChild(parent, name)
Widget parent;
StringConst name;
#endif
{
return _XmtCreateChild(parent, name, NULL, NULL, 0);
}
#if NeedVarargsPrototypes
Widget XmtCreateQueryChild(Widget parent, StringConst name, ...)
#else
Widget XmtCreateQueryChild(parent, name, va_alist)
Widget parent;
StringConst name;
va_dcl
#endif
{
va_list var;
WidgetName *names;
Cardinal num_names;
Widget child;
Va_start(var, name);
GetWidgetNames(var, &names, &num_names);
va_end(var);
child = _XmtCreateChild(parent, name, NULL, names, num_names);
XtFree((char *)names);
return child;
}
#if NeedFunctionPrototypes
static Widget _XmtBuildDialog(Widget parent, StringConst dialog_name,
XtResourceList resources, Cardinal num_resources,
WidgetName *names, Cardinal num_names)
#else
static Widget _XmtBuildDialog(parent, dialog_name, resources, num_resources,
names, num_names)
Widget parent;
StringConst dialog_name;
XtResourceList resources;
Cardinal num_resources;
WidgetName *names;
Cardinal num_names;
#endif
{
Widget shell;
Arg arg;
/* create the dialog shell */
/* XXX do I need/want allowShellResize? What happens without? */
XtSetArg(arg, XmNallowShellResize, True);
shell = XmCreateDialogShell(parent, (String)dialog_name, &arg, 1);
/* associate the resources with the shell */
XmtDialogBindResourceList(shell, resources, num_resources);
/* create the dialog child and its children */
_XmtCreateChildren(shell, names, num_names);
/* return the dialog child, if any, or warn and return NULL */
if (((CompositeWidget)shell)->composite.num_children)
return ((CompositeWidget)shell)->composite.children[0];
else
XmtWarningMsg("XmtBuildDialog", "nochild",
"No xmtChildren resource for shell widget '%s'",
dialog_name);
return NULL;
}
#if NeedFunctionPrototypes
Widget XmtBuildDialog(Widget parent, StringConst dialog_name,
XtResourceList resources, Cardinal num_resources)
#else
Widget XmtBuildDialog(parent, dialog_name, resources, num_resources)
Widget parent;
StringConst dialog_name;
XtResourceList resources;
Cardinal num_resources;
#endif
{
return _XmtBuildDialog(parent, dialog_name,
resources, num_resources,
NULL, 0);
}
#if NeedVarargsPrototypes
Widget XmtBuildQueryDialog(Widget parent, StringConst dialog_name,
XtResourceList resources, Cardinal num_resources,
...)
#else
Widget XmtBuildQueryDialog(parent, dialog_name,
resources, num_resources, va_alist)
Widget parent;
StringConst dialog_name;
XtResourceList resources;
Cardinal num_resources;
va_dcl
#endif
{
va_list var;
WidgetName *names;
Cardinal num_names;
Widget dialog;
Va_start(var, num_resources);
GetWidgetNames(var, &names, &num_names);
va_end(var);
dialog = _XmtBuildDialog(parent, dialog_name,
resources, num_resources,
names, num_names);
XtFree((char *)names);
return dialog;
}
#if NeedVarargsPrototypes
Widget XmtBuildQueryToplevel(Widget parent, StringConst name, ...)
#else
Widget XmtBuildQueryToplevel(parent, name, va_alist)
Widget parent;
StringConst name;
va_dcl
#endif
{
va_list var;
WidgetName *names;
Cardinal num_names;
Widget shell;
shell = XtCreatePopupShell((String)name, topLevelShellWidgetClass,
parent, NULL, 0);
Va_start(var, name);
GetWidgetNames(var, &names, &num_names);
va_end(var);
_XmtCreateChildren(shell, names, num_names);
XtFree((char *)names);
if (!((CompositeWidget)shell)->composite.num_children)
XmtWarningMsg("XmtBuildToplevel", "nochild",
"No xmtChildren resource for shell widget '%s'",
name);
return shell;
}
#if NeedFunctionPrototypes
Widget XmtBuildToplevel(Widget parent, StringConst name)
#else
Widget XmtBuildToplevel(parent, name)
Widget parent;
StringConst name;
#endif
{
return XmtBuildQueryToplevel(parent, name, NULL);
}
#if NeedVarargsPrototypes
Widget XmtBuildQueryApplication(StringConst appname, StringConst appclass,
Display *display,
ArgList args, Cardinal num_args, ...)
#else
Widget XmtBuildQueryApplication(appname, appclass, display, args, num_args,
va_alist)
StringConst appname, appclass;
Display *display;
ArgList args;
Cardinal num_args;
va_dcl
#endif
{
va_list var;
WidgetName *names;
Cardinal num_names;
Widget rootshell;
rootshell = XtAppCreateShell((String)appname, (String)appclass,
applicationShellWidgetClass,
display, args, num_args);
Va_start(var, num_args);
GetWidgetNames(var, &names, &num_names);
va_end(var);
_XmtCreateChildren(rootshell, names, num_names);
XtFree((char *)names);
if (!((CompositeWidget)rootshell)->composite.num_children)
XmtWarningMsg("XmtBuildApplication", "nochild",
"No xmtChildren resource for root shell widget '%s'",
appname);
XmtInitializeApplicationShell(rootshell, args, num_args);
return rootshell;
}
#if NeedFunctionPrototypes
Widget XmtBuildApplication(StringConst appname, StringConst appclass,
Display *display,
ArgList args, Cardinal num_args)
#else
Widget XmtBuildApplication(appname, appclass, display, args, num_args)
StringConst appname, appclass;
Display *display;
ArgList args;
Cardinal num_args;
#endif
{
return XmtBuildQueryApplication(appname, appclass, display,
args, num_args, NULL);
}
|