Add an optional function to the pop-up button, so that it will select the next entry when clicked and also do some miscellaneous code clean-ups including forward declarations.

This commit is contained in:
Adam Reichold
2015-12-20 15:56:12 +01:00
parent e9141dd98c
commit 151556ae23
11 changed files with 127 additions and 91 deletions

View File

@@ -21,11 +21,21 @@
#ifndef _POPUPCOMMON_
#define _POPUPCOMMON_
#include <vector>
#include <glibmm/ustring.h>
#include <sigc++/signal.h>
#include <gtkmm.h>
#include <sigc++/sigc++.h>
#include "rtimage.h"
namespace Gtk
{
class HBox;
class Menu;
class Button;
class ImageMenuItem;
}
typedef struct _GdkEventButton GdkEventButton;
class RTImage;
class PopUpCommon
{
@@ -37,12 +47,10 @@ public:
PopUpCommon (Gtk::Button* button, const Glib::ustring& label = "");
virtual ~PopUpCommon ();
bool addEntry (Glib::ustring fileName, Glib::ustring label);
bool addEntry (const Glib::ustring& fileName, const Glib::ustring& label);
int getEntryCount () const;
bool setSelected (int entryNum);
int getSelected ()
{
return selected;
}
int getSelected () const;
void setButtonHint();
void show ();
void set_tooltip_text (const Glib::ustring &text);
@@ -50,14 +58,8 @@ public:
private:
type_signal_changed message;
/*
TODO: MenuItem::get_label() doesn't return any string, or an empty string !?
That's why we store entries strings in sItems, but it would be nice to get ride of it...
*/
std::vector<Glib::ustring> sItems;
std::vector<Glib::ustring> imageFilenames;
std::vector<RTImage*> images;
std::vector<Gtk::ImageMenuItem*> items;
Glib::ustring buttonHint;
RTImage* buttonImage;
Gtk::HBox* imageContainer;
@@ -67,9 +69,26 @@ private:
bool hasMenu;
void showMenu(GdkEventButton* event);
void entrySelected (int i);
void setItemSensitivity (int i, bool isSensitive);
protected:
void entrySelected (int i);
};
inline PopUpCommon::type_signal_changed PopUpCommon::signal_changed ()
{
return message;
}
inline int PopUpCommon::getEntryCount () const
{
return images.size();
}
inline int PopUpCommon::getSelected () const
{
return selected;
}
#endif