Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1769 yogev_ezra 1
#ifndef __MENUET_FILE_OPEN_H_INCLUDED_
2
#define __MENUET_FILE_OPEN_H_INCLUDED_
3
 
4
#include 
5
 
6
// Menuet interface.
7
 
8
namespace Menuet   // All menuet functions, types and data are nested in the (Menuet) namespace.
9
{
10
	struct TOpenFileStruct;   // Data for a file open dialog.
11
#define MENUET_OPEN_FILE_INIT {}   // Initializer of the file open struct, cat be redefined in a realization of the library
12
 
13
	void OpenFileInit(TOpenFileStruct &ofs);
14
	void OpenFileDelete(TOpenFileStruct &ofs);
15
	bool OpenFileDialog(TOpenFileStruct &ofs);
16
	int OpenFileGetState(const TOpenFileStruct &ofs);
17
	bool OpenFileSetState(TOpenFileStruct &ofs, int state);
18
	char *OpenFileGetName(const TOpenFileStruct &ofs);
19
	bool OpenFileSetName(TOpenFileStruct &ofs, char *name);
20
}
21
 
22
#ifdef __MENUET__
23
 
24
namespace Menuet
25
{
26
// Structures.
27
 
28
	struct TOpenFileStruct
29
	{
30
		int state;
31
		char *name;
32
	};
33
#undef  MENUET_OPEN_FILE_INIT
34
#define MENUET_OPEN_FILE_INIT  {0,0}
35
 
36
// Inline functions.
37
 
38
	inline void OpenFileInit(TOpenFileStruct &ofs)
39
	{
40
		ofs.state = 0;
41
		ofs.name = 0;
42
	}
43
 
44
	inline void OpenFileDelete(TOpenFileStruct &ofs)
45
	{
46
		if (ofs.name) {Free(ofs.name); ofs.name = 0;}
47
	}
48
 
49
	inline int OpenFileGetState(const TOpenFileStruct &ofs)
50
	{
51
		return ofs.state;
52
	}
53
 
54
	inline char *OpenFileGetName(const TOpenFileStruct &ofs)
55
	{
56
		return ofs.name;
57
	}
58
 
59
// Functions.
60
 
61
	bool OpenFileSetState(TOpenFileStruct &ofs, int state)
62
	{
63
		if (!ofs.state) return !state;
64
		if (ofs.state == state) return true;
65
		if (state < 0) return false;
66
		ofs.state = state;
67
		return true;
68
	}
69
 
70
	bool OpenFileSetName(TOpenFileStruct &ofs, char *name)
71
	{
72
		if (!ofs.name && !name) return true;
73
		if (ofs.name) Free(ofs.name);
74
		if (!name) {ofs.name = 0; return true;}
75
		ofs.name = (char*)Alloc(StrLen(name) + 1);
76
		if (!ofs.name) return false;
77
		StrCopy(ofs.name, name);
78
		return true;
79
	}
80
}
81
 
82
#else   // else: def __MENUET__
83
 
84
namespace Menuet
85
{
86
	struct TOpenFileStruct
87
	{
88
		unsigned int data;
89
 
90
		TOpenFileStruct();
91
		~TOpenFileStruct();
92
	};
93
#undef  MENUET_OPEN_FILE_INIT
94
#define MENUET_OPEN_FILE_INIT  TOpenFileStruct()
95
}
96
 
97
#endif  // __MENUET__
98
 
99
#endif  // __MENUET_FILE_OPEN_H_INCLUDED_
100