1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: textctrl.h
|
|
|
|
// Purpose: wxTextCtrl class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
1998-08-07 23:52:45 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-07 23:52:45 +00:00
|
|
|
#ifndef _WX_TEXTCTRL_H_
|
|
|
|
#define _WX_TEXTCTRL_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "textctrl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_IOSTREAMH
|
1998-05-20 14:12:05 +00:00
|
|
|
#include <iostream.h>
|
|
|
|
#else
|
|
|
|
#include <iostream>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
|
|
|
|
WXDLLEXPORT_DATA(extern const char*) 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(__WIN32__)) || defined(__MWERKS__) || defined(_WINDLL) || defined(WXUSINGDLL) || defined(WXMAKINGDLL)
|
|
|
|
#define NO_TEXT_WINDOW_STREAM
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NO_TEXT_WINDOW_STREAM
|
|
|
|
, public streambuf
|
|
|
|
#endif
|
|
|
|
|
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
1998-07-19 20:45:51 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// creation
|
|
|
|
// --------
|
|
|
|
wxTextCtrl();
|
1998-07-04 15:17:59 +00:00
|
|
|
inline wxTextCtrl(wxWindow *parent, wxWindowID id,
|
1998-07-19 20:45:51 +00:00
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxTextCtrlNameStr)
|
1998-05-20 14:12:05 +00:00
|
|
|
#ifndef NO_TEXT_WINDOW_STREAM
|
1998-07-19 20:45:51 +00:00
|
|
|
:streambuf()
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
|
|
|
{
|
1998-07-19 20:45:51 +00:00
|
|
|
Create(parent, id, value, pos, size, style, validator, name);
|
1998-05-20 14:12:05 +00:00
|
|
|
}
|
1998-07-19 20:45:51 +00:00
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
1998-07-19 20:45:51 +00:00
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize, long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxTextCtrlNameStr);
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
// ---------
|
|
|
|
virtual wxString GetValue() const ;
|
1998-05-20 14:12:05 +00:00
|
|
|
virtual void SetValue(const wxString& value);
|
|
|
|
|
1998-07-19 20:45:51 +00:00
|
|
|
virtual int GetLineLength(long lineNo) const;
|
|
|
|
virtual wxString GetLineText(long lineNo) const;
|
|
|
|
virtual int GetNumberOfLines() const;
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1998-07-19 20:45:51 +00:00
|
|
|
// operations
|
|
|
|
// ----------
|
|
|
|
virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
|
|
|
|
|
|
|
// Clipboard operations
|
|
|
|
virtual void Copy();
|
|
|
|
virtual void Cut();
|
|
|
|
virtual void Paste();
|
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual void SetInsertionPoint(long pos);
|
1998-07-19 20:45:51 +00:00
|
|
|
virtual void SetInsertionPointEnd();
|
|
|
|
virtual long GetInsertionPoint() const ;
|
|
|
|
virtual long GetLastPosition() const ;
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual void Replace(long from, long to, const wxString& value);
|
|
|
|
virtual void Remove(long from, long to);
|
|
|
|
virtual void SetSelection(long from, long to);
|
|
|
|
virtual void SetEditable(bool editable);
|
1998-07-19 20:45:51 +00:00
|
|
|
|
|
|
|
// streambuf implementation
|
1998-05-20 14:12:05 +00:00
|
|
|
#ifndef NO_TEXT_WINDOW_STREAM
|
|
|
|
int overflow(int i);
|
1998-07-19 20:45:51 +00:00
|
|
|
int sync();
|
|
|
|
int underflow();
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1998-07-19 20:45:51 +00:00
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
wxTextCtrl& operator<<(const wxString& s);
|
1998-07-04 15:17:59 +00:00
|
|
|
wxTextCtrl& operator<<(int i);
|
|
|
|
wxTextCtrl& operator<<(long i);
|
|
|
|
wxTextCtrl& operator<<(float f);
|
|
|
|
wxTextCtrl& operator<<(double d);
|
1998-05-20 14:12:05 +00:00
|
|
|
wxTextCtrl& operator<<(const char c);
|
1998-07-19 20:45:51 +00:00
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
virtual bool LoadFile(const wxString& file);
|
|
|
|
virtual bool SaveFile(const wxString& file);
|
|
|
|
virtual void WriteText(const wxString& text);
|
1998-07-19 20:45:51 +00:00
|
|
|
virtual void DiscardEdits();
|
|
|
|
virtual bool IsModified() const;
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
#if WXWIN_COMPATIBILITY
|
1998-07-19 20:45:51 +00:00
|
|
|
inline bool Modified() const { return IsModified(); }
|
1998-05-20 14:12:05 +00:00
|
|
|
#endif
|
1998-07-19 20:45:51 +00:00
|
|
|
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual long XYToPosition(long x, long y) const ;
|
|
|
|
virtual void PositionToXY(long pos, long *x, long *y) const ;
|
|
|
|
virtual void ShowPosition(long pos);
|
1998-07-19 20:45:51 +00:00
|
|
|
virtual void Clear();
|
|
|
|
|
|
|
|
// callbacks
|
|
|
|
// ---------
|
|
|
|
void OnDropFiles(wxDropFilesEvent& event);
|
|
|
|
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
1998-05-20 14:12:05 +00:00
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
1998-07-19 20:45:51 +00:00
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
// Implementation
|
1998-07-19 20:45:51 +00:00
|
|
|
// --------------
|
|
|
|
virtual void Command(wxCommandEvent& event);
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
1998-07-19 20:45:51 +00:00
|
|
|
inline bool IsRich() const { return m_isRich; }
|
1998-07-04 15:17:59 +00:00
|
|
|
inline void SetRichEdit(bool isRich) { m_isRich = isRich; }
|
|
|
|
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
1998-07-19 20:45:51 +00:00
|
|
|
WXUINT message, WXWPARAM wParam,
|
|
|
|
WXLPARAM lParam);
|
|
|
|
|
|
|
|
virtual void AdoptAttributesFromHWND();
|
|
|
|
virtual void SetupColours();
|
|
|
|
virtual long MSWGetDlgCode();
|
|
|
|
|
1998-05-20 14:12:05 +00:00
|
|
|
protected:
|
1998-07-19 20:45:51 +00:00
|
|
|
bool m_isRich; // Are we using rich text edit to implement this?
|
1998-08-09 16:46:37 +00:00
|
|
|
wxString m_fileName;
|
1998-07-19 20:45:51 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1998-08-07 23:52:45 +00:00
|
|
|
// _WX_TEXTCTRL_H_
|