Annotation of /trunk/indra/newview/llfilepicker.h
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llfilepicker.h | ||
| 3 : | * @brief OS-specific file picker | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2001-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | // OS specific file selection dialog. This is implemented as a | ||
| 34 : | // singleton class, so call the instance() method to get the working | ||
| 35 : | // instance. When you call getMultipleOpenFile(), it locks the picker | ||
| 36 : | // until you iterate to the end of the list of selected files with | ||
| 37 : | // getNextFile() or call reset(). | ||
| 38 : | |||
| 39 : | #ifndef LL_LLFILEPICKER_H | ||
| 40 : | #define LL_LLFILEPICKER_H | ||
| 41 : | |||
| 42 : | #include "stdtypes.h" | ||
| 43 : | |||
| 44 : | #if LL_DARWIN | ||
| 45 : | #include <Carbon/Carbon.h> | ||
| 46 : | |||
| 47 : | // AssertMacros.h does bad things. | ||
| 48 : | #undef verify | ||
| 49 : | #undef check | ||
| 50 : | #undef require | ||
| 51 : | |||
| 52 : | #include <vector> | ||
| 53 : | #include "llstring.h" | ||
| 54 : | |||
| 55 : | #endif | ||
| 56 : | |||
| 57 : | // Need commdlg.h for OPENFILENAMEA | ||
| 58 : | #ifdef LL_WINDOWS | ||
| 59 : | #include <commdlg.h> | ||
| 60 : | #endif | ||
| 61 : | |||
| 62 : | // mostly for Linux, possible on others | ||
| 63 : | #if LL_GTK | ||
| 64 : | # include "gtk/gtk.h" | ||
| 65 : | #endif // LL_GTK | ||
| 66 : | |||
| 67 : | // also mostly for Linux, for some X11-specific filepicker usability tweaks | ||
| 68 : | #if LL_X11 | ||
| 69 : | #include "SDL/SDL_syswm.h" | ||
| 70 : | #endif | ||
| 71 : | |||
| 72 : | class LLFilePicker | ||
| 73 : | { | ||
| 74 : | #ifdef LL_GTK | ||
| 75 : | friend class LLDirPicker; | ||
| 76 : | friend void chooser_responder(GtkWidget *, gint, gpointer); | ||
| 77 : | #endif // LL_GTK | ||
| 78 : | public: | ||
| 79 : | // calling this before main() is undefined | ||
| 80 : | static LLFilePicker& instance( void ) { return sInstance; } | ||
| 81 : | |||
| 82 : | enum ELoadFilter | ||
| 83 : | { | ||
| 84 : | FFLOAD_ALL = 1, | ||
| 85 : | FFLOAD_WAV = 2, | ||
| 86 : | FFLOAD_IMAGE = 3, | ||
| 87 : | FFLOAD_ANIM = 4, | ||
| 88 : | #ifdef _CORY_TESTING | ||
| 89 : | FFLOAD_GEOMETRY = 5, | ||
| 90 : | #endif | ||
| 91 : | FFLOAD_XML = 6, | ||
| 92 : | FFLOAD_SLOBJECT = 7, | ||
| 93 : | FFLOAD_RAW = 8, | ||
| 94 : | }; | ||
| 95 : | |||
| 96 : | enum ESaveFilter | ||
| 97 : | { | ||
| 98 : | FFSAVE_ALL = 1, | ||
| 99 : | FFSAVE_WAV = 3, | ||
| 100 : | FFSAVE_TGA = 4, | ||
| 101 : | FFSAVE_BMP = 5, | ||
| 102 : | FFSAVE_AVI = 6, | ||
| 103 : | FFSAVE_ANIM = 7, | ||
| 104 : | #ifdef _CORY_TESTING | ||
| 105 : | FFSAVE_GEOMETRY = 8, | ||
| 106 : | #endif | ||
| 107 : | FFSAVE_XML = 9, | ||
| 108 : | FFSAVE_COLLADA = 10, | ||
| 109 : | FFSAVE_RAW = 11, | ||
| 110 : | FFSAVE_J2C = 12, | ||
| 111 : | FFSAVE_PNG = 13, | ||
| 112 : | FFSAVE_JPEG = 14, | ||
| 113 : | }; | ||
| 114 : | |||
| 115 : | // open the dialog. This is a modal operation | ||
| 116 : | BOOL getSaveFile( ESaveFilter filter = FFSAVE_ALL, const std::string& filename = LLStringUtil::null ); | ||
| 117 : | BOOL getOpenFile( ELoadFilter filter = FFLOAD_ALL ); | ||
| 118 : | BOOL getMultipleOpenFiles( ELoadFilter filter = FFLOAD_ALL ); | ||
| 119 : | |||
| 120 : | // Get the filename(s) found. getFirstFile() sets the pointer to | ||
| 121 : | // the start of the structure and allows the start of iteration. | ||
| 122 : | const std::string getFirstFile(); | ||
| 123 : | |||
| 124 : | // getNextFile() increments the internal representation and | ||
| 125 : | // returns the next file specified by the user. Returns NULL when | ||
| 126 : | // no more files are left. Further calls to getNextFile() are | ||
| 127 : | // undefined. | ||
| 128 : | const std::string getNextFile(); | ||
| 129 : | |||
| 130 : | // This utility function extracts the current file name without | ||
| 131 : | // doing any incrementing. | ||
| 132 : | const std::string getCurFile(); | ||
| 133 : | |||
| 134 : | // Returns the index of the current file. | ||
| 135 : | S32 getCurFileNum() const { return mCurrentFile; } | ||
| 136 : | |||
| 137 : | S32 getFileCount() const { return (S32)mFiles.size(); } | ||
| 138 : | |||
| 139 : | // See llvfs/lldir.h : getBaseFileName and getDirName to extract base or directory names | ||
| 140 : | |||
| 141 : | // clear any lists of buffers or whatever, and make sure the file | ||
| 142 : | // picker isn't locked. | ||
| 143 : | void reset(); | ||
| 144 : | |||
| 145 : | private: | ||
| 146 : | enum | ||
| 147 : | { | ||
| 148 : | SINGLE_FILENAME_BUFFER_SIZE = 1024, | ||
| 149 : | //FILENAME_BUFFER_SIZE = 65536 | ||
| 150 : | FILENAME_BUFFER_SIZE = 65000 | ||
| 151 : | }; | ||
| 152 : | |||
| 153 : | #if LL_WINDOWS | ||
| 154 : | OPENFILENAMEW mOFN; // for open and save dialogs | ||
| 155 : | WCHAR mFilesW[FILENAME_BUFFER_SIZE]; | ||
| 156 : | |||
| 157 : | BOOL setupFilter(ELoadFilter filter); | ||
| 158 : | #endif | ||
| 159 : | |||
| 160 : | #if LL_DARWIN | ||
| 161 : | NavDialogCreationOptions mNavOptions; | ||
| 162 : | std::vector<std::string> mFileVector; | ||
| 163 : | UInt32 mFileIndex; | ||
| 164 : | |||
| 165 : | OSStatus doNavChooseDialog(ELoadFilter filter); | ||
| 166 : | OSStatus doNavSaveDialog(ESaveFilter filter, const std::string& filename); | ||
| 167 : | void getFilePath(SInt32 index); | ||
| 168 : | void getFileName(SInt32 index); | ||
| 169 : | static Boolean navOpenFilterProc(AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode); | ||
| 170 : | #endif | ||
| 171 : | |||
| 172 : | #if LL_GTK | ||
| 173 : | static void add_to_selectedfiles(gpointer data, gpointer user_data); | ||
| 174 : | static void chooser_responder(GtkWidget *widget, gint response, gpointer user_data); | ||
| 175 : | // we remember the last path that was accessed for a particular usage | ||
| 176 : | std::map <std::string, std::string> mContextToPathMap; | ||
| 177 : | std::string mCurContextName; | ||
| 178 : | #endif | ||
| 179 : | |||
| 180 : | std::vector<std::string> mFiles; | ||
| 181 : | S32 mCurrentFile; | ||
| 182 : | BOOL mLocked; | ||
| 183 : | BOOL mMultiFile; | ||
| 184 : | |||
| 185 : | static LLFilePicker sInstance; | ||
| 186 : | |||
| 187 : | protected: | ||
| 188 : | #if LL_GTK | ||
| 189 : | GtkWindow* buildFilePicker(bool is_save, bool is_folder, | ||
| 190 : | std::string context = "generic"); | ||
| 191 : | #endif | ||
| 192 : | |||
| 193 : | public: | ||
| 194 : | // don't call these directly please. | ||
| 195 : | LLFilePicker(); | ||
| 196 : | ~LLFilePicker(); | ||
| 197 : | }; | ||
| 198 : | |||
| 199 : | #endif |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

