A basic graphics package for the LPC4088 Display Module.

Dependents:   lpc4088_displaymodule_demo_sphere sampleGUI sampleEmptyGUI lpc4088_displaymodule_fs_aid ... more

Fork of DMBasicGUI by EmbeddedArtists AB

Application/AppLauncher.h

Committer:
embeddedartists
Date:
2019-11-04
Revision:
22:f0d00f29bfeb
Parent:
14:647b1896ed84

File content as of revision 22:f0d00f29bfeb:

/*
 *  Copyright 2014 Embedded Artists AB
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
 
#ifndef APP_LAUNCHER_H
#define APP_LAUNCHER_H

#include "App.h"
#include "DMBoard.h"
#include "lpc_swim.h"
#include "Clickable.h"

/**
 * An App example using a number of buttons to launch different Apps.
 *
 * The purpose of this example is to demonstrate how to manage a set of
 * Apps and launch them either as a result of clicked buttons or (in the 
 * case of the TouchCalibrationApp) after an extended press of the USER
 * button on the back of the display module.
 */
class AppLauncher : public App {
public:

	AppLauncher();
	virtual ~AppLauncher();

    enum CommonApplicationIDs {
        CalibrationApp = 0xffff,
    };

    virtual bool setup();
    virtual void runToCompletion();
    virtual bool teardown();

    void setAppCreatorFunc(App*(*callback)(uint32_t buttonID));

    bool addButton(uint32_t buttonID, const char* caption);
    bool addImageButton(uint32_t buttonID, const char* imgUp, const char* imgDown = 0);
    bool addImageButton(uint32_t buttonID, const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown = 0, unsigned int imgDownSize = 0);
    bool addImageButton(uint32_t buttonID, const char* caption, COLOR_T color, const char* imgUp, const char* imgDown = 0);
    bool addImageButton(uint32_t buttonID, const char* caption, COLOR_T color, const unsigned char* imgUp, unsigned int imgUpSize, const unsigned char* imgDown = 0, unsigned int imgDownSize = 0);

private:
    enum Constants {
       TitleHeight = 20,
       ButtonWidth = 75,
       ButtonHeight = 75,
       ButtonRows   = 2,
       ButtonColumns = 5,
       NumberOfButtons = ButtonRows*ButtonColumns,
    };

    Display* _disp;
    SWIM_WINDOW_T* _win;
    void* _fb;
    Clickable* _buttons[NumberOfButtons];
    int _usedButtons;
    App*(*_callback)(uint32_t buttonID);
    bool _supportsCalibration;
    bool _newTouchEvent;
    bool _newButtonEvent;

    void draw();
    void onTouchEvent();
    void onButtonEvent();
};

#endif