xref: /haiku/src/apps/terminal/ThemeView.h (revision 106388ddbfdd00f4409c86bd3fe8d581bae532ec)
1 /*
2  * Copyright 2022, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef THEME_VIEW_H
6 #define THEME_VIEW_H
7 
8 
9 #include <Button.h>
10 #include <ColorControl.h>
11 #include <GroupView.h>
12 #include <ListItem.h>
13 #include <ListView.h>
14 #include <Menu.h>
15 #include <MenuBar.h>
16 #include <MenuField.h>
17 #include <MenuItem.h>
18 #include <Message.h>
19 #include <Messenger.h>
20 #include <ObjectList.h>
21 #include <ScrollBar.h>
22 #include <ScrollView.h>
23 #include <String.h>
24 #include <StringView.h>
25 #include <View.h>
26 
27 #include "Colors.h"
28 
29 
30 static const uint32 MSG_COLOR_SCHEME_CHANGED 	= 'mccs';
31 static const uint32 MSG_SET_CURRENT_COLOR	 	= 'sccl';
32 static const uint32 MSG_UPDATE_COLOR		 	= 'upcl';
33 static const uint32 MSG_COLOR_ATTRIBUTE_CHOSEN	= 'atch';
34 static const uint32 MSG_THEME_MODIFIED			= 'tmdf';
35 static const uint32 MSG_SET_COLOR = 'sclr';
36 
37 static const char* const kRGBColor = "RGBColor";
38 static const char* const kName = "name";
39 
40 class ThemeWindow;
41 class ColorPreview;
42 class BMenu;
43 class BMenuField;
44 class BPopUpMenu;
45 class BTextView;
46 
47 class ThemeView : public BGroupView {
48 public:
49 								ThemeView(const char *name,
50 									const BMessenger &messenger);
51 	virtual						~ThemeView();
52 
53 	virtual	void				AttachedToWindow();
54 	virtual void				WindowActivated(bool active);
55 	virtual	void				MessageReceived(BMessage *msg);
56 
57 			void				SetDefaults();
58 			void				Revert();
59 			void				UpdateMenu();
60 
61 private:
62 			void				_UpdateStyle();
63 			void				_ChangeColorScheme(color_scheme* scheme);
64 			void				_SetCurrentColorScheme();
65 			void				_SetCurrentColor(rgb_color color);
66 			void				_SetColor(const char* name, rgb_color color);
67 
68 			void				_MakeColorSchemeMenu();
69 			void				_MakeColorSchemeMenuItem(const color_scheme *item);
70 
71 private:
72 			BColorControl*		fPicker;
73 			BListView*			fAttrList;
74 			const char*			fName;
75 			BScrollView*		fScrollView;
76 			ColorPreview*		fColorPreview;
77 			BMenuField*			fColorSchemeField;
78 			BPopUpMenu*			fColorSchemeMenu;
79 			BTextView*			fPreview;
80 
81 			BMessage			fPrevColors;
82 			BMessage			fDefaultColors;
83 			BMessage			fCurrentColors;
84 
85 			BMessenger			fTerminalMessenger;
86 
87 public:
88 	static const char* 			kColorTable[];
89 };
90 
91 #endif	// THEME_VIEW_H
92