Back to index

nux  3.0.0
RangeValueInteger.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
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, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef RANGEVALUEINTEGER_H
00024 #define RANGEVALUEINTEGER_H
00025 
00026 namespace nux
00027 {
00028 
00029   class HLayout;
00030   class EditTextBox;
00031 
00032   class RangeValueInteger : public View
00033   {
00034   public:
00035     RangeValueInteger(int Value = 0, int MinValue = 0, int MaxValue = 100, NUX_FILE_LINE_PROTO);
00036     ~RangeValueInteger();
00037 
00038     void DrawMarker(GraphicsEngine &graphics_engine);
00039     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00040     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
00041     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw);
00042 
00044     //  RECEIVERS  //
00046     void SetRange(int min_value, int max_value);
00047     void SetValue(int value);
00048     int GetValue() const;
00049     int GetMinValue() const
00050     {
00051       return m_min;
00052     }
00053     int GetMaxValue() const
00054     {
00055       return m_max;
00056     }
00057 
00058     void SetBackgroundColor(const Color &color)
00059     {
00060       m_ValueString->SetTextBackgroundColor(color);
00061     }
00062     const Color GetBackgroundColor() const
00063     {
00064       return m_ValueString->GetTextBackgroundColor();
00065     }
00066 
00067     void setStartToEndColor(Color color_start, Color color_end)
00068     {
00069       m_StartColor = color_start;
00070       m_EndColor = color_end;
00071     }
00072     void setStartColor(Color color)
00073     {
00074       m_StartColor = color;
00075     }
00076     void setEndColor(Color color)
00077     {
00078       m_EndColor = color;
00079     }
00080     void setProgressColor(Color color)
00081     {
00082       m_ProgressColor = color;
00083     }
00084     void EnableDrawProgress(bool b)
00085     {
00086       m_EnableDrawProgress = b;
00087     }
00088 
00090     //  EMITTERS  //
00092     void OnReceiveMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00093     void OnReceiveMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00094     void OnReceiveMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00095     void OnKeyboardFocus();
00096     void OnLostKeyboardFocus();
00097     void OnValidateKeyboardEntry(EditTextBox *textbox, const NString &text);
00098 
00099     bool IsCtrlKeyPressed() const
00100     {
00101       return (m_CTRL_KEY ? true : false);
00102     }
00103 
00104     // signals
00105     sigc::signal<void, RangeValueInteger *> sigValueChanged;
00106     sigc::signal<void, int> sigMouseDown;
00107     sigc::signal<void, int> sigMouseUp;
00108     sigc::signal<void, int> sigMouseDrag;
00109     sigc::signal<void, int> sigSetTypedValue;
00110     sigc::signal<void, int> sigValueChanged2;
00111     //sigc::signal<void, const char*> sigValidateKeyboarEntry;
00112 
00113     void BroadcastValue();
00114   protected:
00115     void InitializeWidgets();
00116     void InitializeLayout();
00117 
00118   protected:
00119     HLayout        *hlayout;
00120     EditTextBox    *m_ValueString;
00121     InputArea       *m_Percentage;
00122     Color m_StartColor;
00123     Color m_EndColor;
00124     Color m_ProgressColor;
00125     Color m_BackgroundColor;
00126     bool m_EnableDrawProgress;
00127 
00128     long m_CTRL_KEY;
00129 
00130     float m_MarkerPosition;
00131     int m_Value;
00132     int m_min, m_max;
00133 
00134   };
00135 
00136 }
00137 
00138 #endif // RANGEVALUEINTEGER_H
00139 
00140