CheeseBoard
A library for use with the CheeseBoard Cheddar platform
GfxStringListBox.h
1 #pragma once
2 
3 #include <Arduino.h>
4 #include <stdint.h>
5 #include "GfxItem.h"
6 
9 class GfxStringListBox : public GfxItem {
10 public:
11  const static uint8_t MaxItems = 10;
12 
13 public:
14  GfxStringListBox(uint16_t width);
16 
22  int16_t add(const String s);
23 
30  bool remove(const uint8_t idx, bool compactAfter=true);
31 
36  void draw(uint16_t xOffset=0, uint16_t yOffset=0);
37  uint16_t width();
38  uint16_t height();
39 
45  int16_t find(const String s, uint8_t n=1);
46 
52  bool select(int16_t idx);
53 
56  int16_t selected();
57 
62  uint8_t scrollDown(uint8_t rows);
63 
68  uint8_t scrollUp(uint8_t rows);
69 
75  bool scrollTo(uint8_t idx);
76 
77 protected:
82  int16_t findGap(uint8_t startAt=0);
83 
88  int16_t findNext(uint8_t from=0);
89 
94  int16_t findPreceding(uint8_t from=MaxItems);
95 
98  // TODO: void sort();
99 
103  bool isCompacted();
104 
107  void compact();
108 
111  bool isOnScreen(uint8_t idx);
112 
115  uint8_t rowsFrom(uint8_t idx);
116 
117 
118 protected:
119  String *_items[MaxItems];
120  uint16_t _width;
121  uint16_t _lineHeight;
122  int16_t _selected;
123  uint8_t _screenLines;
124  uint8_t _screenStart;
125  // TODO: uint8_t _frameSize; uint8_t _frameStart;
126 
127 };
128 
uint8_t rowsFrom(uint8_t idx)
void compact()
Make used items contiguous (remove gaps)
int16_t findPreceding(uint8_t from=MaxItems)
Definition: GfxItem.h:5
int16_t add(const String s)
uint8_t scrollDown(uint8_t rows)
int16_t findGap(uint8_t startAt=0)
int16_t findNext(uint8_t from=0)
void draw(uint16_t xOffset=0, uint16_t yOffset=0)
bool isCompacted()
Sort the items contained in the list box using quicksort.
bool select(int16_t idx)
int16_t find(const String s, uint8_t n=1)
uint8_t scrollUp(uint8_t rows)
bool isOnScreen(uint8_t idx)
bool scrollTo(uint8_t idx)