[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

908.0. "FIREFOX color changing in Ada" by EMASS::HEBERT () Thu Jun 08 1989 17:59

Hi,

I am using ADA 1.5, VMS 5.1-1, PHIGS 2.0 and DECWindows 1.0.  I have been
able to figure out how to alter the color of dialog boxes on a VAXstation 
3200.  The sequence of calls that works on the 3200 is as follows:

  DWT.XT_DISPLAY(DISPLAY, TOPLEVEL_WIDGET);
  X.DEFAULT_SCREEN(SCREEN, DISPLAY);
  X.DEFAULT_COLORMAP(COLORMAP, DISPLAY, SCREEN);
  X.ALLOC_COLOR_CELLS(STATUS, DISPLAY, COLORMAP, 0, PLANE_MASK, 0, 
                      PIXELS, 2);
  next_color := 1
  g_returned_color(next_color).colr_pixel := PIXELS (NEXT_COLOR);
  g_returned_color(next_color).colr_red := 65280;
  g_returned_color(next_color).colr_green := 65280;
  g_returned_color(next_color).colr_blue := 0;
  g_returned_color(next_color).colr_flags := SYSTEM."OR" (X.M_DO_RED,
          SYSTEM."OR" (X.M_DO_GREEN, X.M_DO_BLUE));

  X.STORE_COLOR (DISPLAY, COLORMAP, RETURNED_COLOR (next_color));
  DWT.XT_WINDOW(ALERT_WINDOW, WIDGET_ARRAY(ALERT_AREA));
  X.SET_WINDOW_BACKGROUND (DISPLAY, ALERT_WINDOW, RETURNED_COLOR 
          (NEXT_COLOR).COLR_PIXEL;
  DWT.XT_UNMANAGE_CHILD(WIDGET_ARRAY(ALERT_AREA));
  DWT.XT_MANAGE_CHILD(WIDGET_ARRAY(ALERT_AREA));

The problem is that the changing of colors on the dialog box no longer
works now that I have done a straight port over to a FIREFOX. 
When I change the background color of a dialog box it changes to black 
(not yellow like on the 3200) and I get an error which reads as follows :
    
     Attempt to access private resource
       failed request major opcode 89 XStoreColors
       failed request minor opcode 0 (if applicable)
       resource ID 0x0in failed request
       serial number of failed request 2185
       current serial number in output stream 2193
     Error event received from server
    
If any one has a clue to how I can resolve this FIREFOX specific problem
please let me know ASAP.

Thanks,

Mike    

T.RTitleUserPersonal
Name
DateLines
908.1PSW::WINALSKICareful with that VAX, EugeneThu Jun 08 1989 19:0713
How many planes does your Firefox have?

Furthermore, the correct way to change a resource on a toolkit widget is to
use XtSetValues to change the pixel value of the background resource on the
widget, not XSetWindowBackground on the widget's window.  But it looks like
your real problem is storing the color map entry.  If you've got a 24-plane,
true color system, then the default visual probably doesn't allow XStoreColor
to be done, nor does it make sense on a true color system.  You don't seem to
be checking the status from XAllocColorCells.  You should make sure that you
successfully allocated the cells before you try to store into them.

--PSW

908.2Yah, but...EMASS::HEBERTFri Jun 09 1989 10:1315
    Yup, I do have a 24 plane FIREFOX.  If there is an easier way to
    change the color of a dialog box at execution time I am willing
    to change my ways.  However, it took me a week to figure out how
    to get it to happen at all on the 3200.  The issue of changing colors
    on any system is quite confusing and the DECWindows documentation
    unfortunately does not shed enough light on this subject.  I will
    definitely check my status values.  I have tried SET ARG along with
    anything else I could think of.  I will research this further and
    will post any new results.  In the mean time, a good example of
    how to do this on a FIREFOX would be extremely beneficial.
    
    Thanks for the quick response
    
    Mike

908.3PSW::WINALSKICareful with that VAX, EugeneFri Jun 09 1989 18:2413
I think that the default visual on a 24-plane Firefox is a TrueColor visual,
in which case all of the "colormap entries" are read-only.  Try building the
XColor structure as you do now and then calling XAllocColor passing that
structure.  You will get back the pixel value for the color closest to the one
you requested.  You should then be able to do a XtSetValues on the
DwtNbackground resource for the widget using that pixel value to have the
background color take effect.  You can't use XAllocColorCells and XStoreColor
because a TrueColor colormap is read-only (in fact, the hardware doesn't have
a color map per se, but uses the pixel value to encode the RGB values
directly.

--PSW

908.4Found the solutionEMASS::HEBERTMon Jun 12 1989 10:4416
Great your suggestion worked.  I did have a problem with STORE_COLORS and
SET_WINDOW_BACKGROUND.  However, I also discovered the basic problem that I
had with using VMS_SET_ARG and XT_SET_VALUES.  There are two Ada bindings for
routine VMS_SET_ARG in the DECW$ package.  In one binding, the first argument
is an address and in the second binding, the first argument is an integer.
Since Ada is strongly typed and since a COLR_PIXEL is an UNSIGNED integer,
neither binding was correct.  In several other instances, using the address
binding was appropriate so that is what I used.  This DOES NOT WORK FOR
CHANGING COLOR ATTRIBUTES.  In stead I converted the the UNSIGNED COLR_PIXEL
type to an integer, used the second Ada binding and it worked.  Now what I read
in the manual seems to make much more sense.

Thanks for your quick suggestions.

Mike

908.5Comment on Ada bindingsQUARK::LIONELB - L - Oh, I don't know!Mon Jun 12 1989 11:109
Re: .4

We couldn't provide an additional signature with type UNSIGNED_LONGWORD
because then it would be ambiguous if you just specified a constant.
So using the builtin conversion function to INTEGER is what you need to
do.

				Steve

908.6.4 ClarifiedEMASS::HEBERTMon Jun 12 1989 16:088
Re: .5

No question, I just didn't use the right stuff.  Sorry if it sounded like 
a hit on Ada.  It was my misuse of the Ada binding.

Mike

908.7QUARK::LIONELB - L - Oh, I don't know!Mon Jun 12 1989 16:275
No "hit" was assumed.  I just wanted to explain why it was the way it was,
for the potential benefit of other Ada programmers.

		Steve