00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef FileChooser_h
00032 #define FileChooser_h
00033
00034 #include "PlatformString.h"
00035 #include <wtf/RefPtr.h>
00036
00037 #if PLATFORM(MAC)
00038 #include <wtf/RetainPtr.h>
00039 #ifdef __OBJC__
00040 @class OpenPanelController;
00041 #else
00042 class OpenPanelController;
00043 #endif
00044 #endif
00045
00046 #ifdef __OWB__
00047 namespace BAL {
00048 class BTFont;
00049 }
00050 #endif
00051
00052 namespace WebCore {
00053
00054 class Document;
00055 #ifndef __OWB__
00056 class Font;
00057 #endif //__OWB__
00058 #ifdef OWB_ICON_SUPPORT
00059 class Icon;
00060 #endif //OWB_ICON_SUPPORT
00061
00062 class FileChooserClient {
00063 public:
00064 virtual ~FileChooserClient() { }
00065 virtual void valueChanged() = 0;
00066 };
00067
00068 class FileChooser : public Shared<FileChooser> {
00069 public:
00070 static PassRefPtr<FileChooser> create(FileChooserClient*, const String& initialFilename);
00071 ~FileChooser();
00072
00073 void disconnectClient() { m_client = 0; }
00074 bool disconnected() { return !m_client; }
00075
00076
00077
00078
00079
00080 void openFileChooser(Document*);
00081
00082 const String& filename() const { return m_filename; }
00083 #ifdef __OWB__
00084 String basenameForWidth(const BAL::BTFont&, int width) const;
00085 #else
00086 String basenameForWidth(const Font&, int width) const;
00087 #endif //__OWB__
00088
00089 #ifdef OWB_ICON_SUPPORT
00090 Icon* icon() const { return m_icon.get(); }
00091 #endif //OWB_ICON_SUPPORT
00092 void clear();
00093
00094 void chooseFile(const String& filename);
00095
00096 private:
00097 FileChooser(FileChooserClient*, const String& initialFilename);
00098 #ifdef OWB_ICON_SUPPORT
00099 static PassRefPtr<Icon> chooseIcon(const String& filename);
00100 #endif //OWB_ICON_SUPPORT
00101
00102 FileChooserClient* m_client;
00103 String m_filename;
00104 #ifdef OWB_ICON_SUPPORT
00105 RefPtr<Icon> m_icon;
00106 #endif //OWB_ICON_SUPPORT
00107
00108 #if PLATFORM(MAC)
00109 RetainPtr<OpenPanelController> m_controller;
00110 #endif
00111 };
00112
00113 }
00114
00115 #endif