For wxMSW, split XPM handler into separate file (please add handler explicitly in app);

doc changes espec. wxBitmap overview


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1999-01-16 22:17:13 +00:00
parent a4abc0fc8d
commit 2fd284a4a0
28 changed files with 1643 additions and 497 deletions

View File

@@ -30,15 +30,13 @@ a reference to your application object) to be visible to other files.
\membersection{wxApp::wxApp}
\func{void}{wxApp}{\param{int}{ language = wxLANGUAGE\_ENGLISH}}
\func{void}{wxApp}{\void}
Constructor. Called implicitly with a definition of a wxApp object.
The argument is a language identifier; this is an experimental
feature and will be expanded and documented in future versions.
TODO: completely rewrite the language stuff.
\membersection{wxApp::\destruct{wxApp}}
\func{void}{\destruct{wxApp}}{\void}

View File

@@ -12,7 +12,11 @@ either monochrome or colour.
\wxheading{See also}
\helpref{wxBitmap overview}{wxbitmapoverview}, \helpref{wxDC::Blit}{wxdcblit}, \helpref{wxIcon}{wxicon}, \helpref{wxCursor}{wxcursor}, \helpref{wxMemoryDC}{wxmemorydc}
\helpref{wxBitmap overview}{wxbitmapoverview},
\helpref{supported bitmap file formats}{supportedbitmapformats},
\helpref{wxDC::Blit}{wxdcblit},
\helpref{wxIcon}{wxicon}, \helpref{wxCursor}{wxcursor}, \helpref{wxBitmap}{wxbitmap},
\helpref{wxMemoryDC}{wxmemorydc}
\latexignore{\rtfignore{\wxheading{Members}}}
@@ -74,8 +78,9 @@ Its meaning is determined by the {\it type} parameter.}
\end{twocollist}
The validity of these flags depends on the platform and wxWindows configuration.
If all possible wxWindows settings are used, the Windows platform supports BMP, BMP\_RESOURCE,
XPM\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.}
If all possible wxWindows settings are used, the Windows platform supports BMP file, BMP resource,
XPM data, and XPM. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.}
\wxheading{Remarks}
@@ -113,7 +118,7 @@ The eighth form constructs a bitmap from a file or resource. {\it name} can refe
to a resource name under MS Windows, or a filename under MS Windows and X.
Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_BMP\_RESOURCE.
Under X, {\it type} defaults to wxBITMAP\_TYPE\_XBM.
Under X, {\it type} defaults to wxBITMAP\_TYPE\_XPM.
\wxheading{See also}

View File

@@ -1,41 +1,32 @@
\section{\class{wxIcon}}\label{wxicon}
An icon is a small rectangular bitmap usually used for denoting a
minimized application.
minimized application. It differs from a wxBitmap in always
having a mask associated with it for transparent drawing. On some platforms,
icons and bitmaps are implemented identically, since there is no real distinction between
a wxBitmap with a mask and an icon; and there is no specific icon format on
some platforms (X-based applications usually standardize on XPMs for small bitmaps
and icons). However, some platforms (such as Windows) make the distinction, so
a separate class is provided.
\wxheading{Remarks}
It is optional (but desirable) to associate a
pertinent icon with a frame. Obviously icons in X and MS Windows are
created in a different manner, and colour icons in X are difficult
to arrange. Therefore, separate icons will be created for the different
It is usually desirable to associate a pertinent icon with a frame. Icons
can also be used for other purposes, for example with \helpref{wxTreeCtrl}{wxtreectrl}
and \helpref{wxListCtrl}{wxlistctrl}.
Icons have different formats on different platforms.
Therefore, separate icons will usually be created for the different
environments. Platform-specific methods for creating a {\bf wxIcon}\rtfsp
structure are catered for, and this is an occasion where conditional
compilation will probably be required.
Note that a new icon must be created for every time the icon is to be
used for a new window. In X, this will ensure that fresh X resources
are allocated for this frame. In MS Windows, the icon will not be
used for a new window. In Windows, the icon will not be
reloaded if it has already been used. An icon allocated to a frame will
be deleted when the frame is deleted.
The following shows the conditional compilation required to define an
icon in X and in MS Windows. The alternative is to use the string
version of the icon constructor, which loads a file under X and a
resource under MS Windows, but has the disadvantage of requiring the
X icon file to be available at run-time.
\begin{verbatim}
#ifdef wx_x
#include "aiai.xbm"
#endif
#ifdef wx_msw
wxIcon *icon = new wxIcon("aiai");
#endif
#ifdef wx_x
wxIcon *icon = new wxIcon(aiai_bits, aiai_width, aiai_height);
#endif
\end{verbatim}
For more information please see \helpref{Bitmap and icon overview}{wxbitmapoverview}.
\wxheading{Derived from}
@@ -45,7 +36,8 @@ X icon file to be available at run-time.
\wxheading{See also}
\helpref{wxIcon overview}{wxiconoverview}, \helpref{wxDC::DrawIcon}{wxdcdrawicon}, \helpref{wxCursor}{wxcursor}
\helpref{Bitmap and icon overview}{wxbitmapoverview}, \helpref{supported bitmap file formats}{supportedbitmapformats},
\helpref{wxDC::DrawIcon}{wxdcdrawicon}, \helpref{wxCursor}{wxcursor}
\latexignore{\rtfignore{\wxheading{Members}}}
@@ -116,8 +108,9 @@ Its meaning is determined by the {\it flags} parameter.}
\end{twocollist}
The validity of these flags depends on the platform and wxWindows configuration.
If all possible wxWindows settings are used, the Windows platform supports ICO, ICO\_RESOURCE,
XPM\_DATA, and XPM. Under X, the available formats are BMP, GIF, XBM, and XPM.}
If all possible wxWindows settings are used, the Windows platform supports ICO file, ICO resource,
XPM data, and XPM file. Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file.
Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file.}
\wxheading{Remarks}
@@ -151,11 +144,28 @@ of character pointers called mybitmap:
wxIcon *icon = new wxIcon(mybitmap);
\end{verbatim}
A macro, wxICON, is available which creates an icon using an XPM
on the appropriate platform, or an icon resource on Windows.
\begin{verbatim}
wxIcon icon(wxICON(mondrian));
// Equivalent to:
#if defined(__WXGTK__) || defined(__WXMOTIF__)
wxIcon icon(mondrian_xpm);
#endif
#if defined(__WXMSW__)
wxIcon icon("mondrian");
#endif
\end{verbatim}
The eighth form constructs an icon from a file or resource. {\it name} can refer
to a resource name under MS Windows, or a filename under MS Windows and X.
Under Windows, {\it type} defaults to wxBITMAP\_TYPE\_ICO\_RESOURCE.
Under X, {\it type} defaults to wxBITMAP\_TYPE\_XBM.
Under X, {\it type} defaults to wxBITMAP\_TYPE\_XPM.
\wxheading{See also}
@@ -175,46 +185,6 @@ destroyed automatically by wxWindows when the application exits.
Do not delete an icon that is selected into a memory device context.
\begin{comment}
\membersection{wxIcon::Create}\label{wxiconcreate}
\func{virtual bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
Creates a fresh icon. If the final argument is omitted, the display depth of
the screen is used.
\func{virtual bool}{Create}{\param{void*}{ data}, \param{int}{ type}, \param{int}{ width}, \param{int}{ height}, \param{int}{ depth = -1}}
Creates an icon from the given data, which can be of arbitrary type.
\wxheading{Parameters}
\docparam{width}{The width of the icon in pixels.}
\docparam{height}{The height of the icon in pixels.}
\docparam{depth}{The depth of the icon in pixels. If this is -1, the screen depth is used.}
\docparam{data}{Data whose type depends on the value of {\it type}.}
\docparam{type}{An icon type identifier - see \helpref{wxIcon::wxIcon}{wxiconconstr} for a list
of possible values.}
\wxheading{Return value}
TRUE if the call succeeded, FALSE otherwise.
\wxheading{Remarks}
The first form works on all platforms. The portability of the second form depends on the
type of data.
\wxheading{See also}
\helpref{wxIcon::wxIcon}{wxiconconstr}
\end{comment}
\membersection{wxIcon::GetDepth}
\constfunc{int}{GetDepth}{\void}

View File

@@ -1,4 +1,4 @@
\section{Bitmaps overview}\label{wxbitmapoverview}
\section{Bitmaps and icons overview}\label{wxbitmapoverview}
Classes: \helpref{wxBitmap}{wxbitmap}, \helpref{wxBitmapHandler}{wxbitmaphandler}, \helpref{wxIcon}{wxicon}, \helpref{wxCursor}{wxcursor}.
@@ -19,40 +19,120 @@ version of the graphic which appears on the main window.
See \helpref{wxMemoryDC}{wxmemorydc} for an example of drawing onto a bitmap.
The following shows the conditional compilation required to load a
bitmap in X and in Windows 3. The alternative is to use the string
version of the bitmap constructor, which loads a file under X and a
resource under Windows 3, but has the disadvantage of requiring the
X icon file to be available at run-time.
bitmap under Unix and in Windows. The alternative is to use the string
version of the bitmap constructor, which loads a file under Unix and a
resource or file under Windows, but has the disadvantage of requiring the
XPM icon file to be available at run-time.
\begin{verbatim}
#ifdef wx_x
#include "aiai.xbm"
#endif
#ifdef wx_msw
wxIcon *icon = new wxBitmap("aiai");
#endif
#ifdef wx_x
wxIcon *icon = new wxBitmap(aiai_bits, aiai_width, aiai_height);
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm"
#endif
\end{verbatim}
\subsection{Loading bitmaps: further information}
A macro, wxICON, is available which creates an icon using an XPM
on the appropriate platform, or an icon resource on Windows.
There is provision for a number of bitmap
formats via the standard wxBitmap class. These facilities can
be enabled or disabled using settings in wx\_setup.h.
\begin{verbatim}
wxIcon icon(wxICON(mondrian));
XPM colour pixmaps may be loaded and saved under Windows and X, with
some restrictions imposed by the lack of colourmap facility when
using XPM files. The user may elect to use XPM files as a cross-platform
stabdard, or translate between XPM and BMP files using a suitable
utility.
// Equivalent to:
Also, under Windows, DIBs (device independent bitmaps with extension BMP)
may be dynamically loaded and saved. Under X, GIF and BMP files may be
loaded but not saved.
#if defined(__WXGTK__) || defined(__WXMOTIF__)
wxIcon icon(mondrian_xpm);
#endif
\subsection{Bitmap format handlers}
#if defined(__WXMSW__)
wxIcon icon("mondrian");
#endif
\end{verbatim}
\subsection{Supported bitmap file formats}\label{supportedbitmapformats}
The following lists the formats handled on different platforms. Note
that missing or partially-implemented formats can be supplemented
by using \helpref{wxImage}{wximage} to load the data, and then converting
it to wxBitmap form.
\wxheading{wxBitmap}
Under Windows, wxBitmap may load the following formats:
\begin{itemize}\itemsep=0pt
\item Windows bitmap resource (wxBITMAP\_TYPE\_BMP\_RESOURCE)
\item Windows bitmap file (wxBITMAP\_TYPE\_BMP)
\item PNG file (wxBITMAP\_TYPE\_PNG). Currently 4-bit (16-colour) PNG files do not load properly.
\item XPM data and file (wxBITMAP\_TYPE\_XPM)
\end{itemize}
Under wxGTK, wxBitmap may load the following formats:
\begin{itemize}\itemsep=0pt
\item Windows bitmap file (wxBITMAP\_TYPE\_BMP)
\item PNG (wxBITMAP\_TYPE\_PNG).
\item XPM data and file (wxBITMAP\_TYPE\_XPM)
\end{itemize}
Under wxMotif, wxBitmap may load the following formats:
\begin{itemize}\itemsep=0pt
%\item Windows bitmap file (wxBITMAP\_TYPE\_BMP)
%\item PNG (wxBITMAP\_TYPE\_PNG).
\item XBM data and file (wxBITMAP\_TYPE\_XBM)
\item XPM data and file (wxBITMAP\_TYPE\_XPM)
\end{itemize}
\wxheading{wxIcon}
Under Windows, wxIcon may load the following formats:
\begin{itemize}\itemsep=0pt
\item Windows icon resource (wxBITMAP\_TYPE\_ICO\_RESOURCE)
\item Windows icon file (wxBITMAP\_TYPE\_ICO)
\item XPM data and file (wxBITMAP\_TYPE\_XPM)
\end{itemize}
Under wxGTK, wxIcon may load the following formats:
\begin{itemize}\itemsep=0pt
\item PNG (wxBITMAP\_TYPE\_PNG).
\item XPM data and file (wxBITMAP\_TYPE\_XPM)
\end{itemize}
Under wxMotif, wxIcon may load the following formats:
\begin{itemize}\itemsep=0pt
%\item Windows bitmap file (wxBITMAP\_TYPE\_BMP)
%\item PNG (wxBITMAP\_TYPE\_PNG).
\item XBM data and file (wxBITMAP\_TYPE\_XBM)
\item XPM data and file (wxBITMAP\_TYPE\_XPM)
\end{itemize}
\wxheading{wxCursor}
Under Windows, wxCursor may load the following formats:
\begin{itemize}\itemsep=0pt
\item Windows cursor resource (wxBITMAP\_TYPE\_CUR\_RESOURCE)
\item Windows cursor file (wxBITMAP\_TYPE\_CUR)
\item Windows icon file (wxBITMAP\_TYPE\_ICO)
\item Windows bitmap file (wxBITMAP\_TYPE\_BMP)
\end{itemize}
Under wxGTK, wxCursor may load the following formats (in additional
to stock cursors):
\begin{itemize}\itemsep=0pt
\item None (stock cursors only).
\end{itemize}
Under wxMotif, wxCursor may load the following formats:
\begin{itemize}\itemsep=0pt
\item XBM data and file (wxBITMAP\_TYPE\_XBM)
\end{itemize}
\subsection{Bitmap format handlers}\label{bitmaphandlers}
To provide extensibility, the functionality for loading and saving bitmap formats
is not implemented in the wxBitmap class, but in a number of handler classes,
@@ -66,20 +146,21 @@ then call the static function \helpref{wxBitmap::AddHandler}{wxbitmapaddhandler}
{\small
\begin{verbatim}
#include "JPEGBitmapHandler.h"
#include <wx/pnghand.h>
#include <wx/xpmhand.h>
...
// Initialisation
wxBitmap::AddHandler(new wxJPEGBitmapHandler);
wxBitmap::AddHandler(new wxPNGFileHandler);
wxBitmap::AddHandler(new wxXPMFileHandler);
wxBitmap::AddHandler(new wxXPMDataHandler);
...
\end{verbatim}
}
Assuming wxJPEGBitmapHandler has been written correctly, you should now be able to load and save JPEG files
using the usual wxBitmap API.
Assuming the handlers have been written correctly, you should now be able to load and save PNG files
and XPM files using the usual wxBitmap API.
To see how bitmap handlers are implemented, please look at the files {\tt bitmap.h} and {\tt bitmap.cpp}.
\subsection{wxIcon overview}\label{wxiconoverview}
TODO.
{\bf Note:} bitmap handlers are not implemented on all platforms. Currently, the above is only necessary on
Windows, to save the extra overhead of formats that may not be necessary (if you don't use them, they
are not linked into the executable). Unix platforms have PNG and XPM capability built-in (where supported).

View File

@@ -110,9 +110,8 @@ dialog, using the EVT\_CLOSE macro. The event handler function might look like t
\wxheading{How do I exit the application gracefully?}
A wxWindows application automatically exits when the top frame (returned
from \helpref{wxApp::OnInit}{wxapponinit}) is destroyed. This may be modified
in later versions to exit only when the {\it last} top-level frame is destroyed.
A wxWindows application automatically exits when the designated top window, or the
last frame or dialog, is destroyed.
\wxheading{Do child windows get deleted automatically?}