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