home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / windows / x / 19268 < prev    next >
Encoding:
Internet Message Format  |  1992-11-17  |  2.5 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!ogicse!network.ucsd.edu!ucsbcsl!ucsbuxa!6500msd
  2. From: 6500msd@ucsbuxa.ucsb.edu (Michael D'Errico)
  3. Newsgroups: comp.windows.x
  4. Subject: Re: Finding out the number of 'free' cells in the color map
  5. Keywords: color map, color cells
  6. Message-ID: <6747@ucsbcsl.ucsb.edu>
  7. Date: 18 Nov 92 01:08:25 GMT
  8. Article-I.D.: ucsbcsl.6747
  9. References: <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au> <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu>
  10. Sender: root@ucsbcsl.ucsb.edu
  11. Lines: 48
  12.  
  13. In article <1992Nov15.193125.19911@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
  14.  
  15. |In article <1992Nov13.072332.27682@mailhost.ocs.mq.edu.au>, s8923098@macnab.mqcs.mq.oz.au (Josef WIDJAJA) writes:
  16.  
  17. |> I want to use XAllocColor many times to allocate color cells that can
  18. |> be shared by other applications.  But I want to know in advance how
  19. |> many of these will be available.  How can I do this ?
  20.  
  21. |You can't.  For one thing, it depends on exactly what colors you're
  22. |allocating, because you may match colors that are already allocated and
  23. |hence get an already-allocated cell instead of a new one.  Even if you
  24. |rephrase it to ask "how many cells are unallocated", there is no simple
  25. |way to answer it; you have to try it and see.  (Unless you want to
  26. |design and implement an extension, of course.)
  27.  
  28. |> [code example]
  29.  
  30. |> I want to know how many color cells are going to be available so that
  31. |> I can adjust the value of maxno, and prepare data[i]'s accordingly.
  32. |> More specifically, I want to make sure that result is always
  33. |> succesful(true).
  34.  
  35. |Can't be done.  Even if you did contrive somehow to find out how many
  36. |cells are free, other clients could allocate cells while you're
  37. |working.  You'd have to grab the server to prevent this....
  38.  
  39. I agree that there is no way (at least not yet) to query the number of unused
  40. color cells in a colormap.  You could probably get around this with the
  41. following approach:  use a loop that adjusts maxno until you successfully
  42. allocate the colormap.  The following pseudo-code shows what I would try:
  43.  
  44.         maxno = desired_maxno;
  45.         done = False;
  46.  
  47.         while (!done && maxno>=min_allowable_maxno)  {
  48.           if (try_to_allocate_maxno_colors)
  49.             done = True;
  50.           else  {
  51.             free_any_allocated_colors;
  52.             maxno--;
  53.             }
  54.  
  55.         if (!done)
  56.           error;
  57.  
  58.  
  59. Michael D'Errico
  60. 6500msd@ucsbuxa.ucsb.edu
  61.