AWind
DefaultDecorators.h
1 #pragma once
2 /*
3  AWind.h - Arduino window library support for Color TFT LCD Boards
4  Copyright (C)2014 Andrei Degtiarev. All right reserved
5 
6  You can find the latest version of the library at
7  https://github.com/AndreiDegtiarev/AWind
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the CC BY-NC-SA 3.0 license.
11  Please see the included documents for further information.
12 
13  Commercial use of this library requires you to buy a license that
14  will allow commercial use. This includes using the library,
15  modified or not, as a tool to sell products.
16 
17  The license applies to all part of the library including the
18  examples and tools supplied with the library.
19 */
20 #include "DecoratorPrimitives.h"
23 {
24 public:
25  enum InitMode
26  {
27  all,
28  none
29  };
30  DefaultDecorators(InitMode mode=DefaultDecorators::none)
31  {
32  if(mode == DefaultDecorators::all)
33  DefaultDecorators::InitAll();
34  }
35  static void InitAll()
36  {
37  InitMainWindow();
38  InitButton();
39  InitDialog();
40  InitEditBox();
41  InitLabel();
42  InitGauge();
43  InitTabControl();
44  }
45  static void InitMainWindow()
46  {
47  DecoratorList *list=new DecoratorList();
48  list->Add(new DecoratorRectFill(Color::LightGray,false));
49  list->Add(new DecoratorColor(Color::Black));
50  Environment::Get()->RegisterDecoratorsGroup(F("Window"),list);
51  }
52  static void InitButton()
53  {
54  DecoratorList *list=new DecoratorList();
55  //list->Add(new DecoratorRectFill(Color::LightGray,false));
56  list->Add(new DecoratorRectGradientFill(Color::Gray,Color::WhiteSmoke));
57  list->Add(new Decorator3DRect(Color::White,Color::Black));
58  list->Add(new DecoratorColor(Color::Black));
59  Environment::Get()->RegisterDecoratorsGroup(F("Button"),list);
60  }
61  static void InitDialog()
62  {
63  DecoratorList *listDialog=new DecoratorList();
64  listDialog->Add(new DecoratorRectFill(Color::LightGray,false));
65  listDialog->Add(new Decorator3DRect(Color::White,Color::Gray));
66  listDialog->Add(new DecoratorColor(Color::Black));
67  Environment::Get()->RegisterDecoratorsGroup(F("Dialog"),listDialog);
68  DecoratorList *list=new DecoratorList();
69  list->Add(new DecoratorRectFill(Color::LightBlue,false));
70  list->Add(new DecoratorColor(Color::White));
71  Environment::Get()->RegisterDecoratorsGroup(F("DialogCaption"),list);
72  }
73  static void InitLabel()
74  {
75  Environment::Get()->RegisterDecoratorsGroup(F("Label"),Environment::Get()->FindDecorators(F("Window")));
76  }
77  static void InitEditBox()
78  {
79  DecoratorList *list=new DecoratorList();
80  list->Add(new DecoratorRectFill(Color::Black));
81  list->Add(new Decorator3DRect(Color::Gray,Color::White));
82  list->Add(new DecoratorColor(Color::White));
83  Environment::Get()->RegisterDecoratorsGroup(F("EditTextBox"),list);
84 
85  list=new DecoratorList();
86  list->Add(new DecoratorRectFill(Color::LightGray));
87  list->Add(new Decorator3DRect(Color::Gray,Color::White));
88  list->Add(new DecoratorColor(Color::Black));
89  Environment::Get()->RegisterDecoratorsGroup(F("EditTextBoxReadOnly"),list);
90 
91  }
92  static void InitGauge()
93  {
94  DecoratorList *list=new DecoratorList();
95  list->Add(new Decorator3DRect(Color::White,Color::Gray));
96  list->Add(new DecoratorColor(Color::Green));
97  Environment::Get()->RegisterDecoratorsGroup(F("Gauge"),list);
98  }
99  static void InitTabControl()
100  {
101  DecoratorList *list = new DecoratorList();
102  list->Add(new DecoratorRectFill(Color::LightGray, false));
103  list->Add(new DecoratorColor(Color::Gray));
104  list->Add(new DecoratorBoundaryLine(DecoratorBoundaryLine::Left));
105  list->Add(new DecoratorBoundaryLine(DecoratorBoundaryLine::Top));
106  list->Add(new DecoratorBoundaryLine(DecoratorBoundaryLine::Right));
107  list->Add(new DecoratorColor(Color::Black));
108  Environment::Get()->RegisterDecoratorsGroup(F("ActiveTabButton"), list);
109 
110  DecoratorList *list_ctrl = new DecoratorList();
111  list_ctrl->Add(new DecoratorRectFill(Color::LightGray, false));
112  list_ctrl->Add(new DecoratorColor(Color::Gray));
113  list_ctrl->Add(new DecoratorBoundaryLine(DecoratorBoundaryLine::Bottom));
114  Environment::Get()->RegisterDecoratorsGroup(F("BackTabButtons"), list_ctrl);
115 
116  DecoratorList *list_tab = new DecoratorList();
117  list_tab->Add(new DecoratorRectFill(Color::LightGray, false));
118  list_tab->Add(new Decorator3DRect(Color::Gray, Color::Gray));
119  //list_tab->Add(new DecoratorColor(Color::Gray));
120  //list_tab->Add(new DecoratorBoundaryLine(DecoratorBoundaryLine::Left));
121  Environment::Get()->RegisterDecoratorsGroup(F("TabControl"), list_tab);
122  }
123 };
static Environment * Get()
Returns singltone instance of environment.
Definition: Environment.h:44
Decorator primitive for boundary lines. Overriden members description see Decorator class documentati...
Definition: DecoratorPrimitives.h:42
void RegisterDecoratorsGroup(const __FlashStringHelper *id, DecoratorList *decorators)
Registers decorators group. It is like application resources that can be shred between windows of the...
Definition: Environment.h:51
This class initializes default apperance for window, buttons, edit box and other controls in AWind li...
Definition: DefaultDecorators.h:22
Decorator primitive for round rect filled area. Overriden members description see Decorator class doc...
Definition: DecoratorPrimitives.h:98
Decorator primitive for 3D rectangle. Overriden members description see Decorator class documentation...
Definition: DecoratorPrimitives.h:130
Decorator primitive that sets current color. Overriden members description see Decorator class docume...
Definition: DecoratorPrimitives.h:24
Decorator primitive for round rect filled area. Overriden members description see Decorator class doc...
Definition: DecoratorPrimitives.h:79