BMenu now does even work correctly and doesn't flicker anymore. Submenus does not yet, though, and sticky mode is not yed supported.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10553 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2004-12-30 15:37:33 +00:00
parent b0d01b5f78
commit efa306a09d
+17 -68
View File
@@ -35,7 +35,6 @@
#include <MenuWindow.h> #include <MenuWindow.h>
#include <stdio.h> #include <stdio.h>
#define CALLED() printf("%s\n", __PRETTY_FUNCTION__);
#ifndef COMPILE_FOR_R5 #ifndef COMPILE_FOR_R5
menu_info BMenu::sMenuInfo; menu_info BMenu::sMenuInfo;
@@ -239,7 +238,6 @@ BMenu::Archive(BMessage *data, bool deep) const
void void
BMenu::AttachedToWindow() BMenu::AttachedToWindow()
{ {
CALLED();
BView::AttachedToWindow(); BView::AttachedToWindow();
LayoutItems(0); LayoutItems(0);
@@ -249,7 +247,6 @@ BMenu::AttachedToWindow()
void void
BMenu::DetachedFromWindow() BMenu::DetachedFromWindow()
{ {
CALLED();
BView::DetachedFromWindow(); BView::DetachedFromWindow();
} }
@@ -292,7 +289,8 @@ BMenu::AddItem(BMenuItem *item, BRect frame)
{ {
if (!item) if (!item)
return false; return false;
frame.PrintToStream();
item->fBounds = frame; item->fBounds = frame;
return AddItem(item, CountItems()); return AddItem(item, CountItems());
@@ -690,7 +688,6 @@ BMenu::GetPreferredSize(float *width, float *height)
void void
BMenu::ResizeToPreferred() BMenu::ResizeToPreferred()
{ {
CALLED();
BView::ResizeToPreferred(); BView::ResizeToPreferred();
} }
@@ -698,7 +695,6 @@ BMenu::ResizeToPreferred()
void void
BMenu::FrameMoved(BPoint new_position) BMenu::FrameMoved(BPoint new_position)
{ {
CALLED();
BView::FrameMoved(new_position); BView::FrameMoved(new_position);
} }
@@ -706,7 +702,6 @@ BMenu::FrameMoved(BPoint new_position)
void void
BMenu::FrameResized(float new_width, float new_height) BMenu::FrameResized(float new_width, float new_height)
{ {
CALLED();
BView::FrameResized(new_width, new_height); BView::FrameResized(new_width, new_height);
} }
@@ -799,7 +794,6 @@ BMenu::Perform(perform_code d, void *arg)
void void
BMenu::MakeFocus(bool focused) BMenu::MakeFocus(bool focused)
{ {
CALLED();
BView::MakeFocus(focused); BView::MakeFocus(focused);
} }
@@ -807,7 +801,6 @@ BMenu::MakeFocus(bool focused)
void void
BMenu::AllAttached() BMenu::AllAttached()
{ {
CALLED();
BView::AllAttached(); BView::AllAttached();
} }
@@ -815,7 +808,6 @@ BMenu::AllAttached()
void void
BMenu::AllDetached() BMenu::AllDetached()
{ {
CALLED();
BView::AllDetached(); BView::AllDetached();
} }
@@ -850,7 +842,6 @@ BMenu::BMenu(BRect frame, const char *name, uint32 resizingMode, uint32 flags,
fRedrawAfterSticky(true), fRedrawAfterSticky(true),
fAttachAborted(false) fAttachAborted(false)
{ {
CALLED();
InitData(NULL); InitData(NULL);
} }
@@ -903,7 +894,6 @@ BMenu::GetItemMargins(float *left, float *top, float *right,
menu_layout menu_layout
BMenu::Layout() const BMenu::Layout() const
{ {
CALLED();
return fLayout; return fLayout;
} }
@@ -911,7 +901,6 @@ BMenu::Layout() const
void void
BMenu::Show() BMenu::Show()
{ {
CALLED();
Show(false); Show(false);
} }
@@ -919,7 +908,6 @@ BMenu::Show()
void void
BMenu::Show(bool selectFirst) BMenu::Show(bool selectFirst)
{ {
CALLED();
_show(selectFirst); _show(selectFirst);
} }
@@ -927,7 +915,6 @@ BMenu::Show(bool selectFirst)
void void
BMenu::Hide() BMenu::Hide()
{ {
CALLED();
_hide(); _hide();
} }
@@ -935,7 +922,6 @@ BMenu::Hide()
BMenuItem * BMenuItem *
BMenu::Track(bool openAnyway, BRect *clickToOpenRect) BMenu::Track(bool openAnyway, BRect *clickToOpenRect)
{ {
CALLED();
if (IsStickyPrefOn()) if (IsStickyPrefOn())
openAnyway = false; openAnyway = false;
@@ -947,7 +933,7 @@ BMenu::Track(bool openAnyway, BRect *clickToOpenRect)
} }
int action; int action;
return BMenu::_track(&action, -1); return _track(&action, -1);
} }
@@ -984,7 +970,6 @@ BMenu::DrawBackground(BRect update)
void void
BMenu::SetTrackingHook(menu_tracking_hook func, void *state) BMenu::SetTrackingHook(menu_tracking_hook func, void *state)
{ {
CALLED();
} }
@@ -1031,7 +1016,6 @@ BMenu::InitData(BMessage *data)
bool bool
BMenu::_show(bool selectFirstItem) BMenu::_show(bool selectFirstItem)
{ {
CALLED();
BPoint point = ScreenLocation(); BPoint point = ScreenLocation();
BWindow *window = new BMenuWindow(BRect(point.x, point.y, BWindow *window = new BMenuWindow(BRect(point.x, point.y,
@@ -1046,7 +1030,6 @@ BMenu::_show(bool selectFirstItem)
void void
BMenu::_hide() BMenu::_hide()
{ {
CALLED();
BWindow *window = Window(); BWindow *window = Window();
if (window) { if (window) {
@@ -1060,42 +1043,35 @@ BMenu::_hide()
BMenuItem * BMenuItem *
BMenu::_track(int *action, long start) BMenu::_track(int *action, long start)
{ {
CALLED(); // TODO: Take Sticky mode into account
BPoint location; BPoint location;
ulong buttons; ulong buttons;
BMenuItem *item = NULL; BMenuItem *item = NULL;
do { do {
if (LockLooper()) { if (LockLooper()) {
GetMouse(&location, &buttons); GetMouse(&location, &buttons);
if (OverSuper(location)) {
UnlockLooper();
break;
}
item = HitTestItems(location); item = HitTestItems(location);
if (item == NULL) {
UnlockLooper();
break;
}
if (item && fSelected != item) { if (item && fSelected != item) {
SelectItem(item); SelectItem(item);
/*if (fSelected)
fSelected->Select(false);
fSelected = item;
item->Select(true);
*/
Invalidate();
Window()->UpdateIfNeeded();
} }
Draw(Bounds());
UnlockLooper(); UnlockLooper();
} }
snooze(50000); snooze(50000);
} while (buttons != 0); } while (buttons != 0);
if (action != NULL) { if (action != NULL) {
if (item != NULL) if (buttons != 0)
*action = 5;
else
*action = 0; *action = 0;
else
*action = 5;
} }
return item; return item;
@@ -1205,7 +1181,6 @@ BMenu::ComputeLayout(int32 index, bool bestFit, bool moveItems,
BRect BRect
BMenu::Bump(BRect current, BPoint extent, int32 index) const BMenu::Bump(BRect current, BPoint extent, int32 index) const
{ {
CALLED();
return BRect(); return BRect();
} }
@@ -1213,7 +1188,6 @@ BMenu::Bump(BRect current, BPoint extent, int32 index) const
BPoint BPoint
BMenu::ItemLocInRect(BRect frame) const BMenu::ItemLocInRect(BRect frame) const
{ {
CALLED();
return BPoint(); return BPoint();
} }
@@ -1221,7 +1195,6 @@ BMenu::ItemLocInRect(BRect frame) const
BRect BRect
BMenu::CalcFrame(BPoint where, bool *scrollOn) BMenu::CalcFrame(BPoint where, bool *scrollOn)
{ {
CALLED();
return BRect(); return BRect();
} }
@@ -1229,7 +1202,6 @@ BMenu::CalcFrame(BPoint where, bool *scrollOn)
bool bool
BMenu::ScrollMenu(BRect bounds, BPoint loc, bool *fast) BMenu::ScrollMenu(BRect bounds, BPoint loc, bool *fast)
{ {
CALLED();
return false; return false;
} }
@@ -1237,7 +1209,6 @@ BMenu::ScrollMenu(BRect bounds, BPoint loc, bool *fast)
void void
BMenu::ScrollIntoView(BMenuItem *item) BMenu::ScrollIntoView(BMenuItem *item)
{ {
CALLED();
} }
@@ -1256,7 +1227,6 @@ BMenu::DrawItems(BRect updateRect)
int int
BMenu::State(BMenuItem **item) const BMenu::State(BMenuItem **item) const
{ {
CALLED();
return 0; return 0;
} }
@@ -1264,7 +1234,6 @@ BMenu::State(BMenuItem **item) const
void void
BMenu::InvokeItem(BMenuItem *item, bool now) BMenu::InvokeItem(BMenuItem *item, bool now)
{ {
CALLED();
if (item->Submenu()) if (item->Submenu())
item->Submenu()->Show(); item->Submenu()->Show();
else if (IsRadioMode()) else if (IsRadioMode())
@@ -1277,8 +1246,6 @@ BMenu::InvokeItem(BMenuItem *item, bool now)
bool bool
BMenu::OverSuper(BPoint loc) BMenu::OverSuper(BPoint loc)
{ {
CALLED();
ConvertToScreen(&loc); ConvertToScreen(&loc);
if (!Supermenu()) if (!Supermenu())
@@ -1291,7 +1258,6 @@ BMenu::OverSuper(BPoint loc)
bool bool
BMenu::OverSubmenu(BMenuItem *item, BPoint loc) BMenu::OverSubmenu(BMenuItem *item, BPoint loc)
{ {
CALLED();
// TODO: we assume that loc is in screen coords // TODO: we assume that loc is in screen coords
if (!item->Submenu()) if (!item->Submenu())
return false; return false;
@@ -1303,7 +1269,6 @@ BMenu::OverSubmenu(BMenuItem *item, BPoint loc)
BMenuWindow * BMenuWindow *
BMenu::MenuWindow() BMenu::MenuWindow()
{ {
CALLED();
return fCachedMenuWindow; return fCachedMenuWindow;
} }
@@ -1311,7 +1276,6 @@ BMenu::MenuWindow()
void void
BMenu::DeleteMenuWindow() BMenu::DeleteMenuWindow()
{ {
CALLED();
delete fCachedMenuWindow; delete fCachedMenuWindow;
fCachedMenuWindow = NULL; fCachedMenuWindow = NULL;
} }
@@ -1335,7 +1299,6 @@ BMenu::HitTestItems(BPoint where, BPoint slop) const
BRect BRect
BMenu::Superbounds() const BMenu::Superbounds() const
{ {
CALLED();
if (fSuper) if (fSuper)
return fSuper->Bounds(); return fSuper->Bounds();
@@ -1346,7 +1309,6 @@ BMenu::Superbounds() const
void void
BMenu::CacheFontInfo() BMenu::CacheFontInfo()
{ {
CALLED();
font_height fh; font_height fh;
GetFontHeight(&fh); GetFontHeight(&fh);
fAscent = fh.ascent; fAscent = fh.ascent;
@@ -1358,7 +1320,6 @@ BMenu::CacheFontInfo()
void void
BMenu::ItemMarked(BMenuItem *item) BMenu::ItemMarked(BMenuItem *item)
{ {
CALLED();
if (IsRadioMode()) { if (IsRadioMode()) {
for (int32 i = 0; i < CountItems(); i++) for (int32 i = 0; i < CountItems(); i++)
if (ItemAt(i) != item) if (ItemAt(i) != item)
@@ -1373,7 +1334,6 @@ BMenu::ItemMarked(BMenuItem *item)
void void
BMenu::Install(BWindow *target) BMenu::Install(BWindow *target)
{ {
CALLED();
for (int32 i = 0; i < CountItems(); i++) for (int32 i = 0; i < CountItems(); i++)
ItemAt(i)->Install(target); ItemAt(i)->Install(target);
} }
@@ -1382,7 +1342,6 @@ BMenu::Install(BWindow *target)
void void
BMenu::Uninstall() BMenu::Uninstall()
{ {
CALLED();
for (int32 i = 0; i < CountItems(); i++) for (int32 i = 0; i < CountItems(); i++)
ItemAt(i)->Uninstall(); ItemAt(i)->Uninstall();
} }
@@ -1391,14 +1350,12 @@ BMenu::Uninstall()
void void
BMenu::SelectItem(BMenuItem *m, uint32 showSubmenu,bool selectFirstItem) BMenu::SelectItem(BMenuItem *m, uint32 showSubmenu,bool selectFirstItem)
{ {
CALLED();
} }
BMenuItem * BMenuItem *
BMenu::CurrentSelection() const BMenu::CurrentSelection() const
{ {
CALLED();
return fSelected; return fSelected;
} }
@@ -1406,7 +1363,6 @@ BMenu::CurrentSelection() const
bool bool
BMenu::SelectNextItem(BMenuItem *item, bool forward) BMenu::SelectNextItem(BMenuItem *item, bool forward)
{ {
CALLED();
return false; return false;
} }
@@ -1414,7 +1370,6 @@ BMenu::SelectNextItem(BMenuItem *item, bool forward)
BMenuItem * BMenuItem *
BMenu::NextItem(BMenuItem *item, bool forward) const BMenu::NextItem(BMenuItem *item, bool forward) const
{ {
CALLED();
return NULL; return NULL;
} }
@@ -1422,7 +1377,6 @@ BMenu::NextItem(BMenuItem *item, bool forward) const
bool bool
BMenu::IsItemVisible(BMenuItem *item) const BMenu::IsItemVisible(BMenuItem *item) const
{ {
CALLED();
return false; return false;
} }
@@ -1430,7 +1384,6 @@ BMenu::IsItemVisible(BMenuItem *item) const
void void
BMenu::SetIgnoreHidden(bool on) BMenu::SetIgnoreHidden(bool on)
{ {
CALLED();
fIgnoreHidden = on; fIgnoreHidden = on;
} }
@@ -1452,14 +1405,12 @@ BMenu::IsStickyMode() const
void void
BMenu::CalcTriggers() BMenu::CalcTriggers()
{ {
CALLED();
} }
const char * const char *
BMenu::ChooseTrigger(const char *title, BList *chars) BMenu::ChooseTrigger(const char *title, BList *chars)
{ {
CALLED();
return NULL; return NULL;
} }
@@ -1467,7 +1418,6 @@ BMenu::ChooseTrigger(const char *title, BList *chars)
void void
BMenu::UpdateWindowViewSize(bool upWind) BMenu::UpdateWindowViewSize(bool upWind)
{ {
CALLED();
} }
@@ -1481,7 +1431,6 @@ BMenu::IsStickyPrefOn()
void void
BMenu::RedrawAfterSticky(BRect bounds) BMenu::RedrawAfterSticky(BRect bounds)
{ {
CALLED();
} }