Any1 can help me solve this problem?

16 posts / 0 new
Last post
0900743F@student....
0900743F@student.tp.edu.sg's picture
Offline
Joined: 27 Apr 2011
Posts:
Any1 can help me solve this problem?

thiss is my coding for the error : please help me thanks !

Util.h

#ifndef _UTIL_H_
#define _UTIL_H_

#include
#include
#include
#include

using namespace MAUI;

#define PADDING 5

void setLabelPadding(Widget *w);
Label* createLabel(const char *str, int height=32);
Widget* createSoftKeyBar(int height, const char *left, const char *right);
Layout* createMainLayout(const char *left, const char *right);

extern Font *gFont;
extern WidgetSkin *gSkin;
extern int scrWidth;
extern int scrHeight;

#endif //_UTIL_H_

login.cpp

#include "login.h"
#include "Util.h"
#include

EditBoxScreen::EditBoxScreen(Screen *previous) : previous(previous) {
mainLayout = createMainLayout("", "Back");
listBox = (ListBox*) mainLayout->getChildren()[0];

Label *label;
EditBox *editBox;

label = createLabel("single line", 64);
editBox = new EditBox(0, 24, label->getWidth()-PADDING*2, 64-24-PADDING*2, label, "", 0, gFont, true, false);
editBox->setDrawBackground(false);
label->addWidgetListener(this);
listBox->add(label);

label = createLabel("multi line input", 128);
editBox = new EditBox(0, 24, label->getWidth()-PADDING*2, 128-24-PADDING*2, label, "", 0, gFont, true, true, 512);
editBox->setDrawBackground(false);
label->addWidgetListener(this);
listBox->add(label);

label = createLabel("number input", 64);
editBox = new EditBox(0, 24, label->getWidth()-PADDING*2, 64-24-PADDING*2, label, "", 0, gFont, true, false, 64, EditBox::IM_NUMBERS);
editBox->setDrawBackground(false);
label->addWidgetListener(this);
listBox->add(label);

softKeys = mainLayout->getChildren()[1];

this->setMain(mainLayout);
}

EditBoxScreen::~EditBoxScreen() {
}

void EditBoxScreen::selectionChanged(Widget *widget, bool selected) {
if(selected) {
widget->getChildren()[0]->setSelected(true);
} else {
widget->getChildren()[0]->setSelected(false);
}
}

void EditBoxScreen::show() {
listBox->getChildren()[Box->getSelectedIndex()]->setSelected(true);
Screen::show();
}

void EditBoxScreen::hide() {
listBox->getChildren()[Box->getSelectedIndex()]->setSelected(false);
Screen::hide();
}

void EditBoxScreen::keyPressEvent(int keyCode, int nativeCode) {
switch(keyCode) {
case MAK_UP:
listBox->selectPreviousItem();
break;
case MAK_DOWN:
listBox->selectNextItem();
break;
case MAK_SOFTRIGHT:
previous->show();
break;
}
}

void EditBoxScreen::pointerPressEvent(MAPoint2d point) {
Point p;
p.set(point.x, point.y);
if(listBox->contains(p)) {
for(int i = 0; i < listBox->getChildren().size(); i++) {
if(listBox->getChildren()[i]->contains(p)) {
listBox->setSelectedIndex(i);
break;
}
}
}
else if(softKeys->contains(p)) {
if(softKeys->getChildren()[0]->contains(p)) {
// Do nothing
}
else if(softKeys->getChildren()[1]->contains(p)) {
keyPressEvent(MAK_SOFTRIGHT, 0);
}
}
}

void EditBoxScreen::pointerReleaseEvent(MAPoint2d point) {
}

main.cpp

#include "main.h"

#include "login.h"

#include "Util.h"

#include

MyMoblet *moblet;

MainScreen::MainScreen() {

screens.add(new EditBoxScreen(this));

layout = createMainLayout("Select", "Exit");
listBox = (ListBox*) layout->getChildren()[0];

listBox->add(createLabel("Label / ListBox"));
listBox->add(createLabel("Image"));
listBox->add(createLabel("EditBox"));
listBox->add(createLabel("Layout"));
listBox->add(createLabel("Custom"));

softKeys = layout->getChildren()[1];

this->setMain(layout);
}

MainScreen::~MainScreen() {
delete layout;
for(int i = 0; i < screens.size(); i++) delete screens[i];
}

void MainScreen::keyPressEvent(int keyCode, int nativeCode) {
switch(keyCode) {
case MAK_UP:
listBox->selectPreviousItem();
break;
case MAK_DOWN:
listBox->selectNextItem();
break;
case MAK_FIRE:
case MAK_SOFTLEFT:
{
int index = listBox->getSelectedIndex();
if(index == screens.size()+1) {
moblet->closeEvent();
moblet->close();
}
else
screens

->show();
}
break;
case MAK_SOFTRIGHT:
moblet->closeEvent();
moblet->close();
break;
}
}

void MainScreen::pointerPressEvent(MAPoint2d point) {
Point p;
p.set(point.x, point.y);
if(listBox->contains(p)) {
for(int i = 0; i < listBox->getChildren().size(); i++) {
if(listBox->getChildren()[i]->contains(p)) {
int index = listBox->getSelectedIndex();
if(index == i) {
keyPressEvent(MAK_FIRE, 0);
}
else {
listBox->setSelectedIndex(i);
}
break;
}
}
}
else if(softKeys->contains(p)) {
if(softKeys->getChildren()[0]->contains(p)) {
keyPressEvent(MAK_SOFTLEFT, 0);
}
else if(softKeys->getChildren()[1]->contains(p)) {
keyPressEvent(MAK_SOFTRIGHT, 0);
}
}
}

void MainScreen::pointerReleaseEvent(MAPoint2d point) {
}

void MyMoblet::keyPressEvent(int keyCode, int nativeCode) {
}

void MyMoblet::keyReleaseEvent(int keyCode, int nativeCode) {
}

void MyMoblet::closeEvent() {
// do destruction here
delete mainScreen;
}

MyMoblet::MyMoblet() {
gFont = new MAUI::Font(RES_FONT);
gSkin = new WidgetSkin(RES_SELECTED, RES_UNSELECTED, 16, 32, 16, 32, true, true);
Engine& engine = Engine::getSingleton();
engine.setDefaultFont(gFont);
engine.setDefaultSkin(gSkin);

MAExtent screenSize = maGetScrSize();
scrWidth = EXTENT_X(screenSize);
scrHeight = EXTENT_Y(screenSize);
mainScreen = new MainScreen();
mainScreen->show();

}

extern "C" int MAMain() {
moblet = new MyMoblet();
MyMoblet::run(moblet);
return 0;
}
[/]

[/]

AttachmentSize
Error!.jpg310.36 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Sorry, I can't effectively read your code like this. Can you post it again, with the syntax highlighter? To do this, click 'Enable rich-text' beneath the space where you type your question. When the icons appear, click the icon which looks like a yellow pen. This will popup a box. Paste your code into that box, and select Insert. Thanks

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hi, I've deleted the last couple of reposts because they weren't readable still, sorry.

Can you post them again using the Syntax Highlighter? 

 

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

Hi my friend asked me to post u this

#include "main.h"
#include "login.h"
#include "Util.h"

#include <conprint.h>

MyMoblet *moblet;

MainScreen::MainScreen() {

	screens.add(new EditBoxScreen(this));


	layout = createMainLayout("Select", "Exit");
	listBox = (ListBox*) layout->getChildren()[0];

	listBox->add(createLabel("Label / ListBox"));
	listBox->add(createLabel("Image"));
	listBox->add(createLabel("EditBox"));
	listBox->add(createLabel("Layout"));
	listBox->add(createLabel("Custom"));

	softKeys = layout->getChildren()[1];

	this->setMain(layout);
}

MainScreen::~MainScreen() {
	delete layout;
	for(int i = 0; i < screens.size(); i++) delete screens[i];
}

void MainScreen::keyPressEvent(int keyCode, int nativeCode) {
	switch(keyCode) {
	case MAK_UP:
		listBox->selectPreviousItem();
		break;
	case MAK_DOWN:
		listBox->selectNextItem();
		break;
	case MAK_FIRE:
	case MAK_SOFTLEFT:
		{
			int index = listBox->getSelectedIndex();
			if(index == screens.size()+1) {
				moblet->closeEvent();
				moblet->close();
			}
			else
				screens
->show(); } break; case MAK_SOFTRIGHT: moblet->closeEvent(); moblet->close(); break; } } void MainScreen::pointerPressEvent(MAPoint2d point) { Point p; p.set(point.x, point.y); if(listBox->contains(p)) { for(int i = 0; i < listBox->getChildren().size(); i++) { if(listBox->getChildren()[i]->contains(p)) { int index = listBox->getSelectedIndex(); if(index == i) { keyPressEvent(MAK_FIRE, 0); } else { listBox->setSelectedIndex(i); } break; } } } else if(softKeys->contains(p)) { if(softKeys->getChildren()[0]->contains(p)) { keyPressEvent(MAK_SOFTLEFT, 0); } else if(softKeys->getChildren()[1]->contains(p)) { keyPressEvent(MAK_SOFTRIGHT, 0); } } } void MainScreen::pointerReleaseEvent(MAPoint2d point) { } void MyMoblet::keyPressEvent(int keyCode, int nativeCode) { } void MyMoblet::keyReleaseEvent(int keyCode, int nativeCode) { } void MyMoblet::closeEvent() { // do destruction here delete mainScreen; } MyMoblet::MyMoblet() { gFont = new MAUI::Font(RES_FONT); gSkin = new WidgetSkin(RES_SELECTED, RES_UNSELECTED, 16, 32, 16, 32, true, true); Engine& engine = Engine::getSingleton(); engine.setDefaultFont(gFont); engine.setDefaultSkin(gSkin); MAExtent screenSize = maGetScrSize(); scrWidth = EXTENT_X(screenSize); scrHeight = EXTENT_Y(screenSize); mainScreen = new MainScreen(); mainScreen->show(); } extern "C" int MAMain() { moblet = new MyMoblet(); MyMoblet::run(moblet); return 0; }
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

OK, this looks like main.cpp? The errors in main.cpp are based around resources (e.g. RES_FONT was not declared in this scope). This is because the resource has probably been created in res.lst, but MAHeaders.h hasn't been included in this code. Simply add this line with the other #includes at the top of the code

#include "MAHeaders.h"

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

I can't fix the login problems without seeing some code for it.

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

hi sam which code u need?

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

after #include "MAHeaders.h" it shows this

Untitled.png
insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

this is the login.cpp just now above is main.cpp


 

#include "login.h"
#include "Util.h"
#include <MAUI/EditBox.h>
#include <MAUI/Label.h>

EditBoxScreen::EditBoxScreen(Screen *previous) : previous(previous) {
	mainLayout = createMainLayout("", "Back");
	listBox = (ListBox*) mainLayout->getChildren()[0];

	Label *label;
	EditBox *editBox;

	label = createLabel("single line", 64);
	editBox = new EditBox(0, 24, label->getWidth()-PADDING*2, 64-24-PADDING*2, label, "", 0, gFont, true, false);
	editBox->setDrawBackground(false);
	label->addWidgetListener(this);
	listBox->add(label);

	label = createLabel("multi line input", 128);
	editBox = new EditBox(0, 24, label->getWidth()-PADDING*2, 128-24-PADDING*2, label, "", 0, gFont, true, true, 512);
	editBox->setDrawBackground(false);
	label->addWidgetListener(this);
	listBox->add(label);

	label = createLabel("number input", 64);
	editBox = new EditBox(0, 24, label->getWidth()-PADDING*2, 64-24-PADDING*2, label, "", 0, gFont, true, false, 64, EditBox::IM_NUMBERS);
	editBox->setDrawBackground(false);
	label->addWidgetListener(this);
	listBox->add(label);

	softKeys = mainLayout->getChildren()[1];

	this->setMain(mainLayout);
}

EditBoxScreen::~EditBoxScreen() {
}

void EditBoxScreen::selectionChanged(Widget *widget, bool selected) {
	if(selected) {
		widget->getChildren()[0]->setSelected(true);
	} else {
		widget->getChildren()[0]->setSelected(false);
	}
}

void EditBoxScreen::show() {
	listBox->getChildren()[Box->getSelectedIndex()]->setSelected(true);
	Screen::show();
}

void EditBoxScreen::hide() {
	listBox->getChildren()[Box->getSelectedIndex()]->setSelected(false);
	Screen::hide();
}

void EditBoxScreen::keyPressEvent(int keyCode, int nativeCode) {
	switch(keyCode) {
			case MAK_UP:
				listBox->selectPreviousItem();
				break;
			case MAK_DOWN:
				listBox->selectNextItem();
				break;
			case MAK_SOFTRIGHT:
				previous->show();
				break;
	}
}

void EditBoxScreen::pointerPressEvent(MAPoint2d point) {
	Point p;
	p.set(point.x, point.y);
	if(listBox->contains(p)) {
		for(int i = 0; i < listBox->getChildren().size(); i++) {
			if(listBox->getChildren()[i]->contains(p)) {
				listBox->setSelectedIndex(i);
				break;
			}
		}
	}
	else if(softKeys->contains(p)) {
		if(softKeys->getChildren()[0]->contains(p)) {
			// Do nothing
		}
		else if(softKeys->getChildren()[1]->contains(p)) {
			keyPressEvent(MAK_SOFTRIGHT, 0);
		}
	}
}

void EditBoxScreen::pointerReleaseEvent(MAPoint2d point) {
}

[/]

[/]

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:
#ifndef _UTIL_H_
#define _UTIL_H_

#include <MAUI/Widget.h>
#include <MAUI/Label.h>
#include <MAUI/Layout.h>
#include <MAUI/Font.h>

using namespace MAUI;

#define PADDING 5

void setLabelPadding(Widget *w);
Label* createLabel(const char *str, int height=32);
Widget* createSoftKeyBar(int height, const char *left, const char *right);
Layout* createMainLayout(const char *left, const char *right);

extern Font *gFont;
extern WidgetSkin *gSkin;
extern int scrWidth;
extern int scrHeight;

#endif	//_UTIL_H_

this is Util.h having a error also

Untitled.png
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:
insert wrote:

after #include "MAHeaders.h" it shows this

Ok, right-click your project and select 'Rebuild'. If you still get this screen, then it is because you're not looking at the console. Have a look at the errors in the console, as I think that the resources aren't being added correctly.

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

after rebuild it shows this

Untitled.png Untitled.png
Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Have you created a new project from scratch, or did you copy the MAUIex example? It looks like you may have created a new project, and not selected the MAUI option. Its not a problem to fix it though. Have a look at this thread. Your project should include MAUtil.lib and MAUI.lib

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

so how do i include those? sry am new to this

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Sorry, its my fault, I meant to give you this link http://www.mosync.com/content/unresolved-symbol-error-crtlibs - it shows you how to do it.

insert
insert's picture
Offline
Joined: 3 May 2011
Posts:

i have checked i do have it both of them but the problem still there