keep position between select file windows session
This commit is contained in:
parent
ccfd6516fb
commit
125636e29f
3 changed files with 52 additions and 27 deletions
|
@ -18,7 +18,7 @@ How to compile on Raspbian:
|
||||||
You need to install gcc-4.8 (or edit Makefile) and install some dev package.
|
You need to install gcc-4.8 (or edit Makefile) and install some dev package.
|
||||||
In order to do this enter the following in command line:
|
In order to do this enter the following in command line:
|
||||||
|
|
||||||
sudo apt-get install gcc-4.8
|
sudo apt-get install g++-4.8
|
||||||
sudo apt-get install libsdl1.2-dev
|
sudo apt-get install libsdl1.2-dev
|
||||||
sudo apt-get install libsdl-gfx1.2-dev
|
sudo apt-get install libsdl-gfx1.2-dev
|
||||||
sudo apt-get install libsdl-ttf2.0-dev
|
sudo apt-get install libsdl-ttf2.0-dev
|
||||||
|
|
|
@ -84,8 +84,8 @@ static FilesysHardfileActionListener* filesysHardfileActionListener;
|
||||||
|
|
||||||
static void InitEditFilesysHardfile(void)
|
static void InitEditFilesysHardfile(void)
|
||||||
{
|
{
|
||||||
wndEditFilesysHardfile = new gcn::Window("Edit");
|
wndEditFilesysHardfile = new gcn::Window("Edit");
|
||||||
wndEditFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
wndEditFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||||
wndEditFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
wndEditFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||||
wndEditFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
|
wndEditFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
|
||||||
wndEditFilesysHardfile->setCaption("Volume settings");
|
wndEditFilesysHardfile->setCaption("Volume settings");
|
||||||
|
@ -93,16 +93,16 @@ static void InitEditFilesysHardfile(void)
|
||||||
|
|
||||||
filesysHardfileActionListener = new FilesysHardfileActionListener();
|
filesysHardfileActionListener = new FilesysHardfileActionListener();
|
||||||
|
|
||||||
cmdOK = new gcn::Button("Ok");
|
cmdOK = new gcn::Button("Ok");
|
||||||
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||||
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||||
cmdOK->setId("hdfOK");
|
cmdOK->setId("hdfOK");
|
||||||
cmdOK->addActionListener(filesysHardfileActionListener);
|
cmdOK->addActionListener(filesysHardfileActionListener);
|
||||||
|
|
||||||
cmdCancel = new gcn::Button("Cancel");
|
cmdCancel = new gcn::Button("Cancel");
|
||||||
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||||
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||||
cmdCancel->setId("hdfCancel");
|
cmdCancel->setId("hdfCancel");
|
||||||
cmdCancel->addActionListener(filesysHardfileActionListener);
|
cmdCancel->addActionListener(filesysHardfileActionListener);
|
||||||
|
@ -114,7 +114,7 @@ static void InitEditFilesysHardfile(void)
|
||||||
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
|
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
|
||||||
txtDevice->setId("hdfDev");
|
txtDevice->setId("hdfDev");
|
||||||
|
|
||||||
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
|
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
|
||||||
chkReadWrite->setId("hdfRW");
|
chkReadWrite->setId("hdfRW");
|
||||||
|
|
||||||
lblBootPri = new gcn::Label("Boot priority:");
|
lblBootPri = new gcn::Label("Boot priority:");
|
||||||
|
@ -331,10 +331,8 @@ bool EditFilesysHardfile(int unit_no)
|
||||||
txtSectors->setText("32");
|
txtSectors->setText("32");
|
||||||
txtBlocksize->setText("512");
|
txtBlocksize->setText("512");
|
||||||
}
|
}
|
||||||
|
|
||||||
EditFilesysHardfileLoop();
|
EditFilesysHardfileLoop();
|
||||||
ExitEditFilesysHardfile();
|
ExitEditFilesysHardfile();
|
||||||
|
|
||||||
if(dialogResult)
|
if(dialogResult)
|
||||||
{
|
{
|
||||||
if(unit_no >= 0)
|
if(unit_no >= 0)
|
||||||
|
@ -347,6 +345,5 @@ bool EditFilesysHardfile(int unit_no)
|
||||||
atoi(txtReserved->getText().c_str()), atoi(txtBlocksize->getText().c_str()),
|
atoi(txtReserved->getText().c_str()), atoi(txtBlocksize->getText().c_str()),
|
||||||
atoi(txtBootPri->getText().c_str()), 0, 0);
|
atoi(txtBootPri->getText().c_str()), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dialogResult;
|
return dialogResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
#define DIALOG_WIDTH 520
|
#define DIALOG_WIDTH 520
|
||||||
#define DIALOG_HEIGHT 400
|
#define DIALOG_HEIGHT 400
|
||||||
|
|
||||||
|
#ifdef RASPBERRY
|
||||||
|
#define FILE_SELECT_KEEP_POSITION
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool dialogResult = false;
|
static bool dialogResult = false;
|
||||||
static bool dialogFinished = false;
|
static bool dialogFinished = false;
|
||||||
static char workingDir[MAX_PATH];
|
static char workingDir[MAX_PATH];
|
||||||
|
@ -153,8 +157,8 @@ static SelectFileActionListener* selectFileActionListener;
|
||||||
|
|
||||||
static void InitSelectFile(const char *title)
|
static void InitSelectFile(const char *title)
|
||||||
{
|
{
|
||||||
wndSelectFile = new gcn::Window("Load");
|
wndSelectFile = new gcn::Window("Load");
|
||||||
wndSelectFile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
wndSelectFile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
|
||||||
wndSelectFile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
wndSelectFile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
|
||||||
wndSelectFile->setBaseColor(gui_baseCol + 0x202020);
|
wndSelectFile->setBaseColor(gui_baseCol + 0x202020);
|
||||||
wndSelectFile->setCaption(title);
|
wndSelectFile->setCaption(title);
|
||||||
|
@ -162,15 +166,15 @@ static void InitSelectFile(const char *title)
|
||||||
|
|
||||||
fileButtonActionListener = new FileButtonActionListener();
|
fileButtonActionListener = new FileButtonActionListener();
|
||||||
|
|
||||||
cmdOK = new gcn::Button("Ok");
|
cmdOK = new gcn::Button("Ok");
|
||||||
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||||
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||||
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
cmdOK->setBaseColor(gui_baseCol + 0x202020);
|
||||||
cmdOK->addActionListener(fileButtonActionListener);
|
cmdOK->addActionListener(fileButtonActionListener);
|
||||||
|
|
||||||
cmdCancel = new gcn::Button("Cancel");
|
cmdCancel = new gcn::Button("Cancel");
|
||||||
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
|
||||||
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
|
||||||
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
|
||||||
cmdCancel->addActionListener(fileButtonActionListener);
|
cmdCancel->addActionListener(fileButtonActionListener);
|
||||||
|
|
||||||
|
@ -201,10 +205,9 @@ static void InitSelectFile(const char *title)
|
||||||
wndSelectFile->add(scrAreaFiles);
|
wndSelectFile->add(scrAreaFiles);
|
||||||
|
|
||||||
gui_top->add(wndSelectFile);
|
gui_top->add(wndSelectFile);
|
||||||
|
|
||||||
lstFiles->requestFocus();
|
lstFiles->requestFocus();
|
||||||
lstFiles->setSelected(0);
|
|
||||||
wndSelectFile->requestModalFocus();
|
wndSelectFile->requestModalFocus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,22 +297,47 @@ static void SelectFileLoop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FILE_SELECT_KEEP_POSITION
|
||||||
|
static int Already_init = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
bool SelectFile(const char *title, char *value, const char *filter[])
|
bool SelectFile(const char *title, char *value, const char *filter[])
|
||||||
{
|
{
|
||||||
dialogResult = false;
|
dialogResult = false;
|
||||||
dialogFinished = false;
|
dialogFinished = false;
|
||||||
filefilter = filter;
|
filefilter = filter;
|
||||||
|
|
||||||
InitSelectFile(title);
|
|
||||||
|
#ifdef FILE_SELECT_KEEP_POSITION
|
||||||
|
if (Already_init == 0)
|
||||||
|
{
|
||||||
|
InitSelectFile(title);
|
||||||
|
Already_init = 1;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
strncpy(value,workingDir,MAX_PATH);
|
||||||
|
wndSelectFile->setCaption(title);
|
||||||
|
wndSelectFile->requestModalFocus();
|
||||||
|
wndSelectFile->setVisible(true);
|
||||||
|
gui_top->moveToTop(wndSelectFile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extractPath(value, workingDir);
|
extractPath(value, workingDir);
|
||||||
checkfoldername(workingDir);
|
checkfoldername(workingDir);
|
||||||
checkfilename(value);
|
checkfilename(value);
|
||||||
|
|
||||||
SelectFileLoop();
|
SelectFileLoop();
|
||||||
|
#ifdef FILE_SELECT_KEEP_POSITION
|
||||||
|
wndSelectFile->releaseModalFocus();
|
||||||
|
wndSelectFile->setVisible(false);
|
||||||
|
#else
|
||||||
ExitSelectFile();
|
ExitSelectFile();
|
||||||
|
#endif
|
||||||
if(dialogResult)
|
if(dialogResult)
|
||||||
strncpy(value, workingDir, MAX_PATH);
|
strncpy(value, workingDir, MAX_PATH);
|
||||||
|
#ifdef FILE_SELECT_KEEP_POSITION
|
||||||
|
else
|
||||||
|
strncpy(workingDir,value, MAX_PATH);
|
||||||
|
#endif
|
||||||
return dialogResult;
|
return dialogResult;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue