// Copyright (c) Sean Walton 1999-2006 All rights reserved // // Standard disclaimer: you use it --> you're responsible // Standard license: you can use it in any way, but keep // my copyright attached. #ifndef BBGRID_H #define BBGRID_H #include "Pager.h" #include "Ui32.h" #include "shared.h" #define DISPLAYWIDTH 160 #define MAXCOLUMNS 10 #define CELLHEIGHT (LcdGetFontHeight(0)) /////////////////////////////////////////////////////////////////////////////////////// /// BBGrid class BBGrid: public Field { public: typedef enum { eNone, eRow, eColumn, eCell } ESelectBy; public: BBGrid(ubyte Rows, ubyte Columns); virtual ~BBGrid(void) {} public: //---Forced overrides virtual FIELDTYPE GetFieldType( FIELDTYPE * pDerived = NULL ) { return (FIELDTYPE)101; } virtual void ResetDimensionDependentData() { RowHeight = CELLHEIGHT; } virtual int QueryLineHeight(int const MaximumRelevant) { return RowHeight; } public: virtual int GetHeight() const { return Rows*RowHeight; } virtual int GetHeight(int width) const { return Rows*RowHeight; } virtual int GetHeightMax() const { return Rows*RowHeight; } virtual int GetHeightMin() const { return Rows*RowHeight; } virtual int GetWidth() const { return Width; } virtual int GetWidth(int height) const { return Width; } virtual int GetWidthMax() const { return Width; } virtual int GetWidthMin() const { return Width; } virtual void Paint(Graphics& g); virtual void Redraw(void) { Field::Redraw(); } virtual void Redraw(int Row, int Col); virtual int OnScroll(int axis, int directionMagnitude); virtual XYRect GetFocusRect(void) const; public: virtual void NowDisplaying(ubyte row, ubyte col, Graphics& area)=0; virtual bool AllowSelect(ubyte row, ubyte col) { return true; } virtual void GetSelected(int& Row, int& Column) const; // virtual bool OnKey(int event, char character, int flags); public: ESelectBy GetSelectBy(void) { return SelectBy; } void SetSelectBy(ESelectBy selectby) { SelectBy = selectby; Selected = 0; } void SetSelected(int Row, int Column); void SetColumnWidth(ubyte column, unsigned short width, bool redraw=false); unsigned short GetColumnWidth(ubyte column) { return ColumnWidths[column]; } void SetRows(int Row); private: ubyte Rows, Columns; unsigned short RowHeight, ColumnWidths[MAXCOLUMNS], ColumnPlaces[MAXCOLUMNS]; unsigned int Width; signed short Selected; ESelectBy SelectBy; bool ColumnsChanged; }; #endif