[comp.sys.sun] Help with OpenWindows

chuck@trantor.harris-atd.com (Chuck Musciano) (02/28/90)

I am just beginning to use OpenWindows, and have discovered that the
documentation is missing one important part: the OpenWindows Programmers
Guide.  While the API Reference Manual and Porting Guide are fine in their
own right, you cannot get any real work done without a programmer's guide.
In particular, the API reference has absolutely no example code in it to
help you out.

Am I missing something fundamental?  Did I not get a complete manual set?
Where do I turn for example code and a more tutorial approach?  I am a
wizened SunView veteran, and I want to learn XView as a complete system,
not just how to convert tools.

My flails are prompted by some problems in opening a font.  The font
attributes include FONT_FAMILY, and FONT_STYLE.  The API reference says
that these attributes accept character strings for their values.  (What a
help, huh?)  Perusing the include files (which I should NEVER have to do)
tells me that things like FONT_FAMILY_LUCIDA and FONT_STYLE_BOLDITALIC are
acceptable values for these attributes (I think).  However, using these
attributes results in the default font, I think.  Here is my code:

    #include	<stdio.h>
    #include	<xview/xview.h>
    #include	<xview/panel.h>
    #include	<xview/font.h>

    main(argc, argv)

    int	argc;
    char	**argv;

    {	Frame	frame;
	    Panel	panel;
	    Xv_font	font;

	    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
	    font = xv_create(NULL, FONT,
				FONT_FAMILY, FONT_FAMILY_LUCIDA,
				FONT_SIZE, 14,
				FONT_STYLE, FONT_STYLE_BOLD_ITALIC,
			     0);
	    frame = xv_create(NULL, FRAME, XV_LABEL, "A simple window", 0);
	    panel = xv_create(frame, PANEL,
				 XV_WIDTH, 400,
				 XV_HEIGHT, 200,
			      0);
	    xv_create(panel, PANEL_BUTTON,
			 PANEL_LABEL_STRING, "A Button",
			 PANEL_LABEL_FONT, font,
		      0);
	    window_fit(frame);
	    window_main_loop(frame);
    }

My button is always displayed in the default font.  What gives?  How do I
know what values are appropriate for these attributes?  Where is some real
documentation on this?

Chuck Musciano				ARPA  : chuck@trantor.harris-atd.com
Harris Corporation 			Usenet: ...!uunet!x102a!trantor!chuck
PO Box 37, MS 3A/1912			AT&T  : (407) 727-6131
Melbourne, FL 32902			FAX   : (407) 727-{5118,5227,4004}

I'm glad you asked, son.  Being popular
	is the most important thing in the world.	-- Homer Simpson

isa@eng.sun.com (Isa Hashim) (03/03/90)

The usage of font attributes in xv_create() is correct in the posted
example.  However, the usage of PANEL_LABEL_FONT on the PANEL_BUTTON has
some problems:

PANEL_LABEL_FONT is a 'compatability' attribute i.e. it exists for SunView
compatability reasons, but is not really supported. The attribute that
should be used is XV_FONT.

Also, you can set the font for a PANEL which will make all the Panel items
use it, but you cannot set fonts for individual Panel items.  This is
because according to OPEN LOOK, all Panel items must have the same font.
Panel items simply ignore font attributes.

The solution is to use the attribute XV_FONT on the PANEL and not on the
PANEL_BUTTON. The entire corrected program is included below.

As far as documentation is concerned, one source is:

	"XView Programming Manual"

	O'Reilly & Associates, Inc.
	632 Petaluma Avenue
	Sebastopol, CA  95472
	(800)338-6887  [from within the USA]
	(707)829-0515
	FAX: (707)829-0104
	EMAIL: uunet!ora!xview

Additional documentation in PostScript source format exists online with the
XView source:

	"XView 1.0.1 Reference Manual: Converting SunView Applications"
	"Converting Your SunView Application's Pixwin/Pixrect Graphics
	to XView and Xlib Graphics"

A pre-printed version of the XView 1.0.1 reference manual can be ordered
(at the cost of media and shipping) from Sun Microsystems by ordering Part
Number 800-2482-10. (Call the Sun sales office or telemarketing
1-800-USA-4SUN)

Hope this helps.
Please let me know of other problems you might have concerning this.

Isa Hashim
XView toolkit group
isa@sun.com

    #include	<stdio.h>
    #include	<xview/xview.h>
    #include	<xview/panel.h>
    #include	<xview/font.h>

    main(argc, argv)

    int	argc;
    char	**argv;

    {	Frame	frame;
	    Panel	panel;
	    Xv_font	font;

	    xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
	    font = xv_create(NULL, FONT,
				FONT_FAMILY, FONT_FAMILY_LUCIDA,
				FONT_SIZE, 14,
				FONT_STYLE, FONT_STYLE_BOLD_ITALIC,
			     0);
	    frame = xv_create(NULL, FRAME, XV_LABEL, "A simple window", 0);
	    panel = xv_create(frame, PANEL,
			         XV_FONT, font,
				 XV_WIDTH, 400,
				 XV_HEIGHT, 200,
			      0);
	    xv_create(panel, PANEL_BUTTON,
			 PANEL_LABEL_STRING, "A Button",
		      0);
	    window_fit(frame);
	    window_main_loop(frame);
    }