1 // Options dialog
2 #ifndef OPTIONS_DLG_H_INCLUDED
3 #define OPTIONS_DLG_H_INCLUDED
4 
5 
6 #include <wx/treebook.h>
7 
8 
9 enum {
10     ID_OPTIONS_TREEBOOK,
11     ID_OPTIONS_WINDOW,
12     ID_OPTIONS_WINDOW_MENU,
13     ID_OPTIONS_WINDOW_STATUSBAR,
14     ID_OPTIONS_WINDOW_TOOLBAR,
15     ID_OPTIONS_PAGE_TITLE,
16 };
17 
18 #define PROP_CRENGINE_FONT_SIZE     "crengine.font.size"
19 #define PROP_WINDOW_RECT            "window.rect"
20 #define PROP_WINDOW_FULLSCREEN      "window.fullscreen"
21 #define PROP_WINDOW_MINIMIZED       "window.minimized"
22 #define PROP_WINDOW_MAXIMIZED       "window.maximized"
23 #define PROP_WINDOW_SHOW_MENU       "window.menu.show"
24 #define PROP_WINDOW_ROTATE_ANGLE    "window.rotate.angle"
25 #define PROP_WINDOW_TOOLBAR_SIZE    "window.toolbar.size"
26 #define PROP_WINDOW_TOOLBAR_POSITION "window.toolbar.position"
27 #define PROP_WINDOW_SHOW_STATUSBAR  "window.statusbar.show"
28 
29 #define PROP_PAGE_HEADER_ENABLED     "page.header.enabled"
30 #define PROP_PAGE_HEADER_PAGE_NUMBER "page.header.pagenumber"
31 #define PROP_PAGE_HEADER_PAGE_COUNT  "page.header.pagecount"
32 #define PROP_PAGE_HEADER_CLOCK       "page.header.clock"
33 #define PROP_PAGE_HEADER_BATTERY     "page.header.battery"
34 #define PROP_PAGE_HEADER_AUTHOR      "page.header.author"
35 #define PROP_PAGE_HEADER_TITLE       "page.header.title"
36 
37 //#define PROP_PAGE_VIEW_MODE          "page.view.mode"
38 #define PROP_FONT_ANTIALIASING       "font.antialiasing.mode"
39 #define PROP_FONT_COLOR              "font.color.default"
40 #define PROP_BACKGROUND_COLOR        "background.color.default"
41 #define PROP_FONT_FACE               "font.face.default"
42 
43 #define PROP_APP_OPEN_LAST_BOOK      "app.init.open-recent"
44 
45 class PropOption {
46 protected:
47     const char * _option;
48     wxWindow * _control;
49 public:
PropOption(wxWindow * control,const char * option)50     PropOption( wxWindow * control, const char * option )
51     : _option(option), _control(control) { }
~PropOption()52     virtual ~PropOption() { }
53     virtual void ControlToOption( CRPropRef props ) = 0;
54     virtual void OptionToControl( CRPropRef props ) = 0;
getActionId()55     virtual int getActionId() { return 0; }
onAction()56     virtual void onAction() { }
57 };
58 
59 class OptPanel : public wxPanel {
60 protected:
61     wxStaticBoxSizer * _sizer;
62     LVPtrVector<PropOption> _opts;
63     wxWindow * AddControl(wxWindow * control);
64     wxCheckBox * AddCheckbox(const char * option, wxString caption, bool defValue );
65     wxComboBox * AddCombobox(const char * option, wxString caption, const wxArrayString & options, int defValue, bool storeValues = false );
66     wxComboBox * AddFontFaceCombobox( const char * option, wxString caption );
67     wxPanel * AddColor( const char * option, wxString caption, lvColor defValue, int buttonId );
68     void OnButtonClicked( wxCommandEvent & event );
69 public:
70     OptPanel();
71     void Create( wxWindow * parent, wxWindowID id, wxString title );
72     virtual void CreateControls() = 0;
PropsToControls(CRPropRef props)73     virtual void PropsToControls( CRPropRef props )
74     {
75         for ( int i=0; i<_opts.length(); i++ ) {
76             _opts.get(i)->OptionToControl( props );
77         }
78     }
ControlsToProps(CRPropRef props)79     virtual void ControlsToProps( CRPropRef props )
80     {
81         for ( int i=0; i<_opts.length(); i++ ) {
82             _opts.get(i)->ControlToOption( props );
83         }
84     }
85 protected:
86     DECLARE_EVENT_TABLE()
87 };
88 
89 class CR3OptionsDialog : public wxDialog
90 {
91 private:
92     wxTreebook * _notebook;
93     OptPanel * _opt_window;
94     OptPanel * _opt_page;
95     OptPanel * _opt_view;
96     OptPanel * _opt_app;
97     CRPropRef _props;
98     CRPropRef _oldprops;
99 public:
getNewProps()100     CRPropRef getNewProps() { return _props; }
getOldProps()101     CRPropRef getOldProps() { return _oldprops; }
getChangedProps()102     CRPropRef getChangedProps() { return _oldprops ^ _props; }
103     virtual void PropsToControls();
104     virtual void ControlsToProps();
105     CR3OptionsDialog( CRPropRef props );
106     virtual ~CR3OptionsDialog();
107     bool Create( wxWindow* parent, wxWindowID id );
108 };
109 
110 #define OPTION_DIALOG_BUTTON_START 2000
111 #define OPTION_DIALOG_BUTTON_END   2099
112 
113 
114 #endif// OPTIONS_DLG_H_INCLUDED
115