Subversion Repositories filter_foundry

Rev

Rev 193 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.         This file is part of a common library
  3.     Copyright (C) 1990-2009 Toby Thain, toby@telegraphics.com.au
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. */
  19.  
  20. #include <osutils.h>
  21. #include <packages.h>
  22. #include <plstringfuncs.h>
  23. #include <windows.h>
  24.  
  25. #include "misc.h"
  26.  
  27. WDEF(main){
  28. #define w theWindow
  29.         enum{INDENT=3,TITLEBAR=10};
  30.         Rect fr,wr,*rp,ga;
  31.        
  32.         rp = &w->port.portBits.bounds;
  33.         wr = w->port.portRect;
  34.         OffsetRect(&wr,-rp->left,-rp->top);
  35.         fr = wr;
  36.         fr.top -= TITLEBAR;
  37.         InsetRect(&fr,-1,-1);
  38.  
  39.         ga.right = (ga.left = wr.left + 7) + (TITLEBAR - 3);
  40.         ga.bottom = (ga.top = wr.top - TITLEBAR + 1) + (TITLEBAR - 3);
  41.  
  42.         switch(message){
  43.         case wDraw:
  44.                 if(w->visible){
  45.                         if(param)
  46.                                 InvertRect(&ga);
  47.                         else{
  48.                                 FrameRect(&fr);
  49.                                 MoveTo(fr.right,fr.top+INDENT);
  50.                                 LineTo(fr.right,fr.bottom);
  51.                                 LineTo(fr.left+INDENT,fr.bottom);
  52.                                 fr.bottom = fr.top + TITLEBAR + 1;
  53.                                 FrameRect(&fr);
  54.                                 InsetRect(&fr,1,1);
  55.                                 EraseRect(&fr);
  56.                                 if(w->hilited){
  57.                                         Pattern p = {0,85,0,85,0,85,0,85};
  58.                                         Point o = TOPLEFT(QD(thePort)->portRect);
  59.                                         RgnHandle c1,c2;
  60.  
  61.                                         GetClip(c1 = NewRgn());
  62.                                         SetOrigin(rp->left,rp->top);
  63.                                         CopyRgn(c1,c2 = NewRgn());
  64.                                         OffsetRgn(c2,rp->left,rp->top);
  65.                                         SetClip(c2);
  66.                                         DisposeRgn(c2);
  67.                                         OffsetRect(&fr,rp->left,rp->top);
  68.                                         FillRect(&fr,&p);
  69.                                         SetOrigin(o.h,o.v);
  70.                                         SetClip(c1);
  71.                                         DisposeRgn(c1);
  72.  
  73.                                         if(w->goAwayFlag){
  74.                                                 fr = ga;
  75.                                                 InsetRect(&fr,-1,-1);
  76.                                                 EraseRect(&fr);
  77.                                                 FrameRect(&ga);
  78.                                         }
  79.                                 }
  80.                         }
  81.                 }
  82.                 break;
  83.         case wHit:
  84.                 if(PtInRect(*(Point*)&param,&wr))
  85.                         return wInContent;
  86.                 else if(PtInRgn(*(Point*)&param,w->strucRgn)){
  87.                         if(w->goAwayFlag && w->hilited){
  88.                                 if(PtInRect(*(Point*)&param,&ga))
  89.                                         return wInGoAway;
  90.                         }
  91.                         return wInDrag;
  92.                 }
  93.                 break;
  94.         case wCalcRgns:
  95.                 { RgnHandle sh;
  96.                         RectRgn(w->contRgn,&wr);
  97.                         RectRgn(w->strucRgn,&fr);
  98.                         ++fr.bottom;
  99.                         ++fr.right;
  100.                         fr.left += INDENT;
  101.                         fr.top += INDENT;
  102.                         RectRgn(sh = NewRgn(),&fr);
  103.                         UnionRgn(w->strucRgn,sh,w->strucRgn);
  104.                         DisposeRgn(sh);
  105.                 }
  106.         }
  107.         return 0;
  108. }
  109. #if 0
  110. debug_rect(char*s,Rect*r){ Str255 t,n;
  111.         PLstrcpy(t,s); PLstrcat(t,"\p:");
  112. #define A(x) NumToString(x,n); PLstrcat(t,n); PLstrcat(t,"\p,");
  113.         A(r->left); A(r->top); A(r->right); A(r->bottom);
  114.         --*t;
  115.         DebugStr(t);
  116. }
  117. #endif
  118.