Hello All,
I am a MoSync newbie so please bear with me while I get to grips with creating and managing a MoSync project.
Having gotten past the HelloWorld example and not being very good at reading readymade code I decided to try out a simple MAUI project. The first issue I ran into was with font resources. Creating a .mof file was easy enough. I then created the corresponding .lst file as explained here. However, the MoSync help talks of the resource compiler automatically creating the MAHeaders.h file. Not quite sure where and when this happens. Presumably not whilst I am building the project. So I ended up creating the .h file manually and got the project to compile.
When I tried to run it I got a MALLOC warning regarding insufficient memory so I increased it to 128 Kb and ran the app again. Much to my surprise instead of seeing "Hello World" against a blue background I get a blank screen. What am I doing wrong.
My main.cpp code is given below
#include
#include
#include
#include
#include "MAHeaders.h"
using namespace MAUtil;
using namespace MAUI;
class MyScreen : public Screen {
public:
MyScreen() {
label = new Label(
10, // set the top-left corner
10, // to be in the top-left corner of the lcd display.
100, // the width and height are set to the width and height of the lcd display
30, // automatically for the root widget in a screen.
NULL, // this widget has no parent widget
"123Hello World!", // the caption of the label
255, // use background color 0 (black)
new Font(myfonts) // create a new instance of the font stored as the
// resource MY_FONT and set the font of the label to that font.
);
setMain(label); // set the root widget to be the label we just created
}
void keyPressEvent(int key) {
if(key == MAK_0) {
maExit(0); // exit the application when key 0 has been pressed
}
}
private:
Label *label;
};
class MyMoblet : public Moblet {
public:
MyMoblet() {
myScreen = new MyScreen();
myScreen->show();
}
private:
MyScreen *myScreen;
};
// Since this is a C++ program, the main function
// needs to be declared extern "C"
extern "C" int MAMain() {
Moblet::run(new MyMoblet());
}