1. minor fixes in wxDynLib
2. added more symbols to winundef.h 3. fixed wxTextFile::IsOpen() - now it does what you'd suppose 4. listctrl now updates the item image when it changes 5. file dlg checks for an error and gives a message about it (debug only) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2973 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,12 +48,10 @@
|
|||||||
# error "wxLibrary can't be compiled on this platform, sorry."
|
# error "wxLibrary can't be compiled on this platform, sorry."
|
||||||
#endif // OS
|
#endif // OS
|
||||||
|
|
||||||
// defined in windows.h
|
// LoadLibrary is defined in windows.h as LoadLibraryA, but wxDllLoader method
|
||||||
// This breaks app.cpp if RICHEDIT is included.
|
// should be called LoadLibrary, not LoadLibraryA or LoadLibraryW!
|
||||||
#if 0
|
#if defined(__WIN32__) && defined(LoadLibrary)
|
||||||
#ifdef LoadLibrary
|
# include "wx/msw/winundef.h"
|
||||||
# undef LoadLibrary
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -75,7 +73,7 @@ class wxDllLoader
|
|||||||
@param success Must point to a bool variable which will be set to TRUE or FALSE.
|
@param success Must point to a bool variable which will be set to TRUE or FALSE.
|
||||||
@return A handle to the loaded DLL. Use success parameter to test if it is valid.
|
@return A handle to the loaded DLL. Use success parameter to test if it is valid.
|
||||||
*/
|
*/
|
||||||
static wxDllType LoadLibrary(const wxString & libname, bool *success);
|
static wxDllType LoadLibrary(const wxString & libname, bool *success = NULL);
|
||||||
/** This function unloads the shared library. */
|
/** This function unloads the shared library. */
|
||||||
static void UnloadLibrary(wxDllType dll);
|
static void UnloadLibrary(wxDllType dll);
|
||||||
/** This function returns a valid handle for the main program
|
/** This function returns a valid handle for the main program
|
||||||
|
@@ -157,9 +157,14 @@ const wxEventType wxEVT_COMPARE_ITEM = wxEVT_FIRST + 436;
|
|||||||
const wxEventType wxEVT_INIT_DIALOG = wxEVT_FIRST + 437;
|
const wxEventType wxEVT_INIT_DIALOG = wxEVT_FIRST + 437;
|
||||||
const wxEventType wxEVT_IDLE = wxEVT_FIRST + 438;
|
const wxEventType wxEVT_IDLE = wxEVT_FIRST + 438;
|
||||||
const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439;
|
const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439;
|
||||||
|
|
||||||
/* System misc. */
|
/* System misc. */
|
||||||
const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440;
|
const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440;
|
||||||
|
|
||||||
|
/* Dial up events */
|
||||||
|
const wxEventType wxEVT_DIALUP_CONNECTED = wxEVT_FIRST + 450;
|
||||||
|
const wxEventType wxEVT_DIALUP_DISCONNECTED = wxEVT_FIRST + 451;
|
||||||
|
|
||||||
/* Generic command events */
|
/* Generic command events */
|
||||||
/* Note: a click is a higher-level event than button down/up */
|
/* Note: a click is a higher-level event than button down/up */
|
||||||
const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500;
|
const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500;
|
||||||
|
@@ -16,7 +16,14 @@
|
|||||||
#define _WX_WINUNDEF_H_
|
#define _WX_WINUNDEF_H_
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// windows.h #defines the following identifiers which are also used in wxWin
|
// ----------------------------------------------------------------------------
|
||||||
|
// windows.h #defines the following identifiers which are also used in wxWin so
|
||||||
|
// we replace these symbols with the corresponding inline functions and
|
||||||
|
// undefine the macro.
|
||||||
|
//
|
||||||
|
// This looks quite ugly here but allows us to write clear (and correct!) code
|
||||||
|
// elsewhere because the functions, unlike the macros, respect the scope.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// GetCharWidth
|
// GetCharWidth
|
||||||
|
|
||||||
@@ -152,6 +159,7 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// GetMessage
|
||||||
|
|
||||||
#ifdef GetMessage
|
#ifdef GetMessage
|
||||||
#undef GetMessage
|
#undef GetMessage
|
||||||
@@ -165,6 +173,20 @@
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// LoadLibrary
|
||||||
|
|
||||||
|
#ifdef LoadLibrary
|
||||||
|
#undef LoadLibrary
|
||||||
|
inline HINSTANCE LoadLibrary(LPCTSTR lpLibFileName)
|
||||||
|
{
|
||||||
|
#ifdef _UNICODE
|
||||||
|
return LoadLibraryW(lpLibFileName);
|
||||||
|
#else
|
||||||
|
return LoadLibraryA(lpLibFileName);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// For WINE
|
// For WINE
|
||||||
|
|
||||||
#if defined(GetWindowStyle) || defined(__WXWINE__)
|
#if defined(GetWindowStyle) || defined(__WXWINE__)
|
||||||
|
@@ -63,7 +63,7 @@ public:
|
|||||||
// closes the file and frees memory, losing all changes
|
// closes the file and frees memory, losing all changes
|
||||||
bool Close();
|
bool Close();
|
||||||
// is file currently opened?
|
// is file currently opened?
|
||||||
bool IsOpened() const { return m_file.IsOpened(); }
|
bool IsOpened() const { return m_isOpened; }
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// get the number of lines in the file
|
// get the number of lines in the file
|
||||||
@@ -137,6 +137,8 @@ private:
|
|||||||
|
|
||||||
size_t m_nCurLine; // number of current line in the file
|
size_t m_nCurLine; // number of current line in the file
|
||||||
|
|
||||||
|
bool m_isOpened; // was the file successfully opened the last time?
|
||||||
|
|
||||||
wxString m_strFile; // name of the file
|
wxString m_strFile; // name of the file
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -185,41 +185,40 @@ wxDllLoader::GetProgramHandle(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
wxDllType
|
wxDllType
|
||||||
wxDllLoader::LoadLibrary(const wxString & lib_name, bool *success)
|
wxDllLoader::LoadLibrary(const wxString & libname, bool *success)
|
||||||
{
|
{
|
||||||
wxASSERT(success);
|
wxDllType handle;
|
||||||
|
|
||||||
wxDllType handle;
|
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
FSSpec myFSSpec ;
|
FSSpec myFSSpec ;
|
||||||
Ptr myMainAddr ;
|
Ptr myMainAddr ;
|
||||||
Str255 myErrName ;
|
Str255 myErrName ;
|
||||||
|
|
||||||
wxMacPathToFSSpec( lib_name , &myFSSpec ) ;
|
wxMacPathToFSSpec( libname , &myFSSpec ) ;
|
||||||
if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
|
if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
|
||||||
myErrName ) != noErr )
|
myErrName ) != noErr )
|
||||||
{
|
{
|
||||||
p2cstr( myErrName ) ;
|
p2cstr( myErrName ) ;
|
||||||
wxASSERT_MSG( 1 , (char*)myErrName ) ;
|
wxASSERT_MSG( 1 , (char*)myErrName ) ;
|
||||||
return NULL ;
|
return NULL ;
|
||||||
}
|
}
|
||||||
#else // !Mac
|
#else // !Mac
|
||||||
handle = wxDllOpen(lib_name);
|
handle = wxDllOpen(libname);
|
||||||
#endif // OS
|
#endif // OS
|
||||||
|
|
||||||
if ( !handle )
|
if ( !handle )
|
||||||
{
|
{
|
||||||
wxLogSysError(_("Failed to load shared library '%s'"),
|
wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str());
|
||||||
lib_name.c_str());
|
}
|
||||||
*success = FALSE;
|
|
||||||
return NULL;
|
if ( success )
|
||||||
}
|
{
|
||||||
*success = TRUE;
|
*success = handle != 0;
|
||||||
return handle;
|
}
|
||||||
|
|
||||||
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -234,26 +233,26 @@ wxDllLoader::UnloadLibrary(wxDllType handle)
|
|||||||
void *
|
void *
|
||||||
wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name)
|
wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name)
|
||||||
{
|
{
|
||||||
void *symbol = NULL; // return value
|
void *symbol = NULL; // return value
|
||||||
|
|
||||||
#if defined( __WXMAC__ )
|
#if defined( __WXMAC__ )
|
||||||
Ptr symAddress ;
|
Ptr symAddress ;
|
||||||
CFragSymbolClass symClass ;
|
CFragSymbolClass symClass ;
|
||||||
Str255 symName ;
|
Str255 symName ;
|
||||||
|
|
||||||
strcpy( (char*) symName , name ) ;
|
strcpy( (char*) symName , name ) ;
|
||||||
c2pstr( (char*) symName ) ;
|
c2pstr( (char*) symName ) ;
|
||||||
|
|
||||||
if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
|
if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
|
||||||
symbol = (void *)symAddress ;
|
symbol = (void *)symAddress ;
|
||||||
#else
|
#else
|
||||||
symbol = wxDllGetSymbol(dllHandle, name);
|
symbol = wxDllGetSymbol(dllHandle, name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( !symbol )
|
if ( !symbol )
|
||||||
{
|
{
|
||||||
wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
|
wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
|
||||||
name.c_str());
|
name.c_str());
|
||||||
}
|
}
|
||||||
return symbol;
|
return symbol;
|
||||||
}
|
}
|
||||||
@@ -291,7 +290,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
|||||||
old_sm_first = wxClassInfo::sm_first;
|
old_sm_first = wxClassInfo::sm_first;
|
||||||
wxClassInfo::sm_first = NULL;
|
wxClassInfo::sm_first = NULL;
|
||||||
|
|
||||||
wxString lib_name = ConstructLibraryName(name);
|
wxString libname = ConstructLibraryName(name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Unix automatically builds that library name, at least for dlopen()
|
Unix automatically builds that library name, at least for dlopen()
|
||||||
@@ -308,10 +307,10 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
|||||||
{
|
{
|
||||||
wxString fullname(tokenizer.NextToken());
|
wxString fullname(tokenizer.NextToken());
|
||||||
|
|
||||||
fullname << '/' << lib_name;
|
fullname << '/' << libname;
|
||||||
if ( wxFileExists(fullname) )
|
if ( wxFileExists(fullname) )
|
||||||
{
|
{
|
||||||
lib_name = fullname;
|
libname = fullname;
|
||||||
|
|
||||||
// found the library
|
// found the library
|
||||||
break;
|
break;
|
||||||
@@ -323,7 +322,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool success = FALSE;
|
bool success = FALSE;
|
||||||
wxDllType handle = wxDllLoader::LoadLibrary(lib_name, &success);
|
wxDllType handle = wxDllLoader::LoadLibrary(libname, &success);
|
||||||
if(success)
|
if(success)
|
||||||
{
|
{
|
||||||
lib = new wxLibrary(handle);
|
lib = new wxLibrary(handle);
|
||||||
|
@@ -63,6 +63,8 @@ const wxTextFileType wxTextFile::typeDefault =
|
|||||||
|
|
||||||
wxTextFile::wxTextFile(const wxString& strFile) : m_strFile(strFile)
|
wxTextFile::wxTextFile(const wxString& strFile) : m_strFile(strFile)
|
||||||
{
|
{
|
||||||
|
m_nCurLine = 0;
|
||||||
|
m_isOpened = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextFile::~wxTextFile()
|
wxTextFile::~wxTextFile()
|
||||||
@@ -91,11 +93,11 @@ bool wxTextFile::Open()
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// read file into memory
|
// read file into memory
|
||||||
bool bRet = Read();
|
m_isOpened = Read();
|
||||||
|
|
||||||
m_file.Close();
|
m_file.Close();
|
||||||
|
|
||||||
return bRet;
|
return m_isOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
// analyse some lines of the file trying to guess it's type.
|
// analyse some lines of the file trying to guess it's type.
|
||||||
@@ -175,7 +177,6 @@ bool wxTextFile::Read()
|
|||||||
nRead = m_file.Read(buf, WXSIZEOF(buf));
|
nRead = m_file.Read(buf, WXSIZEOF(buf));
|
||||||
if ( nRead == wxInvalidOffset ) {
|
if ( nRead == wxInvalidOffset ) {
|
||||||
// read error (error message already given in wxFile::Read)
|
// read error (error message already given in wxFile::Read)
|
||||||
m_file.Close();
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +232,7 @@ bool wxTextFile::Close()
|
|||||||
m_aTypes.Clear();
|
m_aTypes.Clear();
|
||||||
m_aLines.Clear();
|
m_aLines.Clear();
|
||||||
m_nCurLine = 0;
|
m_nCurLine = 0;
|
||||||
|
m_isOpened = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -341,9 +341,23 @@ int wxFileDialog::ShowModal(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // END: if ( success )
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// common dialog failed - why?
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
DWORD dwErr = CommDlgExtendedError();
|
||||||
|
if ( dwErr != 0 )
|
||||||
|
{
|
||||||
|
// this msg is only for developers
|
||||||
|
wxLogError(_T("Common dialog failed with error code %0lx."),
|
||||||
|
dwErr);
|
||||||
|
}
|
||||||
|
//else: it was just cancelled
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return (success ? wxID_OK : wxID_CANCEL) ;
|
return success ? wxID_OK : wxID_CANCEL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -551,7 +551,14 @@ bool wxListCtrl::SetItem(wxListItem& info)
|
|||||||
LV_ITEM item;
|
LV_ITEM item;
|
||||||
wxConvertToMSWListItem(this, info, item);
|
wxConvertToMSWListItem(this, info, item);
|
||||||
item.cchTextMax = 0;
|
item.cchTextMax = 0;
|
||||||
return (ListView_SetItem(GetHwnd(), &item) != 0);
|
bool ok = ListView_SetItem(GetHwnd(), &item) != 0;
|
||||||
|
if ( ok && (info.m_mask & wxLIST_MASK_IMAGE) )
|
||||||
|
{
|
||||||
|
// make the change visible
|
||||||
|
ListView_Update(GetHwnd(), item.iItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
|
long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
|
||||||
|
Reference in New Issue
Block a user