// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <FUiWindow.h>
#include <FUiIActionEventListener.h>
+namespace Tizen { namespace Graphics
+{
+class Bitmap;
+}; };
+
namespace Tizen { namespace Ui { namespace Controls
{
/**
- * @if OSPDEPREC
+ * @enum OptionMenuItemStatus
+ *
+ * Defines the possible states of the %OptionMenu control item.
+ *
+ * @since 2.2
+ */
+enum OptionMenuItemStatus
+{
+ OPTION_MENU_ITEM_STATUS_NORMAL, /**< The normal state */
+ OPTION_MENU_ITEM_STATUS_PRESSED, /**< The pressed state */
+ OPTION_MENU_ITEM_STATUS_HIGHLIGHTED /**< The highlighted state */
+};
+
+
+/**
* @class OptionMenu
- * @brief <i> [Deprecated] </i> This class defines a common behavior for an %OptionMenu control.
+ * @brief This class defines a common behavior for an %OptionMenu control.
*
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* The %OptionMenu class defines a common behavior for an %OptionMenu control.
* An %OptionMenu is used to present users with multiple options. Hierarchical menu
// IActionEventListener
virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+ // KeyEventListener
+ virtual bool OnKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
+ virtual bool OnKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo);
+ virtual bool OnPreviewKeyPressed(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
+ virtual bool OnPreviewKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo) { return false; };
+
private:
- static const int ID_OPTIONKEY = 100;
static const int ID_OPTIONMENU_ITEM1 = 101;
static const int ID_OPTIONMENU_ITEM2 = 102;
bool
OptionMenuSample::Initialize()
{
- Construct(FORM_STYLE_OPTIONKEY|FORM_STYLE_NORMAL);
+ Construct(FORM_STYLE_NORMAL);
return true;
}
__pOptionMenu->Construct();
__pOptionMenu->AddItem("Item1",ID_OPTIONMENU_ITEM1);
__pOptionMenu->AddItem("Item2",ID_OPTIONMENU_ITEM2);
- SetOptionkeyActionId(ID_OPTIONKEY);
AddOptionkeyActionListener(*this);
return r;
{
switch (actionId)
{
- case ID_OPTIONKEY:
- {
- ShowOptionMenu();
- }
- break;
case ID_OPTIONMENU_ITEM1:
{
// ....
break;
}
}
+
+bool
+OptionMenuSample::OnKeyReleased(Tizen::Ui::Control& source, const Tizen::Ui::KeyEventInfo& keyEventInfo)
+{
+ if (keyEventInfo->GetKeyCode() == KEY_CONTEXT_MENU)
+ {
+ ShowOptionMenu();
+ }
+}
* @endcode
- * @endif
*/
class _OSP_EXPORT_ OptionMenu
: public Tizen::Ui::Window
{
public:
/**
- * @if OSPDEPREC
* The object is not fully constructed after this constructor is called. @n
* For full construction, the OptionMenu::Construct() method must be called right after calling this constructor.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
- * @endif
+ * @since 2.2
*/
OptionMenu(void);
/**
- * @if OSPDEPREC
* This polymorphic destructor should be overridden if required.@n
* This way, the destructors of the derived classes are called when the destructor of this interface is called.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
- * @endif
+ * @since 2.2
*/
virtual ~OptionMenu(void);
/**
- * @if OSPDEPREC
* Initializes this instance of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @exception E_SUCCESS The method is successful.
* @exception E_SYSTEM This method has failed.
- * @endif
*/
result Construct(void);
/**
- * @if OSPDEPREC
* Adds a listener instance to receive action events from this control. @n
* The added listener can listen to events on the given event dispatcher's context when they are fired.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @param[in] listener The event listener to add
- * @endif
*/
void AddActionEventListener(Tizen::Ui::IActionEventListener& listener);
/**
- * @if OSPDEPREC
* Removes the specified action event listener so that it no longer receives events from this control.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @param[in] listener The event listener to remove
- * @endif
*/
void RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
/**
- * @if OSPDEPREC
* Appends new item to the end of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] text The item to append
* @param[in] actionId The action ID
* @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit.
* @exception E_SYSTEM This method has failed.
* @remarks %OptionMenu can have a maximum of @c 12 main items.
- * @endif
*/
result AddItem(const Tizen::Base::String& text, int actionId);
- result AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId);\r
- result AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap=null, const Tizen::Graphics::Bitmap* pHighlightedBitmap=null);\r
/**
- * @if OSPDEPREC
+ * Appends the new item to the end of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] normalBitmap The normal bitmap of the item
+ * @param[in] pPressedBitmap The pressed bitmap of the item
+ * @param[in] pHighlightedBitmap The highlighted bitmap of the item
+ * @param[in] actionId The action ID
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit.
+ * @exception E_SYSTEM This method has failed.
+ * @remarks When a user navigates the user interface using the directional keys, @n
+ * the selected UI control is highlighted and the control takes the focus. @n
+ * %OptionMenu can have a maximum of @c 12 main items.
+ */
+ result AddItem (const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId);
+
+ /**
+ * Appends new item to the end of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] text The sting of the item to append
+ * @param[in] actionId The specified action ID for this item
+ * @param[in] normalBitmap The normal bitmap of the item
+ * @param[in] pPressedBitmap The pressed bitmap of the item
+ * @param[in] pHighlightedBitmap The highlighted bitmap of the item
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit.
+ * @remarks %OptionMenu can have a maximum of @c 12 main items.
+ */
+ result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap = null, const Tizen::Graphics::Bitmap* pHighlightedBitmap = null);
+
+ /**
* Inserts a specific item at the given index of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The main index
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM The method has failed.
* @remarks %OptionMenu can have a maximum of @c 12 main items.
- * @endif
*/
result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
/**
- * @if OSPDEPREC
+ * Inserts a specific item at the given index of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] mainIndex The main index
+ * @param[in] normalBitmap The normal bitmap of the item
+ * @param[in] pPressedBitmap The pressed bitmap of the item
+ * @param[in] pHighlightedBitmap The highlighted bitmap of the item
+ * @param[in] actionId The specified action ID for this item
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit.
+ * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
+ * @remarks When a user navigates the user interface using the directional keys, @n
+ * the selected UI control is highlighted and the control takes the focus. @n
+ * %OptionMenu can have a maximum of @c 12 main items.
+ */
+ result InsertItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId);
+
+ /**
+ * Inserts a specific item at the given index of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] mainIndex The main index
+ * @param[in] text The sting of the item to append
+ * @param[in] actionId The specified action ID for this item
+ * @param[in] normalBitmap The normal bitmap of the item
+ * @param[in] pPressedBitmap The pressed bitmap of the item
+ * @param[in] pHighlightedBitmap The highlighted bitmap of the item
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_MAX_EXCEEDED The total number of items has exceeded the maximum limit.
+ * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
+ * @exception E_SYSTEM The method has failed.
+ * @remarks %OptionMenu can have a maximum of @c 12 main items.
+ */
+ result InsertItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap=null, const Tizen::Graphics::Bitmap *pHighlightedBitmap=null);
+
+ /**
* Sets a specific item at the given index of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The main index
* @exception E_SUCCESS The method is successful.
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM The method has failed.
- * @endif
*/
result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
/**
- * @if OSPDEPREC
+ * Sets a specific item at the given index of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] mainIndex The main index
+ * @param[in] normalBitmap The normal bitmap of the item
+ * @param[in] pPressedBitmap The pressed bitmap of the item
+ * @param[in] pHighlightedBitmap The highlighted bitmap of the item
+ * @param[in] actionId The specified action ID for this item
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
+ * @remarks When a user navigates the user interface using the directional keys, @n
+ * the selected UI control is highlighted and the control takes the focus. @n
+ */
+ result SetItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId);
+
+ /**
+ * Sets a specific item at the given index of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] mainIndex The main index
+ * @param[in] text The string of the item to set
+ * @param[in] actionId The specified action ID for this item
+ * @param[in] normalBitmap The normal bitmap of the item
+ * @param[in] pPressedBitmap The pressed bitmap of the item
+ * @param[in] pHighlightedBitmap The highlighted bitmap of the item
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
+ */
+ result SetItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap=null, const Tizen::Graphics::Bitmap *pHighlightedBitmap=null);
+
+ /**
* Removes the item of the specified index from %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The main index
* @exception E_SUCCESS The method is successful.
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM This method has failed.
- * @endif
*/
result RemoveItemAt(int mainIndex);
/**
- * @if OSPDEPREC
+ * Removes all items from %OptionMenu.
+ *
+ * @since 2.2
+ */
+ void RemoveAllItems (void);
+
+ /**
* Gets the number of items registered for %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return The number of items registered for %OptionMenu
- * @endif
*/
int GetItemCount(void) const;
/**
- * @if OSPDEPREC
* Gets the index of the item with the specified action ID.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return The index of the item
* @param[in] actionId The action ID of the item
- * @endif
*/
int GetItemIndexFromActionId(int actionId) const;
/**
- * @if OSPDEPREC
* Gets the action ID of the item at the specified index.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return The action ID of the item
- * @param[in] mainIndex The index of the item
- * @endif
+ * @param[in] mainIndex The index of the item
*/
int GetItemActionIdAt(int mainIndex) const;
/**
- * @if OSPDEPREC
* Appends new sub-item to the end of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The index of the main item
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM This method has failed.
* @remarks %OptionMenu can have a maximum of @c 32 sub-items.
- * @endif
*/
result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId);
/**
- * @if OSPDEPREC
* Inserts a specific sub-item at the given index of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The index of the main item
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM This method has failed.
* @remarks %OptionMenu can have a maximum of @c 32 sub-items.
- * @endif
*/
result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
/**
- * @if OSPDEPREC
* Sets a specific sub-item at the given index of %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The index of the main item
* @exception E_SUCCESS The method is successful.
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM This method has failed.
- * @endif
*/
result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
/**
- * @if OSPDEPREC
* Removes the sub-item of the specified index from %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return An error code
* @param[in] mainIndex The index of the main item
* @exception E_SUCCESS The method is successful.
* @exception E_OUT_OF_RANGE The specified @c index is less than @c 0 or greater than @c 12.
* @exception E_SYSTEM This method has failed.
- * @endif
*/
result RemoveSubItemAt(int mainIndex, int subIndex);
/**
- * @if OSPDEPREC
* Gets the number of sub-items registered for %OptionMenu.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return The number of sub-items registered for %OptionMenu
* @param[in] mainIndex The index of the main item
- * @endif
*/
int GetSubItemCount(int mainIndex) const;
/**
- * @if OSPDEPREC
* Gets the index of the sub-item at the specified action ID.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return The index of the item
* @param[in] actionId The action ID of the item
- * @endif
*/
int GetSubItemIndexFromActionId(int actionId) const;
/**
- * @if OSPDEPREC
* Gets the action ID of the sub-item at the specified index.
*
- * @brief <i> [Deprecated] </i>
- * @deprecated This class is deprecated because the use of the %OptionMenu control is no longer recommended.
- * @since 2.0
+ * @since 2.2
*
* @return The action ID of the item
* @param[in] mainIndex The index of the main item
* @param[in] subIndex The index of the sub-item
- * @endif
*/
int GetSubItemActionIdAt(int mainIndex, int subIndex) const;
+ /**
+ * Sets the item text color of %OptionMenu for the specified status.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] status The item status
+ * @param[in] color The item text color to set
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid.
+ * @see GetItemTextColor()
+ */
+ result SetItemTextColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color);
+
+ /**
+ * Gets the item text color of %OptionMenu for the specified status.
+ *
+ * @since 2.2
+ *
+ * @return The item text color @n
+ * else RGBA (0,0,0,0) if an error occurs
+ * @param[in] status The item status
+ * @see SetItemTextColor()
+ */
+ Tizen::Graphics::Color GetItemTextColor(OptionMenuItemStatus status) const;
+
+ /**
+ * Sets the item color of %OptionMenu for the specified status.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] status The item status
+ * @param[in] color The item color to set
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_ARG The specified input parameter is invalid. @n
+ * The item color for @c OPTION_MENU_ITEM_STATUS_NORMAL is not supported.
+ * @remarks The item color for the @c OPTION_MENU_ITEM_STATUS_NORMAL status is always the same as the color of the %OptionMenu control.
+ * @see GetItemColor()
+ */
+ result SetItemColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color);
+
+ /**
+ * Gets the item color of %OptionMenu for the specified status.
+ *
+ * @since 2.2
+ *
+ * @return The item color, @n
+ * else RGBA(0, 0, 0, 0) if an error occurs
+ * @param[in] status The item status
+ */
+ Tizen::Graphics::Color GetItemColor(OptionMenuItemStatus status) const;
+
+ /**
+ * Sets the color of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] color The color to set
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_INVALID_STATE This instance is in an invalid state.
+ * @see GetColor()
+ */
+ result SetColor(const Tizen::Graphics::Color &color);
+
+ /**
+ * Gets the color of %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return The color of %OptionMenu, @n
+ * else RGBA(0, 0, 0, 0) if an error occurs
+ * @see SetColor()
+ */
+ Tizen::Graphics::Color GetColor(void) const;
+
+ /**
+ * Sets the maximum number of visible items for %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return An error code
+ * @param[in] maxItemsCount The maximum number of visible items
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_OUT_OF_RANGE The specified @c parameter is out of possible range.
+ * @remarks @c maxItemsCount should be greater than @c 0 and less than @c 8. The default value for
+ * the maximum number of the visible menu items is @c 5.
+ */
+ result SetMaxVisibleItemsCount(int maxItemsCount);
+
+ /**
+ * Gets the maximum number of visible items for %OptionMenu.
+ *
+ * @since 2.2
+ *
+ * @return The maximum number of visible items, @n
+ * else @c -1 if an error occurs
+ */
+ int GetMaxVisibleItemsCount(void) const;
+
private:
//
// The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
controls/FUiCtrl_OptionMenu.cpp
controls/FUiCtrl_OptionMenuModel.cpp
controls/FUiCtrl_OptionMenuPresenter.cpp
- controls/FUiCtrl_OptionMenuListPresenter.cpp\r
controls/FUiCtrl_OptionMenuItem.cpp
controls/FUiCtrl_Panel.cpp
controls/FUiCtrl_PanelPresenter.cpp
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <FBaseSysLog.h>
#include "FUiCtrl_OptionMenuImpl.h"
-#include "FUiCtrl_ContextMenuImpl.h"\r
using namespace Tizen::Base;
}
result
-OptionMenu::AddItem(const String& text, int actionId)
+OptionMenu::AddItem(const Tizen::Base::String& text, int actionId)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->AddItem(text, actionId, null, null, null);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+OptionMenu::AddItem (const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->AddItem(Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+OptionMenu::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)
{
ClearLastResult();
_OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
- result r = pOptionMenuImpl->AddItem(text, actionId);
+ result r = pOptionMenuImpl->AddItem(text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return r;
-}\r
-result\r
-OptionMenu::AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId)\r
-{\r
- ClearLastResult();\r
-\r
- _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);\r
- SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");\r
-\r
- result r = pOptionMenuImpl->AddItem(normalBitmap, pPressedBitmap, pHighlightedBitmap, actionId);\r
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
- return r;\r
-}\r
-\r
-result\r
-OptionMenu::AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
-{\r
- ClearLastResult();\r
-\r
- _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);\r
- SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");\r
-\r
- result r = pOptionMenuImpl->AddItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
- return r;\r
}
result
_OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
- result r = pOptionMenuImpl->InsertItemAt(mainIndex, text, actionId);
+ result r = pOptionMenuImpl->InsertItemAt(mainIndex, text, actionId, null, null, null);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return r;
}
result
+OptionMenu::InsertItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->InsertItemAt(mainIndex, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+OptionMenu::InsertItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap, const Tizen::Graphics::Bitmap *pHighlightedBitmap)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->InsertItemAt(mainIndex, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId)
{
ClearLastResult();
_OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
- result r = pOptionMenuImpl->SetItemAt(mainIndex, text, actionId);
+ result r = pOptionMenuImpl->SetItemAt(mainIndex, text, actionId, null, null, null);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return r;
}
result
+OptionMenu::SetItemAt (int mainIndex, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap *pPressedBitmap, const Tizen::Graphics::Bitmap*pHighlightedBitmap, int actionId)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->SetItemAt(mainIndex, Tizen::Base::String(""), actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
+OptionMenu::SetItemAt (int mainIndex, const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap &normalBitmap, const Tizen::Graphics::Bitmap*pPressedBitmap, const Tizen::Graphics::Bitmap *pHighlightedBitmap)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->SetItemAt(mainIndex, text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+result
OptionMenu::RemoveItemAt(int mainIndex)
{
ClearLastResult();
return r;
}
+void
+OptionMenu::RemoveAllItems (void)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ pOptionMenuImpl->RemoveAllItems();
+ result r = GetLastResult();
+ SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return;
+}
+
int
OptionMenu::GetItemCount(void) const
{
_OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
- result r = pOptionMenuImpl->AddSubItem(mainIndex, text, actionId);
+ result r = pOptionMenuImpl->AddSubItem(mainIndex, text, actionId);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return r;
return actionId;
}
+result
+OptionMenu::SetItemTextColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->SetItemTextColor(status, color);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+Tizen::Graphics::Color
+OptionMenu::GetItemTextColor(OptionMenuItemStatus status) const
+{
+ ClearLastResult();
+
+ const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ Tizen::Graphics::Color color = pOptionMenuImpl->GetItemTextColor(status);
+ result r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return color;
+}
+
+result
+OptionMenu::SetItemColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->SetItemColor(status, color);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+Tizen::Graphics::Color
+OptionMenu::GetItemColor(OptionMenuItemStatus status) const
+{
+ ClearLastResult();
+
+ const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ Tizen::Graphics::Color color = pOptionMenuImpl->GetItemColor(status);
+ result r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return color;
+}
+
+result
+OptionMenu::SetColor(const Tizen::Graphics::Color& color)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->SetColor(color);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+Tizen::Graphics::Color
+OptionMenu::GetColor(void) const
+{
+ ClearLastResult();
+
+ const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ Tizen::Graphics::Color color = pOptionMenuImpl->GetColor();
+ result r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), Tizen::Graphics::Color(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return color;
+}
+
+result
+OptionMenu::SetMaxVisibleItemsCount(int maxItemsCount)
+{
+ ClearLastResult();
+
+ _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ result r = pOptionMenuImpl->SetMaxVisibleItemsCount(maxItemsCount);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return r;
+}
+
+int
+OptionMenu::GetMaxVisibleItemsCount(void) const
+{
+ ClearLastResult();
+
+ const _OptionMenuImpl* pOptionMenuImpl = _OptionMenuImpl::GetInstance(*this);
+ SysAssertf((pOptionMenuImpl != null), "Not yet constructed. Construct() should be called before use.");
+
+ int count = pOptionMenuImpl->GetMaxVisibleItemsCount();
+ result r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), -1, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ return count;
+}
+
}}} //Tizen::Ui::Controls
if (__style == CONTEXT_MENU_CORE_STYLE_LIST)
{
- if (__anchorPoint.Equals(FloatPoint(-1.0f ,-1.0f)))\r
- {\r
- _IContextMenuPresenter* pPresenter = new (std::nothrow) _OptionMenuListPresenter(this);\r
- SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
-\r
- SetPresenter(*pPresenter);\r
-\r
- r = pPresenter->Install();\r
- }\r
- else\r
- {\r
_IContextMenuPresenter* pPresenter = new (std::nothrow) _ContextMenuListPresenter(this);
SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
SetPresenter(*pPresenter);
-
r = pPresenter->Install();
- }\r
}
else
{
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-
/**
* @file FUiCtrl_OptionMenu.cpp
* @brief This is the implementation file for the _OptionMenu class.
*/
+#include <FBaseErrorDefine.h>
+#include <FBaseSysLog.h>
+#include <FGrp_BitmapImpl.h>
#include <FBaseColIEnumeratorT.h>
-
-#include "FUiCtrl_OptionMenu.h"
-#include "FUiCtrl_OptionMenuPresenter.h"
-#include "FUiCtrl_ActionEvent.h"
-#include "FUiCtrl_ContextMenu.h"
-#include "FUiCtrl_Frame.h"
-#include "FUiCtrl_Form.h"
+#include "FUi_ControlImplManager.h"
+#include "FUi_ResourceManager.h"
#include "FUiAnim_VisualElement.h"
+#include "FUiAnim_AnimationManager.h"
#include "FUi_AccessibilityContainer.h"
#include "FUi_AccessibilityElement.h"
-#include "FUi_CoordinateSystemUtils.h"
-#include "FUi_ResourceManager.h"
+#include "FUiCtrl_ActionEvent.h"
+#include "FUiCtrl_Form.h"
+#include "FUiCtrl_Frame.h"
+#include "FUiCtrl_OptionMenu.h"
+#include "FUiCtrl_Scroll.h"
+#include "FUiCtrl_ContextMenu.h"
+#include "FUiCtrl_OptionMenuItem.h"
+#include "FUi_TouchManager.h"
-using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
-using namespace Tizen::Base::Runtime;
using namespace Tizen::Graphics;
-using namespace Tizen::Ui;
+using namespace Tizen::Media;
+using namespace Tizen::Ui::Animations;
+using namespace Tizen::Base::Runtime;
+
+namespace {
+static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
+}
namespace Tizen { namespace Ui { namespace Controls
{
+IMPLEMENT_PROPERTY(_OptionMenu);
+
_OptionMenu::_OptionMenu(void)
- : _Window()
- , __pOptionMenuPresenter(null)
+ : __pOptionMenuPresenter(null)
+ , __showItemCount(0)
+ , __showItemMaxCount(0)
+ , __isAttachedToMainTree(false)
+ , __ownerInputEnableState(false)
+ , __windowRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+ , __bodyRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+ , __itemRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
, __pActionEvent(null)
+ , __pBackgroundNormalBitmap(null)
+ , __pBackgroundEffectBitmap(null)
+ , __layout(_CONTROL_ORIENTATION_PORTRAIT)
+ , __pScrollPanel(null)
, __pSubMenu(null)
, __subMenuIndex(-1)
- , __currentFocusedIndex(-1)
- , __isFocused(false)
{
+ __backgroundColor = Color(255, 255, 255, 255);
+
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255);
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255);
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255);
+
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL] = Color(255, 255, 255, 255);
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED] = Color(255, 255, 255, 255);
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = Color(255, 255, 255, 255);
+
+ GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
}
_OptionMenu::~_OptionMenu(void)
{
- delete __pOptionMenuPresenter;
- __pOptionMenuPresenter = null;
+ if (__isAttachedToMainTree && GetOwner() != null)
+ {
+ GetOwner()->UnlockInputEvent();
+ }
- if (__pActionEvent != null)
+ if (__pScrollPanel)
{
- delete __pActionEvent;
- __pActionEvent = null;
+ __pScrollPanel->DetachAllChildren();
+ DetachChild(*__pScrollPanel);
+ delete __pScrollPanel;
+ __pScrollPanel = null;
}
if (__pSubMenu != null)
__pSubMenu = null;
}
+ delete __pOptionMenuPresenter;
+ __pOptionMenuPresenter = null;
+
+ if (__pBackgroundNormalBitmap != null)
+ {
+ delete __pBackgroundNormalBitmap;
+ __pBackgroundNormalBitmap = null;
+ }
+
+ if (__pBackgroundEffectBitmap != null)
+ {
+ delete __pBackgroundEffectBitmap;
+ __pBackgroundEffectBitmap = null;
+ }
+
+ if (__pActionEvent)
+ {
+ delete __pActionEvent;
+ __pActionEvent = null;
+ }
+
+ __actionId.RemoveAll();
+
RemoveAllAccessibilityElement();
}
_OptionMenu*
_OptionMenu::CreateOptionMenuN(void)
{
- _OptionMenu* pOptionMenu = new (std::nothrow) _OptionMenu;
- SysTryReturn(NID_UI_CTRL, (pOptionMenu != null), null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ _OptionMenu* pOptionMenu = new (std::nothrow) _OptionMenu();
+ SysTryReturn(NID_UI_CTRL, pOptionMenu != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- result r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r));
+ result r = E_SUCCESS;
r = pOptionMenu->CreateRootVisualElement();
SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
- pOptionMenu->AcquireHandle();
-
- SysTryCatch(NID_UI_CTRL, (pOptionMenu->GetVisualElement() != null), , E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. Failed to get _VisualElement instance.");
-
- pOptionMenu->__pOptionMenuPresenter = _OptionMenuPresenter::CreateInstanceN(*pOptionMenu);
- r = GetLastResult();
- SysTryCatch(NID_UI_CTRL, (pOptionMenu->__pOptionMenuPresenter != null), , r,
- "[%s] Propagating.", GetErrorMessage(r));
+ pOptionMenu->SetFocusable(true);
- r = pOptionMenu->__pOptionMenuPresenter->InitializeTextObject();
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pOptionMenu->Initialize();
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Initialize.", GetErrorMessage(r));
- r = pOptionMenu->__pOptionMenuPresenter->InitializeVisualElement();
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ r = pOptionMenu->Install();
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed to Install.", GetErrorMessage(r));
- pOptionMenu->__pActionEvent = _ActionEvent::CreateInstanceN(*pOptionMenu);
- r = GetLastResult();
- SysTryCatch(NID_UI_CTRL, (pOptionMenu->__pActionEvent != null), , r,
- "[%s] Propagating.", GetErrorMessage(r));
-
- // Set alpha merge to VisualElement
- pOptionMenu->GetVisualElement()->SetSurfaceOpaque(false);
- pOptionMenu->SetBackgroundColor(Color());
+ pOptionMenu->AcquireHandle();
+ pOptionMenu->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
- pOptionMenu->SetMovable(false);
- pOptionMenu->SetResizable(false);
+ pOptionMenu->SetMovable(false);
+ pOptionMenu->SetResizable(false);
if (pOptionMenu->GetAccessibilityContainer() != null)
{
pOptionMenu->GetAccessibilityContainer()->Activate(true);
+ pOptionMenu->GetAccessibilityContainer()->AddListener(*pOptionMenu);
+ }
+
+ {
+ float minWidth, minHeight; // for visible scrollbar when scrollable
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, minWidth);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, minHeight);
+ pOptionMenu->__pScrollPanel = _ScrollPanel::CreateScrollPanelN(FloatRectangle(0.0f, 0.0f, minWidth, minHeight), SCROLL_PANEL_SCROLL_DIRECTION_VERTICAL, false, false);
+ pOptionMenu->__pScrollPanel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
+
+ _Scroll* pScroll = pOptionMenu->__pScrollPanel->GetScrollBar();
+ SysTryCatch(NID_UI_CTRL, pScroll, , E_INVALID_STATE, "[E_INVALID_STATE] _Scroll isn't constructed");
+ pScroll->SetContextMenuScrollType(true);
+
+ pOptionMenu->AttachChild(*(pOptionMenu->__pScrollPanel));
}
+ GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, pOptionMenu->GetOrientation(), pOptionMenu->__showItemMaxCount);
+
+
return pOptionMenu;
+
CATCH:
delete pOptionMenu;
+
return null;
}
-result
-_OptionMenu::AddActionEventListener(const _IActionEventListener& listener)
+_ScrollPanel*
+_OptionMenu::GetScrollPanel(void)
{
- return __pActionEvent->AddListener(listener);
+ return __pScrollPanel;
}
-result
-_OptionMenu::RemoveActionEventListener(const _IActionEventListener& listener)
-{
- return __pActionEvent->RemoveListener(listener);
-}
+//bool
+//_OptionMenu::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+//{
+// AppLog("vipul : OnKeyPressed");
+// _KeyCode keyCode = keyInfo.GetKeyCode();
+
+// switch (keyCode)
+// {
+// case _KEY_ENTER:
+// {
+
+// }
+// break;
+// case _KEY_UP:
+// break;
+// case _KEY_DOWN:
+// break;
+// default:
+// break;
+
+// }
+
+// return __pOptionMenuPresenter->OnKeyPressed(source, keyInfo);
+//}
+
+//bool
+//_OptionMenu::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
+//{
+// AppLog("vipul : OnKeyReleased");
+// _KeyCode keyCode = keyInfo.GetKeyCode();
+
+// if (keyCode == _KEY_UP || keyCode == _KEY_DOWN || keyCode == _KEY_ENTER)
+// {
+// return true;
+// }
+
+// return false;
+//}
+
+//bool
+//_OptionMenu::OnFocusGained(const _Control &source)
+//{
+// AppLog("vipul : OnFocusGained");
+// //__pScrollPanel->SetFocused(true);
+// __pOptionMenuPresenter->OnFocusGained(source);
+
+// return true;
+//}
+
+//bool
+//_OptionMenu::OnFocusLost(const _Control &source)
+//{
+// AppLog("vipul : OnFocusLost");
+// //__pScrollPanel->SetFocused(false);
+// //__pOptionMenuPresenter->OnFocusLost(source);
+
+// return _Control::OnFocusLost(source);
+//}
+
+//void
+//_OptionMenu::OnDrawFocus(void)
+//{
+// AppLog("vipul : OnDrawFocus");
+// //__pOptionMenuPresenter->SetFocusState(true);
+// // __pOptionMenuPresenter->DrawFocus();
+// return;
+//}
+
+//void
+//_OptionMenu::OnFocusModeStateChanged(void)
+//{
+// AppLog("vipul : OnFocusModeStateChanged");
+// return;
+//}
+
+//bool
+//_OptionMenu::IsChildControlFocusManage(void) const
+//{
+// AppLog("vipul : IsChildControlFocusManage");
+// return true;
+//}
result
-_OptionMenu::FireActionEvent(int actionId)
+_OptionMenu::Install(void)
{
- IEventArg* pArg = _ActionEvent::CreateActionEventArgN(actionId);
- result r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pArg != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ result r = E_SUCCESS;
- r = __pActionEvent->Fire(*pArg);
+ // load bitmap of a background and arrow
+ r = LoadBitmap();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to load bitmap.");
+
+ r = __actionId.Construct();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct arraylist.");
+
+ _OptionMenuPresenter* pPresenter = new (std::nothrow) _OptionMenuPresenter(this);
+ SysTryReturnResult(NID_UI_CTRL, pPresenter != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+
+ SetPresenter(*pPresenter);
+
+ r = pPresenter->Install();
return r;
}
result
-_OptionMenu::AddItem(const String& text, int actionId)
+_OptionMenu::Initialize(void)
{
- result r = __pOptionMenuPresenter->AddItem(text, actionId);
+ FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
+ result r = E_SUCCESS;
+
+ Color backgroundColor;
+ Color backgroundSelectedColor;
+ Color itemTextColor;
+ Color itemTextSelectedColor;
+
+ r = SetBounds(FloatRectangle(0.0f, 0.0f, screen.width, screen.height));
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "SetBounds failed.");
- if (r == E_SUCCESS)
+ SetMovable(false);
+ SetResizable(false);
+
+ GET_COLOR_CONFIG(CONTEXTMENU::BG_NORMAL, backgroundColor);
+ GET_COLOR_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED, backgroundSelectedColor);
+ GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_NORMAL, itemTextColor);
+ GET_COLOR_CONFIG(CONTEXTMENU::ITEM_TEXT_PRESSED, itemTextSelectedColor);
+
+ __backgroundColor = backgroundColor;
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL] = backgroundColor;
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED] = backgroundSelectedColor;
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL] = itemTextColor;
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED] = itemTextSelectedColor;
+
+ if (GetVisualElement() != null)
{
- _AccessibilityContainer* pContainer = GetAccessibilityContainer();
- if (pContainer != null)
- {
- _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true);
- if (pElement != null)
- {
- pElement->SetLabel(text);
- pElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
- pElement->SetHint(L"Double tap to select");
-// pElement->SetTrait(ACCESSIBILITY_TRAITS_OPTIONMENU);
- pContainer->AddElement(*pElement);
- __accessibilityElements.Add(pElement);
- SetBoundsAllAccessibilityElement();
- }
- }
+ GetVisualElement()->SetSurfaceOpaque(false);
}
return r;
+
}
result
-_OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId)
+_OptionMenu::SetPresenter(const _OptionMenuPresenter& OptionMenuPresenter)
+{
+ __pOptionMenuPresenter = const_cast <_OptionMenuPresenter*>(&OptionMenuPresenter);
+
+ return E_SUCCESS;
+}
+
+void
+_OptionMenu::OnDraw()
{
- result r = __pOptionMenuPresenter->InsertItemAt(mainIndex, text, actionId);
+ __pOptionMenuPresenter->Draw();
- if (r == E_SUCCESS)
+ if(unlikely((_AccessibilityManager::IsActivated())))
{
- _AccessibilityContainer* pContainer = GetAccessibilityContainer();
- if (pContainer != null)
- {
- _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true);
- if (pElement != null)
- {
- pElement->SetLabel(text);
- pElement->SetTrait(ACCESSIBILITY_TRAITS_BUTTON);
- pElement->SetHint(L"Double tap to select");
-// pElement->SetTrait(ACCESSIBILITY_TRAITS_OPTIONMENU);
- pContainer->InsertElement(*pElement, mainIndex);
- __accessibilityElements.InsertAt(pElement, mainIndex);
- SetBoundsAllAccessibilityElement();
- }
- }
+ _AccessibilityManager::GetInstance()->RequestAutoReading(_ACCESSIBILITY_AUTO_READING_MODE_FIRST_ITEM);
}
-
- return r;
}
result
-_OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId)
+_OptionMenu::OnAttachedToMainTree(void)
{
- result r = __pOptionMenuPresenter->SetItemAt(mainIndex, text, actionId);
+ result r = E_SUCCESS;
- if (r == E_SUCCESS)
+ __layout = _ControlManager::GetInstance()->GetOrientation();
+ __isAttachedToMainTree = true;
+ _Control* pOwner = GetOwner();
+ if (pOwner == null)
{
- _AccessibilityElement* pElement = GetAccessibilityElement(mainIndex);
- if (pElement != null)
- {
- pElement->SetLabel(text);
- }
+ _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
+ SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Current frame instance is not available.");
+
+ _Form* pForm = pFrame->GetCurrentForm();
+ pForm != null ? SetOwner(pForm) : SetOwner(pFrame);
+
+ GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, __layout, __showItemMaxCount);
+ }
+ else
+ {
+ pOwner->LockInputEvent();
}
- return r;
+ if (GetItemCount() <= 0)
+ {
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ }
+
+ r = __pOptionMenuPresenter->CalculateWindowRect();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ r = Open();
+
+ SetVisibleState(true);
+
+ SetTouchCapture(false, false);
+
+ SetAllAccessibilityElement();
+
+ _VisualElement* pVisualElement = GetVisualElement();
+ FloatRectangle pBounds = pVisualElement->GetBounds();
+ float oldBoundsX = pBounds.x;
+ float oldBoundsY = pBounds.y;
+ float distanceX = 0.0f;
+ float distanceY = 0.0f;
+
+ GET_SHAPE_CONFIG(CONTEXTMENU::APPEARING_ANIMATION_DISTANCE_X, __layout, distanceX);
+ GET_SHAPE_CONFIG(CONTEXTMENU::APPEARING_ANIMATION_DISTANCE_Y, __layout, distanceY);
+
+ pVisualElement->SetBounds(pBounds);
+ pVisualElement->SetOpacity(0.0f);
+
+ bool enable = pVisualElement->IsImplicitAnimationEnabled();
+
+ pVisualElement->SetImplicitAnimationEnabled(true);
+
+ pBounds.x = oldBoundsX;
+ pBounds.y = oldBoundsY;
+ pVisualElement->SetBounds(pBounds);
+ pVisualElement->SetOpacity(1.0f);
+
+ pVisualElement->SetImplicitAnimationEnabled(enable);
+
+ return _Window::OnAttachedToMainTree();
}
result
-_OptionMenu::RemoveItemAt(int mainIndex)
+_OptionMenu::OnDetachingFromMainTree(void)
{
- result r = __pOptionMenuPresenter->RemoveItemAt(mainIndex);
- if (r == E_SUCCESS)
+ ReleaseTouchCapture();
+
+ _Control* pOwner = GetOwner();
+ if (pOwner != null)
{
- _AccessibilityContainer* pContainer = GetAccessibilityContainer();
- if (pContainer != null)
- {
- _AccessibilityElement* pElement = GetAccessibilityElement(mainIndex);
- if (pElement != null)
- {
- pContainer->RemoveElement(*pElement);
- __accessibilityElements.RemoveAt(mainIndex);
- SetBoundsAllAccessibilityElement();
- }
- }
+ pOwner->UnlockInputEvent();
}
+ __isAttachedToMainTree = false;
+
+ return _Window::OnDetachingFromMainTree();
+}
+
+result
+_OptionMenu::AddItem(const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
+{
+ result r = E_SUCCESS;
+
+ r = __pOptionMenuPresenter->AddItem(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item.");
+
+ __actionId.Add(actionId);
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
return r;
}
-int
-_OptionMenu::GetItemCount(void) const
+result
+_OptionMenu::InsertItemAt(int mainIndex, const String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- return __pOptionMenuPresenter->GetItemCount();
+ result r = E_SUCCESS;
+
+ r = __pOptionMenuPresenter->InsertItem(mainIndex, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to add a item.");
+
+ __actionId.InsertAt(actionId, mainIndex);
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ return r;
}
int
return __pOptionMenuPresenter->GetItemIndexFromActionId(actionId);
}
-int
-_OptionMenu::GetItemActionIdAt(int mainIndex) const
+result
+_OptionMenu::SetItemAt(int mainIndex, const String& text, int actionId, const Bitmap* pNormalBitmap, const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- return __pOptionMenuPresenter->GetItemActionIdAt(mainIndex);
+ result r = E_SUCCESS;
+
+ r = __pOptionMenuPresenter->SetItem(mainIndex, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item.");
+
+ __actionId.SetAt(actionId, mainIndex);
+
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ return r;
}
result
if (__pSubMenu != null && mainIndex == __subMenuIndex)
{
- __pSubMenu->AddItem(text, actionId, null, null, null);
+ __pSubMenu->AddItem(text, actionId, null, null, null);
}
return E_SUCCESS;
}
result
_OptionMenu::InsertSubItemAt(int mainIndex, int subIndex, const String& text, int actionId)
{
- result r = __pOptionMenuPresenter->InsertSubItemAt(mainIndex, subIndex, text, actionId);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ result r = __pOptionMenuPresenter->InsertSubItemAt(mainIndex, subIndex, text, actionId);
+ SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
- if (__pSubMenu != null && mainIndex == __subMenuIndex)
- {
- __pSubMenu->InsertItem(subIndex, text, actionId, null, null, null);
- }
+ if (__pSubMenu != null && mainIndex == __subMenuIndex)
+ {
+ __pSubMenu->InsertItem(subIndex, text, actionId, null, null, null);
+ }
- return E_SUCCESS;
+ return E_SUCCESS;
}
result
if (__pSubMenu != null && mainIndex == __subMenuIndex)
{
- __pSubMenu->SetItem(subIndex, text, actionId, null, null, null);
+ __pSubMenu->SetItem(subIndex, text, actionId, null, null, null);
}
return E_SUCCESS;
if (__pSubMenu != null && mainIndex == __subMenuIndex)
{
- __pSubMenu->RemoveItemAt(subIndex);
+ __pSubMenu->RemoveItemAt(subIndex);
}
return E_SUCCESS;
return __pOptionMenuPresenter->GetSubItemActionIdAt(mainIndex, subIndex);
}
-bool
-_OptionMenu::IsSubMenuShown(void) const
-{
- return (__pSubMenu != null) && __pSubMenu->IsAttached();
-}
result
-_OptionMenu::ShowSubMenu(int mainIndex, _OptionMenuItem& item)
+_OptionMenu::ShowSubMenu(int mainIndex, _OptionMenuItem& item, FloatPoint touchPosition)
{
if (__pSubMenu != null)
{
- DestroySubMenu();
+ DestroySubMenu();
}
float textSize = 0.0f;
- Font* pFont = __pOptionMenuPresenter->GetFont();
+ float itemHeight = 0.0f;
+// Font* pFont = __pOptionMenuPresenter->GetFont();
GET_SHAPE_CONFIG(OPTIONMENU::TEXT_SIZE, GetOrientation(), textSize);
- FloatRectangle itemBounds = __pOptionMenuPresenter->GetItemBounds(mainIndex);
- FloatPoint anchorPosition(GetBoundsF().x + itemBounds.x + itemBounds.width / 2.0f,
- GetBoundsF().y + itemBounds.y + itemBounds.height / 2.0f - textSize / 2.0f);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, itemHeight);
+// FloatRectangle itemBounds = __pOptionMenuPresenter->GetItemBounds(mainIndex);
+
+ _OptionMenuItem* pMainItem = __pOptionMenuPresenter->GetItemFromPosition(touchPosition).pOptionMenuItem;
+ FloatRectangle itemBounds = pMainItem->GetBoundsF();
+ itemBounds.height = itemHeight;
+ float scrollPosition = __pScrollPanel->GetScrollPosition();
+ FloatPoint anchorPosition(GetBoundsF().x + itemBounds.x + itemBounds.width,
+ GetBoundsF().y + itemBounds.y + itemBounds.height / 2.0f - scrollPosition);
- __pSubMenu = _ContextMenu::CreateContextMenuN(anchorPosition,
- CONTEXT_MENU_CORE_STYLE_LIST,
- CONTEXT_MENU_CORE_ALIGN_UP);
+// FloatPoint anchorPosition = touchPosition;
+
+ __pSubMenu = _ContextMenu::CreateContextMenuN(anchorPosition, CONTEXT_MENU_CORE_STYLE_LIST, CONTEXT_MENU_CORE_ALIGN_RIGHT);
if (__pSubMenu == null)
{
- return GetLastResult();
+ return GetLastResult();
}
__pSubMenu->SetFocusable(true);
if (__pSubMenu->GetOwner() == null)
{
- _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
- SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM,
- E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
+ _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
+ SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM,
+ E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
- _Form* pForm = pFrame->GetCurrentForm();
- if (pForm != null)
- {
- __pSubMenu->SetOwner(pForm);
- }
- else
- {
- __pSubMenu->SetOwner(pFrame);
- }
+ _Form* pForm = pFrame->GetCurrentForm();
+ if (pForm != null)
+ {
+ __pSubMenu->SetOwner(pForm);
+ }
+ else
+ {
+ __pSubMenu->SetOwner(pFrame);
+ }
}
__pSubMenu->Initialize();
int subItemCount = item.GetSubItemCount();
for (int subIndex = 0; subIndex < subItemCount; subIndex++)
{
- pSubItem = item.GetSubItem(subIndex);
- if (pSubItem != null)
- {
- __pSubMenu->AddItem(pSubItem->GetText(), pSubItem->GetActionId(), null, null, null);
- }
+ pSubItem = item.GetSubItem(subIndex);
+ if (pSubItem != null)
+ {
+ __pSubMenu->AddItem(pSubItem->GetText(), pSubItem->GetActionId(), null, null, null);
+ }
}
- if (pFont != null)
- {
- __pSubMenu->SetFont(pFont->GetFaceName());
- }
+// if (pFont != null)
+// {
+// __pSubMenu->SetFont(pFont->GetFaceName());
+// }
__pSubMenu->Open();
__subMenuIndex = mainIndex;
return E_SUCCESS;
}
+bool
+_OptionMenu::IsSubMenuShown(void) const
+{
+ return (__pSubMenu != null) && __pSubMenu->IsAttached();
+}
+
result
_OptionMenu::DestroySubMenu(void)
{
if (__pSubMenu == null)
{
- return E_SYSTEM;
+ return E_SYSTEM;
}
__pSubMenu->Close();
return E_SUCCESS;
}
-_AccessibilityElement*
-_OptionMenu::GetAccessibilityElement(int mainIndex)
+result
+_OptionMenu::InsertItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- _AccessibilityElement* pElement = null;
result r = E_SUCCESS;
- r = __accessibilityElements.GetAt(mainIndex,pElement);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r));
- return pElement;
+ r = __pOptionMenuPresenter->InsertItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to insert a item.");
+
+ __actionId.InsertAt(actionId, index);
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ return r;
}
-void
-_OptionMenu::OnDraw()
+result
+_OptionMenu::SetItem(int index, const Base::String& text, int actionId, const Bitmap* pNormalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- __pOptionMenuPresenter->Draw();
+ result r = E_SUCCESS;
+
+ r = __pOptionMenuPresenter->SetItem(index, text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set a item.");
+
+ __actionId.SetAt(actionId, index);
+
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ return r;
}
-void
-_OptionMenu::OnChangeLayout(_ControlOrientation orientation)
+result
+_OptionMenu::RemoveItemAt(int index)
{
- __pOptionMenuPresenter->OnChangeLayout(orientation);
+ result r = E_SUCCESS;
+
+ r = __pOptionMenuPresenter->DeleteItem(index);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove a item.");
+
+ __actionId.RemoveAt(index);
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ return r;
}
void
-_OptionMenu::OnBoundsChanged(void)
+_OptionMenu::RemoveAllItems(void)
{
- SetBoundsAllAccessibilityElement();
+ result r = E_SUCCESS;
+
+ r = __pOptionMenuPresenter->DeleteItemAll();
+ SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Failed to remove all items.", GetErrorMessage(r));
+
+ __actionId.RemoveAll();
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ SetLastResult(r);
+ return;
}
-result
-_OptionMenu::OnAttachingToMainTree(const _Control* pParent)
+int
+_OptionMenu::GetItemCount(void) const
+{
+ return __actionId.GetCount();
+}
+
+int
+_OptionMenu::GetItemIndexAt(int actionId) const
{
- result r = __pOptionMenuPresenter->OnAttachingToMainTree(pParent);
- if (r != E_SUCCESS)
+ int count = __actionId.GetCount();
+
+ for (int i = 0; i < count; i++)
{
- return r;
+ int index = GetItemActionIdAt(i);
+
+ if (actionId == index)
+ {
+ return i;
+ }
}
- return _Window::OnAttachingToMainTree(pParent);
+ return -1;
}
-result
-_OptionMenu::OnAttachedToMainTree(void)
+int
+_OptionMenu::GetItemActionIdAt(int index) const
{
- if (__pOptionMenuPresenter != null)
- {
- __pOptionMenuPresenter->CalculateBounds();
+ int count = __actionId.GetCount();
+ int actionId = -1;
- __pOptionMenuPresenter->PrepareAnimation();
- __pOptionMenuPresenter->SetOptionMenuVisibility(true);
+ if (count <= 0 || index >= count)
+ {
+ return -1;
}
- __pOptionMenuPresenter->OnAttachedToMainTree();
+ __actionId.GetAt(index, actionId);
- return _Window::OnAttachedToMainTree();
+ return actionId;
}
result
-_OptionMenu::OnDetachingFromMainTree(void)
+_OptionMenu::SetWindowRect(const FloatRectangle& rect)
{
- __pOptionMenuPresenter->OnDetachingFromMainTree();
+ __windowRect = rect;
- return _Window::OnDetachingFromMainTree();
+ return E_SUCCESS;
}
-void
-_OptionMenu::OnVisibleStateChanged(void)
+FloatRectangle
+_OptionMenu::GetWindowRect(void) const
{
- _Window::OnVisibleStateChanged();
-
- __pOptionMenuPresenter->OnVisibleStateChanged();
+ return __windowRect;
}
-void
-_OptionMenu::OnActivated(void)
+result
+_OptionMenu::SetBodyRect(const FloatRectangle& rect)
{
- if (GetOwner() != null)
- {
- ChangeLayout(GetOwner()->GetOrientation());
- }
- else
- {
- ChangeLayout(_ControlManager::GetInstance()->GetOrientation());
- }
+ __bodyRect = rect;
- SetTouchCapture(true, false);
- _Window::OnActivated();
+ return E_SUCCESS;
}
-void
-_OptionMenu::OnDeactivated(void)
+FloatRectangle
+_OptionMenu::GetBodyRect(void) const
{
- ReleaseTouchCapture();
- _Window::OnDeactivated();
+ return __bodyRect;
}
-void
-_OptionMenu::OnFontChanged(Font* pFont)
+result
+_OptionMenu::SetItemRect(const FloatRectangle& rect)
{
- __pOptionMenuPresenter->OnFontChanged(pFont);
- return;
-}
+ __itemRect = rect;
-void
-_OptionMenu::OnFontInfoRequested(unsigned long& style, float& size)
+ return E_SUCCESS;
+}
+
+FloatRectangle
+_OptionMenu::GetItemRect(void) const
{
- __pOptionMenuPresenter->OnFontInfoRequested(style, size);
- return;
+ return __itemRect;
+}
+
+result
+_OptionMenu::SetPropertyMaxVisibleItemsCount(const Variant& count)
+{
+ int showCount = count.ToInt();
+
+ if (showCount < 1)
+ {
+ SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Count is invalid.");
+ return E_INVALID_ARG;
+ }
+
+ __showItemCount = showCount;
+
+ return E_SUCCESS;
+}
+
+Variant
+_OptionMenu::GetPropertyMaxVisibleItemsCount(void) const
+{
+ return Tizen::Ui::Variant(__showItemCount);
+}
+
+int
+_OptionMenu::GetShowItemCount(void) const
+{
+ Variant count = GetProperty("maxVisibleItemsCount");
+
+ return count.ToInt();
+}
+
+int
+_OptionMenu::GetShowItemMaxCount(void) const
+{
+ return __showItemMaxCount;
+}
+
+result
+_OptionMenu::SetShowItemCount(int count)
+{
+ result r;
+
+ r = SetProperty("maxVisibleItemsCount", Variant(count));
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to set property.");
+
+ r = __pOptionMenuPresenter->CalculateWindowRect();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to calculate window.");
+
+ return E_SUCCESS;
+}
+
+result
+_OptionMenu::SetPropertyColor(const Variant& color)
+{
+ __backgroundColor = color.ToColor();
+
+ LoadColorReplacedBitmap(__backgroundColor);
+
+ return E_SUCCESS;
+}
+
+Variant
+_OptionMenu::GetPropertyColor(void) const
+{
+ return Tizen::Ui::Variant(__backgroundColor);
+}
+
+result
+_OptionMenu::SetColor(const Graphics::Color& color)
+{
+ return SetProperty("color", Variant(color));
+}
+
+Color
+_OptionMenu::GetColor(void) const
+{
+ Variant color = GetProperty("color");
+
+ return color.ToColor();
+}
+
+result
+_OptionMenu::SetMaxVisibleItemsCount(int maxItemsCount)
+{
+ SetPropertyMaxVisibleItemsCount(maxItemsCount);
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ return E_SUCCESS;
+}
+
+result
+_OptionMenu::SetPropertyNormalItemColor(const Variant& color)
+{
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL] = color.ToColor();
+
+ return __pOptionMenuPresenter->ApplyColorProperty();
+}
+
+Variant
+_OptionMenu::GetPropertyNormalItemColor(void) const
+{
+ return Tizen::Ui::Variant(__itemColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL]);
+}
+
+result
+_OptionMenu::SetPropertyPressedItemColor(const Variant& color)
+{
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED] = color.ToColor();
+
+ return __pOptionMenuPresenter->ApplyColorProperty();
+}
+
+Variant
+_OptionMenu::GetPropertyPressedItemColor(void) const
+{
+ return Tizen::Ui::Variant(__itemColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED]);
+}
+
+result
+_OptionMenu::SetPropertyHighlightedItemColor(const Variant & color)
+{
+ __itemColor[OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = color.ToColor();
+
+ return __pOptionMenuPresenter->ApplyColorProperty();
+}
+
+Variant
+_OptionMenu::GetPropertyHighlightedItemColor(void) const
+{
+ return Tizen::Ui::Variant(__itemColor[OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED]);
+}
+
+result
+_OptionMenu::SetItemColor(enum OptionMenuCoreItemStatus status, const Graphics::Color& color)
+{
+ result r = E_SUCCESS;
+
+ if (status == OPTION_MENU_CORE_ITEM_STATUS_NORMAL)
+ {
+ r = SetProperty("normalItemColor", Variant(color));
+ }
+ else if (status == OPTION_MENU_CORE_ITEM_STATUS_PRESSED)
+ {
+ r = SetProperty("pressedItemColor", Variant(color));
+ }
+ else
+ {
+ r = SetProperty("highlightedItemColor", Variant(color));
+ }
+
+ return r;
+}
+
+Color
+_OptionMenu::GetItemColor(enum OptionMenuCoreItemStatus status) const
+{
+ Color itemColor;
+
+ if (status == OPTION_MENU_CORE_ITEM_STATUS_NORMAL)
+ {
+ Variant color = GetProperty("normalItemColor");
+ itemColor = color.ToColor();
+
+ }
+ else if (status == OPTION_MENU_CORE_ITEM_STATUS_PRESSED)
+ {
+ Variant color = GetProperty("pressedItemColor");
+ itemColor = color.ToColor();
+
+ }
+ else
+ {
+ Variant color = GetProperty("highlightedItemColor");
+ itemColor = color.ToColor();
+ }
+
+ return itemColor;
+
+}
+
+result
+_OptionMenu::SetPropertyNormalItemTextColor(const Variant& color)
+{
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL] = color.ToColor();
+
+ return __pOptionMenuPresenter->ApplyColorProperty();
+}
+
+Variant
+_OptionMenu::GetPropertyNormalItemTextColor(void) const
+{
+ return Tizen::Ui::Variant(__textColor[OPTION_MENU_CORE_ITEM_STATUS_NORMAL]);
+}
+
+result
+_OptionMenu::SetPropertyPressedItemTextColor(const Variant& color)
+{
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED] = color.ToColor();
+
+ return __pOptionMenuPresenter->ApplyColorProperty();
+}
+
+Variant
+_OptionMenu::GetPropertyPressedItemTextColor(void) const
+{
+ return Tizen::Ui::Variant(__textColor[OPTION_MENU_CORE_ITEM_STATUS_PRESSED]);
+}
+
+result
+_OptionMenu::SetPropertyHighlightedItemTextColor(const Variant & color)
+{
+ __textColor[OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED] = color.ToColor();
+
+ return __pOptionMenuPresenter->ApplyColorProperty();
+}
+
+Variant
+_OptionMenu::GetPropertyHighlightedItemTextColor(void) const
+{
+ return Tizen::Ui::Variant(__textColor[OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED]);
+}
+
+result
+_OptionMenu::SetTextColor(enum OptionMenuCoreItemStatus status, const Graphics::Color& color)
+{
+ result r = E_SUCCESS;
+
+ if (status == OPTION_MENU_CORE_ITEM_STATUS_NORMAL)
+ {
+ r = SetProperty("normalItemTextColor", Variant(color));
+ }
+ else if (status == OPTION_MENU_CORE_ITEM_STATUS_PRESSED)
+ {
+ r = SetProperty("pressedItemTextColor", Variant(color));
+ }
+ else
+ {
+ r = SetProperty("highlightedItemTextColor", Variant(color));
+ }
+
+ return r;
+}
+
+Color
+_OptionMenu::GetTextColor(enum OptionMenuCoreItemStatus status) const
+{
+ Color textColor;
+
+ if (status == OPTION_MENU_CORE_ITEM_STATUS_NORMAL)
+ {
+ Variant color = GetProperty("normalItemTextColor");
+ textColor = color.ToColor();
+
+ }
+ else if (status == OPTION_MENU_CORE_ITEM_STATUS_PRESSED)
+ {
+ Variant color = GetProperty("pressedItemTextColor");
+ textColor = color.ToColor();
+
+ }
+ else
+ {
+ Variant color = GetProperty("highlightedItemTextColor");
+ textColor = color.ToColor();
+ }
+
+ return textColor;
+}
+
+result
+_OptionMenu::AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener)
+{
+ result r = E_SUCCESS;
+
+ if (__pActionEvent == null)
+ {
+ __pActionEvent = _ActionEvent::CreateInstanceN(*this);
+ SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+ "[E_OUT_OF_MEMORY] The memory is insufficient.")
+
+ r = __pActionEvent->AddListener(listener);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to remove an action event listener.")
+ }
+
+ return r;
+
+CATCH:
+ delete __pActionEvent;
+ __pActionEvent = null;
+ return r;
+}
+
+result
+_OptionMenu::RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener)
+{
+ SysTryReturn(NID_UI_CTRL, __pActionEvent != null, E_INVALID_STATE, E_INVALID_STATE,
+ "[E_INVALID_STATE] The action event instance isn't constructed.")
+
+ result r = E_SUCCESS;
+
+ r = __pActionEvent->RemoveListener(listener);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to remove an action event listener")
+
+ return r;
+}
+
+result
+_OptionMenu::FireActionEvent(int actionId)
+{
+ IEventArg* pArg = _ActionEvent::CreateActionEventArgN(actionId);
+ result r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (pArg != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = __pActionEvent->Fire(*pArg);
+
+ return r;
+}
+
+Tizen::Ui::Controls::_ActionEvent*
+_OptionMenu::GetActionEvent(void) const
+{
+ return __pActionEvent;
+}
+
+result
+_OptionMenu::LoadBitmap(void)
+{
+ Color backgroundColor;
+
+ // Delete old bitmap
+ if (__pBackgroundEffectBitmap != null)
+ {
+ delete __pBackgroundEffectBitmap;
+ __pBackgroundEffectBitmap = null;
+ }
+
+ backgroundColor = GetColor();
+
+
+ result r;
+ r = LoadColorReplacedBitmap(backgroundColor);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
+
+ return r;
+
+CATCH:
+ delete __pBackgroundEffectBitmap;
+ __pBackgroundEffectBitmap = null;
+
+ return r;
+}
+
+result
+_OptionMenu::LoadColorReplacedBitmap(const Tizen::Graphics::Color& color)
+{
+ Bitmap* ptempNormalBitmap = null;
+
+ // Delete old bitmap
+ if (__pBackgroundNormalBitmap != null)
+ {
+ delete __pBackgroundNormalBitmap;
+ __pBackgroundNormalBitmap = null;
+ }
+
+ result r;
+
+ r = GET_BITMAP_CONFIG_N(CONTEXTMENU::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, ptempNormalBitmap);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "Failed to load bitmap.");
+ __pBackgroundNormalBitmap = _BitmapImpl::GetColorReplacedBitmapN(*ptempNormalBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
+ SysTryCatch(NID_UI_CTRL, __pBackgroundNormalBitmap != null, , GetLastResult(), "[%s] Propagating.",
+ GetErrorMessage(GetLastResult()));
+ delete ptempNormalBitmap;
+
+ return r;
+
+CATCH:
+ delete ptempNormalBitmap;
+
+ delete __pBackgroundNormalBitmap;
+ __pBackgroundNormalBitmap = null;
+
+ return r;
+}
+
+const Bitmap*
+_OptionMenu::GetBackgroundNormalBitmap(void) const
+{
+ return __pBackgroundNormalBitmap;
+}
+
+const Bitmap*
+_OptionMenu::GetBackgroundEffectBitmap(void) const
+{
+ return __pBackgroundEffectBitmap;
+}
+
+_UiTouchEventDelivery
+_OptionMenu::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
+{
+ return __pOptionMenuPresenter->OnPreviewTouchPressed(source, touchinfo);
}
bool
return __pOptionMenuPresenter->OnTouchPressed(source, touchinfo);
}
-bool
-_OptionMenu::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
+_UiTouchEventDelivery
+_OptionMenu::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
{
- return __pOptionMenuPresenter->OnTouchReleased(source, touchinfo);
+ return __pOptionMenuPresenter->OnPreviewTouchMoved(source, touchinfo);
}
bool
return __pOptionMenuPresenter->OnTouchMoved(source, touchinfo);
}
+_UiTouchEventDelivery
+_OptionMenu::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
+{
+ return __pOptionMenuPresenter->OnPreviewTouchReleased(source, touchinfo);
+}
+
+bool
+_OptionMenu::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
+{
+ return __pOptionMenuPresenter->OnTouchReleased(source, touchinfo);
+}
+
bool
_OptionMenu::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
{
- return __pOptionMenuPresenter->OnTouchCanceled(source, touchinfo);
+ __pOptionMenuPresenter->OnTouchCanceled(source, touchinfo);
+
+ SetVisibleState(false);
+
+ return true;
}
void
__pOptionMenuPresenter->OnActionPerformed(source, actionId);
}
-bool
-_OptionMenu::OnFocusGained(const _Control &source)
+void
+_OptionMenu::OnFontChanged(Tizen::Graphics::Font* pFont)
{
- __currentFocusedIndex = -1;
- __isFocused = false;
- return true;
+ return __pOptionMenuPresenter->OnFontChanged(pFont);
}
-bool
-_OptionMenu::OnFocusLost(const _Control &source)
+void
+_OptionMenu::OnFontInfoRequested(unsigned long& style, float& size)
{
- __pOptionMenuPresenter->ClearFocus(__currentFocusedIndex);
- __isFocused = false;
- return true;
+ return __pOptionMenuPresenter->OnFontInfoRequested(style, size);
}
void
-_OptionMenu::OnDrawFocus(void)
+_OptionMenu::OnChangeLayout(_ControlOrientation orientation)
{
- if (!__isFocused)
+ AppLog("vipul : OnChangeLayout");
+ GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, orientation, __showItemMaxCount);
+
+ __pOptionMenuPresenter->CalculateShowItemCount();
+ __pOptionMenuPresenter->CalculateWindowRect();
+
+ if (__isAttachedToMainTree == true)
{
- __isFocused = true;
- __currentFocusedIndex = -1;
- __pOptionMenuPresenter->DrawFocus(__currentFocusedIndex);
+ if (__layout != orientation)
+ {
+ SetVisibleState(false);
+ }
}
- return;
+
+ __layout = orientation;
}
-bool
-_OptionMenu::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+void
+_OptionMenu::OnOwnerChanged(_Control* pOldOwner)
{
- if (&source != this)
+ if (!__isAttachedToMainTree)
{
- return false;
+ return;
}
- _KeyCode keyCode = keyInfo.GetKeyCode();
+ _Control* pOwner = GetOwner();
- int count = GetItemCount();
-
- if(!__isFocused)
+ if (pOldOwner != null)
{
- return false;
+ pOldOwner->UnlockInputEvent();
}
- switch(keyCode)
+ if (pOwner != null)
{
- case _KEY_RIGHT:
- if (__currentFocusedIndex >= (count - 1))
- {
- __currentFocusedIndex = count - 1;
- }
- else
- {
- __currentFocusedIndex++;
- }
- break;
+ pOwner->LockInputEvent();
+ }
+}
- case _KEY_LEFT:
- if (__currentFocusedIndex <= -1)
- {
- __currentFocusedIndex = -1;
- }
- else
- {
- __currentFocusedIndex--;
- }
- break;
+_AccessibilityElement*
+_OptionMenu::GetAccessibilityElement(const int mainIndex) const
+{
+ _AccessibilityElement* pElement = null;
+ result r = __accessibilityElements.GetAt(mainIndex, pElement);
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Failed at AccessibilityElement.", GetErrorMessage(r));
- case _KEY_ENTER:
- __pOptionMenuPresenter->OnEnterKeyPressed(__currentFocusedIndex);
+ return pElement;
- return true;
+CATCH:
+ delete pElement;
- default :
- return false;
- }
- __pOptionMenuPresenter->DrawFocus(__currentFocusedIndex);
+ return null;
+}
- return true;
+void
+_OptionMenu::AddAccessibilityElement(const _AccessibilityElement& element)
+{
+ __accessibilityElements.Add(const_cast<_AccessibilityElement*>(&element));
}
void
-_OptionMenu::SetBoundsAllAccessibilityElement(void)
+_OptionMenu::SetAllAccessibilityElement(void)
{
- _AccessibilityElement* pElement = null;
- IEnumeratorT<_AccessibilityElement*>* pEnumerator = __accessibilityElements.GetEnumeratorN();
- int index = 0;
- while (pEnumerator->MoveNext() == E_SUCCESS)
- {
- if (pEnumerator->GetCurrent(pElement) == E_SUCCESS)
- {
- pElement->SetBounds(__pOptionMenuPresenter->GetItemBounds(index));
- }
- index++;
- }
- delete pEnumerator;
+ RemoveAllAccessibilityElement();
+ __pOptionMenuPresenter->SetAllAccessibilityElement();
+}
+
+bool
+_OptionMenu::OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ SetVisibleState(false);
+
+ return true;
+}
+
+bool
+_OptionMenu::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
+}
+
+bool
+_OptionMenu::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
+{
+ return false;
}
void
_OptionMenu::RemoveAllAccessibilityElement(void)
{
- _AccessibilityElement* pElement = null;
- while (__accessibilityElements.GetCount() > 0)
+ _AccessibilityContainer* pAccessibilityContainer = GetAccessibilityContainer();
+ if (pAccessibilityContainer && pAccessibilityContainer->IsActivated())
{
- if ((__accessibilityElements.GetAt(0, pElement)) == E_SUCCESS)
- {
- __accessibilityElements.RemoveAt(0);
- pElement->GetParent()->RemoveElement(*pElement);
- }
- else
- {
- __accessibilityElements.RemoveAt(0);
- }
+ pAccessibilityContainer->RemoveAllElement();
}
}
-}}} // Tizen::Ui::Controls
+_OptionMenuItemInfo
+_OptionMenu::GetItemFromPosition(const FloatPoint& position) const
+{
+ return __pOptionMenuPresenter->GetItemFromPosition(position);
+}
+
+_OptionMenuItemInfo
+_OptionMenu::FindItem(int index) const
+{
+ return __pOptionMenuPresenter->FindItem(index);
+}
+
+result
+_OptionMenu::SetTopDrawnItemIndex(int index)
+{
+ return __pOptionMenuPresenter->SetTopDrawnItemIndex(index);
+}
+
+_ControlOrientation
+_OptionMenu::GetLayout(void) const
+{
+ return __layout;
+}
+
+}}} // Tizen::Ui: Control
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using namespace Tizen::Base;
using namespace Tizen::Base::Runtime;
using namespace Tizen::Ui;
+using namespace Tizen::Graphics;
-const int MAX_ITEM_COUNT = 7;\r
-\r
namespace Tizen { namespace Ui { namespace Controls
{
return static_cast<const _OptionMenuImpl*>(optionMenu._pControlImpl);
}
-_OptionMenuImpl::_OptionMenuImpl(OptionMenu* pPublic, _ContextMenu* pCore)\r
+_OptionMenuImpl::_OptionMenuImpl(OptionMenu* pPublic, _OptionMenu* pCore)
: _WindowImpl(pPublic, pCore)
, __pPublicActionEvent(null)
{
{
ClearLastResult();
- _ContextMenu* pCore = _ContextMenu::CreateContextMenuN(Tizen::Graphics::FloatPoint(-1,-1),CONTEXT_MENU_CORE_STYLE_LIST, CONTEXT_MENU_CORE_ALIGN_UP);\r
+ _OptionMenu* pCore = _OptionMenu::CreateOptionMenuN();
result r = GetLastResult();
SysTryReturn(NID_UI_CTRL, (pCore != null), null, r, "[%s] Propagating.", GetErrorMessage(r));
- pCore->SetShowItemCount(MAX_ITEM_COUNT);\r
_OptionMenuImpl* pImpl = new (std::nothrow) _OptionMenuImpl(&control, pCore);
r = CheckConstruction(pCore, pImpl);
}
result
-_OptionMenuImpl::AddItem(const String& text, int actionId)
+_OptionMenuImpl::AddItem(const String& text, int actionId, const Bitmap* pNormalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
ClearLastResult();
- return GetCore().AddItem(text, actionId, null, null ,null);\r
-}
-result\r
-_OptionMenuImpl::AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId)\r
-{\r
- ClearLastResult();\r
-\r
- return GetCore().AddItem(L" ", actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
-}\r
-\r
-result\r
-_OptionMenuImpl::AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
-{\r
- ClearLastResult();\r
-\r
- return GetCore().AddItem(text, actionId, &normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
-}\r
-\r
+ return GetCore().AddItem(text, actionId, pNormalBitmap, pPressedBitmap, pHighlightedBitmap);
+}
result
-_OptionMenuImpl::InsertItemAt(int mainIndex, const String& text, int actionId)
+_OptionMenuImpl::InsertItemAt (int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap *pHighlightedBitmap)
{
- ClearLastResult();
- SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
+ ClearLastResult();
+ SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
- return GetCore().InsertItem(mainIndex, text, actionId, null, null, null);\r
+ return GetCore().InsertItemAt(mainIndex, text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);
}
result
-_OptionMenuImpl::SetItemAt(int mainIndex, const String& text, int actionId)
+_OptionMenuImpl::SetItemAt (int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap *pHighlightedBitmap)
{
- ClearLastResult();
- SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
+ ClearLastResult();
+ SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
- return GetCore().SetItem(mainIndex, text, actionId, null, null, null);\r
+ return GetCore().SetItemAt(mainIndex, text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);
}
result
return GetCore().RemoveItemAt(mainIndex);
}
+void
+_OptionMenuImpl::RemoveAllItems (void)
+{
+ ClearLastResult();
+
+ GetCore().RemoveAllItems();
+
+ return;
+}
+
int
_OptionMenuImpl::GetItemCount(void) const
{
{
ClearLastResult();
- return 0;//GetCore().GetItemIndexFromActionId(actionId);\r
+ return GetCore().GetItemIndexAt(actionId);
}
int
SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
- return E_SUCCESS;//GetCore().AddSubItem(mainIndex, text, actionId);\r
+ return GetCore().AddSubItem(mainIndex, text, actionId);
}
result
SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
- return E_SUCCESS;//GetCore().InsertSubItemAt(mainIndex, subIndex, text, actionId);\r
+ return GetCore().InsertSubItemAt(mainIndex, subIndex, text, actionId);
}
result
SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
- return E_SUCCESS;//GetCore().SetSubItemAt(mainIndex, subIndex, text, actionId);\r
+ return GetCore().SetSubItemAt(mainIndex, subIndex, text, actionId);
}
result
SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
- return E_SUCCESS;//GetCore().RemoveSubItemAt(mainIndex, subIndex);\r
+ return GetCore().RemoveSubItemAt(mainIndex, subIndex);
}
int
SysTryReturn(NID_UI_CTRL, (mainIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] The specified main index (%d) is negative.", mainIndex);
- return 0;//GetCore().GetSubItemCount(mainIndex);\r
+ return GetCore().GetSubItemCount(mainIndex);
}
int
{
ClearLastResult();
- return 0;//GetCore().GetSubItemIndexFromActionId(actionId);\r
+ return GetCore().GetSubItemIndexFromActionId(actionId);
}
int
SysTryReturn(NID_UI_CTRL, (subIndex >= 0), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
"[E_OUT_OF_RANGE] The specified sub index (%d) is negative.", subIndex);
- return 0;//GetCore().GetSubItemActionIdAt(mainIndex, subIndex);\r
+ return GetCore().GetSubItemActionIdAt(mainIndex, subIndex);
+}
+
+result
+_OptionMenuImpl::SetItemTextColor(OptionMenuItemStatus status, const Color& color)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+
+ switch (status)
+ {
+ case OPTION_MENU_ITEM_STATUS_NORMAL:
+ r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL, color);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_PRESSED:
+ r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED, color);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED:
+ r = GetCore().SetTextColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color);
+ break;
+
+ default:
+ SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at OptionMenuItemStatus.");
+ r = E_INVALID_ARG;
+ break;
+ }
+
+ return r;
+}
+
+Color
+_OptionMenuImpl::GetItemTextColor(OptionMenuItemStatus status) const
+{
+ ClearLastResult();
+
+ Tizen::Graphics::Color color(0, 0, 0, 0);
+
+ switch (status)
+ {
+ case OPTION_MENU_ITEM_STATUS_NORMAL:
+ color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_PRESSED:
+ color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED:
+ color = GetCore().GetTextColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED);
+ break;
+
+ default:
+ SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus.");
+ break;
+ }
+
+ return color;
+}
+
+result
+_OptionMenuImpl::SetItemColor(OptionMenuItemStatus status, const Color& color)
+{
+ ClearLastResult();
+
+ result r = E_SUCCESS;
+
+ switch (status)
+ {
+ case OPTION_MENU_ITEM_STATUS_NORMAL:
+ r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL, color);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_PRESSED:
+ r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED, color);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED:
+ r = GetCore().SetItemColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED, color);
+ break;
+
+ default:
+ SysLogException(NID_UI_CTRL, E_INVALID_ARG, "Invalid argument at OptionMenuItemStatus.");
+ r = E_INVALID_ARG;
+ break;
+ }
+
+ return r;
+}
+
+Color
+_OptionMenuImpl::GetItemColor(OptionMenuItemStatus status) const
+{
+ ClearLastResult();
+
+ Tizen::Graphics::Color color(0, 0, 0, 0);
+
+ switch (status)
+ {
+ case OPTION_MENU_ITEM_STATUS_NORMAL:
+ color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_NORMAL);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_PRESSED:
+ color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_PRESSED);
+ break;
+
+ case OPTION_MENU_ITEM_STATUS_HIGHLIGHTED:
+ color = GetCore().GetItemColor(OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED);
+ break;
+
+ default:
+ SysLogException(NID_UI_CTRL, E_SYSTEM, "Invalid argument at ContextMenuItemStatus.");
+ break;
+ }
+
+ return color;
+}
+
+result
+_OptionMenuImpl::SetColor(const Color& color)
+{
+ ClearLastResult();
+
+ return GetCore().SetColor(color);
+}
+
+Color
+_OptionMenuImpl::GetColor(void) const
+{
+ ClearLastResult();
+
+ return GetCore().GetColor();
+}
+
+result
+_OptionMenuImpl::SetMaxVisibleItemsCount(int maxItemsCount)
+{
+ ClearLastResult();
+
+ return GetCore().SetMaxVisibleItemsCount(maxItemsCount);
+}
+
+int
+_OptionMenuImpl::GetMaxVisibleItemsCount(void) const
+{
+ ClearLastResult();
+
+ return GetCore().GetPropertyMaxVisibleItemsCount().ToInt();
}
result
return static_cast <OptionMenu&>(_ControlImpl::GetPublic());
}
-const _ContextMenu&\r
+const _OptionMenu&
_OptionMenuImpl::GetCore(void) const
{
- return static_cast <const _ContextMenu&>(_ControlImpl::GetCore());\r
+ return static_cast <const _OptionMenu&>(_ControlImpl::GetCore());
}
-_ContextMenu&\r
+_OptionMenu&
_OptionMenuImpl::GetCore(void)
{
- return static_cast <_ContextMenu&>(_ControlImpl::GetCore());\r
+ return static_cast <_OptionMenu&>(_ControlImpl::GetCore());
}
void
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
* @brief This is the implementation file for the _OptionMenuItem class.
*/
-#include <new>
#include <FBaseSysLog.h>
-#include <FBaseErrorDefine.h>
-
+#include <FGrp_BitmapImpl.h>
+#include "FUi_AccessibilityContainer.h"
+#include "FUi_AccessibilityElement.h"
+#include "FUi_CoordinateSystemUtils.h"
+#include "FUi_Math.h"
+#include "FUi_ResourceManager.h"
+
+#include "FUiCtrl_ScrollPanel.h"
#include "FUiCtrl_OptionMenuItem.h"
using namespace Tizen::Base;
-using namespace Tizen::Base::Collection;
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui;
+namespace {
+static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
const int MAX_SUB_ITEM_COUNT = 32;
+}
namespace Tizen { namespace Ui { namespace Controls
{
_OptionMenuItem::_OptionMenuItem(void)
- : __actionId(-1)
+ : __type(OPTION_MENU_ITEM_DRAWING_TYPE_NONE)
+ , __actionId(-1)
+ , __upperDividerLine(false)
+ , __lowerDividerLine(false)
+ , __selected(false)
+ , __parentScrollEnable(false)
+ , __leftMargin(0.0f)
+ , __rightMargin(0.0f)
+ , __dividerHeight(0.0f)
+ , __bgPressedMargin(0.0f)
+ , __textLeftMargin(0.0f)
+ , __textRightMargin(0.0f)
+ , __textTopMargin(0.0f)
+ , __textBottomMargin(0.0f)
+ , __arrowLeftMargin(0.0f)
+ , __arrowRightMargin(0.0f)
+ , __arrowMargin(0.0f)
+ , __itemHeight(0.0f)
+ , __textSize(0.0f)
+ , __text(L"")
+ , __pMagentaBgBitmap(null)
+ , __pArrowBitmap(null)
+ , __pArrowPressedBitmap(null)
+ , __size(FloatDimension(0.0f, 0.0f))
+ , __drawRect(FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
+ , __pBitmapLabel(null)
+ , __pTextLabel(null)
+ , __pUpperDividerLineLabel(null)
+ , __pBackgroundLabel(null)
+ , __pLowerDividerLineLabel(null)
+ , __pArrowLabel(null)
, __pSubItems(null)
{
+ _ControlOrientation orientation = GetOrientation();
+
+ __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL] = null;
+ __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED] = null;
+ __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED] = null;
+
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight);
+ GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bgPressedMargin);
+
+ GET_SHAPE_CONFIG(OPTIONMENU::TEXT_LEFT_MARGIN, orientation, __textLeftMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::TEXT_RIGHT_MARGIN, orientation, __textRightMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::TEXT_TOP_MARGIN, orientation, __textTopMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::TEXT_BOTTOM_MARGIN, orientation, __textBottomMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::LEFT_MARGIN, orientation, __arrowLeftMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::RIGHT_MARGIN, orientation, __arrowRightMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::ARROW_MARGIN, orientation, __arrowMargin);
+ GET_SHAPE_CONFIG(OPTIONMENU::ITEM_HEIGHT, orientation, __itemHeight);
+
+ GET_COLOR_CONFIG(CONTEXTMENU::ITEM_BG_PRESSED, __selectedBgColor);
+ GET_COLOR_CONFIG(CONTEXTMENU::LIST_ITEM_DIVIDER_01_NORMAL, __lowerDividerLineColor); // lower divider of item n and
+ GET_COLOR_CONFIG(CONTEXTMENU::LIST_ITEM_DIVIDER_02_NORMAL, __upperDividerLineColor); // upper divider of item n+1 are bonded together.
+ GET_BITMAP_CONFIG_N(CONTEXTMENU::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pMagentaBgBitmap);
+
+ InitializeAccessibilityElement();
}
_OptionMenuItem::~_OptionMenuItem(void)
{
+ if (__pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL] != null)
+ {
+ delete __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL];
+ __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL] = null;
+ }
+
+ if (__pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED] != null)
+ {
+ delete __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED];
+ __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED] = null;
+ }
+
+ if (__pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED] != null)
+ {
+ delete __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED];
+ __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED] = null;
+ }
+
+ if (__pUpperDividerLineLabel != null)
+ {
+ DetachChild(*__pUpperDividerLineLabel);
+ delete __pUpperDividerLineLabel;
+ __pUpperDividerLineLabel = null;
+ }
+
+ if (__pBackgroundLabel != null)
+ {
+ DetachChild(*__pBackgroundLabel);
+ delete __pBackgroundLabel;
+ __pBackgroundLabel = null;
+ }
+
+ delete __pMagentaBgBitmap;
+ __pMagentaBgBitmap = null;
+
+ delete __pArrowBitmap;
+ __pArrowBitmap = null;
+
+ delete __pArrowPressedBitmap;
+ __pArrowPressedBitmap = null;
+
+ if (__pLowerDividerLineLabel != null)
+ {
+ DetachChild(*__pLowerDividerLineLabel);
+ delete __pLowerDividerLineLabel;
+ __pLowerDividerLineLabel = null;
+ }
+
+ if (__pArrowLabel != null)
+ {
+ DetachChild(*__pArrowLabel);
+ delete __pArrowLabel;
+ __pArrowLabel = null;
+ }
+
if (__pSubItems != null)
{
__pSubItems->RemoveAll(true);
delete __pSubItems;
__pSubItems = null;
}
+
+ _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->RemoveAllElement();
+ }
}
_OptionMenuItem*
-_OptionMenuItem::CreateInstanceN(void)
+_OptionMenuItem::CreateOptionMenuItemN(void)
{
- _OptionMenuItem* pItem = new (std::nothrow) _OptionMenuItem;
- SysTryReturn(NID_UI_CTRL, (pItem != null), null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ ClearLastResult();
- return pItem;
-}
+ _OptionMenuItem* pItem = null;
-void
-_OptionMenuItem::SetText(const String& text)
-{
- __text = text;
-}
+ pItem = new (std::nothrow) _OptionMenuItem();
+ if (pItem == null)
+ {
+ SetLastResult(E_OUT_OF_MEMORY);
+ return null;
+ }
-const String&
-_OptionMenuItem::GetText(void) const
-{
- return __text;
-}
+ pItem->AcquireHandle();
-void
-_OptionMenuItem::SetActionId(int actionId)
-{
- __actionId = actionId;
-}
-
-int
-_OptionMenuItem::GetActionId(void) const
-{
- return __actionId;
+ SetLastResult(E_SUCCESS);
+ return pItem;
}
result
{
__pSubItems = new (std::nothrow) ArrayList;
SysTryReturn(NID_UI_CTRL, (__pSubItems != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ "[E_OUT_OF_MEMORY] Memory allocation failed.");
result r = __pSubItems->Construct(MAX_SUB_ITEM_COUNT);
if (r != E_SUCCESS)
{
- delete __pSubItems;
- __pSubItems = null;
- SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
- return r;
+ delete __pSubItems;
+ __pSubItems = null;
+ SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
}
}
SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
+ "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
SysTryReturn(NID_UI_CTRL, (index <= __pSubItems->GetCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
+ "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
return __pSubItems->InsertAt(subItem, index);
}
result
+_OptionMenuItem::SetSubItemAt(_OptionMenuItem& subItem, int index)
+{
+ _OptionMenuItem* pItem = static_cast<_OptionMenuItem*>(__pSubItems->GetAt(index));
+
+ pItem->SetText(subItem.GetText());
+ pItem->SetActionId(subItem.GetActionId());
+
+ delete &subItem;
+
+ return E_SUCCESS;
+}
+
+result
_OptionMenuItem::RemoveSubItemAt(int index)
{
SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
+ "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
SysTryReturn(NID_UI_CTRL, (__pSubItems != null), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The sub items list is null.");
+ "[E_SYSTEM] A system error has occurred. The sub items list is null.");
SysTryReturn(NID_UI_CTRL, (index < __pSubItems->GetCount()), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
+ "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
return __pSubItems->RemoveAt(index, true);
}
-result
-_OptionMenuItem::RemoveAllSubItem(void)
+bool
+_OptionMenuItem::HasSubItem(void) const
{
- SysTryReturn(NID_UI_CTRL, (__pSubItems != null), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The sub items list is null.");
+ return (__pSubItems != null && __pSubItems->GetCount() > 0);
+}
- __pSubItems->RemoveAll(true);
- return E_SUCCESS;
+int
+_OptionMenuItem::GetSubItemCount(void) const
+{
+ if (__pSubItems == null)
+ {
+ return 0;
+ }
+
+ return __pSubItems->GetCount();
}
_OptionMenuItem*
_OptionMenuItem::GetSubItem(int index)
{
SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
+ "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
SysTryReturn(NID_UI_CTRL, (__pSubItems != null), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The sub items list is null.", index);
+ "[E_SYSTEM] A system error has occurred. The sub items list is null.", index);
SysTryReturn(NID_UI_CTRL, (index < __pSubItems->GetCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
+ "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
return static_cast<_OptionMenuItem*>(__pSubItems->GetAt(index));
}
-const _OptionMenuItem*
-_OptionMenuItem::GetSubItem(int index) const
+void
+_OptionMenuItem::InitializeAccessibilityElement(void)
{
- SysTryReturn(NID_UI_CTRL, (index >= 0 && index < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", index);
- SysTryReturn(NID_UI_CTRL, (__pSubItems != null), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The sub items list is null.", index);
- SysTryReturn(NID_UI_CTRL, (index < __pSubItems->GetCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified index (%d) is greater than the available items count.", index);
+ _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->Activate(true);
+ _AccessibilityElement* pElement = new (std::nothrow) _AccessibilityElement(true);
+ SysTryReturnVoidResult(NID_UI_CTRL, pElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
+
+ pElement->SetTrait(L"Optionual popup");
+ pElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
+ pContainer->AddElement(*pElement);
+ }
+
+ return;
+}
+
+void
+_OptionMenuItem::SetBitmapLabel(_Label* pLabel)
+{
+ __pBitmapLabel = pLabel;
+}
+
+void
+_OptionMenuItem::SetTextLabel(_Label* pLabel)
+{
+ __pTextLabel = pLabel;
+}
+
+void
+_OptionMenuItem::SetType(OptionMenuItemDrawingType type)
+{
+ __type = type;
+}
- return static_cast<const _OptionMenuItem*>(__pSubItems->GetAt(index));
+OptionMenuItemDrawingType
+_OptionMenuItem::GetType(void) const
+{
+ return __type;
+}
+
+void
+_OptionMenuItem::SetActionId(int actionId)
+{
+ __actionId = actionId;
}
int
-_OptionMenuItem::GetSubItemCount(void) const
+_OptionMenuItem::GetActionId(void) const
{
- if (__pSubItems == null)
+ return __actionId;
+}
+
+void
+_OptionMenuItem::SetUpperDivider(bool drawDivider)
+{
+ __upperDividerLine = drawDivider;
+}
+
+void
+_OptionMenuItem::SetLowerDivider(bool drawDivider)
+{
+ __lowerDividerLine = drawDivider;
+}
+
+bool
+_OptionMenuItem::HasUpperDivider(void) const
+{
+ return __upperDividerLine;
+}
+
+bool
+_OptionMenuItem::HasLowerDivider(void) const
+{
+ return __lowerDividerLine;
+}
+
+void
+_OptionMenuItem::SetTextSize(float size)
+{
+ __textSize = size;
+}
+
+result
+_OptionMenuItem::SetText(const String& text)
+{
+ __text = text;
+
+ return E_SUCCESS;
+}
+
+const String&
+_OptionMenuItem::GetText(void) const
+{
+ return __text;
+}
+
+result
+_OptionMenuItem::SetBitmap(OptionMenuItemDrawingStatus status, const Bitmap* pBitmap)
+{
+ if (status < OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL || status > OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED)
{
- return 0;
+ return E_INVALID_ARG;
}
- return __pSubItems->GetCount();
+ SysTryReturn(NID_UI_CTRL, (status != OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL || pBitmap != null), E_INVALID_ARG,
+ E_INVALID_ARG, "[E_INVALID_ARG] The normal bitmap must not be null.");
+
+ Bitmap* pClonedBitmap = _BitmapImpl::CloneN(*pBitmap);
+
+ // If bitmap is in _OptionMenuItem, delete old one.
+ if (__pBitmap[status] != null)
+ {
+ delete __pBitmap[status];
+ __pBitmap[status] = null;
+ }
+
+ __pBitmap[status] = pClonedBitmap;
+
+ return E_SUCCESS;
+}
+
+const Bitmap*
+_OptionMenuItem::GetBitmap(OptionMenuItemDrawingStatus status) const
+{
+ if (status < OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL || status > OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED)
+ {
+ return null;
+ }
+
+ return __pBitmap[status];
+}
+
+void
+_OptionMenuItem::SetSize(Tizen::Graphics::FloatDimension size)
+{
+ __size = size;
+}
+
+Tizen::Graphics::FloatDimension
+_OptionMenuItem::GetSize(void) const
+{
+ return __size;
+}
+
+void
+_OptionMenuItem::SetDrawRect(Tizen::Graphics::FloatRectangle rect)
+{
+ __drawRect = rect;
+
+}
+
+FloatRectangle
+_OptionMenuItem::GetDrawRect(void) const
+{
+ return __drawRect;
+}
+
+void
+_OptionMenuItem::SetPressedDrawRect(Tizen::Graphics::FloatRectangle rect)
+{
+ __pressedDrawRect = rect;
+
+}
+
+FloatRectangle
+_OptionMenuItem::GetPressedDrawRect(void) const
+{
+ return __pressedDrawRect;
+}
+
+int
+_OptionMenuItem::Release(void)
+{
+ delete this;
+
+ return 0;
+}
+
+void
+_OptionMenuItem::OnBoundsChanged(void)
+{
+ _AccessibilityContainer* pContainer = GetAccessibilityContainer();
+ if (pContainer)
+ {
+ _AccessibilityElement* pElement = pContainer->GetChildElement(0);
+ if (pElement)
+ {
+ pElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
+ }
+ }
+}
+
+void
+_OptionMenuItem::OnDraw(void)
+{
+ DrawItem();
+}
+
+void
+_OptionMenuItem::DrawItem(void)
+{
+ if (__upperDividerLine)
+ {
+ DrawItemUpperDivider();
+ }
+
+ if (__lowerDividerLine)
+ {
+ DrawItemLowerDivider();
+ }
+
+ DrawItemBackground();
+
+ if (HasSubItem() == true)
+ {
+ DrawArrow();
+ }
+
+ if (IsSelected())
+ {
+ __pBitmapLabel->SetBackgroundBitmap(*__pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED]);
+ }
+ else
+ {
+ __pBitmapLabel->SetBackgroundBitmap(*__pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL]);
+ }
+}
+
+void
+_OptionMenuItem::DrawArrow(void)
+{
+ FloatRectangle bounds = GetBoundsF();
+ FloatRectangle textRect;
+ textRect.height = bounds.height - __textTopMargin - __textBottomMargin;
+ textRect.width = bounds.width - __arrowLeftMargin - __arrowRightMargin - __textLeftMargin - __textRightMargin;
+ textRect.x = bounds.x + __arrowLeftMargin + __textLeftMargin;
+ textRect.y = bounds.y + ((bounds.height - textRect.height) / 2.0f);
+
+ textRect.width -= __arrowMargin;
+
+ Color arrowColor;
+ Bitmap *pArrowBitmap = null;
+ result r;
+
+ if (__pArrowBitmap == null)
+ {
+ // Load Contextual Popup Arrow Bitmap
+ r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, pArrowBitmap);
+ //SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ GET_COLOR_CONFIG(OPTIONMENU::CONTEXTUAL_POPUP_ARROW_NORMAL, arrowColor);
+ __pArrowBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pArrowBitmap, Color::GetColor(COLOR_ID_MAGENTA), arrowColor);
+ //SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ delete pArrowBitmap;
+ pArrowBitmap = null;
+ }
+
+ if (__pArrowPressedBitmap == null)
+ {
+ // Load Contextual Popup Arrow Pressed Bitmap
+ r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, pArrowBitmap);
+ //SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ GET_COLOR_CONFIG(OPTIONMENU::CONTEXTUAL_POPUP_ARROW_PRESSED, arrowColor);
+ __pArrowPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pArrowBitmap, Color::GetColor(COLOR_ID_MAGENTA), arrowColor);
+ //SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+
+ delete pArrowBitmap;
+ pArrowBitmap = null;
+ }
+
+ FloatRectangle arrowbounds(bounds.x + bounds.width - __arrowMargin - __rightMargin,
+ (__itemHeight - __pArrowBitmap->GetHeight())/2.0f, __pArrowBitmap->GetWidth(), __pArrowBitmap->GetHeight());
+
+ if (__pArrowLabel == null)
+ {
+ __pArrowLabel = _Label::CreateLabelN();
+ SysTryReturnVoidResult(NID_UI_CTRL, __pArrowLabel, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ __pArrowLabel->SetBounds(FloatRectangle(arrowbounds));
+
+ AttachChild(*__pArrowLabel);
+ }
+
+ if (__selected == true)
+ {
+ if (__pArrowPressedBitmap)
+ {
+ __pArrowLabel->SetBackgroundBitmap(*__pArrowPressedBitmap);
+ }
+ }
+ else
+ {
+ if (__pArrowBitmap)
+ {
+ __pArrowLabel->SetBackgroundBitmap(*__pArrowBitmap);
+ }
+ }
+
+ __pArrowLabel->Invalidate();
+}
+
+void
+_OptionMenuItem::DrawItemUpperDivider(void)
+{
+ if (__pUpperDividerLineLabel == null)
+ {
+ __pUpperDividerLineLabel = _Label::CreateLabelN();
+ SysTryReturnVoidResult(NID_UI_CTRL, __pUpperDividerLineLabel, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ FloatRectangle bounds = GetBoundsF();
+ __pUpperDividerLineLabel->SetBounds(FloatRectangle(__leftMargin, 0.0f, bounds.width - __leftMargin - __rightMargin, __dividerHeight));
+
+ AttachChild(*__pUpperDividerLineLabel);
+
+ _AccessibilityContainer* pContainer = __pUpperDividerLineLabel->GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->Activate(false);
+ }
+ }
+
+ Color dividerLineColor = Color(0, 0, 0, 0);
+ if (__selected == false)
+ {
+ dividerLineColor = __upperDividerLineColor;
+ }
+
+ __pUpperDividerLineLabel->SetBackgroundColor(dividerLineColor);
+ __pUpperDividerLineLabel->Invalidate();
}
int
_OptionMenuItem::GetSubItemIndexFromActionId(int actionId) const
{
- if (__pSubItems == null)
+ if (__pSubItems == null)
+ {
+ return -1;
+ }
+
+ int index = 0;
+ int subItemCount = __pSubItems->GetCount();
+ const _OptionMenuItem* pItem = null;
+ for (index = 0; index < subItemCount; index++)
+ {
+ pItem = static_cast<const _OptionMenuItem*>(__pSubItems->GetAt(index));
+ if (pItem != null)
+ {
+ if (pItem->__actionId == actionId)
+ {
+ return index;
+ }
+ }
+ }
+
+ return -1;
+}
+
+void
+_OptionMenuItem::DrawItemBackground(void)
+{
+ float topMargin = 0.0f, bottomMargin = 0.0f;
+
+ SetBackgroundColor(Color(0, 0, 0, 0));
+
+ if (__pBackgroundLabel == null)
{
- return -1;
+ __pBackgroundLabel = _Label::CreateLabelN();
+ SysTryReturnVoidResult(NID_UI_CTRL, __pBackgroundLabel, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ __pBackgroundLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
+ AttachChild(*__pBackgroundLabel);
+ MoveChildToBottom(*__pBackgroundLabel);
+
+ _AccessibilityContainer* pContainer = __pBackgroundLabel->GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->Activate(false);
+ }
}
- int index = 0;
- int subItemCount = __pSubItems->GetCount();
- const _OptionMenuItem* pItem = null;
- for (index = 0; index < subItemCount; index++)
+ Color color= Color(0, 0, 0, 0);
+ if (__selected == true)
+ {
+ color = __selectedBgColor;
+ }
+
+ FloatRectangle bounds = GetBoundsF();
+ _ScrollPanel* pScrollPanel = static_cast<_ScrollPanel*>(GetParent());
+ FloatRectangle boundsScrollPanel = pScrollPanel->GetBoundsF();
+
+ float topOverlap = pScrollPanel->GetScrollPosition() - bounds.y;
+ if (topOverlap > 0.0f)
+ {
+ topMargin = topOverlap + __bgPressedMargin;
+ }
+ else if (!__upperDividerLine)
{
- pItem = static_cast<const _OptionMenuItem*>(__pSubItems->GetAt(index));
- if (pItem != null)
+ topMargin = __bgPressedMargin;
+ }
+
+ float bottomOverlap = bounds.y + bounds.height - (pScrollPanel->GetScrollPosition() + boundsScrollPanel.height);
+ if (bottomOverlap > 0.0f)
+ {
+ bottomMargin = bottomOverlap + __bgPressedMargin;
+ }
+ else if (!__lowerDividerLine)
+ {
+ bottomMargin = __bgPressedMargin;
+ }
+
+ __pBackgroundLabel->SetBounds(FloatRectangle(__bgPressedMargin, topMargin, bounds.width - __bgPressedMargin * 2.0f, bounds.height - topMargin - bottomMargin));
+
+ Bitmap* BgBitmap = _BitmapImpl::GetColorReplacedBitmapN(*__pMagentaBgBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
+ SysTryReturnVoidResult(NID_UI_CTRL, BgBitmap, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ __pBackgroundLabel->SetBackgroundBitmap(*BgBitmap);
+ delete BgBitmap;
+ BgBitmap = null;
+
+ __pBackgroundLabel->Invalidate();
+}
+
+void
+_OptionMenuItem::DrawItemLowerDivider(void)
+{
+ if (__pLowerDividerLineLabel == null)
+ {
+ __pLowerDividerLineLabel = _Label::CreateLabelN();
+ SysTryReturnVoidResult(NID_UI_CTRL, __pLowerDividerLineLabel, E_OUT_OF_MEMORY, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ FloatRectangle bounds = GetBoundsF();
+ __pLowerDividerLineLabel->SetBounds(FloatRectangle(__leftMargin, bounds.height - __dividerHeight, bounds.width - __leftMargin - __rightMargin, __dividerHeight));
+
+ AttachChild(*__pLowerDividerLineLabel);
+
+ _AccessibilityContainer* pContainer = __pLowerDividerLineLabel->GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->Activate(false);
+ }
+ }
+
+ Color dividerLineColor = Color(0, 0, 0, 0);
+ if (__selected == false)
+ {
+ dividerLineColor = __lowerDividerLineColor;
+ }
+
+ __pLowerDividerLineLabel->SetBackgroundColor(dividerLineColor);
+ __pLowerDividerLineLabel->Invalidate();
+}
+
+_UiTouchEventDelivery
+_OptionMenuItem::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
+{
+ SetAndInvalidate(true);
+
+ return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
+}
+
+bool
+_OptionMenuItem::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
+{
+ SetAndInvalidate(true);
+
+ return false;
+}
+
+_UiTouchEventDelivery
+_OptionMenuItem::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
+{
+ TouchMoved(source, touchinfo);
+
+ return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
+}
+
+bool
+_OptionMenuItem::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
+{
+ TouchMoved(source, touchinfo);
+
+ return false;
+}
+
+_UiTouchEventDelivery
+_OptionMenuItem::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
+{
+ SetAndInvalidate(false);
+
+ return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
+}
+
+bool
+_OptionMenuItem::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
+{
+ SetAndInvalidate(false);
+
+ return false;
+}
+
+
+void
+_OptionMenuItem::TouchMoved(const _Control& source, const _TouchInfo& touchinfo)
+{
+ FloatPoint touchPosition = touchinfo.GetCurrentPosition();
+
+ if (__pressed)
+ {
+ if (__parentScrollEnable)
{
- if (pItem->__actionId == actionId)
+ if (__selected)
+ {
+ __selected = false;
+ Invalidate();
+ }
+ }
+ else
+ {
+ int oldSelected = __selected;
+
+ FloatRectangle bounds(0.0f, 0.0f, __size.width, __size.height);
+ if (bounds.Contains(touchPosition))
{
- return index;
+ __selected = true;
+ }
+ else
+ {
+ __selected = false;
+ }
+
+ if (oldSelected != __selected)
+ {
+ Invalidate();
}
}
}
+}
- return -1;
+void
+_OptionMenuItem::OnFontChanged(Tizen::Graphics::Font* pFont)
+{
+ String fontName = _Control::GetFont();
+
+ if (__pTextLabel != null)
+ {
+ __pTextLabel->SetFont(fontName);
+ }
+}
+
+void
+_OptionMenuItem::OnFontInfoRequested(unsigned long& style, float& size)
+{
+ style = FONT_STYLE_PLAIN;
+ size = __textSize;
+}
+
+void
+_OptionMenuItem::SetParentScrollEnable(bool enable)
+{
+ __parentScrollEnable = enable;
}
bool
-_OptionMenuItem::HasSubItem(void) const
+_OptionMenuItem::GetParentScrollEnable() const
{
- return (__pSubItems != null && __pSubItems->GetCount() > 0);
+ return __parentScrollEnable;
+}
+
+bool
+_OptionMenuItem::IsSelected() const
+{
+ return __selected;
+}
+
+void
+_OptionMenuItem::SetAndInvalidate(bool flag)
+{
+ __selected = flag;
+ __pressed = flag;
+ Invalidate();
+}
+
+const Tizen::Graphics::Bitmap*
+_OptionMenuItem::GetMagentaBgBitmap() const
+{
+ return __pMagentaBgBitmap;
}
}}} // Tizen::Ui::Controls
+++ /dev/null
-//\r
-// Open Service Platform\r
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-/**\r
- * @file FUiCtrl_OptionMenuListPresenter.cpp\r
- * @brief This is the implementation file for the _OptionMenuListPresenter class.\r
- */\r
-\r
-#include <FBaseErrorDefine.h>\r
-#include <FBaseSysLog.h>\r
-#include <FGrp_BitmapImpl.h>\r
-#include <FGrp_CanvasImpl.h>\r
-#include <FGrp_TextTextSimple.h>\r
-#include "FUi_AccessibilityContainer.h"\r
-#include "FUi_AccessibilityElement.h"\r
-#include "FUi_CoordinateSystemUtils.h"\r
-#include "FUi_Math.h"\r
-#include "FUi_ResourceManager.h"\r
-#include "FUiCtrl_ActionEvent.h"\r
-#include "FUiCtrl_IActionEventListener.h"\r
-\r
-#include "FUiCtrl_OptionMenuListPresenter.h"\r
-\r
-using namespace Tizen::Graphics;\r
-using namespace Tizen::Ui;\r
-using namespace Tizen::Base;\r
-using namespace Tizen::Base::Runtime;\r
-using namespace Tizen::Graphics::_Text;\r
-\r
-const int MAX_MAIN_ITEM_COUNT = 12;\r
-\r
-namespace {\r
-static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;\r
-static const int CONTEXT_MENU_LIST_ELEMENT_TEXT = 0;\r
-static const int CONTEXT_MENU_LIST_ELEMENT_BITMAP = 1;\r
-}\r
-\r
-namespace Tizen { namespace Ui { namespace Controls\r
-{\r
-\r
-_OptionMenuListPresenter::_OptionMenuListPresenter(_ContextMenu* pContextMenu)\r
- : __pContextMenu(pContextMenu)\r
- , __pModel(null)\r
- , __pFont(null)\r
- , __layoutSize(FloatDimension(0.0f, 0.0f))\r
- , __touchOutRect(false)\r
- , __selectedIndex(-1)\r
- , __scrollEnable(false)\r
- , __maxWidth(0.0f)\r
- , __minWidth(0.0f)\r
- , __topMargin(0.0f)\r
- , __bottomMargin(0.0f)\r
- , __leftMargin(0.0f)\r
- , __rightMargin(0.0f)\r
- , __screenTopMargin(0.0f)\r
- , __screenBottomMargin(0.0f)\r
- , __screenLeftMargin(0.0f)\r
- , __screenRightMargin(0.0f)\r
- , __arrowTopMargin(0.0f)\r
- , __arrowBottomMargin(0.0f)\r
- , __arrowRightMargin(0.0f)\r
- , __arrowLeftMargin(0.0f)\r
- , __arrowWidth(0.0f)\r
- , __arrowHeight(0.0f)\r
- , __itemWidth(0.0f)\r
- , __itemMinWidth(0.0f)\r
- , __itemHeight(0.0f)\r
- , __itemMaxWidth(0.0f)\r
- , __itemGap(0.0f)\r
- , __itemBitmapWidth(0.0f)\r
- , __itemBitmapHeight(0.0f)\r
- , __itemFontSize(0.0f)\r
- , __dividerHeight(0.0f)\r
- , __anchorPopupOverlap(0.0f)\r
-{\r
-\r
-}\r
-\r
-_OptionMenuListPresenter::~_OptionMenuListPresenter(void)\r
-{\r
- __pContextMenu = null;\r
-\r
- delete __pModel;\r
- __pModel = null;\r
-\r
- __pFont = null;\r
-\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::Install(void)\r
-{\r
- result r = E_SUCCESS;\r
-\r
- LoadShape();\r
-\r
- __pModel = new (std::nothrow) _ContextMenuModel;\r
- SysTryCatch(NID_UI_CTRL, __pModel != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");\r
-\r
- r = __pModel->Construct();\r
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create data instance.");\r
-\r
- __pFont = __pContextMenu->GetFallbackFont();\r
- r = GetLastResult();\r
- SysTryCatch(NID_UI_CTRL, (__pFont != null), , r, "[%s] Propagating.", GetErrorMessage(r));\r
-\r
- return r;\r
-\r
-CATCH:\r
- delete __pModel;\r
- __pModel = null;\r
-\r
- __pFont = null;\r
-\r
- return r;\r
-}\r
-\r
-\r
-void\r
-_OptionMenuListPresenter::LoadShape(void)\r
-{\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMinWidth);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMaxWidth);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemHeight);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_GAP, _CONTROL_ORIENTATION_PORTRAIT, __itemGap);\r
-\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin);\r
-\r
- GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenTopMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenBottomMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenLeftMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::SCREEN_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __screenRightMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowTopMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowBottomMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowLeftMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __arrowRightMargin);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __arrowWidth);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __arrowHeight);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight);\r
-\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __itemFontSize);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::LIST_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight);\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ANCHOR_POPUP_OVERLAP, _CONTROL_ORIENTATION_PORTRAIT, __anchorPopupOverlap);\r
-\r
- __itemWidth = __itemMinWidth;\r
-}\r
-\r
-_ContextMenuItem*\r
-_OptionMenuListPresenter::CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
-{\r
- _ContextMenuItem* pItem = _ContextMenuItem::CreateContextMenuItemN();\r
- SysTryReturn(NID_UI_CTRL, pItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
-\r
- ContextMenuItemDrawingType itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_TEXT;\r
- _Label* pLabel = null;\r
- result r = E_SUCCESS;\r
-\r
- if (pNormalBitmap != null)\r
- {\r
- r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_NORMAL, pNormalBitmap);\r
- if (r != E_SUCCESS)\r
- {\r
- delete pItem;\r
- return null;\r
- }\r
-\r
- // add bitmap label\r
- pLabel = _Label::CreateLabelN();\r
- pLabel->SetBackgroundBitmap(*pNormalBitmap);\r
- pLabel->SetBackgroundColor(Color(0, 0, 0, 0));\r
-\r
- int bitmapY = (__itemHeight - __itemBitmapHeight ) / 2;\r
- pLabel->SetBounds(FloatRectangle(__leftMargin, bitmapY, __itemBitmapWidth, __itemBitmapHeight));\r
- pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);\r
- pItem->AttachChild(*pLabel);\r
- _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();\r
- if (pContainer)\r
- {\r
- pContainer->Activate(false);\r
- }\r
- pItem->SetBitmapLabel(pLabel);\r
-\r
- itemType = CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP;\r
- }\r
-\r
- if (pPressedBitmap != null)\r
- {\r
- r = pItem->SetBitmap(CONTEXT_MENU_ITEM_DRAWING_STATUS_PRESSED, pPressedBitmap);\r
- if (r != E_SUCCESS)\r
- {\r
- delete pItem;\r
- return null;\r
- }\r
- }\r
-\r
- pItem->SetType(itemType);\r
- pItem->SetActionId(actionId);\r
-\r
- pItem->SetTextSize(__itemFontSize);\r
- r = pItem->SetText(text);\r
- if (r != E_SUCCESS)\r
- {\r
- delete pItem;\r
- return null;\r
- }\r
-\r
- // calculate item size\r
- float bitmapWidth = (itemType == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP) ? __itemBitmapWidth : 0.0f;\r
-\r
- FloatDimension textArea(0.0f, 0.0f);\r
- FloatDimension itemSize(0.0f, 0.0f);\r
-\r
- __pFont->GetTextExtent(text, text.GetLength(), textArea);\r
- float labelLeftMargin = 0.0f, labelTopMargin = 0.0f;\r
- GET_SHAPE_CONFIG(LABEL::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelLeftMargin);\r
- GET_SHAPE_CONFIG(LABEL::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelTopMargin);\r
- textArea.width += 2.0f * labelLeftMargin;\r
- textArea.height += 2.0f * labelTopMargin;\r
- itemSize.height = __itemHeight + (__dividerHeight * 2.0f);\r
- itemSize.width = __leftMargin + textArea.width + __rightMargin + bitmapWidth;\r
-\r
- itemSize.width = itemSize.width < __itemMinWidth ? __itemMinWidth : itemSize.width;\r
-\r
- if (itemSize.width > __itemMaxWidth)\r
- {\r
- textArea.width -= itemSize.width - __itemMaxWidth;\r
- itemSize.width = __itemMaxWidth;\r
- }\r
-\r
- pItem->SetSize(itemSize);\r
-\r
- // add text label\r
- float textLabelX = __leftMargin + bitmapWidth;\r
-\r
- pLabel = _Label::CreateLabelN();\r
- pLabel->SetText(text);\r
- ContextMenuCoreItemStatus itemStatus = CONTEXT_MENU_CORE_ITEM_STATUS_NORMAL;\r
- pLabel->SetTextColor(__pContextMenu->GetTextColor(itemStatus));\r
- pLabel->SetBackgroundColor(Color(0, 0, 0, 0));\r
-\r
- itemSize = pItem->GetSize();\r
- pLabel->SetBounds(FloatRectangle(textLabelX, (itemSize.height - textArea.height) / 2.0f, textArea.width, textArea.height));\r
- pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);\r
- pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);\r
- pLabel->SetTextConfig(__itemFontSize, LABEL_TEXT_STYLE_NORMAL);\r
-\r
- pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);\r
- pItem->AttachChild(*pLabel);\r
- _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();\r
- if (pContainer)\r
- {\r
- pContainer->Activate(false);\r
- }\r
- pItem->SetTextLabel(pLabel);\r
-\r
- __itemWidth = __itemWidth < itemSize.width ? itemSize.width : __itemWidth;\r
-\r
- pItem->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);\r
- return pItem;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap,\r
- const Tizen::Graphics::Bitmap* pPressedBitmap,\r
- const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
-{\r
- SysTryReturn(NID_UI_CTRL, (__pModel->GetItemCount() < MAX_MAIN_ITEM_COUNT), E_SYSTEM, E_SYSTEM,\r
- "[E_SYSTEM] A system error has occurred. The maximum items count is reached.");\r
- _ContextMenuItem* pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
- SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
-\r
- result r = __pModel->AddItem(pItem);\r
-\r
- if (r != E_SUCCESS)\r
- {\r
- delete pItem;\r
- SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");\r
- }\r
-\r
- return r;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::InsertItem(int index, const Tizen::Base::String& text, int actionId,\r
- const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap,\r
- const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
-{\r
- if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null)\r
- {\r
- return E_INVALID_ARG;\r
- }\r
-\r
- _ContextMenuItem* pItem = null;\r
-\r
- pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
- SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
-\r
- result r = __pModel->InsertItem(pItem, index);\r
- if (r != E_SUCCESS)\r
- {\r
- delete pItem;\r
- SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");\r
- }\r
-\r
- return E_SUCCESS;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::SetItem(int index, const Tizen::Base::String& text, int actionId,\r
- const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap,\r
- const Tizen::Graphics::Bitmap* pHighlightedBitmap)\r
-{\r
- if (text.GetLength() == 0 && normalBitmap == null && pPressedBitmap == null)\r
- {\r
- return E_INVALID_ARG;\r
- }\r
-\r
- result r = __pContextMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index));\r
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item.");\r
-\r
- _ContextMenuItem* pItem = null;\r
- pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);\r
- SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
-\r
- r = __pModel->SetItem(pItem, index);\r
- if (r != E_SUCCESS)\r
- {\r
- delete pItem;\r
- SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");\r
- }\r
-\r
- return E_SUCCESS;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::DeleteItem(int index)\r
-{\r
- if (__pContextMenu->GetItemCount() <= 0)\r
- {\r
- SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument.");\r
- return E_INVALID_STATE;\r
- }\r
-\r
- result r = __pContextMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index));\r
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item.");\r
-\r
- r = __pModel->RemoveItem(index);\r
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item.");\r
-\r
- return r;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::DeleteItemAll(void)\r
-{\r
- if (__pContextMenu->GetItemCount() <= 0)\r
- {\r
- SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument.");\r
- return E_INVALID_STATE;\r
- }\r
-\r
- __pContextMenu->GetScrollPanel()->DetachAllChildren();\r
-\r
- result r = __pModel->RemoveAllItem();\r
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item all.");\r
-\r
- return r;\r
-}\r
-\r
-\r
-int\r
-_OptionMenuListPresenter::CalculateShowItemCount(void)\r
-{\r
- int itemMaxCount = 0;\r
- _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();\r
- GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, orientation, itemMaxCount);\r
-\r
- int maxVisibleCount = __pContextMenu->GetShowItemCount();\r
-\r
- return maxVisibleCount > itemMaxCount ? itemMaxCount : maxVisibleCount;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::CalculateWindowRect(void)\r
-{\r
- result r = CalculateRect();\r
- AdjustItemPosition();\r
-\r
- return r;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::ApplyColorProperty(void)\r
-{\r
- return E_SUCCESS;\r
-}\r
-\r
-\r
-result\r
-_OptionMenuListPresenter::CalculateRect(void)\r
-{\r
- Tizen::Graphics::FloatRectangle windowRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // ContextMenu window itself\r
- Tizen::Graphics::FloatRectangle bodyRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // bg surronding showing items, relative to window\r
- Tizen::Graphics::FloatRectangle arrowRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // relative to window\r
- Tizen::Graphics::FloatRectangle itemRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // relative to window\r
-\r
- float bodyTopMargin = __topMargin;\r
- float bodyBottomMargin = __bottomMargin;\r
- float bodyLeftMargin = __leftMargin;\r
- float bodyRightMargin = __rightMargin;\r
-\r
-\r
- FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();\r
-\r
- if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)\r
- {\r
- screen.SetSize(screen.height, screen.width);\r
- }\r
-\r
- // calculate layout size (__layoutSize)\r
- AdjustItemLayout();\r
-\r
- bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin;\r
- bodyRect.height = __layoutSize.height + bodyTopMargin + bodyBottomMargin;\r
-\r
- bodyRect.x = 0;\r
- // Set body position y\r
- bodyRect.y = screen.height - bodyRect.height;\r
- // - check top margin\r
-\r
-\r
- float correctLength = __arrowTopMargin - __anchorPopupOverlap;\r
- windowRect.x = bodyRect.x;\r
- windowRect.y = bodyRect.y;\r
- windowRect.width = bodyRect.width;\r
- windowRect.height = bodyRect.height;\r
-\r
- bodyRect.x = 0.0f;\r
- bodyRect.y = 0.0f;\r
-\r
-\r
- if (_ControlManager::GetInstance()->GetOrientationStatus() == _CONTROL_ROTATION_270)\r
- {\r
- windowRect.x = screen.width - bodyRect.width;\r
- }\r
-\r
- itemRect.x = bodyRect.x;\r
- itemRect.y = bodyRect.y;\r
- itemRect.width = __layoutSize.width;\r
- itemRect.height = __layoutSize.height;\r
-\r
- __pContextMenu->SetWindowRect(windowRect);\r
- __pContextMenu->SetBodyRect(bodyRect);\r
- __pContextMenu->SetArrowRect(arrowRect);\r
- __pContextMenu->SetItemRect(itemRect);\r
-\r
- // _ScrollPanel API call sequence: SetBounds() -> SetScrollAreaBounds()\r
- // _Scroll visual interaction if Bounds < ScrollAreaBounds\r
- if (__pContextMenu->IsVisible())\r
- {\r
- __pContextMenu->GetScrollPanel()->SetBounds(FloatRectangle(bodyRect.x + bodyLeftMargin, bodyRect.y + bodyTopMargin, __layoutSize.width, __layoutSize.height));\r
- int itemCount = __pModel->GetItemCount();\r
- float itemHeight = __itemHeight + (__dividerHeight * 2.0f);\r
- float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);\r
- __pContextMenu->GetScrollPanel()->SetClientAreaHeight(layoutClientHeight);\r
- }\r
-\r
- __pContextMenu->SetMovable(true);\r
- __pContextMenu->SetResizable(true);\r
-\r
- __pContextMenu->SetMinimumSize(FloatDimension(0.0f, 0.0f));\r
- __pContextMenu->SetMaximumSize(screen);\r
- __pContextMenu->SetBounds(windowRect);\r
-\r
- __pContextMenu->SetMovable(false);\r
- __pContextMenu->SetResizable(false);\r
-\r
- return E_SUCCESS;\r
-}\r
-\r
-void\r
-_OptionMenuListPresenter::AdjustItemLayout(void)\r
-{\r
- FloatDimension layoutSize(0.0f, 0.0f);\r
-\r
- int itemCount = __pModel->GetItemCount();\r
- if (itemCount <= 0)\r
- {\r
- __layoutSize.width = __itemWidth;\r
- __layoutSize.height = __itemHeight;\r
- return;\r
- }\r
-\r
- layoutSize = AdjustItemLayoutStyle();\r
-\r
- FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();\r
- if (__pContextMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)\r
- {\r
- screen.SetSize(screen.height, screen.width);\r
- }\r
-\r
- int maxHeight = screen.height;// - __screenTopMargin - __screenBottomMargin - __arrowHeight;\r
- if (layoutSize.height > maxHeight)\r
- {\r
- layoutSize.height = maxHeight;\r
- }\r
-\r
- __layoutSize = layoutSize;\r
-}\r
-\r
-\r
-Tizen::Graphics::FloatDimension\r
-_OptionMenuListPresenter::AdjustItemLayoutStyle(void)\r
-{\r
- int itemMaxCount = CalculateShowItemCount();\r
-\r
- int itemCount = __pModel->GetItemCount();\r
- float itemHeight = __itemHeight + (__dividerHeight * 2.0f);\r
-\r
- FloatDimension layoutSize(__itemWidth, 0.0f);\r
-\r
- float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);\r
- float layoutMaxHeight = itemMaxCount * itemHeight - (__dividerHeight * 2.0f);\r
- if (layoutClientHeight > layoutMaxHeight)\r
- {\r
- __scrollEnable = true;\r
- layoutSize.height = layoutMaxHeight;\r
- }\r
- else\r
- {\r
- __scrollEnable = false;\r
- layoutSize.height = layoutClientHeight;\r
- }\r
-\r
- return layoutSize;\r
-}\r
-\r
-void\r
-_OptionMenuListPresenter::AdjustItemPosition(void)\r
-{\r
- int itemCount = __pModel->GetItemCount();\r
- if (itemCount <= 0)\r
- {\r
- return;\r
- }\r
-\r
- float itemHeight = __itemHeight + (__dividerHeight * 2.0f);\r
- float drawItemY = 0.0f;\r
-\r
- float x = __pContextMenu->GetBodyRect().x;\r
- float y = __pContextMenu->GetBodyRect().y ;\r
-\r
- _ContextMenuItem* pItem = null;\r
-\r
- for (int i = 0; i < itemCount; i++)\r
- {\r
- pItem = __pModel->GetItem(i);\r
-\r
- if (pItem == null)\r
- {\r
- break;\r
- }\r
-\r
- FloatRectangle drawRect(x, drawItemY + y, __itemWidth, itemHeight);\r
-\r
- pItem->SetDrawRect(drawRect);\r
- pItem->SetUpperDivider(i > 0);\r
- pItem->SetLowerDivider(i < itemCount - 1);\r
- pItem->SetParentScrollEnable(__scrollEnable);\r
- pItem->SetBounds(FloatRectangle(0.0f, drawItemY, drawRect.width, drawRect.height));\r
-\r
- if (pItem->HasParent() == false)\r
- {\r
- __pContextMenu->GetScrollPanel()->AttachChild(*pItem);\r
- }\r
-\r
- drawItemY += itemHeight;\r
- }\r
-}\r
-\r
-int\r
-_OptionMenuListPresenter::GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& point) const\r
-{\r
- int index = -1;\r
- int itemCount = __pModel->GetItemCount();\r
-\r
- if (itemCount < 0)\r
- {\r
- return -1;\r
- }\r
-\r
- _ContextMenuItem* pItem = null;\r
-\r
- float scrollPosition = __pContextMenu->GetScrollPanel()->GetScrollPosition();\r
- FloatPoint position(point.x, point.y + scrollPosition);\r
-\r
- for (int i = 0; i < itemCount; i++)\r
- {\r
- pItem = __pModel->GetItem(i);\r
-\r
- if (pItem == null)\r
- {\r
- break;\r
- }\r
-\r
- FloatRectangle drawRect = pItem->GetDrawRect();\r
-\r
- if (drawRect.Contains(position) == true)\r
- {\r
- index = i;\r
- break;\r
- }\r
- }\r
-\r
- return index;\r
-}\r
-\r
-\r
-result\r
-_OptionMenuListPresenter::Draw(void)\r
-{\r
- result r = E_SUCCESS;\r
-\r
- Canvas* pCanvas = __pContextMenu->GetCanvasN();\r
- SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");\r
-\r
- // Clear canvas for drawing area of the ContextMenu.\r
- pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));\r
- Tizen::Graphics::FloatRectangle bounds(__pContextMenu->GetWindowRect());\r
- pCanvas->Clear(Tizen::Graphics::FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));\r
-\r
- r = DrawBackground(pCanvas);\r
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw background.");\r
-\r
- //r = DrawArrow(pCanvas);\r
- //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw arrow.");\r
-\r
- delete pCanvas;\r
-\r
- return r;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::DrawBackground(Canvas* pCanvas)\r
-{\r
- SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
-\r
- result r = E_SUCCESS;\r
-\r
- Tizen::Graphics::FloatRectangle bodyRect = __pContextMenu->GetBodyRect();\r
-\r
- const Bitmap* pBackgroundNormalBitmap = __pContextMenu->GetBackgroundNormalBitmap();\r
- const Bitmap* pBackgroundEffectBitmap = __pContextMenu->GetBackgroundEffectBitmap();\r
-\r
- if (pBackgroundNormalBitmap == null && pBackgroundEffectBitmap == null)\r
- {\r
- pCanvas->SetForegroundColor(__pContextMenu->GetColor());\r
- pCanvas->DrawRectangle(bodyRect);\r
- }\r
- else\r
- {\r
- if (pBackgroundNormalBitmap != null)\r
- {\r
- r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundNormalBitmap);\r
- }\r
-\r
- if (pBackgroundEffectBitmap != null)\r
- {\r
- r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundEffectBitmap);\r
- }\r
- }\r
-\r
- return r;\r
-}\r
-\r
-\r
-result\r
-_OptionMenuListPresenter::DrawArrow(Canvas* pCanvas)\r
-{\r
- SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");\r
-\r
- result r = E_SUCCESS;\r
- Tizen::Graphics::FloatRectangle arrowRect = __pContextMenu->GetArrowRect();\r
- ContextMenuCoreDropPosition dropPosition = __pContextMenu->GetDropPosition();\r
-\r
- const Bitmap* pArrowNormalBitmap = __pContextMenu->GetArrowNormalBitmap(dropPosition);\r
- const Bitmap* pEffectArrowBitmap = __pContextMenu->GetArrowEffectBitmap(dropPosition);\r
-\r
- if (pArrowNormalBitmap != null)\r
- {\r
- r = DrawBitmap(*pCanvas, arrowRect, *pArrowNormalBitmap);\r
- }\r
-\r
- if (pEffectArrowBitmap != null)\r
- {\r
- r = DrawBitmap(*pCanvas, arrowRect, *pEffectArrowBitmap);\r
- }\r
-\r
- return r;\r
-}\r
-\r
-_UiTouchEventDelivery\r
-_OptionMenuListPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;\r
-}\r
-\r
-bool\r
-_OptionMenuListPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- FloatPoint touchPosition = touchinfo.GetCurrentPosition();\r
- FloatRectangle itemRect = __pContextMenu->GetItemRect();\r
-\r
- if (!itemRect.Contains(touchPosition))\r
- {\r
- __selectedIndex = -1;\r
- __touchOutRect = true;\r
- return true;\r
- }\r
-\r
- __selectedIndex = GetItemIndexFromPosition(touchPosition);\r
- __touchOutRect = false;\r
- return true;\r
-}\r
-\r
-_UiTouchEventDelivery\r
-_OptionMenuListPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;\r
-}\r
-\r
-bool\r
-_OptionMenuListPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- FloatPoint touchPosition = touchinfo.GetCurrentPosition();\r
-\r
- if (__touchOutRect)\r
- {\r
- FloatRectangle itemRect = __pContextMenu->GetItemRect();\r
- if (!itemRect.Contains(touchPosition))\r
- {\r
- __selectedIndex = -1;\r
- __pContextMenu->SetVisibleState(false);\r
-\r
- return true;\r
- }\r
- }\r
-\r
- int currentSelectedIndex = GetItemIndexFromPosition(touchPosition);\r
- if (__selectedIndex != -1 && (__selectedIndex == currentSelectedIndex))\r
- {\r
- _ContextMenuItem* pItem = null;\r
- pItem = __pModel->GetItem(__selectedIndex);\r
-\r
- __selectedIndex = -1;\r
- __pContextMenu->SetVisibleState(false);\r
-\r
- int actionId = pItem->GetActionId();\r
-\r
- _ActionEvent* pActionEvent = __pContextMenu->GetActionEvent();\r
- if (pActionEvent == null)\r
- {\r
- return true;\r
- }\r
-\r
- IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);\r
- if (pEventArg == null)\r
- {\r
- return true;\r
- }\r
-\r
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);\r
- pActionEvent->Fire(*pEventArg);\r
- }\r
-\r
- return true;\r
-}\r
-\r
-_UiTouchEventDelivery\r
-_OptionMenuListPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;\r
-}\r
-\r
-bool\r
-_OptionMenuListPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- if (__scrollEnable)\r
- {\r
- __selectedIndex = -1;\r
- }\r
-\r
- return true;\r
-}\r
-\r
-bool\r
-_OptionMenuListPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)\r
-{\r
- __pModel->ResetAllItem();\r
-\r
- return true;\r
-}\r
-\r
-void\r
-_OptionMenuListPresenter::OnFontChanged(Tizen::Graphics::Font* pFont)\r
-{\r
- __pFont = pFont;\r
- String fontName = __pContextMenu->GetFont();\r
-\r
- int itemCount = __pModel->GetItemCount();\r
- for (int i = 0; i < itemCount; i++)\r
- {\r
- _ContextMenuItem* pItem = __pModel->GetItem(i);\r
- if (pItem != null)\r
- {\r
- pItem->SetFont(fontName);\r
- }\r
- }\r
-}\r
-\r
-void\r
-_OptionMenuListPresenter::OnFontInfoRequested(unsigned long& style, float& size)\r
-{\r
- style = FONT_STYLE_PLAIN;\r
- size = __itemFontSize;\r
-}\r
-\r
-void\r
-_OptionMenuListPresenter::SetAllAccessibilityElement(void)\r
-{\r
- _AccessibilityContainer* pContainerContextMenu = __pContextMenu->GetAccessibilityContainer();\r
- if (pContainerContextMenu != null)\r
- {\r
- _AccessibilityElement* pElementContextMenu = new (std::nothrow) _AccessibilityElement(true);\r
- SysTryReturnVoidResult(NID_UI_CTRL, pElementContextMenu, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");\r
-\r
- pElementContextMenu->SetSupportOperatingGesture(false);\r
- pElementContextMenu->SetTrait(L"Contextual popup");\r
- pElementContextMenu->SetHint(L"double tap to close");\r
- pElementContextMenu->SetBounds(FloatRectangle(0.0f, 0.0f, __pContextMenu->GetBoundsF().width, __pContextMenu->GetBoundsF().height));\r
- pContainerContextMenu->AddElement(*pElementContextMenu);\r
- __pContextMenu->AddAccessibilityElement(*pElementContextMenu);\r
-\r
- int itemCount = __pModel->GetItemCount();\r
- for (int i = 0; i < itemCount; i++)\r
- {\r
- _ContextMenuItem* pItem = __pModel->GetItem(i);\r
- if (pItem)\r
- {\r
- _AccessibilityContainer* pContainer = pItem->GetAccessibilityContainer();\r
- if (pContainer != null)\r
- {\r
- LinkedListT<_AccessibilityElement*> accessibilityElements;\r
- _AccessibilityElement* pElement = null;\r
-\r
- pContainer->GetElements(accessibilityElements);\r
- if (accessibilityElements.GetAt(0, pElement) == E_SUCCESS)\r
- {\r
- pElement->SetName(L"ContextMenuItem" + Integer::ToString(i));\r
- if (pItem->GetType() == CONTEXT_MENU_ITEM_DRAWING_TYPE_BITMAP)\r
- {\r
- pElement->SetLabel(L"icon " + pItem->GetText());\r
- }\r
- else\r
- {\r
- pElement->SetLabel(pItem->GetText());\r
- }\r
-\r
- pElement->SetBounds(FloatRectangle(0.0f, 0.0f, pItem->GetBoundsF().width, pItem->GetBoundsF().height));\r
- }\r
- pContainerContextMenu->AddChildContainer(*pContainer);\r
- }\r
- }\r
- }\r
- }\r
-}\r
-\r
-_ContextMenuItemInfo\r
-_OptionMenuListPresenter::GetItemFromPosition(const FloatPoint& position)\r
-{\r
- _ContextMenuItemInfo itemInfo;\r
- int index = GetItemIndexFromPosition(position);\r
- itemInfo.pContextMenuItem = __pModel->GetItem(index);\r
-\r
- itemInfo.bListItem = false;\r
- itemInfo.pListItem = null;\r
- return itemInfo;\r
-}\r
-\r
-_ContextMenuItemInfo\r
-_OptionMenuListPresenter::FindItem(int index)\r
-{\r
- _ContextMenuItemInfo itemInfo;\r
- itemInfo.bListItem = false;\r
- itemInfo.pListItem = null;\r
- itemInfo.pContextMenuItem = __pModel->GetItem(index);\r
- return itemInfo;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::SetTopDrawnItemIndex(int index)\r
-{\r
- return E_SUCCESS;\r
-}\r
-\r
-result\r
-_OptionMenuListPresenter::DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Graphics::Bitmap& bitmap)\r
-{\r
- result r = E_SUCCESS;\r
- if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))\r
- {\r
- r = canvas.DrawNinePatchedBitmap(bounds, bitmap);\r
- SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.")\r
- }\r
- else\r
- {\r
- r = canvas.DrawBitmap(bounds, bitmap);\r
- SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.")\r
- }\r
-\r
- return r;\r
-}\r
-\r
-}}} // Tizen::Ui: Control\r
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-
/**
* @file FUiCtrl_OptionMenuModel.cpp
* @brief This is the implementation file for the _OptionMenuModel class.
*/
-#include <new>
-#include <FBaseSysLog.h>
#include <FBaseErrorDefine.h>
-
+#include <FBaseSysLog.h>
#include "FUiCtrl_OptionMenuModel.h"
-#include "FUiCtrl_OptionMenuItem.h"
+static const int DEFAULT_ITEM_COUNT = 32;
const int INVALID_INDEX = -1;
const int MAX_MAIN_ITEM_COUNT = 12;
const int MAX_SUB_ITEM_COUNT = 32;
-using namespace Tizen::Base;
+using namespace Tizen::Graphics;
namespace Tizen { namespace Ui { namespace Controls
{
_OptionMenuModel::_OptionMenuModel(void)
- : __items()
{
+
}
_OptionMenuModel::~_OptionMenuModel(void)
__items.RemoveAll(true);
}
-_OptionMenuModel*
-_OptionMenuModel::CreateInstanceN(void)
-{
- _OptionMenuModel* pModel = new (std::nothrow) _OptionMenuModel;
- SysTryReturn(NID_UI_CTRL, (pModel != null), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- result r = pModel->__items.Construct(MAX_MAIN_ITEM_COUNT);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
- return pModel;
+result
+_OptionMenuModel::Construct(void)
+{
+ result r = __items.Construct(DEFAULT_ITEM_COUNT);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to construct ArrayList.");
-CATCH:
- delete pModel;
- return null;
+ return r;
}
-result
-_OptionMenuModel::AddItem(const String& text, int actionId, int mainIndex)
+bool
+_OptionMenuModel::IsValidItem(_OptionMenuItem *pItem)
{
- SysTryReturn(NID_UI_CTRL,
- (mainIndex >= INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", mainIndex);
- SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex);
-
- result r = E_SUCCESS;
- _OptionMenuItem* pItem = null;
- if (mainIndex == INVALID_INDEX)
+ if (pItem == null)
{
- // Add MainItem
- SysTryReturn(NID_UI_CTRL, (__items.GetCount() < MAX_MAIN_ITEM_COUNT), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of items.");
- SysTryReturn(NID_UI_CTRL, (GetItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId);
-
- pItem = _OptionMenuItem::CreateInstanceN();
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- pItem->SetText(text);
- pItem->SetActionId(actionId);
-
- r = __items.Add(*pItem);
- if (r != E_SUCCESS)
- {
- delete pItem;
- SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
- return r;
- }
+ return false;
}
- else
- {
- // Add SubItem
- pItem = GetItem(mainIndex);
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
- SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemCount() < MAX_SUB_ITEM_COUNT), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of items.");
- SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId);
+ int actionId = pItem->GetActionId();
+ int itemCount = __items.GetCount();
- _OptionMenuItem* pSubItem = _OptionMenuItem::CreateInstanceN();
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pSubItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ for (int i = 0; i < itemCount; i++)
+ {
+ _OptionMenuItem* pTargetItem = GetItem(i);
- pSubItem->SetText(text);
- pSubItem->SetActionId(actionId);
+ if (pTargetItem == null)
+ return false;
- r = pItem->InsertSubItemAt(*pSubItem, pItem->GetSubItemCount());
- if (r != E_SUCCESS)
+ if (pTargetItem->GetActionId() == actionId)
{
- delete pSubItem;
- SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
- return r;
+ return false;
}
}
- return E_SUCCESS;
+ return true;
}
-result
-_OptionMenuModel::InsertItemAt(const String& text, int actionId, int mainIndex, int subIndex)
+int
+_OptionMenuModel::GetItemCount(void) const
{
- SysTryReturn(NID_UI_CTRL,
- (mainIndex > INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified index (%d) is out of range.", mainIndex);
- SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex);
-
- result r = E_SUCCESS;
- _OptionMenuItem* pItem = null;
- if (subIndex == INVALID_INDEX)
- {
- // Insert MainItem
- SysTryReturn(NID_UI_CTRL, (__items.GetCount() < MAX_MAIN_ITEM_COUNT), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of items.");
- SysTryReturn(NID_UI_CTRL, (GetItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId);
- pItem = _OptionMenuItem::CreateInstanceN();
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ return __items.GetCount();
+}
- pItem->SetText(text);
- pItem->SetActionId(actionId);
+result
+_OptionMenuModel::AddItem(_OptionMenuItem* pItem, int mainIndex)
+{
+ result r = E_SUCCESS;
- r = __items.InsertAt(*pItem, mainIndex);
- if (r != E_SUCCESS)
- {
- delete pItem;
- SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
- return r;
- }
+ if (IsValidItem(pItem) == false)
+ {
+ return E_SYSTEM;
+ }
+
+ if (mainIndex == INVALID_INDEX)
+ {
+ r = __items.Add(*pItem);
}
else
{
- // Insert SubItem
- pItem = GetItem(mainIndex);
- r = GetLastResult();
+ _OptionMenuItem* pMainItem = GetItem(mainIndex);
+ result r = GetLastResult();
SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
- SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemCount() < MAX_SUB_ITEM_COUNT), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has maximum number of sub items.");
- SysTryReturn(NID_UI_CTRL,
- (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex);
- SysTryReturn(NID_UI_CTRL, (subIndex <= pItem->GetSubItemCount()), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available items count.", subIndex);
- SysTryReturn(NID_UI_CTRL, (pItem->GetSubItemIndexFromActionId(actionId) < 0), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The option menu already has an item with the same action id (%d).", actionId);
-
- _OptionMenuItem* pSubItem = _OptionMenuItem::CreateInstanceN();
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pSubItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- pSubItem->SetText(text);
- pSubItem->SetActionId(actionId);
-
- r = pItem->InsertSubItemAt(*pSubItem, subIndex);
+ r = pMainItem->InsertSubItemAt(*pItem, pMainItem->GetSubItemCount());
if (r != E_SUCCESS)
{
- delete pSubItem;
+ delete pItem;
SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
return r;
}
}
- return E_SUCCESS;
+ return E_SUCCESS;
}
result
-_OptionMenuModel::SetItemAt(const String& text, int actionId, int mainIndex, int subIndex)
+_OptionMenuModel::InsertItem( _OptionMenuItem* pItem, int mainIndex, int subIndex)
{
- _OptionMenuItem* pItem = GetItem(mainIndex, subIndex);
- result r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ result r = E_SUCCESS;
+
+ if (IsValidItem(pItem) == false)
+ {
+ return E_SYSTEM;
+ }
if (subIndex == INVALID_INDEX)
{
- int index = GetItemIndexFromActionId(actionId);
- SysTryReturn(NID_UI_CTRL, (index < 0 || mainIndex == index), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified actionId (%d) is not valid", actionId);
+ r = __items.InsertAt(*pItem, mainIndex);
}
else
{
_OptionMenuItem* pMainItem = GetItem(mainIndex);
- SysTryReturn(NID_UI_CTRL, (pMainItem != null), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified main index (%d) does not exists.", mainIndex);
- int index = pMainItem->GetSubItemIndexFromActionId(actionId);
- SysTryReturn(NID_UI_CTRL, (index < 0 || subIndex == index), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified actionId (%d) is not valid", actionId);
- }
+ r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
- pItem->SetText(text);
- pItem->SetActionId(actionId);
+ r = pMainItem->InsertSubItemAt(*pItem, subIndex);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
+ }
+ }
return E_SUCCESS;
}
result
-_OptionMenuModel::RemoveItemAt(int mainIndex, int subIndex)
+_OptionMenuModel::SetItem(_OptionMenuItem* pItem, int mainIndex, int subIndex)
{
- SysTryReturn(NID_UI_CTRL,
- (mainIndex > INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified main index (%d) is out of range.", mainIndex);
- SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex);
+ result r = E_SUCCESS;
- if (subIndex == INVALID_INDEX)
+ // The same ActionId can be used in SetItem.
+ if (IsValidItem(pItem) == false)
{
- // Remove MainItem
- return __items.RemoveAt(mainIndex, true);
+ _OptionMenuItem* pTargetItem = GetItem(mainIndex);
+ if (pItem == null || pTargetItem == null || pItem->GetActionId() != pTargetItem->GetActionId())
+ {
+ //return E_SYSTEM;
+ }
}
- // Remove SubItem
- _OptionMenuItem* pItem = GetItem(mainIndex);
- result r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- SysTryReturn(NID_UI_CTRL,
- (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex);
- SysTryReturn(NID_UI_CTRL, (subIndex < pItem->GetSubItemCount()), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex);
-
- return pItem->RemoveSubItemAt(subIndex);
+ if (subIndex == INVALID_INDEX)
+ {
+ r = __items.SetAt(*pItem, mainIndex, true);
+ }
+ else
+ {
+ _OptionMenuItem* pMainItem = GetItem(mainIndex);
+ r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (pItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ r = pMainItem->SetSubItemAt(*pItem, subIndex);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ SysLogException(NID_UI_CTRL, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
+ }
+ }
+
+ return E_SUCCESS;
}
result
-_OptionMenuModel::RemoveAllItem(void)
+_OptionMenuModel::RemoveItem(int mainIndex, int subIndex)
{
- __items.RemoveAll(true);
- return GetLastResult();
+ if (subIndex == INVALID_INDEX)
+ {
+ return __items.RemoveAt(mainIndex, true);
+ }
+
+ _OptionMenuItem* pMainItem = GetItem(mainIndex);
+ result r = GetLastResult();
+ SysTryReturn(NID_UI_CTRL, (pMainItem != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ SysTryReturn(NID_UI_CTRL,
+ (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), E_OUT_OF_RANGE, E_OUT_OF_RANGE,
+ "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex);
+ SysTryReturn(NID_UI_CTRL, (subIndex < pMainItem->GetSubItemCount()), E_SYSTEM, E_SYSTEM,
+ "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex);
+
+ return pMainItem->RemoveSubItemAt(subIndex);
}
-_OptionMenuItem*
-_OptionMenuModel::GetItem(int mainIndex, int subIndex)
+result
+_OptionMenuModel::RemoveAllItem(void)
{
- SysTryReturn(NID_UI_CTRL,
- (mainIndex > INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified main index (%d) is out of range.", mainIndex);
- SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex);
-
- _OptionMenuItem* pItem = static_cast <_OptionMenuItem*>(__items.GetAt(mainIndex));
- if (subIndex != INVALID_INDEX)
- {
- // Get SubItem
- if (pItem == null)
- {
- return null;
- }
-
- SysTryReturn(NID_UI_CTRL,
- (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex);
- SysTryReturn(NID_UI_CTRL, (subIndex < pItem->GetSubItemCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex);
-
- pItem = pItem->GetSubItem(subIndex);
- }
+ __items.RemoveAll(true);
- return pItem;
+ return E_SUCCESS;
}
-const _OptionMenuItem*
-_OptionMenuModel::GetItem(int mainIndex, int subIndex) const
-{
- SysTryReturn(NID_UI_CTRL,
- (mainIndex >= INVALID_INDEX && mainIndex < MAX_MAIN_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified main index (%d) is out of range.", mainIndex);
- SysTryReturn(NID_UI_CTRL, (mainIndex < __items.GetCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified main index (%d) is greater than the available items count.", mainIndex);
-
- const _OptionMenuItem* pItem = static_cast <const _OptionMenuItem*>(__items.GetAt(mainIndex));
- if (subIndex != INVALID_INDEX)
- {
- // Get SubItem
- if (pItem == null)
- {
- return null;
- }
- SysTryReturn(NID_UI_CTRL,
- (subIndex > INVALID_INDEX && subIndex < MAX_SUB_ITEM_COUNT), null, E_OUT_OF_RANGE,
- "[E_OUT_OF_RANGE] The specified sub index (%d) is out of range.", subIndex);
- SysTryReturn(NID_UI_CTRL, (subIndex < pItem->GetSubItemCount()), null, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The specified sub index (%d) is greater than the available sub items count.", subIndex);
+void
+_OptionMenuModel::ResetAllItem(void)
+{
+ int count = __items.GetCount();
- pItem = pItem->GetSubItem(subIndex);
+ _OptionMenuItem* pItem;
+ for(int index = 0; index < count; index++)
+ {
+ pItem = static_cast <_OptionMenuItem*>(__items.GetAt(index));
+ pItem->SetAndInvalidate(false);
}
-
- return pItem;
-}
-
-int
-_OptionMenuModel::GetItemCount(void) const
-{
- return __items.GetCount();
}
int
return -1;
}
+
int
_OptionMenuModel::GetSubItemCount(int mainIndex) const
{
- const _OptionMenuItem* pItem = GetItem(mainIndex);
- if (pItem == null)
- {
- return -1;
- }
+ const _OptionMenuItem* pItem = GetItem(mainIndex);
+ if (pItem == null)
+ {
+ return -1;
+ }
- return pItem->GetSubItemCount();
+ return pItem->GetSubItemCount();
}
int
return -1;
}
+_OptionMenuItem*
+_OptionMenuModel::GetItem(int mainIndex, int subIndex) const
+{
+ int count = __items.GetCount();
+
+ if (mainIndex < 0 || mainIndex >= count)
+ {
+ return null;
+ }
+
+ const _OptionMenuItem* pItem = static_cast <const _OptionMenuItem*>(__items.GetAt(mainIndex));
+
+ if (subIndex == INVALID_INDEX)
+ {
+ return const_cast<_OptionMenuItem*>(pItem);
+ }
+ else
+ {
+ return const_cast<_OptionMenuItem*>(pItem)->GetSubItem(subIndex);
+ }
+}
+
}}} // Tizen::Ui::Controls
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/**
- * @file FUiCtrl_OptionMenuPresenter.cpp
+ * @file FUiCtrl_OptionMenuListPresenter.cpp
* @brief This is the implementation file for the _OptionMenuPresenter class.
*/
#include <FBaseErrorDefine.h>
-#include <FGrpFont.h>
#include <FBaseSysLog.h>
#include <FGrp_BitmapImpl.h>
-#include <FGrp_TextCommon.h>
+#include <FGrp_CanvasImpl.h>
#include <FGrp_TextTextSimple.h>
-#include "FUiAnim_MatrixUtil.h"
-#include "FUiCtrl_OptionMenuPresenter.h"
-#include "FUiCtrl_OptionMenu.h"
-#include "FUiCtrl_OptionMenuModel.h"
-#include "FUiCtrl_OptionMenuItem.h"
-#include "FUiCtrl_Frame.h"
-#include "FUiCtrl_Form.h"
-#include "FGrp_FontImpl.h"
+#include "FUi_AccessibilityContainer.h"
#include "FUi_AccessibilityElement.h"
-#include "FUi_ControlManager.h"
-#include "FUi_TouchManager.h"
-#include "FUi_UiTouchEvent.h"
-#include "FUi_ResourceManager.h"
#include "FUi_CoordinateSystemUtils.h"
+#include "FUi_Math.h"
+#include "FUi_ResourceManager.h"
+#include "FUiCtrl_ActionEvent.h"
+#include "FUiCtrl_IActionEventListener.h"
+
+#include "FUiCtrl_OptionMenuPresenter.h"
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui;
using namespace Tizen::Base;
using namespace Tizen::Base::Runtime;
-using namespace Tizen::Graphics;
using namespace Tizen::Graphics::_Text;
-using namespace Tizen::Ui;
-using namespace Tizen::Ui::Animations;
-
-const int EFFECT_INTERVAL = 10;
-const double EFFECT_CONSTANT = 0.075;
-
-namespace Tizen { namespace Ui { namespace Controls
-{
-
-float
-SineThirtyThreeTimingFunction::CalculateProgress(float timeProgress) const
-{
- const float segments[2][3] = {{0.0f, 0.050f, 0.495f}, {0.495f, 0.940f, 1.0f}};
-
- float loc_5 = timeProgress;
- int loc_6 = 2; //Length of the segments array
- int loc_9 = (int)floor(loc_6 * loc_5);
- if (loc_9 >= loc_6)
- {
- loc_9 = loc_6 - 1;
- }
-
- float loc_7 = (loc_5 - loc_9 * (1.0f / loc_6)) * loc_6;
-
- float loc_8[3];
-
- for (int i = 0; i < 3; i++)
- {
- loc_8[i] = segments[loc_9][i];
- }
-
- float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0])));
-
- return ret;
+namespace {
+static const float TOUCH_PRESS_THRESHOLD_INSENSITIVE = 0.16f;
+static const int OPTION_MENU_LIST_ELEMENT_TEXT = 0;
+static const int OPTION_MENU_LIST_ELEMENT_BITMAP = 1;
}
-float
-SineSixtyTimingFunction::CalculateProgress(float timeProgress) const
+namespace Tizen { namespace Ui { namespace Controls
{
- const float segments[3][3] = {{0.0f, 0.01f, 0.37f}, {0.37f, 0.72f, 0.888f}, {0.888f, 0.9999f, 1.0f}};
- float loc_5 = timeProgress;
- int loc_6 = 3; //Length of the segments array
- int loc_9 = (int)floor(loc_6 * loc_5);
-
- if (loc_9 >= loc_6)
- {
- loc_9 = loc_6 - 1;
- }
- float loc_7 = (loc_5 - loc_9 * (1.0 / loc_6)) * loc_6;
- float loc_8[3];
-
- for (int i = 0; i < 3; i++)
- {
- loc_8[i] = segments[loc_9][i];
- }
- float ret = 0 + 1 * (loc_8[0] + loc_7 * (2 * (1 - loc_7) * (loc_8[1] - loc_8[0]) + loc_7 * (loc_8[2] - loc_8[0])));
-
- return ret;
-}
-
-_OptionMenuPresenter::_OptionMenuPresenter(_OptionMenu* optionMenu)
- : __pOptionMenu(optionMenu)
- , __pOptionMenuModel(null)
- , __pItemBitmap(null)
- , __pItemPressedBitmap(null)
- , __pItemPressedEffectBitmap(null)
- , __pArrowBitmap(null)
- , __pArrowPressedBitmap(null)
- , __pHandleBitmap(null)
- , __pHandleEffectBitmap(null)
- , __pHandlePressedBitmap(null)
- , __pHandlePressedEffectBitmap(null)
- , __pHandleDisabledBitmap(null)
- , __pHandleArrowNormalBitmap(null)
- , __pHandleArrowPressedBitmap(null)
- , __pHandleArrowDisabledBitmap(null)
- , __textObject()
+_OptionMenuPresenter::_OptionMenuPresenter(_OptionMenu* pOptionMenu)
+ : __pOptionMenu(pOptionMenu)
+ , __pModel(null)
, __pFont(null)
- , __maxColumnCount(0)
- , __rowCount(0)
- , __columnCount(0)
- , __width(0.0f)
- , __handleHeight(0.0f)
- , __itemHeight(0.0f)
- , __lineWidth(0.0f)
+ , __layoutSize(FloatDimension(0.0f, 0.0f))
+ , __touchOutRect(false)
+ , __selectedIndex(-1)
+ , __scrollEnable(false)
+ , __maxWidth(0.0f)
+ , __minWidth(0.0f)
+ , __topMargin(0.0f)
+ , __bottomMargin(0.0f)
, __leftMargin(0.0f)
, __rightMargin(0.0f)
- , __textSize(0.0f)
- , __textLeftMargin(0.0f)
- , __textRightMargin(0.0f)
- , __textTopMargin(0.0f)
- , __textBottomMargin(0.0f)
- , __arrowMargin(0.0f)
- , __selectedIndex(-1)
- , __isHandlerPressed(false)
- , __isClosing(false)
- , __isAnimationStarted(false)
- , __focusedIndex(-1)
- , __pOptionMenuVE(null)
- , __pThirtyThreeTimingFunction(null)
- , __pSixtyTimingFunction(null)
+ , __itemWidth(0.0f)
+ , __itemMinWidth(0.0f)
+ , __itemHeight(0.0f)
+ , __itemMaxWidth(0.0f)
+ , __itemGap(0.0f)
+ , __itemBitmapWidth(0.0f)
+ , __itemBitmapHeight(0.0f)
+ , __itemFontSize(0.0f)
+ , __dividerHeight(0.0f)
{
+
}
_OptionMenuPresenter::~_OptionMenuPresenter(void)
{
__pOptionMenu = null;
- delete __pOptionMenuModel;
- __pOptionMenuModel = null;
+ delete __pModel;
+ __pModel = null;
- delete __pItemBitmap;
- __pItemBitmap = null;
+ __pFont = null;
- delete __pItemPressedBitmap;
- __pItemPressedBitmap = null;
+}
+
+result
+_OptionMenuPresenter::Install(void)
+{
+ result r = E_SUCCESS;
- delete __pItemPressedEffectBitmap;
- __pItemPressedEffectBitmap = null;
+ LoadShape();
- delete __pArrowBitmap;
- __pArrowBitmap = null;
+ __pModel = new (std::nothrow) _OptionMenuModel;
+ SysTryCatch(NID_UI_CTRL, __pModel != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
- delete __pArrowPressedBitmap;
- __pArrowPressedBitmap = null;
+ r = __pModel->Construct();
+ SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create data instance.");
- delete __pHandleBitmap;
- __pHandleBitmap = null;
+ __pFont = __pOptionMenu->GetFallbackFont();
+ r = GetLastResult();
+ SysTryCatch(NID_UI_CTRL, (__pFont != null), , r, "[%s] Propagating.", GetErrorMessage(r));
- delete __pHandleEffectBitmap;
- __pHandleEffectBitmap = null;
+ return r;
- delete __pHandlePressedBitmap;
- __pHandlePressedBitmap = null;
+CATCH:
+ delete __pModel;
+ __pModel = null;
- delete __pHandlePressedEffectBitmap;
- __pHandlePressedEffectBitmap = null;
+ __pFont = null;
- delete __pHandleDisabledBitmap;
- __pHandleDisabledBitmap = null;
+ return r;
+}
- delete __pHandleArrowNormalBitmap;
- __pHandleArrowNormalBitmap = null;
- delete __pHandleArrowPressedBitmap;
- __pHandleArrowPressedBitmap = null;
+void
+_OptionMenuPresenter::LoadShape(void)
+{
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_MIN_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMinWidth);
+ GET_SHAPE_CONFIG(OPTIONMENU::LIST_MAX_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemMaxWidth);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemHeight);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_GAP, _CONTROL_ORIENTATION_PORTRAIT, __itemGap);
- delete __pHandleArrowDisabledBitmap;
- __pHandleArrowDisabledBitmap = null;
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin);
- if (__pOptionMenuVE != null)
- {
- __pOptionMenuVE->RemoveAllAnimations();
- __pOptionMenuVE->SetAnimationProvider(null);
- }
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_WIDTH, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapWidth);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ICON_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __itemBitmapHeight);
- delete __pThirtyThreeTimingFunction;
- __pThirtyThreeTimingFunction = null;
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_ITEM_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __itemFontSize);
+ GET_SHAPE_CONFIG(CONTEXTMENU::LIST_DIVIDER_HEIGHT, _CONTROL_ORIENTATION_PORTRAIT, __dividerHeight);
- delete __pSixtyTimingFunction;
- __pSixtyTimingFunction = null;
+ __itemWidth = __itemMinWidth;
}
-_OptionMenuPresenter*
-_OptionMenuPresenter::CreateInstanceN(_OptionMenu& optionMenu)
+_OptionMenuItem*
+_OptionMenuPresenter::CreateItem(const String& text, int actionId, const Bitmap* pNormalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- result r = E_SUCCESS;
+ _OptionMenuItem* pItem = _OptionMenuItem::CreateOptionMenuItemN();
+ SysTryReturn(NID_UI_CTRL, pItem != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- _OptionMenuPresenter* pOptionMenuPresenter = new (std::nothrow) _OptionMenuPresenter(&optionMenu);
- SysTryReturn(NID_UI_CTRL, (pOptionMenuPresenter != null), null, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ OptionMenuItemDrawingType itemType = OPTION_MENU_ITEM_DRAWING_TYPE_TEXT;
+ _Label* pLabel = null;
+ result r = E_SUCCESS;
- r = GetLastResult();
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ if (pNormalBitmap != null)
+ {
+ r = pItem->SetBitmap(OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL, pNormalBitmap);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ return null;
+ }
- pOptionMenuPresenter->__pOptionMenuModel = _OptionMenuModel::CreateInstanceN();
- r = GetLastResult();
- SysTryCatch(NID_UI_CTRL, (pOptionMenuPresenter->__pOptionMenuModel != null), , r,
- "[%s] Propagating.", GetErrorMessage(r));
+ // add bitmap label
+ pLabel = _Label::CreateLabelN();
+ pLabel->SetBackgroundBitmap(*pNormalBitmap);
+ pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
- r = pOptionMenuPresenter->LoadBitmap();
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ int bitmapY = (__itemHeight - __itemBitmapHeight ) / 2;
+ pLabel->SetBounds(FloatRectangle(__leftMargin, bitmapY, __itemBitmapWidth, __itemBitmapHeight));
+ pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
+ pItem->AttachChild(*pLabel);
- r = pOptionMenuPresenter->LoadShapeResource(optionMenu.GetOrientation());
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
+ _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->Activate(false);
+ }
+ pItem->SetBitmapLabel(pLabel);
- return pOptionMenuPresenter;
+ itemType = OPTION_MENU_ITEM_DRAWING_TYPE_BITMAP;
+ }
-CATCH:
- delete pOptionMenuPresenter;
- return null;
-}
+ if (pPressedBitmap != null)
+ {
+ r = pItem->SetBitmap(OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED, pPressedBitmap);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ return null;
+ }
+ }
-result
-_OptionMenuPresenter::InitializeVisualElement(void)
-{
- // matrix for scale-animation
- _matrixOrigin.SetAsIdentity();
- _matrixScale.SetAsIdentity();
+ pItem->SetType(itemType);
+ pItem->SetActionId(actionId);
- _MatrixUtilScale(_matrixScale, 1, 0.7, 1);
+ pItem->SetTextSize(__itemFontSize);
+ r = pItem->SetText(text);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ return null;
+ }
- __pOptionMenuVE = __pOptionMenu->GetVisualElement();
+ // calculate item size
+ float bitmapWidth = (itemType == OPTION_MENU_ITEM_DRAWING_TYPE_BITMAP) ? __itemBitmapWidth : 0.0f;
- FloatPoint point(0.0f, 1.0f);
+ FloatDimension textArea(0.0f, 0.0f);
+ FloatDimension itemSize(0.0f, 0.0f);
- __pOptionMenuVE->SetAnchor(point);
- SysTryReturn(NID_UI_CTRL, __pOptionMenuVE != null, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. Failed to get VisualElement.");
+ __pFont->GetTextExtent(text, text.GetLength(), textArea);
+ float labelLeftMargin = 0.0f, labelTopMargin = 0.0f;
+ GET_SHAPE_CONFIG(LABEL::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelLeftMargin);
+ GET_SHAPE_CONFIG(LABEL::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, labelTopMargin);
+ textArea.width += 2.0f * labelLeftMargin;
+ textArea.height += 2.0f * labelTopMargin;
+ itemSize.height = __itemHeight + (__dividerHeight * 2.0f);
+ itemSize.width = __leftMargin + textArea.width + __rightMargin + bitmapWidth;
- return E_SUCCESS;
-}
+ itemSize.width = itemSize.width < __itemMinWidth ? __itemMinWidth : itemSize.width;
-result
-_OptionMenuPresenter::InitializeTextObject(void)
-{
- result r = __textObject.Construct();
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ if (itemSize.width > __itemMaxWidth)
+ {
+ textArea.width -= itemSize.width - __itemMaxWidth;
+ itemSize.width = __itemMaxWidth;
+ }
- TextSimple* pSimpleText = new (std::nothrow)TextSimple(null, 0, TEXT_ELEMENT_SOURCE_TYPE_EXTERNAL);
- SysTryReturn(NID_UI_CTRL, (pSimpleText != null), E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ pItem->SetSize(itemSize);
- __textObject.AppendElement(*pSimpleText);
+ // add text label
+ float textLabelX = __leftMargin + bitmapWidth;
- // Create and initialize the Font.
- __pFont = __pOptionMenu->GetFallbackFont();
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, __pFont, r , r, "[%s] Propagating.", GetErrorMessage(r));
+ pLabel = _Label::CreateLabelN();
+ pLabel->SetText(text);
+ OptionMenuCoreItemStatus itemStatus = OPTION_MENU_CORE_ITEM_STATUS_NORMAL;
+ pLabel->SetTextColor(__pOptionMenu->GetTextColor(itemStatus));
+ pLabel->SetBackgroundColor(Color(0, 0, 0, 0));
- __textObject.SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE);
- __textObject.SetWrap(TEXT_OBJECT_WRAP_TYPE_CHARACTER);
- __textObject.SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV);
- __textObject.SetTextObjectEllipsisType(TEXT_OBJECT_ELLIPSIS_TYPE_TAIL);
+ itemSize = pItem->GetSize();
+ pLabel->SetBounds(FloatRectangle(textLabelX, (itemSize.height - textArea.height) / 2.0f, textArea.width, textArea.height));
+ pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
+ pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
+ pLabel->SetTextConfig(__itemFontSize, LABEL_TEXT_STYLE_NORMAL);
- return E_SUCCESS;
-}
+ pLabel->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
+ pItem->AttachChild(*pLabel);
+ _AccessibilityContainer* pContainer = pLabel->GetAccessibilityContainer();
+ if (pContainer)
+ {
+ pContainer->Activate(false);
+ }
+ pItem->SetTextLabel(pLabel);
-result
-_OptionMenuPresenter::AddItem(const String& text, int actionId)
-{
- result r = __pOptionMenuModel->AddItem(text, actionId);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ __itemWidth = __itemWidth < itemSize.width ? itemSize.width : __itemWidth;
- return E_SUCCESS;
+ pItem->SetTouchPressThreshold(TOUCH_PRESS_THRESHOLD_INSENSITIVE);
+ return pItem;
}
result
-_OptionMenuPresenter::InsertItemAt(int mainIndex, const String& text, int actionId)
+_OptionMenuPresenter::AddItem(const String& text, int actionId, const Bitmap* normalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- result r = __pOptionMenuModel->InsertItemAt(text, actionId, mainIndex);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ _OptionMenuItem* pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
- return E_SUCCESS;
-}
+ result r = __pModel->AddItem(pItem);
-result
-_OptionMenuPresenter::SetItemAt(int mainIndex, const String& text, int actionId)
-{
- result r = __pOptionMenuModel->SetItemAt(text, actionId, mainIndex);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");
+ }
- return E_SUCCESS;
+ return r;
}
result
-_OptionMenuPresenter::RemoveItemAt(int mainIndex)
+_OptionMenuPresenter::AddSubItem(int mainIndex, const String& text, int actionId)
{
- result r = __pOptionMenuModel->RemoveItemAt(mainIndex);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ _OptionMenuItem* pItem = CreateItem(text, actionId, null, null, null);
+ SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
- return E_SUCCESS;
-}
+ result r = __pModel->AddItem(pItem, mainIndex);
-int
-_OptionMenuPresenter::GetItemCount(void) const
-{
- return __pOptionMenuModel->GetItemCount();
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");
+ }
+
+ return r;
}
int
_OptionMenuPresenter::GetItemIndexFromActionId(int actionId) const
{
- return __pOptionMenuModel->GetItemIndexFromActionId(actionId);
+ return __pModel->GetItemIndexFromActionId(actionId);
}
int
_OptionMenuPresenter::GetItemActionIdAt(int mainIndex) const
{
- _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(mainIndex);
+ _OptionMenuItem* pItem = __pModel->GetItem(mainIndex);
if (pItem == null)
{
return -1;
}
result
-_OptionMenuPresenter::AddSubItem(int mainIndex, const String& text, int actionId)
+_OptionMenuPresenter::InsertItem(int mainIndex, const String& text, int actionId, const Bitmap* normalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- result r = __pOptionMenuModel->AddItem(text, actionId, mainIndex);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ _OptionMenuItem* pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ result r = __pModel->InsertItem(pItem, mainIndex);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");
+ }
return E_SUCCESS;
}
result
_OptionMenuPresenter::InsertSubItemAt(int mainIndex, int subIndex, const String& text, int actionId)
{
- result r = __pOptionMenuModel->InsertItemAt(text, actionId, mainIndex, subIndex);
+ _OptionMenuItem* pItem = CreateItem(text, actionId, null, null, null);
+ SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ result r = __pModel->InsertItem(pItem, mainIndex, subIndex);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return E_SUCCESS;
result
_OptionMenuPresenter::SetSubItemAt(int mainIndex, int subIndex, const String& text, int actionId)
{
- result r = __pOptionMenuModel->SetItemAt(text, actionId, mainIndex, subIndex);
+ _OptionMenuItem* pItem = CreateItem(text, actionId, null, null, null);
+ SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ result r = __pModel->SetItem(pItem, mainIndex, subIndex);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return E_SUCCESS;
result
_OptionMenuPresenter::RemoveSubItemAt(int mainIndex, int subIndex)
{
- result r = __pOptionMenuModel->RemoveItemAt(mainIndex, subIndex);
+ result r = __pModel->RemoveItem(mainIndex, subIndex);
SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
return E_SUCCESS;
int
_OptionMenuPresenter::GetSubItemCount(int mainIndex) const
{
- return __pOptionMenuModel->GetSubItemCount(mainIndex);
+ return __pModel->GetSubItemCount(mainIndex);
}
int
_OptionMenuPresenter::GetSubItemIndexFromActionId(int actionId) const
{
int mainIndex = -1;
- return __pOptionMenuModel->GetSubItemIndexFromActionId(actionId, mainIndex);
+ return __pModel->GetSubItemIndexFromActionId(actionId, mainIndex);
}
int
_OptionMenuPresenter::GetSubItemActionIdAt(int mainIndex, int subIndex) const
{
- _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(mainIndex, subIndex);
+ _OptionMenuItem* pItem = __pModel->GetItem(mainIndex, subIndex);
if (pItem == null)
{
return -1;
return pItem->GetActionId();
}
+
+
result
-_OptionMenuPresenter::Draw(void)
+_OptionMenuPresenter::SetItem(int index, const String& text, int actionId, const Bitmap* normalBitmap,
+ const Bitmap* pPressedBitmap, const Bitmap* pHighlightedBitmap)
{
- CalculateBounds();
+ result r = __pOptionMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index));
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item.");
- Canvas* pCanvas = __pOptionMenu->GetCanvasN();
- result r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ _OptionMenuItem* pItem = null;
+ pItem = CreateItem(text, actionId, normalBitmap, pPressedBitmap, pHighlightedBitmap);
+ SysTryReturn(NID_UI_CTRL, pItem != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
+
+ r = __pModel->SetItem(pItem, index);
+ if (r != E_SUCCESS)
+ {
+ delete pItem;
+ SysTryReturn(NID_UI_CTRL, false, r, r, "Failed to add item.");
+ }
+
+ return E_SUCCESS;
+}
- DrawHandler(*pCanvas);
+result
+_OptionMenuPresenter::DeleteItem(int index)
+{
+ if (__pOptionMenu->GetItemCount() <= 0)
+ {
+ SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument.");
+ return E_INVALID_STATE;
+ }
+
+ result r = __pOptionMenu->GetScrollPanel()->DetachChild(*__pModel->GetItem(index));
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to detach item.");
+
+ r = __pModel->RemoveItem(index);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item.");
+
+ return r;
+}
- // Draw Items
- for (int index = __pOptionMenuModel->GetItemCount() - 1; index >= 0; index--)
+result
+_OptionMenuPresenter::DeleteItemAll(void)
+{
+ if (__pOptionMenu->GetItemCount() <= 0)
{
- DrawItem(*pCanvas, index);
+ SysLogException(NID_UI_CTRL, E_INVALID_STATE, "Invalid argument.");
+ return E_INVALID_STATE;
}
- DrawItemLine(*pCanvas);
- delete pCanvas;
+ __pOptionMenu->GetScrollPanel()->DetachAllChildren();
- return E_SUCCESS;
+ result r = __pModel->RemoveAllItem();
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to delete item all.");
+
+ return r;
+}
+
+int
+_OptionMenuPresenter::CalculateShowItemCount(void)
+{
+ int itemMaxCount = 0;
+ GET_SHAPE_CONFIG(CONTEXTMENU::ITEM_MAX_COUNT, _CONTROL_ORIENTATION_PORTRAIT, itemMaxCount);
+
+ int maxVisibleCount = __pOptionMenu->GetShowItemCount();
+
+ return maxVisibleCount > itemMaxCount ? itemMaxCount : maxVisibleCount;
}
result
-_OptionMenuPresenter::DrawHandler(Canvas& canvas)
+_OptionMenuPresenter::CalculateWindowRect(void)
{
- result r = E_SUCCESS;
- _ControlOrientation orientation = __pOptionMenu->GetOrientation();
- float arrowYPos = 0.0f;
- Bitmap *pHandleBitmap = null;
- Bitmap *pHandleArrowBitmap = null;
- Bitmap *pHandleEffectBitmap = null;
+ result r = CalculateRect();
+ AdjustItemPosition();
- r = GET_SHAPE_CONFIG(OPTIONMENU::HANDLE_ARROW_Y_POSITION, orientation, arrowYPos);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ return r;
+}
- FloatRectangle bounds = __pOptionMenu->GetBoundsF();
- bounds.x = 0.0f;
- bounds.y = 0.0f;
- FloatRectangle arrowBounds(0.0f, 0.0f, 0.0f, 0.0f);
- arrowBounds.y = arrowYPos;
+result
+_OptionMenuPresenter::ApplyColorProperty(void)
+{
+ return E_SUCCESS;
+}
- bool isCustomHandleBitmap = false;
+result
+_OptionMenuPresenter::CalculateRect(void)
+{
+ Tizen::Graphics::FloatRectangle windowRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // OptionMenu window itself
+ Tizen::Graphics::FloatRectangle bodyRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // bg surronding showing items, relative to window
+// Tizen::Graphics::FloatRectangle arrowRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // relative to window
+ Tizen::Graphics::FloatRectangle itemRect = Tizen::Graphics::FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f); // relative to window
- r = GET_SHAPE_CONFIG(OPTIONMENU::HANDLE_HEIGHT, orientation, bounds.height);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ float bodyTopMargin = __topMargin;
+ float bodyBottomMargin = __bottomMargin;
+ float bodyLeftMargin = __leftMargin;
+ float bodyRightMargin = __rightMargin;
- canvas.SetBackgroundColor(Color(0x00000000));
- canvas.Clear(bounds);
+ FloatPoint anchorPosition(0.0f, 0.0f);
+ FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
- if (!__pOptionMenu->IsEnabled())
+ if (__pOptionMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)
{
- isCustomHandleBitmap = IS_CUSTOM_BITMAP(OPTIONMENU::HANDLE_BG_DISABLED);
+ screen.SetSize(screen.height, screen.width);
+ }
+ AdjustItemLayout();
- pHandleBitmap = __pHandleDisabledBitmap;
- pHandleArrowBitmap = __pHandleArrowDisabledBitmap;
- pHandleEffectBitmap = __pHandleEffectBitmap;
- }
- else if (__isHandlerPressed)
- {
- isCustomHandleBitmap = IS_CUSTOM_BITMAP(OPTIONMENU::HANDLE_BG_PRESSED);
+ bodyRect.width = __layoutSize.width + bodyLeftMargin + bodyRightMargin;
+ bodyRect.height = __layoutSize.height + bodyTopMargin + bodyBottomMargin;
- pHandleBitmap = __pHandlePressedBitmap;
- pHandleArrowBitmap = __pHandleArrowPressedBitmap;
- pHandleEffectBitmap = __pHandlePressedEffectBitmap;
- }
- else
- {
- isCustomHandleBitmap = IS_CUSTOM_BITMAP(OPTIONMENU::HANDLE_BG_NORMAL);
+ {
+ bodyRect.y = anchorPosition.y - (bodyRect.height / 2.0f);
+
+ windowRect.x = bodyRect.x ;//+ correctLength;
+ windowRect.y = bodyRect.y;
+ windowRect.width = bodyRect.width ;//+ arrowRect.width - correctLength;
+ windowRect.height = bodyRect.height;
- pHandleBitmap = __pHandleBitmap;
- pHandleArrowBitmap = __pHandleArrowNormalBitmap;
- pHandleEffectBitmap = __pHandleEffectBitmap;
+ bodyRect.x = 0.0f;
+ bodyRect.y = 0.0f;
}
- r = DrawResourceBitmap(canvas, bounds, pHandleBitmap);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
- // Draw Arrow for Handle
- arrowBounds.x = (bounds.width - pHandleArrowBitmap->GetWidthF()) / 2.0f;
- arrowBounds.width = pHandleArrowBitmap->GetWidthF();
- arrowBounds.height = pHandleArrowBitmap->GetHeightF();
+ itemRect.x = bodyRect.x + bodyLeftMargin;
+ itemRect.y = bodyRect.y + bodyTopMargin;
+ itemRect.width = __layoutSize.width;
+ itemRect.height = __layoutSize.height;
- r = DrawResourceBitmap(canvas, arrowBounds, pHandleArrowBitmap);
- __arrowBounds = arrowBounds;
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ __pOptionMenu->SetWindowRect(windowRect);
+ __pOptionMenu->SetBodyRect(bodyRect);
+ __pOptionMenu->SetItemRect(itemRect);
- if (!isCustomHandleBitmap && (pHandleEffectBitmap!= null))
+ // _ScrollPanel API call sequence: SetBounds() -> SetScrollAreaBounds()
+ // _Scroll visual interaction if Bounds < ScrollAreaBounds
+ if (__pOptionMenu->IsVisible())
{
- r = DrawResourceBitmap(canvas, bounds, pHandleEffectBitmap);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ __pOptionMenu->GetScrollPanel()->SetBounds(FloatRectangle(bodyRect.x + bodyLeftMargin, bodyRect.y + bodyTopMargin, __layoutSize.width, __layoutSize.height));
+ int itemCount = __pModel->GetItemCount();
+ float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
+ float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);
+ __pOptionMenu->GetScrollPanel()->SetClientAreaHeight(layoutClientHeight);
}
- return r;
-}
+ __pOptionMenu->SetMovable(true);
+ __pOptionMenu->SetResizable(true);
-result
-_OptionMenuPresenter::DrawItem(Canvas& canvas, int index)
-{
- FloatRectangle bounds = GetItemBounds(index);
- TextSimple* pSimpleText = null;
- _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(index);
- SysTryReturn(NID_UI_CTRL, (pItem != null), E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The item in specified index (%d) is null.", index);
+ __pOptionMenu->SetMinimumSize(FloatDimension(0.0f, 0.0f));
+ __pOptionMenu->SetMaximumSize(screen);
+ __pOptionMenu->SetBounds(windowRect);
+
+ __pOptionMenu->SetMovable(false);
+ __pOptionMenu->SetResizable(false);
- SysTryReturn (NID_UI_CTRL, (index != __selectedIndex || __pItemPressedBitmap != null), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. Failed to draw an item with index (%d).", index);
+ return E_SUCCESS;
+}
- // Draw Background of Item
- SysTryReturn(NID_UI_CTRL, (__pItemBitmap != null), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. Failed to draw an item with index (%d).", index);
+void
+_OptionMenuPresenter::AdjustItemLayout(void)
+{
+ FloatDimension layoutSize(0.0f, 0.0f);
- result r = DrawResourceBitmap(canvas, bounds, __pItemBitmap);
- if (r != E_SUCCESS)
+ int itemCount = __pModel->GetItemCount();
+ if (itemCount <= 0)
{
- return r;
+ __layoutSize.width = __itemWidth;
+ __layoutSize.height = __itemHeight;
+ return;
}
- Color textColor;
- bool isCustomItemBitmap = false;
- Color arrowColor;
- Bitmap *pArrowBitmap = null;
- _AccessibilityElement* pElement = null;
- _ControlOrientation orientation = __pOptionMenu->GetOrientation();
+ layoutSize = AdjustItemLayoutStyle();
- if (!__pOptionMenu->IsEnabled())
+ FloatDimension screen = _ControlManager::GetInstance()->GetScreenSizeF();
+ if (__pOptionMenu->GetLayout() == _CONTROL_ORIENTATION_LANDSCAPE)
{
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_TEXT_DISABLED, textColor);
+ screen.SetSize(screen.height, screen.width);
}
- else if (index == __selectedIndex)
- {
- FloatRectangle pressedBounds = bounds;
- float margin = 0.0f;
-
- GET_FIXED_VALUE_CONFIG(OPTIONMENU::ITEM_PRESS_EDGE_MARGIN, orientation, margin);
- if (pressedBounds.x == 0.0f)
- {
- // Adjust left-edge
- pressedBounds.x += margin;
- pressedBounds.width -= margin;
- }
- if ((pressedBounds.x + pressedBounds.width) == __width)
- {
- // Adjust right-edge
- pressedBounds.width -= margin;
- }
-
- GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_LEFT_MARGIN, orientation, margin);
- pressedBounds.x += margin;
- pressedBounds.width -= margin;
-
- GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_RIGHT_MARGIN, orientation, margin);
- pressedBounds.width -= margin;
-
- GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_TOP_MARGIN, orientation, margin);
- pressedBounds.y += margin;
- pressedBounds.height -= margin;
+ int maxHeight = screen.height;// - __screenTopMargin - __screenBottomMargin - __arrowHeight;
+ if (layoutSize.height > maxHeight)
+ {
+ layoutSize.height = maxHeight;
+ }
- GET_SHAPE_CONFIG(OPTIONMENU::ITEM_PRESS_BOTTOM_MARGIN, orientation, margin);
- pressedBounds.height -= margin;
+ __layoutSize = layoutSize;
+}
- isCustomItemBitmap = IS_CUSTOM_BITMAP(OPTIONMENU::ITEM_BG_PRESSED);
+FloatDimension
+_OptionMenuPresenter::AdjustItemLayoutStyle(void)
+{
+ int itemMaxCount = CalculateShowItemCount();
- DrawResourceBitmap(canvas, pressedBounds, __pItemPressedBitmap);
+ int itemCount = __pModel->GetItemCount();
+ float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
- if (isCustomItemBitmap == false)
- {
- DrawResourceBitmap(canvas, pressedBounds, __pItemPressedEffectBitmap);
- }
+ FloatDimension layoutSize(__itemWidth, 0.0f);
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_TEXT_PRESSED, textColor);
- }
- else if (!__pOptionMenu->IsEnabled())
+ float layoutClientHeight = itemCount * itemHeight - (__dividerHeight * 2.0f);
+ float layoutMaxHeight = itemMaxCount * itemHeight - (__dividerHeight * 2.0f);
+ if (layoutClientHeight > layoutMaxHeight)
{
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_TEXT_DISABLED, textColor);
+ __scrollEnable = true;
+ layoutSize.height = layoutMaxHeight;
}
else
{
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_TEXT_NORMAL, textColor);
+ __scrollEnable = false;
+ layoutSize.height = layoutClientHeight;
}
- __textObject.RemoveAll();
- pSimpleText = new (std::nothrow)TextSimple((wchar_t*)(pItem->GetText().GetPointer()), pItem->GetText().GetLength());
- if (pSimpleText != null)
- {
- __textObject.AppendElement(*pSimpleText);
- }
- __textObject.SetForegroundColor(textColor, 0, __textObject.GetTextLength());
- __textObject.Compose();
-
- int lineCount = __textObject.GetTotalLineCount();
- float textSize = __textSize;
+ return layoutSize;
+}
- if (lineCount > 1)
+void
+_OptionMenuPresenter::AdjustItemPosition(void)
+{
+ int itemCount = __pModel->GetItemCount();
+ if (itemCount <= 0)
{
- textSize = textSize - 1.0f;
+ return;
}
- (_FontImpl::GetInstance(*__pFont))->SetSize(textSize);
+ float itemHeight = __itemHeight + (__dividerHeight * 2.0f);
+ float drawItemY = 0.0f;
- __textObject.SetFont(__pFont, 0, __textObject.GetTextLength());
+ float x = __pOptionMenu->GetBodyRect().x + __leftMargin;
+ float y = __pOptionMenu->GetBodyRect().y + __topMargin;
- // Draw Text
- FloatRectangle textRect;
- textRect.height = bounds.height - __textTopMargin - __textBottomMargin;
- textRect.width = bounds.width - __leftMargin - __rightMargin - __textLeftMargin - __textRightMargin;
- textRect.x = bounds.x + __leftMargin + __textLeftMargin;
- textRect.y = bounds.y + ((bounds.height - textRect.height) / 2.0f);
+ _OptionMenuItem* pItem = null;
- if (pItem->HasSubItem() == true)
+ for (int i = 0; i < itemCount; i++)
{
- textRect.width -= __arrowMargin;
- if (!__pOptionMenu->IsEnabled())
+ pItem = __pModel->GetItem(i);
+
+ if (pItem == null)
{
- if (__pArrowBitmap)
- {
- delete __pArrowBitmap;
- __pArrowBitmap = null;
- }
+ break;
+ }
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, pArrowBitmap);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), E_SYSTEM, r, "[%s] Propagating.", GetErrorMessage(r));
+ FloatRectangle drawRect(x, drawItemY + y, __itemWidth, itemHeight);
- GET_COLOR_CONFIG(OPTIONMENU::CONTEXTUAL_POPUP_ARROW_DISABLED, arrowColor);
- __pArrowBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pArrowBitmap, Color::GetColor(COLOR_ID_MAGENTA), arrowColor);
- SysTryCatch(NID_UI_CTRL, (__pArrowBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
+ pItem->SetDrawRect(drawRect);
+ pItem->SetUpperDivider(i > 0);
+ pItem->SetLowerDivider(i < itemCount - 1);
+ pItem->SetParentScrollEnable(__scrollEnable);
+ pItem->SetBounds(FloatRectangle(0.0f, drawItemY, drawRect.width, drawRect.height));
- delete pArrowBitmap;
- pArrowBitmap = null;
+ if (pItem->HasParent() == false)
+ {
+ __pOptionMenu->GetScrollPanel()->AttachChild(*pItem);
}
- // Draw Arrow if item has subItem
- if (__pArrowBitmap != null)
- {
+ drawItemY += itemHeight;
+ }
+}
- FloatPoint arrowPosition(bounds.x + bounds.width - __arrowMargin - __rightMargin,
- bounds.y + ((bounds.height - __pArrowBitmap->GetHeight()) / 2.0f));
+int
+_OptionMenuPresenter::GetItemIndexFromPosition(const FloatPoint& point) const
+{
+ int index = -1;
+ int itemCount = __pModel->GetItemCount();
- if (index == __selectedIndex)
- {
- canvas.DrawBitmap(arrowPosition, *__pArrowPressedBitmap);
- }
- else
- {
- canvas.DrawBitmap(arrowPosition, *__pArrowBitmap);
- }
- }
+ if (itemCount < 0)
+ {
+ return -1;
}
- __textObject.SetBounds(textRect);
- __textObject.Draw(*_CanvasImpl::GetInstance(canvas));
+ _OptionMenuItem* pItem = null;
- pElement = __pOptionMenu->GetAccessibilityElement(index);
- if (pElement != null)
+ float scrollPosition = __pOptionMenu->GetScrollPanel()->GetScrollPosition();
+ FloatPoint position(point.x, point.y + scrollPosition);
+
+ for (int i = 0; i < itemCount; i++)
{
- pElement->SetBounds(bounds);
- }
+ pItem = __pModel->GetItem(i);
- return E_SUCCESS;
+ if (pItem == null)
+ {
+ break;
+ }
-CATCH:
- delete pArrowBitmap;
- pArrowBitmap = null;
+ FloatRectangle drawRect = pItem->GetDrawRect();
- return r;
+ if (drawRect.Contains(position) == true)
+ {
+ index = i;
+ break;
+ }
+ }
+
+ return index;
}
+
result
-_OptionMenuPresenter::DrawItemLine(Canvas& canvas)
+_OptionMenuPresenter::Draw(void)
{
- result r = E_SUCCESS;
+ result r = E_SUCCESS;
- if (__columnCount <= 0)
+ // calculate bounds
{
- return E_SUCCESS;
- }
- Color dividerTopHalfColor;
- Color dividerBottomHalfColor;
+ _ControlManager *pManager = _ControlManager::GetInstance();
+ FloatDimension screenSize = pManager->GetScreenSizeF();
+ _ControlOrientation orientation = __pOptionMenu->GetOrientation();
- r = GET_COLOR_CONFIG(OPTIONMENU::DIVIDER_TOP_HALF, dividerTopHalfColor);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
+ {
+ FloatDimension temp = screenSize;
+ screenSize.width = temp.height;
+ screenSize.height = temp.width;
+ }
+ int maxItem = 0;
+ GET_SHAPE_CONFIG(OPTIONMENU::MAX_OPTIONMENU_SHOW_ITEM, orientation, maxItem);
+ __pOptionMenu->SetPropertyMaxVisibleItemsCount(maxItem);
- r = GET_COLOR_CONFIG(OPTIONMENU::DIVIDER_BOTTOM_HALF, dividerBottomHalfColor);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ Tizen::Graphics::FloatRectangle bodyRect = __pOptionMenu->GetBodyRect();
- Color foreGroundColor = canvas.GetForegroundColor();
- canvas.SetLineStyle(LINE_STYLE_SOLID);
+ bodyRect.y = screenSize.height - bodyRect.height;
- float rowHeight = __itemHeight + __lineWidth;
- float x = 0.0f;
- float y = 0.0f;
- for (y = __handleHeight + (__rowCount - 1) * rowHeight - 1.0f; y > __handleHeight; y -= rowHeight)
- {
- // Horizontal Line
- canvas.SetForegroundColor(dividerBottomHalfColor);
- canvas.DrawLine(CoordinateSystem::AlignToDevice(FloatPoint(0.0f, y)), CoordinateSystem::AlignToDevice(FloatPoint(__width, y)));
- canvas.SetForegroundColor(dividerTopHalfColor);
- canvas.DrawLine(CoordinateSystem::AlignToDevice(FloatPoint(0.0f, y - 1.0f)), CoordinateSystem::AlignToDevice(FloatPoint(__width, y - 1.0f)));
-
- // Vertical Line
- for (int column = 1; column < __columnCount; column++)
- {
- x = (__width - __lineWidth) * column / __columnCount;
- canvas.SetForegroundColor(dividerBottomHalfColor);
- canvas.DrawLine(CoordinateSystem::AlignToDevice(FloatPoint(x, y - __itemHeight - 1.0f)), CoordinateSystem::AlignToDevice(FloatPoint(x, y)));
- canvas.SetForegroundColor(dividerTopHalfColor);
- canvas.DrawLine(CoordinateSystem::AlignToDevice(FloatPoint(x - 1.0f, y - __itemHeight - 1.0f)), CoordinateSystem::AlignToDevice(FloatPoint(x - 1.0f, y)));
- }
- }
+ __pOptionMenu->SetMovable(true);
+ __pOptionMenu->SetResizable(true);
- // Last-Row Vertical Line
- int lastRowColumnCount = __pOptionMenuModel->GetItemCount() % __columnCount;
- if (lastRowColumnCount == 0)
- {
- lastRowColumnCount = __columnCount;
+ __pOptionMenu->SetBounds(CoordinateSystem::AlignToDevice(bodyRect));
+
+ __pOptionMenu->SetMovable(false);
+ __pOptionMenu->SetResizable(false);
}
- y = __handleHeight + (__rowCount - 1) * rowHeight - 1.0f;
- for (int column = 1; column < lastRowColumnCount; column++)
- {
- x = (__width - __lineWidth) * column / lastRowColumnCount;
- canvas.SetForegroundColor(dividerBottomHalfColor);
- canvas.DrawLine(CoordinateSystem::AlignToDevice(FloatPoint(x, y)), CoordinateSystem::AlignToDevice(FloatPoint(x, y + __itemHeight)));
- canvas.SetForegroundColor(dividerTopHalfColor);
- canvas.DrawLine(CoordinateSystem::AlignToDevice(FloatPoint(x - 1.0f, y)), CoordinateSystem::AlignToDevice(FloatPoint(x - 1.0f, y + __itemHeight)));
+ Canvas* pCanvas = __pOptionMenu->GetCanvasN();
+ SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "The memory is insufficient.");
- }
+ // Clear canvas for drawing area of the OptionMenu.
+ pCanvas->SetBackgroundColor(Color(0, 0, 0, 0));
+ Tizen::Graphics::FloatRectangle bounds(__pOptionMenu->GetWindowRect());
+ pCanvas->Clear(Tizen::Graphics::FloatRectangle(0.0f, 0.0f, bounds.width, bounds.height));
- canvas.SetForegroundColor(foreGroundColor);
+ r = DrawBackground(pCanvas);
+ SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "Failed to draw background.");
- return E_SUCCESS;
+ delete pCanvas;
+
+ return r;
}
result
-_OptionMenuPresenter::DrawFocus(int index)
+_OptionMenuPresenter::DrawBackground(Canvas* pCanvas)
{
- ClearFocus(__focusedIndex);
+ SysTryReturn(NID_UI_CTRL, pCanvas != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
result r = E_SUCCESS;
- Canvas* pCanvas;
- pCanvas = __pOptionMenu->GetCanvasN();
+ Tizen::Graphics::FloatRectangle bodyRect = __pOptionMenu->GetBodyRect();
- SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ const Bitmap* pBackgroundNormalBitmap = __pOptionMenu->GetBackgroundNormalBitmap();
+ const Bitmap* pBackgroundEffectBitmap = __pOptionMenu->GetBackgroundEffectBitmap();
- FloatRectangle bounds;
-
- if (index == -1)
+ if (pBackgroundNormalBitmap == null && pBackgroundEffectBitmap == null)
{
- bounds = __arrowBounds;
+ pCanvas->SetForegroundColor(__pOptionMenu->GetColor());
+ pCanvas->DrawRectangle(bodyRect);
}
else
{
- bounds = GetItemBounds(index);
- }
-
- Bitmap* pBitmap = null;
- r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
- SysTryCatch(NID_UI_CTRL, (pBitmap != null), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
- {
- r = pCanvas->DrawNinePatchedBitmap(bounds, *pBitmap);
- }
- else
- {
- r = pCanvas->DrawBitmap(bounds, *pBitmap);
- }
-
- __focusedIndex = index;
-
- delete pCanvas;
- delete pBitmap;
-
- return r;
-
-CATCH:
- delete pCanvas;
-
- return r;
-}
-
-result
-_OptionMenuPresenter::ClearFocus(int index)
-{
- result r = E_SUCCESS;
- Canvas* pCanvas;
-
- pCanvas = __pOptionMenu->GetCanvasN();
- SysTryReturn(NID_UI_CTRL, (pCanvas != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- Color background;
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_BG_NORMAL, background);
-
- FloatRectangle bounds;
-
- if (index == -1)
- {
- bounds = __arrowBounds;
- }
- else
- {
- bounds = GetItemBounds(index);
- }
-
- pCanvas->SetBackgroundColor(background);
- pCanvas->Clear(bounds);
-
- if (index == -1)
- {
- DrawHandler(*pCanvas);
- }
- else
- {
- DrawItem(*pCanvas, index);
- }
-
- DrawItemLine(*pCanvas);
-
- delete pCanvas;
- return r;
-}
-
-void
-_OptionMenuPresenter::OnEnterKeyPressed(int selectedIndex)
-{
- if (selectedIndex == -1)
- {
- __isHandlerPressed = false;
- Hide();
- }
- else
- {
- _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(selectedIndex);
- if (pItem != null)
+ if (pBackgroundNormalBitmap != null)
{
- if (pItem->HasSubItem() == true)
- {
- __pOptionMenu->ShowSubMenu(selectedIndex, *pItem);
- }
- else
- {
- // Fire Action Event
- Hide();
- __pOptionMenu->FireActionEvent(pItem->GetActionId());
- }
+ r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundNormalBitmap);
}
- }
- return;
-}
-
-result
-_OptionMenuPresenter::RefreshItem(int index)
-{
- if (index < 0 || index >= __pOptionMenuModel->GetItemCount())
- {
- return E_OUT_OF_RANGE;
- }
-
- Canvas* pCanvas = __pOptionMenu->GetCanvasN();
- if (pCanvas == null)
- {
- return GetLastResult();
- }
-
- result r = DrawItem(*pCanvas, index);
- delete pCanvas;
- if (r == E_SUCCESS)
- {
- if (__pOptionMenu->GetVisualElement() != null)
+ if (pBackgroundEffectBitmap != null)
{
- __pOptionMenu->GetVisualElement()->SetFlushNeeded();
+ r = DrawBitmap(*pCanvas, bodyRect, *pBackgroundEffectBitmap);
}
}
return r;
}
-result
-_OptionMenuPresenter::LoadShapeResource(_ControlOrientation orientation)
+_UiTouchEventDelivery
+_OptionMenuPresenter::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
- result r = E_SUCCESS;
-
- r = GET_FIXED_VALUE_CONFIG(OPTIONMENU::COLUMN_MAX, orientation, __maxColumnCount);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::HANDLE_HEIGHT, orientation, __handleHeight);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::ITEM_HEIGHT, orientation, __itemHeight);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_FIXED_VALUE_CONFIG(OPTIONMENU::LINE_WIDTH, orientation, __lineWidth);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::LEFT_MARGIN, orientation, __leftMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::RIGHT_MARGIN, orientation, __rightMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_SIZE, orientation, __textSize);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_LEFT_MARGIN, orientation, __textLeftMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_RIGHT_MARGIN, orientation, __textRightMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_TOP_MARGIN, orientation, __textTopMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::TEXT_BOTTOM_MARGIN, orientation, __textBottomMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- r = GET_SHAPE_CONFIG(OPTIONMENU::ARROW_MARGIN, orientation, __arrowMargin);
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- return E_SUCCESS;
+ return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
}
-result
-_OptionMenuPresenter::CalculateBounds(void)
+bool
+_OptionMenuPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
{
- _ControlManager *pManager = _ControlManager::GetInstance();
- SysTryReturn(NID_UI_CTRL, (pManager != null), E_SYSTEM, E_SYSTEM,
- "[E_SYSTEM] A system error has occurred. The _ControlManager instance is null.");
-
- FloatDimension screenSize = pManager->GetScreenSizeF();
- FloatRectangle bounds(0.0f, 0.0f, 0.0f, __handleHeight);
+ FloatPoint touchPosition = touchinfo.GetCurrentPosition();
+ FloatRectangle itemRect = __pOptionMenu->GetItemRect();
- int itemCount = GetItemCount();
- if (itemCount > 0)
- {
- float rowCountF = (itemCount - 1.0f) / __maxColumnCount + 1.0f;
- __rowCount = _CoordinateSystemUtils::ConvertToInteger(rowCountF);
- if (__rowCount > 0)
- {
- __columnCount = itemCount / __rowCount;
- if ((itemCount % __rowCount) > 0)
- {
- __columnCount++;
- }
- }
- else
- {
- __rowCount = 0;
- __columnCount = 0;
- }
-
- bounds.height += (__itemHeight + __lineWidth) * __rowCount - __lineWidth;
- }
-
- if ((__pOptionMenu != null) && (__pOptionMenu->GetOrientation() == _CONTROL_ORIENTATION_PORTRAIT))
- {
- bounds.width = screenSize.width;
- bounds.y = (screenSize.height - bounds.height) + __lineWidth;
- }
- else
- {
- bounds.width = screenSize.height;
- bounds.y = screenSize.width - bounds.height + __lineWidth;
- }
- __width = bounds.width;
-
- if ((__pOptionMenu != null) && (bounds.height != __pOptionMenu->GetBoundsF().height))
+ if (__pOptionMenu->IsSubMenuShown() == true)
{
- __pOptionMenu->SetMovable(true);
- __pOptionMenu->SetResizable(true);
-
- result r = __pOptionMenu->SetBounds(CoordinateSystem::AlignToDevice(bounds));
- if (r != E_SUCCESS)
- {
- return r;
- }
-
- __pOptionMenu->SetMovable(false);
- __pOptionMenu->SetResizable(false);
+ __pOptionMenu->DestroySubMenu();
+ __pOptionMenu->SetTouchCapture(false, false);
+ return true;
}
-
- return E_SUCCESS;
-}
-
-FloatRectangle
-_OptionMenuPresenter::GetItemBounds(int index) const
-{
- if (__columnCount <= 0)
+ if (!itemRect.Contains(touchPosition))
{
- return FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f);
+ __selectedIndex = -1;
+ __touchOutRect = true;
+ return true;
}
- int itemCount = __pOptionMenuModel->GetItemCount();
- int lastRowColumnCount = itemCount % __columnCount;
- int row = index / __columnCount;
- int column = index % __columnCount;
- FloatRectangle bounds(0.0f, __handleHeight + row * (__itemHeight + __lineWidth), 0.0f, __itemHeight);
- if ((row == (__rowCount - 1)) && (lastRowColumnCount != 0))
+ if (__selectedIndex == -1 && touchPosition.y >= 0.0f)
{
- // Calculate last row
- bounds.x = column * __width / lastRowColumnCount;
- column++;
- bounds.width = column * __width / lastRowColumnCount - bounds.x + 1.0f;
-
- if (column < lastRowColumnCount)
- {
- bounds.width -= __lineWidth;
- }
+ __touchOutRect = true;
+ __pOptionMenu->Draw();
}
else
{
- bounds.x = column * __width / __columnCount;
- column++;
- bounds.width = column * __width / __columnCount - bounds.x + 1.0f;
-
- if (column < __columnCount)
- {
- bounds.width -= __lineWidth;
- }
- }
-
- return bounds;
-}
-
-int
-_OptionMenuPresenter::GetItemIndexFromPosition(const FloatPoint& position) const
-{
- if ((__columnCount <= 0)
- || (__width <= 0.0f)
- || (position.y < __handleHeight)
- || (position.y >= __pOptionMenu->GetBoundsF().height))
- {
- return -1;
+ __pOptionMenu->SetVisibleState(false);
}
- int itemCount = __pOptionMenuModel->GetItemCount();
- int row = (position.y - __handleHeight) / (__itemHeight + __lineWidth);
- if ((row == (__rowCount - 1)) && ((itemCount % __columnCount) != 0))
- {
- return (row * __columnCount) + position.x * (itemCount % __columnCount) / __width;
- }
-
- return (row * __columnCount) + position.x * __columnCount / __width;
-}
-
-result
-_OptionMenuPresenter::LoadBitmap(void)
-{
- result r = E_SUCCESS;
- Color color;
-
- Bitmap* pTempBitmap = null;
-
- // Load Item Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::ITEM_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_BG_NORMAL, color);
- __pItemBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- // Load Item Pressed Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::ITEM_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::ITEM_BG_PRESSED, color);
- __pItemPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- // Load Item Pressed
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::ITEM_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pItemPressedEffectBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- // Load Contextual Popup Arrow Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::CONTEXTUAL_POPUP_ARROW_NORMAL, color);
- __pArrowBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- // Load Contextual Popup Arrow Pressed Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::CONTEXTUAL_POPUP_ARROW, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::CONTEXTUAL_POPUP_ARROW_PRESSED, color);
- __pArrowPressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- // Load Handle Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::HANDLE_BG_NORMAL, color);
- __pHandleBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- // Load Handle Effect Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleEffectBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- // Load Handle Pressed Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::HANDLE_BG_PRESSED, color);
- __pHandlePressedBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- //Load Handle Disabled Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- GET_COLOR_CONFIG(OPTIONMENU::HANDLE_BG_DISABLED, color);
- __pHandleDisabledBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), color);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- // Load Handle Pressed Effect Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandlePressedEffectBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- // Load Handle Arrow Bitmap
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_ARROW_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleArrowNormalBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_ARROW_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleArrowPressedBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- r = GET_BITMAP_CONFIG_N(OPTIONMENU::HANDLE_ARROW_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, __pHandleArrowDisabledBitmap);
- SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
-
- return E_SUCCESS;
-CATCH:
-
- delete pTempBitmap;
- pTempBitmap = null;
-
- delete __pItemBitmap;
- __pItemBitmap = null;
-
- delete __pItemPressedBitmap;
- __pItemPressedBitmap = null;
-
- delete __pItemPressedEffectBitmap;
- __pItemPressedEffectBitmap = null;
-
- delete __pArrowBitmap;
- __pArrowBitmap = null;
-
- delete __pArrowPressedBitmap;
- __pArrowPressedBitmap = null;
-
- delete __pHandleBitmap;
- __pHandleBitmap = null;
-
- delete __pHandleEffectBitmap;
- __pHandleEffectBitmap = null;
-
- delete __pHandlePressedBitmap;
- __pHandlePressedBitmap = null;
-
- delete __pHandleDisabledBitmap;
- __pHandleDisabledBitmap = null;
-
- delete __pHandlePressedEffectBitmap;
- __pHandlePressedEffectBitmap = null;
-
- delete __pHandleArrowNormalBitmap;
- __pHandleArrowNormalBitmap = null;
-
- delete __pHandleArrowPressedBitmap;
- __pHandleArrowPressedBitmap = null;
-
- return r;
-
+ __selectedIndex = GetItemIndexFromPosition(touchPosition);
+ __touchOutRect = false;
+ return true;
}
-result
-_OptionMenuPresenter::PrepareAnimation(void)
+_UiTouchEventDelivery
+_OptionMenuPresenter::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
{
- result r = E_SUCCESS;
-
- __pOptionMenuVE->SetAnimationProvider(this);
-
- r = __pOptionMenuVE->SetSurfaceOpaque(false);
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- __pOptionMenuVE->SetOpacity(0.0f);
- __pOptionMenuVE->SetShowState(true);
-
- return r;
+ return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
}
-result
-_OptionMenuPresenter::SetOptionMenuVisibility(bool visibility)
+bool
+_OptionMenuPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
{
- SysTryReturnResult(NID_UI_CTRL, __pOptionMenuVE != null, E_INVALID_STATE, "[E_INVALID_STATE] OptionMenu VisualElement instance is null.");
-
- result r = E_SUCCESS;
-
- if (visibility == true)
- {
- __pOptionMenuVE->SetTransformMatrix(_matrixScale);
-
- __pOptionMenuVE->SetImplicitAnimationEnabled(true);
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ FloatPoint touchPosition = touchinfo.GetCurrentPosition();
- __pOptionMenuVE->SetTransformMatrix(_matrixOrigin);
- __pOptionMenuVE->SetOpacity(1.0f);
-
- __pOptionMenuVE->SetImplicitAnimationEnabled(false);
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
- }
- else
+ if (__touchOutRect)
{
- __pOptionMenuVE->SetTransformMatrix(_matrixOrigin);
- __pOptionMenuVE->SetOpacity(1.0f);
-
- __pOptionMenuVE->SetImplicitAnimationEnabled(true);
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
-
- __pOptionMenuVE->SetTransformMatrix(_matrixScale);
- __pOptionMenuVE->SetOpacity(0.0f);
+ FloatRectangle itemRect = __pOptionMenu->GetItemRect();
+ if (!itemRect.Contains(touchPosition))
+ {
+ __selectedIndex = -1;
+ __pOptionMenu->SetVisibleState(false);
- __pOptionMenuVE->SetImplicitAnimationEnabled(false);
- r = GetLastResult();
- SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
+ return true;
+ }
}
- return E_SUCCESS;
-
-}
-
-VisualElementAnimation*
-_OptionMenuPresenter::CreateAnimationForProperty(VisualElement& target, const String& property)
-{
- VisualElementAnimation* pAnimation = VisualElementAnimationProvider::CreateAnimationForProperty(target, property);
-
- if (pAnimation != null)
+ int currentSelectedIndex = GetItemIndexFromPosition(touchPosition);
+ if (__selectedIndex != -1 && (__selectedIndex == currentSelectedIndex))
{
- result r = E_SUCCESS;
-
- __isAnimationStarted = true;
+ _OptionMenuItem* pItem = null;
+ pItem = __pModel->GetItem(__selectedIndex);
+ __selectedIndex = -1;
- if (__pOptionMenuVE == (static_cast <Tizen::Ui::Animations::_VisualElement*>(&target)))
+ if (pItem != null)
{
- String opacity = L"opacity";
-
- if (opacity == property)
+ if (pItem->HasSubItem() == true)
{
- r = pAnimation->SetDuration(333);
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- __pThirtyThreeTimingFunction = new (std::nothrow) SineThirtyThreeTimingFunction();
- SysTryCatch(NID_UI_CTRL, (__pThirtyThreeTimingFunction != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
-
- pAnimation->SetTimingFunction(__pThirtyThreeTimingFunction);
+ // Show SubItem
+ __pOptionMenu->ShowSubMenu(__selectedIndex, *pItem, touchPosition);
+ return true;
}
else
{
- r = pAnimation->SetDuration(333);
- SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
-
- __pSixtyTimingFunction = new (std::nothrow) SineSixtyTimingFunction();
- SysTryCatch(NID_UI_CTRL, (__pSixtyTimingFunction != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ // Fire Action Event
+ __pOptionMenu->SetVisibleState(false);
- pAnimation->SetTimingFunction(__pSixtyTimingFunction);
+// Hide();
+ __pOptionMenu->FireActionEvent(pItem->GetActionId());
}
}
- pAnimation->SetVisualElementAnimationStatusEventListener(this);
- }
-
- return pAnimation;
-
-CATCH:
- delete pAnimation;
-
- return null;
-}
-
-void
-_OptionMenuPresenter::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target)
-{
- return;
-}
-
-void
-_OptionMenuPresenter::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount)
-{
- return;
-}
+// __selectedIndex = -1;
+// __pOptionMenu->SetVisibleState(false);
-void
-_OptionMenuPresenter::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally)
-{
- SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuVE != null, E_INVALID_STATE, "[E_INVALID_STATE] OptionMenu VisualElement instance is null.");
+// int actionId = pItem->GetActionId();
- __isAnimationStarted = false;
+// _ActionEvent* pActionEvent = __pOptionMenu->GetActionEvent();
+// if (pActionEvent == null)
+// {
+// return true;
+// }
- if (__pOptionMenuVE == (static_cast <Tizen::Ui::Animations::_VisualElement*>(&target)))
- {
- if (completedNormally == true)
- {
- __pOptionMenuVE->RemoveAllAnimations();
- __pOptionMenuVE->SetAnimationProvider(null);
+// IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(actionId);
+// if (pEventArg == null)
+// {
+// return true;
+// }
- if (__isClosing)
- {
- __isClosing = false;
- __pOptionMenu->Close();
- }
- }
+// PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
+// pActionEvent->Fire(*pEventArg);
}
- return;
-}
-
-void
-_OptionMenuPresenter::Hide(void)
-{
- __isClosing = true;
- PrepareAnimation();
- SetOptionMenuVisibility(false);
-}
-
-result
-_OptionMenuPresenter::SetPosition(const FloatPoint& position)
-{
- __pOptionMenu->SetMovable(true);
-
- result r = __pOptionMenu->SetPosition(position);
-
- __pOptionMenu->SetMovable(false);
-
- return r;
+ return true;
}
-void
-_OptionMenuPresenter::OnChangeLayout(_ControlOrientation orientation)
+_UiTouchEventDelivery
+_OptionMenuPresenter::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
{
- StopAnimation();
- LoadShapeResource(orientation);
- CalculateBounds();
+ return _UI_TOUCH_EVENT_DELIVERY_FORCED_YES;
}
-result
-_OptionMenuPresenter::StopAnimation(void)
+bool
+_OptionMenuPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
{
- if (__isAnimationStarted)
+ if (__scrollEnable)
{
- if (__isClosing)
- {
- __isClosing = false;
- if (__pOptionMenu != null && __pOptionMenuVE != null)
- {
- __pOptionMenuVE->RemoveAllAnimations();
- __pOptionMenuVE->SetAnimationProvider(null);
-
- __pOptionMenu->Close();
- }
- }
+ __selectedIndex = -1;
}
- return E_SUCCESS;
+ return true;
}
-result
-_OptionMenuPresenter::OnAttachingToMainTree(const _Control* pParent)
+bool
+_OptionMenuPresenter::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
{
- if (__pOptionMenu->GetOwner() == null)
- {
- _Frame* pFrame = dynamic_cast<_Frame*>(_ControlManager::GetInstance()->GetCurrentFrame());
- SysTryReturn(NID_UI_CTRL, pFrame != null, E_SYSTEM,
- E_SYSTEM, "[E_SYSTEM] This instance is not constructed.");
+ __pModel->ResetAllItem();
- _Form* pForm = pFrame->GetCurrentForm();
- if (pForm != null)
- {
- __pOptionMenu->SetOwner(pForm);
- }
- else
- {
- __pOptionMenu->SetOwner(pFrame);
- }
- }
-
- return E_SUCCESS;
-}
-
-result
-_OptionMenuPresenter::OnAttachedToMainTree(void)
-{
- return E_SUCCESS;
+ return true;
}
-result
-_OptionMenuPresenter::OnDetachingFromMainTree(void)
+void
+_OptionMenuPresenter::OnActionPerformed(const _Control& source, int actionId)
{
- __pOptionMenu->SetOwner(null);
- return E_SUCCESS;
+ // for SubMenu Events
+ __pOptionMenu->DestroySubMenu();
+ //Hide();
+ __pOptionMenu->SetVisibleState(false);
+ __pOptionMenu->FireActionEvent(actionId);
}
void
-_OptionMenuPresenter::OnVisibleStateChanged(void)
+_OptionMenuPresenter::OnFontChanged(Tizen::Graphics::Font* pFont)
{
- if (__pOptionMenu->IsVisible() == true)
- {
- if (_ControlManager::GetInstance()->GetTopWindow() == __pOptionMenu)
- {
- __pOptionMenu->SetTouchCapture(false, false);
- }
- }
- else
+ __pFont = pFont;
+ String fontName = __pOptionMenu->GetFont();
+
+ int itemCount = __pModel->GetItemCount();
+ for (int i = 0; i < itemCount; i++)
{
- _TouchManager* pManager = _TouchManager::GetInstance();
- if (pManager != null && pManager->GetCapturedControl() == __pOptionMenu)
+ _OptionMenuItem* pItem = __pModel->GetItem(i);
+ if (pItem != null)
{
- __pOptionMenu->ReleaseTouchCapture();
+ pItem->SetFont(fontName);
}
}
}
-bool
-_OptionMenuPresenter::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
+void
+_OptionMenuPresenter::OnFontInfoRequested(unsigned long& style, float& size)
{
- if (&source != __pOptionMenu)
- {
- return false;
- }
-
- SysTryReturn(NID_UI_CTRL, (!__isAnimationStarted), false, E_SUCCESS, "[E_SUCCESS] Animation is in Progress.");
-
- if (__pOptionMenu->IsSubMenuShown() == true)
- {
- __pOptionMenu->DestroySubMenu();
- __pOptionMenu->SetTouchCapture(false, false);
- return true;
- }
-
- FloatPoint position = touchinfo.GetCurrentPosition();
- __selectedIndex = GetItemIndexFromPosition(position);
- if (__selectedIndex >= 0)
- {
- RefreshItem(__selectedIndex);
- }
- else if (__selectedIndex == -1 && position.y >= 0.0f)
- {
- __isHandlerPressed = true;
- __pOptionMenu->Draw();
- }
- else
- {
- Hide();
- }
-
- return true;
+ style = FONT_STYLE_PLAIN;
+ size = __itemFontSize;
}
-bool
-_OptionMenuPresenter::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
+void
+_OptionMenuPresenter::SetAllAccessibilityElement(void)
{
- if (&source != __pOptionMenu)
+ _AccessibilityContainer* pContainerOptionMenu = __pOptionMenu->GetAccessibilityContainer();
+ if (pContainerOptionMenu != null)
{
- return false;
- }
+ _AccessibilityElement* pElementOptionMenu = new (std::nothrow) _AccessibilityElement(true);
+ SysTryReturnVoidResult(NID_UI_CTRL, pElementOptionMenu, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
- if (__isHandlerPressed == true)
- {
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
- __isHandlerPressed = false;
- Hide();
- return true;
- }
-
- if (__selectedIndex >= 0)
- {
- PLAY_FEEDBACK(_RESOURCE_FEEDBACK_PATTERN_TAP);
- int selectedIndex = __selectedIndex;
- __selectedIndex = -1;
- RefreshItem(selectedIndex);
+ pElementOptionMenu->SetSupportOperatingGesture(false);
+ pElementOptionMenu->SetTrait(L"Optionual popup");
+ pElementOptionMenu->SetHint(L"double tap to close");
+ pElementOptionMenu->SetBounds(FloatRectangle(0.0f, 0.0f, __pOptionMenu->GetBoundsF().width, __pOptionMenu->GetBoundsF().height));
+ pContainerOptionMenu->AddElement(*pElementOptionMenu);
+ __pOptionMenu->AddAccessibilityElement(*pElementOptionMenu);
- _OptionMenuItem* pItem = __pOptionMenuModel->GetItem(selectedIndex);
- if (pItem != null)
+ int itemCount = __pModel->GetItemCount();
+ for (int i = 0; i < itemCount; i++)
{
- if (pItem->HasSubItem() == true)
+ _OptionMenuItem* pItem = __pModel->GetItem(i);
+ if (pItem)
{
- // Show SubItem
- __pOptionMenu->ShowSubMenu(selectedIndex, *pItem);
+ _AccessibilityContainer* pContainer = pItem->GetAccessibilityContainer();
+ if (pContainer != null)
+ {
+ LinkedListT<_AccessibilityElement*> accessibilityElements;
+ _AccessibilityElement* pElement = null;
+
+ pContainer->GetElements(accessibilityElements);
+ if (accessibilityElements.GetAt(0, pElement) == E_SUCCESS)
+ {
+ pElement->SetName(L"OptionMenuItem" + Integer::ToString(i));
+ if (pItem->GetType() == OPTION_MENU_ITEM_DRAWING_TYPE_BITMAP)
+ {
+ pElement->SetLabel(L"icon " + pItem->GetText());
+ }
+ else
+ {
+ pElement->SetLabel(pItem->GetText());
+ }
+
+ pElement->SetBounds(FloatRectangle(0.0f, 0.0f, pItem->GetBoundsF().width, pItem->GetBoundsF().height));
+ }
+ pContainerOptionMenu->AddChildContainer(*pContainer);
+ }
}
- else
- {
- // Fire Action Event
- Hide();
- __pOptionMenu->FireActionEvent(pItem->GetActionId());
- }
- }
- }
-
- return true;
-}
-
-bool
-_OptionMenuPresenter::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
-{
- if (&source != __pOptionMenu)
- {
- return false;
- }
-
- FloatPoint position = touchinfo.GetCurrentPosition();
- int selectedIndex = GetItemIndexFromPosition(position);
- if (__isHandlerPressed == true)
- {
- if (selectedIndex >= 0 || position.y < 0.0f)
- {
- __isHandlerPressed = false;
- __pOptionMenu->Draw();
- }
- return true;
- }
-
- if (__selectedIndex >= 0)
- {
- if (selectedIndex != __selectedIndex)
- {
- selectedIndex = __selectedIndex;
- __selectedIndex = -1;
- RefreshItem(selectedIndex);
}
}
-
- return true;
-}
-
-bool
-_OptionMenuPresenter::OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo)
-{
- if (&source != __pOptionMenu)
- {
- return false;
- }
-
- __isHandlerPressed = false;
- __selectedIndex = -1;
- __pOptionMenu->Draw();
-
- return true;
}
-void
-_OptionMenuPresenter::OnActionPerformed(const _Control& source, int actionId)
+_OptionMenuItemInfo
+_OptionMenuPresenter::GetItemFromPosition(const FloatPoint& position)
{
- // for SubMenu Events
- __pOptionMenu->DestroySubMenu();
- Hide();
- __pOptionMenu->FireActionEvent(actionId);
-}
+ _OptionMenuItemInfo itemInfo;
+ int index = GetItemIndexFromPosition(position);
+ itemInfo.pOptionMenuItem = __pModel->GetItem(index);
-void
-_OptionMenuPresenter::OnFontChanged(Font* pFont)
-{
- __pFont = pFont;
- return;
+ itemInfo.bListItem = false;
+ itemInfo.pListItem = null;
+ return itemInfo;
}
-void
-_OptionMenuPresenter::OnFontInfoRequested(unsigned long& style, float& size)
+_OptionMenuItemInfo
+_OptionMenuPresenter::FindItem(int index)
{
- style = FONT_STYLE_PLAIN;
- size = __textSize;
- return;
+ _OptionMenuItemInfo itemInfo;
+ itemInfo.bListItem = false;
+ itemInfo.pListItem = null;
+ itemInfo.pOptionMenuItem = __pModel->GetItem(index);
+ return itemInfo;
}
-Font*
-_OptionMenuPresenter::GetFont(void) const
+result
+_OptionMenuPresenter::SetTopDrawnItemIndex(int index)
{
- return __pFont;
+ return E_SUCCESS;
}
result
-_OptionMenuPresenter::DrawResourceBitmap(Canvas& canvas, const FloatRectangle& bounds, Bitmap* pBitmap)
+_OptionMenuPresenter::DrawBitmap(Canvas& canvas, const FloatRectangle& bounds, const Bitmap& bitmap)
{
result r = E_SUCCESS;
-
- if (pBitmap == null)
- {
- return r;
- }
-
- if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
+ if (_BitmapImpl::CheckNinePatchedBitmapStrictly(bitmap))
{
- r = canvas.DrawNinePatchedBitmap(CoordinateSystem::AlignToDevice(bounds), *pBitmap);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = canvas.DrawNinePatchedBitmap(bounds, bitmap);
+ SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw ninepatched bitmap.")
}
else
{
- r = canvas.DrawBitmap(CoordinateSystem::AlignToDevice(bounds), *pBitmap);
- SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), r, r, "[%s] Propagating.", GetErrorMessage(r));
+ r = canvas.DrawBitmap(bounds, bitmap);
+ SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Fail to draw bitmap.")
}
return r;
}
-}}} // Tizen::Ui::Controls
+//bool
+//_OptionMenuPresenter::OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo)
+//{
+// return false;
+//}
+
+//bool
+//_OptionMenuPresenter::OnFocusGained(const _Control &source)
+//{
+// return true;
+//}
+
+//bool
+//_OptionMenuPresenter::OnFocusLost(const _Control &source)
+//{
+// return true;
+//}
+
+//void
+//_OptionMenuPresenter::OnDrawFocus(void)
+//{
+// return;
+//}
+
+
+}}} // Tizen::Ui: Control
#include "FUiCtrl_IContextMenuPresenter.h"
#include "FUiCtrl_ContextMenuGridPresenter.h"
#include "FUiCtrl_ContextMenuListPresenter.h"
-#include "FUiCtrl_OptionMenuListPresenter.h"\r
#include "FUiCtrl_ActionEvent.h"
#include "FUiCtrl_IActionEventListener.h"
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-
/**
* @file FUiCtrl_OptionMenu.h
* @brief This is the header file for the _OptionMenu class.
+ *
+ * This header file contains the declarations of the %_OptionMenu class.
*/
-
#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_H_
#define _FUI_CTRL_INTERNAL_OPTION_MENU_H_
-#include <FBaseColLinkedListT.h>
-
+#include <FBaseString.h>
+#include <FGrpColor.h>
#include "FUi_Window.h"
+#include "FUiCtrl_OptionMenuPresenter.h"
+#include "FUiCtrl_ActionEvent.h"
#include "FUiCtrl_IActionEventListener.h"
-#include "FUiCtrl_OptionMenuItem.h"
+
+#include "FUiCtrl_ScrollPanel.h"
namespace Tizen { namespace Ui {
class _AccessibilityElement;
namespace Tizen { namespace Ui { namespace Controls
{
-class _ActionEvent;
-class _ContextMenu;
+const int OPTION_MENU_ITEM_STATUS_COUNT = 3;
+
+enum OptionMenuCoreItemStatus
+{
+ OPTION_MENU_CORE_ITEM_STATUS_NORMAL = 0, /**< The normal state */
+ OPTION_MENU_CORE_ITEM_STATUS_PRESSED, /**< The pressed state */
+ OPTION_MENU_CORE_ITEM_STATUS_HIGHLIGHTED /**< The highlighted state */
+};
+
+struct _OptionMenuItemInfo;
+
+/**
+ * @class _OptionMenu
+ * @brief
+ * @since 2.2
+ *
+ *
+ *
+ *
+ */
class _OptionMenuPresenter;
+class _ContextMenu;
+class _OptionMenuItem;
class _OSP_EXPORT_ _OptionMenu
- : public Tizen::Ui::_Window
- , public _IActionEventListener
+ : public _Window
+ , public _IActionEventListener
, virtual public Tizen::Base::Runtime::IEventListener
, virtual public _IUiEventListener
, virtual public _IUiEventPreviewer
+ , public _IAccessibilityListener
{
-public:
- result AddActionEventListener(const _IActionEventListener& listener);
+ DECLARE_CLASS_BEGIN(_OptionMenu, _Control);
+ DECLARE_PROPERTY("color", GetPropertyColor, SetPropertyColor);
+ DECLARE_PROPERTY("normalItemColor", GetPropertyNormalItemColor, SetPropertyNormalItemColor);
+ DECLARE_PROPERTY("pressedItemColor", GetPropertyPressedItemColor, SetPropertyPressedItemColor);
+ DECLARE_PROPERTY("highlightedItemColor", GetPropertyHighlightedItemColor, SetPropertyHighlightedItemColor);
+ DECLARE_PROPERTY("normalItemTextColor", GetPropertyNormalItemTextColor, SetPropertyNormalItemTextColor);
+ DECLARE_PROPERTY("pressedItemTextColor", GetPropertyPressedItemTextColor, SetPropertyPressedItemTextColor);
+ DECLARE_PROPERTY("highlightedItemTextColor", GetPropertyHighlightedItemTextColor, SetPropertyHighlightedItemTextColor);
+ DECLARE_PROPERTY("maxVisibleItemsCount", GetPropertyMaxVisibleItemsCount, SetPropertyMaxVisibleItemsCount);
+ DECLARE_CLASS_END();
- result RemoveActionEventListener(const _IActionEventListener& listener);
+ result SetPropertyMaxVisibleItemsCount(const Variant& count);
+ Variant GetPropertyMaxVisibleItemsCount(void) const;
- result FireActionEvent(int actionId);
+ result SetPropertyColor(const Variant& color);
+ Variant GetPropertyColor(void) const;
- result AddItem(const Tizen::Base::String& text, int actionId);
+ result SetPropertyNormalItemColor(const Variant& color);
+ Variant GetPropertyNormalItemColor(void) const;
- result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
+ result SetPropertyPressedItemColor(const Variant& color);
+ Variant GetPropertyPressedItemColor(void) const;
- result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
+ result SetPropertyHighlightedItemColor(const Variant & color);
+ Variant GetPropertyHighlightedItemColor(void) const;
- result RemoveItemAt(int mainIndex);
+ result SetPropertyNormalItemTextColor(const Variant& color);
+ Variant GetPropertyNormalItemTextColor(void) const;
- int GetItemCount(void) const;
+ result SetPropertyPressedItemTextColor(const Variant& color);
+ Variant GetPropertyPressedItemTextColor(void) const;
- int GetItemIndexFromActionId(int actionId) const;
+ result SetPropertyHighlightedItemTextColor(const Variant & color);
+ Variant GetPropertyHighlightedItemTextColor(void) const;
- int GetItemActionIdAt(int mainIndex) const;
+public:
+ _OptionMenu(void);
+ virtual ~_OptionMenu(void);
+ static _OptionMenu* CreateOptionMenuN(void);
+public:
+ result Install(void);
+ result Initialize(void);
+ result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ result InsertItemAt(int mainIndex, const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ result SetItemAt(int mainIndex, const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ int GetItemIndexFromActionId(int actionId) const;
result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId);
-
result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
-
result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
-
result RemoveSubItemAt(int mainIndex, int subIndex);
-
int GetSubItemCount(int mainIndex) const;
-
int GetSubItemIndexFromActionId(int actionId) const;
-
int GetSubItemActionIdAt(int mainIndex, int subIndex) const;
-
+ result ShowSubMenu(int mainIndex, _OptionMenuItem& item, Tizen::Graphics::FloatPoint touchPosition);
bool IsSubMenuShown(void) const;
-
- result ShowSubMenu(int mainIndex, _OptionMenuItem& item);
-
result DestroySubMenu(void);
-
- Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(int mainIndex);
-
-public:
-// _IControlDelegator
- virtual void OnDraw(void);
-
- virtual void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
-
- virtual void OnBoundsChanged(void);
-
- virtual result OnAttachingToMainTree(const Tizen::Ui::_Control* pParent);
+ result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap,
+ const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap,
+ const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ result RemoveItemAt(int index);
+ void RemoveAllItems(void);
+ int GetItemCount(void) const;
+ result SetShowItemCount(int count);
+ int GetShowItemCount(void) const;
+ int GetShowItemMaxCount(void) const;
+ int GetItemIndexAt(int actionId) const;
+ int GetItemActionIdAt(int index) const;
+ result SetWindowRect(const Tizen::Graphics::FloatRectangle& rect);
+ Tizen::Graphics::FloatRectangle GetWindowRect(void) const;
+ result SetBodyRect(const Tizen::Graphics::FloatRectangle& rect);
+ Tizen::Graphics::FloatRectangle GetBodyRect(void) const;
+ result SetItemRect(const Tizen::Graphics::FloatRectangle& rect);
+ Tizen::Graphics::FloatRectangle GetItemRect(void) const;
+ result SetTextColor(enum OptionMenuCoreItemStatus status, const Tizen::Graphics::Color& color);
+ Tizen::Graphics::Color GetTextColor(enum OptionMenuCoreItemStatus status) const;
+ result SetColor(const Tizen::Graphics::Color& color);
+ Tizen::Graphics::Color GetColor(void) const;
+ result SetMaxVisibleItemsCount(int maxItemsCount);
+ result SetItemColor(enum OptionMenuCoreItemStatus status, const Tizen::Graphics::Color& color);
+ Tizen::Graphics::Color GetItemColor(enum OptionMenuCoreItemStatus status) const;
+ result AddActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener);
+ result RemoveActionEventListener(const Tizen::Ui::Controls::_IActionEventListener& listener);
+ result FireActionEvent(int actionId);
+ Tizen::Ui::Controls::_ActionEvent* GetActionEvent(void) const;
+ const Tizen::Graphics::Bitmap* GetBackgroundNormalBitmap(void) const;
+ const Tizen::Graphics::Bitmap* GetBackgroundEffectBitmap(void) const;
+ _ControlOrientation GetLayout(void) const;
virtual result OnAttachedToMainTree(void);
-
virtual result OnDetachingFromMainTree(void);
+ virtual void OnDraw(void);
- virtual void OnVisibleStateChanged(void);
-
-// _IWindowDelegator
- virtual void OnActivated(void);
-
- virtual void OnDeactivated(void);
-
-// _ITouchEventListener
- virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
-
- virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
-
- virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
- virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
+ virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
-// _IActionEventListener
virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
- bool OnFocusGained(const _Control& source);
-
- bool OnFocusLost(const _Control& source);
-
- void OnDrawFocus(void);
-
- bool OnKeyPressed(const _Control &source, const _KeyInfo &keyInfo);
+ virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
+ virtual void OnFontInfoRequested(unsigned long& style, float& size);
- virtual ~_OptionMenu(void);
+ virtual void OnChangeLayout(_ControlOrientation orientation);
+ virtual void OnOwnerChanged(_Control* pOldOwner);
- static _OptionMenu* CreateOptionMenuN(void);
+ virtual bool OnAccessibilityFocusMovedNext(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityFocusMovedPrevious(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityReadingElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityReadElement(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityFocusIn(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityFocusOut(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityActionPerformed(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
+ virtual bool OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element);
- virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
- virtual void OnFontInfoRequested(unsigned long& style, float& size);
+ Tizen::Ui::_AccessibilityElement* GetAccessibilityElement(const int mainIndex) const;
+ void AddAccessibilityElement(const _AccessibilityElement& element);
-private:
- _OptionMenu(void);
+ _OptionMenuItemInfo GetItemFromPosition(const Tizen::Graphics::FloatPoint& position) const;
+ _OptionMenuItemInfo FindItem(int index) const;
+ result SetTopDrawnItemIndex(int index);
- _OptionMenu(const _OptionMenu&);
+ _ScrollPanel* GetScrollPanel(void);
- _OptionMenu& operator =(const _OptionMenu&);
+// virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
+// virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
+// virtual bool OnFocusGained(const _Control& source);
+// virtual bool OnFocusLost(const _Control& source);
+// virtual void OnDrawFocus(void);
+// void OnFocusModeStateChanged(void);
+// bool IsChildControlFocusManage(void) const;
- void SetBoundsAllAccessibilityElement(void);
+protected:
+ result SetPresenter(const _OptionMenuPresenter& OptionMenuPresenter);
+private:
+ result LoadBitmap(void);
+ result LoadColorReplacedBitmap(const Tizen::Graphics::Color& color);
+ void SetAllAccessibilityElement(void);
void RemoveAllAccessibilityElement(void);
private:
+ _OptionMenu(const _OptionMenu& rhs);
+ _OptionMenu& operator =(const _OptionMenu& rhs);
+
+private:
_OptionMenuPresenter* __pOptionMenuPresenter;
+ int __showItemCount;
+ int __showItemMaxCount;
+ bool __isAttachedToMainTree;
+ bool __ownerInputEnableState;
+
+// attribute for position fo the window
+ Tizen::Graphics::FloatRectangle __windowRect; // OptionMenu window in the whole screen area
+ Tizen::Graphics::FloatRectangle __bodyRect; // body area relative to window
+ Tizen::Graphics::FloatRectangle __itemRect; // item area relative to window
+// attribute for event
_ActionEvent* __pActionEvent;
- _ContextMenu* __pSubMenu;
+// attribute for drawing
+ Tizen::Graphics::Bitmap* __pBackgroundNormalBitmap;
+ Tizen::Graphics::Bitmap* __pBackgroundEffectBitmap;
+ enum _ControlOrientation __layout;
- int __subMenuIndex;
+ Tizen::Graphics::Color __backgroundColor;
+ Tizen::Graphics::Color __textColor[OPTION_MENU_ITEM_STATUS_COUNT];
+ Tizen::Graphics::Color __itemColor[OPTION_MENU_ITEM_STATUS_COUNT];
+ Tizen::Base::Collection::ArrayListT<int> __actionId;
Tizen::Base::Collection::LinkedListT<_AccessibilityElement*> __accessibilityElements;
- int __currentFocusedIndex;
+ _ScrollPanel* __pScrollPanel;
+ _ContextMenu* __pSubMenu;
+ int __subMenuIndex;
- bool __isFocused;
}; // _OptionMenu
-}}} // Tizen::Ui::Controls
+}}} // Tizen::Ui: Control
-#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_H_
+#endif //_FUI_CTRL_INTERNAL_OPTION_MENU_H_
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#define _FUI_CTRL_INTERNAL_OPTION_MENU_IMPL_H_
#include <FUiCtrlOptionMenu.h>
-#include <FUiCtrlContextMenu.h>\r
-#include <FUiCtrl_ContextMenu.h>\r
+
#include "FUiCtrl_OptionMenu.h"
#include "FUiCtrl_IActionEventListener.h"
#include "FUi_WindowImpl.h"
result RemoveActionEventListener(Tizen::Ui::IActionEventListener& listener);
- result AddItem(const Tizen::Base::String& text, int actionId);
-\r
- result AddItem(const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap, int actionId);\r
- result AddItem(const Tizen::Base::String &text, int actionId, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap=null, const Tizen::Graphics::Bitmap* pHighlightedBitmap=null);\r
-\r
+ result AddItem(const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap,
+ const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
- result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
+ result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap,
+ const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
- result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
+ result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap,
+ const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
result RemoveItemAt(int mainIndex);
+ void RemoveAllItems (void);
+
int GetItemCount(void) const;
int GetItemIndexFromActionId(int actionId) const;
int GetSubItemActionIdAt(int mainIndex, int subIndex) const;
+ result SetItemTextColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color);
+
+ Tizen::Graphics::Color GetItemTextColor(OptionMenuItemStatus status) const;
+
+ result SetItemColor(OptionMenuItemStatus status, const Tizen::Graphics::Color& color);
+
+ Tizen::Graphics::Color GetItemColor(OptionMenuItemStatus status) const;
+
+ result SetColor(const Tizen::Graphics::Color& color);
+
+ Tizen::Graphics::Color GetColor(void) const;
+
+ result SetMaxVisibleItemsCount(int maxItemsCount);
+
+ int GetMaxVisibleItemsCount(void) const;
+
virtual const char* GetPublicClassName(void) const;
virtual const OptionMenu& GetPublic(void) const;
virtual OptionMenu& GetPublic(void);
- virtual const _ContextMenu& GetCore(void) const;\r
+ virtual const _OptionMenu& GetCore(void) const;
- virtual _ContextMenu& GetCore(void);\r
+ virtual _OptionMenu& GetCore(void);
virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
virtual result OnAttachedToMainTree(void);
private:
- _OptionMenuImpl(OptionMenu* pPublic, _ContextMenu* pCore);\r
+ _OptionMenuImpl(OptionMenu* pPublic, _OptionMenu* pCore);
_OptionMenuImpl(const _OptionMenuImpl&);
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-
/**
* @file FUiCtrl_OptionMenuItem.h
* @brief This is the header file for the _OptionMenuItem class.
+ *
+ * This header file contains the declarations of the %_OptionMenuItem class.
*/
-
-#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_ITEM_H_
-#define _FUI_CTRL_INTERNAL_OPTION_MENU_ITEM_H_
+#ifndef _FUI_CTRL_INTERNAL_OPTIONMENU_ITEM_H_
+#define _FUI_CTRL_INTERNAL_OPTIONMENU_ITEM_H_
#include <FBaseObject.h>
-#include <FBaseResult.h>
#include <FBaseString.h>
-#include <FBaseColArrayList.h>
+#include <FGrpBitmap.h>
+#include <FGrpColor.h>
+#include <FGrpRectangle.h>
+
+#include "FUi_Control.h"
+#include "FUiCtrl_Label.h"
+
namespace Tizen { namespace Ui { namespace Controls
{
+enum OptionMenuItemDrawingStatus
+{
+ OPTION_MENU_ITEM_DRAWING_STATUS_NORMAL = 0,
+ OPTION_MENU_ITEM_DRAWING_STATUS_PRESSED,
+ OPTION_MENU_ITEM_DRAWING_STATUS_HIGHLIGHTED,
+ OPTION_MENU_ITEM_DRAWING_STATUS_MAX
+};
+
+enum OptionMenuItemDrawingType
+{
+ OPTION_MENU_ITEM_DRAWING_TYPE_NONE = -1,
+ OPTION_MENU_ITEM_DRAWING_TYPE_TEXT,
+ OPTION_MENU_ITEM_DRAWING_TYPE_BITMAP
+};
+
+/**
+ * @class _OptionMenuItem
+ * @brief
+ * @since 2.2
+ *
+ *
+ *
+ *
+ */
class _OptionMenuItem
- : public Tizen::Base::Object
+ : public Tizen::Ui::_Control
{
+
public:
- void SetText(const Tizen::Base::String& text);
+ _OptionMenuItem(void);
+ virtual ~_OptionMenuItem(void);
- const Tizen::Base::String& GetText(void) const;
+ static _OptionMenuItem* CreateOptionMenuItemN(void);
- void SetActionId(int actionId);
+ result InsertSubItemAt(_OptionMenuItem& subItem, int index);
+ result SetSubItemAt(_OptionMenuItem& subItem, int index);
+ result RemoveSubItemAt(int index);
+ bool HasSubItem(void) const;
+ int GetSubItemCount(void) const;
+ _OptionMenuItem* GetSubItem(int index);
+
+ void InitializeAccessibilityElement(void);
+
+ void SetType(OptionMenuItemDrawingType type);
+ OptionMenuItemDrawingType GetType(void) const;
+ void SetActionId(int actionId);
int GetActionId(void) const;
- result InsertSubItemAt(_OptionMenuItem& subItem, int index);
+ void SetUpperDivider(bool drawDivider);
+ bool HasUpperDivider(void) const; // first item has no upper divider in List style
+ void SetLowerDivider(bool drawDivider);
+ bool HasLowerDivider(void) const; // last item has no lower divider in List style
- result RemoveSubItemAt(int index);
+ void SetTextSize(float size);
- result RemoveAllSubItem(void);
+ result SetText(const Tizen::Base::String& text);
+ const Tizen::Base::String& GetText(void) const;
- _OptionMenuItem* GetSubItem(int index);
+ result SetBitmap(OptionMenuItemDrawingStatus status, const Tizen::Graphics::Bitmap* pBitmap);
+ const Tizen::Graphics::Bitmap* GetBitmap(OptionMenuItemDrawingStatus status) const;
- const _OptionMenuItem* GetSubItem(int index) const;
+ void SetSize(Tizen::Graphics::FloatDimension size);
+ Tizen::Graphics::FloatDimension GetSize(void) const;
- int GetSubItemCount(void) const;
+ void SetDrawRect(Tizen::Graphics::FloatRectangle rect);
+ Tizen::Graphics::FloatRectangle GetDrawRect(void) const;
- int GetSubItemIndexFromActionId(int actionId) const;
+ void SetPressedDrawRect(Tizen::Graphics::FloatRectangle rect);
+ Tizen::Graphics::FloatRectangle GetPressedDrawRect(void) const;
- bool HasSubItem(void) const;
+ void SetParentScrollEnable(bool enable);
+ bool GetParentScrollEnable() const;
- virtual ~_OptionMenuItem(void);
+ bool IsSelected() const;
- static _OptionMenuItem* CreateInstanceN(void);
+ int Release(void);
-private:
- _OptionMenuItem(void);
+ void SetAndInvalidate(bool flag);
+ const Tizen::Graphics::Bitmap* GetMagentaBgBitmap(void) const;
+
+ virtual void OnBoundsChanged(void);
+ // draw
+ virtual void OnDraw(void);
+ void DrawItem(void);
+ void DrawArrow(void);
+ void SetBitmapLabel(_Label* pLabel);
+ void SetTextLabel(_Label* pLabel);
+ void DrawItemUpperDivider(void);
+ int GetSubItemIndexFromActionId(int actionId) const;
+ void DrawItemBackground(void);
+ void DrawItemLowerDivider(void);
+
+ void TouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ // event handler for ITouchEventListener
+ virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
- _OptionMenuItem(const _OptionMenuItem&);
+ virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
- _OptionMenuItem& operator=(const _OptionMenuItem&);
+ virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
+ virtual void OnFontInfoRequested(unsigned long& style, float& size);
private:
- Tizen::Base::String __text;
+ _OptionMenuItem(const _OptionMenuItem& rhs);
+ _OptionMenuItem& operator =(const _OptionMenuItem& rhs);
+private:
+ OptionMenuItemDrawingType __type;
int __actionId;
+ bool __upperDividerLine;
+ bool __lowerDividerLine;
+
+ bool __pressed;
+ bool __selected;
+ bool __parentScrollEnable;
+
+ float __leftMargin;
+ float __rightMargin;
+ float __dividerHeight;
+ float __bgPressedMargin;
+ float __textLeftMargin;
+ float __textRightMargin;
+ float __textTopMargin;
+ float __textBottomMargin;
+ float __arrowLeftMargin;
+ float __arrowRightMargin;
+ float __arrowMargin;
+ float __itemHeight;
+
+ float __textSize;
+ Tizen::Base::String __text;
+ Tizen::Graphics::Bitmap* __pBitmap[OPTION_MENU_ITEM_DRAWING_STATUS_MAX];
+ Tizen::Graphics::Bitmap* __pMagentaBgBitmap;
+ Tizen::Graphics::Bitmap* __pArrowBitmap;
+ Tizen::Graphics::Bitmap* __pArrowPressedBitmap;
+ Tizen::Graphics::FloatDimension __size;
+ Tizen::Graphics::FloatRectangle __drawRect;
+ Tizen::Graphics::FloatRectangle __pressedDrawRect;
+ Tizen::Graphics::Color __selectedBgColor;
+ Tizen::Graphics::Color __upperDividerLineColor;
+ Tizen::Graphics::Color __lowerDividerLineColor;
+
+ _Label* __pBitmapLabel;
+ _Label* __pTextLabel;
+ _Label* __pUpperDividerLineLabel;
+ _Label* __pBackgroundLabel;
+ _Label* __pLowerDividerLineLabel;
+ _Label* __pArrowLabel;
Tizen::Base::Collection::ArrayList* __pSubItems;
+
}; // _OptionMenuItem
}}} // Tizen::Ui::Controls
-#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_ITEM_H_
+#endif // _FUI_CTRL_INTERNAL_OPTIONMENU_ITEM_H_
+++ /dev/null
-//\r
-// Open Service Platform\r
-// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0/\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-/**\r
- * @file FUiCtrl_OptionMenuListPresenter.h\r
- * @brief This is the header file for the _OptionMenuListPresenter class.\r
- *\r
- * This header file contains the declarations of the %_OptionMenuListPresenter class.\r
- */\r
-#ifndef _FUI_CTRL_INTERNAL_OPTIONMENU_LIST_PRESENTER_H_\r
-#define _FUI_CTRL_INTERNAL_OPTIONMENU_LIST_PRESENTER_H_\r
-\r
-#include <FGrp_TextTextObject.h>\r
-#include "FUi_Control.h"\r
-#include "FUiCtrl_ContextMenu.h"\r
-#include "FUiCtrl_ContextMenuModel.h"\r
-#include "FUiCtrl_IContextMenuPresenter.h"\r
-\r
-namespace Tizen { namespace Ui { namespace Controls\r
-{\r
-\r
-class _ContextMenu;\r
-class _ContextMenuModel;\r
-class _ContextMenuItem;\r
-\r
-/**\r
- * @class _OptionMenuListPresenter\r
- * @brief\r
- * @since 2.0\r
- *\r
- *\r
- *\r
- *\r
- */\r
-class _OptionMenuListPresenter\r
- : public _IContextMenuPresenter\r
-{\r
-// Lifecycle\r
-public:\r
- _OptionMenuListPresenter(_ContextMenu* pContextMenu);\r
- virtual ~_OptionMenuListPresenter(void);\r
-\r
-// Operation\r
-public:\r
- virtual result Install(void);\r
- virtual result Draw(void);\r
- virtual result DrawBackground(Tizen::Graphics::Canvas* pCanvas);\r
- virtual result DrawArrow(Tizen::Graphics::Canvas* pCanvas);\r
- virtual result AddItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
- virtual result InsertItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
- virtual result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
- virtual result DeleteItem(int index);\r
- virtual result DeleteItemAll(void);\r
- virtual int CalculateShowItemCount(void);\r
- virtual result CalculateWindowRect(void);\r
- virtual result ApplyColorProperty(void);\r
-\r
- virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);\r
- virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);\r
- virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);\r
-\r
- virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);\r
- virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);\r
- virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);\r
- virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);\r
-\r
- virtual void OnFontChanged(Tizen::Graphics::Font* pFont);\r
- virtual void OnFontInfoRequested(unsigned long& style, float& size);\r
-\r
- virtual void SetAllAccessibilityElement(void);\r
-\r
- virtual _ContextMenuItemInfo GetItemFromPosition(const Tizen::Graphics::FloatPoint& position);\r
- virtual _ContextMenuItemInfo FindItem(int index);\r
- virtual result SetTopDrawnItemIndex(int index);\r
- virtual result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);\r
-\r
-private:\r
- void LoadShape(void);\r
- result CalculateRect(void);\r
- void AdjustItemLayout(void);\r
- void AdjustItemPosition(void);\r
- Tizen::Graphics::FloatDimension AdjustItemLayoutStyle(void);\r
-\r
- _ContextMenuItem* CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);\r
- int GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& point) const;\r
-\r
-private:\r
- _OptionMenuListPresenter(const _OptionMenuListPresenter& rhs);\r
- _OptionMenuListPresenter& operator =(const _OptionMenuListPresenter& rhs);\r
-\r
-// Attribute\r
-private:\r
- _ContextMenu* __pContextMenu;\r
- _ContextMenuModel* __pModel;\r
-\r
- Tizen::Graphics::Font* __pFont;\r
- Tizen::Graphics::FloatDimension __layoutSize;\r
-\r
- bool __touchOutRect;\r
- int __selectedIndex;\r
- bool __scrollEnable;\r
-\r
- float __maxWidth;\r
- float __minWidth;\r
- float __topMargin;\r
- float __bottomMargin;\r
- float __leftMargin;\r
- float __rightMargin;\r
- float __screenTopMargin;\r
- float __screenBottomMargin;\r
- float __screenLeftMargin;\r
- float __screenRightMargin;\r
- float __arrowTopMargin;\r
- float __arrowBottomMargin;\r
- float __arrowRightMargin;\r
- float __arrowLeftMargin;\r
- float __arrowWidth;\r
- float __arrowHeight;\r
- float __itemWidth;\r
- float __itemMinWidth;\r
- float __itemHeight;\r
- float __itemMaxWidth;\r
- float __itemGap;\r
- float __itemBitmapWidth;\r
- float __itemBitmapHeight;\r
- float __itemFontSize;\r
- float __dividerHeight;\r
- float __anchorPopupOverlap;\r
-}; // _OptionMenuListPresenter\r
-\r
-}}} // Tizen::Ui: Control\r
-\r
-#endif //_FUI_CTRL_INTERNAL_OPTIONMENU_LIST_PRESENTER_H_\r
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-
/**
* @file FUiCtrl_OptionMenuModel.h
* @brief This is the header file for the _OptionMenuModel class.
+ *
+ * This header file contains the declarations of the %_OptionMenuModel class.
*/
-
-#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_MODEL_H_
-#define _FUI_CTRL_INTERNAL_OPTION_MENU_MODEL_H_
+#ifndef _FUI_CTRL_INTERNAL_OPTIONMENU_MODEL_H_
+#define _FUI_CTRL_INTERNAL_OPTIONMENU_MODEL_H_
#include <FBaseObject.h>
-#include <FBaseResult.h>
-#include <FBaseString.h>
#include <FBaseColArrayList.h>
+#include "FUiCtrl_OptionMenuItem.h"
namespace Tizen { namespace Ui { namespace Controls
{
-
-class _OptionMenuItem;
+/**
+ * @class _OptionMenuModel
+ * @brief
+ * @since 2.2
+ *
+ *
+ *
+ *
+ */
class _OptionMenuModel
: public Tizen::Base::Object
{
public:
- result AddItem(const Tizen::Base::String& text, int actionId, int mainIndex = -1);
-
- result InsertItemAt(const Tizen::Base::String& text, int actionId, int mainIndex, int subIndex = -1);
-
- result SetItemAt(const Tizen::Base::String& text, int actionId, int mainIndex, int subIndex = -1);
-
- result RemoveItemAt(int mainIndex, int subIndex = -1);
-
- result RemoveAllItem(void);
-
- _OptionMenuItem* GetItem(int mainIndex, int subIndex = -1);
-
- const _OptionMenuItem* GetItem(int mainIndex, int subIndex = -1) const;
+ _OptionMenuModel(void);
+ virtual ~_OptionMenuModel(void);
+public:
+ result Construct(void);
int GetItemCount(void) const;
-
- int GetItemIndexFromActionId(int actionId) const;
-
+ _OptionMenuItem* GetItem(int mainIndex, int subIndex = -1) const;
+ result AddItem(_OptionMenuItem* pItem, int mainIndex = -1);
+ result InsertItem(_OptionMenuItem* pItem, int mainIndex, int subIndex = -1);
+ result SetItem(_OptionMenuItem* pItem, int mainIndex, int subIndex = -1);
+ result RemoveItem(int mainIndex, int subIndex = -1);
+ result RemoveAllItem(void);
+ void ResetAllItem(void);
int GetSubItemCount(int mainIndex) const;
-
+ int GetItemIndexFromActionId(int actionId) const;
int GetSubItemIndexFromActionId(int actionId, int& mainIndex) const;
- virtual ~_OptionMenuModel(void);
-
- static _OptionMenuModel* CreateInstanceN(void);
-
private:
- _OptionMenuModel(void);
-
- _OptionMenuModel(const _OptionMenuModel&);
+ bool IsValidItem(_OptionMenuItem *pItem);
- _OptionMenuModel& operator =(const _OptionMenuModel&);
+private:
+ _OptionMenuModel(const _OptionMenuModel& rhs);
+ _OptionMenuModel& operator =(const _OptionMenuModel& rhs);
private:
Tizen::Base::Collection::ArrayList __items;
}}} // Tizen::Ui::Controls
-#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_MODEL_H_
+#endif // _FUI_CTRL_INTERNAL_OPTIONMENU_MODEL_H_
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
-
/**
* @file FUiCtrl_OptionMenuPresenter.h
* @brief This is the header file for the _OptionMenuPresenter class.
+ *
+ * This header file contains the declarations of the %_OptionMenuPresenter class.
*/
+#ifndef _FUI_CTRL_INTERNAL_OPTIONMENU_PRESENTER_H_
+#define _FUI_CTRL_INTERNAL_OPTIONMENU_PRESENTER_H_
-#ifndef _FUI_CTRL_INTERNAL_OPTION_MENU_PRESENTER_H_
-#define _FUI_CTRL_INTERNAL_OPTION_MENU_PRESENTER_H_
-
-#include <FBaseObject.h>
-#include <FBaseRtTimer.h>
-#include <FBaseRtITimerEventListener.h>
-#include <FGrpPoint.h>
-#include <FGrpFloatMatrix4.h>
-#include <FUiAnim_VisualElement.h>
-#include <FUiAnimVisualElementAnimation.h>
-#include <FUiAnimVisualElementAnimationProvider.h>
-#include <FUiAnimIVisualElementAnimationStatusEventListener.h>
-#include <FUiAnimIVisualElementAnimationTimingFunction.h>
#include <FGrp_TextTextObject.h>
+#include <FBaseString.h>
+#include <FGrpColor.h>
+#include <FGrpBitmap.h>
+#include <FUiCtrlListView.h>
+#include <FUiCtrlCustomItem.h>
#include "FUi_Control.h"
-
-namespace Tizen { namespace Graphics {
-class Font;
-}} // Tizen::Graphics
+#include "FUiCtrl_OptionMenu.h"
+#include "FUiCtrl_OptionMenuModel.h"
+#include "FUiAnim_VisualElement.h"
namespace Tizen { namespace Ui { namespace Controls
{
class _OptionMenu;
class _OptionMenuModel;
+class _OptionMenuItem;
+class _ListItem;
-class SineThirtyThreeTimingFunction
- : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction
+struct _OptionMenuItemInfo
{
-public:
- float CalculateProgress(float timeProgress) const;
-}; // SineTimingFunction
-
-class SineSixtyTimingFunction
- : public Tizen::Ui::Animations::IVisualElementAnimationTimingFunction
-{
-public:
- float CalculateProgress(float timeProgress) const;
-}; // SineTimingFunction
+ bool bListItem;
+ _ListItem* pListItem;
+ _OptionMenuItem* pOptionMenuItem;
+};
+/**
+ * @class _OptionMenuPresenter
+ * @brief
+ * @since 2.0
+ *
+ *
+ *
+ *
+ */
class _OptionMenuPresenter
- : public Tizen::Base::Object
- , virtual public Tizen::Ui::Animations::VisualElementAnimationProvider
- , virtual public Tizen::Ui::Animations::IVisualElementAnimationProvider
- , virtual public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener
- , virtual public Tizen::Base::Runtime::IEventListener
{
+// Lifecycle
public:
- result AddItem(const Tizen::Base::String& text, int actionId);
-
- result InsertItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
-
- result SetItemAt(int mainIndex, const Tizen::Base::String& text, int actionId);
-
- result RemoveItemAt(int mainIndex);
-
- Tizen::Graphics::FloatRectangle GetItemBounds(int index) const;
-
- int GetItemCount(void) const;
-
- int GetItemIndexFromActionId(int actionId) const;
-
- int GetItemActionIdAt(int mainIndex) const;
-
- result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId);
-
- result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
-
- result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
-
- result RemoveSubItemAt(int mainIndex, int subIndex);
-
- int GetSubItemCount(int mainIndex) const;
+ _OptionMenuPresenter(_OptionMenu* pOptionMenu);
+ virtual ~_OptionMenuPresenter(void);
+// Operation
+public:
+ virtual result Install(void);
+ virtual result Draw(void);
+ virtual result DrawBackground(Tizen::Graphics::Canvas* pCanvas);
+ virtual result AddItem(const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ virtual result AddSubItem(int mainIndex, const Tizen::Base::String& text, int actionId);
+ int GetItemIndexFromActionId(int actionId) const;
+ int GetItemActionIdAt(int mainIndex) const;
+ virtual result InsertItem(int mainIndex, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ virtual result InsertSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
+ virtual result SetSubItemAt(int mainIndex, int subIndex, const Tizen::Base::String& text, int actionId);
+ virtual result RemoveSubItemAt(int mainIndex, int subIndex);
+ virtual int GetSubItemCount(int mainIndex) const;
+ virtual result SetItem(int index, const Tizen::Base::String& text, int actionId, const Tizen::Graphics::Bitmap* normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ virtual result DeleteItem(int index);
+ virtual result DeleteItemAll(void);
+ virtual int CalculateShowItemCount(void);
+ virtual result CalculateWindowRect(void);
+ virtual result ApplyColorProperty(void);
int GetSubItemIndexFromActionId(int actionId) const;
int GetSubItemActionIdAt(int mainIndex, int subIndex) const;
- result Draw(void);
-
-public:
- result InitializeVisualElement(void);
-
- result InitializeTextObject(void);
-
-// _IControlDelegator
- void OnChangeLayout(Tizen::Ui::_ControlOrientation orientation);
-
- result OnAttachingToMainTree(const Tizen::Ui::_Control* pParent);
-
- result OnAttachedToMainTree(void);
-
- result OnDetachingFromMainTree(void);
-
- void OnVisibleStateChanged(void);
-
-// _ITouchEventListener
- bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
-
- bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ virtual _UiTouchEventDelivery OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
- bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
+ virtual bool OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo);
+ virtual bool OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo);
- bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
+ virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
-// _IActionEventListener
- void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
+ virtual void OnFontChanged(Tizen::Graphics::Font* pFont);
+ virtual void OnFontInfoRequested(unsigned long& style, float& size);
- virtual ~_OptionMenuPresenter(void);
-
- static _OptionMenuPresenter* CreateInstanceN(_OptionMenu& optionMenu);
-
- result CalculateBounds(void);
+ virtual void SetAllAccessibilityElement(void);
- result PrepareAnimation(void);
- result SetOptionMenuVisibility(bool visibility);
- virtual Tizen::Ui::Animations::VisualElementAnimation* CreateAnimationForProperty(Tizen::Ui::Animations::VisualElement& target, const Tizen::Base::String& property);
- virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target);
- virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount);
- virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally);
- result DrawResourceBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, Tizen::Graphics::Bitmap* pBitmap);
+ virtual _OptionMenuItemInfo GetItemFromPosition(const Tizen::Graphics::FloatPoint& position);
+ virtual _OptionMenuItemInfo FindItem(int index);
+ virtual result SetTopDrawnItemIndex(int index);
+ virtual result DrawBitmap(Tizen::Graphics::Canvas& canvas, const Tizen::Graphics::FloatRectangle& bounds, const Tizen::Graphics::Bitmap& bitmap);
- void OnFontChanged(Tizen::Graphics::Font* pFont);
- void OnFontInfoRequested(unsigned long& style, float& size);
- Tizen::Graphics::Font* GetFont(void) const;
+// virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
- result DrawFocus(int index);
- result ClearFocus(int index);
- void OnEnterKeyPressed(int index);
+// virtual bool OnFocusGained(const _Control& source);
+// virtual bool OnFocusLost(const _Control& source);
+// virtual void OnDrawFocus(void);
private:
- _OptionMenuPresenter(_OptionMenu* optionMenu);
-
- _OptionMenuPresenter(const _OptionMenuPresenter&);
-
- _OptionMenuPresenter& operator =(const _OptionMenuPresenter&);
-
- int GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& position) const;
-
- result LoadBitmap(void);
-
- result DrawHandler(Tizen::Graphics::Canvas& canvas);
-
- result DrawItem(Tizen::Graphics::Canvas& canvas, int index);
-
- result DrawItemLine(Tizen::Graphics::Canvas& canvas);
-
- result RefreshItem(int index);
+ void LoadShape(void);
+ result CalculateRect(void);
+ void AdjustItemLayout(void);
+ void AdjustItemPosition(void);
+ Tizen::Graphics::FloatDimension AdjustItemLayoutStyle(void);
- result LoadShapeResource(Tizen::Ui::_ControlOrientation orientation);
+ _OptionMenuItem* CreateItem(const Base::String& text, int actionId, const Tizen::Graphics::Bitmap* pNormalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap, const Tizen::Graphics::Bitmap* pHighlightedBitmap);
+ int GetItemIndexFromPosition(const Tizen::Graphics::FloatPoint& point) const;
- void Hide(void);
-
- result SetPosition(const Tizen::Graphics::FloatPoint& position);
-
- result StopAnimation(void);
+private:
+ _OptionMenuPresenter(const _OptionMenuPresenter& rhs);
+ _OptionMenuPresenter& operator =(const _OptionMenuPresenter& rhs);
+// Attribute
private:
_OptionMenu* __pOptionMenu;
-
- _OptionMenuModel* __pOptionMenuModel;
-
- Tizen::Graphics::Bitmap* __pItemBitmap;
-
- Tizen::Graphics::Bitmap* __pItemPressedBitmap;
-
- Tizen::Graphics::Bitmap* __pItemPressedEffectBitmap;
-
- Tizen::Graphics::Bitmap* __pArrowBitmap;
-
- Tizen::Graphics::Bitmap* __pArrowPressedBitmap;
-
- Tizen::Graphics::Bitmap* __pHandleBitmap;
-
- Tizen::Graphics::Bitmap* __pHandleEffectBitmap;
-
- Tizen::Graphics::Bitmap* __pHandlePressedBitmap;
-
- Tizen::Graphics::Bitmap* __pHandlePressedEffectBitmap;
-
- Tizen::Graphics::Bitmap* __pHandleDisabledBitmap;
-
- Tizen::Graphics::Bitmap* __pHandleArrowNormalBitmap;
-
- Tizen::Graphics::Bitmap* __pHandleArrowPressedBitmap;
-
- Tizen::Graphics::Bitmap* __pHandleArrowDisabledBitmap;
-
- Tizen::Graphics::_Text::TextObject __textObject;
+ _OptionMenuModel* __pModel;
Tizen::Graphics::Font* __pFont;
+ Tizen::Graphics::FloatDimension __layoutSize;
- int __maxColumnCount;
-
- int __rowCount;
-
- int __columnCount;
-
- float __width;
-
- float __handleHeight;
-
- float __itemHeight;
-
- float __lineWidth;
-
- float __leftMargin;
-
- float __rightMargin;
-
- float __textSize;
-
- float __textLeftMargin;
-
- float __textRightMargin;
-
- float __textTopMargin;
-
- float __textBottomMargin;
-
- float __arrowMargin;
-
+ bool __touchOutRect;
int __selectedIndex;
+ bool __scrollEnable;
- bool __isHandlerPressed;
-
- bool __isClosing;
-
- bool __isAnimationStarted;
-
- int __focusedIndex;
-
- Tizen::Graphics::FloatRectangle __arrowBounds;
-
- Tizen::Graphics::FloatMatrix4 _matrixOrigin;
- Tizen::Graphics::FloatMatrix4 _matrixScale;
- Tizen::Ui::Animations::_VisualElement* __pOptionMenuVE;
- const Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pThirtyThreeTimingFunction;
- const Tizen::Ui::Animations::IVisualElementAnimationTimingFunction* __pSixtyTimingFunction;
-
-
-}; // _OptionMenuPresenter
+ float __maxWidth;
+ float __minWidth;
+ float __topMargin;
+ float __bottomMargin;
+ float __leftMargin;
+ float __rightMargin;
+ float __itemWidth;
+ float __itemMinWidth;
+ float __itemHeight;
+ float __itemMaxWidth;
+ float __itemGap;
+ float __itemBitmapWidth;
+ float __itemBitmapHeight;
+ float __itemFontSize;
+ float __dividerHeight;
+}; // _OptionMenuListPresenter
-}}} // Tizen::Ui::Controls
+}}} // Tizen::Ui: Control
-#endif // _FUI_CTRL_INTERNAL_OPTION_MENU_PRESENTER_H_
+#endif //_FUI_CTRL_INTERNAL_OPTIONMENU_PRESENTER_H_
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
DECLARE_SHAPE_CONFIG(ITEM_PRESS_RIGHT_MARGIN, 13);
DECLARE_SHAPE_CONFIG(ITEM_PRESS_TOP_MARGIN, 14);
DECLARE_SHAPE_CONFIG(ITEM_PRESS_BOTTOM_MARGIN, 15);
+ DECLARE_SHAPE_CONFIG(LIST_MAX_WIDTH, 16);
+ DECLARE_SHAPE_CONFIG(MAX_OPTIONMENU_SHOW_ITEM, 17);
DECLARE_END_UI_CONFIG(OPTIONMENU);
#endif //_FUI_RESOURCE_OPTION_MENU_CONFIG_H_
// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
+// distributed under the License is distributed on an ”AS IS” BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
ADD_SHAPE_CONFIG(ITEM_PRESS_RIGHT_MARGIN, 5);
ADD_SHAPE_CONFIG(ITEM_PRESS_TOP_MARGIN, 3);
ADD_SHAPE_CONFIG(ITEM_PRESS_BOTTOM_MARGIN, 3);
+ ADD_SHAPE_CONFIG(LIST_MAX_WIDTH, 500);
+ ADD_SHAPE_CONFIG(MAX_OPTIONMENU_SHOW_ITEM, 7);
ADD_FIXED_VALUE_CONFIG(ITEM_PRESS_EDGE_MARGIN, 2);
}
END_UI_CONFIG_MODE(720x1280);
START_UI_CONFIG_MODE(1280x720);
{
ADD_FIXED_VALUE_CONFIG(COLUMN_MAX, 4);
+ ADD_SHAPE_CONFIG(MAX_OPTIONMENU_SHOW_ITEM, 5);
}
END_UI_CONFIG_MODE(1280x720);
}