home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / next / programm / 5199 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  4.4 KB

  1. Path: sparky!uunet!olivea!decwrl!sgi!wdl1!wdl1!mdm
  2. From: mdm@wdl1.wdl.loral.com (Mike D Marchionna)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Can't redraw in conentView after resizing window?
  5. Message-ID: <1992Jul23.180124.108@wdl.loral.com>
  6. Date: 23 Jul 92 18:01:24 GMT
  7. Sender: news@wdl.loral.com
  8. Distribution: usa
  9. Organization: Loral Western Development Labs
  10. Lines: 117
  11.  
  12. Help!  I'm stupid.
  13.  
  14. I have an Application that has a custom View inside a window leaving
  15. a 2 pixel boarder around custom view.  It looks sort of like this:
  16.  
  17. +------------------+
  18. |                  |
  19. | +--------------+ |<--Window
  20. | |              | |
  21. | |              | |
  22. | | Custom View  | |
  23. | |              | |
  24. | |              | |
  25. | +--------------+ |
  26. |  Content View    |
  27. +------------------+
  28.  
  29. I have implemented delegate methods -windowDidBecomeMain: and
  30. -windowDidResignMain to draw a 2 pixel wide rectangle in the windows content
  31. view to produce a highlighted border around the Custom View.  A black border
  32. is drawn when the window bocomes main and light gray border is drawn when
  33. the window resigns main.
  34.  
  35. The problem is when the I resize the window.  I have implemented the
  36. the -windowDidResize method redraw the border in the content view, but
  37. it does not seem to work.  I use the same code I used to draw the
  38. border in the -windowDidBecomeMain: method.  Try as I might I can't get this
  39. to work.  The custom View is set to auto size with the window, and I use the
  40. content Views bounds rectangle difine the rectangle to draw.  When I dump
  41. the values for the content View bounds rectangle they seem consistent with
  42. the windows new size.
  43.  
  44. So why isn't my border getting redrawn?  What the heck am I missing?
  45. Any help is appreciated.  The pertinant code is listed below.
  46.  
  47. --MDM
  48.  
  49. /******************************************************************************
  50. * INSTANCE METHOD:- windowDidBecomeMain:                                      *
  51. ******************************************************************************/
  52. - windowDidBecomeMain:sender
  53.  
  54. {   /* Local Variables */
  55.     NXRect  bounds;
  56.  
  57. /* BEGIN - windowDidBecomeMain: */
  58.  
  59. /* Draw a 2 pixel wide border rectangle around the VdtView in the **
  60. ** Vdt Window's content view.                                     */
  61. [contentView getBounds:&bounds];
  62. [contentView lockFocus];
  63. PSsetgray(NX_BLACK);
  64. PSsetlinewidth(2.0);
  65. PSrectstroke(bounds.origin.x+1.0, bounds.origin.y+1.0,
  66.              bounds.size.width-2.0, bounds.size.height-2.0);
  67. [contentView unlockFocus];
  68.  
  69. /* Since the window has become key, make sure the VDT is up to date */
  70. [IVvdtView updateVdtView:self];
  71.  
  72. return(self);
  73. }/* END - windowDidBecomeMain: */
  74.  
  75. /******************************************************************************
  76. * INSTANCE METHOD:- windowDidResignMain:                                      *
  77. ******************************************************************************/
  78. - windowDidResignMain:sender
  79.  
  80. {   /* Local Variables */
  81.     NXRect  bounds;
  82.  
  83. /* BEGIN - windowDidResignMain: */
  84.  
  85. /* Clear the 2 pixel wide border rectangle around the VdtView in **
  86. ** the Vdt Window's content view.                                */
  87. [contentView getBounds:&bounds];
  88. [contentView lockFocus];
  89. PSsetgray(NX_LTGRAY);
  90. PSsetlinewidth(2.0);
  91. PSrectstroke(bounds.origin.x+1.0, bounds.origin.y+1.0,
  92.              bounds.size.width-2.0, bounds.size.height-2.0);
  93. [contentView unlockFocus];
  94.  
  95. return(self);
  96. }/* END - windowDidResignMain: */
  97.  
  98.  
  99.  
  100. /******************************************************************************
  101. * INSTANCE METHOD:- windowDidResize:                                          *
  102. ******************************************************************************/
  103. - windowDidResize:sender
  104.  
  105. {   /* Local Variables */
  106.     NXRect  bounds;
  107.  
  108. /* BEGIN - windowDidResize: */
  109.  
  110. /* Redraw a 2 pixel wide border rectangle around the VdtView in the **
  111. ** Vdt Window's content view.                                       */
  112. [contentView getBounds:&bounds];
  113. [contentView lockFocus];
  114. PSsetgray(NX_BLACK);
  115. PSsetlinewidth(2.0);
  116. PSrectstroke(bounds.origin.x+1.0, bounds.origin.y+1.0,
  117.              bounds.size.width-2.0, bounds.size.height-2.0);
  118. [contentView unlockFocus];
  119. [contentView display];
  120.  
  121. return(self);
  122. }/* END - windowDidResize: */
  123.  
  124. -- 
  125.  _________________________________________________________________________ 
  126. (  _______________________________   Brain, and brain!  What is brain!    ) 
  127.  \________________________________)        --Star Trek (Spock's Brain)   /
  128. El_Rayo_X_______________________________________________________________/ 
  129.