1. wxLoad/SaveFileSelector return "wxString" instead of "char *"

2. WXDLLEXPORT was misplaced in a couple of places (hopefully my chanegs won't
   break compilation for other compilers)
3. Some VC++ warnings suppressed in socket code


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1464 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 1999-01-24 23:31:39 +00:00
parent 08853b68b7
commit ba681060f3
18 changed files with 164 additions and 188 deletions

View File

@ -82,7 +82,7 @@ class WXDLLEXPORT wxDate: public wxObject
friend bool WXDLLEXPORT operator == (const wxDate &dt1, const wxDate &dt2);
friend bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2);
friend ostream& WXDLLEXPORT operator << (ostream &os, const wxDate &dt);
friend ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt);
wxString FormatDate (int type=-1) const;
void SetFormat (int format);

View File

@ -15,5 +15,41 @@
#include "wx/stubs/filedlg.h"
#endif
// File selector - backward compatibility
WXDLLEXPORT wxString
wxFileSelector(const char *message = wxFileSelectorPromptStr,
const char *default_path = NULL,
const char *default_filename = NULL,
const char *default_extension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT wxString
wxFileSelectorEx(const char *message = wxFileSelectorPromptStr,
const char *default_path = NULL,
const char *default_filename = NULL,
int *indexDefaultExtension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr,
int flags = 0,
wxWindow *parent = NULL,
int x = -1, int y = -1);
// Ask for filename to load
WXDLLEXPORT wxString
wxLoadFileSelector(const char *what,
const char *extension,
const char *default_name = (const char *)NULL,
wxWindow *parent = (wxWindow *) NULL);
// Ask for filename to save
WXDLLEXPORT wxString
wxSaveFileSelector(const char *what,
const char *extension,
const char *default_name = (const char *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif
// _WX_FILEDLG_H_BASE_

View File

@ -85,9 +85,9 @@ class WXDLLEXPORT wxGenericFontDialog: public wxDialog
DECLARE_EVENT_TABLE()
};
char* WXDLLEXPORT wxFontFamilyIntToString(int family);
char* WXDLLEXPORT wxFontWeightIntToString(int weight);
char* WXDLLEXPORT wxFontStyleIntToString(int style);
char WXDLLEXPORT *wxFontFamilyIntToString(int family);
char WXDLLEXPORT *wxFontWeightIntToString(int weight);
char WXDLLEXPORT *wxFontStyleIntToString(int style);
int WXDLLEXPORT wxFontFamilyStringToInt(char *family);
int WXDLLEXPORT wxFontWeightStringToInt(char *weight);
int WXDLLEXPORT wxFontStyleStringToInt(char *style);

View File

@ -76,20 +76,5 @@ class wxFileDialog: public wxDialog
#define wxHIDE_READONLY 8
#define wxFILE_MUST_EXIST 16
// File selector - backward compatibility
char* wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = (const char *) NULL,
const char *default_filename = (const char *) NULL, const char *default_extension = (const char *) NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1);
char* wxLoadFileSelector(const char *what, const char *extension, const char *default_name = (const char *) NULL,
wxWindow *parent = (wxWindow *) NULL);
char* wxSaveFileSelector(const char *what, const char *extension, const char *default_name = (const char *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif
// __GTKFILEDLGH__

View File

@ -76,20 +76,5 @@ class wxFileDialog: public wxDialog
#define wxHIDE_READONLY 8
#define wxFILE_MUST_EXIST 16
// File selector - backward compatibility
char* wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = (const char *) NULL,
const char *default_filename = (const char *) NULL, const char *default_extension = (const char *) NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = (wxWindow *) NULL, int x = -1, int y = -1);
char* wxLoadFileSelector(const char *what, const char *extension, const char *default_name = (const char *) NULL,
wxWindow *parent = (wxWindow *) NULL);
char* wxSaveFileSelector(const char *what, const char *extension, const char *default_name = (const char *) NULL,
wxWindow *parent = (wxWindow *) NULL);
#endif
// __GTKFILEDLGH__

View File

@ -6,7 +6,7 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDLG_H_
@ -28,15 +28,7 @@ WXDLLEXPORT_DATA(extern const char*) wxFileSelectorDefaultWildcardStr;
class WXDLLEXPORT wxFileDialog: public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxFileDialog)
protected:
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
wxString m_dir;
wxString m_path; // Full path
wxString m_fileName;
wxString m_wildCard;
int m_filterIndex;
public:
wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = wxEmptyString, const wxString& defaultFile = wxEmptyString, const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
@ -59,6 +51,16 @@ public:
inline int GetFilterIndex(void) const { return m_filterIndex ; }
int ShowModal(void);
protected:
wxString m_message;
long m_dialogStyle;
wxWindow * m_parent;
wxString m_dir;
wxString m_path; // Full path
wxString m_fileName;
wxString m_wildCard;
int m_filterIndex;
};
#define wxOPEN 0x0001
@ -67,23 +69,5 @@ public:
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility
WXDLLEXPORT char* wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, const char *default_extension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// An extended version of wxFileSelector
WXDLLEXPORT char* wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, int *indexDefaultExtension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// Generic file load dialog
WXDLLEXPORT char* wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
// Generic file save dialog
WXDLLEXPORT char* wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
#endif
// _WX_FILEDLG_H_

View File

@ -67,23 +67,5 @@ public:
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility
char* WXDLLEXPORT wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, const char *default_extension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// An extended version of wxFileSelector
char* WXDLLEXPORT wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, int *indexDefaultExtension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// Generic file load dialog
char* WXDLLEXPORT wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
// Generic file save dialog
char* WXDLLEXPORT wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
#endif
// _WX_FILEDLG_H_

View File

@ -67,23 +67,5 @@ public:
#define wxHIDE_READONLY 0x0008
#define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility
char* WXDLLEXPORT wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, const char *default_extension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// An extended version of wxFileSelector
char* WXDLLEXPORT wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL,
const char *default_filename = NULL, int *indexDefaultExtension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1);
// Generic file load dialog
char* WXDLLEXPORT wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
// Generic file save dialog
char* WXDLLEXPORT wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL);
#endif
// _WX_FILEDLG_H_

View File

@ -279,7 +279,7 @@ bool WXDLLEXPORT operator != (const wxDate &dt1, const wxDate &dt2)
// Ostream operations
////////////////////////////////////////////////////////////////
ostream& WXDLLEXPORT operator << (ostream &os, const wxDate &dt)
ostream WXDLLEXPORT & operator << (ostream &os, const wxDate &dt)
{
return os << (const char *) dt.FormatDate();
}

View File

@ -194,18 +194,21 @@ bool wxDocument::Save(void)
bool wxDocument::SaveAs(void)
{
wxDocTemplate *docTemplate = GetDocumentTemplate();
if (!docTemplate)
return FALSE;
char *tmp = wxFileSelector(_("Save as"), docTemplate->GetDirectory(), GetFilename(),
docTemplate->GetDefaultExtension(), docTemplate->GetFileFilter(),
wxSAVE|wxOVERWRITE_PROMPT, GetDocumentWindow());
wxDocTemplate *docTemplate = GetDocumentTemplate();
if (!docTemplate)
return FALSE;
if (!tmp)
return FALSE;
else
{
wxString tmp = wxFileSelector(_("Save as"),
docTemplate->GetDirectory(),
GetFilename(),
docTemplate->GetDefaultExtension(),
docTemplate->GetFileFilter(),
wxSAVE | wxOVERWRITE_PROMPT,
GetDocumentWindow());
if (tmp.IsEmpty())
return FALSE;
wxString fileName(tmp);
wxString path("");
wxString name("");
@ -231,8 +234,8 @@ bool wxDocument::SaveAs(void)
view->OnChangeFilename();
node = node->Next();
}
}
return OnSaveDocument(m_documentFile);
return OnSaveDocument(m_documentFile);
}
bool wxDocument::OnSaveDocument(const wxString& file)
@ -1144,33 +1147,30 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **WXUNUSED(templat
{
// We can only have multiple filters in Windows
#ifdef __WXMSW__
char *descrBuf = new char[1000]; // FIXME static buffer
descrBuf[0] = 0;
int i;
for (i = 0; i < noTemplates; i++)
{
if (templates[i]->IsVisible())
wxString descrBuf;
int i;
for (i = 0; i < noTemplates; i++)
{
strcat(descrBuf, templates[i]->GetDescription());
strcat(descrBuf, " (");
strcat(descrBuf, templates[i]->GetFileFilter());
strcat(descrBuf, ") ");
strcat(descrBuf, "|");
strcat(descrBuf, templates[i]->GetFileFilter());
strcat(descrBuf, "|");
if (templates[i]->IsVisible())
{
// add a '|' to separate this filter from the previous one
if ( !descrBuf.IsEmpty() )
descrBuf << '|';
descrBuf << templates[i]->GetDescription()
<< " (" << templates[i]->GetFileFilter() << ") |"
<< templates[i]->GetFileFilter();
}
}
}
int len = strlen(descrBuf);
if (len > 0)
// Omit final "|"
descrBuf[len-1] = 0;
#else
char* descrBuf = copystring("*.*");
wxString descrBuf = "*.*";
#endif
char *pathTmp = wxFileSelector(_("Select a file"), "", "", "", descrBuf, 0, wxTheApp->GetTopWindow());
delete[] descrBuf;
if (pathTmp)
wxString pathTmp = wxFileSelector(_("Select a file"), "", "", "",
descrBuf, 0, wxTheApp->GetTopWindow());
if (!pathTmp.IsEmpty())
{
path = pathTmp;
char *theExt = FindExtension((char *)(const char *)path);

View File

@ -439,6 +439,11 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes)
{
SockMsg msg;
// warning about 'cast truncates constant value'
#ifdef _MSC_VER
#pragma warning(disable: 4310)
#endif // _MSC_VER
msg.sig[0] = (char) 0xad;
msg.sig[1] = (char) 0xde;
msg.sig[2] = (char) 0xed;
@ -462,6 +467,10 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes)
Write((char *)&msg, sizeof(msg));
return *this;
#ifdef _MSC_VER
#pragma warning(default: 4310)
#endif // _MSC_VER
}
wxSocketBase& wxSocketBase::Unread(const char *buffer, size_t nbytes)
@ -1602,7 +1611,12 @@ LRESULT APIENTRY _EXPORT wxSocketHandlerWndProc(HWND hWnd, UINT message,
case FD_CONNECT:
sk_req = wxSocketBase::EVT_CONNECT;
break;
default:
wxFAIL_MSG("invalid socket event");
return (LRESULT)0;
}
sock->OnRequest(sk_req);
return (LRESULT)0;

View File

@ -80,7 +80,7 @@ static const struct
} g_strEmpty = { {-1, 0, 0}, '\0' };
// empty C style string: points to 'string data' byte of g_strEmpty
extern const char *g_szNul = &g_strEmpty.dummy;
extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy;
// ----------------------------------------------------------------------------
// conditional compilation

View File

@ -335,12 +335,13 @@ bool wxPostScriptDC::PrinterDialog(wxWindow *parent)
}
else if ((m_filename == "") && (wxThePrintSetupData->GetPrinterMode() == PS_FILE))
{
char *file = wxSaveFileSelector (_("PostScript"), "ps");
if (!file)
wxString file = wxSaveFileSelector (_("PostScript"), "ps");
if ( file.IsEmpty() )
{
m_ok = FALSE;
return FALSE;
}
wxThePrintSetupData->SetPrinterFile(file);
m_filename = file;
m_ok = TRUE;

View File

@ -156,14 +156,14 @@ void wxGenericPrintDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
wxThePrintSetupData->SetPrinterMode(PS_FILE);
char *f = wxFileSelector(_("PostScript file"),
wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
"ps", "*.ps", 0, this);
if (f)
wxThePrintSetupData->SetPrinterFile(f);
else
return;
wxString f = wxFileSelector(_("PostScript file"),
wxPathOnly(wxThePrintSetupData->GetPrinterFile()),
wxFileNameFromPath(wxThePrintSetupData->GetPrinterFile()),
"ps", "*.ps", 0, this);
if ( f.IsEmpty() )
return;
wxThePrintSetupData->SetPrinterFile(f);
}
else
wxThePrintSetupData->SetPrinterMode(PS_PRINTER);
@ -425,7 +425,7 @@ void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event))
wxPrintData data;
data.SetSetupDialog(TRUE);
wxPrintDialog *printDialog = new wxPrintDialog(this, & data);
int ret = printDialog->ShowModal();
printDialog->ShowModal();
printDialog->Destroy();

View File

@ -260,7 +260,7 @@ bool wxApp::Initialize()
// This is to foil optimizations in Visual C++ that
// throw out dummy.obj.
#if defined(_MSC_VER) && !defined(WXMAKINGDLL)
#if 0 && defined(_MSC_VER) && !defined(WXMAKINGDLL)
extern char wxDummyChar;
if (wxDummyChar) wxDummyChar++;
#endif

View File

@ -97,8 +97,8 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE);
#if defined(__WIN95__)
long style = GetWindowLong((HWND) GetHWND(), GWL_STYLE);
if (style & BS_BITMAP)
{
// Should we call Default() here?

View File

@ -10,30 +10,30 @@
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "filedlg.h"
#pragma implementation "filedlg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/defs.h"
#include "wx/utils.h"
#include "wx/msgdlg.h"
#include "wx/dialog.h"
#include "wx/filedlg.h"
#include "wx/intl.h"
#include <stdio.h>
#include "wx/defs.h"
#include "wx/utils.h"
#include "wx/msgdlg.h"
#include "wx/dialog.h"
#include "wx/filedlg.h"
#include "wx/intl.h"
#endif
#include <windows.h>
#if !defined(__WIN32__) || defined(__SALFORDC__)
#include <commdlg.h>
#include <commdlg.h>
#endif
#include "wx/msw/private.h"
@ -43,13 +43,17 @@
#include <string.h>
#if !USE_SHARED_LIBRARY
IMPLEMENT_CLASS(wxFileDialog, wxDialog)
IMPLEMENT_CLASS(wxFileDialog, wxDialog)
#endif
char *wxFileSelector(const char *title,
const char *defaultDir, const char *defaultFileName,
const char *defaultExtension, const char *filter, int flags,
wxWindow *parent, int x, int y)
wxString wxFileSelector(const char *title,
const char *defaultDir,
const char *defaultFileName,
const char *defaultExtension,
const char *filter,
int flags,
wxWindow *parent,
int x, int y)
{
// In the original implementation, defaultExtension is passed to the
// lpstrDefExt member of OPENFILENAME. This extension, if non-NULL, is
@ -120,7 +124,7 @@ char *wxFileSelector(const char *title,
return wxBuffer;
}
else
return NULL;
return wxGetEmptyString();
}
# if __BORLANDC__
@ -144,7 +148,7 @@ char *wxFileSelector(const char *title,
# endif
char *wxFileSelectorEx(const char *title,
wxString wxFileSelectorEx(const char *title,
const char *defaultDir,
const char *defaultFileName,
int* defaultFilterIndex,
@ -165,7 +169,7 @@ char *wxFileSelectorEx(const char *title,
return wxBuffer;
}
else
return NULL;
return wxGetEmptyString();
}
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
@ -328,17 +332,16 @@ int wxFileDialog::ShowModal(void)
}
// Generic file load/save dialog
static char *
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
// Generic file load/save dialog (for internal use only)
static
wxString wxDefaultFileSelector(bool load,
const char *what,
const char *extension,
const char *default_name,
wxWindow *parent)
{
wxString prompt;
wxString str;
if (load)
str = _("Load %s file");
else
str = _("Save %s file");
wxString str = load ? _("Load %s file") : _("Save %s file");
prompt.Printf(str, what);
const char *ext = extension;
@ -352,18 +355,20 @@ wxDefaultFileSelector(bool load, const char *what, const char *extension, const
}
// Generic file load dialog
char *
wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
WXDLLEXPORT wxString wxLoadFileSelector(const char *what,
const char *extension,
const char *default_name,
wxWindow *parent)
{
return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
}
// Generic file save dialog
char *
wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
WXDLLEXPORT wxString wxSaveFileSelector(const char *what,
const char *extension,
const char *default_name,
wxWindow *parent)
{
return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
}

View File

@ -48,7 +48,7 @@
#undef GetClassName
#endif
#if wxUSE_NATIVE_STATUSBAR
#if wxUSE_NATIVE_STATUSBAR
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStatusBar95, wxStatusBar);
@ -236,7 +236,9 @@ void wxStatusBar95::OnSize(wxSizeEvent& event)
SetFieldsWidth();
}
#endif
// __WIN95__
#endif
// wxUSE_NATIVE_STATUSBAR
#endif // wxUSE_NATIVE_STATUSBAR
#else
#error "wxStatusBar95 is only available under Windows 95 and later."
#endif // __WIN95__