fixed build and applied yet more cleanup

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17741 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2006-06-06 16:25:46 +00:00
parent a216b33aed
commit b962260488
2 changed files with 39 additions and 42 deletions
+2 -2
View File
@@ -14,8 +14,8 @@
#include <Window.h> #include <Window.h>
struct CalcOptions { struct CalcOptions {
bool mAutoNumLock; // automatically activate numlock bool auto_num_lock; // automatically activate numlock
bool mAudioFeedback; // provide audio feedback bool audio_feedback; // provide audio feedback
CalcOptions(); CalcOptions();
}; };
+34 -37
View File
@@ -218,7 +218,7 @@ CalcView::Draw(BRect updateRect)
SetFont(be_bold_font); SetFont(be_bold_font);
// ****** DISPLAY Area // ****** DISPLAY Area
if (updateRect.Intersects(displayRect)){ if (updateRect.Intersects(displayRect)) {
// paint display b/g // paint display b/g
SetHighColor(fExpressionBGColor); SetHighColor(fExpressionBGColor);
@@ -231,14 +231,13 @@ CalcView::Draw(BRect updateRect)
SetFontSize(sizeDisp * K_FONT_YPROP); SetFontSize(sizeDisp * K_FONT_YPROP);
float baselineOffset = sizeDisp * (1.0 - K_FONT_YPROP) * 0.5; float baselineOffset = sizeDisp * (1.0 - K_FONT_YPROP) * 0.5;
DrawString(fExpression.String(), DrawString(fExpression.String(),
BPoint(fWidth - StringWidth(fExpression.String()), BPoint(fWidth - StringWidth(fExpression.String()),
sizeDisp - baselineOffset)); sizeDisp - baselineOffset));
}
} // end if
// ****** KEYPAD Area // ****** KEYPAD Area
if (updateRect.Intersects(keypadRect)){ if (updateRect.Intersects(keypadRect)) {
// TODO: support pressed keys
// paint keypad b/g // paint keypad b/g
SetHighColor(fBaseColor); SetHighColor(fBaseColor);
@@ -249,32 +248,32 @@ CalcView::Draw(BRect updateRect)
// render cols // render cols
AddLine(BPoint(0.0, sizeDisp), AddLine(BPoint(0.0, sizeDisp),
BPoint(0.0, fHeight), BPoint(0.0, fHeight),
fLightColor);
for (int col = 1; col < fColums; col++){
AddLine(BPoint(col * sizeCol - 1.0, sizeDisp),
BPoint(col * sizeCol - 1.0, fHeight),
fDarkColor);
AddLine(BPoint(col * sizeCol, sizeDisp),
BPoint(col * sizeCol, fHeight),
fLightColor); fLightColor);
} // end for for (int col = 1; col < fColums; col++) {
AddLine(BPoint(col * sizeCol - 1.0, sizeDisp),
BPoint(col * sizeCol - 1.0, fHeight),
fDarkColor);
AddLine(BPoint(col * sizeCol, sizeDisp),
BPoint(col * sizeCol, fHeight),
fLightColor);
}
AddLine(BPoint(fColums * sizeCol, sizeDisp), AddLine(BPoint(fColums * sizeCol, sizeDisp),
BPoint(fColums * sizeCol, fHeight), BPoint(fColums * sizeCol, fHeight),
fDarkColor); fDarkColor);
// render rows // render rows
for (int row = 0; row < fRows; row++){ for (int row = 0; row < fRows; row++) {
AddLine(BPoint(0.0, sizeDisp + row * sizeRow - 1.0), AddLine(BPoint(0.0, sizeDisp + row * sizeRow - 1.0),
BPoint(fWidth, sizeDisp + row * sizeRow - 1.0), BPoint(fWidth, sizeDisp + row * sizeRow - 1.0),
fDarkColor); fDarkColor);
AddLine(BPoint(0.0, sizeDisp + row * sizeRow), AddLine(BPoint(0.0, sizeDisp + row * sizeRow),
BPoint(fWidth, sizeDisp + row * sizeRow), BPoint(fWidth, sizeDisp + row * sizeRow),
fLightColor); fLightColor);
} // end for }
AddLine(BPoint(0.0, sizeDisp + fRows * sizeRow), AddLine(BPoint(0.0, sizeDisp + fRows * sizeRow),
BPoint(fWidth, sizeDisp + fRows * sizeRow), BPoint(fWidth, sizeDisp + fRows * sizeRow),
fDarkColor); fDarkColor);
// main grid complete // main grid complete
EndLineArray(); EndLineArray();
@@ -286,20 +285,18 @@ CalcView::Draw(BRect updateRect)
SetDrawingMode(B_OP_COPY); SetDrawingMode(B_OP_COPY);
SetFontSize(((fHeight - sizeDisp)/(float)fRows) * K_FONT_YPROP); SetFontSize(((fHeight - sizeDisp)/(float)fRows) * K_FONT_YPROP);
float baselineOffset = ((fHeight - sizeDisp)/(float)fRows) float baselineOffset = ((fHeight - sizeDisp)/(float)fRows)
* (1.0 - K_FONT_YPROP) * 0.5; * (1.0 - K_FONT_YPROP) * 0.5;
CalcKey *key = fKeypad; CalcKey *key = fKeypad;
for (int row = 0; row < fRows; row++){ for (int row = 0; row < fRows; row++) {
for (int col = 0; col < fColums; col++){ for (int col = 0; col < fColums; col++) {
float halfSymbolWidth = StringWidth(key->label) * 0.5f; float halfSymbolWidth = StringWidth(key->label) * 0.5f;
DrawString(key->label, DrawString(key->label,
BPoint(col * sizeCol + halfSizeCol - halfSymbolWidth, BPoint(col * sizeCol + halfSizeCol - halfSymbolWidth,
sizeDisp + (row + 1) * sizeRow - baselineOffset)); sizeDisp + (row + 1) * sizeRow - baselineOffset));
key++; key++;
} // end for }
} // end for }
}
} // end if
} }
@@ -329,7 +326,7 @@ CalcView::MouseDown(BPoint point)
// click on display, initiate drag if appropriate // click on display, initiate drag if appropriate
if ((point.y - sizeDisp) < 0.0) { if ((point.y - sizeDisp) < 0.0) {
// only drag if there's some text // only drag if there's some text
if (fExpression.Length() > 0){ if (fExpression.Length() > 0) {
// assemble drag message // assemble drag message
BMessage dragmsg(B_MIME_DATA); BMessage dragmsg(B_MIME_DATA);
dragmsg.AddData("text/plain", dragmsg.AddData("text/plain",