replace use of 'long/int bitmapType' with 'wxBitmapType bitmapType' in richtext and wxMemoryFSHandler
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53535 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -99,11 +99,11 @@ public:
|
||||
#if wxUSE_IMAGE
|
||||
static void AddFile(const wxString& filename,
|
||||
const wxImage& image,
|
||||
long type);
|
||||
wxBitmapType type);
|
||||
|
||||
static void AddFile(const wxString& filename,
|
||||
const wxBitmap& bitmap,
|
||||
long type);
|
||||
wxBitmapType type);
|
||||
#endif // wxUSE_IMAGE
|
||||
|
||||
};
|
||||
|
@@ -80,6 +80,8 @@ enum wxBitmapType
|
||||
wxBITMAP_TYPE_TGA,
|
||||
wxBITMAP_TYPE_MACCURSOR,
|
||||
wxBITMAP_TYPE_MACCURSOR_RESOURCE,
|
||||
|
||||
wxBITMAP_TYPE_MAX,
|
||||
wxBITMAP_TYPE_ANY = 50
|
||||
};
|
||||
|
||||
|
@@ -91,13 +91,15 @@ extern WXDLLIMPEXP_RICHTEXT const wxChar wxRichTextLineBreakChar;
|
||||
/*!
|
||||
* File types
|
||||
*/
|
||||
|
||||
#define wxRICHTEXT_TYPE_ANY 0
|
||||
#define wxRICHTEXT_TYPE_TEXT 1
|
||||
#define wxRICHTEXT_TYPE_XML 2
|
||||
#define wxRICHTEXT_TYPE_HTML 3
|
||||
#define wxRICHTEXT_TYPE_RTF 4
|
||||
#define wxRICHTEXT_TYPE_PDF 5
|
||||
enum wxRichTextFileType
|
||||
{
|
||||
wxRICHTEXT_TYPE_ANY = 0,
|
||||
wxRICHTEXT_TYPE_TEXT,
|
||||
wxRICHTEXT_TYPE_XML,
|
||||
wxRICHTEXT_TYPE_HTML,
|
||||
wxRICHTEXT_TYPE_RTF,
|
||||
wxRICHTEXT_TYPE_PDF
|
||||
};
|
||||
|
||||
/*!
|
||||
* Forward declarations
|
||||
@@ -1131,11 +1133,12 @@ public:
|
||||
// to conserve space.
|
||||
// If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
|
||||
// load the image a 2nd time.
|
||||
virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = true);
|
||||
virtual bool MakeImageBlock(const wxString& filename, wxBitmapType imageType,
|
||||
wxImage& image, bool convertToJPEG = true);
|
||||
|
||||
// Make an image block from the wxImage in the given
|
||||
// format.
|
||||
virtual bool MakeImageBlock(wxImage& image, int imageType, int quality = 80);
|
||||
virtual bool MakeImageBlock(wxImage& image, wxBitmapType imageType, int quality = 80);
|
||||
|
||||
// Write to a file
|
||||
bool Write(const wxString& filename);
|
||||
@@ -1144,7 +1147,7 @@ public:
|
||||
bool WriteHex(wxOutputStream& stream);
|
||||
|
||||
// Read data in hex from a stream
|
||||
bool ReadHex(wxInputStream& stream, int length, int imageType);
|
||||
bool ReadHex(wxInputStream& stream, int length, wxBitmapType imageType);
|
||||
|
||||
// Copy from 'block'
|
||||
void Copy(const wxRichTextImageBlock& block);
|
||||
@@ -1159,11 +1162,11 @@ public:
|
||||
|
||||
unsigned char* GetData() const { return m_data; }
|
||||
size_t GetDataSize() const { return m_dataSize; }
|
||||
int GetImageType() const { return m_imageType; }
|
||||
wxBitmapType GetImageType() const { return m_imageType; }
|
||||
|
||||
void SetData(unsigned char* image) { m_data = image; }
|
||||
void SetDataSize(size_t size) { m_dataSize = size; }
|
||||
void SetImageType(int imageType) { m_imageType = imageType; }
|
||||
void SetImageType(wxBitmapType imageType) { m_imageType = imageType; }
|
||||
|
||||
bool Ok() const { return IsOk(); }
|
||||
bool IsOk() const { return GetData() != NULL; }
|
||||
@@ -1188,7 +1191,7 @@ protected:
|
||||
// This is in the raw, original form such as a JPEG file.
|
||||
unsigned char* m_data;
|
||||
size_t m_dataSize;
|
||||
int m_imageType; // wxWin type id
|
||||
wxBitmapType m_imageType;
|
||||
};
|
||||
|
||||
|
||||
@@ -1306,16 +1309,16 @@ public:
|
||||
virtual void ResetAndClearCommands();
|
||||
|
||||
/// Load a file
|
||||
virtual bool LoadFile(const wxString& filename, int type = wxRICHTEXT_TYPE_ANY);
|
||||
virtual bool LoadFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||
|
||||
/// Save a file
|
||||
virtual bool SaveFile(const wxString& filename, int type = wxRICHTEXT_TYPE_ANY);
|
||||
virtual bool SaveFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||
|
||||
/// Load from a stream
|
||||
virtual bool LoadFile(wxInputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
|
||||
virtual bool LoadFile(wxInputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||
|
||||
/// Save to a stream
|
||||
virtual bool SaveFile(wxOutputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
|
||||
virtual bool SaveFile(wxOutputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
|
||||
|
||||
/// Set the handler flags, controlling loading and saving
|
||||
void SetHandlerFlags(int flags) { m_handlerFlags = flags; }
|
||||
@@ -1554,13 +1557,14 @@ public:
|
||||
static wxRichTextFileHandler *FindHandler(const wxString& name);
|
||||
|
||||
/// Finds a handler by extension and type
|
||||
static wxRichTextFileHandler *FindHandler(const wxString& extension, int imageType);
|
||||
static wxRichTextFileHandler *FindHandler(const wxString& extension, wxRichTextFileType imageType);
|
||||
|
||||
/// Finds a handler by filename or, if supplied, type
|
||||
static wxRichTextFileHandler *FindHandlerFilenameOrType(const wxString& filename, int imageType);
|
||||
static wxRichTextFileHandler *FindHandlerFilenameOrType(const wxString& filename,
|
||||
wxRichTextFileType imageType);
|
||||
|
||||
/// Finds a handler by type
|
||||
static wxRichTextFileHandler *FindHandler(int imageType);
|
||||
static wxRichTextFileHandler *FindHandler(wxRichTextFileType imageType);
|
||||
|
||||
/// Gets a wildcard incorporating all visible handlers. If 'types' is present,
|
||||
/// will be filled with the file type corresponding to each filter. This can be
|
||||
@@ -1857,7 +1861,9 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler: public wxRichTextFileHand
|
||||
{
|
||||
DECLARE_CLASS(wxRichTextPlainTextHandler)
|
||||
public:
|
||||
wxRichTextPlainTextHandler(const wxString& name = wxT("Text"), const wxString& ext = wxT("txt"), int type = wxRICHTEXT_TYPE_TEXT)
|
||||
wxRichTextPlainTextHandler(const wxString& name = wxT("Text"),
|
||||
const wxString& ext = wxT("txt"),
|
||||
wxRichTextFileType type = wxRICHTEXT_TYPE_TEXT)
|
||||
: wxRichTextFileHandler(name, ext, type)
|
||||
{ }
|
||||
|
||||
|
@@ -166,7 +166,8 @@ public:
|
||||
|
||||
// load/save the controls contents from/to the file
|
||||
virtual bool DoLoadFile(const wxString& file, int fileType);
|
||||
virtual bool DoSaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
|
||||
virtual bool DoSaveFile(const wxString& file = wxEmptyString,
|
||||
int fileType = wxRICHTEXT_TYPE_ANY);
|
||||
|
||||
/// Set the handler flags, controlling loading and saving
|
||||
void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); }
|
||||
@@ -281,14 +282,14 @@ public:
|
||||
|
||||
/// Write an image at the current insertion point. Supply optional type to use
|
||||
/// for internal and file storage of the raw data.
|
||||
virtual bool WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG);
|
||||
virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG);
|
||||
|
||||
/// Write a bitmap at the current insertion point. Supply optional type to use
|
||||
/// for internal and file storage of the raw data.
|
||||
virtual bool WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG);
|
||||
virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG);
|
||||
|
||||
/// Load an image from file and write at the current insertion point.
|
||||
virtual bool WriteImage(const wxString& filename, int bitmapType);
|
||||
virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType);
|
||||
|
||||
/// Write an image block at the current insertion point.
|
||||
virtual bool WriteImage(const wxRichTextImageBlock& imageBlock);
|
||||
|
@@ -233,12 +233,12 @@ void wxMemoryFSHandlerBase::AddFile(const wxString& filename,
|
||||
/*static*/ void
|
||||
wxMemoryFSHandler::AddFile(const wxString& filename,
|
||||
const wxImage& image,
|
||||
long type)
|
||||
wxBitmapType type)
|
||||
{
|
||||
if (!CheckHash(filename)) return;
|
||||
|
||||
wxMemoryOutputStream mems;
|
||||
if (image.Ok() && image.SaveFile(mems, (int)type))
|
||||
if (image.Ok() && image.SaveFile(mems, type))
|
||||
{
|
||||
m_Hash->Put
|
||||
(
|
||||
@@ -262,7 +262,7 @@ wxMemoryFSHandler::AddFile(const wxString& filename,
|
||||
/*static*/ void
|
||||
wxMemoryFSHandler::AddFile(const wxString& filename,
|
||||
const wxBitmap& bitmap,
|
||||
long type)
|
||||
wxBitmapType type)
|
||||
{
|
||||
#if !defined(__WXMSW__) || wxUSE_WXDIB
|
||||
wxImage img = bitmap.ConvertToImage();
|
||||
|
@@ -5853,7 +5853,8 @@ bool wxRichTextBuffer::RemoveHandler(const wxString& name)
|
||||
}
|
||||
|
||||
/// Finds a handler by filename or, if supplied, type
|
||||
wxRichTextFileHandler *wxRichTextBuffer::FindHandlerFilenameOrType(const wxString& filename, int imageType)
|
||||
wxRichTextFileHandler *wxRichTextBuffer::FindHandlerFilenameOrType(const wxString& filename,
|
||||
wxRichTextFileType imageType)
|
||||
{
|
||||
if (imageType != wxRICHTEXT_TYPE_ANY)
|
||||
return FindHandler(imageType);
|
||||
@@ -5883,7 +5884,7 @@ wxRichTextFileHandler* wxRichTextBuffer::FindHandler(const wxString& name)
|
||||
}
|
||||
|
||||
/// Finds a handler by extension and type
|
||||
wxRichTextFileHandler* wxRichTextBuffer::FindHandler(const wxString& extension, int type)
|
||||
wxRichTextFileHandler* wxRichTextBuffer::FindHandler(const wxString& extension, wxRichTextFileType type)
|
||||
{
|
||||
wxList::compatibility_iterator node = sm_handlers.GetFirst();
|
||||
while (node)
|
||||
@@ -5898,7 +5899,7 @@ wxRichTextFileHandler* wxRichTextBuffer::FindHandler(const wxString& extension,
|
||||
}
|
||||
|
||||
/// Finds a handler by type
|
||||
wxRichTextFileHandler* wxRichTextBuffer::FindHandler(int type)
|
||||
wxRichTextFileHandler* wxRichTextBuffer::FindHandler(wxRichTextFileType type)
|
||||
{
|
||||
wxList::compatibility_iterator node = sm_handlers.GetFirst();
|
||||
while (node)
|
||||
@@ -5976,7 +5977,7 @@ wxString wxRichTextBuffer::GetExtWildcard(bool combine, bool save, wxArrayInt* t
|
||||
}
|
||||
|
||||
/// Load a file
|
||||
bool wxRichTextBuffer::LoadFile(const wxString& filename, int type)
|
||||
bool wxRichTextBuffer::LoadFile(const wxString& filename, wxRichTextFileType type)
|
||||
{
|
||||
wxRichTextFileHandler* handler = FindHandlerFilenameOrType(filename, type);
|
||||
if (handler)
|
||||
@@ -5992,7 +5993,7 @@ bool wxRichTextBuffer::LoadFile(const wxString& filename, int type)
|
||||
}
|
||||
|
||||
/// Save a file
|
||||
bool wxRichTextBuffer::SaveFile(const wxString& filename, int type)
|
||||
bool wxRichTextBuffer::SaveFile(const wxString& filename, wxRichTextFileType type)
|
||||
{
|
||||
wxRichTextFileHandler* handler = FindHandlerFilenameOrType(filename, type);
|
||||
if (handler)
|
||||
@@ -6005,7 +6006,7 @@ bool wxRichTextBuffer::SaveFile(const wxString& filename, int type)
|
||||
}
|
||||
|
||||
/// Load from a stream
|
||||
bool wxRichTextBuffer::LoadFile(wxInputStream& stream, int type)
|
||||
bool wxRichTextBuffer::LoadFile(wxInputStream& stream, wxRichTextFileType type)
|
||||
{
|
||||
wxRichTextFileHandler* handler = FindHandler(type);
|
||||
if (handler)
|
||||
@@ -6021,7 +6022,7 @@ bool wxRichTextBuffer::LoadFile(wxInputStream& stream, int type)
|
||||
}
|
||||
|
||||
/// Save to a stream
|
||||
bool wxRichTextBuffer::SaveFile(wxOutputStream& stream, int type)
|
||||
bool wxRichTextBuffer::SaveFile(wxOutputStream& stream, wxRichTextFileType type)
|
||||
{
|
||||
wxRichTextFileHandler* handler = FindHandler(type);
|
||||
if (handler)
|
||||
@@ -7347,7 +7348,7 @@ void wxRichTextImageBlock::Init()
|
||||
{
|
||||
m_data = NULL;
|
||||
m_dataSize = 0;
|
||||
m_imageType = -1;
|
||||
m_imageType = wxBITMAP_TYPE_INVALID;
|
||||
}
|
||||
|
||||
void wxRichTextImageBlock::Clear()
|
||||
@@ -7355,7 +7356,7 @@ void wxRichTextImageBlock::Clear()
|
||||
delete[] m_data;
|
||||
m_data = NULL;
|
||||
m_dataSize = 0;
|
||||
m_imageType = -1;
|
||||
m_imageType = wxBITMAP_TYPE_INVALID;
|
||||
}
|
||||
|
||||
|
||||
@@ -7365,7 +7366,8 @@ void wxRichTextImageBlock::Clear()
|
||||
// If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
|
||||
// load the image a 2nd time.
|
||||
|
||||
bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG)
|
||||
bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, wxBitmapType imageType,
|
||||
wxImage& image, bool convertToJPEG)
|
||||
{
|
||||
m_imageType = imageType;
|
||||
|
||||
@@ -7409,7 +7411,7 @@ bool wxRichTextImageBlock::MakeImageBlock(const wxString& filename, int imageTyp
|
||||
|
||||
// Make an image block from the wxImage in the given
|
||||
// format.
|
||||
bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, int imageType, int quality)
|
||||
bool wxRichTextImageBlock::MakeImageBlock(wxImage& image, wxBitmapType imageType, int quality)
|
||||
{
|
||||
m_imageType = imageType;
|
||||
image.SetOption(wxT("quality"), quality);
|
||||
@@ -7537,7 +7539,7 @@ bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream)
|
||||
}
|
||||
|
||||
// Read data in hex from a stream
|
||||
bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, int imageType)
|
||||
bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, wxBitmapType imageType)
|
||||
{
|
||||
int dataSize = length/2;
|
||||
|
||||
|
@@ -1990,7 +1990,7 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size)
|
||||
|
||||
bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
|
||||
{
|
||||
bool success = GetBuffer().LoadFile(filename, fileType);
|
||||
bool success = GetBuffer().LoadFile(filename, (wxRichTextFileType)fileType);
|
||||
if (success)
|
||||
m_filename = filename;
|
||||
|
||||
@@ -2014,7 +2014,7 @@ bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
|
||||
|
||||
bool wxRichTextCtrl::DoSaveFile(const wxString& filename, int fileType)
|
||||
{
|
||||
if (GetBuffer().SaveFile(filename, fileType))
|
||||
if (GetBuffer().SaveFile(filename, (wxRichTextFileType)fileType))
|
||||
{
|
||||
m_filename = filename;
|
||||
|
||||
@@ -2257,7 +2257,7 @@ void wxRichTextCtrl::AppendText(const wxString& text)
|
||||
}
|
||||
|
||||
/// Write an image at the current insertion point
|
||||
bool wxRichTextCtrl::WriteImage(const wxImage& image, int bitmapType)
|
||||
bool wxRichTextCtrl::WriteImage(const wxImage& image, wxBitmapType bitmapType)
|
||||
{
|
||||
wxRichTextImageBlock imageBlock;
|
||||
|
||||
@@ -2268,7 +2268,7 @@ bool wxRichTextCtrl::WriteImage(const wxImage& image, int bitmapType)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool wxRichTextCtrl::WriteImage(const wxString& filename, int bitmapType)
|
||||
bool wxRichTextCtrl::WriteImage(const wxString& filename, wxBitmapType bitmapType)
|
||||
{
|
||||
wxRichTextImageBlock imageBlock;
|
||||
|
||||
@@ -2284,7 +2284,7 @@ bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock)
|
||||
return GetBuffer().InsertImageWithUndo(m_caretPosition+1, imageBlock, this);
|
||||
}
|
||||
|
||||
bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, int bitmapType)
|
||||
bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType)
|
||||
{
|
||||
if (bitmap.Ok())
|
||||
{
|
||||
|
@@ -172,10 +172,18 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxXmlNode* node)
|
||||
}
|
||||
else if (childName == wxT("image"))
|
||||
{
|
||||
int imageType = wxBITMAP_TYPE_PNG;
|
||||
wxBitmapType imageType = wxBITMAP_TYPE_PNG;
|
||||
wxString value = node->GetAttribute(wxT("imagetype"), wxEmptyString);
|
||||
if (!value.empty())
|
||||
imageType = wxAtoi(value);
|
||||
{
|
||||
int type = wxAtoi(value);
|
||||
|
||||
// note: 0 == wxBITMAP_TYPE_INVALID
|
||||
if (type <= 0 || type >= wxBITMAP_TYPE_MAX)
|
||||
wxLogWarning("Invalid bitmap type specified for <image> tag: %d", type);
|
||||
else
|
||||
imageType = (wxBitmapType)type;
|
||||
}
|
||||
|
||||
wxString data;
|
||||
|
||||
|
Reference in New Issue
Block a user