A simple yet powerful library for controlling graphical displays. Multiple display controllers are supported using inheritance.

Dependents:   mbed_rifletool Hexi_Bubble_Game Hexi_Catch-the-dot_Game Hexi_Acceleromagnetic_Synth

NOTE: This library is in beta right now. As far as I know, everything here works, but there are many features that are lacking so far. Most notably containers, button handling, and display drivers other than the SSD1306.

Committer:
neilt6
Date:
Tue May 27 21:41:28 2014 +0000
Revision:
3:a8f72d4864e6
Parent:
1:f7003ec66a51
Syntax improvements

Who changed what in which revision?

UserRevisionLine numberNew contents of line
neilt6 0:b876cf091464 1 /* NeatGUI Library
neilt6 0:b876cf091464 2 * Copyright (c) 2013 Neil Thiessen
neilt6 0:b876cf091464 3 *
neilt6 0:b876cf091464 4 * Licensed under the Apache License, Version 2.0 (the "License");
neilt6 0:b876cf091464 5 * you may not use this file except in compliance with the License.
neilt6 0:b876cf091464 6 * You may obtain a copy of the License at
neilt6 0:b876cf091464 7 *
neilt6 0:b876cf091464 8 * http://www.apache.org/licenses/LICENSE-2.0
neilt6 0:b876cf091464 9 *
neilt6 0:b876cf091464 10 * Unless required by applicable law or agreed to in writing, software
neilt6 0:b876cf091464 11 * distributed under the License is distributed on an "AS IS" BASIS,
neilt6 0:b876cf091464 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
neilt6 0:b876cf091464 13 * See the License for the specific language governing permissions and
neilt6 0:b876cf091464 14 * limitations under the License.
neilt6 0:b876cf091464 15 */
neilt6 0:b876cf091464 16
neilt6 0:b876cf091464 17 #ifndef FONT_H
neilt6 0:b876cf091464 18 #define FONT_H
neilt6 0:b876cf091464 19
neilt6 0:b876cf091464 20 #include "mbed.h"
neilt6 0:b876cf091464 21 #include "BitmapImage.h"
neilt6 0:b876cf091464 22
neilt6 0:b876cf091464 23 /** Font class.
neilt6 0:b876cf091464 24 * Used to access font data in an external table.
neilt6 0:b876cf091464 25 */
neilt6 0:b876cf091464 26 class Font
neilt6 0:b876cf091464 27 {
neilt6 0:b876cf091464 28 public:
neilt6 0:b876cf091464 29 /** Create a white Font object
neilt6 0:b876cf091464 30 *
neilt6 0:b876cf091464 31 * @param table Pointer to the font table.
neilt6 0:b876cf091464 32 */
neilt6 1:f7003ec66a51 33 Font(const char* table);
neilt6 0:b876cf091464 34
neilt6 0:b876cf091464 35 /** Create a Font object with the specified color
neilt6 0:b876cf091464 36 *
neilt6 0:b876cf091464 37 * @param table Pointer to the font table.
neilt6 0:b876cf091464 38 * @param color Color for the font as a 32-bit ARGB value.
neilt6 0:b876cf091464 39 */
neilt6 1:f7003ec66a51 40 Font(const char* table, unsigned int color);
neilt6 0:b876cf091464 41
neilt6 0:b876cf091464 42 /** Get the glyph Image for the specified character
neilt6 0:b876cf091464 43 *
neilt6 0:b876cf091464 44 * @returns The character glyph Image.
neilt6 0:b876cf091464 45 */
neilt6 0:b876cf091464 46 BitmapImage glyph(char c);
neilt6 0:b876cf091464 47
neilt6 0:b876cf091464 48 /** Get the current Font color
neilt6 0:b876cf091464 49 *
neilt6 0:b876cf091464 50 * @returns The current Font color as a 32-bit ARGB value.
neilt6 0:b876cf091464 51 */
neilt6 1:f7003ec66a51 52 unsigned int color();
neilt6 0:b876cf091464 53
neilt6 0:b876cf091464 54 /** Set the Font color
neilt6 0:b876cf091464 55 *
neilt6 0:b876cf091464 56 * @param c The new Font color as a 32-bit ARGB value.
neilt6 0:b876cf091464 57 */
neilt6 0:b876cf091464 58 void color(unsigned int c);
neilt6 0:b876cf091464 59
neilt6 0:b876cf091464 60 /** Get the height of the Font glyphs
neilt6 0:b876cf091464 61 *
neilt6 0:b876cf091464 62 * @returns The height of the Font glyphs.
neilt6 0:b876cf091464 63 */
neilt6 1:f7003ec66a51 64 int height();
neilt6 0:b876cf091464 65
neilt6 0:b876cf091464 66 /** Measures the width of a string in pixels if drawn with this font
neilt6 0:b876cf091464 67 *
neilt6 0:b876cf091464 68 * @param str Pointer to the string to measure.
neilt6 0:b876cf091464 69 *
neilt6 0:b876cf091464 70 * @returns The width of the string in pixels.
neilt6 0:b876cf091464 71 */
neilt6 1:f7003ec66a51 72 int measureString(const char* str);
neilt6 0:b876cf091464 73
neilt6 0:b876cf091464 74 /** Measures the width of the next word in a string (separated by whitespace) in pixels if drawn with this font
neilt6 0:b876cf091464 75 *
neilt6 0:b876cf091464 76 * @param str Pointer to the string to measure.
neilt6 0:b876cf091464 77 *
neilt6 0:b876cf091464 78 * @returns The width of the next word in pixels.
neilt6 0:b876cf091464 79 */
neilt6 1:f7003ec66a51 80 int measureWord(const char* str);
neilt6 0:b876cf091464 81
neilt6 0:b876cf091464 82 protected:
neilt6 1:f7003ec66a51 83 const char* m_FontTable;
neilt6 0:b876cf091464 84 unsigned int m_Color;
neilt6 0:b876cf091464 85 };
neilt6 0:b876cf091464 86
neilt6 0:b876cf091464 87 #endif