Skip to content

Commit

Permalink
DeskCalc: Add private _IsEmbedded() method
Browse files Browse the repository at this point in the history
  • Loading branch information
jscipione committed Jul 13, 2013
1 parent d2577d7 commit 43f09ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/apps/deskcalc/CalcView.cpp
Expand Up @@ -315,12 +315,7 @@ CalcView::MessageReceived(BMessage* message)
void
CalcView::Draw(BRect updateRect)
{
bool drawBackground = true;
if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
// CalcView is embedded somewhere, most likely the Tracker Desktop
// shelf.
drawBackground = false;
}
bool drawBackground = !_IsEmbedded();

SetHighColor(fBaseColor);
BRect expressionRect(_ExpressionRect());
Expand Down Expand Up @@ -809,13 +804,16 @@ CalcView::SetDegreeMode(bool degrees)
void
CalcView::SetKeypadMode(uint8 mode)
{
if (fOptions->keypad_mode == mode)
if (_IsEmbedded())
return;

BWindow* window = Window();
if (window == NULL)
return;

if (fOptions->keypad_mode == mode)
return;

fOptions->keypad_mode = mode;
_MarkKeypadItems(fOptions->keypad_mode);

Expand Down Expand Up @@ -1278,3 +1276,12 @@ CalcView::_FetchAppIcon(BBitmap* into)
if (status != B_OK)
memset(into->Bits(), 0, into->BitsLength());
}


// Returns whether or not CalcView is embedded somewhere, most likely
// the Desktop
bool
CalcView::_IsEmbedded()
{
return Parent() != NULL && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0;
}
1 change: 1 addition & 0 deletions src/apps/deskcalc/CalcView.h
Expand Up @@ -117,6 +117,7 @@ class CalcView : public BView {
void _MarkKeypadItems(uint8 mode);

void _FetchAppIcon(BBitmap* into);
bool _IsEmbedded();

// grid dimensions
int16 fColumns;
Expand Down

0 comments on commit 43f09ad

Please sign in to comment.