File: format.cc

package info (click to toggle)
abacus 0.9.13-4
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,308 kB
  • ctags: 5,120
  • sloc: ansic: 27,540; cpp: 11,426; tcl: 7,564; makefile: 386; yacc: 327; lex: 265; sh: 221
file content (166 lines) | stat: -rw-r--r-- 3,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// $Id: format.cc,v 1.7 1998/08/06 21:08:43 aml Exp $

#include "format.hh"
extern Tcl_HashTable font_hash;


int Format::last_timestamp=0;

char *format_strings[4] = {
  "general","general","general","general"
};

char *format_formats[4] = {
  "%g","%g","%g","%g"
};

Format::Format()
{ 
  alignment = DEFAULT_ALIGNMENT;
  form = DEFAULT_FORMAT;
  timestamp=++last_timestamp;
}

void Format::UpdateTimestamp()
{
  timestamp=++last_timestamp;
}

Background::Background() {
    filllevel = DEFAULT_FILL;
    red = 255;
    green = 255;
    blue = 255;
    item = NO_ITEM;
}

Background::Background(const Background &rig) {
    filllevel = rig.filllevel;
    red = rig.red;
    green = rig.green;
    blue = rig.blue;
    item = NO_ITEM;
}

void Background::operator=(const Background &rig) {
    filllevel = rig.filllevel;
    red = rig.red;
    green = rig.green;
    blue = rig.blue;
    //    item = NO_ITEM;
}

Border::Border() {
    top = DEFAULT_BORDER;
    bottom = DEFAULT_BORDER;
    left = DEFAULT_BORDER;
    right = DEFAULT_BORDER;
    top_item = NO_ITEM;
    bottom_item = NO_ITEM;
    left_item = NO_ITEM;
    right_item = NO_ITEM;
    top_item_double = FALSE;
    bottom_item_double = FALSE;
    left_item_double = FALSE;
    right_item_double = FALSE;
}

Border& Border::operator=(const Border &rig) 
{
  top = rig.top;
  bottom = rig.bottom;
  left = rig.left;
  right = rig.right;
  //     top_item = NO_ITEM;
  //     bottom_item = NO_ITEM;
  //     left_item = NO_ITEM;
  //     right_item = NO_ITEM;
  //     top_item_double = FALSE;
  //     bottom_item_double = FALSE;
  //     left_item_double = FALSE;
  //     right_item_double = FALSE;
  // Initializing them leads to incorrect copying and pasting of items.
  return *this;
}

Border::Border(const Border &rig) {
    top = rig.top;
    bottom = rig.bottom;
    left = rig.left;
    right = rig.right;
    top_item = NO_ITEM;
    bottom_item = NO_ITEM;
    left_item = NO_ITEM;
    right_item = NO_ITEM;
    top_item_double = FALSE;
    bottom_item_double = FALSE;
    left_item_double = FALSE;
    right_item_double = FALSE;
}


char *getFont(Tcl_Interp *interp,Fontinfo &font){

    int newv;
    Tcl_HashEntry *entry;
    char *st;
    char buf[256];
    int *keyp;


    keyp = (int*) &font;

    entry = Tcl_CreateHashEntry(&font_hash,(char*)(*keyp),&newv);

    if (newv == 1) {
        sprintf(buf,"computeFont %d %d %d %d",font.family,font.size,
                font.italics,font.bold);
        if (Tcl_Eval(interp,buf) != TCL_OK)
            internal_error();
        st = strsave(interp->result);
        Tcl_SetHashValue(entry,st);
    } else {
        st = (char*)Tcl_GetHashValue(entry);
    }

    return(st);
}







/*
$Log: format.cc,v $
Revision 1.7  1998/08/06 21:08:43  aml
Released alpha version of Abacus.

Revision 1.6  1996/09/17 15:16:30  aml
Fixed problems with copying of cells with non-default formats.
Created printing formats, alignment formats.
Format toolbar now reflects format of active cell.

Revision 1.5  1996/09/16 18:42:47  aml
Some performance problems addressed by reducing tag use.
Several performance problems remain when heavy use is made
of borders and shading in large spreadsheets.

// Revision 1.4  1996/09/04  14:30:01  aml
// Fixed double redrawing of sheets that was taking place.
// Fixed a item reference problem when the sheet is redrawn.
// Fixed misplacement of row labels.
// Created first version of format toolbar.
//
Revision 1.3  1996/09/02 10:51:43  aml
Cell fonts created, loaded and saved.
Row height created.

// Revision 1.2  1996/07/18  10:19:34  aml
// Created formats for cells.
// Load cell now makes copy of old file.
//
Revision 1.1  1996/04/27 11:19:52  aml
Initial revision
*/