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