New key page in GUI

svn-id: r4042
This commit is contained in:
Nicolas Bacca 2002-04-21 21:54:08 +00:00
parent 4b6012a0a1
commit 0e102853cb
4 changed files with 91 additions and 53 deletions

View file

@ -11,7 +11,8 @@ enum ActionType {
ACTION_HIDE = 5,
ACTION_KEYBOARD = 6,
ACTION_SOUND = 7,
ACTION_RIGHTCLICK = 8
ACTION_RIGHTCLICK = 8,
ACTION_CURSOR = 9
};
struct oneAction {
@ -20,8 +21,8 @@ struct oneAction {
};
#define NUMBER_ACTIONS 5
#define TOTAL_ACTIONS 8
#define NUMBER_ACTIONS 10
#define TOTAL_ACTIONS 9
#define GAPI_KEY_BASE 1000
#define GAPI_KEY_VKA 1
@ -32,6 +33,10 @@ struct oneAction {
#define GAPI_KEY_CONTACTS 6
#define GAPI_KEY_INBOX 7
#define GAPI_KEY_ITASK 8
#define GAPI_KEY_VKUP 9
#define GAPI_KEY_VKDOWN 10
#define GAPI_KEY_VKLEFT 11
#define GAPI_KEY_VKRIGHT 12
#define INTERNAL_KEY_CALENDAR 0xc1
#define INTERNAL_KEY_CONTACTS 0xc2

83
gui.cpp
View file

@ -27,7 +27,7 @@
#include "guimaps.h"
#ifdef _WIN32_WCE
// Additional variables for Win32 specific GUI
// Additional variables for WinCE specific GUI
#include "gapi_keys.h"
extern bool toolbar_drawn;
extern bool draw_keyboard;
@ -35,6 +35,7 @@ extern bool get_key_mapping;
extern struct keyops keyMapping;
extern void registry_save(void);
uint16 _key_mapping_required;
uint16 _current_page;
#else
#define registry_save() ;
bool get_key_mapping;
@ -190,12 +191,19 @@ void Gui::drawWidget(const GuiWidget * w)
#ifdef _WIN32_WCE
case GUI_KEYTEXT:
strcpy(text,
getGAPIKeyName(getAction(w->_string_number - 1)->action_key));
getGAPIKeyName(getAction((_current_page * 5) + w->_string_number - 1)->action_key));
break;
case GUI_ACTIONTEXT:
strcpy(text,
getActionName(getAction(w->_string_number - 1)->action_type));
getActionName(getAction((_current_page * 5) + w->_string_number - 1)->action_type));
break;
case GUI_NEXTTEXT:
if (_current_page == 0)
strcpy(text, "Next");
else
strcpy(text, "Prev");
break;
#endif
}
@ -364,48 +372,37 @@ const GuiWidget keys_dialog[] = {
// First action
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10, 15, 15, 10, 3}, // CUSTOMTEXT_PLUS
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10, 15, 15, 11, 4}, // CUSTOMTEXT_MINUS
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 11 + 33 + 10, 10 + 10, 100, 15, 100,
1},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 11 + 33 + 10, 10 + 10, 100, 15, 100, 1},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 3, 100, 15, 1, 1},
//Second action
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5, 15, 15, 20, 3}, // CUSTOMTEXT_PLUS
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5, 15, 15, 21, 4}, // CUSTOMTEXT_MINUS
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5, 100,
15, 101, 2},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 3, 100, 15, 2,
2},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5, 100, 15, 101, 2},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 3, 100, 15, 2, 2},
//Third action
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5, 15, 15, 30, 3},// CUSTOMTEXT_PLUS
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5, 15, 15, 31, 4}, // CUSTOMTEXT_MINUS
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10,
10 + 10 + 15 + 5 + 15 + 5, 100, 15, 102, 3},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 3,
100, 15, 3, 3},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5, 100, 15, 102, 3},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 3, 100, 15, 3, 3},
//Fourth action
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 40, 3},
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 41, 4},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15, 103, 4},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100, 15, 4, 4},
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 40, 3},
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 41, 4},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15, 103, 4},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100, 15, 4, 4},
//Fifth action
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 50, 3},
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 51, 4},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15, 104, 5},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120,
10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100, 15, 5, 5},
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 50, 3},
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 51, 4},
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15, 104, 5},
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100, 15, 5, 5},
//OK
{GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 113, 10 + 106, 54, 16, 60, 9},
{GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 60, 10 + 106, 54, 16, 60, 9 },
//Previous-Next
{GUI_NEXTTEXT, 0x01, GWF_BUTTON, 30 + 120, 10 + 106, 54, 16, 61, 0 },
{0,0,0,0,0,0,0,0,0}
};
@ -551,15 +548,16 @@ void Gui::handleKeysDialogCommand(int cmd)
if (cmd < 100 && cmd != 60) {
if ((cmd % 10) == 1)
setNextType((cmd / 10) - 1);
setNextType((_current_page * 5) + (cmd / 10) - 1);
else
setPreviousType((cmd / 10) - 1);
setPreviousType((_current_page * 5) + (cmd / 10) - 1);
draw(0, 200);
return;
}
if (cmd >= 100)
_key_mapping_required = cmd;
if (cmd == 60) {
@ -567,6 +565,16 @@ void Gui::handleKeysDialogCommand(int cmd)
registry_save();
close();
}
if (cmd == 61) {
if (!_current_page)
_current_page = 1;
else
_current_page = 0;
draw(0, 200);
return;
}
#else
close();
#endif
@ -574,7 +582,7 @@ void Gui::handleKeysDialogCommand(int cmd)
void Gui::handleLauncherDialogCommand(int cmd)
{
printf("handle launcher command\n");
debug(9, "handle launcher command\n");
switch (cmd) {
case 20:
close();
@ -589,10 +597,10 @@ void Gui::handleLauncherDialogCommand(int cmd)
_return_to = LAUNCHER_DIALOG;
_dialog = ABOUT_DIALOG;
draw(0, 100);
printf("about dialog\n");
debug(9, "about dialog\n");
break;
default:
printf("default\n");
debug(9, "default\n");
close();
}
}
@ -805,7 +813,7 @@ void Gui::addLetter(byte letter)
case KEYS_DIALOG:
clearActionKey(letter);
if (_key_mapping_required)
getAction(_key_mapping_required - 100)->action_key = letter;
getAction((_current_page * 5) + _key_mapping_required - 100)->action_key = letter;
_key_mapping_required = 0;
draw(0, 200);
break;
@ -901,6 +909,9 @@ void Gui::pause()
void Gui::options()
{
#ifdef _WIN32_WCE
_current_page = 0;
#endif
_widgets[0] = options_dialog;
_active = true;
_cur_page = 0;

4
gui.h
View file

@ -35,7 +35,8 @@ enum {
GUI_VARTEXT = 5,
GUI_ACTIONTEXT = 6,
GUI_KEYTEXT = 7,
GUI_SCROLLTEXT = 8
GUI_SCROLLTEXT = 8,
GUI_NEXTTEXT = 9
};
enum {
@ -45,7 +46,6 @@ enum {
GWF_DELAY = 8,
GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
};
struct GuiWidget {

View file

@ -18,6 +18,7 @@ struct GXKeyList _keys;
pAction *_action_functions;
const char* ActionsText[] = {
"None",
"Pause",
"Save",
"Quit",
@ -25,7 +26,8 @@ const char* ActionsText[] = {
"Hide",
"Keyboard",
"Sound",
"Right click"
"Right click",
"Cursor on/off"
};
bool _typeExists(int x) {
@ -40,7 +42,7 @@ bool _typeExists(int x) {
const char* getActionName(int action) {
return ActionsText[action - 1];
return ActionsText[action];
}
void GAPIKeysInit(pAction *functions) {
@ -84,6 +86,18 @@ const unsigned char getGAPIKeyMapping(short key) {
if (key == _keys.vkStart)
return GAPI_KEY_VKSTART;
if (key == _keys.vkUp)
return GAPI_KEY_VKUP;
if (key == _keys.vkDown)
return GAPI_KEY_VKDOWN;
if (key == _keys.vkLeft)
return GAPI_KEY_VKLEFT;
if (key == _keys.vkRight)
return GAPI_KEY_VKRIGHT;
switch (key) {
// then the "unsupported" keys
case INTERNAL_KEY_CALENDAR:
@ -117,6 +131,14 @@ const char* getGAPIKeyName(unsigned char key) {
return "Button Inbox";
case GAPI_KEY_ITASK:
return "Button ITask";
case GAPI_KEY_VKUP:
return "Pad Up";
case GAPI_KEY_VKDOWN:
return "Pad Down";
case GAPI_KEY_VKLEFT:
return "Pad Left";
case GAPI_KEY_VKRIGHT:
return "Pad Right";
default:
return "Not mapped";
}