wxNO_BORDER honoured by wxTextCtrl
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1974 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,6 +9,14 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "textctrl.h"
|
#pragma implementation "textctrl.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -16,37 +24,27 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fstream.h>
|
#include <fstream.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "wx/textctrl.h"
|
#include "wx/textctrl.h"
|
||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
#if defined(__BORLANDC__) && !defined(__WIN32__)
|
|
||||||
#include <alloc.h>
|
|
||||||
#else
|
|
||||||
#ifndef __GNUWIN32__
|
|
||||||
#include <malloc.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Xm/Text.h>
|
#include <Xm/Text.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#include "wx/motif/private.h"
|
#include "wx/motif/private.h"
|
||||||
|
|
||||||
static void
|
// ----------------------------------------------------------------------------
|
||||||
wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr);
|
// private functions
|
||||||
static void
|
// ----------------------------------------------------------------------------
|
||||||
wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStruct *cbs);
|
|
||||||
static void
|
// callbacks
|
||||||
wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
|
static void wxTextWindowChangedProc(Widget w, XtPointer clientData, XtPointer ptr);
|
||||||
static void
|
static void wxTextWindowModifyProc(Widget w, XtPointer clientData, XmTextVerifyCallbackStruct *cbs);
|
||||||
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
|
static void wxTextWindowGainFocusProc(Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
|
||||||
static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
|
static void wxTextWindowLoseFocusProc(Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
|
||||||
XmAnyCallbackStruct *ptr);
|
static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallbackStruct *ptr);
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||||
@@ -57,36 +55,45 @@ EVT_CHAR(wxTextCtrl::OnChar)
|
|||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxTextCtrl
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Text item
|
// Text item
|
||||||
wxTextCtrl::wxTextCtrl()
|
wxTextCtrl::wxTextCtrl()
|
||||||
#ifndef NO_TEXT_WINDOW_STREAM
|
#ifndef NO_TEXT_WINDOW_STREAM
|
||||||
: streambuf()
|
: streambuf()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
m_fileName = "";
|
|
||||||
m_tempCallbackStruct = (void*) NULL;
|
m_tempCallbackStruct = (void*) NULL;
|
||||||
m_modified = FALSE;
|
m_modified = FALSE;
|
||||||
m_processedDefault = FALSE;
|
m_processedDefault = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
bool wxTextCtrl::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
const wxString& value,
|
const wxString& value,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size, long style,
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
const wxValidator& validator,
|
const wxValidator& validator,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_tempCallbackStruct = (void*) NULL;
|
m_tempCallbackStruct = (void*) NULL;
|
||||||
m_modified = FALSE;
|
m_modified = FALSE;
|
||||||
m_processedDefault = FALSE;
|
m_processedDefault = FALSE;
|
||||||
m_fileName = "";
|
|
||||||
// m_backgroundColour = parent->GetBackgroundColour();
|
// m_backgroundColour = parent->GetBackgroundColour();
|
||||||
m_backgroundColour = * wxWHITE;
|
m_backgroundColour = * wxWHITE;
|
||||||
m_foregroundColour = parent->GetForegroundColour();
|
m_foregroundColour = parent->GetForegroundColour();
|
||||||
|
|
||||||
SetName(name);
|
SetName(name);
|
||||||
SetValidator(validator);
|
SetValidator(validator);
|
||||||
if (parent) parent->AddChild(this);
|
if (parent)
|
||||||
|
parent->AddChild(this);
|
||||||
|
|
||||||
m_windowStyle = style;
|
m_windowStyle = style;
|
||||||
|
|
||||||
@@ -108,7 +115,9 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False);
|
XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False);
|
||||||
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
|
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
|
||||||
|
|
||||||
m_mainWidget = (WXWidget) XmCreateScrolledText (parentWidget, (char*) (const char*) name, args, 2);
|
m_mainWidget = (WXWidget) XmCreateScrolledText(parentWidget,
|
||||||
|
(char*)name.c_str(),
|
||||||
|
args, 2);
|
||||||
|
|
||||||
XtVaSetValues ((Widget) m_mainWidget,
|
XtVaSetValues ((Widget) m_mainWidget,
|
||||||
XmNeditable, ((style & wxTE_READONLY) ? False : True),
|
XmNeditable, ((style & wxTE_READONLY) ? False : True),
|
||||||
@@ -118,9 +127,13 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
|
m_mainWidget = (WXWidget)XtVaCreateManagedWidget
|
||||||
xmTextWidgetClass, parentWidget,
|
(
|
||||||
NULL);
|
(char*)name.c_str(),
|
||||||
|
xmTextWidgetClass,
|
||||||
|
parentWidget,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: Is this relevant? What does it do?
|
// TODO: Is this relevant? What does it do?
|
||||||
int noCols = 2;
|
int noCols = 2;
|
||||||
@@ -131,9 +144,18 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!value.IsNull())
|
// remove border if asked for
|
||||||
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
|
if ( style & wxNO_BORDER )
|
||||||
|
{
|
||||||
|
XtVaSetValues((Widget)m_mainWidget,
|
||||||
|
XmNshadowThickness, 0,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !!value )
|
||||||
|
XmTextSetString ((Widget) m_mainWidget, (char*)value.c_str());
|
||||||
|
|
||||||
|
// install callbacks
|
||||||
XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this);
|
XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this);
|
||||||
|
|
||||||
XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this);
|
XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this);
|
||||||
@@ -144,6 +166,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
|
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
|
||||||
|
|
||||||
|
// font
|
||||||
m_windowFont = parent->GetFont();
|
m_windowFont = parent->GetFont();
|
||||||
ChangeFont(FALSE);
|
ChangeFont(FALSE);
|
||||||
|
|
||||||
@@ -182,12 +205,9 @@ wxString wxTextCtrl::GetValue() const
|
|||||||
|
|
||||||
void wxTextCtrl::SetValue(const wxString& value)
|
void wxTextCtrl::SetValue(const wxString& value)
|
||||||
{
|
{
|
||||||
// This assert is wrong -- means that you can't set an empty
|
|
||||||
// string (IsNull == IsEmpty).
|
|
||||||
// wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ;
|
|
||||||
m_inSetValue = TRUE;
|
m_inSetValue = TRUE;
|
||||||
|
|
||||||
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
|
XmTextSetString ((Widget) m_mainWidget, (char*)value.c_str());
|
||||||
|
|
||||||
m_inSetValue = FALSE;
|
m_inSetValue = FALSE;
|
||||||
}
|
}
|
||||||
@@ -857,6 +877,10 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// callbacks
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
|
wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
|
||||||
{
|
{
|
||||||
@@ -888,15 +912,6 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||||
/*
|
|
||||||
case XmCR_ACTIVATE:
|
|
||||||
type_event = wxEVENT_TYPE_TEXT_ENTER_COMMAND ;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
type_event = wxEVENT_TYPE_TEXT_COMMAND ;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (tw->InSetValue())
|
if (tw->InSetValue())
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user