Notepad-2 demo updated to work on ChibiOS or pure Win32 compile
This commit is contained in:
parent
e9f60dae38
commit
8a5596b39d
8 changed files with 65 additions and 58 deletions
5
demos/3rdparty/notepad-2/gfxconf.h
vendored
5
demos/3rdparty/notepad-2/gfxconf.h
vendored
|
@ -9,6 +9,11 @@
|
||||||
#ifndef _GFXCONF_H
|
#ifndef _GFXCONF_H
|
||||||
#define _GFXCONF_H
|
#define _GFXCONF_H
|
||||||
|
|
||||||
|
/* GFX operating system to use */
|
||||||
|
#define GFX_USE_OS_CHIBIOS TRUE
|
||||||
|
//#define GFX_USE_OS_WIN32 TRUE
|
||||||
|
//#define GFX_USE_OS_POSIX TRUE
|
||||||
|
|
||||||
/* GFX sub-systems to turn on */
|
/* GFX sub-systems to turn on */
|
||||||
#define GFX_USE_GDISP TRUE
|
#define GFX_USE_GDISP TRUE
|
||||||
#define GFX_USE_GWIN TRUE
|
#define GFX_USE_GWIN TRUE
|
||||||
|
|
18
demos/3rdparty/notepad-2/main.c
vendored
18
demos/3rdparty/notepad-2/main.c
vendored
|
@ -28,10 +28,10 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Modified by InMarket to allow it to compile on any GFX supported operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ch.h"
|
|
||||||
#include "hal.h"
|
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
#include "notepadApp.h"
|
#include "notepadApp.h"
|
||||||
|
@ -69,6 +69,7 @@ const NColorScheme schemeDefault2 = {
|
||||||
const char *tsCalibRead(uint16_t instance) {
|
const char *tsCalibRead(uint16_t instance) {
|
||||||
// This will perform a on-spot calibration
|
// This will perform a on-spot calibration
|
||||||
// Unless you read and add the co-efficients here
|
// Unless you read and add the co-efficients here
|
||||||
|
(void) instance;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,12 +78,7 @@ int main(void) {
|
||||||
font_t font = gdispOpenFont("UI2");
|
font_t font = gdispOpenFont("UI2");
|
||||||
|
|
||||||
/* initialize the hardware and the OS */
|
/* initialize the hardware and the OS */
|
||||||
halInit();
|
|
||||||
chSysInit();
|
|
||||||
|
|
||||||
/* initialize the LCD */
|
|
||||||
gfxInit();
|
gfxInit();
|
||||||
gdispClear(Black);
|
|
||||||
|
|
||||||
/* Calibrate the touchscreen */
|
/* Calibrate the touchscreen */
|
||||||
ginputSetMouseCalibrationRoutines(0, NULL, tsCalibRead, FALSE);
|
ginputSetMouseCalibrationRoutines(0, NULL, tsCalibRead, FALSE);
|
||||||
|
@ -92,16 +88,14 @@ int main(void) {
|
||||||
nSetColorScheme(schemeDefault);
|
nSetColorScheme(schemeDefault);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
|
gfxThreadWait(nLaunchNotepadApp());
|
||||||
|
|
||||||
chThdWait(nLaunchNotepadApp());
|
|
||||||
|
|
||||||
gdispClear(Black);
|
|
||||||
gdispSetClip(0, 0, gdispGetWidth(), gdispGetHeight());
|
gdispSetClip(0, 0, gdispGetWidth(), gdispGetHeight());
|
||||||
|
gdispClear(Black);
|
||||||
gdispDrawString(3, 3, "Notepad Terminated.", font, White);
|
gdispDrawString(3, 3, "Notepad Terminated.", font, White);
|
||||||
gdispDrawString(3, 20, "Relaunching Notepad App...", font, White);
|
gdispDrawString(3, 20, "Relaunching Notepad App...", font, White);
|
||||||
|
|
||||||
chThdSleepMilliseconds(1000);
|
gfxSleepMilliseconds(1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
46
demos/3rdparty/notepad-2/notepadApp.c
vendored
46
demos/3rdparty/notepad-2/notepadApp.c
vendored
|
@ -28,14 +28,12 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Modified by InMarket to allow it to compile on any GFX supported operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ch.h"
|
|
||||||
#include "hal.h"
|
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
#include "chprintf.h"
|
|
||||||
|
|
||||||
#include "notepadApp.h"
|
#include "notepadApp.h"
|
||||||
#include "toolbarIcons.h"
|
#include "toolbarIcons.h"
|
||||||
|
|
||||||
|
@ -45,7 +43,7 @@
|
||||||
// Static objects
|
// Static objects
|
||||||
static GListener gl; // Event listener object
|
static GListener gl; // Event listener object
|
||||||
static GHandle nDrawingArea; // GWindow Drawing Area
|
static GHandle nDrawingArea; // GWindow Drawing Area
|
||||||
static BaseSequentialStream *gstatusConsole; // GConsole Handle to the Status Bar
|
static GHandle gstatusConsole; // GConsole Handle to the Status Bar
|
||||||
|
|
||||||
static GEventMouse curPtr; // Holder for current pointer location
|
static GEventMouse curPtr; // Holder for current pointer location
|
||||||
|
|
||||||
|
@ -72,7 +70,7 @@ static int selColorIndex = 0, selPenWidth = 1, tbMode = 1;
|
||||||
|
|
||||||
static NColorScheme nCurColorScheme;
|
static NColorScheme nCurColorScheme;
|
||||||
|
|
||||||
static msg_t notepadThread(void *param);
|
static DECLARE_THREAD_FUNCTION(notepadThread, param);
|
||||||
|
|
||||||
// Custom drawing functions for the buttons
|
// Custom drawing functions for the buttons
|
||||||
static void nbtnColorBarDraw(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
|
static void nbtnColorBarDraw(GHandle gh, bool_t enabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
|
||||||
|
@ -94,7 +92,7 @@ static void nbtnColorBarDraw(GHandle gh, bool_t enabled, bool_t isdown, const ch
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
j = gh->x + (NPAD_TOOLBAR_BTN_WIDTH / 2) + NPAD_TOOLBAR_BTN_WIDTH * i;
|
j = gh->x + (NPAD_TOOLBAR_BTN_WIDTH / 2) + NPAD_TOOLBAR_BTN_WIDTH * i;
|
||||||
|
|
||||||
if (isdown == TRUE) {
|
if (isdown) {
|
||||||
// Update selection - this is like lazy release.
|
// Update selection - this is like lazy release.
|
||||||
if (k >= 0 && k <= 7) {
|
if (k >= 0 && k <= 7) {
|
||||||
selPenWidth = k + 1;
|
selPenWidth = k + 1;
|
||||||
|
@ -124,7 +122,7 @@ static void nbtnColorBarDraw(GHandle gh, bool_t enabled, bool_t isdown, const ch
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
j = gh->x + (NPAD_TOOLBAR_BTN_WIDTH / 2) + NPAD_TOOLBAR_BTN_WIDTH * i;
|
j = gh->x + (NPAD_TOOLBAR_BTN_WIDTH / 2) + NPAD_TOOLBAR_BTN_WIDTH * i;
|
||||||
|
|
||||||
if (isdown == TRUE) {
|
if (isdown) {
|
||||||
// Update selection - this is like lazy release.
|
// Update selection - this is like lazy release.
|
||||||
if (k >= 0 && k <= 7) {
|
if (k >= 0 && k <= 7) {
|
||||||
selColorIndex = k;
|
selColorIndex = k;
|
||||||
|
@ -176,7 +174,7 @@ static void nbtnColorBarSelDraw(GHandle gh, bool_t enabled, bool_t isdown, const
|
||||||
gdispDrawBox(gh->x + 1, gh->y + 1, gh->width - 2, gh->height - 2, ccs.toolbarBgUnsel);
|
gdispDrawBox(gh->x + 1, gh->y + 1, gh->width - 2, gh->height - 2, ccs.toolbarBgUnsel);
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
if (isdown == TRUE) {
|
if (isdown) {
|
||||||
// Update selection - this is like lazy release.
|
// Update selection - this is like lazy release.
|
||||||
if (k == 0 || k == 1) {
|
if (k == 0 || k == 1) {
|
||||||
tbMode = k;
|
tbMode = k;
|
||||||
|
@ -231,6 +229,11 @@ static void nToolbarImageButtonDraw(GHandle gh, bool_t isenabled, bool_t isdown,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nCloseButtonDraw(GHandle gh, bool_t isenabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
|
static void nCloseButtonDraw(GHandle gh, bool_t isenabled, bool_t isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
|
||||||
|
(void) isenabled;
|
||||||
|
(void) isdown;
|
||||||
|
(void) txt;
|
||||||
|
(void) pstyle;
|
||||||
|
(void) param;
|
||||||
gwinImageDraw(gh, &toolbarImageFilmstrip, 0, 0, NPAD_ICON_WIDTH, NPAD_ICON_HEIGHT, NPAD_ICON_START(8), 0);
|
gwinImageDraw(gh, &toolbarImageFilmstrip, 0, 0, NPAD_ICON_WIDTH, NPAD_ICON_HEIGHT, NPAD_ICON_START(8), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,8 +311,8 @@ static void drawVButtons(void) {
|
||||||
gwinButtonDraw(H(btnFill));
|
gwinButtonDraw(H(btnFill));
|
||||||
}
|
}
|
||||||
|
|
||||||
static WORKING_AREA(waNotepadThread, NPAD_THD_WA_SIZE);
|
static DECLARE_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
|
||||||
static msg_t notepadThread(void *param) {
|
static DECLARE_THREAD_FUNCTION(notepadThread, param) {
|
||||||
|
|
||||||
GEventMouse *pem;
|
GEventMouse *pem;
|
||||||
GEventGWinButton *peb;
|
GEventGWinButton *peb;
|
||||||
|
@ -382,7 +385,7 @@ static msg_t notepadThread(void *param) {
|
||||||
gwinSetBgColor(ghc, nCurColorScheme.winBgColor);
|
gwinSetBgColor(ghc, nCurColorScheme.winBgColor);
|
||||||
gwinSetColor(ghc, Black);
|
gwinSetColor(ghc, Black);
|
||||||
|
|
||||||
gstatusConsole = gwinGetConsoleStream(ghc);
|
gstatusConsole = ghc;
|
||||||
|
|
||||||
/* draw the buttons */
|
/* draw the buttons */
|
||||||
gwinSetColor(nDrawingArea, Black);
|
gwinSetColor(nDrawingArea, Black);
|
||||||
|
@ -394,7 +397,7 @@ static msg_t notepadThread(void *param) {
|
||||||
drawButtons();
|
drawButtons();
|
||||||
drawVButtons();
|
drawVButtons();
|
||||||
|
|
||||||
chprintf(gstatusConsole, "Welcome to ChibiOS/GFX Notepad demo.");
|
gwinPrintf(gstatusConsole, "Welcome to ChibiOS/GFX Notepad demo.");
|
||||||
|
|
||||||
ncoreSpawnDrawThread(nDrawingArea, gstatusConsole);
|
ncoreSpawnDrawThread(nDrawingArea, gstatusConsole);
|
||||||
|
|
||||||
|
@ -419,28 +422,28 @@ static msg_t notepadThread(void *param) {
|
||||||
drawVButtons();
|
drawVButtons();
|
||||||
|
|
||||||
gwinClear(nDrawingArea);
|
gwinClear(nDrawingArea);
|
||||||
chprintf(gstatusConsole, "\nScreen Cleared.");
|
gwinPrintf(gstatusConsole, "\nScreen Cleared.");
|
||||||
}
|
}
|
||||||
else if (peb->button == H(btnOpen)) {
|
else if (peb->button == H(btnOpen)) {
|
||||||
chprintf(gstatusConsole, "\nFile Open not implemented.");
|
gwinPrintf(gstatusConsole, "\nFile Open not implemented.");
|
||||||
}
|
}
|
||||||
else if (peb->button == H(btnSave)) {
|
else if (peb->button == H(btnSave)) {
|
||||||
chprintf(gstatusConsole, "\nFile Save not implemented.");
|
gwinPrintf(gstatusConsole, "\nFile Save not implemented.");
|
||||||
}
|
}
|
||||||
else if (peb->button == H(btnPencil)) {
|
else if (peb->button == H(btnPencil)) {
|
||||||
ncoreSetMode(NCORE_MODE_DRAW);
|
ncoreSetMode(NCORE_MODE_DRAW);
|
||||||
drawVButtons();
|
drawVButtons();
|
||||||
chprintf(gstatusConsole, "\nPencil Tool Selected.");
|
gwinPrintf(gstatusConsole, "\nPencil Tool Selected.");
|
||||||
}
|
}
|
||||||
else if (peb->button == H(btnEraser)) {
|
else if (peb->button == H(btnEraser)) {
|
||||||
ncoreSetMode(NCORE_MODE_ERASE);
|
ncoreSetMode(NCORE_MODE_ERASE);
|
||||||
drawVButtons();
|
drawVButtons();
|
||||||
chprintf(gstatusConsole, "\nEraser Tool Selected.");
|
gwinPrintf(gstatusConsole, "\nEraser Tool Selected.");
|
||||||
}
|
}
|
||||||
else if (peb->button == H(btnFill)) {
|
else if (peb->button == H(btnFill)) {
|
||||||
ncoreSetMode(NCORE_MODE_FILL);
|
ncoreSetMode(NCORE_MODE_FILL);
|
||||||
drawVButtons();
|
drawVButtons();
|
||||||
chprintf(gstatusConsole, "\nFill Tool Selected.");
|
gwinPrintf(gstatusConsole, "\nFill Tool Selected.");
|
||||||
}
|
}
|
||||||
else if (peb->button == H(btnClose)) {
|
else if (peb->button == H(btnClose)) {
|
||||||
break;
|
break;
|
||||||
|
@ -461,11 +464,10 @@ static msg_t notepadThread(void *param) {
|
||||||
void nSetColorScheme(NColorScheme sch) { nCurColorScheme = sch; }
|
void nSetColorScheme(NColorScheme sch) { nCurColorScheme = sch; }
|
||||||
NColorScheme nGetColorScheme(void) { return nCurColorScheme; }
|
NColorScheme nGetColorScheme(void) { return nCurColorScheme; }
|
||||||
|
|
||||||
Thread *nLaunchNotepadApp(void) {
|
gfxThreadHandle nLaunchNotepadApp(void) {
|
||||||
|
|
||||||
return chThdCreateStatic(waNotepadThread,
|
return gfxThreadCreate(waNotepadThread,
|
||||||
sizeof(waNotepadThread),
|
sizeof(waNotepadThread),
|
||||||
NPAD_THD_PRIO,
|
NPAD_THD_PRIO,
|
||||||
notepadThread, NULL);
|
notepadThread, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
6
demos/3rdparty/notepad-2/notepadApp.h
vendored
6
demos/3rdparty/notepad-2/notepadApp.h
vendored
|
@ -28,6 +28,8 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Modified by InMarket to allow it to compile on any GFX supported operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTEPADAPP_H_
|
#ifndef NOTEPADAPP_H_
|
||||||
|
@ -36,13 +38,13 @@
|
||||||
#include "notepadCore.h"
|
#include "notepadCore.h"
|
||||||
#include "notepadUIDefines.h"
|
#include "notepadUIDefines.h"
|
||||||
|
|
||||||
#define NPAD_THD_PRIO (NORMALPRIO + 2)
|
#define NPAD_THD_PRIO NORMAL_PRIORITY
|
||||||
#define NPAD_THD_WA_SIZE 512
|
#define NPAD_THD_WA_SIZE 512
|
||||||
|
|
||||||
void nSetColorScheme(NColorScheme sch);
|
void nSetColorScheme(NColorScheme sch);
|
||||||
NColorScheme nGetColorScheme(void);
|
NColorScheme nGetColorScheme(void);
|
||||||
|
|
||||||
|
|
||||||
Thread *nLaunchNotepadApp(void);
|
gfxThreadHandle nLaunchNotepadApp(void);
|
||||||
|
|
||||||
#endif /* NOTEPADAPP_H_ */
|
#endif /* NOTEPADAPP_H_ */
|
||||||
|
|
36
demos/3rdparty/notepad-2/notepadCore.c
vendored
36
demos/3rdparty/notepad-2/notepadCore.c
vendored
|
@ -28,12 +28,12 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Modified by InMarket to allow it to compile on any GFX supported operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "ch.h"
|
|
||||||
#include "hal.h"
|
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
|
||||||
#include "notepadCore.h"
|
#include "notepadCore.h"
|
||||||
|
@ -43,15 +43,17 @@
|
||||||
(ev.y >= ncoreDrawingArea->y) && (ev.y <= (ncoreDrawingArea->y + ncoreDrawingArea->height)))
|
(ev.y >= ncoreDrawingArea->y) && (ev.y <= (ncoreDrawingArea->y + ncoreDrawingArea->height)))
|
||||||
|
|
||||||
/* This is the drawing core */
|
/* This is the drawing core */
|
||||||
static WORKING_AREA(waDrawThread, NCORE_THD_STACK_SIZE);
|
static DECLARE_THREAD_STACK(waDrawThread, NCORE_THD_STACK_SIZE);
|
||||||
|
|
||||||
static uint8_t nPenWidth = 1;
|
static uint8_t nPenWidth = 1;
|
||||||
static uint8_t nMode = NCORE_MODE_DRAW;
|
static uint8_t nMode = NCORE_MODE_DRAW;
|
||||||
|
|
||||||
static Thread *nThd;
|
static gfxThreadHandle nThd;
|
||||||
|
|
||||||
static GHandle ncoreDrawingArea = NULL;
|
static GHandle ncoreDrawingArea = NULL;
|
||||||
static BaseSequentialStream *nStatusConsole = NULL;
|
static GHandle nStatusConsole = NULL;
|
||||||
|
|
||||||
|
static volatile bool_t doExit;
|
||||||
|
|
||||||
static void draw_point(coord_t x, coord_t y) {
|
static void draw_point(coord_t x, coord_t y) {
|
||||||
color_t c = ncoreDrawingArea->color;
|
color_t c = ncoreDrawingArea->color;
|
||||||
|
@ -125,7 +127,7 @@ static void draw_line(coord_t x0, coord_t y0, coord_t x1, coord_t y1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Core thread */
|
/* Core thread */
|
||||||
static msg_t ncoreDrawThread(void *msg) {
|
static DECLARE_THREAD_FUNCTION(ncoreDrawThread, msg) {
|
||||||
|
|
||||||
GEventMouse ev, evPrev;
|
GEventMouse ev, evPrev;
|
||||||
coord_t dx, dy;
|
coord_t dx, dy;
|
||||||
|
@ -136,11 +138,7 @@ static msg_t ncoreDrawThread(void *msg) {
|
||||||
|
|
||||||
ginputGetMouseStatus(0, &evPrev);
|
ginputGetMouseStatus(0, &evPrev);
|
||||||
|
|
||||||
while (1) {
|
while (!doExit) {
|
||||||
|
|
||||||
// Exit signal received? If yes, terminate.
|
|
||||||
if (chThdShouldTerminate())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
ginputGetMouseStatus(0, &ev);
|
ginputGetMouseStatus(0, &ev);
|
||||||
switch(state) {
|
switch(state) {
|
||||||
|
@ -153,13 +151,13 @@ static msg_t ncoreDrawThread(void *msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
chThdYield();
|
gfxYield();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 1: if (ev.meta == GMETA_MOUSE_UP) {
|
case 1: if (ev.meta == GMETA_MOUSE_UP) {
|
||||||
state = 0;
|
state = 0;
|
||||||
//chprintf(nStatusConsole, "\nPen Up: (%d, %d)", ev.x, ev.y);
|
//gwinPrintf(nStatusConsole, "\nPen Up: (%d, %d)", ev.x, ev.y);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +189,7 @@ static msg_t ncoreDrawThread(void *msg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//chprintf(nStatusConsole, "\nPen Down: (%d, %d)", ev.x, ev.y);
|
//gwinPrintf(nStatusConsole, "\nPen Down: (%d, %d)", ev.x, ev.y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -202,12 +200,13 @@ static msg_t ncoreDrawThread(void *msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spawn the core thread */
|
/* Spawn the core thread */
|
||||||
void ncoreSpawnDrawThread(GHandle drawingArea, BaseSequentialStream *statusConsole) {
|
void ncoreSpawnDrawThread(GHandle drawingArea, GHandle statusConsole) {
|
||||||
|
|
||||||
ncoreDrawingArea = drawingArea;
|
ncoreDrawingArea = drawingArea;
|
||||||
nStatusConsole = statusConsole;
|
nStatusConsole = statusConsole;
|
||||||
|
doExit = FALSE;
|
||||||
|
|
||||||
nThd = chThdCreateStatic(waDrawThread,
|
nThd = gfxThreadCreate(waDrawThread,
|
||||||
sizeof(waDrawThread),
|
sizeof(waDrawThread),
|
||||||
NCORE_THD_PRIO,
|
NCORE_THD_PRIO,
|
||||||
ncoreDrawThread,
|
ncoreDrawThread,
|
||||||
|
@ -217,8 +216,9 @@ void ncoreSpawnDrawThread(GHandle drawingArea, BaseSequentialStream *statusConso
|
||||||
|
|
||||||
/* Terminate the core thread, wait for control release */
|
/* Terminate the core thread, wait for control release */
|
||||||
void ncoreTerminateDrawThread(void) {
|
void ncoreTerminateDrawThread(void) {
|
||||||
chThdTerminate(nThd);
|
doExit = TRUE;
|
||||||
chThdWait(nThd);
|
gfxThreadWait(nThd);
|
||||||
|
nThd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get and set the pen width
|
/* Get and set the pen width
|
||||||
|
|
10
demos/3rdparty/notepad-2/notepadCore.h
vendored
10
demos/3rdparty/notepad-2/notepadCore.h
vendored
|
@ -28,6 +28,8 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Modified by InMarket to allow it to compile on any GFX supported operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTEPADCORE_H_
|
#ifndef NOTEPADCORE_H_
|
||||||
|
@ -35,17 +37,17 @@
|
||||||
|
|
||||||
/* Configuration */
|
/* Configuration */
|
||||||
#define NCORE_THD_STACK_SIZE 256
|
#define NCORE_THD_STACK_SIZE 256
|
||||||
#define NCORE_THD_PRIO (NORMALPRIO + 1)
|
#define NCORE_THD_PRIO NORMAL_PRIORITY
|
||||||
|
|
||||||
#define NCORE_MODE_DRAW 0
|
#define NCORE_MODE_DRAW 0
|
||||||
#define NCORE_MODE_ERASE 1
|
#define NCORE_MODE_ERASE 1
|
||||||
#define NCORE_MODE_FILL 2
|
#define NCORE_MODE_FILL 2
|
||||||
|
|
||||||
#define MAX_DX 500
|
#define MAX_DX 5000
|
||||||
#define MAX_DY 500
|
#define MAX_DY 5000
|
||||||
|
|
||||||
/* Spawn the notepad core thread */
|
/* Spawn the notepad core thread */
|
||||||
void ncoreSpawnDrawThread(GHandle drawingArea, BaseSequentialStream *statusConsole);
|
void ncoreSpawnDrawThread(GHandle drawingArea, GHandle statusConsole);
|
||||||
|
|
||||||
/* Terminate the core thread, wait for control release */
|
/* Terminate the core thread, wait for control release */
|
||||||
void ncoreTerminateDrawThread(void);
|
void ncoreTerminateDrawThread(void);
|
||||||
|
|
2
demos/3rdparty/notepad-2/notepadUIDefines.h
vendored
2
demos/3rdparty/notepad-2/notepadUIDefines.h
vendored
|
@ -28,6 +28,8 @@
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* Modified by InMarket to allow it to compile on any GFX supported operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTEPADUIDEFINES_H_
|
#ifndef NOTEPADUIDEFINES_H_
|
||||||
|
|
BIN
demos/3rdparty/notepad-2/toolbarIcons.gif
vendored
BIN
demos/3rdparty/notepad-2/toolbarIcons.gif
vendored
Binary file not shown.
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Loading…
Add table
Reference in a new issue