00001
00032
00033
00034
00035
00036
00037
00038 #ifndef LL_LLFILEPICKER_H
00039 #define LL_LLFILEPICKER_H
00040
00041 #include "stdtypes.h"
00042
00043 #if LL_DARWIN
00044 #include <Carbon/Carbon.h>
00045
00046
00047 #undef verify
00048 #undef check
00049 #undef require
00050
00051 #include <vector>
00052 #include "llstring.h"
00053
00054 #endif
00055
00056
00057 #ifdef LL_WINDOWS
00058 #include <commdlg.h>
00059 #endif
00060
00061
00062 #if LL_GTK
00063 # include "gtk/gtk.h"
00064 #endif // LL_GTK
00065
00066
00067 #if LL_X11
00068 #include "SDL/SDL_syswm.h"
00069 #endif
00070
00071 #if LL_GTK
00072
00073 typedef struct {
00074 GtkWidget *win;
00075 std::vector<LLString> fileVector;
00076 std::string contextName;
00077 } StoreFilenamesStruct;
00078 #endif // LL_GTK
00079
00080 class LLFilePicker
00081 {
00082 #ifdef LL_GTK
00083 friend class LLDirPicker;
00084 friend void chooser_responder(GtkWidget *, gint, gpointer);
00085 #endif // LL_GTK
00086 public:
00087
00088 static LLFilePicker& instance( void ) { return sInstance; }
00089
00090 enum ELoadFilter
00091 {
00092 FFLOAD_ALL = 1,
00093 FFLOAD_WAV = 2,
00094 FFLOAD_IMAGE = 3,
00095 FFLOAD_ANIM = 4,
00096 #ifdef _CORY_TESTING
00097 FFLOAD_GEOMETRY = 5,
00098 #endif
00099 FFLOAD_XML = 6,
00100 FFLOAD_SLOBJECT = 7,
00101 FFLOAD_RAW = 8,
00102 };
00103
00104 enum ESaveFilter
00105 {
00106 FFSAVE_ALL = 1,
00107 FFSAVE_WAV = 3,
00108 FFSAVE_TGA = 4,
00109 FFSAVE_BMP = 5,
00110 FFSAVE_AVI = 6,
00111 FFSAVE_ANIM = 7,
00112 #ifdef _CORY_TESTING
00113 FFSAVE_GEOMETRY = 8,
00114 #endif
00115 FFSAVE_XML = 9,
00116 FFSAVE_COLLADA = 10,
00117 FFSAVE_RAW = 11,
00118 FFSAVE_J2C = 12,
00119 };
00120
00121
00122 BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const char* filename = NULL );
00123 BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL );
00124 BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL );
00125
00126
00127
00128 const char* getFirstFile();
00129
00130
00131
00132
00133
00134 const char* getNextFile();
00135
00136
00137
00138
00139 const char* getDirname();
00140
00141
00142
00143 void reset();
00144
00145 private:
00146 enum
00147 {
00148 SINGLE_FILENAME_BUFFER_SIZE = 1024,
00149
00150 FILENAME_BUFFER_SIZE = 65000
00151 };
00152
00153 void buildFilename( void );
00154
00155 #if LL_WINDOWS
00156 OPENFILENAMEW mOFN;
00157 char *mOpenFilter;
00158 WCHAR mFilesW[FILENAME_BUFFER_SIZE];
00159
00160 BOOL setupFilter(ELoadFilter filter);
00161 #endif
00162
00163 #if LL_DARWIN
00164 NavDialogCreationOptions mNavOptions;
00165 std::vector<LLString> mFileVector;
00166 UInt32 mFileIndex;
00167
00168 OSStatus doNavChooseDialog(ELoadFilter filter);
00169 OSStatus doNavSaveDialog(ESaveFilter filter, const char* filename);
00170 void getFilePath(SInt32 index);
00171 void getFileName(SInt32 index);
00172 static Boolean navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode);
00173 #endif
00174
00175 #if LL_GTK
00176 StoreFilenamesStruct mStoreFilenames;
00177 U32 mNextFileIndex;
00178
00179 static std::map <std::string, std::string> sContextToPathMap;
00180 #endif
00181
00182 char mFiles[FILENAME_BUFFER_SIZE];
00183 char mFilename[LL_MAX_PATH];
00184 char* mCurrentFile;
00185 BOOL mLocked;
00186 BOOL mMultiFile;
00187
00188 static LLFilePicker sInstance;
00189
00190 protected:
00191 #if LL_GTK
00192 GtkWindow* buildFilePicker(bool is_save, bool is_folder,
00193 std::string context = "generic");
00194 #endif
00195
00196 public:
00197
00198 LLFilePicker();
00199 ~LLFilePicker();
00200 };
00201
00202 #endif