mirror of
https://github.com/jfdelnero/HxCFloppyEmulator.git
synced 2026-07-28 04:06:36 +00:00
parameters window.
git-svn-id: svn://svn.code.sf.net/p/hxcfloppyemu/code/HxCFloppyEmulator/HxCFloppyEmulator_software/trunk@1823 63fa2f70-6a9b-4bc4-b855-9c6a949b1d69
This commit is contained in:
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
//
|
||||
// Copyright (C) 2006-2019 Jean-François DEL NERO
|
||||
//
|
||||
// This file is part of HxCFloppyEmulator.
|
||||
//
|
||||
// HxCFloppyEmulator may be used and distributed without restriction provided
|
||||
// that this copyright statement is not removed from the file and that any
|
||||
// derivative work contains the original copyright notice and the associated
|
||||
// disclaimer.
|
||||
//
|
||||
// HxCFloppyEmulator is free software; you can redistribute it
|
||||
// and/or modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// HxCFloppyEmulator is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with HxCFloppyEmulator; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
//-------------------------------------------------------------------------------//
|
||||
//-------------------------------------------------------------------------------//
|
||||
//-----------H----H--X----X-----CCCCC----22222----0000-----0000------11----------//
|
||||
//----------H----H----X-X-----C--------------2---0----0---0----0--1--1-----------//
|
||||
//---------HHHHHH-----X------C----------22222---0----0---0----0-----1------------//
|
||||
//--------H----H----X--X----C----------2-------0----0---0----0-----1-------------//
|
||||
//-------H----H---X-----X---CCCCC-----222222----0000-----0000----1111------------//
|
||||
//-------------------------------------------------------------------------------//
|
||||
//----------------------------------------------------- http://hxc2001.free.fr --//
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// File : parameters.cxx
|
||||
// Contains: Parameters window
|
||||
//
|
||||
// Written by: Jean-François DEL NERO
|
||||
//
|
||||
// Change History (most recent first):
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Double_Window.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <FL/filename.H>
|
||||
#include <FL/Fl_Button.H>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "parameters_gui.h"
|
||||
|
||||
#include "libhxcfe.h"
|
||||
#include "usb_hxcfloppyemulator.h"
|
||||
#include "libhxcadaptor.h"
|
||||
|
||||
#include "main.h"
|
||||
|
||||
extern s_gui_context * guicontext;
|
||||
|
||||
#ifndef WIN32
|
||||
#define _vsnprintf vsnprintf
|
||||
#endif
|
||||
|
||||
void input_cb(Fl_Widget *w, void *v);
|
||||
|
||||
void Parameters_box::delete_editbox()
|
||||
{
|
||||
int i;
|
||||
|
||||
if(editboxarray)
|
||||
{
|
||||
i = 0;
|
||||
while(editboxarray[i].label)
|
||||
{
|
||||
free(editboxarray[i].label);
|
||||
delete editboxarray[i].input;
|
||||
i++;
|
||||
}
|
||||
|
||||
free(editboxarray);
|
||||
|
||||
editboxarray = NULL;
|
||||
|
||||
delete scroll;
|
||||
}
|
||||
}
|
||||
|
||||
void Parameters_box::create_editbox()
|
||||
{
|
||||
char tmp_value[512];
|
||||
char * param_name;
|
||||
int cnt,i;
|
||||
|
||||
scroll = new Fl_Scroll(5,5, xsize - 20, ysize-((10)+35) );
|
||||
|
||||
cnt = 0;
|
||||
while( hxcfe_getEnvVarIndex( guicontext->hxcfe, cnt, NULL) )
|
||||
{
|
||||
cnt++;
|
||||
}
|
||||
|
||||
if(cnt)
|
||||
{
|
||||
editboxarray = (params_editbox *)malloc(sizeof(params_editbox)*(cnt+1));
|
||||
if(!editboxarray)
|
||||
return;
|
||||
|
||||
memset(editboxarray,0,sizeof(params_editbox)*(cnt+1));
|
||||
|
||||
for(i=0;i<cnt;i++)
|
||||
{
|
||||
param_name = hxcfe_getEnvVarIndex( guicontext->hxcfe, i, (char*)&tmp_value);
|
||||
editboxarray[i].label = (char*)malloc(strlen(param_name)+1);
|
||||
if(editboxarray[i].label)
|
||||
{
|
||||
strcpy(editboxarray[i].label,param_name);
|
||||
}
|
||||
editboxarray[i].input = new Fl_Input(xsize/2, 25 + 25*i, 120, 20, editboxarray[i].label);
|
||||
editboxarray[i].input->value(tmp_value);
|
||||
editboxarray[i].input->callback(input_cb);
|
||||
}
|
||||
}
|
||||
|
||||
scroll->end();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void close_parameters(Fl_Widget *w, void * t)
|
||||
{
|
||||
Parameters_box *pb;
|
||||
|
||||
pb = (Parameters_box *)w->parent();
|
||||
w->parent()->hide();
|
||||
|
||||
delete pb;
|
||||
}
|
||||
|
||||
void input_cb(Fl_Widget *w, void *v) {
|
||||
Fl_Input *i = (Fl_Input*)w;
|
||||
hxcfe_setEnvVar( guicontext->hxcfe, (char*)i->label(), (char*)i->value() );
|
||||
}
|
||||
|
||||
Parameters_box::~Parameters_box()
|
||||
{
|
||||
delete_editbox();
|
||||
}
|
||||
|
||||
Parameters_box::Parameters_box()
|
||||
: Fl_Double_Window(640,400)
|
||||
{
|
||||
editboxarray = NULL;
|
||||
|
||||
xsize = 640;
|
||||
ysize = 400;
|
||||
|
||||
create_editbox();
|
||||
|
||||
button_ok = new Fl_Button(5, ysize-35, 80, 30, "Close" );
|
||||
button_ok->callback(close_parameters,0);
|
||||
|
||||
label("Parameters");
|
||||
|
||||
end();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
//
|
||||
// Copyright (C) 2006-2019 Jean-François DEL NERO
|
||||
//
|
||||
// This file is part of HxCFloppyEmulator.
|
||||
//
|
||||
// HxCFloppyEmulator may be used and distributed without restriction provided
|
||||
// that this copyright statement is not removed from the file and that any
|
||||
// derivative work contains the original copyright notice and the associated
|
||||
// disclaimer.
|
||||
//
|
||||
// HxCFloppyEmulator is free software; you can redistribute it
|
||||
// and/or modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 2
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// HxCFloppyEmulator is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
// See the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with HxCFloppyEmulator; if not, write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
//
|
||||
*/
|
||||
|
||||
#include <FL/Fl_Scroll.H>
|
||||
#include <FL/Fl_Input.H>
|
||||
|
||||
|
||||
typedef struct params_editbox_
|
||||
{
|
||||
char * label;
|
||||
Fl_Input * input;
|
||||
}params_editbox;
|
||||
|
||||
class Parameters_box : public Fl_Double_Window {
|
||||
|
||||
Fl_Button *button_ok;
|
||||
Fl_Double_Window *window;
|
||||
int xsize,ysize;
|
||||
|
||||
public:
|
||||
params_editbox * editboxarray;
|
||||
Fl_Scroll * scroll;
|
||||
|
||||
Parameters_box();
|
||||
~Parameters_box();
|
||||
void create_editbox();
|
||||
void delete_editbox();
|
||||
};
|
||||
Reference in New Issue
Block a user