Fixed compilation and applied our style guide.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8220 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+292
-249
@@ -1,250 +1,293 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2001-2002, OpenBeOS
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
|
||||||
// to deal in the Software without restriction, including without limitation
|
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
// and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
// Software is furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
// DEALINGS IN THE SOFTWARE.
|
|
||||||
//
|
|
||||||
// File Name: PopUpMenu.cpp
|
|
||||||
// Author: Marc Flerackers ([email protected])
|
|
||||||
// Description: BPopUpMenu represents a menu that pops up when you
|
|
||||||
// activate it.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Standard Includes -----------------------------------------------------------
|
|
||||||
#include "typeinfo.h"
|
|
||||||
|
|
||||||
// System Includes -------------------------------------------------------------
|
|
||||||
#include "PopUpMenu.h"
|
|
||||||
#include "MenuItem.h"
|
|
||||||
|
|
||||||
// Project Includes ------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Includes --------------------------------------------------------------
|
|
||||||
|
|
||||||
// Local Defines ---------------------------------------------------------------
|
|
||||||
|
|
||||||
// Globals ---------------------------------------------------------------------
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
|
// Copyright (c) 2001-2004, Haiku
|
||||||
menu_layout layout)
|
//
|
||||||
: BMenu(title, layout),
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
fUseWhere(false),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
fAutoDestruct(false),
|
// to deal in the Software without restriction, including without limitation
|
||||||
fTrackThread(-1)
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
{
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
if (radioMode)
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
SetRadioMode(true);
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
if (autoRename)
|
// all copies or substantial portions of the Software.
|
||||||
SetLabelFromMarked(true);
|
//
|
||||||
}
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
//------------------------------------------------------------------------------
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
BPopUpMenu::BPopUpMenu(BMessage *archive)
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
: BMenu(archive),
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
fUseWhere(false),
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
fAutoDestruct(false),
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
fTrackThread(-1)
|
// DEALINGS IN THE SOFTWARE.
|
||||||
{
|
//
|
||||||
}
|
// File Name: PopUpMenu.cpp
|
||||||
//------------------------------------------------------------------------------
|
// Author: Marc Flerackers ([email protected])
|
||||||
BPopUpMenu::~BPopUpMenu()
|
// Description: BPopUpMenu represents a menu that pops up when you
|
||||||
{
|
// activate it.
|
||||||
/*if (fTrackThread != 0)
|
//------------------------------------------------------------------------------
|
||||||
{
|
|
||||||
while (wait_for_thread() == );
|
#include "PopUpMenu.h"
|
||||||
}*/
|
#include "MenuItem.h"
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t BPopUpMenu::Archive(BMessage *data, bool deep) const
|
BPopUpMenu::BPopUpMenu(const char *title, bool radioMode, bool autoRename,
|
||||||
{
|
menu_layout layout)
|
||||||
return BMenu::Archive(data, deep);
|
: BMenu(title, layout),
|
||||||
}
|
fUseWhere(false),
|
||||||
//------------------------------------------------------------------------------
|
fAutoDestruct(false),
|
||||||
BArchivable *BPopUpMenu::Instantiate(BMessage *data)
|
fTrackThread(-1)
|
||||||
{
|
{
|
||||||
if (validate_instantiation(data, "BPopUpMenu"))
|
if (radioMode)
|
||||||
return new BPopUpMenu(data);
|
SetRadioMode(true);
|
||||||
else
|
|
||||||
return NULL;
|
if (autoRename)
|
||||||
}
|
SetLabelFromMarked(true);
|
||||||
//------------------------------------------------------------------------------
|
}
|
||||||
BMenuItem *BPopUpMenu::Go(BPoint where, bool delivers_message, bool open_anyway,
|
|
||||||
bool async)
|
|
||||||
{
|
BPopUpMenu::BPopUpMenu(BMessage *archive)
|
||||||
//return _go(where, delivers_message, open_anyway, NULL, async);
|
: BMenu(archive),
|
||||||
|
fUseWhere(false),
|
||||||
if (async)
|
fAutoDestruct(false),
|
||||||
{
|
fTrackThread(-1)
|
||||||
fWhere = where;
|
{
|
||||||
fUseWhere = true;
|
}
|
||||||
Show();
|
|
||||||
}
|
|
||||||
else
|
BPopUpMenu::~BPopUpMenu()
|
||||||
{
|
{
|
||||||
}
|
/*if (fTrackThread != 0)
|
||||||
|
{
|
||||||
return NULL;
|
while (wait_for_thread() == );
|
||||||
}
|
}*/
|
||||||
//------------------------------------------------------------------------------
|
}
|
||||||
BMenuItem *BPopUpMenu::Go(BPoint where, bool delivers_message, bool open_anyway,
|
|
||||||
BRect click_to_open, bool async)
|
|
||||||
{
|
status_t
|
||||||
//return _go(where, delivers_message, open_anyway, click_to_open, async);
|
BPopUpMenu::Archive(BMessage *data, bool deep) const
|
||||||
|
{
|
||||||
return NULL;
|
return BMenu::Archive(data, deep);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BPopUpMenu::MessageReceived(BMessage *msg)
|
|
||||||
{
|
BArchivable *
|
||||||
BMenu::MessageReceived(msg);
|
BPopUpMenu::Instantiate(BMessage *data)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
if (validate_instantiation(data, "BPopUpMenu"))
|
||||||
void BPopUpMenu::MouseDown(BPoint pt)
|
return new BPopUpMenu(data);
|
||||||
{
|
|
||||||
BMenu::MouseDown(pt);
|
return NULL;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BPopUpMenu::MouseUp(BPoint pt)
|
|
||||||
{
|
BMenuItem *
|
||||||
BMenu::MouseUp(pt);
|
BPopUpMenu::Go(BPoint where, bool delivers_message, bool open_anyway, bool async)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
//return _go(where, delivers_message, open_anyway, NULL, async);
|
||||||
void BPopUpMenu::MouseMoved(BPoint pt, uint32 code, const BMessage *msg)
|
|
||||||
{
|
if (async) {
|
||||||
BMenu::MouseMoved(pt, code, msg);
|
fWhere = where;
|
||||||
}
|
fUseWhere = true;
|
||||||
//------------------------------------------------------------------------------
|
Show();
|
||||||
void BPopUpMenu::AttachedToWindow()
|
}
|
||||||
{
|
|
||||||
BMenu::AttachedToWindow();
|
return NULL;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BPopUpMenu::DetachedFromWindow()
|
|
||||||
{
|
BMenuItem *
|
||||||
BMenu::DetachedFromWindow();
|
BPopUpMenu::Go(BPoint where, bool deliversMessage, bool openAnyway,
|
||||||
}
|
BRect clickToOpen, bool async)
|
||||||
//------------------------------------------------------------------------------
|
{
|
||||||
void BPopUpMenu::FrameMoved(BPoint new_position)
|
//return _go(where, deliversMessage, openAnyway, clickToOpen, async);
|
||||||
{
|
|
||||||
BMenu::FrameMoved(new_position);
|
return NULL;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BPopUpMenu::FrameResized(float new_width, float new_height)
|
|
||||||
{
|
void
|
||||||
BMenu::FrameResized(new_width, new_height);
|
BPopUpMenu::MessageReceived(BMessage *msg)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
BMenu::MessageReceived(msg);
|
||||||
BHandler *BPopUpMenu::ResolveSpecifier(BMessage *msg, int32 index,
|
}
|
||||||
BMessage *specifier, int32 form,
|
|
||||||
const char *property)
|
|
||||||
{
|
void
|
||||||
return BMenu::ResolveSpecifier(msg, index, specifier, form, property);
|
BPopUpMenu::MouseDown(BPoint point)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
BMenu::MouseDown(point);
|
||||||
status_t BPopUpMenu::GetSupportedSuites(BMessage *data)
|
}
|
||||||
{
|
|
||||||
return BMenu::GetSupportedSuites(data);
|
|
||||||
}
|
void
|
||||||
//------------------------------------------------------------------------------
|
BPopUpMenu::MouseUp(BPoint point)
|
||||||
status_t BPopUpMenu::Perform(perform_code d, void *arg)
|
{
|
||||||
{
|
BMenu::MouseUp(point);
|
||||||
return BMenu::Perform(d, arg);
|
}
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BPopUpMenu::ResizeToPreferred()
|
void
|
||||||
{
|
BPopUpMenu::MouseMoved(BPoint point, uint32 code, const BMessage *msg)
|
||||||
BMenu::ResizeToPreferred();
|
{
|
||||||
}
|
BMenu::MouseMoved(point, code, msg);
|
||||||
//------------------------------------------------------------------------------
|
}
|
||||||
void BPopUpMenu::GetPreferredSize(float *width, float *height)
|
|
||||||
{
|
|
||||||
BMenu::GetPreferredSize(width, height);
|
void
|
||||||
}
|
BPopUpMenu::AttachedToWindow()
|
||||||
//------------------------------------------------------------------------------
|
{
|
||||||
void BPopUpMenu::MakeFocus(bool state)
|
BMenu::AttachedToWindow();
|
||||||
{
|
}
|
||||||
BMenu::MakeFocus(state);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
void
|
||||||
void BPopUpMenu::AllAttached()
|
BPopUpMenu::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
BMenu::AllAttached();
|
BMenu::DetachedFromWindow();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void BPopUpMenu::AllDetached()
|
|
||||||
{
|
void
|
||||||
BMenu::AllDetached();
|
BPopUpMenu::FrameMoved(BPoint newPosition)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
BMenu::FrameMoved(newPosition);
|
||||||
void BPopUpMenu::SetAsyncAutoDestruct(bool state)
|
}
|
||||||
{
|
|
||||||
fAutoDestruct = state;
|
|
||||||
}
|
void
|
||||||
//------------------------------------------------------------------------------
|
BPopUpMenu::FrameResized(float newWidth, float newHeight)
|
||||||
bool BPopUpMenu::AsyncAutoDestruct() const
|
{
|
||||||
{
|
BMenu::FrameResized(newWidth, newHeight);
|
||||||
return fAutoDestruct;
|
}
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
BPoint BPopUpMenu::ScreenLocation()
|
BHandler *
|
||||||
{
|
BPopUpMenu::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
|
||||||
if (fUseWhere)
|
int32 form, const char *property)
|
||||||
return fWhere;
|
{
|
||||||
|
return BMenu::ResolveSpecifier(msg, index, specifier, form, property);
|
||||||
BMenuItem *item = Superitem();
|
}
|
||||||
BMenu *menu = Supermenu();
|
|
||||||
BMenuItem *selectedItem = FindItem(item->Label());
|
|
||||||
BRect rect = item->Frame();
|
status_t
|
||||||
BPoint point = rect.LeftTop();
|
BPopUpMenu::GetSupportedSuites(BMessage *data)
|
||||||
|
{
|
||||||
menu->ConvertToScreen(&point);
|
return BMenu::GetSupportedSuites(data);
|
||||||
|
}
|
||||||
if (selectedItem)
|
|
||||||
point.y -= selectedItem->Frame().top;
|
|
||||||
|
status_t
|
||||||
return point;
|
BPopUpMenu::Perform(perform_code d, void *arg)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
return BMenu::Perform(d, arg);
|
||||||
void BPopUpMenu::_ReservedPopUpMenu1() {}
|
}
|
||||||
void BPopUpMenu::_ReservedPopUpMenu2() {}
|
|
||||||
void BPopUpMenu::_ReservedPopUpMenu3() {}
|
|
||||||
//------------------------------------------------------------------------------
|
void
|
||||||
BPopUpMenu &BPopUpMenu::operator=(const BPopUpMenu &)
|
BPopUpMenu::ResizeToPreferred()
|
||||||
{
|
{
|
||||||
return *this;
|
BMenu::ResizeToPreferred();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
BMenuItem *BPopUpMenu::_go(BPoint where, bool autoInvoke,
|
|
||||||
bool start_opened, BRect *special_rect,
|
void
|
||||||
bool async)
|
BPopUpMenu::GetPreferredSize(float *_width, float *_height)
|
||||||
{
|
{
|
||||||
return NULL;
|
BMenu::GetPreferredSize(_width, _height);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
int32 BPopUpMenu::entry(void *)
|
|
||||||
{
|
void
|
||||||
return -1;
|
BPopUpMenu::MakeFocus(bool state)
|
||||||
}
|
{
|
||||||
//------------------------------------------------------------------------------
|
BMenu::MakeFocus(state);
|
||||||
BMenuItem *BPopUpMenu::start_track(BPoint where, bool autoInvoke,
|
}
|
||||||
bool start_opened, BRect *special_rect)
|
|
||||||
{
|
|
||||||
return NULL;
|
void
|
||||||
}
|
BPopUpMenu::AllAttached()
|
||||||
//------------------------------------------------------------------------------
|
{
|
||||||
|
BMenu::AllAttached();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPopUpMenu::AllDetached()
|
||||||
|
{
|
||||||
|
BMenu::AllDetached();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BPopUpMenu::SetAsyncAutoDestruct(bool state)
|
||||||
|
{
|
||||||
|
fAutoDestruct = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BPopUpMenu::AsyncAutoDestruct() const
|
||||||
|
{
|
||||||
|
return fAutoDestruct;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BPoint
|
||||||
|
BPopUpMenu::ScreenLocation()
|
||||||
|
{
|
||||||
|
if (fUseWhere)
|
||||||
|
return fWhere;
|
||||||
|
|
||||||
|
BMenuItem *item = Superitem();
|
||||||
|
BMenu *menu = Supermenu();
|
||||||
|
BMenuItem *selectedItem = FindItem(item->Label());
|
||||||
|
BRect rect = item->Frame();
|
||||||
|
BPoint point = rect.LeftTop();
|
||||||
|
|
||||||
|
menu->ConvertToScreen(&point);
|
||||||
|
|
||||||
|
if (selectedItem)
|
||||||
|
point.y -= selectedItem->Frame().top;
|
||||||
|
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// #pragma mark -
|
||||||
|
// private methods
|
||||||
|
|
||||||
|
|
||||||
|
void BPopUpMenu::_ReservedPopUpMenu1() {}
|
||||||
|
void BPopUpMenu::_ReservedPopUpMenu2() {}
|
||||||
|
void BPopUpMenu::_ReservedPopUpMenu3() {}
|
||||||
|
|
||||||
|
|
||||||
|
BPopUpMenu &
|
||||||
|
BPopUpMenu::operator=(const BPopUpMenu &)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMenuItem *
|
||||||
|
BPopUpMenu::_go(BPoint where, bool autoInvoke, bool startOpened,
|
||||||
|
BRect *_specialRect, bool async)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
BPopUpMenu::entry(void *)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BMenuItem *
|
||||||
|
BPopUpMenu::start_track(BPoint where, bool autoInvoke,
|
||||||
|
bool startOpened, BRect *_specialRect)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user