]> git.saurik.com Git - wxWidgets.git/commitdiff
Simple wxBatteryPower API for the support in wxWinCE, wxPalmOS and any other mobile...
authorWłodzimierz Skiba <abx@abx.art.pl>
Thu, 20 Jan 2005 16:09:23 +0000 (16:09 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Thu, 20 Jan 2005 16:09:23 +0000 (16:09 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31515 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/function.tex
include/wx/utils.h
src/mac/carbon/utils.cpp
src/mac/classic/utils.cpp
src/msw/utils.cpp
src/os2/utils.cpp
src/palmos/utils.cpp
src/unix/utilsunx.cpp

index bb072e03181b8fab4d8a1f5edb05fe94223604d0..962d473713932989c72c8ef33300eef473e7cae8 100644 (file)
@@ -36,6 +36,7 @@ All:
 - The samples\db sample program now includes an optional example of using a BLOB
   datatype (if BLOB support is enabled and supported by the database)
 - added wxDynamicLibrary::ListLoaded()
 - The samples\db sample program now includes an optional example of using a BLOB
   datatype (if BLOB support is enabled and supported by the database)
 - added wxDynamicLibrary::ListLoaded()
+- wxGetPowerType() and wxGetBatteryState() addition
 
 All (GUI):
 
 
 All (GUI):
 
index 852ce33397f3a7c12a682d5d84513e53c70c432a..4d40bb80ab44b1ebce9cef27f7835a6f7f7e1f45 100644 (file)
@@ -96,6 +96,7 @@ the corresponding topic.
 \helpref{wxFinite}{wxfinite}\\
 \helpref{wxGetActiveWindow}{wxgetactivewindow}\\
 \helpref{wxGetApp}{wxgetapp}\\
 \helpref{wxFinite}{wxfinite}\\
 \helpref{wxGetActiveWindow}{wxgetactivewindow}\\
 \helpref{wxGetApp}{wxgetapp}\\
+\helpref{wxGetBatteryState}{wxgetbatterystate}\\
 \helpref{wxGetClipboardData}{wxgetclipboarddata}\\
 \helpref{wxGetClipboardFormatName}{wxgetclipboardformatname}\\
 \helpref{wxGetColourFromUser}{wxgetcolourfromuser}\\
 \helpref{wxGetClipboardData}{wxgetclipboarddata}\\
 \helpref{wxGetClipboardFormatName}{wxgetclipboardformatname}\\
 \helpref{wxGetColourFromUser}{wxgetcolourfromuser}\\
@@ -123,6 +124,7 @@ the corresponding topic.
 \helpref{wxGetOsDescription}{wxgetosdescription}\\
 \helpref{wxGetOsVersion}{wxgetosversion}\\
 \helpref{wxGetPasswordFromUser}{wxgetpasswordfromuser}\\
 \helpref{wxGetOsDescription}{wxgetosdescription}\\
 \helpref{wxGetOsVersion}{wxgetosversion}\\
 \helpref{wxGetPasswordFromUser}{wxgetpasswordfromuser}\\
+\helpref{wxGetPowerType}{wxgetpowertype}\\
 \helpref{wxGetPrinterCommand}{wxgetprintercommand}\\
 \helpref{wxGetPrinterFile}{wxgetprinterfile}\\
 \helpref{wxGetPrinterMode}{wxgetprintermode}\\
 \helpref{wxGetPrinterCommand}{wxgetprintercommand}\\
 \helpref{wxGetPrinterFile}{wxgetprinterfile}\\
 \helpref{wxGetPrinterMode}{wxgetprintermode}\\
@@ -974,7 +976,7 @@ For example:
 
 \begin{verbatim}
   wxString f = wxFindFirstFile("/home/project/*.*");
 
 \begin{verbatim}
   wxString f = wxFindFirstFile("/home/project/*.*");
-  while ( !f.IsEmpty() )
+  while ( !f.empty() )
   {
     ...
     f = wxFindNextFile();
   {
     ...
     f = wxFindNextFile();
@@ -1606,7 +1608,7 @@ initialization.
 
 Here is an example which should make it more clear: suppose that you have a
 static array of strings containing the weekday names and which have to be
 
 Here is an example which should make it more clear: suppose that you have a
 static array of strings containing the weekday names and which have to be
-translated (note that it is a bad example, really, as 
+translated (note that it is a bad example, really, as
 \helpref{wxDateTime}{wxdatetime} already can be used to get the localized week
 day names already). If you write
 
 \helpref{wxDateTime}{wxdatetime} already can be used to get the localized week
 day names already). If you write
 
@@ -1649,7 +1651,7 @@ argument instead of arbitrary number of parameters.
 
 \func{const wxChar *}{\_}{\param{const char *}{s}}
 
 
 \func{const wxChar *}{\_}{\param{const char *}{s}}
 
-This macro expands into a call to \helpref{wxGetTranslation}{wxgettranslation} 
+This macro expands into a call to \helpref{wxGetTranslation}{wxgettranslation}
 function, so it marks the message for the extraction by {\tt xgettext} just as
 \helpref{wxTRANSLATE}{wxtranslate} does, but also returns the translation of
 the string for the current locale during execution.
 function, so it marks the message for the extraction by {\tt xgettext} just as
 \helpref{wxTRANSLATE}{wxtranslate} does, but also returns the translation of
 the string for the current locale during execution.
@@ -2179,7 +2181,7 @@ checkbox which is shown in the tips dialog.}
 
 \func{int}{wxFinite}{\param{double }{x}}
 
 
 \func{int}{wxFinite}{\param{double }{x}}
 
-Returns a non-zero value if {\it x} is neither infinite or NaN (not a number), 
+Returns a non-zero value if {\it x} is neither infinite or NaN (not a number),
 returns 0 otherwise.
 
 
 returns 0 otherwise.
 
 
@@ -2596,7 +2598,7 @@ This macro returns the concatenation of two tokens \arg{x} and \arg{y}.
 
 \func{}{wxDYNLIB\_FUNCTION}{\param{}{type}, \param{}{name}, \param{}{dynlib}}
 
 
 \func{}{wxDYNLIB\_FUNCTION}{\param{}{type}, \param{}{name}, \param{}{dynlib}}
 
-When loading a function from a DLL you always have to cast the returned 
+When loading a function from a DLL you always have to cast the returned
 {\tt void *} pointer to the correct type and, even more annoyingly, you have to
 repeat this type twice if you want to declare and define a function pointer all
 in one line
 {\tt void *} pointer to the correct type and, even more annoyingly, you have to
 repeat this type twice if you want to declare and define a function pointer all
 in one line
@@ -2604,7 +2606,7 @@ in one line
 This macro makes this slightly less painful by allowing you to specify the
 type only once, as the first parameter, and creating a variable of this type
 named after the function but with {\tt pfn} prefix and initialized with the
 This macro makes this slightly less painful by allowing you to specify the
 type only once, as the first parameter, and creating a variable of this type
 named after the function but with {\tt pfn} prefix and initialized with the
-function \arg{name} from the \helpref{wxDynamicLibrary}{wxdynamiclibrary} 
+function \arg{name} from the \helpref{wxDynamicLibrary}{wxdynamiclibrary}
 \arg{dynlib}.
 
 \wxheading{Parameters}
 \arg{dynlib}.
 
 \wxheading{Parameters}
@@ -2823,6 +2825,21 @@ Gets the currently active window (Windows only).
 <wx/windows.h>
 
 
 <wx/windows.h>
 
 
+\membersection{::wxGetBatteryState}\label{wxgetbatterystate}
+
+\func{wxBatteryState}{wxGetBatteryState}{\void}
+
+Returns battery state as one of \texttt{wxBATTERY_NORMAL_STATE},
+\texttt{wxBATTERY_LOW_STATE}, \texttt{wxBATTERY_CRITICAL_STATE},
+\texttt{wxBATTERY_SHUTDOWN_STATE} or \texttt{wxBATTERY_UNKNOWN_STATE}.
+\texttt{wxBATTERY_UNKNOWN_STATE} is also the default on platforms where
+this feature is not implemented.
+
+\wxheading{Include files}
+
+<wx/utils.h>
+
+
 \membersection{::wxGetDisplayName}\label{wxgetdisplayname}
 
 \func{wxString}{wxGetDisplayName}{\void}
 \membersection{::wxGetDisplayName}\label{wxgetdisplayname}
 
 \func{wxString}{wxGetDisplayName}{\void}
@@ -2834,6 +2851,20 @@ Under X only, returns the current display name. See also \helpref{wxSetDisplayNa
 <wx/utils.h>
 
 
 <wx/utils.h>
 
 
+\membersection{::wxGetPowerType}\label{wxgetpowertype}
+
+\func{wxPowerType}{wxGetPowerType}{\void}
+
+Returns the type of power source as one of \texttt{wxPOWER_SOCKET},
+\texttt{wxPOWER_BATTERY} or \texttt{wxPOWER_UNKNOWN}.
+\texttt{wxPOWER_UNKNOWN} is also the default on platforms where this
+feature is not implemented.
+
+\wxheading{Include files}
+
+<wx/utils.h>
+
+
 \membersection{::wxGetMousePosition}\label{wxgetmouseposition}
 
 \func{wxPoint}{wxGetMousePosition}{\void}
 \membersection{::wxGetMousePosition}\label{wxgetmouseposition}
 
 \func{wxPoint}{wxGetMousePosition}{\void}
@@ -3012,7 +3043,7 @@ which support it or its replacement for those that don't. It must be used to
 preserve the value of a \texttt{va\_list} object if you need to use it after
 passing it to another function because it can be modified by the latter.
 
 preserve the value of a \texttt{va\_list} object if you need to use it after
 passing it to another function because it can be modified by the latter.
 
-As with \texttt{va\_start}, each call to \texttt{wxVaCopy} must have a matching 
+As with \texttt{va\_start}, each call to \texttt{wxVaCopy} must have a matching
 \texttt{va\_end}.
 
 
 \texttt{va\_end}.
 
 
@@ -3171,9 +3202,9 @@ class wxCommand: public wxObject
 
 \func{}{DECLARE\_APP}{className}
 
 
 \func{}{DECLARE\_APP}{className}
 
-This is used in headers to create a forward declaration of the 
-\helpref{wxGetApp}{wxgetapp} function implemented by 
-\helpref{IMPLEMENT\_APP}{implementapp}. It creates the declaration 
+This is used in headers to create a forward declaration of the
+\helpref{wxGetApp}{wxgetapp} function implemented by
+\helpref{IMPLEMENT\_APP}{implementapp}. It creates the declaration
 {\tt className\& wxGetApp(void)}.
 
 Example:
 {\tt className\& wxGetApp(void)}.
 
 Example:
@@ -3458,7 +3489,7 @@ result of executing an equivalent of {\tt static\_cast<classname *>(ptr)}.
 
 \func{T}{wx\_const\_cast}{T, x}
 
 
 \func{T}{wx\_const\_cast}{T, x}
 
-Same as \texttt{const\_cast<T>(x)} if the compiler supports const cast or 
+Same as \texttt{const\_cast<T>(x)} if the compiler supports const cast or
 \texttt{(T)x} for old compilers. Unlike \helpref{wxConstCast}{wxconstcast},
 the cast it to the type \arg{T} and not to \texttt{T *} and also the order of
 arguments is the same as for the standard cast.
 \texttt{(T)x} for old compilers. Unlike \helpref{wxConstCast}{wxconstcast},
 the cast it to the type \arg{T} and not to \texttt{T *} and also the order of
 arguments is the same as for the standard cast.
@@ -3473,7 +3504,7 @@ arguments is the same as for the standard cast.
 
 \func{T}{wx\_reinterpret\_cast}{T, x}
 
 
 \func{T}{wx\_reinterpret\_cast}{T, x}
 
-Same as \texttt{reinterpret\_cast<T>(x)} if the compiler supports reinterpret cast or 
+Same as \texttt{reinterpret\_cast<T>(x)} if the compiler supports reinterpret cast or
 \texttt{(T)x} for old compilers.
 
 \wxheading{See also}
 \texttt{(T)x} for old compilers.
 
 \wxheading{See also}
@@ -3486,7 +3517,7 @@ Same as \texttt{reinterpret\_cast<T>(x)} if the compiler supports reinterpret ca
 
 \func{T}{wx\_static\_cast}{T, x}
 
 
 \func{T}{wx\_static\_cast}{T, x}
 
-Same as \texttt{static\_cast<T>(x)} if the compiler supports static cast or 
+Same as \texttt{static\_cast<T>(x)} if the compiler supports static cast or
 \texttt{(T)x} for old compilers. Unlike \helpref{wxStaticCast}{wxstaticcast},
 there are no checks being done and the meaning of the macro arguments is exactly
 the same as for the standard static cast, i.e. \arg{T} is the full type name and
 \texttt{(T)x} for old compilers. Unlike \helpref{wxStaticCast}{wxstaticcast},
 there are no checks being done and the meaning of the macro arguments is exactly
 the same as for the standard static cast, i.e. \arg{T} is the full type name and
@@ -3933,7 +3964,7 @@ Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.
 
 Sleeps for the specified number of microseconds. The microsecond resolution may
 not, in fact, be available on all platforms (currently only Unix platforms with
 
 Sleeps for the specified number of microseconds. The microsecond resolution may
 not, in fact, be available on all platforms (currently only Unix platforms with
-nanosleep(2) may provide it) in which case this is the same as 
+nanosleep(2) may provide it) in which case this is the same as
 \helpref{wxMilliSleep}{wxmillisleep}(\arg{microseconds}$/1000$).
 
 \wxheading{Include files}
 \helpref{wxMilliSleep}{wxmillisleep}(\arg{microseconds}$/1000$).
 
 \wxheading{Include files}
@@ -3994,8 +4025,8 @@ See also \helpref{wxTimer}{wxtimer}.
 \func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}}
 
 This function is deprecated because its name is misleading: notice that the
 \func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}}
 
 This function is deprecated because its name is misleading: notice that the
-argument is in milliseconds, not microseconds. Please use either 
-\helpref{wxMilliSleep}{wxmillisleep} or \helpref{wxMicroSleep}{wxmicrosleep} 
+argument is in milliseconds, not microseconds. Please use either
+\helpref{wxMilliSleep}{wxmillisleep} or \helpref{wxMicroSleep}{wxmicrosleep}
 depending on the resolution you need.
 
 
 depending on the resolution you need.
 
 
index 27b84005546b046535c539995a5ff68b42ca3994..38bade09743f35c1d65bd3411ee5cfbfde151fbc 100644 (file)
@@ -262,6 +262,26 @@ enum wxShutdownFlags
 // Shutdown or reboot the PC
 WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags);
 
 // Shutdown or reboot the PC
 WXDLLIMPEXP_BASE bool wxShutdown(wxShutdownFlags wFlags);
 
+enum wxPowerType
+{
+    wxPOWER_SOCKET,
+    wxPOWER_BATTERY,
+    wxPOWER_UNKNOWN
+};
+
+WXDLLIMPEXP_BASE wxPowerType wxGetPowerType();
+
+enum wxBatteryState
+{
+    wxBATTERY_NORMAL_STATE,    // system is fully usable
+    wxBATTERY_LOW_STATE,       // start to worry
+    wxBATTERY_CRITICAL_STATE,  // save quickly
+    wxBATTERY_SHUTDOWN_STATE,  // too late
+    wxBATTERY_UNKNOWN_STATE
+};
+
+WXDLLIMPEXP_BASE wxBatteryState wxGetBatteryState();
+
 // send the given signal to the process (only NONE and KILL are supported under
 // Windows, all others mean TERM), return 0 if ok and -1 on error
 //
 // send the given signal to the process (only NONE and KILL are supported under
 // Windows, all others mean TERM), return 0 if ok and -1 on error
 //
index 44e917e2a7206f621ef1a1f0dbbbd4d707e43424..26b435433be3577ab639f897f631b08ba0085b7a 100644 (file)
@@ -336,6 +336,18 @@ bool wxShutdown(wxShutdownFlags wFlags)
     return false;
 }
 
     return false;
 }
 
+wxPowerType wxGetPowerType()
+{
+    // TODO
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
+}
+
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
 wxMemorySize wxGetFreeMemory()
 {
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
 wxMemorySize wxGetFreeMemory()
 {
index e290dc06e50606d39d6c15c17862c16371b5c91d..979ac71cb06214829eabb4e5fe3516bf0bbdb23b 100644 (file)
@@ -190,6 +190,18 @@ bool wxShutdown(wxShutdownFlags wFlags)
     return false;
 }
 
     return false;
 }
 
+wxPowerType wxGetPowerType()
+{
+    // TODO
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
+}
+
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
 wxMemorySize wxGetFreeMemory()
 {
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
 wxMemorySize wxGetFreeMemory()
 {
index 22c24572dc53d5b012ee4b6852c0c5951c708b49..d2238eaddbb5522f0da527ffb3a6b5cd9f0edafe 100644 (file)
@@ -1007,6 +1007,18 @@ bool wxShutdown(wxShutdownFlags wFlags)
 #endif // Win32/16
 }
 
 #endif // Win32/16
 }
 
+wxPowerType wxGetPowerType()
+{
+    // TODO
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
+}
+
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
index 678f7c0edc033fc05bd1319a52c97bea197bd113..f7798795906fe1a102a838ede6afff0fc769187c 100644 (file)
@@ -204,6 +204,18 @@ bool wxShutdown(wxShutdownFlags wFlags)
     return false;
 }
 
     return false;
 }
 
+wxPowerType wxGetPowerType()
+{
+    // TODO
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
+}
+
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
 wxMemorySize wxGetFreeMemory()
 {
 // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
 wxMemorySize wxGetFreeMemory()
 {
index 02d4de03246a0a320bfc8b0cd4e3bdfd7375ee6c..f0cb433e0eaf3fbef84bd9350d10abb2ac17dd57 100644 (file)
@@ -151,6 +151,17 @@ bool wxShutdown(wxShutdownFlags wFlags)
     return false;
 }
 
     return false;
 }
 
+wxPowerType wxGetPowerType()
+{
+    return wxPOWER_BATTERY;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
+}
+
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // misc
 // ----------------------------------------------------------------------------
index cf1cf1240a3f5cf14907ff1e6b9bad6989f852ae..0a9c8e538da5c5358c6846c0848f055b63d86beb 100644 (file)
@@ -239,7 +239,7 @@ int wxKill(long pid, wxSignal sig, wxKillError *rc, int flags)
 
 long wxExecute( const wxString& command, int flags, wxProcess *process )
 {
 
 long wxExecute( const wxString& command, int flags, wxProcess *process )
 {
-    wxCHECK_MSG( !command.IsEmpty(), 0, wxT("can't exec empty command") );
+    wxCHECK_MSG( !command.empty(), 0, wxT("can't exec empty command") );
 
 #if wxUSE_THREADS
     // fork() doesn't mix well with POSIX threads: on many systems the program
 
 #if wxUSE_THREADS
     // fork() doesn't mix well with POSIX threads: on many systems the program
@@ -372,6 +372,17 @@ bool wxShutdown(wxShutdownFlags wFlags)
     return system(wxString::Format(_T("init %c"), level).mb_str()) == 0;
 }
 
     return system(wxString::Format(_T("init %c"), level).mb_str()) == 0;
 }
 
+wxPowerType wxGetPowerType()
+{
+    // TODO
+    return wxPOWER_UNKNOWN;
+}
+
+wxBatteryState wxGetBatteryState()
+{
+    // TODO
+    return wxBATTERY_UNKNOWN_STATE;
+}
 
 // ----------------------------------------------------------------------------
 // wxStream classes to support IO redirection in wxExecute
 
 // ----------------------------------------------------------------------------
 // wxStream classes to support IO redirection in wxExecute
@@ -660,9 +671,9 @@ long wxExecute(wxChar **argv,
 
 const wxChar* wxGetHomeDir( wxString *home  )
 {
 
 const wxChar* wxGetHomeDir( wxString *home  )
 {
-    *home = wxGetUserHome( wxString() );
+    *home = wxGetUserHome( wxEmptyString );
     wxString tmp;
     wxString tmp;
-    if ( home->IsEmpty() )
+    if ( home->empty() )
         *home = wxT("/");
 #ifdef __VMS
     tmp = *home;
         *home = wxT("/");
 #ifdef __VMS
     tmp = *home;