grids ok sous Linux
This commit is contained in:
parent
f5349ddf9e
commit
833f03d495
|
@ -17,7 +17,7 @@
|
|||
|
||||
// Construction
|
||||
//
|
||||
grids::grids(const FONTCHARACTER folder){
|
||||
grids::grids(){
|
||||
index_ = -1; // No file is selected
|
||||
|
||||
//firstFreeID_ = 0; // Folder is empty
|
||||
|
@ -40,7 +40,7 @@ bool grids::nextFile(FONTCHARACTER& fName){
|
|||
}
|
||||
|
||||
// Copy the file name
|
||||
fName = files_[++index_]->fileName;
|
||||
bFile::FC_cpy(fName, files_[++index_]->fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ bool grids::prevFile(FONTCHARACTER& fName){
|
|||
}
|
||||
|
||||
// Copy the file name
|
||||
fName = files_[--index_]->fileName;
|
||||
bFile::FC_cpy(fName, files_[--index_]->fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void grids::_browse(){
|
|||
}
|
||||
|
||||
// Browse folder
|
||||
int shandle;
|
||||
SEARCHHANDLE shandle;
|
||||
struct BFile_FileInfo fileInfo;
|
||||
|
||||
strcpy(szPattern, GRIDS_FOLDER);
|
||||
|
@ -139,7 +139,7 @@ bool grids::_addFile(FONTCHARACTER fileName){
|
|||
|
||||
// fill struct. with file informations
|
||||
if (NULL == (file->fileName = bFile::FC_dup(fileName)) ||
|
||||
-1 == (file->ID = __atoi(fileName))){
|
||||
-1 == (file->ID = __fileName2i(fileName))){
|
||||
free(file);
|
||||
return false; // Unable to copy the filename or invalid name
|
||||
}
|
||||
|
@ -155,6 +155,8 @@ bool grids::_addFile(FONTCHARACTER fileName){
|
|||
|
||||
// __vector_append() : append an file item pointer to the list
|
||||
//
|
||||
// This method automaticaly resizes the list
|
||||
//
|
||||
// @file : pointer to the struct to add to the list
|
||||
//
|
||||
// @return : true if succesfully added
|
||||
|
@ -188,13 +190,12 @@ bool grids::__vector_resize(){
|
|||
count_ = 0;
|
||||
|
||||
cBytes = capacity_ * sizeof(PFNAME);
|
||||
if (NULL == files_){
|
||||
if (NULL == (files_ = (PFNAME*)malloc(cBytes))){
|
||||
capacity_ = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
// list is empty
|
||||
files_ = (PFNAME*)malloc(cBytes);
|
||||
memset(files_, 0x00, cBytes);
|
||||
return true;
|
||||
}
|
||||
|
@ -213,7 +214,7 @@ bool grids::__vector_resize(){
|
|||
return true;
|
||||
}
|
||||
|
||||
// __vector_CLEAR() : clear the list and its content
|
||||
// __vector_clear() : clear the list and its content
|
||||
//
|
||||
void grids::__vector_clear(){
|
||||
PFNAME pFile(NULL);
|
||||
|
@ -238,13 +239,13 @@ void grids::__vector_clear(){
|
|||
// strings utils
|
||||
//
|
||||
|
||||
// __atoi()- Convert a filename (without folder) to int
|
||||
// __fileName2i()- Convert a fully qualified filename to int
|
||||
//
|
||||
// @src : Filename to convert
|
||||
//
|
||||
// @return : numeric value or -1 on error
|
||||
//
|
||||
int grids::__atoi(FONTCHARACTER src){
|
||||
int grids::__fileName2i(FONTCHARACTER src){
|
||||
size_t len;
|
||||
if (0 == (len = bFile::FC_len(src))){
|
||||
return -1;
|
||||
|
@ -257,7 +258,7 @@ int grids::__atoi(FONTCHARACTER src){
|
|||
|
||||
uint8_t sCar(1);
|
||||
#ifdef DEST_CASIO_CALC
|
||||
sCar = 2;
|
||||
sCar = sizeof(uint16_t);
|
||||
#endif // DEST_CASIO_CALC
|
||||
|
||||
// remove path
|
||||
|
@ -272,8 +273,7 @@ int grids::__atoi(FONTCHARACTER src){
|
|||
|
||||
// convert the file name
|
||||
index = 0;
|
||||
while (num >= 0 && buffer[index]){
|
||||
car = buffer[index];
|
||||
while (num >= 0 && (car = buffer[index]) && car != '.'){
|
||||
if (car >= '0' && car <= '9'){
|
||||
num = num * 10 + (car - '0');
|
||||
}
|
||||
|
|
10
src/grids.h
10
src/grids.h
|
@ -28,7 +28,7 @@ class grids{
|
|||
public:
|
||||
|
||||
// Construction
|
||||
grids(const FONTCHARACTER folder);
|
||||
grids();
|
||||
|
||||
// Destruction
|
||||
~grids(){
|
||||
|
@ -96,6 +96,8 @@ private:
|
|||
|
||||
// __vector_append() : append an file item pointer to the list
|
||||
//
|
||||
// This method automaticaly resizes the list
|
||||
//
|
||||
// @file : pointer to the struct to add to the list
|
||||
//
|
||||
// @return : true if succesfully added
|
||||
|
@ -108,7 +110,7 @@ private:
|
|||
//
|
||||
bool __vector_resize();
|
||||
|
||||
// __vector_CLEAR() : clear the list and its content
|
||||
// __vector_clear() : clear the list and its content
|
||||
//
|
||||
void __vector_clear();
|
||||
|
||||
|
@ -116,13 +118,13 @@ private:
|
|||
// strings utils
|
||||
//
|
||||
|
||||
// __atoi()- Convert a filename (without folder) to int
|
||||
// __fileName2i()- Convert a fully qualified filename to int
|
||||
//
|
||||
// @src : Filename to convert
|
||||
//
|
||||
// @return : numeric value or -1 on error
|
||||
//
|
||||
int __atoi(FONTCHARACTER src);
|
||||
int __fileName2i(FONTCHARACTER src);
|
||||
|
||||
// __itoa() : Transform a numeric value into a string
|
||||
//
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
//----------------------------------------------------------------------
|
||||
//--
|
||||
//-- File : bFile.cpp
|
||||
//-- bFile.cpp
|
||||
//--
|
||||
//-- Author : Jérôme Henry-Barnaudière - GeeHB
|
||||
//-- Implementation of bFile object
|
||||
//--
|
||||
//-- Project :
|
||||
//--
|
||||
//----------------------------------------------------------------------
|
||||
//--
|
||||
//-- Description:
|
||||
//--
|
||||
//-- Implementation of bFile object
|
||||
//--
|
||||
//-- This release isn't fully tested.
|
||||
//-- At this time, it's only functionnal for FXCG50 calculator
|
||||
//-- This release isn't fully tested
|
||||
//--
|
||||
//-- Missing :
|
||||
//-- - BFile_Rename
|
||||
//-- - whence in read ops
|
||||
//-- - BFile_Ext_Stat
|
||||
//-- - seek API
|
||||
//--
|
||||
|
@ -38,7 +29,7 @@ bFile::bFile(){
|
|||
fd_ = 0; // no file
|
||||
#else
|
||||
fileName_ = "";
|
||||
dir_ = NULL;
|
||||
folderName_ = "";
|
||||
#endif // #ifdef DEST_CASIO_CALC
|
||||
|
||||
error_ = 0; // no error
|
||||
|
@ -60,7 +51,7 @@ bool bFile::exist(FONTCHARACTER fName){
|
|||
}
|
||||
|
||||
bool exist(false);
|
||||
int handle(0);
|
||||
SEARCHHANDLE handle;
|
||||
#ifdef DEST_CASIO_CALC
|
||||
uint16_t foundFile[BFILE_MAX_PATH+1];
|
||||
#else
|
||||
|
@ -120,7 +111,8 @@ int bFile::size(){
|
|||
bool bFile::open(FONTCHARACTER filename, int access){
|
||||
if (access && !isOpen()){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
fd_ = gint_world_switch(GINT_CALL(BFile_Open, filename, access));
|
||||
fd_ = gint_world_switch(GINT_CALL(BFile_Open,
|
||||
filename, access));
|
||||
if (fd_ < 0){
|
||||
error_ = fd_;
|
||||
fd_ = 0;
|
||||
|
@ -152,7 +144,8 @@ bool bFile::open(FONTCHARACTER filename, int access){
|
|||
//
|
||||
// @filename : name of the file or folder to create (must not exist)
|
||||
// @type : Entry type (BFile_File or BFile_Folder)
|
||||
// @size : Pointer to file size if type is BFile_File, use NULL otherwise
|
||||
// @size : Pointer to file size if type is BFile_File,
|
||||
// use NULL otherwise
|
||||
//
|
||||
// @return : file successfully created ?
|
||||
//
|
||||
|
@ -161,7 +154,8 @@ bool bFile::create(FONTCHARACTER filename, int type, int *size){
|
|||
// File can't be open
|
||||
if (!isOpen()){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Create, filename, BFile_File, size));
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Create,
|
||||
filename, BFile_File, size));
|
||||
return (error_ == 0); // Created ?
|
||||
#else
|
||||
// size if ignored
|
||||
|
@ -177,7 +171,8 @@ bool bFile::create(FONTCHARACTER filename, int type, int *size){
|
|||
else{
|
||||
// Create a folder
|
||||
#ifdef DEST_CASIO_CALC
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Create, filename, BFile_Folder, size));
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Create, filename,
|
||||
BFile_Folder, size));
|
||||
return (error_ == 0); // Created ?
|
||||
#else
|
||||
return fs::create_directory(filename);
|
||||
|
@ -218,7 +213,8 @@ bool bFile::write(void const *data, int even_size){
|
|||
buffer = (void*)data;
|
||||
}
|
||||
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Write, fd_, buffer, mySize));
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Write,
|
||||
fd_, buffer, mySize));
|
||||
done = (error_ == 0); // data written ?
|
||||
|
||||
// Free the buffer ?
|
||||
|
@ -247,7 +243,8 @@ bool bFile::write(void const *data, int even_size){
|
|||
int bFile::read(void *data, int lg, int whence){
|
||||
if (data && lg && isOpen()){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
int read = gint_world_switch(GINT_CALL(BFile_Read, fd_, data, lg, whence));
|
||||
int read = gint_world_switch(GINT_CALL(BFile_Read,
|
||||
fd_, data, lg, whence));
|
||||
if (read < 0){
|
||||
error_ = read;
|
||||
return 0;
|
||||
|
@ -289,9 +286,11 @@ bool bFile::rename(FONTCHARACTER oldPath, FONTCHARACTER newPath){
|
|||
if (buffer && read(buffer, size, 0)){
|
||||
// Create a new file with oldPath content
|
||||
bFile newFile();
|
||||
newFile.create(newPath, BFile_File, NULL);
|
||||
newFile.write(buffer, size);
|
||||
newFile.close();
|
||||
if (newFile.create(newPath, BFile_File, &size)){
|
||||
newFile.write(buffer, size);
|
||||
newFile.close();
|
||||
}
|
||||
|
||||
free(buffer);
|
||||
done = true;
|
||||
}
|
||||
|
@ -307,7 +306,8 @@ bool bFile::rename(FONTCHARACTER oldPath, FONTCHARACTER newPath){
|
|||
|
||||
return false;
|
||||
#else
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Rename, oldPath, newPath));
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_Rename,
|
||||
oldPath, newPath));
|
||||
return (error_ == 0); // Renamed ?
|
||||
#endif // #ifdef FX9860G
|
||||
#else
|
||||
|
@ -358,83 +358,84 @@ void bFile::close(){
|
|||
// findFirst(): Search the storage memory for paths matching a pattern
|
||||
//
|
||||
// @pattern FONTCHARACTER glob pattern
|
||||
// @shandle Will receive search handle (to use in BFile_FindNext/FindClose)
|
||||
// @sHandle Will receive search handle
|
||||
// @foundFile Will receive FONTCHARACTER path of matching entry
|
||||
// @fileInfo Will receive metadata of matching entry
|
||||
//
|
||||
// @return : True on success
|
||||
// @return : True on success
|
||||
//
|
||||
bool bFile::findFirst(const FONTCHARACTER pattern, int *shandle, FONTCHARACTER foundFile, struct BFile_FileInfo *fileInfo){
|
||||
bool bFile::findFirst(const FONTCHARACTER pattern,SEARCHHANDLE *sHandle,
|
||||
FONTCHARACTER foundFile, struct BFile_FileInfo *fileInfo){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
if (!(*shandle)){
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_FindFirst, pattern, shandle, foundFile, fileInfo));
|
||||
return (error_ == 0);
|
||||
}
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_FindFirst,
|
||||
pattern, sHandle, foundFile, fileInfo));
|
||||
return (error_ == 0);
|
||||
#else
|
||||
if (!dir_){
|
||||
dir_ = opendir(pattern);
|
||||
if (NULL != dir_){
|
||||
// Read first value
|
||||
return findNext(0, foundFile, fileInfo);
|
||||
}
|
||||
|
||||
return false;
|
||||
(*sHandle) = opendir(pattern);
|
||||
if (NULL != (*sHandle)){
|
||||
folderName_ = pattern;
|
||||
// Read first value
|
||||
return findNext(*sHandle, foundFile, fileInfo);
|
||||
}
|
||||
#endif // DEST_CASIO_CALC
|
||||
|
||||
// Error
|
||||
return false;
|
||||
#endif // DEST_CASIO_CALC
|
||||
}
|
||||
|
||||
// findNext(): Continue a search
|
||||
//
|
||||
// Continues the search for matches. The search handle is the value set in
|
||||
// Continues the search for matches.
|
||||
//
|
||||
// @shandle : search handle
|
||||
// @sHandle : search handle
|
||||
// @foundFile : next filename
|
||||
// @fileinfo : file metadatas
|
||||
//
|
||||
// @returns true if ok
|
||||
// @return ; true if ok
|
||||
//
|
||||
bool bFile::findNext(int shandle, FONTCHARACTER foundFile, struct BFile_FileInfo *fileInfo){
|
||||
bool bFile::findNext(SEARCHHANDLE sHandle, FONTCHARACTER foundFile,
|
||||
struct BFile_FileInfo *fileInfo){
|
||||
if (sHandle){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
if (shandle){
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_FindNext, shandle, foundFile, fileInfo));
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_FindNext,
|
||||
sHandle, foundFile, fileInfo));
|
||||
return (error_ == 0);
|
||||
}
|
||||
#else
|
||||
if (dir_){
|
||||
struct dirent *de;
|
||||
if (NULL != (de = readdir(dir_))){
|
||||
fileInfo->type = (de->d_type=DT_DIR?BFile_Type_Directory:BFile_Type_File);
|
||||
FC_str2FC(de->d_name, foundFile);
|
||||
char fName[BFILE_MAX_PATH + 1];
|
||||
if (NULL != (de = readdir(sHandle))){
|
||||
fileInfo->type = (DT_DIR == de->d_type?
|
||||
BFile_Type_Directory:BFile_Type_File);
|
||||
strcpy(fName, folderName_.c_str());
|
||||
strcat(fName, "/");
|
||||
strcat(fName, de->d_name);
|
||||
FC_str2FC(fName, foundFile);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif // #ifdef DEST_CASIO_CALC
|
||||
}
|
||||
|
||||
// Error
|
||||
return false;
|
||||
}
|
||||
|
||||
// findClose() : Close a search handle (with or without exhausting the matches).
|
||||
// findClose() : Close a search handle
|
||||
//
|
||||
// @shandle : Search handle
|
||||
// @sHandle : Search handle
|
||||
//
|
||||
// @return : done ?
|
||||
//
|
||||
bool bFile::findClose(int shandle){
|
||||
bool bFile::findClose(SEARCHHANDLE sHandle){
|
||||
if (sHandle){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
if (shandle){
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_FindClose, shandle));
|
||||
error_ = gint_world_switch(GINT_CALL(BFile_FindClose, sHandle));
|
||||
return (error_ == 0);
|
||||
}
|
||||
#else
|
||||
if (dir_){
|
||||
closedir(dir_);
|
||||
dir_ = NULL;
|
||||
closedir(sHandle);
|
||||
folderName_ = "";
|
||||
return true;
|
||||
}
|
||||
#endif // #ifdef DEST_CASIO_CALC
|
||||
}
|
||||
|
||||
// Error
|
||||
return false;
|
||||
|
@ -456,7 +457,7 @@ bool bFile::FC_str2FC(const char* src, FONTCHARACTER dest){
|
|||
if (!src || 0 == (len = strlen(src))){
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef DEST_CASIO_CALC
|
||||
// Copy string content
|
||||
char* buffer = (char*)dest;
|
||||
for (size_t index = 0; index < len; index++){
|
||||
|
@ -465,9 +466,35 @@ bool bFile::FC_str2FC(const char* src, FONTCHARACTER dest){
|
|||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
return (NULL != strcpy(dest, src));
|
||||
#endif // #ifdef DEST_CASIO_CALC
|
||||
}
|
||||
|
||||
// FC_dup() : Duplicate a filename
|
||||
// FC_cpy() : Copy a FONTCHARACTER to another FONTCHARACTER
|
||||
//
|
||||
// @dest : pointer to a destination string (already allocated)
|
||||
// @src : pointer to the source string
|
||||
//
|
||||
// @return : pointer to the copy orif done NULL on error
|
||||
//
|
||||
FONTCHARACTER bFile::FC_cpy(FONTCHARACTER dest, const FONTCHARACTER src){
|
||||
#ifdef DEST_CASIO_CALC
|
||||
size_t len(FC_len(src));
|
||||
if (0 == len){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Allocates
|
||||
int count = (len + 1) * sizeof(uint16_t);
|
||||
memcpy((void*)dest, src, count);
|
||||
return dest;
|
||||
#else
|
||||
return strcpy(dest, src);
|
||||
#endif // #ifdef DEST_CASIO_CALC
|
||||
}
|
||||
|
||||
// FC_dup() : Duplicate a FONTCHARACTER
|
||||
//
|
||||
// @fName : filename to duplicate
|
||||
//
|
||||
|
@ -495,7 +522,7 @@ FONTCHARACTER bFile::FC_dup(const FONTCHARACTER src){
|
|||
|
||||
// FC_len() : length of a fileName in "char"
|
||||
//
|
||||
// @fName : pointer to the string
|
||||
// @fName : pointer to the FONTCHARACTER
|
||||
//
|
||||
// @return : size of fName (O on error)
|
||||
//
|
||||
|
@ -504,7 +531,7 @@ size_t bFile::FC_len(const FONTCHARACTER fName){
|
|||
#ifdef DEST_CASIO_CALC
|
||||
size_t len(0);
|
||||
char* buffer = (char*)fName;
|
||||
while(buffer[len*2]){
|
||||
while(buffer[len*sizeof(uint16_t)]){
|
||||
len++;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
//----------------------------------------------------------------------
|
||||
//--
|
||||
//-- File : bFile.h
|
||||
//-- bFile.h
|
||||
//--
|
||||
//-- Author : Jérôme Henry-Barnaudière - GeeHB
|
||||
//-- Definition of bFile object
|
||||
//--
|
||||
//-- Project :
|
||||
//--
|
||||
//----------------------------------------------------------------------
|
||||
//--
|
||||
//-- Description:
|
||||
//--
|
||||
//-- Definition of bFile object
|
||||
//--
|
||||
//-- This release isn't fully tested.
|
||||
//-- At this time, it's only functionnal for FXCG50 calculator
|
||||
//-- This release isn't fully tested
|
||||
//--
|
||||
//-- Missing :
|
||||
//-- - whence in read ops
|
||||
|
@ -25,13 +16,14 @@
|
|||
#ifndef __GEE_TOOLS_B_FILE_h__
|
||||
#define __GEE_TOOLS_B_FILE_h__ 1
|
||||
|
||||
#define VERSION_B_FILE_OBJECT 0.3.1
|
||||
#define VERSION_B_FILE_OBJECT 0.3.2
|
||||
|
||||
#ifdef DEST_CASIO_CALC
|
||||
#include <gint/gint.h>
|
||||
#include <gint/bfile.h>
|
||||
|
||||
typedef uint16_t const * FONTCHARACTER;
|
||||
typedef int SEARCHHANDLE;
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
@ -41,6 +33,7 @@ typedef uint16_t const * FONTCHARACTER;
|
|||
namespace fs = std::filesystem;
|
||||
|
||||
typedef char* FONTCHARACTER;
|
||||
typedef DIR* SEARCHHANDLE;
|
||||
|
||||
// Entry types
|
||||
//
|
||||
|
@ -132,7 +125,8 @@ public:
|
|||
//
|
||||
// @filename : name of the file or folder to create (must not exist)
|
||||
// @type : Entry type (BFile_File or BFile_Folder)
|
||||
// @size : Pointer to file size if type is BFile_File, use NULL otherwise
|
||||
// @size : Pointer to file size if type is BFile_File,
|
||||
// use NULL otherwise
|
||||
//
|
||||
// @return : file successfully created ?
|
||||
//
|
||||
|
@ -178,41 +172,40 @@ public:
|
|||
//
|
||||
void close();
|
||||
|
||||
// findFirst(): Search the storage memory for paths matching a pattern
|
||||
// findFirst(): Search the storage memory for paths
|
||||
// matching a pattern
|
||||
//
|
||||
// @pattern FONTCHARACTER glob pattern
|
||||
// @shandle Will receive search handle (to use in BFile_FindNext/FindClose)
|
||||
// @sHandle Will receive search handle
|
||||
// @foundFile Will receive FONTCHARACTER path of matching entry
|
||||
// @fileInfo Will receive metadata of matching entry
|
||||
//
|
||||
// @return : True on success
|
||||
// @return : True on success
|
||||
//
|
||||
bool findFirst(const FONTCHARACTER pattern, int *shandle, FONTCHARACTER foundFile,
|
||||
bool findFirst(const FONTCHARACTER pattern,
|
||||
SEARCHHANDLE*sHandle, FONTCHARACTER foundFile,
|
||||
struct BFile_FileInfo *fileInfo);
|
||||
|
||||
// findNext(): Continue a search
|
||||
//
|
||||
// Continues the search for matches. The search handle is the value set in
|
||||
// Continues the search for matches.
|
||||
//
|
||||
// @shandle : search handle
|
||||
// @sHandle : search handle
|
||||
// @foundFile : next filename
|
||||
// @fileinfo : file metadatas
|
||||
//
|
||||
// @returns true if ok
|
||||
// @return : true if ok
|
||||
//
|
||||
bool findNext(int shandle, FONTCHARACTER foundFile, struct BFile_FileInfo *fileInfo);
|
||||
bool findNext(SEARCHHANDLE sHandle,
|
||||
FONTCHARACTER foundFile, struct BFile_FileInfo *fileInfo);
|
||||
|
||||
// findClose() : Close a search handle (with or without exhausting the matches).
|
||||
// findClose() : Close a search handle
|
||||
//
|
||||
// @shandle : Search handle
|
||||
// @sHandle : Search handle
|
||||
//
|
||||
// @return : done ?
|
||||
//
|
||||
bool findClose(int shandle);
|
||||
|
||||
//
|
||||
// Utilities
|
||||
//
|
||||
bool findClose(SEARCHHANDLE sHandle);
|
||||
|
||||
// getLastError() : Get last error code
|
||||
//
|
||||
|
@ -222,6 +215,10 @@ public:
|
|||
return error_;
|
||||
}
|
||||
|
||||
//
|
||||
// Utilities
|
||||
//
|
||||
|
||||
// FC_str2FC() : Convert a string to FC format
|
||||
//
|
||||
// @src : string to copy
|
||||
|
@ -231,7 +228,16 @@ public:
|
|||
//
|
||||
static bool FC_str2FC(const char* src, FONTCHARACTER dest);
|
||||
|
||||
// FC_dup() : Duplicate a filename
|
||||
// FC_cpy() : Copy a FONTCHARACTER to another FONTCHARACTER
|
||||
//
|
||||
// @dest : pointer to a destination string (already allocated)
|
||||
// @src : pointer to the source string
|
||||
//
|
||||
// @return : pointer to the copy orif done NULL on error
|
||||
//
|
||||
static FONTCHARACTER FC_cpy(FONTCHARACTER dest, const FONTCHARACTER src);
|
||||
|
||||
// FC_dup() : Duplicate a FONTCHARACTER
|
||||
//
|
||||
// @fName : filename to copy
|
||||
//
|
||||
|
@ -241,7 +247,7 @@ public:
|
|||
|
||||
// FC_len() : length of a fileName in "char"
|
||||
//
|
||||
// @fName : pointer to the string
|
||||
// @fName : pointer to the FONTCHARACTER
|
||||
//
|
||||
// @return : size of fName (O on error)
|
||||
//
|
||||
|
@ -253,7 +259,7 @@ private:
|
|||
#else
|
||||
std::fstream file_;
|
||||
std::string fileName_;
|
||||
DIR* dir_;
|
||||
std::string folderName_;
|
||||
#endif // #ifdef DEST_CASIO_CALC
|
||||
|
||||
int error_; // Last error code
|
||||
|
|
|
@ -147,8 +147,10 @@ public:
|
|||
//
|
||||
// @return : true if sub menu is added
|
||||
//
|
||||
bool addSubMenu(uint8_t index, const menuBar* subMenu, int id, const char* text){
|
||||
return _addSubMenu(¤t_, index, (PMENUBAR)subMenu, id, text);
|
||||
bool addSubMenu(uint8_t index, const menuBar* subMenu,
|
||||
int id, const char* text){
|
||||
return _addSubMenu(¤t_, index,
|
||||
(PMENUBAR)subMenu, id, text);
|
||||
}
|
||||
// appendSubMenu() : Append a sub menu
|
||||
//
|
||||
|
@ -158,8 +160,10 @@ public:
|
|||
//
|
||||
// @return : true if sub menu is added
|
||||
//
|
||||
bool appendSubMenu(const menuBar* subMenu, int id, const char* text){
|
||||
return _addSubMenu(¤t_, current_.itemCount, (PMENUBAR)subMenu, id, text);
|
||||
bool appendSubMenu(const menuBar* subMenu,
|
||||
int id, const char* text){
|
||||
return _addSubMenu(¤t_, current_.itemCount,
|
||||
(PMENUBAR)subMenu, id, text);
|
||||
}
|
||||
|
||||
// adddItem() : Add an item to the current menu bar
|
||||
|
@ -171,7 +175,8 @@ public:
|
|||
//
|
||||
// @return : true if the item has been added
|
||||
//
|
||||
bool addItem(uint8_t index, int id, const char* text, int state = ITEM_DEFAULT){
|
||||
bool addItem(uint8_t index, int id, const char* text,
|
||||
int state = ITEM_DEFAULT){
|
||||
return _addItem(¤t_, index, id, text, state);
|
||||
}
|
||||
|
||||
|
@ -249,7 +254,8 @@ public:
|
|||
|
||||
// handleKeyboard() : Handle the keyboard events
|
||||
//
|
||||
// @return : MENUACTION struct containing info about item selected b user
|
||||
// @return : MENUACTION struct containing info
|
||||
// about item selected b user
|
||||
//
|
||||
MENUACTION handleKeyboard();
|
||||
|
||||
|
@ -270,7 +276,8 @@ private:
|
|||
//
|
||||
// @return : true if sub menu is added
|
||||
//
|
||||
bool _addSubMenu(PMENUBAR container, uint8_t index, PMENUBAR subMenu, int id, const char* text);
|
||||
bool _addSubMenu(PMENUBAR container, uint8_t index,
|
||||
PMENUBAR subMenu, int id, const char* text);
|
||||
|
||||
// _clearMenuBar() : Empty a menu bar
|
||||
//
|
||||
|
@ -309,21 +316,24 @@ private:
|
|||
//
|
||||
// @return : true if the item has been added
|
||||
//
|
||||
bool _addItem(PMENUBAR bar, uint8_t index, int id, const char* text, int state = ITEM_DEFAULT);
|
||||
bool _addItem(PMENUBAR bar, uint8_t index, int id,
|
||||
const char* text, int state = ITEM_DEFAULT);
|
||||
|
||||
// _findItemByID() : Find an item in the given bar
|
||||
//
|
||||
// @bar : menu bar containing to search item in
|
||||
// @id : id of the searched item
|
||||
//
|
||||
// @containerBar : pointer to a PMENUBAR. when not NULL, if item is ofund,
|
||||
// containerBar will point to the bar containing the item
|
||||
// @pIndex : when not NULL, will point to the Item'index in its menubar.
|
||||
// @containerBar : pointer to a PMENUBAR. when not NULL,
|
||||
// if item is found, containerBar will point to the bar
|
||||
// containing the item
|
||||
// @pIndex : when not NULL, will point to the Item'ID in its menu
|
||||
//
|
||||
// @return : pointer to the item if found or NULL
|
||||
//
|
||||
PMENUITEM _findItemByID(PMENUBAR bar, int id, PMENUBAR* containerBar = NULL, uint8_t* pIndex = NULL);
|
||||
|
||||
PMENUITEM _findItemByID(PMENUBAR bar, int id,
|
||||
PMENUBAR* containerBar = NULL, uint8_t* pIndex = NULL);
|
||||
|
||||
// _createItem() : creae a new menu item
|
||||
//
|
||||
// @id : Item's id
|
||||
|
@ -357,8 +367,8 @@ private:
|
|||
//
|
||||
// @index : index of menu item to select or unselect
|
||||
// @selected : true if item is to be selected
|
||||
// @redraw : when true, item and previously (un)selected item are drawn in their
|
||||
// new states
|
||||
// @redraw : when true, item and previously (un)selected
|
||||
// item are drawn in their new states
|
||||
//
|
||||
// @return : true if item is selected
|
||||
//
|
||||
|
@ -367,7 +377,8 @@ private:
|
|||
// _drawItem() : Draw an item
|
||||
//
|
||||
// @anchor : Position of the item in screen coordinates
|
||||
// @item : Pointer to a MENUITEM strcut containing informations about item to draw
|
||||
// @item : Pointer to a MENUITEM strcut containing informations
|
||||
// about item to draw
|
||||
//
|
||||
void _drawItem(const RECT* anchor, const MENUITEM* item);
|
||||
|
||||
|
|
Loading…
Reference in New Issue