nux-0.9.48
|
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 TABVIEW_H 00024 #define TABVIEW_H 00025 00026 #include "Nux.h" 00027 #include "View.h" 00028 #include "TimerProc.h" 00029 #include "HLayout.h" 00030 00031 namespace nux 00032 { 00033 00034 class TabView : public View 00035 { 00036 public: 00037 TabView (NUX_FILE_LINE_PROTO); 00038 ~TabView(); 00039 00040 virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo); 00041 virtual void Draw (GraphicsEngine &GfxContext, bool force_draw); 00042 virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw); 00043 virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw); 00044 00045 void AddTab (const char *tab_name, Layout *tab_layout); 00046 void SetActiveTad (int index); 00048 /* 00049 Return true if this object can break the layout, meaning, the layout can be done on the composition layout only without 00050 recomputing the whole window layout. 00051 Inherited from View 00052 */ 00053 virtual bool CanBreakLayout() 00054 { 00055 return false; 00056 } 00057 00058 sigc::signal< void, TabView * > sigTabChanged; 00059 sigc::signal< void, int > sigTabIndexChanged; 00060 00061 00062 private: 00063 class TabElement 00064 { 00065 public: 00066 TabElement (NString TabName, Layout *TabLayout); 00067 ~TabElement(); 00068 00069 void SetIndex (int index); 00070 int GetIndex() const; 00071 void SetGeometry (const Geometry &geo); 00072 Geometry GetGeometry() const; 00073 const NString &GetName() const; 00074 00075 NString _tab_name; 00076 Layout *_tab_layout; 00077 InputArea *_tab_area; 00078 int _index; 00079 }; 00080 00081 public: 00082 void RecvTabMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags, TabElement *); 00083 void RecvTabMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags, TabElement *); 00084 00085 void RecvMouseEnter (int x, int y, unsigned long button_flags, unsigned long key_flags); 00086 void RecvMouseLeave (int x, int y, unsigned long button_flags, unsigned long key_flags); 00087 00088 private: 00089 00090 void RecvTabRightTimerExpired (void *v); 00091 void RecvTabLeftTimerExpired (void *v); 00092 void RecvTabRightMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00093 void RecvTabLeftMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00094 void RecvTabButtonMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00095 00096 virtual void PreLayoutManagement(); 00097 virtual long PostLayoutManagement (long LayoutResult); 00098 virtual void PositionChildLayout (float offsetX, float offsetY); 00099 00100 void TranslateLeft (int x, int y, unsigned long button_flags, unsigned long key_flags); 00101 void TranslateRight (int x, int y, unsigned long button_flags, unsigned long key_flags); 00102 void TranslateTabLayout (int offset); 00103 00104 InputArea *m_IncrTab; 00105 InputArea *m_DecrTab; 00106 00107 Layout *m_ClientLayout; 00108 HLayout *m_TabLayout; 00109 HLayout *m_TabControlLayout; 00110 00111 int m_TabPositionOffset; 00112 int m_FocusTabIndex; 00113 00114 TimerFunctor *tabright_callback; 00115 TimerFunctor *tableft_callback; 00116 TimerHandle m_TabRightTimerHandler; 00117 TimerHandle m_TabLeftTimerHandler; 00118 00119 std::vector<TabElement *> m_TabVector; 00120 00121 static Color TAB_HEADER_BACKGROUND_COLOR; 00122 static Color TAB_BACKGROUND_COLOR; 00123 static Color TAB_HEADER_COLOR; 00124 static Color TAB_HEADER_FOCUS_COLOR; 00125 00126 static int TAB_BUTTON_WIDTH; 00127 static int TAB_BUTTON_HEIGHT; 00128 static int TAB_HEIGHT; 00129 static int TAB_X_BORDER; 00130 static int TAB_Y_BORDER; 00131 00132 // We need to draw the background on the previous size of the Table if its 00133 // size is set to match the content(IsSizeMatchContent) and an item is close. 00134 Geometry m_PreviousGeometry; 00135 bool m_DrawBackgroundOnPreviousGeometry; 00136 }; 00137 } 00138 00139 #endif // TABVIEW_H