From 0af779569095af43a2762843f40d2d5e88168bf9 Mon Sep 17 00:00:00 2001 From: that Date: Wed, 25 Feb 2015 08:52:19 +0100 Subject: gui: introduce virtual RenderItem method in ScrollList - so derived lists can draw whatever they want (multi-line etc.) - replace GetListItem with RenderItem - minor cleanup Change-Id: I062e0a354f1c18ce0a5232b7542c4987b480e232 --- gui/objects.hpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'gui/objects.hpp') diff --git a/gui/objects.hpp b/gui/objects.hpp index 0f853ac59..d5c3b2738 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -533,12 +533,14 @@ protected: // derived classes need to implement these // get number of items virtual size_t GetItemCount() { return 0; } - // get data for one item - virtual int GetListItem(size_t item_index, ImageResource*& icon, std::string &text) - { icon = NULL; text = ""; return -1; } + // render a single item in rect (mRenderX, yPos, mRenderW, actualItemHeight) + virtual void RenderItem(size_t itemindex, int yPos, bool selected); // an item was selected virtual void NotifySelect(size_t item_selected) {} + // render a standard-layout list item with optional icon and text + void RenderStdItem(int yPos, bool selected, ImageResource* icon, const char* text, int iconAndTextH = 0); + enum { NO_ITEM = (size_t)-1 }; // returns item index at coordinates or NO_ITEM if there is no item there size_t HitTestItem(int x, int y); @@ -562,7 +564,6 @@ protected: // Background COLOR mBackgroundColor; ImageResource* mBackground; // background image, if any, automatically centered - int mBackgroundW, mBackgroundH; // background width and height if using an image for the background // Header COLOR mHeaderBackgroundColor; @@ -630,7 +631,7 @@ public: virtual void SetPageFocus(int inFocus); virtual size_t GetItemCount(); - virtual int GetListItem(size_t item_index, ImageResource*& icon, std::string &text); + virtual void RenderItem(size_t itemindex, int yPos, bool selected); virtual void NotifySelect(size_t item_selected); protected: @@ -685,7 +686,7 @@ public: virtual void SetPageFocus(int inFocus); virtual size_t GetItemCount(); - virtual int GetListItem(size_t item_index, ImageResource*& icon, std::string &text); + virtual void RenderItem(size_t itemindex, int yPos, bool selected); virtual void NotifySelect(size_t item_selected); protected: @@ -721,7 +722,7 @@ public: virtual void SetPageFocus(int inFocus); virtual size_t GetItemCount(); - virtual int GetListItem(size_t item_index, ImageResource*& icon, std::string &text); + virtual void RenderItem(size_t itemindex, int yPos, bool selected); virtual void NotifySelect(size_t item_selected); protected: -- cgit v1.2.3