1. OnNcPaint() fixed, seems to work
2. start of wxTextCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8370 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
4
TODO
4
TODO
@@ -7,5 +7,5 @@ MSW
|
||||
|
||||
GTK
|
||||
|
||||
* check/radio box remains pressed in win32 mode
|
||||
* wxCheckListBox::HitTest doesn't work (clicking the check)
|
||||
+ check/radio box remains pressed in win32 mode
|
||||
+ wxCheckListBox::HitTest doesn't work (clicking the check)
|
||||
|
@@ -44,6 +44,7 @@
|
||||
wxUSE_STATLINE || \
|
||||
wxUSE_STATUSBAR || \
|
||||
wxUSE_TAB_DIALOG || \
|
||||
wxUSE_TEXTCTRL || \
|
||||
wxUSE_TOOLBAR || \
|
||||
wxUSE_TOOLTIPS || \
|
||||
wxUSE_TREECTRL
|
||||
@@ -103,6 +104,17 @@
|
||||
# endif
|
||||
#endif /* wxUSE_STOPWATCH */
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
# if defined(__WXUNIVERSAL__) && !wxUSE_CARET
|
||||
# ifdef wxABORT_ON_CONFIG_ERROR
|
||||
# error "wxTextCtrl requires wxCaret in wxUniversal"
|
||||
# else
|
||||
# undef wxUSE_CARET
|
||||
# define wxUSE_CARET 1
|
||||
# endif
|
||||
# endif
|
||||
#endif /* wxUSE_RADIOBTN */
|
||||
|
||||
#if !defined(wxUSE_DYNAMIC_CLASSES) || !wxUSE_DYNAMIC_CLASSES
|
||||
# if wxABORT_ON_CONFIG_ERROR
|
||||
# error "wxUSE_DYNAMIC_CLASSES must be defined as 1"
|
||||
|
@@ -92,10 +92,6 @@ public:
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
|
||||
virtual bool CanCopy() const;
|
||||
virtual bool CanCut() const;
|
||||
virtual bool CanPaste() const;
|
||||
|
||||
// Undo/redo
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
|
@@ -92,10 +92,6 @@ public:
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
|
||||
virtual bool CanCopy() const;
|
||||
virtual bool CanCut() const;
|
||||
virtual bool CanPaste() const;
|
||||
|
||||
// Undo/redo
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
|
@@ -119,9 +119,9 @@ public:
|
||||
virtual void Cut() = 0;
|
||||
virtual void Paste() = 0;
|
||||
|
||||
virtual bool CanCopy() const = 0;
|
||||
virtual bool CanCut() const = 0;
|
||||
virtual bool CanPaste() const = 0;
|
||||
virtual bool CanCopy() const;
|
||||
virtual bool CanCut() const;
|
||||
virtual bool CanPaste() const;
|
||||
|
||||
// Undo/redo
|
||||
virtual void Undo() = 0;
|
||||
@@ -168,7 +168,7 @@ protected:
|
||||
private:
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
#if !wxUSE_IOSTREAMH
|
||||
char *m_streambuf;
|
||||
char *m_streambuf;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
@@ -177,7 +177,9 @@ private:
|
||||
// include the platform-dependent class definition
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/textctrl.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/textctrl.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/textctrl.h"
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
virtual bool Enable(bool enable = TRUE);
|
||||
|
||||
virtual void SetCurrent(bool doit = TRUE);
|
||||
virtual bool SetCurrent(bool doit = TRUE);
|
||||
|
||||
virtual void Press();
|
||||
virtual void Release();
|
||||
|
@@ -38,6 +38,7 @@ class WXDLLEXPORT wxScrollBar;
|
||||
#define wxINP_HANDLER_RADIOBTN _T("radiobtn")
|
||||
#define wxINP_HANDLER_SCROLLBAR _T("scrollbar")
|
||||
#define wxINP_HANDLER_LISTBOX _T("listbox")
|
||||
#define wxINP_HANDLER_TEXTCTRL _T("textctrl")
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxInputHandler: maps the events to the actions
|
||||
|
@@ -416,16 +416,11 @@ public:
|
||||
size_t itemFirst, size_t itemLast);
|
||||
void DrawCheckItems(const wxCheckListBox *listbox,
|
||||
size_t itemFirst, size_t itemLast);
|
||||
void DrawBorder();
|
||||
void DrawButtonBorder();
|
||||
// the line must be either horizontal or vertical
|
||||
void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
|
||||
void DrawFrame();
|
||||
void DrawBitmap(const wxBitmap& bitmap);
|
||||
void DrawBitmap(const wxBitmap& bitmap,
|
||||
const wxRect& rect,
|
||||
int alignment = wxALIGN_CENTRE | wxALIGN_CENTRE_VERTICAL,
|
||||
wxStretch stretch = wxSTRETCH_NOT);
|
||||
void DrawBackgroundBitmap();
|
||||
void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld);
|
||||
|
||||
@@ -438,6 +433,13 @@ public:
|
||||
const wxRect& GetRect() const { return m_rect; }
|
||||
wxRect& GetRect() { return m_rect; }
|
||||
|
||||
// static helpers
|
||||
static void DrawBitmap(wxDC &dc,
|
||||
const wxBitmap& bitmap,
|
||||
const wxRect& rect,
|
||||
int alignment = wxALIGN_CENTRE |
|
||||
wxALIGN_CENTRE_VERTICAL,
|
||||
wxStretch stretch = wxSTRETCH_NOT);
|
||||
private:
|
||||
// common part of DrawItems() and DrawCheckItems()
|
||||
void DoDrawItems(const wxListBox *listbox,
|
||||
|
@@ -49,13 +49,9 @@ public:
|
||||
|
||||
// the origin of the static box is inside the border and under the label:
|
||||
// take account of this
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
virtual wxPoint GetBoxAreaOrigin() const;
|
||||
|
||||
protected:
|
||||
// take into account the border/label here as well
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
virtual void DoGetClientSize(int *width, int *height) const;
|
||||
|
||||
// draw the control
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
|
176
include/wx/univ/textctrl.h
Normal file
176
include/wx/univ/textctrl.h
Normal file
@@ -0,0 +1,176 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/univ/textctrl.h
|
||||
// Purpose: wxTextCtrl class
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 15.09.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIV_TEXTCTRL_H_
|
||||
#define _WX_UNIV_TEXTCTRL_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "univtextctrl.h"
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxCaret;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl actions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
|
||||
{
|
||||
public:
|
||||
// creation
|
||||
// --------
|
||||
|
||||
wxTextCtrl() { Init(); }
|
||||
|
||||
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)
|
||||
{
|
||||
Init();
|
||||
|
||||
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);
|
||||
|
||||
// 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);
|
||||
|
||||
// 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 bool PositionToXY(long pos, long *x, long *y) const;
|
||||
|
||||
virtual void ShowPosition(long pos);
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy();
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
|
||||
// Undo/redo
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
|
||||
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 SetSelection(long from, long to);
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
// wxUniv-specific methods
|
||||
// -----------------------
|
||||
|
||||
// caret stuff
|
||||
virtual void ShowCaret(bool show = TRUE);
|
||||
void HideCaret() { ShowCaret(FALSE); }
|
||||
|
||||
// implementation only from now on
|
||||
// -------------------------------
|
||||
|
||||
// set the right colours
|
||||
virtual bool IsContainerWindow() const { return TRUE; }
|
||||
virtual wxBorder GetDefaultBorder() const { return wxBORDER_SUNKEN; }
|
||||
|
||||
protected:
|
||||
// draw the text
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
// calc the size from the text extent
|
||||
virtual wxSize DoGetBestClientSize() const;
|
||||
|
||||
// input support
|
||||
virtual bool PerformAction(const wxControlAction& action,
|
||||
long numArg = -1,
|
||||
const wxString& strArg = wxEmptyString);
|
||||
virtual wxString GetInputHandlerType() const;
|
||||
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// is this a single-line control?
|
||||
bool IsSingleLine() const { return !(GetWindowStyle() & wxTE_MULTILINE); }
|
||||
|
||||
private:
|
||||
// the value (may be only part of it for the multiline controls)
|
||||
wxString m_value;
|
||||
|
||||
// current position
|
||||
long m_curPos,
|
||||
m_curLine,
|
||||
m_curRow;
|
||||
|
||||
// selection
|
||||
long m_selStart,
|
||||
m_selEnd;
|
||||
|
||||
// flags
|
||||
bool m_isModified:1,
|
||||
m_isEditable:1;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_TEXTCTRL_H_
|
||||
|
@@ -115,8 +115,8 @@ public:
|
||||
// return all state flags at once (combination of wxCONTROL_XXX values)
|
||||
int GetStateFlags() const;
|
||||
|
||||
// operations
|
||||
virtual void SetCurrent(bool doit = TRUE);
|
||||
// set the "highlighted" flag and return TRUE if it changed
|
||||
virtual bool SetCurrent(bool doit = TRUE);
|
||||
|
||||
// get the scrollbar (may be NULL) for the given orientation
|
||||
wxScrollBar *GetScrollbar(int orient) const
|
||||
@@ -175,10 +175,10 @@ protected:
|
||||
void OnErase(wxEraseEvent& event);
|
||||
|
||||
// draw the control background, return TRUE if done
|
||||
virtual bool DoDrawBackground(wxControlRenderer *renderer);
|
||||
virtual bool DoDrawBackground(wxDC& dc);
|
||||
|
||||
// draw the controls border
|
||||
virtual void DoDrawBorder(wxControlRenderer *renderer);
|
||||
virtual void DoDrawBorder(wxDC& dc);
|
||||
|
||||
// draw the controls contents
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/statbox.h"
|
||||
#include "wx/stattext.h"
|
||||
#include "wx/textctrl.h"
|
||||
#endif
|
||||
|
||||
#include "wx/statbmp.h"
|
||||
@@ -52,7 +53,7 @@
|
||||
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
#define DEBUG_SCROLL
|
||||
//#define DEBUG_SCROLL
|
||||
//#define DEBUG_LISTBOX
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -227,9 +228,9 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
|
||||
wxStaticText *text;
|
||||
|
||||
new wxStaticText(this, _T("Test static text"), wxPoint(10, 10));
|
||||
new wxStaticText(this,
|
||||
new wxStaticText(this, -1,
|
||||
_T("&Multi line\n(and very very very very long)\nstatic text"),
|
||||
wxPoint(210, 10));
|
||||
wxPoint(210, 10), wxDefaultSize, wxBORDER_SUNKEN);
|
||||
|
||||
(new wxStaticText(this, _T("&Disabled text"), wxPoint(10, 30)))->Disable();
|
||||
|
||||
@@ -364,6 +365,9 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
|
||||
wxDefaultSize,
|
||||
WXSIZEOF(choices), choices);
|
||||
checkLbox->Check(2);
|
||||
|
||||
new wxTextCtrl(this, -1, _T("Hello, Universe!"),
|
||||
wxPoint(550, 150), wxDefaultSize);
|
||||
}
|
||||
|
||||
void MyUnivFrame::OnButton(wxCommandEvent& event)
|
||||
@@ -429,6 +433,6 @@ void MyUnivCanvas::OnPaint(wxPaintEvent& event)
|
||||
dc.DrawLabel(_T("This is the bottom of the canvas"),
|
||||
wxRect(0, 950, 950, 50), wxALIGN_RIGHT | wxBOTTOM);
|
||||
|
||||
event.Skip();
|
||||
//event.Skip();
|
||||
}
|
||||
|
||||
|
@@ -78,6 +78,7 @@ wxTextCtrlBase::~wxTextCtrlBase()
|
||||
|
||||
bool wxTextCtrlBase::LoadFile(const wxString& filename)
|
||||
{
|
||||
#if wxUSE_FFILE
|
||||
wxFFile file(filename);
|
||||
if ( file.IsOpened() )
|
||||
{
|
||||
@@ -95,6 +96,7 @@ bool wxTextCtrlBase::LoadFile(const wxString& filename)
|
||||
}
|
||||
|
||||
wxLogError(_("File couldn't be loaded."));
|
||||
#endif // wxUSE_FFILE
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -110,6 +112,7 @@ bool wxTextCtrlBase::SaveFile(const wxString& filename)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if wxUSE_FFILE
|
||||
wxFFile file(filename, "w");
|
||||
if ( file.IsOpened() && file.Write(GetValue()) )
|
||||
{
|
||||
@@ -122,6 +125,7 @@ bool wxTextCtrlBase::SaveFile(const wxString& filename)
|
||||
}
|
||||
|
||||
wxLogError(_("The text couldn't be saved."));
|
||||
#endif // wxUSE_FFILE
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -210,5 +214,29 @@ int wxTextCtrlBase::underflow()
|
||||
|
||||
#endif // NO_TEXT_WINDOW_STREAM
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// clipboard stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextCtrlBase::CanCopy() const
|
||||
{
|
||||
// can copy if there's a selection
|
||||
long from, to;
|
||||
GetSelection(&from, &to);
|
||||
return from != to;
|
||||
}
|
||||
|
||||
bool wxTextCtrlBase::CanCut() const
|
||||
{
|
||||
// can cut if there's a selection and if we're not read only
|
||||
return CanCopy() && IsEditable();
|
||||
}
|
||||
|
||||
bool wxTextCtrlBase::CanPaste() const
|
||||
{
|
||||
// can paste if we are not read only
|
||||
return IsEditable();
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
|
@@ -31,8 +31,6 @@
|
||||
#error "This file can't be compiled without GUI!"
|
||||
#endif
|
||||
|
||||
#if wxUSE_LOGGUI || wxUSE_LOGWINDOW
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/app.h"
|
||||
#include "wx/button.h"
|
||||
@@ -48,6 +46,8 @@
|
||||
#include "wx/button.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#if wxUSE_LOGGUI || wxUSE_LOGWINDOW
|
||||
|
||||
#include "wx/file.h"
|
||||
#include "wx/textfile.h"
|
||||
#include "wx/statline.h"
|
||||
@@ -185,24 +185,6 @@ void wxLogStatus(wxFrame *pFrame, const wxChar *szFormat, ...)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxLogTextCtrl implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
|
||||
{
|
||||
m_pTextCtrl = pTextCtrl;
|
||||
}
|
||||
|
||||
void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
|
||||
{
|
||||
wxString msg;
|
||||
TimeStamp(&msg);
|
||||
msg << szString << wxT('\n');
|
||||
|
||||
m_pTextCtrl->AppendText(msg);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxLogGui implementation (FIXME MT-unsafe)
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -1055,3 +1037,26 @@ static int OpenLogFile(wxFile& file, wxString *pFilename)
|
||||
#endif // wxUSE_FILE
|
||||
|
||||
#endif // !(wxUSE_LOGGUI || wxUSE_LOGWINDOW)
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxLogTextCtrl implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxLogTextCtrl::wxLogTextCtrl(wxTextCtrl *pTextCtrl)
|
||||
{
|
||||
m_pTextCtrl = pTextCtrl;
|
||||
}
|
||||
|
||||
void wxLogTextCtrl::DoLogString(const wxChar *szString, time_t WXUNUSED(t))
|
||||
{
|
||||
wxString msg;
|
||||
TimeStamp(&msg);
|
||||
msg << szString << wxT('\n');
|
||||
|
||||
m_pTextCtrl->AppendText(msg);
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
|
@@ -22,12 +22,12 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_SASH
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_SASH
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@@ -484,12 +484,15 @@ void wxScrollHelper::DoPrepareDC(wxDC& dc)
|
||||
-m_yScrollPosition * m_yScrollPixelsPerLine );
|
||||
dc.SetUserScale( m_scaleX, m_scaleY );
|
||||
|
||||
// now done in wxPaintDC itself
|
||||
#if 0
|
||||
// for wxUniversal we need to set the clipping region to avoid overwriting
|
||||
// the scrollbars with the user drawing
|
||||
wxSize size = m_win->GetClientSize();
|
||||
dc.SetClippingRegion(m_xScrollPosition * m_xScrollPixelsPerLine,
|
||||
m_yScrollPosition * m_yScrollPixelsPerLine,
|
||||
size.x, size.y);
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
void wxScrollHelper::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_TAB_DIALOG
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
@@ -1279,3 +1281,4 @@ void wxPanelTabView::ShowWindowForTab(int id)
|
||||
newWindow->Refresh();
|
||||
}
|
||||
|
||||
#endif // wxUSE_TAB_DIALOG
|
||||
|
@@ -2213,6 +2213,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
|
||||
wxPaintDC::wxPaintDC( wxWindow *win )
|
||||
: wxClientDC( win )
|
||||
{
|
||||
#ifdef __WXUNIVERSAL__
|
||||
wxPoint ptOrigin = win->GetClientAreaOrigin();
|
||||
SetDeviceOrigin(ptOrigin.x, ptOrigin.y);
|
||||
wxSize size = win->GetClientSize();
|
||||
SetClippingRegion(wxPoint(0, 0), size);
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
#if USE_PAINT_REGION
|
||||
if (!win->m_clipPaintRegion)
|
||||
return;
|
||||
@@ -2229,12 +2236,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
|
||||
gdk_gc_set_clip_region( m_bgGC, region );
|
||||
}
|
||||
#endif // USE_PAINT_REGION
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
wxPoint ptOrigin = win->GetClientAreaOrigin();
|
||||
SetDeviceOrigin(ptOrigin.x, ptOrigin.y);
|
||||
SetClippingRegion(ptOrigin, win->GetClientSize());
|
||||
#endif // __WXUNIVERSAL__
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -731,27 +731,6 @@ void wxTextCtrl::Paste()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanCopy() const
|
||||
{
|
||||
// Can copy if there's a selection
|
||||
long from, to;
|
||||
GetSelection(& from, & to);
|
||||
return (from != to) ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanCut() const
|
||||
{
|
||||
// Can cut if there's a selection
|
||||
long from, to;
|
||||
GetSelection(& from, & to);
|
||||
return (from != to) ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanPaste() const
|
||||
{
|
||||
return IsEditable() ;
|
||||
}
|
||||
|
||||
// Undo/redo
|
||||
void wxTextCtrl::Undo()
|
||||
{
|
||||
|
@@ -696,7 +696,7 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
||||
|
||||
if (gdk_event->count == 0)
|
||||
{
|
||||
wxClientDC dc(win);
|
||||
wxWindowDC dc(win);
|
||||
dc.SetClippingRegion(win->GetUpdateRegion());
|
||||
wxEraseEvent eevent( win->GetId(), &dc );
|
||||
eevent.SetEventObject( win );
|
||||
@@ -808,7 +808,7 @@ static void gtk_window_draw_callback( GtkWidget *widget,
|
||||
|
||||
win->m_clipPaintRegion = TRUE;
|
||||
|
||||
wxClientDC dc(win);
|
||||
wxWindowDC dc(win);
|
||||
dc.SetClippingRegion(win->GetUpdateRegion());
|
||||
wxEraseEvent eevent( win->GetId(), &dc );
|
||||
eevent.SetEventObject( win );
|
||||
|
@@ -2213,6 +2213,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
|
||||
wxPaintDC::wxPaintDC( wxWindow *win )
|
||||
: wxClientDC( win )
|
||||
{
|
||||
#ifdef __WXUNIVERSAL__
|
||||
wxPoint ptOrigin = win->GetClientAreaOrigin();
|
||||
SetDeviceOrigin(ptOrigin.x, ptOrigin.y);
|
||||
wxSize size = win->GetClientSize();
|
||||
SetClippingRegion(wxPoint(0, 0), size);
|
||||
#endif // __WXUNIVERSAL__
|
||||
|
||||
#if USE_PAINT_REGION
|
||||
if (!win->m_clipPaintRegion)
|
||||
return;
|
||||
@@ -2229,12 +2236,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
|
||||
gdk_gc_set_clip_region( m_bgGC, region );
|
||||
}
|
||||
#endif // USE_PAINT_REGION
|
||||
|
||||
#ifdef __WXUNIVERSAL__
|
||||
wxPoint ptOrigin = win->GetClientAreaOrigin();
|
||||
SetDeviceOrigin(ptOrigin.x, ptOrigin.y);
|
||||
SetClippingRegion(ptOrigin, win->GetClientSize());
|
||||
#endif // __WXUNIVERSAL__
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -731,27 +731,6 @@ void wxTextCtrl::Paste()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanCopy() const
|
||||
{
|
||||
// Can copy if there's a selection
|
||||
long from, to;
|
||||
GetSelection(& from, & to);
|
||||
return (from != to) ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanCut() const
|
||||
{
|
||||
// Can cut if there's a selection
|
||||
long from, to;
|
||||
GetSelection(& from, & to);
|
||||
return (from != to) ;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanPaste() const
|
||||
{
|
||||
return IsEditable() ;
|
||||
}
|
||||
|
||||
// Undo/redo
|
||||
void wxTextCtrl::Undo()
|
||||
{
|
||||
|
@@ -696,7 +696,7 @@ static int gtk_window_expose_callback( GtkWidget *widget,
|
||||
|
||||
if (gdk_event->count == 0)
|
||||
{
|
||||
wxClientDC dc(win);
|
||||
wxWindowDC dc(win);
|
||||
dc.SetClippingRegion(win->GetUpdateRegion());
|
||||
wxEraseEvent eevent( win->GetId(), &dc );
|
||||
eevent.SetEventObject( win );
|
||||
@@ -808,7 +808,7 @@ static void gtk_window_draw_callback( GtkWidget *widget,
|
||||
|
||||
win->m_clipPaintRegion = TRUE;
|
||||
|
||||
wxClientDC dc(win);
|
||||
wxWindowDC dc(win);
|
||||
dc.SetClippingRegion(win->GetUpdateRegion());
|
||||
wxEraseEvent eevent( win->GetId(), &dc );
|
||||
eevent.SetEventObject( win );
|
||||
|
@@ -94,11 +94,11 @@ bool wxBitmapButton::Enable(bool enable)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxBitmapButton::SetCurrent(bool doit)
|
||||
bool wxBitmapButton::SetCurrent(bool doit)
|
||||
{
|
||||
ChangeBitmap(doit ? m_bmpFocus : m_bmpNormal);
|
||||
|
||||
wxButton::SetCurrent(doit);
|
||||
return wxButton::SetCurrent(doit);
|
||||
}
|
||||
|
||||
void wxBitmapButton::OnSetFocus(wxFocusEvent& event)
|
||||
|
@@ -15,6 +15,7 @@ UNIVOBJS = \
|
||||
statbox.o \
|
||||
statline.o \
|
||||
stattext.o \
|
||||
textctrl.o \
|
||||
theme.o \
|
||||
gtk.o \
|
||||
winuniv.o \
|
||||
@@ -37,6 +38,7 @@ UNIVDEPS = \
|
||||
statbox.d \
|
||||
statline.d \
|
||||
stattext.d \
|
||||
textctrl.d \
|
||||
theme.d \
|
||||
gtk.d \
|
||||
winuniv.d \
|
||||
|
@@ -249,6 +249,11 @@ wxSize wxRadioBox::DoGetBestClientSize() const
|
||||
sizeBtn.x += 2*BOX_BORDER_X;
|
||||
sizeBtn.y += 2*BOX_BORDER_Y;
|
||||
|
||||
// account for the area taken by static box
|
||||
wxRect rect = GetBorderGeometry();
|
||||
sizeBtn.x += rect.x + rect.width;
|
||||
sizeBtn.y += rect.y + rect.height;
|
||||
|
||||
return sizeBtn;
|
||||
}
|
||||
|
||||
@@ -257,7 +262,7 @@ void wxRadioBox::DoMoveWindow(int x0, int y0, int width, int height)
|
||||
wxStaticBox::DoMoveWindow(x0, y0, width, height);
|
||||
|
||||
wxSize sizeBtn = GetMaxButtonSize();
|
||||
wxPoint ptOrigin = GetClientAreaOrigin();
|
||||
wxPoint ptOrigin = GetBoxAreaOrigin();
|
||||
|
||||
x0 += ptOrigin.x + BOX_BORDER_X;
|
||||
y0 += ptOrigin.y + BOX_BORDER_Y;
|
||||
|
@@ -307,42 +307,20 @@ wxRenderer::~wxRenderer()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxControlRenderer::wxControlRenderer(wxWindow *window,
|
||||
wxDC& dc,
|
||||
wxRenderer *renderer)
|
||||
wxDC& dc,
|
||||
wxRenderer *renderer)
|
||||
: m_dc(dc)
|
||||
{
|
||||
m_window = window;
|
||||
m_renderer = renderer;
|
||||
|
||||
wxSize size = m_window->GetSize();
|
||||
wxSize size = m_window->GetClientSize();
|
||||
m_rect.x =
|
||||
m_rect.y = 0;
|
||||
m_rect.width = size.x;
|
||||
m_rect.height = size.y;
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBorder()
|
||||
{
|
||||
int flags = m_window->GetStateFlags();
|
||||
|
||||
// if the scrollbars are outside the border, we must adjust the rect to
|
||||
// exclude them
|
||||
if ( !m_renderer->AreScrollbarsInsideBorder() )
|
||||
{
|
||||
wxScrollBar *scrollbar = m_window->GetScrollbar(wxVERTICAL);
|
||||
if ( scrollbar )
|
||||
m_rect.width -= scrollbar->GetSize().x;
|
||||
|
||||
scrollbar = m_window->GetScrollbar(wxHORIZONTAL);
|
||||
if ( scrollbar )
|
||||
m_rect.height -= scrollbar->GetSize().y;
|
||||
}
|
||||
|
||||
// draw outline
|
||||
m_renderer->DrawBorder(m_dc, m_window->GetBorder(),
|
||||
m_rect, flags, &m_rect);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawLabel(const wxBitmap& bitmap,
|
||||
wxCoord marginX, wxCoord marginY)
|
||||
{
|
||||
@@ -398,29 +376,14 @@ void wxControlRenderer::DrawButtonBorder()
|
||||
void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
int style = m_window->GetWindowStyle();
|
||||
DrawBitmap(bitmap, m_rect,
|
||||
DrawBitmap(m_dc, bitmap, m_rect,
|
||||
style & wxALIGN_MASK,
|
||||
style & wxBI_EXPAND ? wxEXPAND : wxSTRETCH_NOT);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBackgroundBitmap()
|
||||
{
|
||||
if ( m_window->GetBackgroundBitmap().Ok() )
|
||||
{
|
||||
// get the bitmap and the flags
|
||||
int alignment;
|
||||
wxStretch stretch;
|
||||
wxBitmap bmp = m_window->GetBackgroundBitmap(&alignment, &stretch);
|
||||
DrawBitmap(bmp, m_rect, alignment, stretch);
|
||||
}
|
||||
else // just fill it with bg colour if no bitmap
|
||||
{
|
||||
m_renderer->DrawBackground(m_dc, wxTHEME_BG_COLOUR(m_window),
|
||||
m_rect, m_window->GetStateFlags());
|
||||
}
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap,
|
||||
/* static */
|
||||
void wxControlRenderer::DrawBitmap(wxDC &dc,
|
||||
const wxBitmap& bitmap,
|
||||
const wxRect& rect,
|
||||
int alignment,
|
||||
wxStretch stretch)
|
||||
@@ -443,7 +406,7 @@ void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap,
|
||||
for ( y = 0; y < rect.height; y += height )
|
||||
{
|
||||
// no need to use mask here as we cover the entire window area
|
||||
m_dc.DrawBitmap(bmp, x, y);
|
||||
dc.DrawBitmap(bmp, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -482,7 +445,7 @@ void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap,
|
||||
}
|
||||
|
||||
// do draw it
|
||||
m_dc.DrawBitmap(bmp, x, y, TRUE /* use mask */);
|
||||
dc.DrawBitmap(bmp, x, y, TRUE /* use mask */);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar,
|
||||
|
@@ -86,7 +86,7 @@ wxRect wxStaticBox::GetBorderGeometry() const
|
||||
return rect;
|
||||
}
|
||||
|
||||
wxPoint wxStaticBox::GetClientAreaOrigin() const
|
||||
wxPoint wxStaticBox::GetBoxAreaOrigin() const
|
||||
{
|
||||
wxPoint pt = wxControl::GetClientAreaOrigin();
|
||||
wxRect rect = GetBorderGeometry();
|
||||
@@ -96,6 +96,7 @@ wxPoint wxStaticBox::GetClientAreaOrigin() const
|
||||
return pt;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void wxStaticBox::DoSetClientSize(int width, int height)
|
||||
{
|
||||
wxRect rect = GetBorderGeometry();
|
||||
@@ -115,5 +116,7 @@ void wxStaticBox::DoGetClientSize(int *width, int *height) const
|
||||
*height -= rect.y + rect.height;
|
||||
}
|
||||
|
||||
#endif // 0
|
||||
|
||||
#endif // wxUSE_STATBOX
|
||||
|
||||
|
@@ -87,8 +87,6 @@ wxSize wxStaticText::DoGetBestClientSize() const
|
||||
|
||||
void wxStaticText::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
wxControl::DoDraw(renderer);
|
||||
|
||||
renderer->DrawLabel();
|
||||
}
|
||||
|
||||
|
440
src/univ/textctrl.cpp
Normal file
440
src/univ/textctrl.cpp
Normal file
@@ -0,0 +1,440 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: univ/textctrl.cpp
|
||||
// Purpose: wxTextCtrl
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 15.09.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "univtextctrl.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/validate.h"
|
||||
#include "wx/textctrl.h"
|
||||
#endif
|
||||
|
||||
#include "wx/caret.h"
|
||||
|
||||
#include "wx/univ/inphand.h"
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// creation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::Init()
|
||||
{
|
||||
m_selStart =
|
||||
m_selEnd = -1;
|
||||
|
||||
m_isModified = FALSE;
|
||||
m_isEditable = TRUE;
|
||||
|
||||
m_caret = (wxCaret *)NULL;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString &name)
|
||||
{
|
||||
if ( !wxControl::Create(parent, id, pos, size, style,
|
||||
validator, name) )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxCaret *caret = new wxCaret(this, 1, GetCharHeight());
|
||||
SetCaret(caret);
|
||||
caret->Show();
|
||||
|
||||
SetCursor(wxCURSOR_IBEAM);
|
||||
|
||||
SetValue(value);
|
||||
SetBestSize(size);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// set/get the value
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::SetValue(const wxString& value)
|
||||
{
|
||||
m_value = value;
|
||||
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
SetInsertionPointEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetInsertionPoint(0);
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetValue() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void wxTextCtrl::Clear()
|
||||
{
|
||||
SetValue(_T(""));
|
||||
}
|
||||
|
||||
void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
|
||||
// update current position
|
||||
}
|
||||
|
||||
void wxTextCtrl::Remove(long from, long to)
|
||||
{
|
||||
Replace(from, to, _T(""));
|
||||
}
|
||||
|
||||
void wxTextCtrl::WriteText(const wxString& text)
|
||||
{
|
||||
Replace(m_curPos, m_curPos, text);
|
||||
}
|
||||
|
||||
void wxTextCtrl::AppendText(const wxString& text)
|
||||
{
|
||||
SetInsertionPointEnd();
|
||||
WriteText(text);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// current position
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::SetInsertionPoint(long pos)
|
||||
{
|
||||
HideCaret();
|
||||
|
||||
m_curPos = pos;
|
||||
|
||||
ShowCaret();
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetInsertionPointEnd()
|
||||
{
|
||||
SetInsertionPoint(GetLastPosition());
|
||||
}
|
||||
|
||||
long wxTextCtrl::GetInsertionPoint() const
|
||||
{
|
||||
return m_curPos;
|
||||
}
|
||||
|
||||
long wxTextCtrl::GetLastPosition() const
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
return m_value.length();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG(_T("unimplemented for multi line"));
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// selection
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::GetSelection(long* from, long* to) const
|
||||
{
|
||||
if ( from )
|
||||
*from = m_selStart;
|
||||
if ( to )
|
||||
*to = m_selEnd;
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetSelection(long from, long to)
|
||||
{
|
||||
if ( from != m_selStart || to != m_selEnd )
|
||||
{
|
||||
m_selStart = from;
|
||||
m_selEnd = to;
|
||||
|
||||
// TODO: update display
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// flags
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextCtrl::IsModified() const
|
||||
{
|
||||
return m_isModified;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::IsEditable() const
|
||||
{
|
||||
return m_isEditable;
|
||||
}
|
||||
|
||||
void wxTextCtrl::DiscardEdits()
|
||||
{
|
||||
m_isModified = FALSE;
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetEditable(bool editable)
|
||||
{
|
||||
if ( editable != m_isEditable )
|
||||
{
|
||||
m_isEditable = editable;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// col/lines <-> position correspondence
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxTextCtrl::GetLineLength(long line) const
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
wxASSERT_MSG( line == 0, _T("invalid GetLineLength() parameter") );
|
||||
|
||||
return m_value.length();
|
||||
}
|
||||
else // multiline
|
||||
{
|
||||
wxFAIL_MSG(_T("unimplemented for multi line"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetLineText(long line) const
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
wxASSERT_MSG( line == 0, _T("invalid GetLineLength() parameter") );
|
||||
|
||||
return m_value;
|
||||
}
|
||||
else // multiline
|
||||
{
|
||||
wxFAIL_MSG(_T("unimplemented for multi line"));
|
||||
|
||||
return _T("");
|
||||
}
|
||||
}
|
||||
|
||||
int wxTextCtrl::GetNumberOfLines() const
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else // multiline
|
||||
{
|
||||
wxFAIL_MSG(_T("unimplemented for multi line"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
wxASSERT_MSG( y == 0, _T("invalid XYToPosition() parameter") );
|
||||
|
||||
return x;
|
||||
}
|
||||
else // multiline
|
||||
{
|
||||
wxFAIL_MSG(_T("unimplemented for multi line"));
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTextCtrl::PositionToXY(long pos, long *x, long *y) const
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
if ( x )
|
||||
*x = m_curPos;
|
||||
if ( y )
|
||||
*y = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else // multiline
|
||||
{
|
||||
wxFAIL_MSG(_T("unimplemented for multi line"));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::ShowPosition(long pos)
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// clipboard stuff
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::Copy()
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
void wxTextCtrl::Cut()
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
void wxTextCtrl::Paste()
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
|
||||
void wxTextCtrl::Undo()
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
void wxTextCtrl::Redo()
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
|
||||
bool wxTextCtrl::CanUndo() const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanRedo() const
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// geometry
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxSize wxTextCtrl::DoGetBestClientSize() const
|
||||
{
|
||||
wxCoord w, h;
|
||||
GetTextExtent(GetLineText(0), &w, &h);
|
||||
|
||||
int wChar = GetCharWidth(),
|
||||
hChar = GetCharHeight();
|
||||
|
||||
if ( w < wChar )
|
||||
w = 8*wChar;
|
||||
if ( h < hChar )
|
||||
h = hChar;
|
||||
|
||||
w += 2*wChar;
|
||||
|
||||
return wxSize(w, h);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxTextCtrl::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
if ( IsSingleLine() )
|
||||
{
|
||||
// just redraw everything
|
||||
renderer->GetDC().DrawText(m_value, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::ShowCaret(bool show)
|
||||
{
|
||||
wxCaret *caret = GetCaret();
|
||||
if ( caret )
|
||||
{
|
||||
caret->Show(show);
|
||||
|
||||
if ( caret->IsVisible() )
|
||||
{
|
||||
// position it correctly
|
||||
wxString textBeforeCaret(m_value, (size_t)m_curPos);
|
||||
wxCoord x;
|
||||
GetTextExtent(textBeforeCaret, &x, NULL);
|
||||
|
||||
caret->Move(x + 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// input
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxString wxTextCtrl::GetInputHandlerType() const
|
||||
{
|
||||
return wxINP_HANDLER_TEXTCTRL;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::PerformAction(const wxControlAction& action,
|
||||
long numArg,
|
||||
const wxString& strArg)
|
||||
{
|
||||
return wxControl::PerformAction(action, numArg, strArg);
|
||||
}
|
||||
|
||||
#endif // wxUSE_TEXTCTRL
|
@@ -1698,12 +1698,6 @@ bool wxGTKInputHandler::HandleMouseMove(wxControl *control,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// don't refresh static controls uselessly - they never react to this
|
||||
if ( control->AcceptsFocus() )
|
||||
{
|
||||
control->Refresh();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include "wx/scrolbar.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#include "wx/univ/colschem.h"
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
@@ -147,9 +148,7 @@ void wxWindow::OnErase(wxEraseEvent& event)
|
||||
return;
|
||||
}
|
||||
|
||||
wxControlRenderer renderer(this, *event.GetDC(), m_renderer);
|
||||
|
||||
DoDrawBackground(&renderer);
|
||||
DoDrawBackground(*event.GetDC());
|
||||
|
||||
// if we have both scrollbars, we also have a square in the corner between
|
||||
// them which we must paint
|
||||
@@ -176,10 +175,9 @@ void wxWindow::OnNcPaint(wxPaintEvent& event)
|
||||
{
|
||||
// get the DC to use and create renderer on it
|
||||
wxWindowDC dc(this);
|
||||
wxControlRenderer renderer(this, dc, m_renderer);
|
||||
|
||||
// draw the border
|
||||
DoDrawBorder(&renderer);
|
||||
DoDrawBorder(dc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,16 +199,56 @@ void wxWindow::OnPaint(wxPaintEvent& event)
|
||||
}
|
||||
}
|
||||
|
||||
bool wxWindow::DoDrawBackground(wxControlRenderer *renderer)
|
||||
bool wxWindow::DoDrawBackground(wxDC& dc)
|
||||
{
|
||||
renderer->DrawBackgroundBitmap();
|
||||
wxRect rect;
|
||||
wxSize size = GetSize(); // full, not client only
|
||||
rect.width = size.x;
|
||||
rect.height = size.y;
|
||||
|
||||
if ( GetBackgroundBitmap().Ok() )
|
||||
{
|
||||
// get the bitmap and the flags
|
||||
int alignment;
|
||||
wxStretch stretch;
|
||||
wxBitmap bmp = GetBackgroundBitmap(&alignment, &stretch);
|
||||
wxControlRenderer::DrawBitmap(dc, bmp, rect, alignment, stretch);
|
||||
}
|
||||
else // just fill it with bg colour if no bitmap
|
||||
{
|
||||
m_renderer->DrawBackground(dc, wxTHEME_BG_COLOUR(this),
|
||||
rect, GetStateFlags());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxWindow::DoDrawBorder(wxControlRenderer *renderer)
|
||||
void wxWindow::DoDrawBorder(wxDC& dc)
|
||||
{
|
||||
renderer->DrawBorder();
|
||||
// get the window rect
|
||||
wxRect rect;
|
||||
wxSize size = GetSize();
|
||||
rect.x =
|
||||
rect.y = 0;
|
||||
rect.width = size.x;
|
||||
rect.height = size.y;
|
||||
|
||||
// if the scrollbars are outside the border, we must adjust the rect to
|
||||
// exclude them
|
||||
if ( !m_renderer->AreScrollbarsInsideBorder() )
|
||||
{
|
||||
wxScrollBar *scrollbar = GetScrollbar(wxVERTICAL);
|
||||
if ( scrollbar )
|
||||
rect.width -= scrollbar->GetSize().x;
|
||||
|
||||
scrollbar = GetScrollbar(wxHORIZONTAL);
|
||||
if ( scrollbar )
|
||||
rect.height -= scrollbar->GetSize().y;
|
||||
}
|
||||
|
||||
// draw outline
|
||||
m_renderer->DrawBorder(dc, GetBorder(),
|
||||
rect, GetStateFlags(), &rect);
|
||||
}
|
||||
|
||||
void wxWindow::DoDraw(wxControlRenderer *renderer)
|
||||
@@ -242,9 +280,17 @@ bool wxWindow::IsCurrent() const
|
||||
return m_isCurrent;
|
||||
}
|
||||
|
||||
void wxWindow::SetCurrent(bool doit)
|
||||
bool wxWindow::SetCurrent(bool doit)
|
||||
{
|
||||
if ( doit == m_isCurrent )
|
||||
return FALSE;
|
||||
|
||||
m_isCurrent = doit;
|
||||
|
||||
if ( CanBeHighlighted() )
|
||||
Refresh();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxWindow::GetStateFlags() const
|
||||
|
Reference in New Issue
Block a user