home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / os2 / programm / 4458 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  4.3 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!rutgers!njitgw.njit.edu!hertz.njit.edu!dic5340
  2. From: dic5340@hertz.njit.edu (David Charlap)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re: X/Motif to PM Questions
  5. Keywords: motif xwindows pm
  6. Message-ID: <1992Aug26.203341.18411@njitgw.njit.edu>
  7. Date: 26 Aug 92 20:33:41 GMT
  8. References: <101@slpfs1.UUCP>
  9. Sender: news@njit.edu
  10. Organization: New Jersey Institute of Technology, Newark, N.J.
  11. Lines: 81
  12. Nntp-Posting-Host: hertz.njit.edu
  13.  
  14. In article <101@slpfs1.UUCP> jct@slpfs1.UUCP (Jeff Tolmie) writes:
  15. >    WndClientProc(..., msg, parm1, parm2) {
  16. >    switch(msg) {
  17. >    case WIN_PAINT:
  18. >    case 
  19. >    etc etc etc
  20. >    }
  21.  
  22. The first parameter for a clientProc() is hwnd - the window handle for
  23. the window that's receiving the message.  Normally, you register a
  24. window class with the system and all windows created with that class
  25. use the same client procedure.  Windows with a different class may use
  26. a different procedure.
  27.  
  28. >Now, all that PM has to create (in the code) are the windows/dialogs. And
  29. >there is a PM function to do this. WinCreateStdWindow(...). Here you tell
  30. >the PM if this window has a menu bar, an icon, all the decorations you are
  31. >used to getting automatically from Motif Window Manager like Maximize, 
  32. >Minimize etc, and of course where to find the right resource (.rc) file. Note
  33. >that the creating includes registering the window class. (Can't exactly
  34. >remember the function name.) 
  35.  
  36. WinRegisterClass()
  37.  
  38. >X-Windows  
  39. >    XDrawRectangle(..., x,y, w,h) 
  40. >
  41. >OS/2 PM
  42. >    pt.x=x; pt.t=y; GpiMove(pt); pt.x=x+w, pt.y=y+h; GpiRectangle(...,pt, ...)
  43. >
  44. >Oh!, and watch out! PM uses bottom-left as origin, not top-left.
  45.  
  46. PM's coordinates can be reversed for individual windows.  It's a flag
  47. (a frame creation (FCF_) flag, I believe) passed to WinRegisterClass
  48. (or maybe to WinCreateStdWindow).  Personally, I like the bottom-left
  49. coordinates, it matches the first-quadrant coordinates you find in
  50. mathematics. 
  51.  
  52. >This is a SHOUT for help. Because as far as I can tell, color handling
  53. >in OS/2 PM is terrible. If you just want standard 4 bit colors like
  54. >RED, DARK_RED etc, then it's quite straightforward. If you want to mess
  55. >around with palettes, then it gets very unclear. If someone who understands
  56. >PM color and knows how to, for example, display all 256 colors from the
  57. >hardware colormap (I am using orchid 800x600x256) then please let me know.
  58.  
  59. You can use any RGB color fairly easilly - you request an RGB and it
  60. gives you a palette offset.  If you're on a 24-bit color device, you
  61. get the color.  Otherwise, PM gives you the nearest match based on the
  62. current palette.  Dithered colors (for fills) may be done with a
  63. different API call.
  64.  
  65. If you need the exact colors, you're going to have to mess with the
  66. palette manager.  This is a pain under OS/2 and Windows.  I don't know
  67. why it has to be, though.  Doesn't X assume a 24-bit palette?  That
  68. makes things infinitely easier, since there are no palettes to muck
  69. with. 
  70.  
  71. If you don't want a specific RGB color, but want an offset into the
  72. current palette, I think that can be done fairly easilly as well.  As
  73. far as I can remember, there is a default palette where the first 16
  74. colors correspond to the 16 DOS colors.  The constants CLR_BLACK,
  75. CRL_BLUE, etc., are defined as the numbers 0-15.  I think you can just
  76. use values 16-255 for the rest of the palette, if you don't want a
  77. specific color.
  78.  
  79. I haven't done much with this, but based on what I've read in the
  80. Toolkit documentation, it seems pretty straightforward to me.  To edit
  81. the palette, you request a handle to a palette, make the changes to
  82. it, and register it with the system.  OS/2 then adjusts its palette as
  83. it thinks it should to get you the colors.  Where there's a conflict,
  84. I'm not sure what it does (I haven't played with this, yet).  Windows
  85. resolves conflicts by giving the foreground process the palette and
  86. makes everyone else take the closest matches - this results in windows
  87. getting mangled and repainted whenever two palette-using windows swap
  88. focus.  I haven's seen this behavior under OS/2, so it's doing
  89. something else.
  90. -- 
  91.    |)  David Charlap           "I don't even represent myself
  92.   /|_  dic5340@hertz.njit.edu   sometimes so NJIT is right out!.
  93.  ((|,)
  94.   ~|~  Hi! I am a .signature virus, copy me into your .signature file.
  95.