C++ Mosync:为什么不显示我的布局
我正在钻研布局&试图了解它们是如何工作的。布局是否类似于JavaSwing中的JPanel?也就是说,我们在哪里声明一个主面板&向其中添加所有的小部件 我不明白的一件事是,当我们创建一个移动应用程序时,我们会创建一个布局&一个列表框。这两个对象之间的关系是什么C++ Mosync:为什么不显示我的布局,c++,mobile,layout,C++,Mobile,Layout,我正在钻研布局&试图了解它们是如何工作的。布局是否类似于JavaSwing中的JPanel?也就是说,我们在哪里声明一个主面板&向其中添加所有的小部件 我不明白的一件事是,当我们创建一个移动应用程序时,我们会创建一个布局&一个列表框。这两个对象之间的关系是什么 布局对象是否包含Listbox,然后我们将所有小部件添加到Listbox 或者Listbox是否定义了布局,然后我们将小部件添加到Listbox&它们根据布局对齐 还是像JavaSwing那样将所有小部件添加到布局中 PS:在下面的实
- 布局对象是否包含Listbox,然后我们将所有小部件添加到Listbox
- 或者Listbox是否定义了布局,然后我们将小部件添加到Listbox&它们根据布局对齐
- 还是像JavaSwing那样将所有小部件添加到布局中
#include <MAUtil/Moblet.h>
#include <MAUI/Layout.h>
#include <MAUI/ListBox.h>
#include <MAUI/Label.h>
#include <MAUI/EditBox.h>
#include <MAUI/Screen.h>
#include <MAUtil/Environment.h>
#include <madmath.h>
#include <conprint.h>
using namespace MAUtil;
using namespace MAUI;
class TemperatureScreen : public Screen //, public PointerListener
{
public:
TemperatureScreen()
{
MAExtent screenDim = maGetScrSize();
Layout* mainLayout = new Layout( 0, 0, EXTENT_X(screenDim), EXTENT_Y(screenDim), NULL, 1, 3 );
ListBox* mainListBox = new ListBox( 0, 0, 100, 200, mainLayout,
ListBox::LBO_VERTICAL, ListBox::LBA_LINEAR,
true );
mainListBox -> setPaddingLeft( 10 );
mainListBox -> setPaddingRight( 10 );
mainListBox -> setPaddingTop( 10 );
mainListBox -> setPaddingBottom( 10 );
mainListBox -> setBackgroundColor( 900 );
mainLayout -> setBackgroundColor( 300 );
Label *celLabel = new Label( 10, 300, 50, 20, mainLayout );
Label *fahLabel = new Label( 10, 300, 50, 20, mainLayout );
EditBox *celEdit = new EditBox( 10, 300, 50, 20, mainLayout );
EditBox *fahEdit = new EditBox( 10, 300, 50, 20, mainLayout );
Label *toCelsiusRb = new Label( 10, 300, 50, 20, mainLayout );
Label *toFahRb = new Label( 10, 300, 50, 20, mainLayout );
Label *convertLabel = new Label( 10, 300, 50, 20, mainLayout );
Label *exitLabel = new Label( 10, 300, 50, 20, mainLayout );
celLabel -> setCaption( "Celcius" );
fahLabel -> setCaption( "Fahrenheit" );
convertLabel -> setCaption( "Convert" );
exitLabel -> setCaption( "Exit" );
/*celLabel -> addPointerListener( this );
fahLabel -> addPointerListener( this );
convertLabel -> addPointerListener( this );
exitLabel -> addPointerListener( this );*/
mainLayout -> add( celLabel );
mainLayout -> add( fahLabel );
mainLayout -> add( convertLabel );
mainLayout -> add( exitLabel );
}
};
class TemperatureMoblet : public Moblet
{
public:
TemperatureMoblet()
{
instance = new TemperatureScreen();
instance -> show();
}
~TemperatureMoblet()
{
delete instance;
}
void keyPressEvent(int keyCode, int nativeCode)
{
// todo: handle key presses
printf( "Blah" );
}
void keyReleaseEvent(int keyCode, int nativeCode)
{
// todo: handle key releases
}
private:
TemperatureScreen *instance;
};
extern "C" int MAMain()
{
Moblet::run(new TemperatureMoblet());
return 0;
};
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间MAUtil;
使用名称空间毛伊岛;
类TemperatureScreen:public Screen/,public Pointer Listener
{
公众:
温度屏幕()
{
MAExtent screenDim=maGetScrSize();
布局*主布局=新布局(0,0,区段X(屏幕尺寸),区段Y(屏幕尺寸),空,1,3);
ListBox*mainListBox=新的ListBox(0,0,100,200,mainLayout,
列表框::LBO_垂直,列表框::LBA_线性,
正确的);
mainListBox->setPaddingLeft(10);
mainListBox->setPaddingRight(10);
mainListBox->setPaddingTop(10);
主列表框->设置填充底部(10);
mainListBox->setBackgroundColor(900);
主布局->收进背景颜色(300);
标签*单元标签=新标签(10、300、50、20、主布局);
标签*fahLabel=新标签(10、300、50、20,主布局);
EditBox*celEdit=新的EditBox(10,300,50,20,主布局);
EditBox*fahEdit=新的EditBox(10,300,50,20,主布局);
标签*toCelsiusRb=新标签(10、300、50、20,主布局);
标签*toFahRb=新标签(10、300、50、20,主布局);
标签*convertLabel=新标签(10、300、50、20,主布局);
标签*exitLabel=新标签(10、300、50、20、主布局);
celLabel->setCaption(“Celcius”);
华氏标签->设置标题(“华氏”);
convertLabel->setCaption(“转换”);
exitLabel->setCaption(“退出”);
/*celLabel->addPointerListener(此);
fahLabel->addPointerListener(此);
convertLabel->addPointerListener(此);
exitLabel->addPointerListener(此)*/
主布局->添加(单元标签);
主布局->添加(标签);
主布局->添加(转换标签);
主布局->添加(exitLabel);
}
};
类TemperatureMoblet:公共Moblet
{
公众:
温度气泡()
{
实例=新的TemperatureScreen();
实例->显示();
}
~TemperatureMoblet()
{
删除实例;
}
无效按键事件(int keyCode,int nativeCode)
{
//todo:处理按键操作
printf(“废话”);
}
无效密钥释放事件(int-keyCode,int-nativeCode)
{
//todo:处理密钥释放
}
私人:
TemperatureScreen*实例;
};
外部“C”int MAMain()
{
Moblet::run(新的TemperatureMoblet());
返回0;
};
尝试将maUpdateScreen()放在计时器事件或键侦听器中,看看会发生什么
如果你需要更多的帮助,就给我回电话
您可以在以下位置尝试mosync的新版本2.6:
/托尼