Subversion Repositories filter_foundry

Rev

Rev 193 | Rev 268 | 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-2006 Toby Thain, toby@telegraphics.com.au
3
    Copyright (C) 1990-2006 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 <dialogs.h>
20
#include <dialogs.h>
21
#include <menus.h>
21
#include <menus.h>
22
#include <osutils.h>
22
#include <osutils.h>
23
#include <textutils.h>
23
#include <textutils.h>
24
#include <windows.h>
24
#include <windows.h>
25
 
25
 
26
#include "dlg.h"
26
#include "dlg.h"
27
#include "menu.h"
27
#include "menu.h"
28
#include "carbonstuff.h"
28
#include "carbonstuff.h"
29
 
29
 
30
void set_item_state(MenuHandle m,short i,Boolean f){
30
void set_item_state(MenuHandle m,short i,Boolean f){
31
#if TARGET_API_MAC_CARBON
31
#if TARGET_API_MAC_CARBON
32
        f ? EnableMenuItem(m,i) : DisableMenuItem(m,i);
32
        f ? EnableMenuItem(m,i) : DisableMenuItem(m,i);
33
#else
33
#else
34
        f ? EnableItem(m,i) : DisableItem(m,i);
34
        f ? EnableItem(m,i) : DisableItem(m,i);
35
#endif
35
#endif
36
}
36
}
37
 
37
 
38
void draw_popup(DialogPtr d,short i,unsigned char*s){
38
void draw_popup(DialogPtr d,short i,unsigned char*s){
39
        static short arrow_data[] = {0xffe0,0x7fc0,0x3f80,0x1f00,0x0e00,0x0400};
39
        static short arrow_data[] = {0xffe0,0x7fc0,0x3f80,0x1f00,0x0e00,0x0400};
40
        static BitMap arrow = {(void*)arrow_data,2,{0,0,6,11}}; // ppcc wants cast
40
        static BitMap arrow = {(void*)arrow_data,2,{0,0,6,11}}; // ppcc wants cast
41
        Rect r,r2;
41
        Rect r,r2;
42
 
42
 
43
        get_item_rect(d,i,&r);
43
        get_item_rect(d,i,&r);
44
        EraseRect(&r);
44
        EraseRect(&r);
45
        r.right--;
45
        r.right--;
46
        r.bottom--;
46
        r.bottom--;
47
        FrameRect(&r);
47
        FrameRect(&r);
48
        MoveTo(r.left+3,r.bottom);
48
        MoveTo(r.left+3,r.bottom);
49
        LineTo(r.right,r.bottom);
49
        LineTo(r.right,r.bottom);
50
        LineTo(r.right,r.top+3);
50
        LineTo(r.right,r.top+3);
51
        r2 = arrow.bounds;
51
        r2 = arrow.bounds;
52
        OffsetRect(&r2,r.right-17,r.top+6);
52
        OffsetRect(&r2,r.right-17,r.top+6);
53
        CopyBits(&arrow,GetPortBitMapForCopyBits((CGrafPtr)d),&arrow.bounds,&r2,srcOr,0);
53
        CopyBits(&arrow,GetPortBitMapForCopyBits((CGrafPtr)d),&arrow.bounds,&r2,srcOr,0);
54
        MoveTo(r.left+15,r.top+13);
54
        MoveTo(r.left+15,r.top+13);
55
        DrawString(s);
55
        DrawString(s);
56
}
56
}
57
 
57
 
58
void adjust_popup(DialogPtr d,short i,MenuHandle m,short mItem,short max,unsigned char *s){
58
void adjust_popup(DialogPtr d,short i,MenuHandle m,short mItem,short max,unsigned char *s){
59
        KIND_ITEM_BOX
59
        KIND_ITEM_BOX
60
        short j;
60
        short j;
61
        unsigned char *t;
61
        unsigned char *t;
62
        GrafPtr gp;
62
        GrafPtr gp;
63
        Rect r;
63
        Rect r;
64
       
64
       
65
        GetPort(&gp);
65
        GetPort(&gp);
66
        SetPort((GrafPtr)GetWindowPort(GetDialogWindow(d)));
66
        SetPort((GrafPtr)GetWindowPort(GetDialogWindow(d)));
67
        max -= 12/*info.ascent*/ + 11 + 16;
67
        max -= 12/*info.ascent*/ + 11 + 16;
68
 
68
 
69
        GetMenuItemText(m,mItem,s);
69
        GetMenuItemText(m,mItem,s);
70
       
70
       
71
#if ! TARGET_API_MAC_CARBON
71
#if ! TARGET_API_MAC_CARBON
72
        {
72
        {
73
        SysEnvRec w;
73
        SysEnvRec w;
74
 
74
 
75
        SysEnvirons(curSysEnvVers,&w);
75
        SysEnvirons(curSysEnvVers,&w);
76
        if(w.systemVersion < 0x700)
76
        if(w.systemVersion < 0x700)
77
                for(t = s + (j = *s); j && StringWidth(s) > max; *s = j--, t--)
77
                for(t = s + (j = *s); j && StringWidth(s) > max; *s = j--, t--)
78
                        *t = 'É';
78
                        *t = 'É';
79
        else
79
        else
80
                TruncString(max,s,smTruncEnd);
80
                TruncString(max,s,smTruncEnd);
81
        }
81
        }
82
#else
82
#else
83
        TruncString(max,s,smTruncEnd);
83
        TruncString(max,s,smTruncEnd);
84
#endif
84
#endif
85
 
85
 
86
        GetDialogItem(d,i,&kind,&item,&box);
86
        GetDialogItem(d,i,&kind,&item,&box);
87
        InvalWindowRect(GetDialogWindow(d),&box);
87
        InvalWindowRect(GetDialogWindow(d),&box);
88
        r = box;
88
        r = box;
89
        r.left = box.right = box.left + 12 /*info.ascent*/ + StringWidth(s) + 11 + 16;
89
        r.left = box.right = box.left + 12 /*info.ascent*/ + StringWidth(s) + 11 + 16;
90
        EraseRect(&r);
90
        EraseRect(&r);
91
        InvalWindowRect(GetDialogWindow(d),&box);
91
        InvalWindowRect(GetDialogWindow(d),&box);
92
        SetDialogItem(d,i,kind,item,&box);
92
        SetDialogItem(d,i,kind,item,&box);
93
        SetPort(gp);
93
        SetPort(gp);
94
}
94
}
95
 
95