~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/xpinstall/wizard/mac/src/CheckboxLDEF.c

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* The contents of this file are subject to the Netscape Public License
 
3
 * Version 1.1 (the "License"); you may not use this file except in
 
4
 * compliance with the License. You may obtain a copy of the License at
 
5
 * http://www.mozilla.org/NPL/ 
 
6
 *
 
7
 * Software distributed under the License is distributed on an "AS IS" basis,
 
8
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
 
9
 * for the specific language governing rights and limitations under the 
 
10
 * License. 
 
11
 * 
 
12
 * The Original Code is Mozilla Communicator client code, released March
 
13
 * 31, 1998. 
 
14
 *
 
15
 * The Initial Developer of the Original Code is Netscape Communications
 
16
 * Corporation. Portions created by Netscape are Copyright (C) 1999
 
17
 * Netscape Communications Corporation. All Rights Reserved.  
 
18
 * 
 
19
 * Contributors:
 
20
 *     Samir Gehani <sgehani@netscape.com>
 
21
 */
 
22
 
 
23
#include "CheckboxLDEF.h"
 
24
#include <ToolUtils.h>
 
25
#include <Lists.h>
 
26
#include <LowMem.h>
 
27
#include <TextUtils.h>
 
28
 
 
29
pascal void 
 
30
main(SInt16 message,Boolean selected,Rect *cellRect,Cell theCell,
 
31
         SInt16 dataOffset,SInt16 dataLen,ListHandle theList)  
 
32
{
 
33
        switch(message)
 
34
        {
 
35
                case lDrawMsg:
 
36
                        Draw(selected,cellRect,theCell,dataLen,theList);
 
37
                        break;
 
38
                        
 
39
                case lHiliteMsg:
 
40
                        Highlight(cellRect, selected);
 
41
                        break;
 
42
        }
 
43
}
 
44
 
 
45
void  
 
46
Draw(Boolean selected,Rect *cellRect,Cell theCell,SInt16 dataLen,
 
47
     ListHandle theList)
 
48
{
 
49
        Ptr                     componentName;
 
50
        Rect            nameRect;
 
51
        GrafPtr         oldPort;
 
52
        
 
53
        GetPort(&oldPort);
 
54
        
 
55
        componentName = NewPtrClear(255);
 
56
        LGetCell(componentName, &dataLen, theCell, theList);
 
57
        
 
58
        if (dataLen > 0 && componentName)
 
59
        {
 
60
                Highlight(cellRect, selected);
 
61
                SetRect(&nameRect, cellRect->left+20, cellRect->top,
 
62
                                                        cellRect->right, cellRect->bottom);
 
63
                TETextBox((char*)componentName, dataLen, &nameRect, teFlushDefault);
 
64
        }
 
65
        
 
66
        if (componentName)
 
67
                DisposePtr(componentName);
 
68
                
 
69
        SetPort(oldPort);
 
70
}
 
71
 
 
72
void
 
73
Highlight(Rect *cellRect, Boolean selected)
 
74
{
 
75
        if (selected)
 
76
                DrawCheckedCheckbox(cellRect);
 
77
        else
 
78
                DrawEmptyCheckbox(cellRect);
 
79
}
 
80
 
 
81
Rect
 
82
DrawEmptyCheckbox(Rect *cellRect)
 
83
{
 
84
        Rect checkbox;
 
85
        
 
86
        SetRect(&checkbox, cellRect->left+4, cellRect->top+2, 
 
87
                                                cellRect->left+16, cellRect->top+14);
 
88
        EraseRect(&checkbox);
 
89
        FrameRect(&checkbox);
 
90
        
 
91
        return checkbox;
 
92
}
 
93
 
 
94
void
 
95
DrawCheckedCheckbox(Rect *cellRect)
 
96
{
 
97
        Rect            checkbox = DrawEmptyCheckbox(cellRect);
 
98
        
 
99
        /* now fill in check mark */
 
100
        
 
101
        MoveTo(checkbox.left+1, checkbox.top+1);
 
102
        LineTo(checkbox.right-2, checkbox.bottom-2);
 
103
        MoveTo(checkbox.right-2, checkbox.top+1);
 
104
        LineTo(checkbox.left+1, checkbox.bottom-2); 
 
105
 
 
106
}