Commit 215d7b8e authored by Florian Ernst's avatar Florian Ernst

Imported Upstream version 8.0.2

parent 99474310
......@@ -24,6 +24,7 @@ Abacus*highlightBeadColor: magenta
Abacus*primaryRailColor: gold
Abacus*secondaryRailColor: LightSteelBlue1
Abacus*highlightRailColor: Purple
Abacus*lineRailColor: Black
Abacus*bumpSound: @READPATH@/bump.au
Abacus*moveSound: @READPATH@/move.au
!Abacus*bumpSound: ./bump.au
......@@ -111,6 +112,7 @@ Abacus*format: Chinese
!Abacus*format: Roman
!Abacus*format: Russian
!Abacus*format: Danish
!Abacus*format: Medieval
!Abacus*format: Generic
Abacus*museum: --
!
......@@ -195,6 +197,15 @@ Abacusdk*rails: 10
Abacusdk*group: true
Abacusdk*decimalComma: true
Abacusdk*format: Danish
! Medieval Counter
Abacusme*vertical: true
Abacusme*colorScheme: 4
Abacusme*topNumber: 2
Abacusme*bottomNumber: 5
Abacusme*romanNumerals: true
Abacusme*decimalPosition: 0
Abacusdk*rails: 5
Abacusdk*format: Medieval
! Mesoamerican Nepohualtzintzin (similar to Japanese Soroban base 20)
Abacusma*diamond: 1
Abacusma*topNumber: 3
......
......@@ -283,6 +283,9 @@ static XtResource resources[] =
{XtNhighlightRailColor, XtCForeground, XtRPixel, sizeof (Pixel),
XtOffset(AbacusWidget, abacus.railColor[2]),
XtRString, (caddr_t) "Purple" /*XtDefaultForeground*/},
{XtNlineRailColor, XtCForeground, XtRPixel, sizeof (Pixel),
XtOffset(AbacusWidget, abacus.railColor[3]),
XtRString, (caddr_t) "Black" /*XtDefaultForeground*/},
{XtNbumpSound, XtCBumpSound, XtRString, sizeof (String),
XtOffset(AbacusWidget, abacus.bumpSound),
XtRString, (caddr_t) BUMPSOUND},
......@@ -437,7 +440,7 @@ static XtResource resources[] =
XtOffset(AbacusWidget, abacus.displayBase),
XtRString, (caddr_t) "10"},
{XtNpressOffset, XtCPressOffset, XtRBoolean, sizeof (int),
XtOffset(AbacusWidget, abacus.pressOffsetY),
XtOffset(AbacusWidget, abacus.pressOffset.y),
XtRString, (caddr_t) "0"},
{XtNromanNumerals, XtCRomanNumerals, XtRBoolean, sizeof (Boolean),
XtOffset(AbacusWidget, abacus.romanNumerals),
......@@ -644,6 +647,9 @@ setModeFromFormat(AbacusWidget w)
} else if (strncasecmp("danish", w->abacus.format,
MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = DANISH;
} else if (strncasecmp("medieval", w->abacus.format,
MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = MEDIEVAL;
} else if (strncasecmp("cn", w->abacus.format, MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = CHINESE;
} else if (strncasecmp("zh", w->abacus.format, MAX_FORMAT_LENGTH) == 0) {
......@@ -664,6 +670,12 @@ setModeFromFormat(AbacusWidget w)
w->abacus.mode = DANISH;
} else if (strncasecmp("da", w->abacus.format, MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = DANISH;
} else if (strncasecmp("me", w->abacus.format, MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = MEDIEVAL;
} else if (strncasecmp("de", w->abacus.format, MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = MEDIEVAL;
} else if (strncasecmp("uk", w->abacus.format, MAX_FORMAT_LENGTH) == 0) {
w->abacus.mode = MEDIEVAL;
} else {
w->abacus.mode = GENERIC;
}
......@@ -865,6 +877,45 @@ static int valueSubdeck(AbacusWidget w) {
return sum;
}
/* FIXME for subdeck */
static int
getFactor(AbacusWidget w, int deck, int rail) {
if (w->abacus.sign && rail == w->abacus.rails - 1) {
return 0;
} else if (w->abacus.decks[BOTTOM].piece != 0 &&
(rail == w->abacus.decimalPosition - 1)) {
if (deck == TOP)
return w->abacus.decks[BOTTOM].piece;
} else if (w->abacus.decks[BOTTOM].piecePercent != 0 &&
(rail == w->abacus.decimalPosition -
w->abacus.shiftPercent - 1 -
((w->abacus.decks[BOTTOM].piece == 0) ? 0 : 1))) {
if (deck == TOP)
return w->abacus.decks[BOTTOM].piecePercent;
} else {
return w->abacus.decks[deck].factor;
}
return 1;
}
/* FIXME for subdeck */
static int
getNumber(AbacusWidget w, int deck, int rail) {
if (w->abacus.sign && rail == w->abacus.rails - 1) {
return ((deck == BOTTOM) ? 1 : 0);
} else if (w->abacus.decks[BOTTOM].piece != 0 &&
(rail == w->abacus.decimalPosition - 1)) {
return numberPieces(w, deck);
} else if (w->abacus.decks[BOTTOM].piecePercent != 0 &&
(rail == w->abacus.decimalPosition -
w->abacus.shiftPercent - 1 -
((w->abacus.decks[BOTTOM].piece == 0) ? 0 : 1))) {
return numberPiecePercents(w, deck);
} else {
return w->abacus.decks[deck].number;
}
}
static void
setSpace(AbacusWidget w, int deck)
{
......@@ -1121,7 +1172,23 @@ checkBeads(AbacusWidget w)
w->abacus.mode = CHINESE;
}
/* If a particular mode, ignore improper settings */
if (w->abacus.mode == DANISH) {
if (w->abacus.mode == MEDIEVAL) {
w->abacus.colorScheme = 0;
w->abacus.decks[BOTTOM].factor = 1;
w->abacus.decks[TOP].factor = convertBaseToBottom(w->abacus.base);
w->abacus.decks[BOTTOM].number = w->abacus.decks[TOP].factor;
w->abacus.decks[TOP].number = w->abacus.base / w->abacus.decks[TOP].factor;
w->abacus.decks[BOTTOM].orientation = DEFAULT_BOTTOM_ORIENT;
w->abacus.decks[TOP].orientation = DEFAULT_BOTTOM_ORIENT;
w->abacus.decks[BOTTOM].spaces = DEFAULT_BOTTOM_SPACES;
w->abacus.decks[TOP].spaces = DEFAULT_TOP_SPACES;
w->abacus.vertical = True;
w->abacus.slot = False;
w->abacus.diamond = False;
w->abacus.railIndex = 3;
setSpace(w, BOTTOM);
setSpace(w, TOP);
} else if (w->abacus.mode == DANISH) {
w->abacus.colorScheme = COLOR_HALF;
w->abacus.decks[BOTTOM].factor = 1;
w->abacus.decks[TOP].factor = w->abacus.base;
......@@ -1482,7 +1549,7 @@ resetBeads(AbacusWidget w)
#ifdef HAVE_MOTIF
static Boolean
isEmptyCounter(AbacusWidget w)
isEmptyResultRegister(AbacusWidget w)
{
int n = 0;
......@@ -1496,14 +1563,25 @@ isEmptyCounter(AbacusWidget w)
}
#endif
#if 0
static Boolean
isSuperSaturatedResultRegister()
{
return (w->abacus.digits[0] != '0');
}
#endif
static Boolean
emptyCounter(AbacusWidget w)
emptyResultRegister(AbacusWidget w)
{
int n = 0;
Boolean good = True;
while (n < w->abacus.numDigits - 1) {
if (w->abacus.digits[n] != '0') {
#if 1
printf("emptyResultRegister: %d %d\n", n, w->abacus.digits[n]);
#endif
good = False;
w->abacus.digits[n] = '0';
}
......@@ -1512,8 +1590,9 @@ emptyCounter(AbacusWidget w)
return good;
}
/* mostly depends on w not other input */
static void
setCounter(AbacusWidget w, int deck, int rail, int number)
setResultRegister(AbacusWidget w, int deck, int rail, int number)
{
int n = 0, s = 0, i;
int m = 0, o = 0, half;
......@@ -1547,7 +1626,7 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
if (!(buffer = (char *) malloc(sizeof (char) *
(size_t) (w->abacus.numDigits + 12 + sizeofRoman(w->abacus.base,
w->abacus.romanNumerals, w->abacus.ancientRoman))))) {
DISPLAY_ERROR("Not enough memory (setCounter), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister), exiting.");
}
if (s == 1)
buffer[0] = '-';
......@@ -1562,15 +1641,15 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
if (!(stringBuf = (char *) malloc(sizeof (char) *
(size_t) (w->abacus.numDigits + 2)))) {
DISPLAY_ERROR("Not enough memory (setCounter1), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister1), exiting.");
}
if (!(midBuf = (char *) malloc(sizeof (char) *
(size_t) (w->abacus.numDigits + 2)))) {
DISPLAY_ERROR("Not enough memory (setCounter2), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister2), exiting.");
}
if (!(finalBuf = (char *) malloc(sizeof (char) *
(size_t) (w->abacus.numDigits + 2)))) {
DISPLAY_ERROR("Not enough memory (setCounter3), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister3), exiting.");
}
precision = ((w->abacus.decks[BOTTOM].piecePercent == 0) ?
1 : 2) * w->abacus.shiftPercent + 2;
......@@ -1669,6 +1748,15 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
#endif
buffer[s + half + offset] = '\0';
}
while (strlen(buffer) > 3 &&
buffer[strlen(buffer) - 1] == '0' &&
buffer[strlen(buffer) - 2] != decimalChar(w)) {
buffer[strlen(buffer) - 1] = '\0';
}
#if DEBUG
(void) printf("setResultRegister: buffer %s\n", buffer);
#endif
if (w->abacus.script) {
#ifdef WINVER
(void) fprintf(w->abacus.fp, "%d %d %d %d 4\n",
......@@ -1702,7 +1790,7 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
}
free(buffer);
if (!(buffer = (char *) malloc(sizeof (char) * 1024))) {
DISPLAY_ERROR("Not enough memory (setCounter4), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister4), exiting.");
}
(void) strcpy(buffer, buff);
}
......@@ -1710,14 +1798,14 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
int pieces = w->abacus.decks[BOTTOM].piece;
char *romanString;
(void) strcat(buffer, " ");
(void) strcat(buffer, " ");
if (w->abacus.decks[TOP].piece != 0)
pieces *= w->abacus.decks[TOP].piece;
if (!(romanString = (char *) malloc(sizeof (char) *
(size_t) sizeofRoman(w->abacus.displayBase,
w->abacus.romanNumerals,
w->abacus.ancientRoman)))) {
DISPLAY_ERROR("Not enough memory (setCounter5), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister5), exiting.");
}
(void) string2Roman(romanString, buffer, w->abacus.displayBase,
pieces, valuePiece(w), valueSubdeck(w),
......@@ -1731,7 +1819,7 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
if (!(groupString = (char *) malloc(sizeof (char) *
3 * strlen(buffer) / 2))) {
DISPLAY_ERROR("Not enough memory (setCounter6), exiting.");
DISPLAY_ERROR("Not enough memory (setResultRegister6), exiting.");
}
string2Group(groupString, buffer, w->abacus.groupSize,
decimalChar(w), groupChar(w));
......@@ -1744,10 +1832,54 @@ setCounter(AbacusWidget w, int deck, int rail, int number)
}
}
static int
middleBarPositionX(AbacusWidget w, int rail) {
return 1 - w->abacus.railWidth / 2 + w->abacus.offset.x +
rail * w->abacus.pos.x - (w->abacus.pos.x - 1) / 2;
}
#define SYMBOLGC(s) (s)?((w->abacus.mono && w->abacus.slot)?w->abacus.beadShadeGC[4]:w->abacus.symbolGC):w->abacus.inverseGC
/* Note On Draws:
* There is some overlap i.e. it draws some extra pixels.
* This is to synchronize Java, X and Windows.
*/
static void
drawCounterDecimalSeparator(AbacusWidget w, int rail, Boolean show) {
int x, y, wd, ht;
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
if (w->abacus.decimalPosition == 0)
return;
wd = 1 + w->abacus.railWidth * 2;
x = middleBarPositionX(w, rail) + 2 +
w->abacus.beadSize.x / 2 + w->abacus.railWidth / 2;
y = w->abacus.middleBarPositionY;
if (w->abacus.vertical) {
y = w->abacus.frameSize.y - w->abacus.middleBarHeight - y;
}
ht = w->abacus.middleBarHeight - 1;
// make a diamond, not historical but need
// something when there is a decimal point
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2, x, y + ht);
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2, x, y);
VDRAWLINE(w, dr, gc,
x + wd, y + ht / 2, x, y + ht);
VDRAWLINE(w, dr, gc,
x + wd, y + ht / 2, x, y);
VDRAWLINE(w, dr, gc,
x - wd + 1, y + ht / 2, x, y + ht - 1);
VDRAWLINE(w, dr, gc,
x - wd + 1, y + ht / 2, x, y + 1);
VDRAWLINE(w, dr, gc,
x + wd - 1, y + ht / 2, x, y + ht - 1);
VDRAWLINE(w, dr, gc,
x + wd - 1, y + ht / 2, x, y + 1);
}
static void
drawDecimalSeparator(AbacusWidget w, int rail, Boolean show)
{
......@@ -1755,6 +1887,10 @@ drawDecimalSeparator(AbacusWidget w, int rail, Boolean show)
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
if (w->abacus.mode == MEDIEVAL) {
drawCounterDecimalSeparator(w, rail, show);
return;
}
x = 1 - w->abacus.railWidth / 2 + w->abacus.offset.x +
rail * w->abacus.pos.x - (w->abacus.pos.x - 1) / 2;
y = w->abacus.decks[TOP].room * w->abacus.pos.y + w->abacus.delta.y -
......@@ -1766,13 +1902,46 @@ drawDecimalSeparator(AbacusWidget w, int rail, Boolean show)
w->abacus.railWidth + 4, w->abacus.middleBarHeight);
}
static void
drawCounterGroupSeparator(AbacusWidget w, int rail, Boolean show) {
int x, y, wd, ht;
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
wd = 1 + w->abacus.railWidth * 2;
x = middleBarPositionX(w, rail) + 2 +
w->abacus.beadSize.x / 2 + w->abacus.railWidth / 2;
y = w->abacus.middleBarPositionY;
if (w->abacus.vertical) {
y = w->abacus.frameSize.y - w->abacus.middleBarHeight - y;
}
ht = w->abacus.middleBarHeight - 1;
// make an X
VDRAWLINE(w, dr, gc,
x + wd, y, x - wd, y + ht);
VDRAWLINE(w, dr, gc,
x - wd, y, x + wd, y + ht);
VDRAWLINE(w, dr, gc,
x + wd, y + 1, x - wd, y + ht - 1);
VDRAWLINE(w, dr, gc,
x - wd, y + 1, x + wd, y + ht - 1);
VDRAWLINE(w, dr, gc,
x + wd - 1, y, x - wd + 1, y + ht);
VDRAWLINE(w, dr, gc,
x - wd + 1, y, x + wd - 1 , y + ht);
}
static void
drawGroupSeparator(AbacusWidget w, int rail, Boolean show)
{
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
int x, y;
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
if (w->abacus.mode == MEDIEVAL) {
drawCounterGroupSeparator(w, rail, show);
return;
}
x = 1 - w->abacus.railWidth / 2 + w->abacus.offset.x +
rail * w->abacus.pos.x - (w->abacus.pos.x - 1) / 2;
y = w->abacus.decks[TOP].room * w->abacus.pos.y + w->abacus.delta.y -
......@@ -1809,13 +1978,11 @@ drawAllGroupSeparators(AbacusWidget w, Boolean show)
w->abacus.groupSize * separator, show);
}
#define SYMBOLGC(s) (s)?((w->abacus.mono && w->abacus.slot)?w->abacus.beadShadeGC[4]:w->abacus.symbolGC):w->abacus.inverseGC
static void
drawRomanI(AbacusWidget w, int rail, Boolean show)
{
GC gc = SYMBOLGC(show);
int x, y;
GC gc = SYMBOLGC(show);
Pixmap dr = 0;
x = 2 + w->abacus.offset.x +
......@@ -1876,8 +2043,8 @@ drawRomanC(AbacusWidget w, int rail, Boolean show)
static void
drawRomanM(AbacusWidget w, int rail, Boolean show)
{
GC gc = SYMBOLGC(show);
int x, y, ht;
GC gc = SYMBOLGC(show);
Pixmap dr = 0;
x = 2 + w->abacus.offset.x +
......@@ -1910,8 +2077,8 @@ drawRomanM(AbacusWidget w, int rail, Boolean show)
static void
drawRomanx(AbacusWidget w, int rail, Boolean show)
{
GC gc = SYMBOLGC(show);
int x, y, ht;
GC gc = SYMBOLGC(show);
Pixmap dr = 0;
x = 2 + w->abacus.offset.x +
......@@ -1948,8 +2115,8 @@ drawRomanx(AbacusWidget w, int rail, Boolean show)
static void
drawRomanc(AbacusWidget w, int rail, Boolean show)
{
GC gc = SYMBOLGC(show);
int x, y, ht;
GC gc = SYMBOLGC(show);
Pixmap dr = 0;
x = 2 + w->abacus.offset.x +
......@@ -2147,6 +2314,30 @@ drawRomanTwelfth(AbacusWidget w, int rail, Boolean show)
}
}
static void
drawCounterNegative(AbacusWidget w, int rail, Boolean show) {
int x, y, wd, ht;
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
wd = 1 + w->abacus.railWidth * 2;
x = middleBarPositionX(w, rail) + 2 +
w->abacus.beadSize.x / 2 + w->abacus.railWidth / 2;
y = w->abacus.middleBarPositionY;
if (w->abacus.vertical) {
y = w->abacus.frameSize.y - w->abacus.middleBarHeight - y;
}
ht = w->abacus.middleBarHeight - 1;
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2 - 1, x + wd, y + ht / 2 - 1);
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2, x + wd, y + ht / 2);
if ((ht % 2) == 1) {
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2 + 1, x + wd, y + ht / 2 + 1);
}
}
static void
drawNegative(AbacusWidget w, int rail, Boolean show)
{
......@@ -2165,6 +2356,33 @@ drawNegative(AbacusWidget w, int rail, Boolean show)
w->abacus.railWidth + 4, 2);
}
static void
drawCounterPiece(AbacusWidget w, int rail, Boolean show) {
int x, y, wd, ht;
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
wd = 1 + w->abacus.railWidth * 2;
x = middleBarPositionX(w, rail) + 2 +
w->abacus.beadSize.x / 2 + w->abacus.railWidth / 2;
y = w->abacus.middleBarPositionY;
if (w->abacus.vertical) {
y = w->abacus.frameSize.y - w->abacus.middleBarHeight - y;
}
ht = w->abacus.middleBarHeight - 1;
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2 - 1, x + wd, y + ht / 2 - 1);
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2, x + wd, y + ht / 2);
if ((ht % 2) == 1) {
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2 + 1, x + wd, y + ht / 2 + 1);
}
VFILLRECTANGLE(w, dr, gc,
x - 1 - w->abacus.railWidth / 2, y + 1,
w->abacus.railWidth + 2, ht - 1);
}
static void
drawPiece(AbacusWidget w, int rail, Boolean show)
{
......@@ -2214,6 +2432,42 @@ drawRomanPiece(AbacusWidget w, int rail, Boolean show)
x + 1 + woffset + hoffset, y + 1, 2, ht - 1);
}
static void
drawCounterAnomaly(AbacusWidget w, int rail, Boolean show) {
int x, y, wd, ht;
GC gc = ((show) ? w->abacus.symbolGC : w->abacus.inverseGC);
Pixmap dr = 0;
wd = 1 + w->abacus.railWidth * 2;
x = middleBarPositionX(w, rail) + 2 +
w->abacus.beadSize.x / 2 + w->abacus.railWidth / 2;
y = w->abacus.middleBarPositionY;
if (w->abacus.vertical) {
y = w->abacus.frameSize.y - w->abacus.middleBarHeight - y;
}
ht = w->abacus.middleBarHeight - 1;
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2 - 1, x + wd, y + ht / 2 - 1);
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2, x + wd, y + ht / 2);
if ((ht % 2) == 1) {
VDRAWLINE(w, dr, gc,
x - wd, y + ht / 2 + 1, x + wd, y + ht / 2 + 1);
}
VDRAWLINE(w, dr, gc,
x + wd, y, x - wd, y + ht);
VDRAWLINE(w, dr, gc,
x - wd, y, x + wd, y + ht);
VDRAWLINE(w, dr, gc,
x + wd, y + 1, x - wd, y + ht - 1);
VDRAWLINE(w, dr, gc,
x - wd, y + 1, x + wd, y + ht - 1);
VDRAWLINE(w, dr, gc,
x + wd - 1, y, x - wd + 1, y + ht);
VDRAWLINE(w, dr, gc,
x - wd + 1, y, x + wd - 1 , y + ht);
}
static void
drawAnomaly(AbacusWidget w, int rail, Boolean show)
{
......@@ -2221,10 +2475,8 @@ drawAnomaly(AbacusWidget w, int rail, Boolean show)
GC gc = SYMBOLGC(show);
Pixmap dr = 0;
x = 1 - w->abacus.railWidth / 2 + w->abacus.offset.x +
rail * w->abacus.pos.x - (w->abacus.pos.x - 1) / 2;
y = w->abacus.decks[TOP].room * w->abacus.pos.y + w->abacus.delta.y -
1 + w->abacus.offset.y;
x = middleBarPositionX(w, rail);
y = w->abacus.middleBarPositionY;
ht = w->abacus.middleBarHeight - 1;
if (w->abacus.vertical) {
y = w->abacus.frameSize.y - w->abacus.middleBarHeight - y;
......@@ -2256,148 +2508,6 @@ eraseFrame(const AbacusWidget w, Pixmap dr)
0, 0, w->core.width, w->core.height);
}
static void
drawFrame(const AbacusWidget w, Pixmap dr, Boolean show, Boolean focus)
{
int deck, x, y, yOffset, yPrime;
GC gc = (show) ? ((focus) ? w->abacus.frameGC : w->abacus.borderGC) :
w->abacus.inverseGC;
x = w->abacus.rails * w->abacus.pos.x + w->abacus.delta.x - 1;
/* Top/Left */
VFILLRECTANGLE(w, dr, gc,
0, 0, w->abacus.offset.x + 1, w->abacus.frameSize.y);
/* Bottom/Right */
VFILLRECTANGLE(w, dr, gc,
x + w->abacus.offset.x, 0,
w->abacus.frameSize.x - (x + w->abacus.offset.x),
w->abacus.frameSize.y);
for (deck = TOP; deck >= BOTTOM; deck--) {
yOffset = (deck == TOP) ? 0 : w->abacus.decks[TOP].height;
y = w->abacus.decks[deck].room * w->abacus.pos.y +
w->abacus.delta.y - 1;
yPrime = y + yOffset + w->abacus.offset.y;
if (w->abacus.vertical) {
yPrime = w->abacus.frameSize.y -
w->abacus.middleBarHeight - yPrime;
yOffset = w->abacus.frameSize.y -
w->abacus.offset.y - yOffset;
}
if (deck == TOP) {
Boolean anomalyActive = checkAnomaly(w);
/* Right/Top */
VFILLRECTANGLE(w, dr, gc,
w->abacus.offset.x + 1,
yOffset,
x - 1,
w->abacus.offset.y);
if (!w->abacus.slot) {
/* Middle */
VFILLRECTANGLE(w, dr, gc,
w->abacus.offset.x + 1,
yPrime,
x - 1,
w->abacus.middleBarHeight);
}
if (w->abacus.slot && !anomalyActive) {
int pRails = w->abacus.rails -
w->abacus.decimalPosition -
((w->abacus.sign) ? 1 : 0);
drawRomanI(w, w->abacus.rails -
w->abacus.decimalPosition, show);
if (pRails - 1)
drawRomanX(w, w->abacus.rails -
w->abacus.decimalPosition - 1, show);
if (pRails - 2)
drawRomanC(w, w->abacus.rails -
w->abacus.decimalPosition - 2, show);
if (pRails - 3)
drawRomanM(w, w->abacus.rails -
w->abacus.decimalPosition - 3, show);
if (pRails - 4)
drawRomanx(w, w->abacus.rails -
w->abacus.decimalPosition - 4, show);
if (pRails - 5)
drawRomanc(w, w->abacus.rails -
w->abacus.decimalPosition - 5, show);
if (pRails - 6)
drawRomanm(w, w->abacus.rails -
w->abacus.decimalPosition - 6, show);
if (checkSubdeck(w, 3)) {
drawRomanHalf(w,
w->abacus.rails -
w->abacus.decimalPosition + 3,
show);
if (w->abacus.subdeck > 1)
drawRomanQuarter(w,
w->abacus.rails -
w->abacus.decimalPosition + 3,
show);
if (w->abacus.subdeck > 2)
drawRomanTwelfth(w,
w->abacus.rails -
w->abacus.decimalPosition + 3,
show);
}
} else {
drawDecimalSeparator(w, w->abacus.rails -
w->abacus.decimalPosition, show);
if (!anomalyActive)
drawAllGroupSeparators(w, show);
}
if (w->abacus.sign)
drawNegative(w, 1, show);
if (w->abacus.slot) {
if (w->abacus.decks[BOTTOM].piece != 0)
drawRomanPiece(w, w->abacus.rails -
w->abacus.decimalPosition + 1, show);
if (w->abacus.decks[BOTTOM].piecePercent != 0)
drawRomanPiece(w, w->abacus.rails -
w->abacus.decimalPosition + 1 +
((w->abacus.decks[BOTTOM].piece == 0) ? 0 : 1) +
w->abacus.shiftPercent, show);
} else {
if (w->abacus.decks[BOTTOM].piece != 0)
drawPiece(w, w->abacus.rails -
w->abacus.decimalPosition + 1, show);
if (w->abacus.decks[BOTTOM].piecePercent != 0)
drawPiece(w, w->abacus.rails -
w->abacus.decimalPosition + 1 +
((w->abacus.decks[BOTTOM].piece == 0) ? 0 : 1) +
w->abacus.shiftPercent, show);
}
if (anomalyActive)
drawAnomaly(w, w->abacus.rails -
w->abacus.decimalPosition -
w->abacus.shiftAnomaly, show);
if (anomalyActive && w->abacus.anomalySq != 0)
drawAnomaly(w, w->abacus.rails -
w->abacus.decimalPosition -
w->abacus.shiftAnomaly -
w->abacus.shiftAnomalySq, show);
} else {
if (w->abacus.vertical) {
/* Left */
FILLRECTANGLE(w, dr, gc,
0,
w->abacus.offset.x + 1,
yPrime + 3,
x - 1);
} else {
/* Bottom */
FILLRECTANGLE(w, dr, gc,
w->abacus.offset.x + 1,
yPrime + w->abacus.middleBarHeight - 3,
x - 1,
w->abacus.frameSize.y -
(yPrime + w->abacus.middleBarHeight - 3));
}
}
}
}
static void
fillRectClipX(AbacusWidget w, Pixmap dr, GC gc, int dx, int dy, int sx, int sy,
int ox, int wox, int wsx)
......@@ -2434,6 +2544,76 @@ fillRectClipY(AbacusWidget w, Pixmap dr, GC gc, int dx, int dy, int sx, int sy,
FILLRECTANGLE(w, dr, gc, dx, dy + noy, sx, nsy);
}
static void
drawRomanMarkers(const AbacusWidget w, Boolean show)
{
int pRails = w->abacus.rails -
w->abacus.decimalPosition -
((w->abacus.sign) ? 1 : 0);
drawRomanI(w, w->abacus.rails -
w->abacus.decimalPosition, show);
if (pRails - 1)
drawRomanX(w, w->abacus.rails -
w->abacus.decimalPosition - 1, show);
if (pRails - 2)
drawRomanC(w, w->abacus.rails -
w->abacus.decimalPosition - 2, show);
if (pRails - 3)
drawRomanM(w, w->abacus.rails -
w->abacus.decimalPosition - 3, show);
if (pRails - 4)