UTWindowsMenuTask.h

Go to the documentation of this file.
00001 //==================================================================================================
00002 // Copyright (C) 2010  Brian Tietz    sdbtietz at yahoo dot com
00003 //
00004 // This program is free software; you can redistribute it and/or modify it under the terms of the
00005 // GNU General Public License as published by the Free Software Foundation, version 2.0 of the
00006 // License.
00007 //
00008 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
00009 // even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00010 // General Public License for more details.
00011 //
00012 // You should have received a copy of the GNU General Public License along with this program; if
00013 // not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00014 // 02110-1301, USA.
00015 //
00016 // For commercial software, the copyright holder (Brian Tietz, email sdbtietz at yahoo dot com)
00017 // reserves the right and is willing to waive the proprietary source code disclosure aspects of that
00018 // license as applied to the UT library in exchange for either substantial contributions to the
00019 // development of the UT library or other forms of compensation.  Any such waiver must be
00020 // established in writing between the copyright holder and the commercial entity obtaining such a
00021 // waiver.
00022 //==================================================================================================
00023 
00024 
00025 #ifndef _UT_WINDOWS_MENU_TASK_H_
00026 #define _UT_WINDOWS_MENU_TASK_H_
00027 
00028 
00029 //==================================================================================================
00030 //=== Project headers
00031 //==================================================================================================
00032 #include "UTMessage.h"
00033 #include "UTTask.h"
00034 #include "UTWindow.h"
00035 #include "UTGUIPoolAllocator.h"
00036 
00037 
00038 //==================================================================================================
00039 //=== Forward name declarations
00040 //==================================================================================================
00041 class Menu_t;
00042 
00043 
00044 // \cond DOXYGEN_DOCUMENT_NEVER
00045 
00046 
00047 //==================================================================================================
00048 //=== Constants
00049 //==================================================================================================
00050 const int c_approx_target_window_menu_size = 20;
00051 
00052 
00053 //==================================================================================================
00054 class ActivateWindowMessage_t
00055 //==================================================================================================
00056 : public Message_t
00057 {
00058     //----------------------------------------------------------------------------------------------
00059     public:
00060     //----------------------------------------------------------------------------------------------
00061     inline              ActivateWindowMessage_t(Window_t* window);
00062     inline Window_t*    Window() const;
00063 
00064     //----------------------------------------------------------------------------------------------
00065     private:
00066     //----------------------------------------------------------------------------------------------
00067     Window_t*           m_window;
00068 };
00069 
00070 
00071 //==================================================================================================
00072 class WindowListEntry_t
00073 //==================================================================================================
00074 : public LinkedListNode_t<WindowListEntry_t>
00075 {
00076     //----------------------------------------------------------------------------------------------
00077     public:
00078     //----------------------------------------------------------------------------------------------
00079     inline                                  WindowListEntry_t();
00080     inline                                  WindowListEntry_t(  Window_t* window,
00081                                                                 WindowListEntry_t* parent );
00082 
00083     inline WindowListEntry_t*               ListHead();
00084     WindowListEntry_t*                      AddParentsAndWindowUnlessExists(    Window_t* window,
00085                                                                                 int* total_count );
00086     void                                    TrimWindowsListSize(int* total_count);
00087     int                                     CountNodesIncludingSelf();
00088     void                                    AlphabeticalSortWindows();
00089     WindowListEntry_t*                      NextInFlatList();
00090     int                                     SubordinateDepth();
00091     inline Window_t*                        Window() const;
00092 
00093     inline void*                            operator new(size_t size);
00094     inline void                             operator delete(void* block);
00095 
00096     inline bool                             operator <(const WindowListEntry_t& other) const;
00097 
00098     //----------------------------------------------------------------------------------------------
00099     private:
00100     //----------------------------------------------------------------------------------------------
00101     Window_t*                               m_window;
00102     WindowListEntry_t*                      m_parent;
00103     OwnedLinkedList_t<WindowListEntry_t>    m_contents;
00104 
00105     friend class WindowsMenuTask_t;
00106 };
00107 
00108 
00109 //==================================================================================================
00110 class WindowsMenuTask_t
00111 //==================================================================================================
00112 : public Task_t
00113 {
00114     //----------------------------------------------------------------------------------------------
00115     public:
00116     //----------------------------------------------------------------------------------------------
00117                         WindowsMenuTask_t();
00118     void                SetWindowMenu(Menu_t* menu);
00119     void                UpdateWindowsMenu();
00120 
00121 
00122     static void         CreateWindowsMenuList(  WindowListEntry_t* root_entry,
00123                                                 out bool* more_windows_are_not_in_list );
00124     static void         CreateWindowsMenuList(WindowListEntry_t* root_entry);
00125     static void         AddWindowsInUseOrder( WindowListEntry_t* root_entry, int* total_count );
00126 
00127     //----------------------------------------------------------------------------------------------
00128     private:
00129     //----------------------------------------------------------------------------------------------
00130     Menu_t*             m_windows_menu;
00131     String_t            m_more_string;
00132 
00133     //----------------------------------------------------------------------------------------------
00134     private:
00135     //----------------------------------------------------------------------------------------------
00136     void CascadeWindowsReceived(const Message_t* message);
00137     MessageReceiver_t< WindowsMenuTask_t, Message_t > m_CascadeWindowsReceiver;
00138 
00139     void TileHorizontalReceived(const Message_t* message);
00140     MessageReceiver_t< WindowsMenuTask_t, Message_t > m_TileHorizontalReceiver;
00141 
00142     void TileVerticalReceived(const Message_t* message);
00143     MessageReceiver_t< WindowsMenuTask_t, Message_t > m_TileVerticalReceiver;
00144 
00145     void CloseAllWindowsReceived(const Message_t* message);
00146     MessageReceiver_t< WindowsMenuTask_t, Message_t > m_CloseAllWindowsReceiver;
00147 
00148     void ActivateWindowReceived(const ActivateWindowMessage_t* message);
00149     MessageReceiver_t< WindowsMenuTask_t, ActivateWindowMessage_t > m_ActivateWindowReceiver;
00150 
00151     void MoreWindowsListReceived(const Message_t* message);
00152     MessageReceiver_t< WindowsMenuTask_t, Message_t > m_MoreWindowsListReceiver;
00153 
00154     void DeferredWindowClosedReceived(const Message_t* message);
00155     MessageReceiver_t< WindowsMenuTask_t, Message_t > m_DeferredWindowClosedReceiver;
00156 
00157     friend class App_t;
00158 };
00159 
00160 
00161 
00162 
00163 //==================================================================================================
00164 //==================================================================================================
00165 //===
00166 //=== Inline function implementations: class ActivateWindowMessage_t
00167 //===
00168 //==================================================================================================
00169 //==================================================================================================
00170 inline
00171 ActivateWindowMessage_t::ActivateWindowMessage_t(Window_t* window)
00172 {
00173     m_window = window;
00174 }
00175 
00176 
00177 inline Window_t*
00178 ActivateWindowMessage_t::Window() const
00179 {
00180     return m_window;
00181 }
00182 
00183 
00184 
00185 
00186 //==================================================================================================
00187 //==================================================================================================
00188 //===
00189 //=== Inline function implementations: class WindowListEntry_t
00190 //===
00191 //==================================================================================================
00192 //==================================================================================================
00193 inline
00194 WindowListEntry_t::WindowListEntry_t()
00195 {
00196     m_window = NULL;
00197     m_parent = NULL;
00198 }
00199 
00200 
00201 inline
00202 WindowListEntry_t::WindowListEntry_t( Window_t* window, WindowListEntry_t* parent )
00203 {
00204     m_window = window;
00205     m_parent = parent;
00206 }
00207 
00208 
00209 inline WindowListEntry_t*
00210 WindowListEntry_t::ListHead()
00211 {
00212     return m_contents.Head();
00213 }
00214 
00215 
00216 inline Window_t*
00217 WindowListEntry_t::Window() const
00218 {
00219     return m_window;
00220 }
00221 
00222 
00223 inline void*
00224 WindowListEntry_t::operator new(size_t size)
00225 {
00226     return g_gui_pool_allocator.Allocate(size);
00227 }
00228 
00229 
00230 inline void
00231 WindowListEntry_t::operator delete(void* block)
00232 {
00233     g_gui_pool_allocator.Release(block);
00234 }
00235 
00236 
00237 inline bool
00238 WindowListEntry_t::operator <(const WindowListEntry_t& other) const
00239 {
00240     assert(m_window && other.m_window);
00241     return (m_window->Title().CompareIgnoreCase( other.m_window->Title() ) < 0);
00242 }
00243 
00244 
00245 // \endcond
00246 
00247 #endif // _UT_WINDOWS_MENU_TASK_H_
00248 

Generated on Tue Dec 14 22:35:05 2010 for UT library by  doxygen 1.6.1