9
0
Fork 0

Add a hex calculator example to NxWM

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4760 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2012-05-22 19:29:22 +00:00
parent 1c36227878
commit 19cd40fea5
13 changed files with 1478 additions and 9 deletions

View File

@ -140,3 +140,5 @@
when a new window is started. It should stay in a maximized state
so that it will re-appear with the window above it is closed or
minimized.
* NxWM::CHexCalculator: Add a hexadecimal/decimal calculator
example.

View File

@ -31,7 +31,7 @@ PROJECT_NAME = NXWidgets
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = "1.0"
PROJECT_NUMBER = "1.1"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
@ -574,7 +574,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = "../libnxwidgets"
INPUT = "../libnxwidgets" "../nxwm"
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is

View File

@ -47,6 +47,7 @@
#include "ctaskbar.hxx"
#include "cstartwindow.hxx"
#include "cnxconsole.hxx"
#include "chexcalculator.hxx"
#ifdef CONFIG_NXWM_TOUCHSCREEN
# include "ctouchscreen.hxx"
@ -540,6 +541,35 @@ static bool createNxConsole(void)
return true;
}
/////////////////////////////////////////////////////////////////////////////
// Name: createHexCalculator
/////////////////////////////////////////////////////////////////////////////
static bool createHexCalculator(void)
{
// Add the hex calculator application to the start window
printf("createHexCalculator: Creating the hex calculator application\n");
NxWM::CHexCalculatorFactory *calculator = new NxWM::CHexCalculatorFactory(g_nxwmtest.taskbar);
if (!calculator)
{
printf("createHexCalculator: ERROR: Failed to instantiate CHexCalculatorFactory\n");
return false;
}
showTestCaseMemory("createHexCalculator: After creating the hex calculator application");
printf("createHexCalculator: Adding the hex calculator application to the start window\n");
if (!g_nxwmtest.startwindow->addApplication(calculator))
{
printf("createHexCalculator: ERROR: Failed to add CNxConsoleFactory to the start window\n");
delete calculator;
return false;
}
showTestCaseMemory("createHexCalculator: After adding the hex calculator application");
return true;
}
/////////////////////////////////////////////////////////////////////////////
// Public Functions
/////////////////////////////////////////////////////////////////////////////
@ -645,6 +675,14 @@ int MAIN_NAME(int argc, char *argv[])
testCleanUpAndExit(EXIT_FAILURE);
}
// Create the hex calculator application and add it to the start window
if (!createHexCalculator())
{
printf(MAIN_STRING "ERROR: Failed to create the hex calculator application\n");
testCleanUpAndExit(EXIT_FAILURE);
}
// Call CTaskBar::startWindowManager to start the display with applications in place.
if (!startWindowManager())

View File

@ -47,4 +47,37 @@
* Some of the graphic objects supported by NXWidgets include labels,
* buttons, text boxes, button arrays, check boxes, cycle buttons, images,
* sliders, scrollable list boxes, progress bars, and more.
*
* \subsection NXWM\
*
* NxWM isthe tiny window manager based on NX and NxWidgets. NxWM is a true
* multiple window manager but only one window is displayed at a time. This
* simplification helps performance on LCD based products (in the same way
* that a tiled window manager helps) and also makes the best use of small
* displays. It is awkward from a human factors point-of-view trying to
* manage multiple windows on a small display.
*
* The window manager consists of a task bar with icons representing the
* running tasks. If you touch the task's icon, it comes to the top. Each
* window has a toolbar with (1) a title, (2) a minimize button, and (3) a
* stop application button using the standard icons for these things. User
* input via a touchscreen or mouse and keyboard is supported.
*
* There is always a start window that is available in the task bar. When
* you touch the start window icon, it brings up the start window containing
* icons representing all of the available applications. If you touch an
* icon in the start window, it will be started and added to the task bar.
*
* There is a base class that defines an add-on application and an interface
* that supports incorporation of new applications. The only application
* that is provided is NxConsole. This is an NSH session running in a window.
* You should be able to select the NX icon in the start menu and create as
* many NSH sessions in windows as you want. (keybard input still comes
* through serial).
*
* Note 1: NwWM requires NuttX-6.18 or above.
*
* Note 2: Many of the fundamental classes in NxWidgets derive from the Antony
* Dzeryn's "Woopsi" project: http://woopsi.org/ which also has a BSD style
* license. See the COPYING file for details.
*/

View File

@ -44,20 +44,31 @@ CSRCS =
# Window Manager
CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx cnxconsole.cxx
CXXSRCS += cstartwindow.cxx ctaskbar.cxx cwindowmessenger.cxx
CXXSRCS = capplicationwindow.cxx cfullscreenwindow.cxx ctaskbar.cxx cwindowmessenger.cxx
# Device support
ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
CXXSRCS += ccalibration.cxx ctouchscreen.cxx
CXXSRCS += ctouchscreen.cxx
endif
ifeq ($(CONFIG_NXWM_KEYBOARD),y)
CXXSRCS += ckeyboard.cxx
endif
# Applications
CXXSRCS = cstartwindow.cxx cnxconsole.cxx chexcalculator.cxx
ifeq ($(CONFIG_NXWM_TOUCHSCREEN),y)
CXXSRCS += ccalibration.cxx
endif
# Images
CXXSRCS += glyph_calibration.cxx glyph_cmd.cxx glyph_minimize.cxx glyph_nsh.cxx
CXXSRCS += glyph_play.cxx glyph_start.cxx glyph_stop.cxx
CXXSRCS += glyph_calculator.cxx glyph_calibration.cxx glyph_cmd.cxx
CXXSRCS += glyph_minimize.cxx glyph_nsh.cxx glyph_play.cxx glyph_start.cxx
CXXSRCS += glyph_stop.cxx
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

View File

@ -0,0 +1,276 @@
/****************************************************************************
* NxWidgets/nxwm/include/chexcalculator.hxx
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
* me be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_CHEXCALCULATOR_HXX
#define __INCLUDE_CHEXCALCULATOR_HXX
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/nx/nxtk.h>
#include <nuttx/nx/nxconsole.h>
#include "cbuttonarray.hxx"
#include "clabel.hxx"
#include "iapplication.hxx"
#include "capplicationwindow.hxx"
#include "ctaskbar.hxx"
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
#define NXWM_HEXCALCULATOR_NROWS 6
#define NXWM_HEXCALCULATOR_NCOLUMNS 6
/****************************************************************************
* Implementation Classes
****************************************************************************/
#if defined(__cplusplus)
namespace NxWM
{
/**
* This class implements the NxConsole application.
*/
class CHexCalculator : public IApplication,
private IApplicationCallback,
private NXWidgets::CWidgetEventHandler
{
private:
CTaskbar *m_taskbar; /**< Reference to the "parent" taskbar */
CApplicationWindow *m_window; /**< Reference to the application window */
NXWidgets::CButtonArray *m_keypad; /**< The calculator keyboard */
NXWidgets::CLabel *m_text; /**< The accumulator text display */
struct nxgl_size_s m_windowSize; /**< The size of the calculator window */
struct nxgl_size_s m_keypadSize; /**< The size the calculator keypad */
struct nxgl_size_s m_buttonSize; /**< The size of one calculator button */
struct nxgl_size_s m_textSize; /**< The size of the calculator textbox */
struct nxgl_point_s m_keypadPos; /**< The position the calculator keypad */
struct nxgl_point_s m_textPos; /**< The position of the calculator textbox */
uint64_t m_operand; /**< Previously entered operand */
uint64_t m_accum; /**< The current accumulated value */
uint64_t m_memory; /**< The current value in memory */
uint8_t m_pending; /**< The pending operation */
bool m_hexMode; /**< True if in hex mode */
/**
* Select the geometry of the calculator given the current window size.
* Only called as part of construction.
*/
inline void setGeometry(void);
/**
* Create the calculator keypad. Only start as part of the applicaiton
* start method.
*/
inline bool createCalculator(void);
/**
* Applies labels to the keys.
*/
void labelKeypad(void);
/**
* Show the current value of the accumulator.
*/
void updateText(void);
/**
* Called when the window minimize button is pressed.
*/
void minimize(void);
/**
* Called when the window minimize close is pressed.
*/
void close(void);
/**
* Handle a widget action event. For CImage, this is a button pre-
* release event.
*
* @param e The event data.
*/
void handleActionEvent(const NXWidgets::CWidgetEventArgs &e);
public:
/**
* CHexCalculator constructor
*
* @param window. The application window
*
* @param taskbar. A pointer to the parent task bar instance
* @param window. The window to be used by this application.
*/
CHexCalculator(CTaskbar *taskbar, CApplicationWindow *window);
/**
* CHexCalculator destructor
*/
~CHexCalculator(void);
/**
* Each implementation of IApplication must provide a method to recover
* the contained CApplicationWindow instance.
*/
IApplicationWindow *getWindow(void) const;
/**
* Get the icon associated with the application
*
* @return An instance if IBitmap that may be used to rend the
* application's icon. This is an new IBitmap instance that must
* be deleted by the caller when it is no long needed.
*/
NXWidgets::IBitmap *getIcon(void);
/**
* Get the name string associated with the application
*
* @return A copy if CNxString that contains the name of the application.
*/
NXWidgets::CNxString getName(void);
/**
* Start the application (perhaps in the minimized state).
*
* @return True if the application was successfully started.
*/
bool run(void);
/**
* Stop the application.
*/
void stop(void);
/**
* Destroy the application and free all of its resources. This method
* will initiate blocking of messages from the NX server. The server
* will flush the window message queue and reply with the blocked
* message. When the block message is received by CWindowMessenger,
* it will send the destroy message to the start window task which
* will, finally, safely delete the application.
*/
void destroy(void);
/**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
*/
void hide(void);
/**
* Redraw the entire window. The application has been maximized or
* otherwise moved to the top of the hierarchy. This method is call from
* CTaskbar when the application window must be displayed
*/
void redraw(void);
/**
* Report of this is a "normal" window or a full screen window. The
* primary purpose of this method is so that window manager will know
* whether or not it show draw the task bar.
*
* @return True if this is a full screen window.
*/
bool isFullScreen(void) const;
};
class CHexCalculatorFactory : public IApplicationFactory
{
private:
CTaskbar *m_taskbar; /**< The taskbar */
public:
/**
* CHexCalculatorFactory Constructor
*
* @param taskbar. The taskbar instance used to terminate calibration
*/
CHexCalculatorFactory(CTaskbar *taskbar);
/**
* CHexCalculatorFactory Destructor
*/
inline ~CHexCalculatorFactory(void) { }
/**
* Create a new instance of an CHexCalculator (as IApplication).
*/
IApplication *create(void);
/**
* Get the icon associated with the application
*
* @return An instance if IBitmap that may be used to rend the
* application's icon. This is an new IBitmap instance that must
* be deleted by the caller when it is no long needed.
*/
NXWidgets::IBitmap *getIcon(void);
};
}
#endif // __cplusplus
#endif // __INCLUDE_CHEXCALCULATOR_HXX

View File

@ -172,7 +172,8 @@ namespace NxWM
void removeAllApplications(void);
/**
* Handle a widget action event. For CImage, this is a mouse button pre-release event.
* Handle a widget action event. For CButtonArray, this is a mouse
* button pre-release event.
*
* @param e The event data.
*/

View File

@ -509,6 +509,24 @@
# define CONFIG_NXWM_CALIBRATION_LISTENERSTACK 2048
#endif
/* Hexcalculator applications ***********************************************/
/**
* Calibration display settings:
*
* CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR - The background color of the
* calculator display. Default: Same as CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
* CONFIG_NXWM_HEXCALCULATOR_ICON - The ICON to use for the hex calculator
* application. Default: NxWM::g_calculatorBitmap
*/
#ifndef CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR
# define CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR
#endif
#ifndef CONFIG_NXWM_HEXCALCULATOR_ICON
# define CONFIG_NXWM_HEXCALCULATOR_ICON NxWM::g_calculatorBitmap
#endif
/****************************************************************************
* Global Function Prototypes
****************************************************************************/

View File

@ -57,6 +57,7 @@
namespace NxWM
{
extern const struct NXWidgets::SRlePaletteBitmap g_calculatorBitmap;
extern const struct NXWidgets::SRlePaletteBitmap g_calibrationBitmap;
extern const struct NXWidgets::SRlePaletteBitmap g_cmdBitmap;
extern const struct NXWidgets::SRlePaletteBitmap g_minimizeBitmap;

View File

@ -536,7 +536,7 @@ void CCalibration::stateMachine(void)
// Fill the entire window with the background color
port->drawFilledRect(0, 0, windowSize.w, windowSize.h,
CONFIG_NXWM_DEFAULT_BACKGROUNDCOLOR);
CONFIG_NXWM_CALIBRATION_BACKGROUNDCOLOR);
// Then draw the first calibration screen

View File

@ -0,0 +1,898 @@
/********************************************************************************************
* NxWidgets/nxwm/src/chexcalculator.cxx
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
* me be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************************/
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include <cstdio>
#include <debug.h>
#include "cwidgetcontrol.hxx"
#include "nxwmconfig.hxx"
#include "nxwmglyphs.hxx"
#include "chexcalculator.hxx"
/********************************************************************************************
* Pre-Processor Definitions
********************************************************************************************/
/********************************************************************************************
* Private Types
********************************************************************************************/
/********************************************************************************************
* Private Data
********************************************************************************************/
namespace NxWM
{
/**
* This enumeration value describes a key
*/
enum EKeyType
{
KEY_NONE = 0, // Used to represent no pending operation
// Values: {0-9, A-F}
KEY_VALUE, // Key is a value
// Unary operators
KEY_NOT, // 1's complement
KEY_NEGATE, // 2's complement
// Binary operators
KEY_XOR, // Exclusive OR
KEY_DIVIDE, // Division
KEY_RSH, // Right shift
KEY_LSH, // Left shift
KEY_MULTIPLY, // Multiplication
KEY_AND, // Bit-wise AND
KEY_OR, // Bit-wise OR
KEY_MINUS, // Subtraction
KEY_PLUS, // Additions
// Special operations
KEY_EQUAL, // Equal/Enter key
KEY_DECIMAL, // Decimal mode
KEY_HEXADECIMAL, // Hexadecimal mode
KEY_MRECALL, // Recall from memory
KEY_MPLUS, // Add to memory
KEY_MMINUS, // Subtract from memory
KEY_MCLR, // Clear memory
KEY_CLRENTRY, // Clear entry
KEY_CLR // Clear all
};
/**
* This structure value describes a key
*/
struct SKeyDesc
{
uint16_t hexMode : 1; // Key applies in hex mode
uint16_t decMode : 1; // Key applies in decimal mode
uint16_t keyType : 5; // Describes the key (see enum EKeyType)
uint16_t value : 4; // Value (if the key has an associated value)
};
/**
* This array provides the possible labels for each key
*/
static FAR const char *g_labels[NXWM_HEXCALCULATOR_NCOLUMNS*NXWM_HEXCALCULATOR_NROWS] =
{
"MR", "M+", "M-", "MC", "CE", "C",
"A", "B", "C", "D", "E", "F",
"NOT", "XOR", "7", "8", "9", "/",
"RSH", "LSH", "4", "5", "6", "*",
"AND", "OR", "1", "2", "3", "-",
"DEC", "HEX", "+/-", "0", "=", "+"
};
/**
* This array manages the behavior when each key is pressed
*/
static struct SKeyDesc g_keyDesc[NXWM_HEXCALCULATOR_NCOLUMNS*NXWM_HEXCALCULATOR_NROWS] =
{
{1, 1, KEY_MRECALL, 0},
{1, 1, KEY_MPLUS, 0},
{1, 1, KEY_MMINUS, 0},
{1, 1, KEY_MCLR, 0},
{1, 1, KEY_CLRENTRY, 0},
{1, 1, KEY_CLR, 0},
{1, 0, KEY_VALUE, 10},
{1, 0, KEY_VALUE, 11},
{1, 0, KEY_VALUE, 12},
{1, 0, KEY_VALUE, 13},
{1, 0, KEY_VALUE, 14},
{1, 0, KEY_VALUE, 15},
{1, 0, KEY_NOT, 0},
{1, 0, KEY_XOR, 0},
{1, 1, KEY_VALUE, 7},
{1, 1, KEY_VALUE, 8},
{1, 1, KEY_VALUE, 9},
{1, 1, KEY_DIVIDE, 0},
{1, 0, KEY_RSH, 0},
{1, 0, KEY_LSH, 0},
{1, 1, KEY_VALUE, 4},
{1, 1, KEY_VALUE, 5},
{1, 1, KEY_VALUE, 6},
{1, 1, KEY_MULTIPLY, 0},
{1, 0, KEY_AND, 0},
{1, 0, KEY_OR, 0},
{1, 1, KEY_VALUE, 1},
{1, 1, KEY_VALUE, 2},
{1, 1, KEY_VALUE, 3},
{1, 1, KEY_MINUS, 0},
{1, 0, KEY_DECIMAL, 0},
{0, 1, KEY_HEXADECIMAL, 0},
{1, 1, KEY_NEGATE, 0},
{1, 1, KEY_VALUE, 0},
{1, 1, KEY_EQUAL, 0},
{1, 1, KEY_PLUS, 0}
};
}
/********************************************************************************************
* Private Functions
********************************************************************************************/
/********************************************************************************************
* CHexCalculator Method Implementations
********************************************************************************************/
using namespace NxWM;
/**
* CHexCalculator constructor
*
* @param window. The application window
*/
CHexCalculator::CHexCalculator(CTaskbar *taskbar, CApplicationWindow *window)
{
// Save the constructor data
m_taskbar = taskbar;
m_window = window;
// Nullify widgets that will be instantiated when the window is started
m_keypad = (NXWidgets::CButtonArray *)0;
m_text = (NXWidgets::CLabel *)0;
// Reset other values
m_operand = 0; // No previously entered operand
m_accum = 0; // The accumulator is initially zero
m_memory = 0; // No value in memory
m_pending = (uint8_t)KEY_NONE; // No pending operation */
m_hexMode = 0; // Decimal mode
// Add our personalized window label
NXWidgets::CNxString myName = getName();
window->setWindowLabel(myName);
// Add our callbacks with the application window
window->registerCallbacks(static_cast<IApplicationCallback *>(this));
// Set the geometry of the calculator
setGeometry();
}
/**
* CHexCalculator destructor
*
* @param window. The application window
*/
CHexCalculator::~CHexCalculator(void)
{
// Destroy widgets
if (m_text)
{
delete m_text;
}
if (m_keypad)
{
delete m_keypad;
}
// Although we didn't create it, we are responsible for deleting the
// application window
delete m_window;
}
/**
* Each implementation of IApplication must provide a method to recover
* the contained CApplicationWindow instance.
*/
IApplicationWindow *CHexCalculator::getWindow(void) const
{
return static_cast<IApplicationWindow*>(m_window);
}
/**
* Get the icon associated with the application
*
* @return An instance if IBitmap that may be used to rend the
* application's icon. This is an new IBitmap instance that must
* be deleted by the caller when it is no long needed.
*/
NXWidgets::IBitmap *CHexCalculator::getIcon(void)
{
NXWidgets::CRlePaletteBitmap *bitmap =
new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_HEXCALCULATOR_ICON);
return bitmap;
}
/**
* Get the name string associated with the application
*
* @return A copy if CNxString that contains the name of the application.
*/
NXWidgets::CNxString CHexCalculator::getName(void)
{
return NXWidgets::CNxString("Hex Calculator");
}
/**
* Start the application (perhaps in the minimized state).
*
* @return True if the application was successfully started.
*/
bool CHexCalculator::run(void)
{
// Create the widgets (if we have not already done so)
if (!m_keypad)
{
// Create the widgets
if (!createCalculator())
{
gdbg("ERROR: Failed to create widgets\n");
return false;
}
// Apply initial labels
labelKeypad();
}
return true;
}
/**
* Stop the application.
*/
void CHexCalculator::stop(void)
{
// Just disable further drawing
m_keypad->disableDrawing();
m_keypad->setRaisesEvents(false);
m_text->disableDrawing();
}
/**
* Destroy the application and free all of its resources. This method
* will initiate blocking of messages from the NX server. The server
* will flush the window message queue and reply with the blocked
* message. When the block message is received by CWindowMessenger,
* it will send the destroy message to the start window task which
* will, finally, safely delete the application.
*/
void CHexCalculator::destroy(void)
{
// Make sure that the widgets are stopped
stop();
// Block any further window messages
m_window->block(this);
}
/**
* The application window is hidden (either it is minimized or it is
* maximized, but not at the top of the hierarchy
*/
void CHexCalculator::hide(void)
{
// Disable drawing and events
stop();
}
/**
* Redraw the entire window. The application has been maximized or
* otherwise moved to the top of the hierarchy. This method is call from
* CTaskbar when the application window must be displayed
*/
void CHexCalculator::redraw(void)
{
// Get the widget control associated with the application window
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
// Get the CCGraphicsPort instance for this window
NXWidgets::CGraphicsPort *port = control->getGraphicsPort();
// Fill the entire window with the background color
port->drawFilledRect(0, 0, m_windowSize.w, m_windowSize.h,
CONFIG_NXWM_HEXCALCULATOR_BACKGROUNDCOLOR);
// Enable and redraw widgets
m_keypad->enableDrawing();
m_keypad->redraw();
m_keypad->setRaisesEvents(true);
m_text->enableDrawing();
m_text->redraw();
}
/**
* Report of this is a "normal" window or a full screen window. The
* primary purpose of this method is so that window manager will know
* whether or not it show draw the task bar.
*
* @return True if this is a full screen window.
*/
bool CHexCalculator::isFullScreen(void) const
{
return m_window->isFullScreen();
}
/**
* Select the geometry of the calculator given the current window size.
*/
void CHexCalculator::setGeometry(void)
{
// Recover the NXTK window instance contained in the application window
NXWidgets::INxWindow *window = m_window->getWindow();
// Get the size of the window
(void)window->getSize(&m_windowSize);
// Pick a height and width of a button to fill the entire window.
// For the height, we will assume that the text window is 1.5 times
// as high as a button
m_buttonSize.w = m_windowSize.w / NXWM_HEXCALCULATOR_NCOLUMNS;
m_buttonSize.h = (m_windowSize.h << 1) / (2 * NXWM_HEXCALCULATOR_NROWS + 3);
// Limit aspect ratio. (1) Button should no be taller than it is wide,
// (2) Button should be no more than twice as wide as it is tall.
if (m_buttonSize.h > m_buttonSize.w)
{
m_buttonSize.h = m_buttonSize.w;
}
else if (m_buttonSize.w > (m_buttonSize.h << 1))
{
m_buttonSize.w = (m_buttonSize.h << 1);
}
// Get the size of the entry calculator m_keypad
m_keypadSize.w = NXWM_HEXCALCULATOR_NCOLUMNS * m_buttonSize.w;
m_keypadSize.h = NXWM_HEXCALCULATOR_NROWS * m_buttonSize.h;
// Get the size of the text box. Same width as the m_keypad
m_textSize.w = m_keypadSize.w;
m_textSize.h = m_windowSize.h - NXWM_HEXCALCULATOR_NROWS * m_buttonSize.h;
// Limit the height of the text box to twice the height of a button.
if (m_textSize.h > (m_buttonSize.h << 1))
{
m_textSize.h = (m_buttonSize.h << 1);
}
// Pick an X/Y position such that the m_keypad+textbox will be centered
// in the display
struct nxgl_point_s calculatorPos;
calculatorPos.x = (m_windowSize.w - m_keypadSize.w) >> 1;
calculatorPos.y = (m_windowSize.h - m_textSize.h - m_keypadSize.h) >> 1;
// Now pick the set of the text box and the m_keypad
m_textPos.x = calculatorPos.x;
m_textPos.y = calculatorPos.y;
m_keypadPos.x = calculatorPos.x;
m_keypadPos.y = calculatorPos.y + m_textSize.h;
}
/**
* Create the calculator widgets. Only start as part of the applicaiton
* start method.
*/
bool CHexCalculator::createCalculator(void)
{
// Get the widget control associated with the application window
NXWidgets::CWidgetControl *control = m_window->getWidgetControl();
// Create the button array
m_keypad = new NXWidgets::CButtonArray(control,
m_keypadPos.x, m_keypadPos.y,
NXWM_HEXCALCULATOR_NCOLUMNS,
NXWM_HEXCALCULATOR_NROWS,
m_buttonSize.w, m_buttonSize.h);
if (!m_keypad)
{
gdbg("ERROR: Failed to create CButtonArray\n");
return false;
}
// Disable drawing and events until we are asked to redraw the window
m_keypad->disableDrawing();
m_keypad->setRaisesEvents(false);
// Register to receive events from the keypad
m_keypad->addWidgetEventHandler(this);
// Create a label to show the accumulator. A simple label is used
// because the power of a text box is un-necessary in this application.
m_text = new NXWidgets::CLabel(control,
m_textPos.x, m_textPos.y,
m_textSize.w, m_textSize.h,
"0");
if (!m_text)
{
gdbg("ERROR: Failed to create CLabel\n");
return false;
}
// Align text on the left
m_text->setTextAlignmentHoriz(NXWidgets::CLabel::TEXT_ALIGNMENT_HORIZ_RIGHT);
// Disable drawing and events until we are asked to redraw the window
m_text->disableDrawing();
m_text->setRaisesEvents(false);
return true;
}
/**
* Applies labels to the keys.
*/
void CHexCalculator::labelKeypad(void)
{
// Make sure that drawing is disabled from this operation
bool isEnabled = m_keypad->isDrawingEnabled();
m_keypad->disableDrawing();
// Add the labels to each button.
for (int j = 0; j < NXWM_HEXCALCULATOR_NROWS; j++)
{
for (int i = 0; i < NXWM_HEXCALCULATOR_NCOLUMNS; i++)
{
int index = j * NXWM_HEXCALCULATOR_NCOLUMNS + i;
// What mode are we in? Does the button label appear in this mode?
FAR const char *label;
if ((m_hexMode && g_keyDesc[index].hexMode) ||
(!m_hexMode && g_keyDesc[index].decMode))
{
label = g_labels[index];
}
else
{
label = "";
}
// Set the text in the label
m_keypad->setText(i, j, label);
}
}
// Then redraw the display
if (isEnabled)
{
m_keypad->enableDrawing();
m_keypad->redraw();
}
}
/**
* Show the current value of the accumulator.
*/
void CHexCalculator::updateText(void)
{
char buffer[24];
if (m_hexMode)
{
snprintf(buffer, 24, "%16lx", m_accum);
}
else
{
snprintf(buffer, 24, "%ld", m_accum);
}
// setText will perform the redraw as well
m_text->setText(buffer);
}
/**
* Called when the window minimize button is pressed.
*/
void CHexCalculator::minimize(void)
{
m_taskbar->minimizeApplication(static_cast<IApplication*>(this));
}
/**
* Called when the window close button is pressed.
*/
void CHexCalculator::close(void)
{
m_taskbar->stopApplication(static_cast<IApplication*>(this));
}
/**
* Handle a widget action event. For CButtonArray, this is a button pre-
* release event.
*
* @param e The event data.
*/
void CHexCalculator::handleActionEvent(const NXWidgets::CWidgetEventArgs &e)
{
// A button should now be clicked
int column;
int row;
if (m_keypad->isButtonClicked(column, row))
{
// Handle the key according to its type
int index = row * NXWM_HEXCALCULATOR_NCOLUMNS + column;
// First, make sure that the keypress is valid in this mode
if ((m_hexMode && !g_keyDesc[index].hexMode) ||
(!m_hexMode && !g_keyDesc[index].decMode))
{
// Ignore the key in this mode
return;
}
// Process the keypress
switch (g_keyDesc[index].keyType)
{
// Values: {0-9, A-F}
case KEY_VALUE: // Key is a value
{
m_accum <<= 4;
m_accum |= (uint64_t)g_keyDesc[index].value;
updateText();
}
break;
// Unary operators
case KEY_NOT: // 1's complement
{
m_accum = ~m_accum;
updateText();
}
break;
case KEY_NEGATE: // 2's complement
{
m_accum = -m_accum;
updateText();
}
break;
// Binary operators
case KEY_XOR: // Exclusive OR
case KEY_DIVIDE: // Division
case KEY_RSH: // Right shift
case KEY_LSH: // Left shift
case KEY_MULTIPLY: // Multiplication
case KEY_AND: // Bit-wise AND
case KEY_OR: // Bit-wise OR
case KEY_MINUS: // Subtraction
case KEY_PLUS: // Additions
{
m_operand = m_accum;
m_accum = 0;
m_pending = g_keyDesc[index].keyType;
updateText();
}
break;
// Special operations
case KEY_EQUAL: // Equal/Enter key
{
switch (m_pending)
{
case KEY_NONE: // Do nothing if there is no pending operation
return;
case KEY_XOR: // Exclusive OR
m_accum ^= m_operand;
break;
case KEY_DIVIDE: // Division
m_accum = m_operand / m_accum;
break;
case KEY_RSH: // Right shift
m_accum = m_operand >> m_accum;
break;
case KEY_LSH: // Left shift
m_accum = m_operand << m_accum;
break;
case KEY_MULTIPLY: // Multiplication
m_accum *= m_operand;
break;
case KEY_AND: // Bit-wise AND
m_accum &= m_operand;
break;
case KEY_OR: // Bit-wise OR
m_accum |= m_operand;
break;
case KEY_MINUS: // Subtraction
m_accum = m_operand - m_accum;
break;
case KEY_PLUS: // Additions
m_accum += m_operand;
break;
default:
gdbg("ERROR: Unexpected pending operation %d\n", m_pending);
m_pending = KEY_NONE;
return;
}
m_operand = 0;
m_pending = KEY_NONE;
updateText();
}
break;
case KEY_DECIMAL: // Decimal mode
{
if (m_hexMode)
{
m_hexMode = false;
labelKeypad();
m_keypad->redraw();
}
}
break;
case KEY_HEXADECIMAL: // Hexadecimal mode
{
if (!m_hexMode)
{
m_hexMode = true;
labelKeypad();
m_keypad->redraw();
}
}
break;
case KEY_MRECALL: // Recall from memory
{
m_accum = m_memory;
updateText();
}
break;
case KEY_MPLUS: // Add to memory
{
m_memory += m_accum;
}
break;
case KEY_MMINUS: // Subtract from memory
{
m_memory -= m_accum;
}
break;
case KEY_MCLR: // Clear memory
{
m_memory = 0;
}
break;
case KEY_CLRENTRY: // Clear entry
{
m_accum = 0;
updateText();
}
break;
case KEY_CLR: // Clear all
{
m_accum = 0;
m_operand = 0;
m_pending = KEY_NONE;
updateText();
}
break;
case KEY_NONE:
default:
gdbg("ERROR: Invalid key type %d\n", g_keyDesc[index].keyType);
break;
}
}
}
/**
* CHexCalculatorFactory Constructor
*
* @param taskbar. The taskbar instance used to terminate the console
*/
CHexCalculatorFactory::CHexCalculatorFactory(CTaskbar *taskbar)
{
m_taskbar = taskbar;
}
/**
* Create a new instance of an CHexCalculator (as IApplication).
*/
IApplication *CHexCalculatorFactory::create(void)
{
// Call CTaskBar::openFullScreenWindow to create a application window for
// the NxConsole application
CApplicationWindow *window = m_taskbar->openApplicationWindow();
if (!window)
{
gdbg("ERROR: Failed to create CApplicationWindow\n");
return (IApplication *)0;
}
// Open the window (it is hot in here)
if (!window->open())
{
gdbg("ERROR: Failed to open CApplicationWindow\n");
delete window;
return (IApplication *)0;
}
// Instantiate the application, providing the window to the application's
// constructor
CHexCalculator *hexCalculator = new CHexCalculator(m_taskbar, window);
if (!hexCalculator)
{
gdbg("ERROR: Failed to instantiate CHexCalculator\n");
delete window;
return (IApplication *)0;
}
return static_cast<IApplication*>(hexCalculator);
}
/**
* Get the icon associated with the application
*
* @return An instance if IBitmap that may be used to rend the
* application's icon. This is an new IBitmap instance that must
* be deleted by the caller when it is no long needed.
*/
NXWidgets::IBitmap *CHexCalculatorFactory::getIcon(void)
{
NXWidgets::CRlePaletteBitmap *bitmap =
new NXWidgets::CRlePaletteBitmap(&CONFIG_NXWM_HEXCALCULATOR_ICON);
return bitmap;
}

View File

@ -0,0 +1,191 @@
/********************************************************************************************
* NxWidgets/nxwm/src/glyph_calculator.cxx
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX, NxWidgets, nor the names of its contributors
* me be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
********************************************************************************************/
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <nuttx/nx/nxglib.h>
#include <nuttx/fb.h>
#include <nuttx/rgbcolors.h>
#include "crlepalettebitmap.hxx"
#include "nxwmconfig.hxx"
#include "nxwmglyphs.hxx"
/********************************************************************************************
* Pre-Processor Definitions
********************************************************************************************/
#define BITMAP_NROWS 25
#define BITMAP_NCOLUMNS 24
#define BITMAP_NLUTCODES 8
/********************************************************************************************
* Private Bitmap Data
********************************************************************************************/
using namespace NxWM;
/* RGB24 (8-8-8) Colors */
#if CONFIG_NXWIDGETS_BPP == 24 || CONFIG_NXWIDGETS_BPP == 32
static const uint32_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
{
0xfcfcfc, 0xb8bcbc, 0xf8f8f8, 0x6890c8, 0x384c80, 0xe8e8e8, 0x646464, 0x909090 /* Codes 0-7 */
};
static const uint32_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
{
0xffffff, 0xc9cccc, 0xf9f9f9, 0x8dabd5, 0x69789f, 0xededed, 0x8a8a8a, 0xababab /* Codes 0-7 */
};
/* RGB16 (565) Colors (four of the colors in this map are duplicates) */
#elif CONFIG_NXWIDGETS_BPP == 16
static const uint16_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
{
0xffff, 0xbdf7, 0xffdf, 0x6c99, 0x3a70, 0xef5d, 0x632c, 0x9492 /* Codes 0-7 */
};
static const uint16_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
{
0xffff, 0xce79, 0xffdf, 0x8d5a, 0x6bd3, 0xef7d, 0x8c51, 0xad55 /* Codes 0-7 */
};
/* 8-bit color lookups. NOTE: This is really dumb! The lookup index is 8-bits and it used
* to lookup an 8-bit value. There is no savings in that! It would be better to just put
* the 8-bit color/greyscale value in the run-length encoded image and save the cost of these
* pointless lookups. But these p;ointless lookups do make the logic compatible with the
* 16- and 24-bit types.
*/
#elif CONFIG_NXWIDGETS_BPP == 8
# ifdef CONFIG_NXWIDGETS_GREYSCALE
static const uint8_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
{
0xfc, 0xba, 0xf8, 0x8a, 0x4b, 0xe8, 0x64, 0x90 /* Codes 0-7 */
};
static const uint8_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
{
0xff, 0xcb, 0xf9, 0xa6, 0x77, 0xed, 0x8a, 0xab /* Codes 0-7 */
};
# else /* CONFIG_NXWIDGETS_GREYSCALE */
static const nxgl_mxpixel_t g_calculatorNormalLut[BITMAP_NLUTCODES] =
{
0xff, 0xb7, 0xff, 0x73, 0x2a, 0xff, 0x6d, 0x92 /* Codes 0-7 */
};
static const nxgl_mxpixel_t g_calculatorBrightlLut[BITMAP_NLUTCODES] =
{
0xff, 0xdb, 0xff, 0x97, 0x6e, 0xff, 0x92, 0xb6 /* Codes 0-7 */
};
# endif /* CONFIG_NXWIDGETS_GREYSCALE */
#else
# error "Unsupport pixel format"
#endif
static const struct NXWidgets::SRlePaletteBitmapEntry g_calculatorRleEntries[] =
{
{ 23, 0}, { 1, 1}, /* Row 0 */
{ 1, 0}, { 21, 1}, { 1, 2}, { 1, 1}, /* Row 1 */
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 2 */
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 3 */
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 4 */
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 5 */
{ 1, 0}, { 1, 1}, { 19, 3}, { 1, 4}, { 1, 0}, { 1, 1}, /* Row 6 */
{ 1, 2}, { 1, 1}, { 20, 4}, { 1, 0}, { 1, 1}, /* Row 7 */
{ 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 8 */
{ 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 9 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 10 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 11 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 12 */
{ 1, 0}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 13 */
{ 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 14 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 15 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 16 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 0}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 17 */
{ 1, 2}, { 1, 1}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, { 4, 5}, { 1, 6}, /* Row 18 */
{ 4, 5}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 19 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 20 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 2}, { 1, 1}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, /* Row 21 */
{ 1, 5}, { 3, 7}, { 1, 6}, { 1, 5}, { 3, 7}, { 1, 6}, { 1, 0}, { 1, 1},
{ 1, 2}, { 1, 1}, { 20, 6}, { 1, 0}, { 1, 1}, /* Row 22 */
{ 23, 0}, { 1, 1}, /* Row 23 */
{ 24, 1} /* Row 24 */
};
/********************************************************************************************
* Public Bitmap Structure Defintions
********************************************************************************************/
const struct NXWidgets::SRlePaletteBitmap NxWM::g_calculatorBitmap =
{
CONFIG_NXWIDGETS_BPP, // bpp - Bits per pixel
CONFIG_NXWIDGETS_FMT, // fmt - Color format
BITMAP_NLUTCODES, // nlut - Number of colors in the lLook-Up Table (LUT)
BITMAP_NCOLUMNS, // width - Width in pixels
BITMAP_NROWS, // height - Height in rows
{ // lut - Pointer to the beginning of the Look-Up Table (LUT)
g_calculatorNormalLut, // Index 0: Unselected LUT
g_calculatorBrightlLut, // Index 1: Selected LUT
},
g_calculatorRleEntries // data - Pointer to the beginning of the RLE data
};