Changed a bit the behaviour of BOptionPopUp::SetValue(). We now differ a bit from what R5 does. The old implementation is still there and just ifdeffed out, though.
Added some private unimplemented methods I had forgot, fixed some spelling errors, finished documenting what was missing. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5989 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Copyright (c) 2003 Stefano Ceccherini
|
// Copyright (c) 2003-2004 Stefano Ceccherini
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -42,11 +42,19 @@ BOptionControl::BOptionControl(BRect frame, const char *name, const char *label,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Destructor
|
||||||
|
It does nothing.
|
||||||
|
*/
|
||||||
BOptionControl::~BOptionControl()
|
BOptionControl::~BOptionControl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Overrides the base version to take special actions.
|
||||||
|
\param message The received message.
|
||||||
|
Calls SetValue() if receives a B_OPTION_CONTROL_VALUE message
|
||||||
|
which contains a "be:value" int32
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
BOptionControl::MessageReceived(BMessage *message)
|
BOptionControl::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
@@ -83,7 +91,7 @@ BOptionControl::AddOption(const char *name, int32 value)
|
|||||||
\param value The value of the option.
|
\param value The value of the option.
|
||||||
\return \c B_OK if there was an option with that value,
|
\return \c B_OK if there was an option with that value,
|
||||||
and it was correctly selected, an error code otherwise.
|
and it was correctly selected, an error code otherwise.
|
||||||
It works exactly as SetValue(value);
|
It works like SetValue(value);
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
BOptionControl::SelectOptionFor(int32 value)
|
BOptionControl::SelectOptionFor(int32 value)
|
||||||
@@ -91,10 +99,10 @@ BOptionControl::SelectOptionFor(int32 value)
|
|||||||
// XXX: I wonder why this method was created in the first place,
|
// XXX: I wonder why this method was created in the first place,
|
||||||
// since you can obtain the same result simply by calling SetValue().
|
// since you can obtain the same result simply by calling SetValue().
|
||||||
// The only difference I can see is that this method iterates over
|
// The only difference I can see is that this method iterates over
|
||||||
// all the options contained in the contrl, and thens elects the right one.
|
// all the options contained in the control, and then selects the right one.
|
||||||
int32 numOptions = CountOptions();
|
int32 numOptions = CountOptions();
|
||||||
for (int32 c = 0; c < numOptions; c++) {
|
for (int32 c = 0; c < numOptions; c++) {
|
||||||
const char *name;
|
const char *name = NULL;
|
||||||
int32 optionValue;
|
int32 optionValue;
|
||||||
if (GetOptionAt(c, &name, &optionValue) && optionValue == value) {
|
if (GetOptionAt(c, &name, &optionValue) && optionValue == value) {
|
||||||
SetValue(optionValue);
|
SetValue(optionValue);
|
||||||
@@ -146,6 +154,28 @@ BOptionControl::MakeValueMessage(int32 value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Private unimplemented
|
||||||
|
BOptionControl::BOptionControl()
|
||||||
|
:
|
||||||
|
BControl(BRect(), "", "", NULL, 0, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOptionControl::BOptionControl(const BOptionControl & clone)
|
||||||
|
:
|
||||||
|
BControl(BRect(), "", "", NULL, 0, 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOptionControl &
|
||||||
|
BOptionControl::operator=(const BOptionControl & clone)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// FBC
|
// FBC
|
||||||
status_t BOptionControl::_Reserved_OptionControl_0(void *, ...) { return B_ERROR; }
|
status_t BOptionControl::_Reserved_OptionControl_0(void *, ...) { return B_ERROR; }
|
||||||
status_t BOptionControl::_Reserved_OptionControl_1(void *, ...) { return B_ERROR; }
|
status_t BOptionControl::_Reserved_OptionControl_1(void *, ...) { return B_ERROR; }
|
||||||
|
|||||||
@@ -29,10 +29,16 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
// If enabled, behaves like in BeOS R5, in that when you call
|
||||||
|
// SelectOptionFor() or SetValue(), the selected item isn't marked, and
|
||||||
|
// so SelectedOption() will return -1. This is broken, IMHO.
|
||||||
|
#define BEHAVE_LIKE_R5 0
|
||||||
|
|
||||||
const float kLabelSpace = 8.0;
|
const float kLabelSpace = 8.0;
|
||||||
const float kWidthModifier = 25.0;
|
const float kWidthModifier = 25.0;
|
||||||
const float kHeightModifier = 10.0;
|
const float kHeightModifier = 10.0;
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Creates and initializes a BOptionPopUp.
|
/*! \brief Creates and initializes a BOptionPopUp.
|
||||||
\param frame The frame of the control.
|
\param frame The frame of the control.
|
||||||
\param name The name of the control.
|
\param name The name of the control.
|
||||||
@@ -57,7 +63,8 @@ BOptionPopUp::BOptionPopUp(BRect frame, const char *name, const char *label,
|
|||||||
\param name The name of the control.
|
\param name The name of the control.
|
||||||
\param label The label which will be displayed by the control.
|
\param label The label which will be displayed by the control.
|
||||||
\param message The message which the control will send when operated.
|
\param message The message which the control will send when operated.
|
||||||
\param fixed ?
|
\param fixed It's passed to the BMenuField constructor. If it's true,
|
||||||
|
the BMenuField size will never change.
|
||||||
\param resize Resizing flags. They will be passed to the base class.
|
\param resize Resizing flags. They will be passed to the base class.
|
||||||
\param flags View flags. They will be passed to the base class.
|
\param flags View flags. They will be passed to the base class.
|
||||||
*/
|
*/
|
||||||
@@ -146,6 +153,7 @@ BOptionPopUp::CountOptions() const
|
|||||||
return (menu != NULL) ? menu->CountItems() : 0;
|
return (menu != NULL) ? menu->CountItems() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Adds an option to the control, at the given position.
|
/*! \brief Adds an option to the control, at the given position.
|
||||||
\param name The name of the option to add.
|
\param name The name of the option to add.
|
||||||
\param value The value of the option.
|
\param value The value of the option.
|
||||||
@@ -232,11 +240,12 @@ BOptionPopUp::SetValue(int32 value)
|
|||||||
int32 val;
|
int32 val;
|
||||||
item->Message()->FindInt32("be:value", &val);
|
item->Message()->FindInt32("be:value", &val);
|
||||||
if (val == value) {
|
if (val == value) {
|
||||||
// TODO: This double call is needed because SetValue() doesn't mark
|
|
||||||
// items which are selected. Is there a better way to select
|
|
||||||
// an item without marking it ?
|
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
|
|
||||||
|
#if BEHAVE_LIKE_R5
|
||||||
item->SetMarked(false);
|
item->SetMarked(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,6 +340,29 @@ BOptionPopUp::SelectedOption(const char **outName, int32 *outValue) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Private Unimplemented
|
||||||
|
BOptionPopUp::BOptionPopUp()
|
||||||
|
:
|
||||||
|
BOptionControl(BRect(), "", "", NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOptionPopUp::BOptionPopUp(const BOptionPopUp &clone)
|
||||||
|
:
|
||||||
|
BOptionControl(clone.Frame(), "", "", clone.Message())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOptionPopUp &
|
||||||
|
BOptionPopUp::operator=(const BOptionPopUp & clone)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FBC Stuff
|
||||||
status_t BOptionPopUp::_Reserved_OptionControl_0(void *, ...) { return B_ERROR; }
|
status_t BOptionPopUp::_Reserved_OptionControl_0(void *, ...) { return B_ERROR; }
|
||||||
status_t BOptionPopUp::_Reserved_OptionControl_1(void *, ...) { return B_ERROR; }
|
status_t BOptionPopUp::_Reserved_OptionControl_1(void *, ...) { return B_ERROR; }
|
||||||
status_t BOptionPopUp::_Reserved_OptionControl_2(void *, ...) { return B_ERROR; }
|
status_t BOptionPopUp::_Reserved_OptionControl_2(void *, ...) { return B_ERROR; }
|
||||||
|
|||||||
Reference in New Issue
Block a user