Back to index

unity  6.0.0
IndicatorEntry.h
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003 * Copyright (C) 2010-2011 Canonical Ltd
00004 *
00005 * This program is free software: you can redistribute it and/or modify
00006 * it under the terms of the GNU General Public License version 3 as
00007 * published by the Free Software Foundation.
00008 *
00009 * This program is distributed in the hope that it will be useful,
00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 * GNU General Public License for more details.
00013 *
00014 * You should have received a copy of the GNU General Public License
00015 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 *
00017 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018 *              Marco Trevisan (TreviƱo) <mail@3v1n0.net>
00019 */
00020 
00021 #ifndef UNITY_INDICATOR_ENTRY_H
00022 #define UNITY_INDICATOR_ENTRY_H
00023 
00024 #include <iosfwd>
00025 #include <map>
00026 #include <string>
00027 #include <memory>
00028 #include <sigc++/signal.h>
00029 
00030 #include <NuxCore/Rect.h>
00031 
00032 namespace unity
00033 {
00034 namespace indicator
00035 {
00036 
00037 // The EntryLocationMap is used to map the entry name to the
00038 // physical location on the screen.
00039 typedef std::map<std::string, nux::Rect> EntryLocationMap;
00040 
00041 class Entry
00042 {
00043 public:
00044   typedef std::shared_ptr<Entry> Ptr;
00045 
00046   Entry(std::string const& id,
00047         std::string const& name_hint,
00048         std::string const& label,
00049         bool label_sensitive,
00050         bool label_visible,
00051         int  image_type,
00052         std::string const& image_data,
00053         bool image_sensitive,
00054         bool image_visible,
00055         int  priority);
00056 
00057   // Assignment emits updated event.
00058   Entry& operator=(Entry const& rhs);
00059 
00060   std::string const& id() const;
00061   std::string const& name_hint() const;
00062   std::string const& label() const;
00063   int image_type() const;
00064   std::string const& image_data() const;
00065   bool image_visible() const;
00066   bool image_sensitive() const;
00067   bool label_visible() const;
00068   bool label_sensitive() const;
00069 
00070   void set_active(bool active);
00071   bool active() const;
00072 
00073   void set_geometry(nux::Rect const& geometry);
00074   nux::Rect const& geometry() const;
00075 
00076   int priority() const;
00077 
00078   bool visible() const;
00079 
00085   bool show_now() const;
00086   void set_show_now(bool show_now);
00087 
00088   void ShowMenu(int x, int y, unsigned int button, unsigned int timestamp);
00089   void ShowMenu(unsigned int xid, int x, int y, unsigned int button, unsigned int timestamp);
00090   void SecondaryActivate(unsigned int timestamp);
00091   void Scroll(int delta);
00092 
00093   void setLabel(std::string const& label, bool sensitive, bool visible);
00094   void setImage(int type, std::string const& data, bool sensitive, bool visible);
00095   void setPriority(int priority);
00096 
00097   // Signals
00098   sigc::signal<void> updated;
00099   sigc::signal<void, bool> active_changed;
00100   sigc::signal<void, nux::Rect const&> geometry_changed;
00101   sigc::signal<void, bool> show_now_changed;
00102 
00103   sigc::signal<void, std::string const&, unsigned int, int, int, unsigned int, unsigned int> on_show_menu;
00104   sigc::signal<void, std::string const&, unsigned int> on_secondary_activate;
00105   sigc::signal<void, std::string const&, int> on_scroll;
00106 
00107 private:
00108   std::string id_;
00109   std::string name_hint_;
00110 
00111   std::string label_;
00112   bool label_visible_;
00113   bool label_sensitive_;
00114 
00115   int image_type_;
00116   std::string image_data_;
00117   bool image_visible_;
00118   bool image_sensitive_;
00119   int priority_;
00120 
00121   bool show_now_;
00122   bool active_;
00123 
00124   nux::Rect geometry_;
00125 };
00126 
00127 std::ostream& operator<<(std::ostream& out, Entry const& e);
00128 
00129 }
00130 }
00131 
00132 #endif