* Copyright fixed

* Indentation updated.
* Better grouping of methods.

+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32702 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-08-26 12:22:10 +00:00
parent 13e50c47a2
commit 6eb37bdef7
2 changed files with 222 additions and 192 deletions
+80 -74
View File
@@ -1,10 +1,11 @@
/* /*
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved. * Copyright 2003-2009, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT license.
*/ */
#ifndef _MENU_BAR_H #ifndef _MENU_BAR_H
#define _MENU_BAR_H #define _MENU_BAR_H
#include <BeBuild.h> #include <BeBuild.h>
#include <InterfaceDefs.h> #include <InterfaceDefs.h>
#include <Menu.h> #include <Menu.h>
@@ -24,87 +25,92 @@ class BMenuField;
class BMenuBar : public BMenu { class BMenuBar : public BMenu {
public: public:
BMenuBar(BRect frame, const char *title, BMenuBar(BRect frame, const char* title,
uint32 resizeMask = B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, uint32 resizeMask = B_FOLLOW_LEFT_RIGHT
menu_layout layout = B_ITEMS_IN_ROW, | B_FOLLOW_TOP,
bool resizeToFit = true); menu_layout layout = B_ITEMS_IN_ROW,
BMenuBar(const char *title, menu_layout layout = B_ITEMS_IN_ROW, bool resizeToFit = true);
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS); BMenuBar(const char* title,
BMenuBar(BMessage *data); menu_layout layout = B_ITEMS_IN_ROW,
virtual ~BMenuBar(); uint32 flags = B_WILL_DRAW
| B_FRAME_EVENTS);
BMenuBar(BMessage* archive);
virtual ~BMenuBar();
static BArchivable* Instantiate(BMessage *data); static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage *data, bool deep = true) const; virtual status_t Archive(BMessage* archive,
bool deep = true) const;
virtual void SetBorder(menu_bar_border border); virtual void AttachedToWindow();
menu_bar_border Border() const; virtual void DetachedFromWindow();
virtual void AllAttached();
virtual void Draw(BRect updateRect); virtual void AllDetached();
virtual void AttachedToWindow();
virtual void DetachedFromWindow(); virtual void WindowActivated(bool state);
virtual void MessageReceived(BMessage *message); virtual void MakeFocus(bool state = true);
virtual void MouseDown(BPoint where);
virtual void WindowActivated(bool state); virtual void ResizeToPreferred();
virtual void MouseUp(BPoint where); virtual void GetPreferredSize(float* _width,
virtual void FrameMoved(BPoint newPosition); float* _height);
virtual void FrameResized(float newWidth, float newHeight); virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float newWidth, float newHeight);
virtual void Show();
virtual void Hide();
virtual void Draw(BRect updateRect);
virtual void MessageReceived(BMessage *message);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint where);
virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage* specifier,
int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
virtual void SetBorder(menu_bar_border border);
menu_bar_border Border() const;
virtual void Show(); virtual status_t Perform(perform_code code, void* data);
virtual void Hide();
virtual BHandler* ResolveSpecifier(BMessage *message, int32 index, private:
BMessage *specifier, int32 form, friend class BWindow;
const char *property); friend class BMenuField;
virtual status_t GetSupportedSuites(BMessage *data); friend class BMenu;
virtual void ResizeToPreferred(); virtual void _ReservedMenuBar1();
virtual void GetPreferredSize(float *width, float *height); virtual void _ReservedMenuBar2();
virtual void MakeFocus(bool state = true); virtual void _ReservedMenuBar3();
virtual void AllAttached(); virtual void _ReservedMenuBar4();
virtual void AllDetached();
// layout related BMenuBar &operator=(const BMenuBar &);
virtual BSize MinSize();
virtual BSize MaxSize();
virtual BSize PreferredSize();
virtual status_t Perform(perform_code code, void *arg); // TODO: Tracker uses this function so we can't change
// its signature without breaking it
void StartMenuBar(int32 menuIndex,
bool sticky = true, bool showMenu = false,
BRect* special_rect = NULL);
static int32 _TrackTask(void *arg);
BMenuItem* _Track(int32 *action, int32 startIndex = -1,
bool showMenu = false);
void _StealFocus();
void _RestoreFocus();
void _InitData(menu_layout layout);
private: menu_bar_border fBorder;
friend class BWindow; thread_id fTrackingPID;
friend class BMenuField; int32 fPrevFocusToken;
friend class BMenu; sem_id fMenuSem;
BRect* fLastBounds;
uint32 _reserved[2];
virtual void _ReservedMenuBar1(); bool fTracking;
virtual void _ReservedMenuBar2();
virtual void _ReservedMenuBar3();
virtual void _ReservedMenuBar4();
BMenuBar &operator=(const BMenuBar &);
// TODO: Tracker uses this function so we can't change
// its signature without breaking it
void StartMenuBar(int32 menuIndex, bool sticky = true,
bool showMenu = false,
BRect *special_rect = NULL);
static int32 _TrackTask(void *arg);
BMenuItem *_Track(int32 *action, int32 startIndex = -1,
bool showMenu = false);
void _StealFocus();
void _RestoreFocus();
void _InitData(menu_layout layout);
menu_bar_border fBorder;
thread_id fTrackingPID;
int32 fPrevFocusToken;
sem_id fMenuSem;
BRect* fLastBounds;
uint32 _reserved[2]; // was 3
bool fTracking;
}; };
+142 -118
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2001-2009, Haiku, Inc. * Copyright 2001-2009, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
* Marc Flerackers ([email protected]) * Marc Flerackers ([email protected])
@@ -133,17 +133,140 @@ BMenuBar::Archive(BMessage* data, bool deep) const
} }
// #pragma mark -
void void
BMenuBar::SetBorder(menu_bar_border border) BMenuBar::AttachedToWindow()
{ {
fBorder = border; _Install(Window());
Window()->SetKeyMenuBar(this);
BMenu::AttachedToWindow();
*fLastBounds = Bounds();
} }
menu_bar_border void
BMenuBar::Border() const BMenuBar::DetachedFromWindow()
{ {
return fBorder; BMenu::DetachedFromWindow();
}
void
BMenuBar::AllAttached()
{
BMenu::AllAttached();
}
void
BMenuBar::AllDetached()
{
BMenu::AllDetached();
}
void
BMenuBar::WindowActivated(bool state)
{
BView::WindowActivated(state);
}
void
BMenuBar::MakeFocus(bool state)
{
BMenu::MakeFocus(state);
}
// #pragma mark -
void
BMenuBar::ResizeToPreferred()
{
BMenu::ResizeToPreferred();
}
void
BMenuBar::GetPreferredSize(float* width, float* height)
{
BMenu::GetPreferredSize(width, height);
}
BSize
BMenuBar::MinSize()
{
return BMenu::MinSize();
}
BSize
BMenuBar::MaxSize()
{
BSize size = BMenu::MaxSize();
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
BSize(B_SIZE_UNLIMITED, size.height));
}
BSize
BMenuBar::PreferredSize()
{
return BMenu::PreferredSize();
}
void
BMenuBar::FrameMoved(BPoint newPosition)
{
BMenu::FrameMoved(newPosition);
}
void
BMenuBar::FrameResized(float newWidth, float newHeight)
{
// invalidate right border
if (newWidth != fLastBounds->Width()) {
BRect rect(min_c(fLastBounds->right, newWidth), 0,
max_c(fLastBounds->right, newWidth), newHeight);
Invalidate(rect);
}
// invalidate bottom border
if (newHeight != fLastBounds->Height()) {
BRect rect(0, min_c(fLastBounds->bottom, newHeight) - 1,
newWidth, max_c(fLastBounds->bottom, newHeight));
Invalidate(rect);
}
fLastBounds->Set(0, 0, newWidth, newHeight);
BMenu::FrameResized(newWidth, newHeight);
}
// #pragma mark -
void
BMenuBar::Show()
{
BView::Show();
}
void
BMenuBar::Hide()
{
BView::Hide();
} }
@@ -198,23 +321,7 @@ BMenuBar::Draw(BRect updateRect)
} }
void // #pragma mark -
BMenuBar::AttachedToWindow()
{
_Install(Window());
Window()->SetKeyMenuBar(this);
BMenu::AttachedToWindow();
*fLastBounds = Bounds();
}
void
BMenuBar::DetachedFromWindow()
{
BMenu::DetachedFromWindow();
}
void void
@@ -240,13 +347,6 @@ BMenuBar::MouseDown(BPoint where)
} }
void
BMenuBar::WindowActivated(bool state)
{
BView::WindowActivated(state);
}
void void
BMenuBar::MouseUp(BPoint where) BMenuBar::MouseUp(BPoint where)
{ {
@@ -254,48 +354,7 @@ BMenuBar::MouseUp(BPoint where)
} }
void // #pragma mark -
BMenuBar::FrameMoved(BPoint newPosition)
{
BMenu::FrameMoved(newPosition);
}
void
BMenuBar::FrameResized(float newWidth, float newHeight)
{
// invalidate right border
if (newWidth != fLastBounds->Width()) {
BRect rect(min_c(fLastBounds->right, newWidth), 0,
max_c(fLastBounds->right, newWidth), newHeight);
Invalidate(rect);
}
// invalidate bottom border
if (newHeight != fLastBounds->Height()) {
BRect rect(0, min_c(fLastBounds->bottom, newHeight) - 1,
newWidth, max_c(fLastBounds->bottom, newHeight));
Invalidate(rect);
}
fLastBounds->Set(0, 0, newWidth, newHeight);
BMenu::FrameResized(newWidth, newHeight);
}
void
BMenuBar::Show()
{
BView::Show();
}
void
BMenuBar::Hide()
{
BView::Hide();
}
BHandler* BHandler*
@@ -313,39 +372,24 @@ BMenuBar::GetSupportedSuites(BMessage* data)
} }
void // #pragma mark -
BMenuBar::ResizeToPreferred()
{
BMenu::ResizeToPreferred();
}
void void
BMenuBar::GetPreferredSize(float* width, float* height) BMenuBar::SetBorder(menu_bar_border border)
{ {
BMenu::GetPreferredSize(width, height); fBorder = border;
} }
void menu_bar_border
BMenuBar::MakeFocus(bool state) BMenuBar::Border() const
{ {
BMenu::MakeFocus(state); return fBorder;
} }
void // #pragma mark -
BMenuBar::AllAttached()
{
BMenu::AllAttached();
}
void
BMenuBar::AllDetached()
{
BMenu::AllDetached();
}
status_t status_t
@@ -404,29 +448,6 @@ BMenuBar::Perform(perform_code code, void* _data)
} }
BSize
BMenuBar::MinSize()
{
return BMenu::MinSize();
}
BSize
BMenuBar::MaxSize()
{
BSize size = BMenu::MaxSize();
return BLayoutUtils::ComposeSize(ExplicitMaxSize(),
BSize(B_SIZE_UNLIMITED, size.height));
}
BSize
BMenuBar::PreferredSize()
{
return BMenu::PreferredSize();
}
// #pragma mark - // #pragma mark -
@@ -443,6 +464,9 @@ BMenuBar::operator=(const BMenuBar &)
} }
// #pragma mark -
void void
BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu, BMenuBar::StartMenuBar(int32 menuIndex, bool sticky, bool showMenu,
BRect* specialRect) BRect* specialRect)