[comp.windows.x.motif] making our own widget class under XmPrimitive -- but no 3D??

tjhorton@vis.toronto.edu ("Timothy J. Horton") (02/26/91)

Has anyone successfully created a widget from the XmPrimitive class?  We have,
everything compiles, but no combination of resource settings will make the 3D
shadow effects be drawn (even if I draw NOTHING in the window).

It would appear that we don't know how to set the primitive class part members
to inherit the right behavior?  But alas, without source for other motif
widgets, I cannot guess how to initialize them ...

Please help a poor soul.  Thanks!
tjhorton@vis.toronto.edu
...utai!tjhorton

klee@wsl.dec.com (Ken Lee) (02/27/91)

In article <91Feb25.235707est.8813@orasis.vis.toronto.edu>, tjhorton@vis.toronto.edu ("Timothy J. Horton") writes:
|> Has anyone successfully created a widget from the XmPrimitive class?  We have,
|> everything compiles, but no combination of resource settings will make the 3D
|> shadow effects be drawn (even if I draw NOTHING in the window).

You didn't post any sample code, so I'm just guessing.  How are you
attempting to draw the 3D shadow?  Remember that XmPrimitive has no
drawing procedure, so you must draw everything that is displayed in
your widget's window.  XmPrimitive does, however, provide GC resources
that make the 3D shadow easy.

-- 
Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@wsl.dec.com
uucp: uunet!decwrl!klee

dcr0@gte.com (David Robbins) (02/28/91)

From article <1991Feb26.092658@wsl.dec.com>, by klee@wsl.dec.com (Ken Lee):
> In article <91Feb25.235707est.8813@orasis.vis.toronto.edu>, tjhorton@vis.toronto.edu ("Timothy J. Horton") writes:
> |> Has anyone successfully created a widget from the XmPrimitive class?  We have,
> |> everything compiles, but no combination of resource settings will make the 3D
> |> shadow effects be drawn (even if I draw NOTHING in the window).
> 
> You didn't post any sample code, so I'm just guessing.  How are you
> attempting to draw the 3D shadow?  Remember that XmPrimitive has no
> drawing procedure, so you must draw everything that is displayed in
> your widget's window.  XmPrimitive does, however, provide GC resources
> that make the 3D shadow easy.

I've addressed a similar problem with Motif 1.0.3.  I learned that you
need to do the drawing of the shadows yourself, in your Expose procedure.
Fortunately, you don't really need to know all about *how* do draw shadows.
There exists an undocumented (at least in 1.0.3) function that knows how
to draw shadows, and you just call it from your Expose procedure:

   _XmDrawShadow(XtDisplay(widget), XtWindow(widget),
      widget->primitive.bottom_shadow_GC,
      widget->primitive.top_shadow_GC,
      widget->primitive.shadow_thickness,
      x, y, width, height);

(where x, y, width, height describe the outside bounds of the area to be
shadowed -- perhaps x=0, y=0, width and height from widget->core).
-- 
Dave Robbins                    GTE Laboratories Incorporated
drobbins@bunny.gte.com          40 Sylvan Rd.
...!harvard!bunny!drobbins      Waltham, MA 02254
CYA:  I speak only for myself; GTE may disagree with what I say.

marbru@attc.UUCP (Martin Brunecky) (03/03/91)

In article <91Feb25.235707est.8813@orasis.vis.toronto.edu> tjhorton@vis.toronto.edu ("Timothy J. Horton") writes:
>Has anyone successfully created a widget from the XmPrimitive class?  We have,
>everything compiles, but no combination of resource settings will make the 3D
>shadow effects be drawn (even if I draw NOTHING in the window).
>
    XmPrimitive only provides resources, but no Exposure method.
    Your widget's exposure has to draw the 3D outline.

    Note, when subclassing off-of something like XmPrimitive, you better
    look at the code several times, before you decide:
    - what this superclass does FOR you
    - what this superclass does AGAINST you
    - what you can inherit
    - what you MUST override

    You MUST look at the superclass methods which are always called:
    Initialize and SetValues - normally you shoulkd like what they do,
    but sometimes they don't do enough (this may be an omission/bug),
    sometimes they do more than what you want, and you may be forced
    to un-do that. You must be cerafull about GC's created/destroyed
    /changed by your superclass. May be not in other widget sets,
    but definitelly in Motif.

    Good hacking 
    
-- 
=*= Opinions presented here are solely of my own and not those of Auto-trol =*=
Martin Brunecky                           {...}sunpeaks!auto-trol!marbru
(303) 252-2499                        (sometimes also:  marbru@auto-trol.COM )
Auto-trol Technology Corp. 12500 North Washington St., Denver, CO 80241-2404