2020-11-10 13:19:15 +01:00
|
|
|
#ifndef __KOLIBRI_FILE_OPEN_H_INCLUDED_
|
|
|
|
#define __KOLIBRI_FILE_OPEN_H_INCLUDED_
|
2011-01-28 14:00:06 +01:00
|
|
|
|
2020-11-02 19:44:51 +01:00
|
|
|
#include <kolibri.h>
|
2011-01-28 14:00:06 +01:00
|
|
|
|
2020-11-02 19:44:51 +01:00
|
|
|
// Kolibri interface.
|
2011-01-28 14:00:06 +01:00
|
|
|
|
2020-11-02 19:44:51 +01:00
|
|
|
namespace Kolibri // All kolibri functions, types and data are nested in the (Kolibri) namespace.
|
2011-01-28 14:00:06 +01:00
|
|
|
{
|
|
|
|
struct TOpenFileStruct; // Data for a file open dialog.
|
2020-11-10 13:19:15 +01:00
|
|
|
#define KOLIBRI_OPEN_FILE_INIT {} // Initializer of the file open struct, cat be redefined in a realization of the library
|
2011-01-28 14:00:06 +01:00
|
|
|
|
|
|
|
void OpenFileInit(TOpenFileStruct &ofs);
|
|
|
|
void OpenFileDelete(TOpenFileStruct &ofs);
|
|
|
|
bool OpenFileDialog(TOpenFileStruct &ofs);
|
|
|
|
int OpenFileGetState(const TOpenFileStruct &ofs);
|
|
|
|
bool OpenFileSetState(TOpenFileStruct &ofs, int state);
|
|
|
|
char *OpenFileGetName(const TOpenFileStruct &ofs);
|
|
|
|
bool OpenFileSetName(TOpenFileStruct &ofs, char *name);
|
|
|
|
}
|
|
|
|
|
2020-11-10 13:19:15 +01:00
|
|
|
#ifdef __KOLIBRI__
|
2011-01-28 14:00:06 +01:00
|
|
|
|
2020-11-02 19:44:51 +01:00
|
|
|
namespace Kolibri
|
2011-01-28 14:00:06 +01:00
|
|
|
{
|
|
|
|
// Structures.
|
|
|
|
|
|
|
|
struct TOpenFileStruct
|
|
|
|
{
|
|
|
|
int state;
|
|
|
|
char *name;
|
|
|
|
};
|
2020-11-10 13:19:15 +01:00
|
|
|
#undef KOLIBRI_OPEN_FILE_INIT
|
|
|
|
#define KOLIBRI_OPEN_FILE_INIT {0,0}
|
2011-01-28 14:00:06 +01:00
|
|
|
|
|
|
|
// Inline functions.
|
|
|
|
|
|
|
|
inline void OpenFileInit(TOpenFileStruct &ofs)
|
|
|
|
{
|
|
|
|
ofs.state = 0;
|
|
|
|
ofs.name = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void OpenFileDelete(TOpenFileStruct &ofs)
|
|
|
|
{
|
|
|
|
if (ofs.name) {Free(ofs.name); ofs.name = 0;}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int OpenFileGetState(const TOpenFileStruct &ofs)
|
|
|
|
{
|
|
|
|
return ofs.state;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline char *OpenFileGetName(const TOpenFileStruct &ofs)
|
|
|
|
{
|
|
|
|
return ofs.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Functions.
|
|
|
|
|
|
|
|
bool OpenFileSetState(TOpenFileStruct &ofs, int state)
|
|
|
|
{
|
|
|
|
if (!ofs.state) return !state;
|
|
|
|
if (ofs.state == state) return true;
|
|
|
|
if (state < 0) return false;
|
|
|
|
ofs.state = state;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenFileSetName(TOpenFileStruct &ofs, char *name)
|
|
|
|
{
|
|
|
|
if (!ofs.name && !name) return true;
|
|
|
|
if (ofs.name) Free(ofs.name);
|
|
|
|
if (!name) {ofs.name = 0; return true;}
|
|
|
|
ofs.name = (char*)Alloc(StrLen(name) + 1);
|
|
|
|
if (!ofs.name) return false;
|
|
|
|
StrCopy(ofs.name, name);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-10 13:19:15 +01:00
|
|
|
#else // else: def __KOLIBRI__
|
2011-01-28 14:00:06 +01:00
|
|
|
|
2020-11-02 19:44:51 +01:00
|
|
|
namespace Kolibri
|
2011-01-28 14:00:06 +01:00
|
|
|
{
|
|
|
|
struct TOpenFileStruct
|
|
|
|
{
|
|
|
|
unsigned int data;
|
|
|
|
|
|
|
|
TOpenFileStruct();
|
|
|
|
~TOpenFileStruct();
|
|
|
|
};
|
2020-11-10 13:19:15 +01:00
|
|
|
#undef KOLIBRI_OPEN_FILE_INIT
|
|
|
|
#define KOLIBRI_OPEN_FILE_INIT TOpenFileStruct()
|
2011-01-28 14:00:06 +01:00
|
|
|
}
|
|
|
|
|
2020-11-10 13:19:15 +01:00
|
|
|
#endif // __KOLIBRI__
|
2011-01-28 14:00:06 +01:00
|
|
|
|
2020-11-10 13:19:15 +01:00
|
|
|
#endif // __KOLIBRI_FILE_OPEN_H_INCLUDED_
|
2011-01-28 14:00:06 +01:00
|
|
|
|