1. new wxFFile class - as wxFile but uses fopen/fread/fseek... instead of
open/read/seek... 2. wxTextCtrlBase appears, several bug fixes in MSW wxTextCtrl and made LoadFile() behave in the same way under GTK and MSW (fixed it for MSW too) 3. Corrected the sash position calculation in sashwin.cpp - seems to work now but I wonder how it could ever work before? 4. new, tmake generated, MSW makefiles. They probably don't work - will fix them as soon as people start complaining. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3004 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
114
include/wx/ffile.h
Normal file
114
include/wx/ffile.h
Normal file
@@ -0,0 +1,114 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: ffile.h
|
||||
// Purpose: wxFFile - encapsulates "FILE *" stream
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 14.07.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_FFILE_H_
|
||||
#define _WX_FFILE_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "ffile.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_FILE
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/string.h"
|
||||
#include "wx/filefn.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// class wxFFile: standard C stream library IO
|
||||
//
|
||||
// NB: for space efficiency this class has no virtual functions, including
|
||||
// dtor which is _not_ virtual, so it shouldn't be used as a base class.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFFile
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
// -----
|
||||
// def ctor
|
||||
wxFFile() { m_fp = NULL; }
|
||||
// open specified file (may fail, use IsOpened())
|
||||
wxFFile(const wxChar *filename, const char *mode = "r");
|
||||
// attach to (already opened) file
|
||||
wxFFile(FILE *fp) { m_fp = fp; }
|
||||
|
||||
// open/close
|
||||
// open a file (existing or not - the mode controls what happens)
|
||||
bool Open(const wxChar *filename, const char *mode = "r");
|
||||
// closes the opened file (this is a NOP if not opened)
|
||||
bool Close();
|
||||
|
||||
// assign an existing file descriptor and get it back from wxFFile object
|
||||
void Attach(FILE *fp, const wxString& name = _T(""))
|
||||
{ Close(); m_fp = fp; m_name = name; }
|
||||
void Detach() { m_fp = NULL; }
|
||||
FILE *fp() const { return m_fp; }
|
||||
|
||||
// read/write (unbuffered)
|
||||
// read all data from the file into a string (useful for text files)
|
||||
bool ReadAll(wxString *str);
|
||||
// returns number of bytes read - use Eof() and Error() to see if an error
|
||||
// occured or not
|
||||
size_t Read(void *pBuf, size_t nCount);
|
||||
// returns the number of bytes written
|
||||
size_t Write(const void *pBuf, size_t nCount);
|
||||
// returns true on success
|
||||
bool Write(const wxString& s)
|
||||
{
|
||||
size_t size = s.Len()*sizeof(wxChar);
|
||||
return Write(s.c_str(), size) == size;
|
||||
}
|
||||
// flush data not yet written
|
||||
bool Flush();
|
||||
|
||||
// file pointer operations (return ofsInvalid on failure)
|
||||
// move ptr ofs bytes related to start/current pos/end of file
|
||||
bool Seek(long ofs, wxSeekMode mode = wxFromStart);
|
||||
// move ptr to ofs bytes before the end
|
||||
bool SeekEnd(long ofs = 0) { return Seek(ofs, wxFromEnd); }
|
||||
// get current position in the file
|
||||
size_t Tell() const;
|
||||
// get current file length
|
||||
size_t Length() const;
|
||||
|
||||
// simple accessors
|
||||
// is file opened?
|
||||
bool IsOpened() const { return m_fp != NULL; }
|
||||
// is end of file reached?
|
||||
bool Eof() const { return feof(m_fp) != 0; }
|
||||
// is an error occured?
|
||||
bool Error() const { return ferror(m_fp) != 0; }
|
||||
// get the file name
|
||||
const wxString& GetName() const { return m_name; }
|
||||
|
||||
// dtor closes the file if opened
|
||||
~wxFFile() { Close(); }
|
||||
|
||||
private:
|
||||
// copy ctor and assignment operator are private because it doesn't make
|
||||
// sense to copy files this way: attempt to do it will provoke a compile-time
|
||||
// error.
|
||||
wxFFile(const wxFFile&);
|
||||
wxFFile& operator=(const wxFFile&);
|
||||
|
||||
FILE *m_fp; // IO stream or NULL if not opened
|
||||
|
||||
wxString m_name; // the name of the file (for diagnostic messages)
|
||||
};
|
||||
|
||||
#endif // wxUSE_FILE
|
||||
|
||||
#endif // _WX_FFILE_H_
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: file.cpp
|
||||
// Name: file.h
|
||||
// Purpose: wxFile - encapsulates low-level "file descriptor"
|
||||
// wxTempFile - safely replace the old file
|
||||
// Author: Vadim Zeitlin
|
||||
@@ -10,8 +10,8 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __FILEH__
|
||||
#define __FILEH__
|
||||
#ifndef _WX_FILEH__
|
||||
#define _WX_FILEH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "file.h"
|
||||
@@ -96,10 +96,14 @@ public:
|
||||
// read/write (unbuffered)
|
||||
// returns number of bytes read or ofsInvalid on error
|
||||
off_t Read(void *pBuf, off_t nCount);
|
||||
// returns true on success
|
||||
// returns the number of bytes written
|
||||
size_t Write(const void *pBuf, size_t nCount);
|
||||
// returns true on success
|
||||
bool Write(const wxString& s) { return Write(s.c_str(), s.Len()*sizeof(wxChar)) != 0; }
|
||||
bool Write(const wxString& s)
|
||||
{
|
||||
size_t size = s.Len()*sizeof(wxChar);
|
||||
return Write(s.c_str(), size) == size;
|
||||
}
|
||||
// flush data not yet written
|
||||
bool Flush();
|
||||
|
||||
@@ -118,11 +122,11 @@ public:
|
||||
bool IsOpened() const { return m_fd != fd_invalid; }
|
||||
// is end of file reached?
|
||||
bool Eof() const;
|
||||
// is an error occured?
|
||||
// has an error occured?
|
||||
bool Error() const { return m_error; }
|
||||
|
||||
// dtor closes the file if opened
|
||||
~wxFile();
|
||||
~wxFile() { Close(); }
|
||||
|
||||
private:
|
||||
// copy ctor and assignment operator are private because
|
||||
@@ -180,7 +184,6 @@ private:
|
||||
wxFile m_file; // the temporary file
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif // wxUSE_FILE
|
||||
|
||||
#endif
|
||||
// _WX_FILEH__
|
||||
#endif // _WX_FILEH__
|
||||
|
@@ -8,27 +8,11 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __GTKTEXTCTRLH__
|
||||
#define __GTKTEXTCTRLH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/control.h"
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -38,25 +22,12 @@
|
||||
class wxTextCtrl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global data
|
||||
// wxTextCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxTextCtrlNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTextCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
class wxTextCtrl: public wxControl, public streambuf
|
||||
#else
|
||||
class wxTextCtrl: public wxControl
|
||||
#endif
|
||||
class wxTextCtrl: public wxTextCtrlBase
|
||||
{
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl);
|
||||
|
||||
public:
|
||||
public:
|
||||
wxTextCtrl();
|
||||
wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "",
|
||||
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
||||
@@ -66,35 +37,55 @@ class wxTextCtrl: public wxControl
|
||||
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
||||
int style = 0, const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString &name = wxTextCtrlNameStr );
|
||||
wxString GetValue() const;
|
||||
void SetValue( const wxString &value );
|
||||
void WriteText( const wxString &text );
|
||||
void AppendText( const wxString &text );
|
||||
|
||||
bool LoadFile( const wxString &file );
|
||||
bool SaveFile( const wxString &file );
|
||||
bool IsModified() const { return m_modified; }
|
||||
void SetModified() { m_modified = TRUE; }
|
||||
void DiscardEdits() { m_modified = FALSE; }
|
||||
wxString GetLineText( long lineNo ) const;
|
||||
void OnDropFiles( wxDropFilesEvent &event );
|
||||
long PositionToXY( long pos, long *x, long *y ) const;
|
||||
long XYToPosition( long x, long y ) const;
|
||||
int GetLineLength(long lineNo) const;
|
||||
int GetNumberOfLines() const;
|
||||
virtual void SetInsertionPoint( long pos );
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual void SetEditable( bool editable );
|
||||
virtual void SetSelection( long from, long to );
|
||||
void ShowPosition( long pos );
|
||||
virtual long GetInsertionPoint() const;
|
||||
virtual long GetLastPosition() const;
|
||||
virtual void Remove( long from, long to );
|
||||
virtual void Replace( long from, long to, const wxString &value );
|
||||
void Cut();
|
||||
void Copy();
|
||||
void Paste();
|
||||
void Clear();
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
virtual int GetLineLength(long lineNo) const;
|
||||
virtual wxString GetLineText(long lineNo) const;
|
||||
virtual int GetNumberOfLines() const;
|
||||
|
||||
virtual bool IsModified() const;
|
||||
virtual bool IsEditable() const;
|
||||
|
||||
// If the return values from and to are the same, there is no selection.
|
||||
virtual void GetSelection(long* from, long* to) const;
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// editing
|
||||
virtual void Clear();
|
||||
virtual void Replace(long from, long to, const wxString& value);
|
||||
virtual void Remove(long from, long to);
|
||||
|
||||
// load/save the controls contents from/to the file
|
||||
virtual bool LoadFile(const wxString& file);
|
||||
virtual bool SaveFile(const wxString& file);
|
||||
|
||||
// clears the dirty flag
|
||||
virtual void DiscardEdits();
|
||||
|
||||
// writing text inserts it at the current position, appending always
|
||||
// inserts it at the end
|
||||
virtual void WriteText(const wxString& text);
|
||||
virtual void AppendText(const wxString& text);
|
||||
|
||||
// translate between the position (which is just an index in the text ctrl
|
||||
// considering all its contents as a single strings) and (x, y) coordinates
|
||||
// which represent column and line.
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual void PositionToXY(long pos, long *x, long *y) const;
|
||||
|
||||
virtual void ShowPosition(long pos);
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy();
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
|
||||
virtual bool CanCopy() const;
|
||||
virtual bool CanCut() const;
|
||||
@@ -107,11 +98,17 @@ class wxTextCtrl: public wxControl
|
||||
virtual bool CanUndo() const;
|
||||
virtual bool CanRedo() const;
|
||||
|
||||
// If the return values from and to are the same, there is no
|
||||
// selection.
|
||||
virtual void GetSelection(long* from, long* to) const;
|
||||
virtual bool IsEditable() const ;
|
||||
// Insertion point
|
||||
virtual void SetInsertionPoint(long pos);
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual long GetInsertionPoint() const;
|
||||
virtual long GetLastPosition() const;
|
||||
|
||||
virtual void SetSelection(long from, long to);
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
// Implementation from now on
|
||||
void OnDropFiles( wxDropFilesEvent &event );
|
||||
void OnChar( wxKeyEvent &event );
|
||||
|
||||
void OnCut(wxCommandEvent& event);
|
||||
@@ -126,38 +123,24 @@ class wxTextCtrl: public wxControl
|
||||
void OnUpdateUndo(wxUpdateUIEvent& event);
|
||||
void OnUpdateRedo(wxUpdateUIEvent& event);
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
int overflow(int i);
|
||||
int sync();
|
||||
int underflow();
|
||||
#endif
|
||||
|
||||
wxTextCtrl& operator<<(const wxString& s);
|
||||
wxTextCtrl& operator<<(int i);
|
||||
wxTextCtrl& operator<<(long i);
|
||||
wxTextCtrl& operator<<(float f);
|
||||
wxTextCtrl& operator<<(double d);
|
||||
wxTextCtrl& operator<<(const char c);
|
||||
|
||||
bool SetFont( const wxFont &font );
|
||||
bool SetForegroundColour(const wxColour &colour);
|
||||
bool SetBackgroundColour(const wxColour &colour);
|
||||
|
||||
// implementation
|
||||
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void CalculateScrollbar();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private:
|
||||
bool m_modified;
|
||||
GtkWidget *m_text;
|
||||
GtkWidget *m_vScrollbar;
|
||||
bool m_vScrollbarVisible;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl);
|
||||
};
|
||||
|
||||
#endif // __GTKTEXTCTRLH__
|
||||
|
||||
|
||||
|
@@ -8,27 +8,11 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef __GTKTEXTCTRLH__
|
||||
#define __GTKTEXTCTRLH__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/control.h"
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -38,25 +22,12 @@
|
||||
class wxTextCtrl;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global data
|
||||
// wxTextCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxTextCtrlNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTextCtrl
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
class wxTextCtrl: public wxControl, public streambuf
|
||||
#else
|
||||
class wxTextCtrl: public wxControl
|
||||
#endif
|
||||
class wxTextCtrl: public wxTextCtrlBase
|
||||
{
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl);
|
||||
|
||||
public:
|
||||
public:
|
||||
wxTextCtrl();
|
||||
wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "",
|
||||
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
||||
@@ -66,35 +37,55 @@ class wxTextCtrl: public wxControl
|
||||
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
||||
int style = 0, const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString &name = wxTextCtrlNameStr );
|
||||
wxString GetValue() const;
|
||||
void SetValue( const wxString &value );
|
||||
void WriteText( const wxString &text );
|
||||
void AppendText( const wxString &text );
|
||||
|
||||
bool LoadFile( const wxString &file );
|
||||
bool SaveFile( const wxString &file );
|
||||
bool IsModified() const { return m_modified; }
|
||||
void SetModified() { m_modified = TRUE; }
|
||||
void DiscardEdits() { m_modified = FALSE; }
|
||||
wxString GetLineText( long lineNo ) const;
|
||||
void OnDropFiles( wxDropFilesEvent &event );
|
||||
long PositionToXY( long pos, long *x, long *y ) const;
|
||||
long XYToPosition( long x, long y ) const;
|
||||
int GetLineLength(long lineNo) const;
|
||||
int GetNumberOfLines() const;
|
||||
virtual void SetInsertionPoint( long pos );
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual void SetEditable( bool editable );
|
||||
virtual void SetSelection( long from, long to );
|
||||
void ShowPosition( long pos );
|
||||
virtual long GetInsertionPoint() const;
|
||||
virtual long GetLastPosition() const;
|
||||
virtual void Remove( long from, long to );
|
||||
virtual void Replace( long from, long to, const wxString &value );
|
||||
void Cut();
|
||||
void Copy();
|
||||
void Paste();
|
||||
void Clear();
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
virtual int GetLineLength(long lineNo) const;
|
||||
virtual wxString GetLineText(long lineNo) const;
|
||||
virtual int GetNumberOfLines() const;
|
||||
|
||||
virtual bool IsModified() const;
|
||||
virtual bool IsEditable() const;
|
||||
|
||||
// If the return values from and to are the same, there is no selection.
|
||||
virtual void GetSelection(long* from, long* to) const;
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// editing
|
||||
virtual void Clear();
|
||||
virtual void Replace(long from, long to, const wxString& value);
|
||||
virtual void Remove(long from, long to);
|
||||
|
||||
// load/save the controls contents from/to the file
|
||||
virtual bool LoadFile(const wxString& file);
|
||||
virtual bool SaveFile(const wxString& file);
|
||||
|
||||
// clears the dirty flag
|
||||
virtual void DiscardEdits();
|
||||
|
||||
// writing text inserts it at the current position, appending always
|
||||
// inserts it at the end
|
||||
virtual void WriteText(const wxString& text);
|
||||
virtual void AppendText(const wxString& text);
|
||||
|
||||
// translate between the position (which is just an index in the text ctrl
|
||||
// considering all its contents as a single strings) and (x, y) coordinates
|
||||
// which represent column and line.
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual void PositionToXY(long pos, long *x, long *y) const;
|
||||
|
||||
virtual void ShowPosition(long pos);
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy();
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
|
||||
virtual bool CanCopy() const;
|
||||
virtual bool CanCut() const;
|
||||
@@ -107,11 +98,17 @@ class wxTextCtrl: public wxControl
|
||||
virtual bool CanUndo() const;
|
||||
virtual bool CanRedo() const;
|
||||
|
||||
// If the return values from and to are the same, there is no
|
||||
// selection.
|
||||
virtual void GetSelection(long* from, long* to) const;
|
||||
virtual bool IsEditable() const ;
|
||||
// Insertion point
|
||||
virtual void SetInsertionPoint(long pos);
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual long GetInsertionPoint() const;
|
||||
virtual long GetLastPosition() const;
|
||||
|
||||
virtual void SetSelection(long from, long to);
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
// Implementation from now on
|
||||
void OnDropFiles( wxDropFilesEvent &event );
|
||||
void OnChar( wxKeyEvent &event );
|
||||
|
||||
void OnCut(wxCommandEvent& event);
|
||||
@@ -126,38 +123,24 @@ class wxTextCtrl: public wxControl
|
||||
void OnUpdateUndo(wxUpdateUIEvent& event);
|
||||
void OnUpdateRedo(wxUpdateUIEvent& event);
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
int overflow(int i);
|
||||
int sync();
|
||||
int underflow();
|
||||
#endif
|
||||
|
||||
wxTextCtrl& operator<<(const wxString& s);
|
||||
wxTextCtrl& operator<<(int i);
|
||||
wxTextCtrl& operator<<(long i);
|
||||
wxTextCtrl& operator<<(float f);
|
||||
wxTextCtrl& operator<<(double d);
|
||||
wxTextCtrl& operator<<(const char c);
|
||||
|
||||
bool SetFont( const wxFont &font );
|
||||
bool SetForegroundColour(const wxColour &colour);
|
||||
bool SetBackgroundColour(const wxColour &colour);
|
||||
|
||||
// implementation
|
||||
|
||||
GtkWidget* GetConnectWidget();
|
||||
bool IsOwnGtkWindow( GdkWindow *window );
|
||||
void ApplyWidgetStyle();
|
||||
void CalculateScrollbar();
|
||||
|
||||
private:
|
||||
|
||||
|
||||
private:
|
||||
bool m_modified;
|
||||
GtkWidget *m_text;
|
||||
GtkWidget *m_vScrollbar;
|
||||
bool m_vScrollbarVisible;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl);
|
||||
};
|
||||
|
||||
#endif // __GTKTEXTCTRLH__
|
||||
|
||||
|
||||
|
@@ -85,7 +85,7 @@ public:
|
||||
virtual void Clear();
|
||||
|
||||
/// X11 has two clipboards which get selected by this call. Empty on MSW.
|
||||
inline void UsePrimarySelection( bool WXUNUSED(primary) ) { }
|
||||
void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
|
||||
|
||||
};
|
||||
|
||||
|
@@ -16,70 +16,41 @@
|
||||
#pragma interface "textctrl.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/control.h"
|
||||
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
// can we use RICHEDIT class for wxTextCtrl implementation?
|
||||
#if defined(__WIN95__) && !defined(__TWIN32__) && !defined(__WXWINE__)
|
||||
#define wxUSE_RICHEDIT 1
|
||||
#else
|
||||
#define wxUSE_RICHEDIT 0
|
||||
#endif
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
// Single-line text item
|
||||
class WXDLLEXPORT wxTextCtrl : public wxControl
|
||||
|
||||
// 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow and streambuf:
|
||||
// it complains about deriving a huge class from the huge class streambuf. !!
|
||||
// Also, can't use streambuf if making or using a DLL :-(
|
||||
|
||||
#if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
|
||||
#define NO_TEXT_WINDOW_STREAM
|
||||
#endif
|
||||
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
, public streambuf
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||
|
||||
public:
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxTextCtrl();
|
||||
wxTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr)
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
:streambuf()
|
||||
#endif
|
||||
{
|
||||
Create(parent, id, value, pos, size, style, validator, name);
|
||||
}
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr)
|
||||
{
|
||||
Create(parent, id, value, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr);
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr);
|
||||
|
||||
// accessors
|
||||
// ---------
|
||||
// implement base class pure virtuals
|
||||
// ----------------------------------
|
||||
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
@@ -88,9 +59,39 @@ public:
|
||||
virtual wxString GetLineText(long lineNo) const;
|
||||
virtual int GetNumberOfLines() const;
|
||||
|
||||
virtual bool IsModified() const;
|
||||
virtual bool IsEditable() const;
|
||||
|
||||
// If the return values from and to are the same, there is no selection.
|
||||
virtual void GetSelection(long* from, long* to) const;
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// editing
|
||||
virtual void Clear();
|
||||
virtual void Replace(long from, long to, const wxString& value);
|
||||
virtual void Remove(long from, long to);
|
||||
|
||||
// load the controls contents from the file
|
||||
virtual bool LoadFile(const wxString& file);
|
||||
|
||||
// clears the dirty flag
|
||||
virtual void DiscardEdits();
|
||||
|
||||
// writing text inserts it at the current position, appending always
|
||||
// inserts it at the end
|
||||
virtual void WriteText(const wxString& text);
|
||||
virtual void AppendText(const wxString& text);
|
||||
|
||||
// translate between the position (which is just an index in the text ctrl
|
||||
// considering all its contents as a single strings) and (x, y) coordinates
|
||||
// which represent column and line.
|
||||
virtual long XYToPosition(long x, long y) const;
|
||||
virtual void PositionToXY(long pos, long *x, long *y) const;
|
||||
|
||||
virtual void ShowPosition(long pos);
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy();
|
||||
virtual void Cut();
|
||||
@@ -107,50 +108,15 @@ public:
|
||||
virtual bool CanUndo() const;
|
||||
virtual bool CanRedo() const;
|
||||
|
||||
// Insertion point
|
||||
virtual void SetInsertionPoint(long pos);
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual long GetInsertionPoint() const ;
|
||||
virtual long GetLastPosition() const ;
|
||||
virtual void Replace(long from, long to, const wxString& value);
|
||||
virtual void Remove(long from, long to);
|
||||
virtual long GetInsertionPoint() const;
|
||||
virtual long GetLastPosition() const;
|
||||
|
||||
virtual void SetSelection(long from, long to);
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
// If the return values from and to are the same, there is no
|
||||
// selection.
|
||||
virtual void GetSelection(long* from, long* to) const;
|
||||
virtual bool IsEditable() const ;
|
||||
|
||||
// streambuf implementation
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
int overflow(int i);
|
||||
int sync();
|
||||
int underflow();
|
||||
#endif
|
||||
|
||||
wxTextCtrl& operator<<(const wxString& s);
|
||||
wxTextCtrl& operator<<(int i);
|
||||
wxTextCtrl& operator<<(long i);
|
||||
wxTextCtrl& operator<<(float f);
|
||||
wxTextCtrl& operator<<(double d);
|
||||
wxTextCtrl& operator<<(const char c);
|
||||
|
||||
virtual bool LoadFile(const wxString& file);
|
||||
virtual bool SaveFile(const wxString& file);
|
||||
virtual void WriteText(const wxString& text);
|
||||
virtual void AppendText(const wxString& text);
|
||||
virtual void DiscardEdits();
|
||||
virtual bool IsModified() const;
|
||||
|
||||
#if WXWIN_COMPATIBILITY
|
||||
inline bool Modified() const { return IsModified(); }
|
||||
#endif
|
||||
|
||||
virtual long XYToPosition(long x, long y) const ;
|
||||
virtual void PositionToXY(long pos, long *x, long *y) const ;
|
||||
virtual void ShowPosition(long pos);
|
||||
virtual void Clear();
|
||||
|
||||
// Implementation from now on
|
||||
// --------------------------
|
||||
|
||||
@@ -160,11 +126,11 @@ public:
|
||||
#if wxUSE_RICHEDIT
|
||||
bool IsRich() const { return m_isRich; }
|
||||
void SetRichEdit(bool isRich) { m_isRich = isRich; }
|
||||
#endif
|
||||
#endif // wxUSE_RICHEDIT
|
||||
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam,
|
||||
WXLPARAM lParam);
|
||||
WXUINT message, WXWPARAM wParam,
|
||||
WXLPARAM lParam);
|
||||
|
||||
virtual void AdoptAttributesFromHWND();
|
||||
virtual void SetupColours();
|
||||
@@ -172,7 +138,6 @@ public:
|
||||
virtual bool AcceptsFocus() const;
|
||||
|
||||
// callbacks
|
||||
// ---------
|
||||
void OnDropFiles(wxDropFilesEvent& event);
|
||||
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
||||
|
||||
@@ -193,8 +158,6 @@ protected:
|
||||
bool m_isRich; // Are we using rich text edit to implement this?
|
||||
#endif
|
||||
|
||||
wxString m_fileName;
|
||||
|
||||
// call this to increase the size limit (will do nothing if the current
|
||||
// limit is big enough)
|
||||
void AdjustSpaceLimit();
|
||||
@@ -203,6 +166,7 @@ protected:
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -1,18 +1,177 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: textctrl.h
|
||||
// Purpose: wxTextCtrlBase class - the interface of wxTextCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 13.07.99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) wxWindows team
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_TEXTCTRL_H_BASE_
|
||||
#define _WX_TEXTCTRL_H_BASE_
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/control.h" // the base class
|
||||
|
||||
// 16-bit Borland 4.0 doesn't seem to allow multiple inheritance with wxWindow
|
||||
// and streambuf: it complains about deriving a huge class from the huge class
|
||||
// streambuf. !! Also, can't use streambuf if making or using a DLL :-(
|
||||
|
||||
#if (defined(__BORLANDC__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
|
||||
#define NO_TEXT_WINDOW_STREAM
|
||||
#endif
|
||||
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
#ifdef wxUSE_STD_IOSTREAM
|
||||
#include "ioswrap.h" // for iostream classes if we need them
|
||||
#else // !wxUSE_STD_IOSTREAM
|
||||
// can't compile this feature in if we don't use streams at all
|
||||
#define NO_TEXT_WINDOW_STREAM
|
||||
#endif // wxUSE_STD_IOSTREAM/!wxUSE_STD_IOSTREAM
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl: a single or multiple line text zone where user can enter and
|
||||
// edit text
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxTextCtrlBase : public wxControl
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
, public streambuf
|
||||
#endif
|
||||
|
||||
{
|
||||
public:
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxTextCtrlBase();
|
||||
|
||||
// accessors
|
||||
// ---------
|
||||
|
||||
virtual wxString GetValue() const = 0;
|
||||
virtual void SetValue(const wxString& value) = 0;
|
||||
|
||||
virtual int GetLineLength(long lineNo) const = 0;
|
||||
virtual wxString GetLineText(long lineNo) const = 0;
|
||||
virtual int GetNumberOfLines() const = 0;
|
||||
|
||||
virtual bool IsModified() const = 0;
|
||||
virtual bool IsEditable() const = 0;
|
||||
|
||||
// If the return values from and to are the same, there is no selection.
|
||||
virtual void GetSelection(long* from, long* to) const = 0;
|
||||
|
||||
// operations
|
||||
// ----------
|
||||
|
||||
// editing
|
||||
virtual void Clear() = 0;
|
||||
virtual void Replace(long from, long to, const wxString& value) = 0;
|
||||
virtual void Remove(long from, long to) = 0;
|
||||
|
||||
// load/save the controls contents from/to the file
|
||||
virtual bool LoadFile(const wxString& file);
|
||||
virtual bool SaveFile(const wxString& file = wxEmptyString);
|
||||
|
||||
// clears the dirty flag
|
||||
virtual void DiscardEdits() = 0;
|
||||
|
||||
// writing text inserts it at the current position, appending always
|
||||
// inserts it at the end
|
||||
virtual void WriteText(const wxString& text) = 0;
|
||||
virtual void AppendText(const wxString& text) = 0;
|
||||
|
||||
// translate between the position (which is just an index in the text ctrl
|
||||
// considering all its contents as a single strings) and (x, y) coordinates
|
||||
// which represent column and line.
|
||||
virtual long XYToPosition(long x, long y) const = 0;
|
||||
virtual void PositionToXY(long pos, long *x, long *y) const = 0;
|
||||
|
||||
virtual void ShowPosition(long pos) = 0;
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy() = 0;
|
||||
virtual void Cut() = 0;
|
||||
virtual void Paste() = 0;
|
||||
|
||||
virtual bool CanCopy() const = 0;
|
||||
virtual bool CanCut() const = 0;
|
||||
virtual bool CanPaste() const = 0;
|
||||
|
||||
// Undo/redo
|
||||
virtual void Undo() = 0;
|
||||
virtual void Redo() = 0;
|
||||
|
||||
virtual bool CanUndo() const = 0;
|
||||
virtual bool CanRedo() const = 0;
|
||||
|
||||
// Insertion point
|
||||
virtual void SetInsertionPoint(long pos) = 0;
|
||||
virtual void SetInsertionPointEnd() = 0;
|
||||
virtual long GetInsertionPoint() const = 0;
|
||||
virtual long GetLastPosition() const = 0;
|
||||
|
||||
virtual void SetSelection(long from, long to) = 0;
|
||||
virtual void SetEditable(bool editable) = 0;
|
||||
|
||||
// streambuf methods
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
int overflow(int i);
|
||||
int sync();
|
||||
int underflow();
|
||||
#endif // NO_TEXT_WINDOW_STREAM
|
||||
|
||||
// stream-like insertion operators: these are always available, whether we
|
||||
// were, or not, compiled with streambuf support
|
||||
wxTextCtrl& operator<<(const wxString& s);
|
||||
wxTextCtrl& operator<<(int i);
|
||||
wxTextCtrl& operator<<(long i);
|
||||
wxTextCtrl& operator<<(float f);
|
||||
wxTextCtrl& operator<<(double d);
|
||||
wxTextCtrl& operator<<(const char c);
|
||||
|
||||
// obsolete functions
|
||||
#if WXWIN_COMPATIBILITY
|
||||
bool Modified() const { return IsModified(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
// the name of the last file loaded with LoadFile() which will be used by
|
||||
// SaveFile() by default
|
||||
wxString m_filename;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// include the platform-dependent class definition
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/textctrl.h"
|
||||
#include "wx/msw/textctrl.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/textctrl.h"
|
||||
#include "wx/motif/textctrl.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/textctrl.h"
|
||||
#include "wx/gtk/textctrl.h"
|
||||
#elif defined(__WXQT__)
|
||||
#include "wx/qt/textctrl.h"
|
||||
#include "wx/qt/textctrl.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/textctrl.h"
|
||||
#include "wx/mac/textctrl.h"
|
||||
#elif defined(__WXSTUBS__)
|
||||
#include "wx/stubs/textctrl.h"
|
||||
#include "wx/stubs/textctrl.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -11,16 +11,21 @@
|
||||
// Licence: wxWindows license
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _TEXTFILE_H
|
||||
#define _TEXTFILE_H
|
||||
#ifndef _WX_TEXTFILE_H
|
||||
#define _WX_TEXTFILE_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "textfile.h"
|
||||
#pragma interface "textfile.h"
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_TEXTFILE && wxUSE_FILE
|
||||
#if !wxUSE_FILE
|
||||
#undef wxUSE_TEXTFILE
|
||||
#define wxUSE_TEXTFILE 0
|
||||
#endif // wxUSE_FILE
|
||||
|
||||
#if wxUSE_TEXTFILE
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/file.h"
|
||||
@@ -44,9 +49,20 @@ WX_DEFINE_ARRAY(wxTextFileType, ArrayFileType);
|
||||
class WXDLLEXPORT wxTextFile
|
||||
{
|
||||
public:
|
||||
// default type for current platform (determined at compile time)
|
||||
// constants and static functions
|
||||
// default type for current platform (determined at compile time)
|
||||
static const wxTextFileType typeDefault;
|
||||
|
||||
// this function returns a string which is identical to "text" passed in
|
||||
// except that the line terminator characters are changed to correspond the
|
||||
// given type. Called with the default argument, the function translates
|
||||
// the string to the native format (Unix for Unix, DOS for Windows, ...).
|
||||
static wxString Translate(const wxString& text,
|
||||
wxTextFileType type = typeDefault);
|
||||
|
||||
// get the file termination string
|
||||
static const wxChar *GetEOL(wxTextFileType type = typeDefault);
|
||||
|
||||
// ctors
|
||||
// def ctor, use Open(string)
|
||||
wxTextFile() { }
|
||||
@@ -115,10 +131,6 @@ public:
|
||||
// possibly in another format
|
||||
bool Write(wxTextFileType typeNew = wxTextFileType_None);
|
||||
|
||||
// get the file termination string
|
||||
// Note: implementation moved to textfile to prevent warning due to switch.
|
||||
static const wxChar *GetEOL(wxTextFileType type = typeDefault);
|
||||
|
||||
// dtor
|
||||
~wxTextFile();
|
||||
|
||||
@@ -142,9 +154,34 @@ private:
|
||||
wxString m_strFile; // name of the file
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_TEXTFILE && wxUSE_FILE
|
||||
#else // !wxUSE_TEXTFILE
|
||||
|
||||
#endif
|
||||
// _TEXTFILE_H
|
||||
// these static wxTextFile methods are used internally by wxWindows, so should
|
||||
// be defined even if we're compiling without wxTextFile at all.
|
||||
|
||||
class WXDLLEXPORT wxTextFile
|
||||
{
|
||||
public:
|
||||
// default type for current platform (determined at compile time)
|
||||
static const wxTextFileType typeDefault;
|
||||
|
||||
// this function returns a string which is identical to "text" passed in
|
||||
// except that the line terminator characters are changed to correspond the
|
||||
// given type. Called with the default argument, the function translates
|
||||
// the string to the native format (Unix for Unix, DOS for Windows, ...).
|
||||
static wxString Translate(const wxString& text,
|
||||
wxTextFileType type = typeDefault);
|
||||
|
||||
// get the file termination string
|
||||
static const wxChar *GetEOL(wxTextFileType type = typeDefault);
|
||||
|
||||
private:
|
||||
// copy ctor/assignment operator not implemented
|
||||
wxTextFile(const wxTextFile&);
|
||||
wxTextFile& operator=(const wxTextFile&);
|
||||
};
|
||||
|
||||
#endif // wxUSE_TEXTFILE
|
||||
|
||||
#endif // _WX_TEXTFILE_H
|
||||
|
||||
|
Reference in New Issue
Block a user