I am developing in the Mosync API (a Cross Smart Phone Platform C++ based API) for my internship & I knowticed how there are so few people using this API. http://www.mosync.com/
I want people to start using this, mostly so that there will be more people out there to help me with my bugs & issues , the forums are dead, but also because its a really rich & broad API (bluetooth, xml support, vibration, creates application in each platforms native UI & heaps more) http://www.mosync.co...html/index.html. Plus I wanted to unleash/get the talent into Mosync, ie, gamedev users.
So please start developing in Mosync.....& while your there maybe you can answer some of my mosync problems in the forum , if you want help with making your own widgets(my speciality) just PM me.
Take a look at my simple temperature converter application to see how easy it is to develop in Mosync (see the attachment for the pngs & etc to compile the app). This app will work in many, many platforms such as Symbian phones, iOS, Android & BlackBerry phones(do they use Symbian?) & apparently Windows Phones but I haven't tested that.
#include <MAHeaders.h>
#include <MAUtil/Util.h>
#include <MAUtil/Moblet.h>
#include <MAUI/Engine.h>
#include <MAUI/Layout.h>
#include <MAUI/ListBox.h>
#include <MAUI/Label.h>
#include <MAUI/Image.h>
#include <MAUI/Scaler.h>
#include <MAUI/Screen.h>
#include <MAUI/Font.h>
#include <MAUtil/Environment.h>
#include <madmath.h>
#include <conprint.h>
#include "NativeEditBox.h"
using namespace MAUtil;
using namespace MAUI;
/// Global Variables ///
enum ConversionType { TO_CELSIUS, TO_FAHRENHEIT };
ConversionType conversionType = TO_CELSIUS;
class TemperatureMoblet;
class TemperatureScreen;
/// Functions ///
float toFahrenheit( float fahrenVal );
float toCelsius( float celsiusVal );
class IPointerListener
{
// Interface:
public:
static void registerPointing( PointerListener *p )
{
// Post:
Environment &env = Environment::getEnvironment();
env.addPointerListener( p );
}
static void unregisterPointing( PointerListener *p )
{
// Post:
Environment &env = Environment::getEnvironment();
env.removePointerListener( p );
}
};
/// Our main application screen (the equivalent in Java Swing would be a JFrame, in Win32 a custom window/HWND) ///
class TemperatureScreen : public Screen, public NativeEditBoxListener, public WidgetListener
{
public:
TemperatureScreen( TemperatureMoblet *nParent );
~TemperatureScreen();
void initEnvironment();
void initScreen();
void selectionChanged( Widget *widget, bool selected );
void pointerPressEvent( MAPoint2d p );
void pointerMoveEvent( MAPoint2d p ) {}
void pointerReleaseEvent( MAPoint2d p ) {}
void setPadding( Widget *w, unsigned int nPadding );
void setAlignment( Label* l, Label::HorizontalAlignment horiz, Label::VerticalAlignment vert );
void registerWidget( Widget *w );
void nativeEditFinished();
private:
TemperatureMoblet *parent;
Layout *mainLayout;
ListBox *mainListBox;
Font *gFont;
WidgetSkin *gSkin;
WidgetSkin *rbSkin;
Label *celLabel;
Label *fahLabel;
NativeEditBox *celEdit;
NativeEditBox *fahEdit;
Label *toCelsiusRb;
Label *toFahRb;
Label *convertLabel;
Label *exitLabel;
};
class TemperatureMoblet : public Moblet
{
public:
TemperatureMoblet();
~TemperatureMoblet();
void closeMoblet();
void keyPressEvent(int keyCode, int nativeCode);
void keyReleaseEvent(int keyCode, int nativeCode);
private:
TemperatureScreen *instance;
};
/// Function Implementation ///
double toCelsius( double fahrenVal )
{
// Post:
return ((fahrenVal - 32) * 5/9);
}
double toFahrenheit( double celsiusVal )
{
// Post:
return ((9.0 / 5.0) * celsiusVal) + 32;
}
/// TemperatureScreen Implementation ///
TemperatureScreen::TemperatureScreen( TemperatureMoblet *nParent )
{
// Constructor:
parent = nParent;
mainLayout = NULL;
mainListBox = NULL;
initEnvironment();
initScreen();
IPointerListener::registerPointing( this );
}
TemperatureScreen::~TemperatureScreen()
{
// Destructor
IPointerListener::unregisterPointing( this );
//delete mainListBox;
delete mainLayout;
delete gFont;
delete gSkin;
delete rbSkin;
delete celLabel;
delete fahLabel;
delete celEdit;
delete fahEdit;
delete toCelsiusRb;
delete toFahRb;
delete convertLabel;
delete exitLabel;
}
void TemperatureScreen::initEnvironment()
{
// Post:
Engine &engine = Engine::getSingleton();
gFont = new MAUI::Font(RES_FONT);
gSkin = new MAUI::WidgetSkin( RES_SELECTED, RES_UNSELECTED, 16, 32, 16, 32, true, true );
rbSkin = new MAUI::WidgetSkin( RB_UNSELECTED, RB_SELECTED, 39, 42, 27, 27, true, true );
engine.setDefaultFont( gFont );
engine.setDefaultSkin( gSkin );
}
void TemperatureScreen::initScreen()
{
// Post:
WString caption;
MAExtent screenDim = maGetScrSize();
int widgetPadding = 5 * (5*2);
int titleHeight = (EXTENT_Y(screenDim) - widgetPadding) / 2;
int labelHeight = titleHeight / 5;
mainLayout = new Layout( 0, 0, EXTENT_X(screenDim), EXTENT_Y(screenDim), NULL, 1, 2 );
Layout *inputLayout = new Layout( 0, 0, EXTENT_X(screenDim), EXTENT_Y(screenDim), NULL, 2, 5 );
//Scaler *imgScaler = new Scaler( TITLE_IMAGE, NULL, 0.1, 2.0, 1, ST_NEAREST_NEIGHBOUR );
Image *title = new Image( 0, 0, 0, 0, NULL, true, true, TITLE_IMAGE );
celLabel = new Label( 0, 0, 50, labelHeight, NULL, "Celcius:", 0, gFont );
fahLabel = new Label( 0, 0, 50, labelHeight, NULL, "Fahrenheit:", 0, gFont );
celEdit = new NativeEditBox( 0, 0, 50, labelHeight, 128, MA_TB_TYPE_ANY|MA_TB_TYPE_DECIMAL, "0.00", caption );
fahEdit = new NativeEditBox( 0, 0, 50, labelHeight, 128, MA_TB_TYPE_ANY|MA_TB_TYPE_DECIMAL, "32.0", caption );
toCelsiusRb = new Label( 0, 0, 100, labelHeight, NULL, "To Celcius", 0, gFont );
toFahRb = new Label( 0, 0, 100, labelHeight, NULL, "To Fahrenheit", 0, gFont );
convertLabel = new Label( 0, 0, 50, labelHeight, NULL, "Convert", 0, gFont );
exitLabel = new Label( 0, 0, 50, labelHeight, NULL, "Exit", 0, gFont );
mainLayout -> setAutoSizeX();
mainLayout -> setDrawBackground( true );
mainLayout -> setBackgroundColor( 300 );
inputLayout -> setAutoSizeX();
//inputLayout -> setAutoSizeY();
inputLayout -> setDrawBackground( true );
inputLayout -> setBackgroundColor( 300 );
mainLayout -> setPaddingTop( 25 );
mainLayout -> setPaddingBottom( 25 );
mainLayout -> setPaddingLeft( 10 );
mainLayout -> setPaddingRight( 10 );
celLabel -> setAutoSizeX();
fahLabel -> setAutoSizeX();
fahEdit -> setAutoSizeX();
celEdit -> setAutoSizeX();
toCelsiusRb -> setAutoSizeX();
toFahRb -> setAutoSizeX();
convertLabel -> setAutoSizeX();
exitLabel -> setAutoSizeX();
setAlignment( celLabel, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( fahLabel, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( fahEdit, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( celEdit, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( toCelsiusRb, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( toFahRb, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( convertLabel, Label::HA_CENTER, Label::VA_CENTER );
setAlignment( exitLabel, Label::HA_CENTER, Label::VA_CENTER );
setPadding( title, 5 );
setPadding( celLabel, 5 );
setPadding( fahLabel, 5 );
setPadding( fahEdit, 5 );
setPadding( celEdit, 5 );
setPadding( toCelsiusRb, 5 );
setPadding( toFahRb, 5 );
setPadding( convertLabel, 5 );
setPadding( exitLabel, 5 );
toCelsiusRb -> setSkin( rbSkin );
toFahRb -> setSkin( rbSkin );
toCelsiusRb -> setSelected( true );
toCelsiusRb -> setPaddingLeft(50);
toFahRb -> setPaddingLeft(50);
registerWidget( celLabel );
registerWidget( fahLabel );
registerWidget( fahEdit );
registerWidget( celEdit );
registerWidget( toCelsiusRb );
registerWidget( toFahRb );
registerWidget( convertLabel );
registerWidget( exitLabel );
inputLayout -> add( celLabel );
inputLayout -> add( celEdit );
inputLayout -> add( fahLabel );
inputLayout -> add( fahEdit );
inputLayout -> add( toCelsiusRb );
inputLayout -> add( toFahRb );
inputLayout -> add( convertLabel );
inputLayout -> add( exitLabel );
mainLayout -> add( title );
mainLayout -> add( inputLayout );
this -> setMain( mainLayout );
}
void TemperatureScreen::selectionChanged( Widget *widget, bool selected )
{
// Post: Called when this application looses the focus(pushed to the background)
// or when the application regains the focus (am I correct?). Select the
// the 1st widget of the mainPanel
/*if ( selected )
widget -> getChildren()[0] -> setSelected( true );
else widget -> getChildren()[0] -> setSelected( false );*/
}
void TemperatureScreen::pointerPressEvent( MAPoint2d p )
{
// Post:
//Vector <Widget*> a = mainLayout -> getChildren();
Point widgetP;
widgetP.set( p.x, p.y );
if ( celLabel -> contains( widgetP ) )
{
celLabel -> setSelected( true );
//celLabel -> setSelected( false );
}
else if ( fahLabel -> contains( widgetP ) )
{
fahLabel -> setSelected( true );
//fahLabel -> setSelected( false );
}
else if ( celEdit -> contains( widgetP ) )
{
celEdit -> activate( this );
}
else if ( fahEdit -> contains( widgetP ) )
{
fahEdit -> activate( this );
}
else if ( toCelsiusRb -> contains( widgetP ) || toFahRb -> contains( widgetP ) )
{
if ( conversionType == TO_FAHRENHEIT )
{
conversionType = TO_CELSIUS;
toCelsiusRb -> setSelected( true );
toFahRb -> setSelected( false );
}
else
{
conversionType = TO_FAHRENHEIT;
toCelsiusRb -> setSelected( false );
toFahRb -> setSelected( true );
}
}
else if ( convertLabel -> contains( widgetP ) )
{
if ( conversionType == TO_CELSIUS )
{
double fahVal = MAUtil::stringToDouble( fahEdit->getCaption() );
String celVal = MAUtil::doubleToString( toCelsius( fahVal ), 10 );
celEdit -> setCaption( celVal );
}
else
{
double celVal = MAUtil::stringToDouble( celEdit->getCaption() );
String fahVal = MAUtil::doubleToString( toFahrenheit( celVal ), 10 );
fahEdit -> setCaption( fahVal );
}
}
else if ( exitLabel -> contains( widgetP ) )
{
parent -> closeMoblet();
}
}
void TemperatureScreen::setPadding( Widget *w, unsigned int nPadding )
{
w -> setPaddingLeft( nPadding );
w -> setPaddingTop( nPadding );
w -> setPaddingRight( nPadding );
w -> setPaddingBottom( nPadding );
}
void TemperatureScreen::setAlignment( Label* l, Label::HorizontalAlignment horiz, Label::VerticalAlignment vert )
{
l -> setHorizontalAlignment( Label::HA_CENTER );
l -> setVerticalAlignment( Label::VA_CENTER );
}
void TemperatureScreen::registerWidget( Widget *w )
{
// Post:
w -> addWidgetListener( this );
}
void TemperatureScreen::nativeEditFinished()
{
// Post: Implement the virtual function; here we state what to do after the user has
// edited text in the native edit box, right now there is nothing I need to do
// on this event.
}
TemperatureMoblet::TemperatureMoblet()
{
// Constructor:
instance = new TemperatureScreen( this );
instance -> show();
}
TemperatureMoblet::~TemperatureMoblet()
{
// Destructor
delete instance;
}
void TemperatureMoblet::closeMoblet()
{
this -> closeEvent();
this -> close();
}
void TemperatureMoblet::keyPressEvent(int keyCode, int nativeCode)
{
// Post:
}
void TemperatureMoblet::keyReleaseEvent(int keyCode, int nativeCode)
{
// Post:
}
/// Main ///
extern "C" int MAMain()
{
Moblet::run( new TemperatureMoblet() );
return 0;
};