Back to index

unity  6.0.0
FilterRatingsButton.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Gordon Allott <gord.allott@canonical.com>
00019  *
00020  */
00021 
00022 #ifndef UNITYSHELL_FILTERRATINGSBUTTONWIDGET_H
00023 #define UNITYSHELL_FILTERRATINGSBUTTONWIDGET_H
00024 
00025 #include <memory>
00026 
00027 #include <Nux/Nux.h>
00028 #include <Nux/ToggleButton.h>
00029 #include <Nux/CairoWrapper.h>
00030 #include <UnityCore/RatingsFilter.h>
00031 
00032 namespace unity
00033 {
00034 namespace dash
00035 {
00036 
00037 class FilterRatingsButton : public nux::ToggleButton
00038 {
00039 public:
00040   FilterRatingsButton(NUX_FILE_LINE_PROTO);
00041   virtual ~FilterRatingsButton();
00042 
00043   void SetFilter(Filter::Ptr const& filter);
00044   RatingsFilter::Ptr GetFilter();
00045   std::string GetFilterType();
00046 
00047 protected:
00048   virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
00049 
00050   // Key-nav
00051   virtual bool AcceptKeyNavFocus();
00052   virtual bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
00053 
00054 private:
00055   void OnKeyDown(unsigned long event_type, unsigned long event_keysym,
00056                  unsigned long event_state, const TCHAR* character,
00057                  unsigned short key_repeat_count);
00058 
00059   void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00060   void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00061   void RecvMouseMove(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00062   void OnRatingsChanged(int rating);
00063 
00064   dash::RatingsFilter::Ptr filter_;
00065   int focused_star_;
00066 
00067 };
00068 
00069 } // namespace dash
00070 } // namespace unity
00071 
00072 #endif // UNITYSHELL_FILTERRATINGSBUTTONWIDGET_H
00073