MenuField layouts the menu bar better with respect to fDivider, it aligns better with other controls. fDivider in TextControl is an integer number now, small fix and small cleanup in Menu, Window::InitData takes an optional BBitmap token to construct an offscreen window, fixed PrivateScreen IndexForColor, View prevents being located at fractional coordinates as in R5, BBitmap unlocks its offscreen window since it is never Show()n and needs manual unlocking, fixed Slider offscreen window mode and improved triange thumb drawing, ScrollView would not crash when passing a NULL target just for kicks, the private MenuBar class now implements Draw to draw itself a little differently inside the BMenuField (dark right and bottom side) - though how it currently sets the clipping region prevents the text controls to draw in Playground, needs fixing

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13450 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2005-07-05 16:30:53 +00:00
parent b2086a9ba0
commit 2e6a5805ba
14 changed files with 227 additions and 108 deletions
+21 -19
View File
@@ -25,6 +25,7 @@
//------------------------------------------------------------------------------
// Standard Includes -----------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -55,7 +56,7 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
InitMenu(menu);
frame.OffsetTo(0.0f, 0.0f);
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 2.0f,
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 1.0,
frame.top + kVMargin, frame.right - 2.0f, frame.bottom - kVMargin),
false, this);
@@ -80,7 +81,7 @@ BMenuField::BMenuField(BRect frame, const char *name, const char *label,
fFixedSizeMB = fixed_size;
frame.OffsetTo(0.0f, 0.0f);
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 2.0f,
fMenuBar = new _BMCMenuBar_(BRect(frame.left + fDivider + 1.0,
frame.top + kVMargin, frame.right - 2.0f, frame.bottom - kVMargin),
fixed_size, this);
@@ -194,10 +195,8 @@ void BMenuField::Draw(BRect update)
if (IsFocus())
active = Window()->IsActive();
/*
SetHighColor(0, 255, 0);
FillRect(bounds);
*/
//SetHighColor(255, 0, 0);
//FillRect(bounds);
DrawLabel(bounds, update);
@@ -286,7 +285,7 @@ void BMenuField::KeyDown(const char *bytes, int32 numBytes)
bounds = Bounds();
bounds.right = fDivider;
Draw(bounds);
Invalidate(bounds);
}
default:
BView::KeyDown(bytes, numBytes);
@@ -300,8 +299,8 @@ void BMenuField::MakeFocus(bool state)
BView::MakeFocus(state);
if(Window())
Draw(Bounds()); // TODO: use fStringWidth
if (Window())
Invalidate(); // TODO: use fStringWidth
}
//------------------------------------------------------------------------------
void BMenuField::MessageReceived(BMessage *msg)
@@ -314,7 +313,7 @@ void BMenuField::WindowActivated(bool state)
BView::WindowActivated(state);
if (IsFocus())
Draw(Bounds());
Invalidate();
}
//------------------------------------------------------------------------------
void BMenuField::MouseUp(BPoint pt)
@@ -417,15 +416,19 @@ alignment BMenuField::Alignment() const
return fAlign;
}
//------------------------------------------------------------------------------
void BMenuField::SetDivider(float dividing_line)
void BMenuField::SetDivider(float divider)
{
if (fDivider - dividing_line == 0.0f)
divider = floorf(divider + 0.5);
float dx = fDivider - divider;
if (dx == 0.0f)
return;
MenuBar()->MoveBy(dividing_line - fDivider, 0.0f);
MenuBar()->ResizeBy(fDivider - dividing_line, 0.0f);
fDivider = divider;
fDivider = dividing_line;
MenuBar()->MoveBy(-dx, 0.0f);
MenuBar()->ResizeBy(dx, 0.0f);
}
//------------------------------------------------------------------------------
float BMenuField::Divider() const
@@ -560,14 +563,13 @@ long BMenuField::MenuTask(void *arg)
menuField->fSelected = true;
menuField->fTransition = true;
menuField->Draw(menuField->Bounds());
menuField->Invalidate();
menuField->UnlockLooper();
bool tracking;
do
{
do {
snooze(20000);
if (!menuField->LockLooper())
@@ -583,7 +585,7 @@ long BMenuField::MenuTask(void *arg)
menuField->fSelected = false;
menuField->fTransition = true;
menuField->Draw(menuField->Bounds());
menuField->Invalidate();
menuField->UnlockLooper();