2222#include " platform/sdl/main_bas.h"
2323
2424#define WAIT_INTERVAL 10
25+ #define DEFAULT_FONT_SIZE 16
2526#define MAIN_BAS " __main_bas__"
2627
2728Runtime *runtime;
2829
2930Runtime::Runtime (SDL_Window *window) :
3031 System(),
31- _window(window) {
32+ _window(window),
33+ _cursorHand(NULL ),
34+ _cursorArrow(NULL ) {
3235 runtime = this ;
3336}
3437
@@ -41,12 +44,21 @@ Runtime::~Runtime() {
4144 _output = NULL ;
4245 _eventQueue = NULL ;
4346 _graphics = NULL ;
47+
48+ SDL_FreeCursor (_cursorHand);
49+ SDL_FreeCursor (_cursorArrow);
50+ _cursorHand = NULL ;
51+ _cursorArrow = NULL ;
4452}
4553
4654void Runtime::construct (const char *font, const char *boldFont) {
4755 logEntered ();
4856 _state = kClosingState ;
4957 _graphics = new Graphics (_window);
58+
59+ _cursorHand = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_HAND);
60+ _cursorArrow = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_ARROW);
61+
5062 if (_graphics && _graphics->construct (font, boldFont)) {
5163 int w, h;
5264 SDL_GetWindowSize (_window, &w, &h);
@@ -68,7 +80,7 @@ MAEvent *Runtime::popEvent() {
6880 return _eventQueue->pop ();
6981}
7082
71- void Runtime::runShell (const char *startupBas) {
83+ int Runtime::runShell (const char *startupBas, int fontScale ) {
7284 logEntered ();
7385
7486 os_graphics = 1 ;
@@ -80,6 +92,15 @@ void Runtime::runShell(const char *startupBas) {
8092 opt_pref_bpp = 0 ;
8193 opt_nosave = true ;
8294
95+ _output->setTextColor (DEFAULT_FOREGROUND, DEFAULT_BACKGROUND);
96+ _output->setFontSize (DEFAULT_FONT_SIZE);
97+ _initialFontSize = _output->getFontSize ();
98+ if (fontScale != 100 ) {
99+ _fontScale = fontScale;
100+ int fontSize = (_initialFontSize * _fontScale / 100 );
101+ _output->setFontSize (fontSize);
102+ }
103+
83104 if (startupBas != NULL ) {
84105 runOnce (startupBas);
85106 } else {
@@ -88,6 +109,7 @@ void Runtime::runShell(const char *startupBas) {
88109
89110 _state = kDoneState ;
90111 logLeaving ();
112+ return _fontScale;
91113}
92114
93115char *Runtime::loadResource (const char *fileName) {
@@ -166,6 +188,7 @@ void Runtime::pollEvents(bool blocking) {
166188 maEvent = getMotionEvent (EVENT_TYPE_POINTER_DRAGGED, &ev);
167189 break ;
168190 case SDL_MOUSEBUTTONUP:
191+ SDL_SetCursor (_cursorArrow);
169192 maEvent = getMotionEvent (EVENT_TYPE_POINTER_RELEASED, &ev);
170193 break ;
171194 case SDL_WINDOWEVENT_SIZE_CHANGED:
@@ -217,6 +240,9 @@ MAEvent Runtime::processEvents(int waitFlag) {
217240 break ;
218241 default :
219242 handleEvent (event);
243+ if (event.type == EVENT_TYPE_POINTER_PRESSED && _buttonPressed) {
244+ SDL_SetCursor (_cursorHand);
245+ }
220246 break ;
221247 }
222248 return event;
0 commit comments