pleyo.com

/src/trunk2/BAL/Interfaces/FileChooser.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2006, 2007 Apple Inc.
00003  * Copyright (C) 2007 Pleyo.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * 1.  Redistributions of source code must retain the above copyright
00010  *     notice, this list of conditions and the following disclaimer. 
00011  * 2.  Redistributions in binary form must reproduce the above copyright
00012  *     notice, this list of conditions and the following disclaimer in the
00013  *     documentation and/or other materials provided with the distribution. 
00014  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
00015  *     its contributors may be used to endorse or promote products derived
00016  *     from this software without specific prior written permission. 
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
00019  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00020  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00021  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
00022  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00023  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00024  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00025  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00026  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00027  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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     // FIXME: It's a layering violation that we pass a Document in here.
00077     // The platform directory is underneath the DOM, so it can't use the DOM.
00078     // Because of UI delegates, it's not clear that this class belongs in the platform
00079     // layer at all. It might need to go alongside the Chrome class instead.
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(); // for use by client; does not call valueChanged
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

Generated on Wed Nov 21 20:04:16 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com