other f*h header reviews

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53536 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2008-05-10 09:44:43 +00:00
parent d75a69e832
commit ea6a2ccb4a
4 changed files with 299 additions and 150 deletions

View File

@@ -13,8 +13,8 @@
wxFileConfig implements wxConfigBase interface for
storing and retrieving configuration information using plain text files. The
files have a simple format reminiscent of Windows INI files with lines of the
form @c key = value defining the keys and lines of special form
@c [group] indicating the start of each group.
form @c "key = value" defining the keys and lines of special form
@c "[group]" indicating the start of each group.
This class is used by default for wxConfig on Unix platforms but may also be
used explicitly if you want to use files and not the registry even under
@@ -50,14 +50,13 @@ public:
user-specific, file if it were constructed with @a basename as "local filename"
parameter in the constructor.
@a style has the same meaning as in @ref wxConfigBase::ctor constructor
@a style has the same meaning as in @ref wxConfigBase::wxConfigBase "wxConfig constructor"
and can contain any combination of styles but only wxCONFIG_USE_SUBDIR bit is
examined by this function.
Notice that this function cannot be used if @a basename is already a full path name.
*/
static wxFileName GetLocalFile(const wxString& basename,
int style = 0);
static wxFileName GetLocalFile(const wxString& basename, int style = 0);
/**
Saves all config data to the given stream, returns @true if data was saved

View File

@@ -1,24 +1,36 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filesys.h
// Purpose: interface of wxFileSystem
// Purpose: interface of wxFileSystem, wxFileSystemHandler, wxFSFile
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
Open Bit Flags
*/
enum wxFileSystemOpenFlags
{
wxFS_READ = 1, /**< Open for reading */
wxFS_SEEKABLE = 4 /**< Returned stream will be seekable */
};
/**
@class wxFileSystem
@wxheader{filesys.h}
This class provides an interface for opening files on different
file systems. It can handle absolute and/or local filenames.
It uses a system of handlers() to
provide access to user-defined virtual file systems.
This class provides an interface for opening files on different file systems.
It can handle absolute and/or local filenames.
It uses a system of handlers (see wxFileSystemHandler) to provide access to
user-defined virtual file systems.
@library{wxbase}
@category{vfs}
@see wxFileSystemHandler, wxFSFile, Overview()
@see wxFileSystemHandler, wxFSFile, @ref overview_fs
*/
class wxFileSystem : public wxObject
{
@@ -29,41 +41,65 @@ public:
wxFileSystem();
/**
This static function adds new handler into the list of
handlers() which provide access to virtual FS.
Note that if two handlers for the same protocol are added, the last one added
takes precedence.
This static function adds new handler into the list of handlers
(see wxFileSystemHandler) which provide access to virtual FS.
Note that if two handlers for the same protocol are added, the last
added one takes precedence.
@note You can call:
@code
wxFileSystem::AddHandler(new My_FS_Handler);
@endcode
This is because (a) AddHandler is a static method, and (b) the
handlers are deleted in wxFileSystem's destructor so that you
don't have to care about it.
*/
static void AddHandler(wxFileSystemHandler handler);
/**
Sets the current location. @a location parameter passed to
OpenFile() is relative to this path.
@b Caution! Unless @a is_dir is @true the @a location parameter
is not the directory name but the name of the file in this directory. All these
commands change the path to "dir/subdir/":
Sets the current location. @a location parameter passed to OpenFile() is
relative to this path.
@remarks Unless @a is_dir is @true the @a location parameter is not the
directory name but the name of the file in this directory.
All these commands change the path to "dir/subdir/":
@code
ChangePathTo("dir/subdir/xh.htm");
ChangePathTo("dir/subdir", true);
ChangePathTo("dir/subdir/", true);
@endcode
Example:
@code
f = fs->OpenFile("hello.htm"); // opens file 'hello.htm'
fs->ChangePathTo("subdir/folder", true);
f = fs->OpenFile("hello.htm"); // opens file 'subdir/folder/hello.htm' !!
@endcode
@param location
the new location. Its meaning depends on the value of is_dir
@param is_dir
if @true location is new directory. If @false (default)
location is file in the new directory.
if @true location is new directory.
If @false (the default) location is file in the new directory.
*/
void ChangePathTo(const wxString& location, bool is_dir = false);
/**
Converts filename into URL.
Converts a wxFileName into an URL.
@see URLToFileName(), wxFileName
*/
static wxString FileNameToURL(wxFileName filename);
static wxString FileNameToURL(const wxFileName& filename);
/**
Looks for the file with the given name @a file in a colon or semi-colon
(depending on the current platform) separated list of directories in
@e path. If the file is found in any directory, returns @true and the full
path of the file in @e str, otherwise returns @false and doesn't modify
@e str.
(depending on the current platform) separated list of directories in @a path.
If the file is found in any directory, returns @true and the full path
of the file in @a str, otherwise returns @false and doesn't modify @a str.
@param str
Receives the full path of the file, must not be @NULL
@@ -76,50 +112,57 @@ public:
const wxString& file);
/**
Works like wxFindFirstFile(). Returns name of the first
filename (within filesystem's current path) that matches @e wildcard. @a flags
may be one of
wxFILE (only files), wxDIR (only directories) or 0 (both).
Works like ::wxFindFirstFile().
Returns the name of the first filename (within filesystem's current path)
that matches @a wildcard.
@param wildcard
The wildcard that the filename must match
@param flags
One of wxFILE (only files), wxDIR (only directories) or 0 (both).
*/
wxString FindFirst(const wxString& wildcard, int flags = 0);
/**
Returns the next filename that matches parameters passed to FindFirst().
Returns the next filename that matches the parameters passed to FindFirst().
*/
wxString FindNext();
/**
Returns actual path (set by wxFileSystem::ChangePathTo).
Returns the actual path (set by wxFileSystem::ChangePathTo).
*/
wxString GetPath();
/**
This static function returns @true if there is a registered handler which can
open the given
location.
open the given location.
*/
static bool HasHandlerForPath(const wxString& location);
/**
Opens the file and returns a pointer to a wxFSFile object
or @NULL if failed. It first tries to open the file in relative scope
(based on value passed to ChangePathTo() method) and then as an
absolute path. Note that the user is responsible for deleting the returned
wxFSFile.
@a flags can be one or more of the following bit values ored together:
Opens the file and returns a pointer to a wxFSFile object or @NULL if failed.
It first tries to open the file in relative scope (based on value passed to
ChangePathTo() method) and then as an absolute path.
Note that the user is responsible for deleting the returned wxFSFile.
@a flags can be one or more of the ::wxFileSystemOpenFlags values
combined together.
A stream opened with just the default @e wxFS_READ flag may
or may not be seekable depending on the underlying source.
Passing @e wxFS_READ | wxFS_SEEKABLE for @a flags will
back a stream that is not natively seekable with memory or a file
Passing @e "wxFS_READ | wxFS_SEEKABLE" for @a flags will back
a stream that is not natively seekable with memory or a file
and return a stream that is always seekable.
*/
wxFSFile* OpenFile(const wxString& location,
int flags = wxFS_READ);
/**
Converts URL into a well-formed filename. The URL must use the @c file
protocol.
Converts URL into a well-formed filename.
The URL must use the @c file protocol.
*/
static wxFileName URLToFileName(const wxString& url);
};
@@ -134,22 +177,44 @@ public:
It provides more information than wxWindow's input stream
(stream, filename, mime type, anchor).
@note Any pointer returned by a method of wxFSFile is valid
only as long as the wxFSFile object exists. For example a call to GetStream()
doesn't @e create the stream but only returns the pointer to it. In
other words after 10 calls to GetStream() you will have obtained ten identical
pointers.
@note Any pointer returned by a method of wxFSFile is valid only as long as
the wxFSFile object exists. For example a call to GetStream()
doesn't @e create the stream but only returns the pointer to it.
In other words after 10 calls to GetStream() you will have obtained
ten identical pointers.
@library{wxbase}
@category{vfs}
@see wxFileSystemHandler, wxFileSystem, Overview()
@see wxFileSystemHandler, wxFileSystem, @ref overview_fs
*/
class wxFSFile : public wxObject
{
public:
/**
Constructor. You probably won't use it. See Notes for details.
Constructor. You probably won't use it. See the Note for details.
It is seldom used by the application programmer but you will need it if
you are writing your own virtual FS. For example you may need something
similar to wxMemoryInputStream, but because wxMemoryInputStream doesn't
free the memory when destroyed and thus passing a memory stream pointer
into wxFSFile constructor would lead to memory leaks, you can write your
own class derived from wxFSFile:
@code
class wxMyFSFile : public wxFSFile
{
private:
void *m_Mem;
public:
wxMyFSFile(.....)
~wxMyFSFile() {free(m_Mem);}
// of course dtor is virtual ;-)
};
@endcode
If you are not sure of the meaning of these params, see the description
of the GetXXXX() functions.
@param stream
The input stream that will be used to access data
@@ -168,9 +233,10 @@ public:
/**
Detaches the stream from the wxFSFile object. That is, the
stream obtained with @c GetStream() will continue its existance
after the wxFSFile object is deleted. You will have to delete
the stream yourself.
stream obtained with GetStream() will continue its existance
after the wxFSFile object is deleted.
You will have to delete the stream yourself.
*/
void DetachStream();
@@ -178,25 +244,40 @@ public:
Returns anchor (if present). The term of @b anchor can be easily
explained using few examples:
@verbatim
index.htm#anchor // 'anchor' is anchor
index/wx001.htm // NO anchor here!
archive/main.zip#zip:index.htm#global // 'global'
archive/main.zip#zip:index.htm // NO anchor here!
@endverbatim
Usually an anchor is presented only if the MIME type is 'text/html'.
But it may have some meaning with other files;
for example myanim.avi#200 may refer to position in animation
or reality.wrl#MyView may refer to a predefined view in VRML.
But it may have some meaning with other files; for example myanim.avi#200
may refer to position in animation or reality.wrl#MyView may refer
to a predefined view in VRML.
*/
const wxString GetAnchor() const;
const wxString& GetAnchor() const;
/**
Returns full location of the file, including path and protocol.
Examples :
Examples:
@verbatim
http://www.wxwidgets.org
http://www.ms.mff.cuni.cz/~vsla8348/wxhtml/archive.zip#zip:info.txt
file:/home/vasek/index.htm
relative-file.htm
@endverbatim
*/
const wxString GetLocation() const;
const wxString& GetLocation() const;
/**
Returns the MIME type of the content of this file. It is either
extension-based (see wxMimeTypesManager) or extracted from
Returns the MIME type of the content of this file.
It is either extension-based (see wxMimeTypesManager) or extracted from
HTTP protocol Content-Type header.
*/
const wxString GetMimeType() const;
const wxString& GetMimeType() const;
/**
Returns time when this file was modified.
@@ -204,9 +285,10 @@ public:
wxDateTime GetModificationTime() const;
/**
Returns pointer to the stream. You can use the returned
stream to directly access data. You may suppose
that the stream provide Seek and GetSize functionality
Returns pointer to the stream.
You can use the returned stream to directly access data.
You may suppose that the stream provide Seek and GetSize functionality
(even in the case of the HTTP protocol which doesn't provide
this by default. wxHtml uses local cache to work around
this and to speed up the connection).
@@ -220,26 +302,38 @@ public:
@class wxFileSystemHandler
@wxheader{filesys.h}
Classes derived from wxFileSystemHandler are used
to access virtual file systems. Its public interface consists
of two methods: wxFileSystemHandler::CanOpen
and wxFileSystemHandler::OpenFile.
It provides additional protected methods to simplify the process
of opening the file: GetProtocol, GetLeftLocation, GetRightLocation,
GetAnchor, GetMimeTypeFromExt.
Classes derived from wxFileSystemHandler are used to access virtual file systems.
Please have a look at overview() if you don't know how locations
Its public interface consists of two methods: wxFileSystemHandler::CanOpen
and wxFileSystemHandler::OpenFile.
It provides additional protected methods to simplify the process
of opening the file: GetProtocol(), GetLeftLocation(), GetRightLocation(),
GetAnchor(), GetMimeTypeFromExt().
Please have a look at overview (see wxFileSystem) if you don't know how locations
are constructed.
Also consult @ref overview_fs "list of available handlers".
Also consult the @ref overview_fs_wxhtmlfs "list of available handlers".
@b wxPerl note: In wxPerl, you need to derive your file system handler class
Note that the handlers are shared by all instances of wxFileSystem.
@remarks
wxHTML library provides handlers for local files and HTTP or FTP protocol.
@note
The location parameter passed to OpenFile() or CanOpen() methods is always an
absolute path. You don't need to check the FS's current path.
@beginWxPerlOnly
In wxPerl, you need to derive your file system handler class
from Wx::PlFileSystemHandler.
@endWxPerlOnly
@library{wxbase}
@category{vfs}
@see wxFileSystem, wxFSFile, Overview()
@see wxFileSystem, wxFSFile, @ref overview_fs
*/
class wxFileSystemHandler : public wxObject
{
@@ -254,15 +348,24 @@ public:
check whether the file exists or not, it only checks if it knows the protocol.
Example:
@code
bool MyHand::CanOpen(const wxString& location)
{
return (GetProtocol(location) == "http");
}
@endcode
Must be overridden in derived handlers.
*/
virtual bool CanOpen(const wxString& location);
/**
Works like wxFindFirstFile(). Returns name of the first
filename (within filesystem's current path) that matches @e wildcard. @a flags
may be one of
wxFILE (only files), wxDIR (only directories) or 0 (both).
Works like ::wxFindFirstFile().
Returns the name of the first filename (within filesystem's current path)
that matches @e wildcard. @a flags may be one of wxFILE (only files),
wxDIR (only directories) or 0 (both).
This method is only called if CanOpen() returns @true.
*/
virtual wxString FindFirst(const wxString& wildcard,
@@ -270,43 +373,64 @@ public:
/**
Returns next filename that matches parameters passed to wxFileSystem::FindFirst.
This method is only called if CanOpen() returns @true and FindFirst
This method is only called if CanOpen() returns @true and FindFirst()
returned a non-empty string.
*/
virtual wxString FindNext();
/**
Returns the anchor if present in the location.
See @ref wxFSFile::getanchor wxFSFile for details.
Example: GetAnchor("index.htm#chapter2") == "chapter2"
See wxFSFile::GetAnchor for details.
Example:
@code
GetAnchor("index.htm#chapter2") == "chapter2"
@endcode
@note the anchor is NOT part of the left location.
*/
wxString GetAnchor(const wxString& location) const;
/**
Returns the left location string extracted from @e location.
Example: GetLeftLocation("file:myzipfile.zip#zip:index.htm") ==
"file:myzipfile.zip"
Example:
@code
GetLeftLocation("file:myzipfile.zip#zip:index.htm") == "file:myzipfile.zip"
@endcode
*/
wxString GetLeftLocation(const wxString& location) const;
/**
Returns the MIME type based on @b extension of @e location. (While
wxFSFile::GetMimeType
returns real MIME type - either extension-based or queried from HTTP.)
Example : GetMimeTypeFromExt("index.htm") == "text/html"
Returns the MIME type based on @b extension of @a location.
(While wxFSFile::GetMimeType() returns real MIME type - either
extension-based or queried from HTTP.)
Example:
@code
GetMimeTypeFromExt("index.htm") == "text/html"
@endcode
*/
wxString GetMimeTypeFromExt(const wxString& location);
/**
Returns the protocol string extracted from @e location.
Example: GetProtocol("file:myzipfile.zip#zip:index.htm") == "zip"
Returns the protocol string extracted from @a location.
Example:
@code
GetProtocol("file:myzipfile.zip#zip:index.htm") == "zip"
@endcode
*/
wxString GetProtocol(const wxString& location) const;
/**
Returns the right location string extracted from @e location.
Example : GetRightLocation("file:myzipfile.zip#zip:index.htm") == "index.htm"
Returns the right location string extracted from @a location.
Example:
@code
GetRightLocation("file:myzipfile.zip#zip:index.htm") == "index.htm"
@endcode
*/
wxString GetRightLocation(const wxString& location) const;
@@ -315,8 +439,8 @@ public:
Must be overridden in derived handlers.
@param fs
Parent FS (the FS from that OpenFile was called). See ZIP handler
for details of how to use it.
Parent FS (the FS from that OpenFile was called).
See the ZIP handler for details of how to use it.
@param location
The absolute location of file.
*/

View File

@@ -10,15 +10,32 @@
@class wxFrame
@wxheader{frame.h}
A frame is a window whose size and position can (usually) be changed by the
user. It usually has thick borders and a title bar, and can optionally contain
a menu bar, toolbar and status bar. A frame can contain any window that is not
A frame is a window whose size and position can (usually) be changed by the user.
It usually has thick borders and a title bar, and can optionally contain a
menu bar, toolbar and status bar. A frame can contain any window that is not
a frame or dialog.
A frame that has a status bar and toolbar created via the
CreateStatusBar/CreateToolBar functions manages these windows, and adjusts the
value returned by GetClientSize to reflect the remaining size available to
application windows.
A frame that has a status bar and toolbar, created via the CreateStatusBar() and
CreateToolBar() functions, manages these windows and adjusts the value returned
by GetClientSize() to reflect the remaining size available to application windows.
@remarks An application should normally define an wxCloseEvent handler for the
frame to respond to system close events, for example so that related
data and subwindows can be cleaned up.
@section wxframe_defaultevent Default event processing
wxFrame processes the following events:
@li @c wxEVT_SIZE: if the frame has exactly one child window, not counting the
status and toolbar, this child is resized to take the entire frame client area.
If two or more windows are present, they should be laid out explicitly either
by manually handling wxEVT_SIZE or using sizers;
@li @c wxEVT_MENU_HIGHLIGHT: the default implementation displays the help string
associated with the selected item in the first pane of the status bar, if there is one.
@beginStyleTable
@style{wxDEFAULT_FRAME_STYLE}
@@ -54,12 +71,26 @@
and thus it might be better to use this style only without
wxMINIMIZE_BOX style). In wxGTK, the flag is respected only if GTK+
is at least version 2.2 and the window manager supports
_NET_WM_STATE_SKIP_TASKBAR hint. Has no effect under other
platforms.
_NET_WM_STATE_SKIP_TASKBAR hint. Has no effect under other platforms.
@style{wxFRAME_FLOAT_ON_PARENT}
The frame will always be on top of its parent (unlike
wxSTAY_ON_TOP). A frame created with this style must have a
non-@NULL parent.
The frame will always be on top of its parent (unlike wxSTAY_ON_TOP).
A frame created with this style must have a non-@NULL parent.
@style{wxFRAME_SHAPED}
Windows with this style are allowed to have their shape changed
with the SetShape() method.
@endStyleTable
The default frame style is for normal, resizeable frames.
To create a frame which can not be resized by user, you may use the following
combination of styles:
@code
wxDEFAULT_FRAME_STYLE & ~(wxRESIZE_BORDER | wxRESIZE_BOX | wxMAXIMIZE_BOX)
@endcode
See also the @ref overview_windowstyles.
@beginExtraStyleTable
@style{wxFRAME_EX_CONTEXTHELP}
Under Windows, puts a query button on the caption. When pressed,
Windows will go into a context-sensitive help mode and wxWidgets
@@ -71,13 +102,10 @@
wxDEFAULT_FRAME_STYLE ~ (wxMINIMIZE_BOX | wxMAXIMIZE_BOX) for the
frames having this style (the dialogs don't have a minimize or a
maximize box by default)
@style{wxFRAME_SHAPED}
Windows with this style are allowed to have their shape changed
with the SetShape method.
@style{wxFRAME_EX_METAL}
On Mac OS X, frames with this style will be shown with a metallic
look. This is an extra style.
@endStyleTable
@endExtraStyleTable
@library{wxcore}
@category{managedwnd}

View File

@@ -10,12 +10,13 @@
@class wxMemoryFSHandler
@wxheader{fs_mem.h}
This wxFileSystem handler can store arbitrary
data in memory stream and make them accessible via URL. It is particularly
suitable for storing bitmaps from resources or included XPM files so that
they can be used with wxHTML.
This wxFileSystem handler can store arbitrary data in memory stream and make
them accessible via an URL.
Filenames are prefixed with "memory:", e.g. "memory:myfile.html".
It is particularly suitable for storing bitmaps from resources or included XPM
files so that they can be used with wxHTML.
Filenames are prefixed with @c "memory:", e.g. @c "memory:myfile.html".
Example:
@@ -30,26 +31,26 @@
wxFileSystem::AddHandler(new wxMemoryFSHandler);
wxMemoryFSHandler::AddFile("logo.pcx", wxBITMAP(logo), wxBITMAP_TYPE_PCX);
wxMemoryFSHandler::AddFile("about.htm",
"htmlbodyAbout: "
"img src=\"memory:logo.pcx\"/body/html");
"<html><body>About: "
"<img src=\"memory:logo.pcx\"></body></html>");
wxDialog dlg(this, -1, wxString(_("About")));
wxBoxSizer *topsizer;
wxHtmlWindow *html;
topsizer = new wxBoxSizer(wxVERTICAL);
html = new wxHtmlWindow(, -1, wxDefaultPosition,
html = new wxHtmlWindow(&dlg, -1, wxDefaultPosition,
wxSize(380, 160), wxHW_SCROLLBAR_NEVER);
html-SetBorders(0);
html-LoadPage("memory:about.htm");
html-SetSize(html-GetInternalRepresentation()-GetWidth(),
html-GetInternalRepresentation()-GetHeight());
topsizer-Add(html, 1, wxALL, 10);
topsizer-Add(new wxStaticLine(, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
topsizer-Add(new wxButton(, wxID_OK, "Ok"),
0, wxALL | wxALIGN_RIGHT, 15);
dlg.SetAutoLayout(@true);
html->SetBorders(0);
html->LoadPage("memory:about.htm");
html->SetSize(html->GetInternalRepresentation()->GetWidth(),
html->GetInternalRepresentation()->GetHeight());
topsizer->Add(html, 1, wxALL, 10);
topsizer->Add(new wxStaticLine(&dlg, -1), 0, wxEXPAND | wxLEFT | wxRIGHT, 10);
topsizer->Add(new wxButton(&dlg, wxID_OK, "Ok"),
0, wxALL | wxALIGN_RIGHT, 15);
dlg.SetAutoLayout(true);
dlg.SetSizer(topsizer);
topsizer-Fit();
topsizer->Fit(&dlg);
dlg.Centre();
dlg.ShowModal();
@@ -59,7 +60,7 @@
@endcode
@library{wxbase}
@category{FIXME}
@category{vfs}
@see wxMemoryFSHandler::AddFileWithMimeType
*/
@@ -73,29 +74,26 @@ public:
//@{
/**
Add file to list of files stored in memory. Stored
data (bitmap, text or raw data)
will be copied into private memory stream and available under
name "memory:" + @e filename.
The @a type argument is one of @c wxBITMAP_TYPE_XXX constants.
Note that you must use a @a type value (aka image format)
that wxWidgets can save (e.g. JPG, PNG, see wxImage
documentation())!
Adds a file to the list of the files stored in memory.
Stored data (bitmap, text or raw data) will be copied into private memory
stream and available under name @c "memory:" + @e filename.
@note you must use a @a type value (aka image format) that wxWidgets
can save (e.g. JPG, PNG, see wxImage documentation)!
@see AddFileWithMimeType()
*/
static void AddFile(const wxString& filename, wxImage& image,
long type);
static void AddFile(const wxString& filename,
const wxBitmap& bitmap,
long type);
static void AddFile(const wxString& filename, wxImage& image, wxBitmapType type);
static void AddFile(const wxString& filename, const wxBitmap& bitmap, wxBitmapType type);
//@}
//@{
/**
Like AddFile(), but lets you explicitly
specify added file's MIME type. This version should be used whenever you know
the MIME type, because it makes accessing the files faster.
Like AddFile(), but lets you explicitly specify added file's MIME type.
This version should be used whenever you know the MIME type, because it
makes accessing the files faster.
@since 2.8.5
@@ -111,7 +109,7 @@ public:
//@}
/**
Remove file from memory FS and free occupied memory.
Removes a file from memory FS and frees the occupied memory.
*/
static void RemoveFile(const wxString& filename);
};