| 
									
										
										
										
											2012-01-06 12:12:57 +08:00
										 |  |  | // ASEPRITE gui library
 | 
					
						
							| 
									
										
										
										
											2013-01-27 23:13:13 +08:00
										 |  |  | // Copyright (C) 2001-2013  David Capello
 | 
					
						
							| 
									
										
										
										
											2010-09-28 06:18:17 +08:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2012-09-24 10:24:07 +08:00
										 |  |  | // This source file is distributed under a BSD-like license, please
 | 
					
						
							| 
									
										
										
										
											2010-09-28 06:18:17 +08:00
										 |  |  | // read LICENSE.txt for more information.
 | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-13 04:29:16 +08:00
										 |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-18 09:49:58 +08:00
										 |  |  | #include "ui/manager.h"
 | 
					
						
							|  |  |  | #include "ui/theme.h"
 | 
					
						
							|  |  |  | #include "ui/widget.h"
 | 
					
						
							| 
									
										
										
										
											2012-07-09 10:24:42 +08:00
										 |  |  | #include "ui/window.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  | #include <list>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-18 09:02:54 +08:00
										 |  |  | namespace ui { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  | static std::list<Widget*>* widgets; | 
					
						
							| 
									
										
										
										
											2009-08-05 09:53:02 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | int _ji_widgets_init() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   widgets = new std::list<Widget*>; | 
					
						
							| 
									
										
										
										
											2009-08-05 09:53:02 +08:00
										 |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void _ji_widgets_exit() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   delete widgets; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-31 00:38:24 +08:00
										 |  |  | void addWidget(Widget* widget) | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   widgets->push_back(widget); | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-31 00:38:24 +08:00
										 |  |  | void removeWidget(Widget* widget) | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   std::list<Widget*>::iterator it = | 
					
						
							|  |  |  |     std::find(widgets->begin(), widgets->end(), widget); | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   if (it != widgets->end()) | 
					
						
							|  |  |  |     widgets->erase(it); | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-31 00:38:24 +08:00
										 |  |  | void setFontOfAllWidgets(FONT* f) | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   for (std::list<Widget*>::iterator it=widgets->begin(), end=widgets->end(); | 
					
						
							|  |  |  |        it != end; ++it) { | 
					
						
							|  |  |  |     (*it)->setFont(f); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2010-03-09 10:43:28 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-31 00:38:24 +08:00
										 |  |  | void reinitThemeForAllWidgets() | 
					
						
							| 
									
										
										
										
											2010-03-09 10:43:28 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   // Reinitialize the theme of each widget
 | 
					
						
							|  |  |  |   for (std::list<Widget*>::iterator it=widgets->begin(), end=widgets->end(); | 
					
						
							|  |  |  |        it != end; ++it) { | 
					
						
							|  |  |  |       (*it)->setTheme(CurrentTheme::get()); | 
					
						
							|  |  |  |       (*it)->initTheme(); | 
					
						
							| 
									
										
										
										
											2010-03-09 10:43:28 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-09 10:43:28 +08:00
										 |  |  |   // Remap the windows
 | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   for (std::list<Widget*>::iterator it=widgets->begin(), end=widgets->end(); | 
					
						
							|  |  |  |        it != end; ++it) { | 
					
						
							| 
									
										
										
										
											2013-04-04 09:07:24 +08:00
										 |  |  |     if ((*it)->type == kWindowWidget) | 
					
						
							| 
									
										
										
										
											2013-01-11 23:43:25 +08:00
										 |  |  |       static_cast<Window*>(*it)->remapWindow(); | 
					
						
							| 
									
										
										
										
											2012-06-16 10:37:59 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-16 02:21:24 +08:00
										 |  |  |   // Redraw the whole screen
 | 
					
						
							| 
									
										
										
										
											2012-06-18 09:02:54 +08:00
										 |  |  |   Manager::getDefault()->invalidate(); | 
					
						
							| 
									
										
										
										
											2007-09-19 07:57:02 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-06-18 09:02:54 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } // namespace ui
 |