Some fixes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1343 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marc Flerackers
2002-10-02 12:06:16 +00:00
parent a0cbca4f9f
commit fb4bf99df7
+30 -12
View File
@@ -26,6 +26,7 @@
// Standard Includes ----------------------------------------------------------- // Standard Includes -----------------------------------------------------------
#include <string.h> #include <string.h>
#include <malloc.h>
// System Includes ------------------------------------------------------------- // System Includes -------------------------------------------------------------
#include <Control.h> #include <Control.h>
@@ -101,10 +102,10 @@ BControl::BControl(BRect frame, const char *name, const char *label, BMessage *m
fLabel = strdup(label); fLabel = strdup(label);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BControl::~BControl () BControl::~BControl()
{ {
if ( fLabel ) if (fLabel)
delete fLabel; free(fLabel);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
BControl::BControl(BMessage *archive) : BView(archive) BControl::BControl(BMessage *archive) : BView(archive)
@@ -175,7 +176,13 @@ status_t BControl::Archive(BMessage *archive, bool deep) const
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BControl::WindowActivated(bool active) void BControl::WindowActivated(bool active)
{ {
// TODO: redraw if focus // Should we check this?
if (Window())
{
Draw(Bounds());
Flush();
}
BView::WindowActivated(active); BView::WindowActivated(active);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@@ -184,7 +191,7 @@ void BControl::AttachedToWindow()
if (Parent()) if (Parent())
SetViewColor(Parent()->ViewColor()); SetViewColor(Parent()->ViewColor());
if ( Target() == NULL) if (Target() == NULL)
BInvoker::SetTarget(BMessenger(Window(), NULL)); BInvoker::SetTarget(BMessenger(Window(), NULL));
BView::AttachedToWindow(); BView::AttachedToWindow();
@@ -277,10 +284,13 @@ void BControl::MakeFocus(bool focused)
{ {
BView::MakeFocus(focused); BView::MakeFocus(focused);
fFocusChanging = true; if(Window())
Draw(Bounds()); {
Flush(); fFocusChanging = true;
fFocusChanging = false; Draw(Bounds());
Flush();
fFocusChanging = false;
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void BControl::KeyDown(const char *bytes, int32 numBytes) void BControl::KeyDown(const char *bytes, int32 numBytes)
@@ -351,7 +361,7 @@ void BControl::DetachedFromWindow()
void BControl::SetLabel(const char *string) void BControl::SetLabel(const char *string)
{ {
if (fLabel) if (fLabel)
delete fLabel; free(fLabel);
fLabel = strdup(string); fLabel = strdup(string);
@@ -370,7 +380,11 @@ void BControl::SetValue(int32 value)
fValue = value; fValue = value;
Invalidate(); if (Window())
{
Draw(Bounds());
Flush();
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
int32 BControl::Value() const int32 BControl::Value() const
@@ -390,7 +404,11 @@ void BControl::SetEnabled(bool enabled)
else else
BView::SetFlags(Flags() & ~B_NAVIGABLE); BView::SetFlags(Flags() & ~B_NAVIGABLE);
Invalidate(); if (Window())
{
Draw(Bounds());
Flush();
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool BControl::IsEnabled() const bool BControl::IsEnabled() const