1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: textctrl.h
|
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Created: 01/02/97
|
1998-07-23 16:07:55 +00:00
|
|
|
// Id: $Id$
|
1998-05-20 14:01:55 +00:00
|
|
|
// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
|
1998-07-23 16:07:55 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:01:55 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
1999-01-04 21:51:15 +00:00
|
|
|
#if wxUSE_STD_IOSTREAM
|
1999-01-03 16:54:26 +00:00
|
|
|
|
1998-09-25 13:28:52 +00:00
|
|
|
#if wxUSE_IOSTREAMH
|
1998-05-20 14:01:55 +00:00
|
|
|
#include <iostream.h>
|
|
|
|
#else
|
|
|
|
#include <iostream>
|
|
|
|
#endif
|
|
|
|
|
1999-01-03 16:54:26 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
#define NO_TEXT_WINDOW_STREAM
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxTextCtrl;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// global data
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
extern const char *wxTextCtrlNameStr;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxTextCtrl
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
1999-01-03 16:54:26 +00:00
|
|
|
#ifndef NO_TEXT_WINDOW_STREAM
|
1998-05-20 14:01:55 +00:00
|
|
|
class wxTextCtrl: public wxControl, public streambuf
|
1999-01-03 16:54:26 +00:00
|
|
|
#else
|
|
|
|
class wxTextCtrl: public wxControl
|
|
|
|
#endif
|
1998-05-20 14:01:55 +00:00
|
|
|
{
|
1998-07-23 16:07:55 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-20 14:01:55 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxTextCtrl);
|
|
|
|
|
1998-08-14 22:53:21 +00:00
|
|
|
public:
|
1998-07-23 16:07:55 +00:00
|
|
|
wxTextCtrl();
|
|
|
|
wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "",
|
1998-07-04 15:17:59 +00:00
|
|
|
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
1998-08-14 10:07:38 +00:00
|
|
|
int style = 0, const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString &name = wxTextCtrlNameStr );
|
1998-07-04 15:17:59 +00:00
|
|
|
bool Create( wxWindow *parent, wxWindowID id, const wxString &value = "",
|
|
|
|
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
|
1998-08-14 10:07:38 +00:00
|
|
|
int style = 0, const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString &name = wxTextCtrlNameStr );
|
1998-07-23 16:07:55 +00:00
|
|
|
wxString GetValue() const;
|
1998-05-20 14:01:55 +00:00
|
|
|
void SetValue( const wxString &value );
|
|
|
|
void WriteText( const wxString &text );
|
1998-07-23 16:07:55 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
bool LoadFile( const wxString &file );
|
|
|
|
bool SaveFile( const wxString &file );
|
1998-07-23 16:07:55 +00:00
|
|
|
bool IsModified() const { return m_modified; }
|
|
|
|
void SetModified() { m_modified = TRUE; }
|
|
|
|
void DiscardEdits() { m_modified = FALSE; }
|
1998-07-04 15:17:59 +00:00
|
|
|
wxString GetLineText( long lineNo ) const;
|
1998-05-20 14:01:55 +00:00
|
|
|
void OnDropFiles( wxDropFilesEvent &event );
|
1998-07-04 15:17:59 +00:00
|
|
|
long PositionToXY( long pos, long *x, long *y ) const;
|
1998-10-27 15:04:35 +00:00
|
|
|
long XYToPosition( long x, long y ) const;
|
|
|
|
int GetLineLength(long lineNo) const;
|
|
|
|
int GetNumberOfLines() const;
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual void SetInsertionPoint( long pos );
|
1998-07-23 16:07:55 +00:00
|
|
|
virtual void SetInsertionPointEnd();
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual void SetEditable( bool editable );
|
|
|
|
virtual void SetSelection( long from, long to );
|
|
|
|
void ShowPosition( long pos );
|
1998-07-23 16:07:55 +00:00
|
|
|
virtual long GetInsertionPoint() const;
|
|
|
|
virtual long GetLastPosition() const;
|
1998-07-04 15:17:59 +00:00
|
|
|
virtual void Remove( long from, long to );
|
|
|
|
virtual void Replace( long from, long to, const wxString &value );
|
1998-07-23 16:07:55 +00:00
|
|
|
void Cut();
|
|
|
|
void Copy();
|
|
|
|
void Paste();
|
1998-10-12 13:09:15 +00:00
|
|
|
void Clear();
|
1998-07-23 16:07:55 +00:00
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
void OnChar( wxKeyEvent &event );
|
1998-07-23 16:07:55 +00:00
|
|
|
|
1999-01-03 16:54:26 +00:00
|
|
|
#ifndef NO_TEXT_WINDOW_STREAM
|
1998-05-20 14:01:55 +00:00
|
|
|
int overflow(int i);
|
1998-07-23 16:07:55 +00:00
|
|
|
int sync();
|
|
|
|
int underflow();
|
1998-05-20 14:01:55 +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:01:55 +00:00
|
|
|
wxTextCtrl& operator<<(const char c);
|
1999-01-03 16:54:26 +00:00
|
|
|
#endif
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1998-09-06 13:46:50 +00:00
|
|
|
void SetFont( const wxFont &font );
|
1998-10-29 18:03:18 +00:00
|
|
|
void SetForegroundColour(const wxColour &colour);
|
|
|
|
void SetBackgroundColour(const wxColour &colour);
|
1998-10-19 14:18:56 +00:00
|
|
|
|
1998-09-06 13:46:50 +00:00
|
|
|
// implementation
|
|
|
|
|
1998-12-15 08:03:37 +00:00
|
|
|
GtkWidget* GetConnectWidget();
|
1998-09-07 12:29:07 +00:00
|
|
|
bool IsOwnGtkWindow( GdkWindow *window );
|
1998-10-29 18:03:18 +00:00
|
|
|
void ApplyWidgetStyle();
|
1998-12-15 08:03:37 +00:00
|
|
|
void CalculateScrollbar();
|
1998-07-27 20:50:48 +00:00
|
|
|
|
1998-08-14 22:53:21 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
bool m_modified;
|
|
|
|
GtkWidget *m_text;
|
1998-12-15 08:03:37 +00:00
|
|
|
GtkWidget *m_vScrollbar;
|
|
|
|
bool m_vScrollbarVisible;
|
1998-05-20 14:01:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __GTKTEXTCTRLH__
|
|
|
|
|
|
|
|
|