28 #ifndef _LCDGFX_CHECKBOX_MENU_H_ 29 #define _LCDGFX_CHECKBOX_MENU_H_ 37 #define lcd_gfx_min(x, y) ((x) < (y) ? (x) : (y)) 41 #define lcd_gfx_max(x, y) ((x) > (y) ? (x) : (y)) 87 template <
typename D>
void show(D &d);
166 template <
typename D> uint8_t getMaxScreenItems(D &d)
168 return (menu.
height - 16) / d.getFont().getHeader().height;
171 template <
typename D> uint8_t calculateScrollPosition(D &d, uint8_t selection)
177 else if ( selection - menu.
scrollPosition > getMaxScreenItems(d) - 1 )
179 return selection - getMaxScreenItems(d) + 1;
184 template <
typename D>
void drawMenuItem(D &d, uint8_t index)
191 lcduint_t fh = d.getFont().getHeader().height;
192 uint16_t color = d.getColor();
197 lcdint_t boxY = item_top + (fh - boxSize) / 2;
198 lcdint_t textX = boxX + boxSize + 3;
202 d.fillRect(textX + d.getFont().getTextSize(menu.
items[index]), item_top,
203 menu.
width + menu.
left - 9, item_top + fh - 1);
205 d.fillRect(menu.
left + 5, item_top, textX - 1, item_top + fh - 1);
209 if ( m_checked & (1u << index) )
211 d.fillRect(boxX, boxY, boxX + boxSize - 1, boxY + boxSize - 1);
215 d.drawRect(boxX, boxY, boxX + boxSize - 1, boxY + boxSize - 1);
219 d.printFixed(textX, item_top, menu.
items[index], STYLE_NORMAL);
227 template <
typename D>
void drawScrollIndicators(D &d, uint8_t maxItems)
229 uint16_t color = d.getColor();
233 lcdint_t itemsBot = itemsTop + maxItems * d.getFont().getHeader().height;
237 d.fillRect(5 + menu.
left, borderTop + 1, menu.
width + menu.
left - 6, itemsTop - 1);
241 d.drawHLine(cx, borderTop + 1, cx);
242 d.drawHLine(cx - 1, borderTop + 2, cx + 1);
243 d.drawHLine(cx - 2, borderTop + 3, cx + 2);
247 d.fillRect(5 + menu.
left, itemsBot, menu.
width + menu.
left - 6, borderBot - 1);
251 d.drawHLine(cx - 2, borderBot - 3, cx + 2);
252 d.drawHLine(cx - 1, borderBot - 2, cx + 1);
253 d.drawHLine(cx, borderBot - 1, cx);
257 lcdint_t sbH = itemsBot - itemsTop - 1;
268 d.fillRect(sbX, itemsTop, sbX + 1, itemsTop + sbH);
270 d.fillRect(sbX, thumbY, sbX + 1, thumbY + thumbH);
281 uint8_t maxItems = getMaxScreenItems(d);
284 this->drawMenuItem(d, i);
287 if ( menu.
count > maxItems )
289 this->drawScrollIndicators(d, maxItems);
uint8_t lcduint_t
internal int type, used by the library.
NanoRect structure describes rectangle area.
int8_t lcdint_t
internal int type, used by the library.
#define lcd_gfx_max(a, b)
Macros returning maximum of 2 numbers.
Basic structures of nano gfx library.
#define lcd_gfx_min(a, b)
Macros returning minimum of 2 numbers.