tcMenu
RuntimeTitleMenuItem.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry).
3  * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4  */
5 
11 #ifndef TCMENU_RUNTIMETITLEMENUITEM_H
12 #define TCMENU_RUNTIMETITLEMENUITEM_H
13 
14 #include <BaseRenderers.h>
15 
16 namespace tcgfx {
17 
26  int appTitleRenderingFn(RuntimeMenuItem *item, uint8_t, RenderFnMode mode, char *buffer, int bufferSize);
27 
34  private:
35  const char *titleHeaderPgm;
36  const char *titleOverridePgm;
37  MenuCallbackFn callback;
38  public:
46  appTitleRenderingFn, 0, 1, next) {
47  titleHeaderPgm = nullptr;
48  titleOverridePgm = nullptr;
49  callback = nullptr;
50  }
51 
57  void setTitleHeaderPgm(const char *header) {
58  titleHeaderPgm = header;
59  setChanged(true);
60  }
61 
66  void setTitleOverridePgm(const char* overrideTitle) {
67  titleOverridePgm = overrideTitle;
68  setChanged(true);
69  }
70 
75  titleOverridePgm = nullptr;
76  setChanged(true);
77  }
78 
79  const char *getTitleHeaderPgm() const {
80  return (titleOverridePgm != nullptr) ? titleOverridePgm : titleHeaderPgm;
81  }
82 
83  void setCallback(MenuCallbackFn titleCb) {
84  callback = titleCb;
85  }
86 
87  MenuCallbackFn getCallback() const {
88  return callback;
89  }
90  };
91 
95  extern RuntimeTitleMenuItem appTitleMenuItem;
96 
102  appTitleMenuItem.setCallback(cb);
103  }
104 }
105 
106 #endif //TCMENU_RUNTIMETITLEMENUITEM_H
The base definitions and classes shared by all TcMenu renderers.
RenderFnMode
Definition: MenuItems.h:283
void(* MenuCallbackFn)(int id)
Definition: MenuItems.h:45
@ MENUTYPE_TITLE_ITEM
Definition: MenuItems.h:262
void setTitlePressedCallback(MenuCallbackFn cb)
Definition: RuntimeTitleMenuItem.h:101
Definition: MenuItems.h:329
void setChanged(bool changed)
Definition: MenuItems.cpp:112
Definition: RuntimeMenuItem.h:75
Definition: RuntimeTitleMenuItem.h:33
void clearTitleOverride()
Definition: RuntimeTitleMenuItem.h:74
void setTitleHeaderPgm(const char *header)
Definition: RuntimeTitleMenuItem.h:57
RuntimeTitleMenuItem(uint16_t id, MenuItem *next)
Definition: RuntimeTitleMenuItem.h:45
void setTitleOverridePgm(const char *overrideTitle)
Definition: RuntimeTitleMenuItem.h:66