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."
|
||||
#endif // OS
|
||||
|
||||
// defined in windows.h
|
||||
// This breaks app.cpp if RICHEDIT is included.
|
||||
#if 0
|
||||
#ifdef LoadLibrary
|
||||
# undef LoadLibrary
|
||||
#endif
|
||||
// LoadLibrary is defined in windows.h as LoadLibraryA, but wxDllLoader method
|
||||
// should be called LoadLibrary, not LoadLibraryA or LoadLibraryW!
|
||||
#if defined(__WIN32__) && defined(LoadLibrary)
|
||||
# include "wx/msw/winundef.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -75,7 +73,7 @@ class wxDllLoader
|
||||
@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.
|
||||
*/
|
||||
static wxDllType LoadLibrary(const wxString & libname, bool *success);
|
||||
static wxDllType LoadLibrary(const wxString & libname, bool *success = NULL);
|
||||
/** This function unloads the shared library. */
|
||||
static void UnloadLibrary(wxDllType dll);
|
||||
/** 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_IDLE = wxEVT_FIRST + 438;
|
||||
const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439;
|
||||
|
||||
/* System misc. */
|
||||
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 */
|
||||
/* Note: a click is a higher-level event than button down/up */
|
||||
const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500;
|
||||
|
@@ -16,7 +16,14 @@
|
||||
#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
|
||||
|
||||
@@ -152,6 +159,7 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
// GetMessage
|
||||
|
||||
#ifdef GetMessage
|
||||
#undef GetMessage
|
||||
@@ -165,6 +173,20 @@
|
||||
}
|
||||
#endif
|
||||
|
||||
// LoadLibrary
|
||||
|
||||
#ifdef LoadLibrary
|
||||
#undef LoadLibrary
|
||||
inline HINSTANCE LoadLibrary(LPCTSTR lpLibFileName)
|
||||
{
|
||||
#ifdef _UNICODE
|
||||
return LoadLibraryW(lpLibFileName);
|
||||
#else
|
||||
return LoadLibraryA(lpLibFileName);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// For WINE
|
||||
|
||||
#if defined(GetWindowStyle) || defined(__WXWINE__)
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
// closes the file and frees memory, losing all changes
|
||||
bool Close();
|
||||
// is file currently opened?
|
||||
bool IsOpened() const { return m_file.IsOpened(); }
|
||||
bool IsOpened() const { return m_isOpened; }
|
||||
|
||||
// accessors
|
||||
// get the number of lines in the file
|
||||
@@ -137,6 +137,8 @@ private:
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
@@ -182,44 +182,43 @@ wxDllLoader::GetProgramHandle(void)
|
||||
wxFAIL_MSG(_("This method is not implemented under Windows"));
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* static */
|
||||
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__)
|
||||
FSSpec myFSSpec ;
|
||||
Ptr myMainAddr ;
|
||||
Str255 myErrName ;
|
||||
|
||||
wxMacPathToFSSpec( lib_name , &myFSSpec ) ;
|
||||
if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
|
||||
myErrName ) != noErr )
|
||||
{
|
||||
p2cstr( myErrName ) ;
|
||||
wxASSERT_MSG( 1 , (char*)myErrName ) ;
|
||||
return NULL ;
|
||||
}
|
||||
FSSpec myFSSpec ;
|
||||
Ptr myMainAddr ;
|
||||
Str255 myErrName ;
|
||||
|
||||
wxMacPathToFSSpec( libname , &myFSSpec ) ;
|
||||
if (GetDiskFragment( &myFSSpec , 0 , kCFragGoesToEOF , "\p" , kPrivateCFragCopy , &handle , &myMainAddr ,
|
||||
myErrName ) != noErr )
|
||||
{
|
||||
p2cstr( myErrName ) ;
|
||||
wxASSERT_MSG( 1 , (char*)myErrName ) ;
|
||||
return NULL ;
|
||||
}
|
||||
#else // !Mac
|
||||
handle = wxDllOpen(lib_name);
|
||||
handle = wxDllOpen(libname);
|
||||
#endif // OS
|
||||
|
||||
if ( !handle )
|
||||
{
|
||||
wxLogSysError(_("Failed to load shared library '%s'"),
|
||||
lib_name.c_str());
|
||||
*success = FALSE;
|
||||
return NULL;
|
||||
}
|
||||
*success = TRUE;
|
||||
return handle;
|
||||
if ( !handle )
|
||||
{
|
||||
wxLogSysError(_("Failed to load shared library '%s'"), libname.c_str());
|
||||
}
|
||||
|
||||
if ( success )
|
||||
{
|
||||
*success = handle != 0;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
@@ -234,26 +233,26 @@ wxDllLoader::UnloadLibrary(wxDllType handle)
|
||||
void *
|
||||
wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name)
|
||||
{
|
||||
void *symbol = NULL; // return value
|
||||
void *symbol = NULL; // return value
|
||||
|
||||
#if defined( __WXMAC__ )
|
||||
Ptr symAddress ;
|
||||
CFragSymbolClass symClass ;
|
||||
Str255 symName ;
|
||||
|
||||
strcpy( (char*) symName , name ) ;
|
||||
c2pstr( (char*) symName ) ;
|
||||
|
||||
if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
|
||||
symbol = (void *)symAddress ;
|
||||
Ptr symAddress ;
|
||||
CFragSymbolClass symClass ;
|
||||
Str255 symName ;
|
||||
|
||||
strcpy( (char*) symName , name ) ;
|
||||
c2pstr( (char*) symName ) ;
|
||||
|
||||
if ( FindSymbol( dllHandle , symName , &symAddress , &symClass ) == noErr )
|
||||
symbol = (void *)symAddress ;
|
||||
#else
|
||||
symbol = wxDllGetSymbol(dllHandle, name);
|
||||
#endif
|
||||
|
||||
if ( !symbol )
|
||||
{
|
||||
wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
|
||||
name.c_str());
|
||||
wxLogSysError(_("Couldn't find symbol '%s' in a dynamic library"),
|
||||
name.c_str());
|
||||
}
|
||||
return symbol;
|
||||
}
|
||||
@@ -291,7 +290,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
||||
old_sm_first = wxClassInfo::sm_first;
|
||||
wxClassInfo::sm_first = NULL;
|
||||
|
||||
wxString lib_name = ConstructLibraryName(name);
|
||||
wxString libname = ConstructLibraryName(name);
|
||||
|
||||
/*
|
||||
Unix automatically builds that library name, at least for dlopen()
|
||||
@@ -308,10 +307,10 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
||||
{
|
||||
wxString fullname(tokenizer.NextToken());
|
||||
|
||||
fullname << '/' << lib_name;
|
||||
fullname << '/' << libname;
|
||||
if ( wxFileExists(fullname) )
|
||||
{
|
||||
lib_name = fullname;
|
||||
libname = fullname;
|
||||
|
||||
// found the library
|
||||
break;
|
||||
@@ -323,7 +322,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
|
||||
#endif
|
||||
|
||||
bool success = FALSE;
|
||||
wxDllType handle = wxDllLoader::LoadLibrary(lib_name, &success);
|
||||
wxDllType handle = wxDllLoader::LoadLibrary(libname, &success);
|
||||
if(success)
|
||||
{
|
||||
lib = new wxLibrary(handle);
|
||||
|
@@ -63,6 +63,8 @@ const wxTextFileType wxTextFile::typeDefault =
|
||||
|
||||
wxTextFile::wxTextFile(const wxString& strFile) : m_strFile(strFile)
|
||||
{
|
||||
m_nCurLine = 0;
|
||||
m_isOpened = FALSE;
|
||||
}
|
||||
|
||||
wxTextFile::~wxTextFile()
|
||||
@@ -91,11 +93,11 @@ bool wxTextFile::Open()
|
||||
return FALSE;
|
||||
|
||||
// read file into memory
|
||||
bool bRet = Read();
|
||||
m_isOpened = Read();
|
||||
|
||||
m_file.Close();
|
||||
|
||||
return bRet;
|
||||
return m_isOpened;
|
||||
}
|
||||
|
||||
// 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));
|
||||
if ( nRead == wxInvalidOffset ) {
|
||||
// read error (error message already given in wxFile::Read)
|
||||
m_file.Close();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -231,6 +232,7 @@ bool wxTextFile::Close()
|
||||
m_aTypes.Clear();
|
||||
m_aLines.Clear();
|
||||
m_nCurLine = 0;
|
||||
m_isOpened = FALSE;
|
||||
|
||||
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;
|
||||
wxConvertToMSWListItem(this, info, item);
|
||||
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)
|
||||
|
Reference in New Issue
Block a user