Misc. Motif; removed duplicate wxICON; variant compile fix; added wxString form
of wxStripMenuCodes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@843 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
#ifndef _WX_ICON_H_BASE_
|
||||
#define _WX_ICON_H_BASE_
|
||||
|
||||
/* Commenting out since duplicated in gdicmn.h
|
||||
// this is for Unix (i.e. now for anything other than MSW)
|
||||
#undef wxICON
|
||||
#define wxICON(icon_name) wxIcon(icon_name##_xpm)
|
||||
*/
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
// under Windows, icon name is the ressource id (string)
|
||||
#undef wxICON
|
||||
#define wxICON(icon_name) wxIcon(#icon_name)
|
||||
|
||||
#include "wx/msw/icon.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/icon.h"
|
||||
|
@@ -138,6 +138,7 @@ public:
|
||||
inline WXAppContext GetAppContext() const { return m_appContext; }
|
||||
inline WXWidget GetTopLevelWidget() const { return m_topLevelWidget; }
|
||||
WXColormap GetMainColormap(WXDisplay* display) ;
|
||||
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
|
||||
inline long GetMaxRequestSize() const { return m_maxRequestSize; }
|
||||
|
||||
// This handler is called when a property change event occurs
|
||||
@@ -154,6 +155,7 @@ protected:
|
||||
WXAppContext m_appContext;
|
||||
WXWidget m_topLevelWidget;
|
||||
WXColormap m_mainColormap;
|
||||
WXDisplay* m_initialDisplay;
|
||||
long m_maxRequestSize;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -96,6 +96,10 @@ class WXDLLEXPORT wxWindowDC: public wxDC
|
||||
// Motif-specific
|
||||
void SetDCClipping (); // Helper function for setting clipping
|
||||
|
||||
inline WXGC GetGC() const { return m_gc; }
|
||||
inline bool GetAutoSetting() const { return m_autoSetting; }
|
||||
inline void SetAutoSetting(bool flag) { m_autoSetting = flag; }
|
||||
|
||||
protected:
|
||||
WXGC m_gc;
|
||||
WXGC m_gcBacking;
|
||||
|
@@ -86,6 +86,8 @@
|
||||
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
|
||||
// In debug mode, cause new and delete to be redefined globally.
|
||||
// If this causes problems (e.g. link errors), set this to 0.
|
||||
// In wxMotif, causes an 'all bets are off'
|
||||
// memory error (generated by wxWindows)
|
||||
|
||||
#define REMOVE_UNUSED_ARG 1
|
||||
// Set this to 0 if your compiler can't cope
|
||||
|
@@ -26,7 +26,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBox)
|
||||
|
||||
public:
|
||||
inline wxStaticBox() {}
|
||||
wxStaticBox();
|
||||
inline wxStaticBox(wxWindow *parent, wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
@@ -49,8 +49,18 @@ class WXDLLEXPORT wxStaticBox: public wxControl
|
||||
|
||||
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
void SetLabel(const wxString& label);
|
||||
wxString GetLabel() const;
|
||||
|
||||
// Motif-specific
|
||||
WXWidget GetTopWidget() const { return m_formWidget; }
|
||||
WXWidget GetLabelWidget() const { return m_labelWidget; }
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
protected:
|
||||
// Motif-specific
|
||||
WXWidget m_formWidget;
|
||||
WXWidget m_labelWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -465,6 +465,8 @@ public:
|
||||
|
||||
// Get main widget for this window, e.g. a text widget
|
||||
virtual WXWidget GetMainWidget() const;
|
||||
// Get the widget that supports font setting
|
||||
virtual WXWidget GetLabelWidget() const { return GetMainWidget(); }
|
||||
// Get the client widget for this window (something we can
|
||||
// create other windows on)
|
||||
virtual WXWidget GetClientWidget() const;
|
||||
@@ -561,13 +563,14 @@ protected:
|
||||
bool m_winCaptured;
|
||||
bool m_hScroll;
|
||||
bool m_vScroll;
|
||||
bool m_hScrollingEnabled;
|
||||
bool m_vScrollingEnabled;
|
||||
WXPixmap m_backingPixmap;
|
||||
int m_pixmapWidth;
|
||||
int m_pixmapHeight;
|
||||
int m_pixmapOffsetX;
|
||||
int m_pixmapOffsetY;
|
||||
int m_scrollPosX; // Store the last scroll pos,
|
||||
int m_scrollPosY; // since in wxWin the pos isn't
|
||||
// set automatically by system
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -144,6 +144,7 @@ bool WXDLLEXPORT wxGetUserName(char *buf, int maxSize);
|
||||
* Strip out any menu codes
|
||||
*/
|
||||
char* WXDLLEXPORT wxStripMenuCodes(char *in, char *out = (char *) NULL);
|
||||
wxString WXDLLEXPORT wxStripMenuCodes(const wxString& str);
|
||||
|
||||
// Find the window/widget with the given title or label.
|
||||
// Pass a parent to begin the search from, or NULL to look through
|
||||
|
@@ -390,6 +390,14 @@ char *wxStripMenuCodes (char *in, char *out)
|
||||
return tmpOut;
|
||||
}
|
||||
|
||||
wxString wxStripMenuCodes(const wxString& str)
|
||||
{
|
||||
char *buf = new char[str.Length() + 1];
|
||||
wxStripMenuCodes((char*) (const char*) str, buf);
|
||||
wxString str1(buf);
|
||||
delete[] buf;
|
||||
return str1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Window search functions
|
||||
|
@@ -677,7 +677,7 @@ bool wxVariantDataString::Write(ostream& str) const
|
||||
|
||||
bool wxVariantDataString::Write(wxOutputStream& str) const
|
||||
{
|
||||
str << m_value;
|
||||
str << (const char*) m_value;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -247,6 +247,7 @@ wxApp::wxApp()
|
||||
m_appContext = (WXAppContext) NULL;
|
||||
m_topLevelWidget = (WXWidget) NULL;
|
||||
m_maxRequestSize = 0;
|
||||
m_initialDisplay = (WXDisplay*) 0;
|
||||
}
|
||||
|
||||
bool wxApp::Initialized()
|
||||
@@ -460,6 +461,8 @@ bool wxApp::OnInitGui()
|
||||
cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
|
||||
exit(-1);
|
||||
}
|
||||
m_initialDisplay = (WXDisplay*) dpy;
|
||||
|
||||
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
|
||||
applicationShellWidgetClass,dpy,
|
||||
NULL,0) ;
|
||||
|
@@ -30,8 +30,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
SetValidator(validator);
|
||||
parent->AddChild(this);
|
||||
|
||||
m_backgroundColour = parent->GetDefaultBackgroundColour() ;
|
||||
m_foregroundColour = parent->GetDefaultForegroundColour() ;
|
||||
m_backgroundColour = parent->GetBackgroundColour() ;
|
||||
m_foregroundColour = parent->GetForegroundColour() ;
|
||||
m_windowStyle = style;
|
||||
m_marginX = 0;
|
||||
m_marginY = 0;
|
||||
|
@@ -188,8 +188,13 @@ wxCursor::wxCursor(wxStockCursor id)
|
||||
{
|
||||
m_refData = new wxCursorRefData;
|
||||
M_CURSORDATA->m_cursorId = id;
|
||||
M_CURSORDATA->m_ok = TRUE;
|
||||
|
||||
WXCursor cursor = GetXCursor(wxGetDisplay());
|
||||
WXDisplay* display = wxGetDisplay();
|
||||
if (!display)
|
||||
return;
|
||||
|
||||
WXCursor cursor = GetXCursor(display);
|
||||
if (cursor)
|
||||
{
|
||||
wxXCursor* c = new wxXCursor;
|
||||
|
@@ -15,9 +15,18 @@
|
||||
|
||||
#include "wx/scrolbar.h"
|
||||
|
||||
#include <X11/IntrinsicP.h>
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/RowColumn.h>
|
||||
#include <Xm/ScrollBar.h>
|
||||
|
||||
#include <wx/motif/private.h>
|
||||
|
||||
void wxScrollBarCallback(Widget widget, XtPointer clientData,
|
||||
XmScaleCallbackStruct *cbs);
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScrollBar, wxControl)
|
||||
|
||||
#endif
|
||||
|
||||
// Scrollbar
|
||||
@@ -40,7 +49,50 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
// TODO create scrollbar
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
if (width == -1)
|
||||
{
|
||||
if (style & wxHORIZONTAL)
|
||||
width = 140;
|
||||
else
|
||||
width = 12;
|
||||
}
|
||||
if (height == -1)
|
||||
{
|
||||
if (style & wxVERTICAL)
|
||||
height = 140;
|
||||
else
|
||||
height = 12;
|
||||
}
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
int direction = (style & wxHORIZONTAL) ? XmHORIZONTAL: XmVERTICAL;
|
||||
|
||||
Widget scrollBarWidget = XtVaCreateManagedWidget("scrollBarWidget",
|
||||
xmScrollBarWidgetClass, parentWidget,
|
||||
XmNorientation, direction,
|
||||
NULL);
|
||||
|
||||
m_mainWidget = (Widget) scrollBarWidget;
|
||||
|
||||
// This will duplicate other events
|
||||
// XtAddCallback(scrollBarWidget, XmNvalueChangedCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNdragCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNdecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNincrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNpageDecrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNpageIncrementCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNtoTopCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
XtAddCallback(scrollBarWidget, XmNtoBottomCallback, (XtCallbackProc)wxScrollBarCallback, (XtPointer)this);
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
|
||||
ChangeColour(m_mainWidget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -48,14 +100,26 @@ wxScrollBar::~wxScrollBar()
|
||||
{
|
||||
}
|
||||
|
||||
void wxScrollBar::SetPosition(int viewStart)
|
||||
void wxScrollBar::SetPosition(int pos)
|
||||
{
|
||||
// TODO
|
||||
if (m_mainWidget)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNvalue, pos,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
int wxScrollBar::GetPosition() const
|
||||
{
|
||||
// TODO
|
||||
if (m_mainWidget)
|
||||
{
|
||||
int pos;
|
||||
XtVaGetValues((Widget) m_mainWidget,
|
||||
XmNvalue, &pos, NULL);
|
||||
return pos;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,9 +130,19 @@ void wxScrollBar::SetScrollbar(int position, int thumbSize, int range, int pageS
|
||||
m_pageSize = thumbSize;
|
||||
m_objectSize = range;
|
||||
|
||||
// TODO
|
||||
}
|
||||
if (range == 0)
|
||||
range = 1;
|
||||
if (thumbSize == 0)
|
||||
thumbSize = 1;
|
||||
|
||||
XtVaSetValues((Widget) m_mainWidget,
|
||||
XmNvalue, position,
|
||||
XmNminimum, 0,
|
||||
XmNmaximum, range,
|
||||
XmNsliderSize, thumbSize,
|
||||
XmNpageIncrement, pageSize,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void wxScrollBar::Command(wxCommandEvent& event)
|
||||
{
|
||||
@@ -76,3 +150,71 @@ void wxScrollBar::Command(wxCommandEvent& event)
|
||||
ProcessCommand(event);
|
||||
}
|
||||
|
||||
void wxScrollBarCallback(Widget widget, XtPointer clientData,
|
||||
XmScaleCallbackStruct *cbs)
|
||||
{
|
||||
wxScrollBar *scrollBar = (wxScrollBar *)clientData;
|
||||
|
||||
wxEventType eventType = wxEVT_NULL;
|
||||
switch (cbs->reason)
|
||||
{
|
||||
case XmCR_INCREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_LINEDOWN;
|
||||
break;
|
||||
}
|
||||
case XmCR_DECREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_LINEUP;
|
||||
break;
|
||||
}
|
||||
case XmCR_DRAG:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_THUMBTRACK;
|
||||
break;
|
||||
}
|
||||
case XmCR_VALUE_CHANGED:
|
||||
{
|
||||
// TODO: Should this be intercepted too, or will it cause
|
||||
// duplicate events?
|
||||
eventType = wxEVT_SCROLL_THUMBTRACK;
|
||||
break;
|
||||
}
|
||||
case XmCR_PAGE_INCREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_PAGEDOWN;
|
||||
break;
|
||||
}
|
||||
case XmCR_PAGE_DECREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_PAGEUP;
|
||||
break;
|
||||
}
|
||||
case XmCR_TO_TOP:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_TOP;
|
||||
break;
|
||||
}
|
||||
case XmCR_TO_BOTTOM:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_BOTTOM;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Should never get here
|
||||
wxFAIL_MSG("Unknown scroll event.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wxScrollEvent event(eventType, scrollBar->GetId());
|
||||
event.SetEventObject(scrollBar);
|
||||
event.SetPosition(cbs->value);
|
||||
scrollBar->GetEventHandler()->ProcessEvent(event);
|
||||
/*
|
||||
if (!scrollBar->inSetValue)
|
||||
scrollBar->ProcessCommand(event);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,14 @@
|
||||
#endif
|
||||
|
||||
#include "wx/statbox.h"
|
||||
#include "wx/utils.h"
|
||||
|
||||
#include <Xm/Frame.h>
|
||||
#include <Xm/Form.h>
|
||||
#include <Xm/Label.h>
|
||||
#include <Xm/LabelG.h>
|
||||
|
||||
#include <wx/motif/private.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
||||
@@ -28,6 +36,12 @@ END_EVENT_TABLE()
|
||||
* Static box
|
||||
*/
|
||||
|
||||
wxStaticBox::wxStaticBox()
|
||||
{
|
||||
m_formWidget = (WXWidget) 0;
|
||||
m_labelWidget = (WXWidget) 0;
|
||||
}
|
||||
|
||||
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos,
|
||||
@@ -35,6 +49,9 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
m_formWidget = (WXWidget) 0;
|
||||
m_labelWidget = (WXWidget) 0;
|
||||
|
||||
SetName(name);
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
@@ -46,17 +63,119 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
m_windowStyle = style;
|
||||
|
||||
// TODO: create static box
|
||||
return FALSE;
|
||||
bool hasLabel = (!label.IsNull() && !label.IsEmpty()) ;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
|
||||
xmFormWidgetClass, parentWidget,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
NULL);
|
||||
|
||||
|
||||
if (hasLabel)
|
||||
{
|
||||
wxString label1(wxStripMenuCodes(label));
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
|
||||
m_labelWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) label1,
|
||||
xmLabelWidgetClass, formWidget,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
}
|
||||
|
||||
Widget frameWidget = XtVaCreateManagedWidget ("frame",
|
||||
xmFrameWidgetClass, formWidget,
|
||||
XmNshadowType, XmSHADOW_IN,
|
||||
// XmNmarginHeight, 0,
|
||||
// XmNmarginWidth, 0,
|
||||
NULL);
|
||||
|
||||
if (hasLabel)
|
||||
XtVaSetValues ((Widget) m_labelWidget,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNalignment, XmALIGNMENT_BEGINNING,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues (frameWidget,
|
||||
XmNtopAttachment, hasLabel ? XmATTACH_WIDGET : XmATTACH_FORM,
|
||||
XmNtopWidget, hasLabel ? (Widget) m_labelWidget : formWidget,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
NULL);
|
||||
|
||||
m_mainWidget = (Widget) formWidget;
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) frameWidget, pos.x, pos.y, size.x, size.y);
|
||||
ChangeColour(m_mainWidget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxStaticBox::SetLabel(const wxString& label)
|
||||
{
|
||||
// TODO
|
||||
if (!m_labelWidget)
|
||||
return;
|
||||
|
||||
if (!label.IsNull())
|
||||
{
|
||||
wxString label1(wxStripMenuCodes(label));
|
||||
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
|
||||
XtVaSetValues ((Widget) m_labelWidget,
|
||||
XmNlabelString, text,
|
||||
XmNlabelType, XmSTRING,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxStaticBox::GetLabel() const
|
||||
{
|
||||
if (!m_labelWidget)
|
||||
return wxEmptyString;
|
||||
|
||||
XmString text = 0;
|
||||
char *s;
|
||||
XtVaGetValues ((Widget) m_labelWidget,
|
||||
XmNlabelString, &text,
|
||||
NULL);
|
||||
|
||||
if (!text)
|
||||
return wxEmptyString;
|
||||
|
||||
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
|
||||
{
|
||||
wxString str(s);
|
||||
XtFree (s);
|
||||
return str;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
}
|
||||
|
||||
void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
// TODO
|
||||
wxControl::SetSize (x, y, width, height, sizeFlags);
|
||||
|
||||
if (m_labelWidget)
|
||||
{
|
||||
Dimension xx, yy;
|
||||
XtVaGetValues ((Widget) m_labelWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
|
||||
|
||||
if (width > -1)
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width,
|
||||
NULL);
|
||||
if (height > -1)
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNheight, height - yy,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -36,8 +36,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
||||
SetName(name);
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
SetBackgroundColour(parent->GetDefaultBackgroundColour()) ;
|
||||
SetForegroundColour(parent->GetDefaultForegroundColour()) ;
|
||||
SetBackgroundColour(parent->GetBackgroundColour()) ;
|
||||
SetForegroundColour(parent->GetForegroundColour()) ;
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
|
@@ -290,7 +290,12 @@ WXDisplay *wxGetDisplay()
|
||||
if (gs_currentDisplay)
|
||||
return gs_currentDisplay;
|
||||
|
||||
if (wxTheApp && wxTheApp->GetTopLevelWidget())
|
||||
return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
|
||||
else if (wxTheApp)
|
||||
return wxTheApp->GetInitialDisplay();
|
||||
else
|
||||
return (WXDisplay*) NULL;
|
||||
}
|
||||
|
||||
bool wxSetDisplay(const wxString& display_name)
|
||||
|
@@ -52,6 +52,8 @@ void wxCanvasRepaintProc (Widget, XtPointer, XmDrawingAreaCallbackStruct * cbs);
|
||||
void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallbackStruct * cbs);
|
||||
void wxCanvasMotionEvent (Widget, XButtonEvent * event);
|
||||
void wxCanvasEnterLeave (Widget drawingArea, XtPointer clientData, XCrossingEvent * event);
|
||||
void wxScrollBarCallback(Widget widget, XtPointer clientData,
|
||||
XmScaleCallbackStruct *cbs);
|
||||
void wxPanelItemEventHandler (Widget wid,
|
||||
XtPointer client_data,
|
||||
XEvent* event,
|
||||
@@ -121,8 +123,6 @@ wxWindow::wxWindow()
|
||||
m_drawingArea = (WXWidget) 0;
|
||||
m_hScroll = FALSE;
|
||||
m_vScroll = FALSE;
|
||||
m_hScrollingEnabled = FALSE;
|
||||
m_vScrollingEnabled = FALSE;
|
||||
m_backingPixmap = (WXPixmap) 0;
|
||||
m_pixmapWidth = 0;
|
||||
m_pixmapHeight = 0;
|
||||
@@ -131,6 +131,8 @@ wxWindow::wxWindow()
|
||||
m_lastTS = 0;
|
||||
m_lastButton = 0;
|
||||
m_canAddEventHandler = FALSE;
|
||||
m_scrollPosX = 0;
|
||||
m_scrollPosY = 0;
|
||||
m_paintRegion = (WXRegion) 0;
|
||||
}
|
||||
|
||||
@@ -296,13 +298,13 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
m_drawingArea = (WXWidget) 0;
|
||||
m_hScroll = FALSE;
|
||||
m_vScroll = FALSE;
|
||||
m_hScrollingEnabled = FALSE;
|
||||
m_vScrollingEnabled = FALSE;
|
||||
m_backingPixmap = (WXPixmap) 0;
|
||||
m_pixmapWidth = 0;
|
||||
m_pixmapHeight = 0;
|
||||
m_pixmapOffsetX = 0;
|
||||
m_pixmapOffsetY = 0;
|
||||
m_scrollPosX = 0;
|
||||
m_scrollPosY = 0;
|
||||
m_paintRegion = (WXRegion) 0;
|
||||
|
||||
if (!parent)
|
||||
@@ -322,7 +324,6 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
|
||||
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ;
|
||||
m_foregroundColour = *wxBLACK;
|
||||
m_defaultForegroundColour = *wxBLACK ;
|
||||
|
||||
m_windowStyle = style;
|
||||
|
||||
@@ -418,6 +419,62 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
|
||||
False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
|
||||
|
||||
// Add scrollbars if required
|
||||
if (m_windowStyle & wxHSCROLL)
|
||||
{
|
||||
Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
|
||||
xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
NULL);
|
||||
// XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
|
||||
|
||||
XtVaSetValues (hScrollBar,
|
||||
XmNincrement, 1,
|
||||
XmNvalue, 0,
|
||||
NULL);
|
||||
|
||||
m_hScrollBar = (WXWidget) hScrollBar;
|
||||
m_hScroll = TRUE;
|
||||
}
|
||||
if (m_windowStyle & wxVSCROLL)
|
||||
{
|
||||
Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
|
||||
xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
|
||||
XmNorientation, XmVERTICAL,
|
||||
NULL);
|
||||
// XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
|
||||
|
||||
XtVaSetValues (vScrollBar,
|
||||
XmNincrement, 1,
|
||||
XmNvalue, 0,
|
||||
NULL);
|
||||
|
||||
m_vScrollBar = (WXWidget) vScrollBar;
|
||||
m_vScroll = TRUE;
|
||||
}
|
||||
|
||||
if (m_hScrollBar || m_vScrollBar)
|
||||
XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
|
||||
|
||||
if (m_hScrollBar)
|
||||
XtRealizeWidget ((Widget) m_hScrollBar);
|
||||
if (m_vScrollBar)
|
||||
XtRealizeWidget ((Widget) m_vScrollBar);
|
||||
|
||||
SetSize(pos.x, pos.y, size.x, size.y);
|
||||
|
||||
return TRUE;
|
||||
@@ -540,7 +597,15 @@ void wxWindow::GetPosition(int *x, int *y) const
|
||||
|
||||
void wxWindow::ScreenToClient(int *x, int *y) const
|
||||
{
|
||||
// TODO
|
||||
Widget widget = (Widget) GetClientWidget();
|
||||
Display *display = XtDisplay((Widget) GetMainWidget());
|
||||
Window rootWindow = RootWindowOfScreen(XtScreen(widget));
|
||||
Window thisWindow = XtWindow(widget);
|
||||
|
||||
Window childWindow;
|
||||
int xx = *x;
|
||||
int yy = *y;
|
||||
XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
|
||||
}
|
||||
|
||||
void wxWindow::ClientToScreen(int *x, int *y) const
|
||||
@@ -548,15 +613,7 @@ void wxWindow::ClientToScreen(int *x, int *y) const
|
||||
Widget widget = (Widget) GetClientWidget();
|
||||
Display *display = XtDisplay(widget);
|
||||
Window rootWindow = RootWindowOfScreen(XtScreen(widget));
|
||||
Window thisWindow;
|
||||
if (this->IsKindOf(CLASSINFO(wxFrame)))
|
||||
{
|
||||
wxFrame *fr = (wxFrame *)this;
|
||||
// TODO
|
||||
// thisWindow = XtWindow(fr->m_clientArea);
|
||||
}
|
||||
else
|
||||
thisWindow = XtWindow((Widget)widget);
|
||||
Window thisWindow = XtWindow(widget);
|
||||
|
||||
Window childWindow;
|
||||
int xx = *x;
|
||||
@@ -569,14 +626,12 @@ void wxWindow::SetCursor(const wxCursor& cursor)
|
||||
m_windowCursor = cursor;
|
||||
if (m_windowCursor.Ok())
|
||||
{
|
||||
/* TODO when wxCursor implemented
|
||||
WXDisplay *dpy = GetXDisplay();
|
||||
Cursor x_cursor = cursor.GetXCursor(dpy);
|
||||
WXCursor x_cursor = ((wxCursor&)cursor).GetXCursor(dpy);
|
||||
|
||||
Widget w = (Widget) GetMainWidget();
|
||||
Window win = XtWindow(w);
|
||||
XDefineCursor((Display*) dpy, win, x_cursor);
|
||||
*/
|
||||
XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,7 +639,7 @@ void wxWindow::SetCursor(const wxCursor& cursor)
|
||||
// Get size *available for subwindows* i.e. excluding menu bar etc.
|
||||
void wxWindow::GetClientSize(int *x, int *y) const
|
||||
{
|
||||
Widget widget = (Widget) GetTopWidget();
|
||||
Widget widget = (Widget) GetClientWidget();
|
||||
Dimension xx, yy;
|
||||
XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
|
||||
*x = xx; *y = yy;
|
||||
@@ -708,24 +763,77 @@ bool wxWindow::IsShown() const
|
||||
|
||||
int wxWindow::GetCharHeight() const
|
||||
{
|
||||
// TODO
|
||||
if (!m_windowFont.Ok())
|
||||
return 0;
|
||||
|
||||
WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
|
||||
|
||||
int direction, ascent, descent;
|
||||
XCharStruct overall;
|
||||
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
|
||||
&descent, &overall);
|
||||
// return (overall.ascent + overall.descent);
|
||||
return (ascent + descent);
|
||||
}
|
||||
|
||||
int wxWindow::GetCharWidth() const
|
||||
{
|
||||
// TODO
|
||||
if (!m_windowFont.Ok())
|
||||
return 0;
|
||||
|
||||
WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
|
||||
|
||||
int direction, ascent, descent;
|
||||
XCharStruct overall;
|
||||
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
|
||||
&descent, &overall);
|
||||
return overall.width;
|
||||
}
|
||||
|
||||
/* Helper function for 16-bit fonts */
|
||||
static int str16len(const char *s)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
while (s[0] && s[1]) {
|
||||
count++;
|
||||
s += 2;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
|
||||
int *descent, int *externalLeading, const wxFont *theFont, bool) const
|
||||
int *descent, int *externalLeading, const wxFont *theFont, bool use16) const
|
||||
{
|
||||
wxFont *fontToUse = (wxFont *)theFont;
|
||||
if (!fontToUse)
|
||||
fontToUse = (wxFont *) & m_windowFont;
|
||||
|
||||
// TODO
|
||||
if (!fontToUse->Ok())
|
||||
return;
|
||||
|
||||
WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
|
||||
|
||||
int direction, ascent, descent2;
|
||||
XCharStruct overall;
|
||||
int slen;
|
||||
|
||||
if (use16) slen = str16len(string); else slen = strlen(string);
|
||||
|
||||
if (use16)
|
||||
XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
|
||||
&ascent, &descent2, &overall);
|
||||
else
|
||||
XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
|
||||
&ascent, &descent2, &overall);
|
||||
|
||||
*x = (overall.width);
|
||||
*y = (ascent + descent2);
|
||||
if (descent)
|
||||
*descent = descent2;
|
||||
if (externalLeading)
|
||||
*externalLeading = 0;
|
||||
}
|
||||
|
||||
void wxWindow::Refresh(bool eraseBack, const wxRectangle *rect)
|
||||
@@ -859,21 +967,20 @@ void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, in
|
||||
return;
|
||||
|
||||
wxFrame *frame = (wxFrame *)this;
|
||||
Widget widget = (Widget) frame->GetShellWidget();
|
||||
|
||||
/* Uncomment when wxFrame implemented
|
||||
if (minW > -1)
|
||||
XtVaSetValues((Widget) frame->m_frameShell, XmNminWidth, minW, NULL);
|
||||
XtVaSetValues(widget, XmNminWidth, minW, NULL);
|
||||
if (minH > -1)
|
||||
XtVaSetValues((Widget) frame->m_frameShell, XmNminHeight, minH, NULL);
|
||||
XtVaSetValues(widget, XmNminHeight, minH, NULL);
|
||||
if (maxW > -1)
|
||||
XtVaSetValues((Widget) frame->m_frameShell, XmNmaxWidth, maxW, NULL);
|
||||
XtVaSetValues(widget, XmNmaxWidth, maxW, NULL);
|
||||
if (maxH > -1)
|
||||
XtVaSetValues((Widget) frame->m_frameShell, XmNmaxHeight, maxH, NULL);
|
||||
XtVaSetValues(widget, XmNmaxHeight, maxH, NULL);
|
||||
if (incW > -1)
|
||||
XtVaSetValues((Widget) frame->m_frameShell, XmNwidthInc, incW, NULL);
|
||||
XtVaSetValues(widget, XmNwidthInc, incW, NULL);
|
||||
if (incH > -1)
|
||||
XtVaSetValues((Widget) frame->m_frameShell, XmNheightInc, incH, NULL);
|
||||
*/
|
||||
XtVaSetValues(widget, XmNheightInc, incH, NULL);
|
||||
}
|
||||
|
||||
void wxWindow::Centre(int direction)
|
||||
@@ -915,49 +1022,252 @@ void wxWindow::OnEraseBackground(wxEraseEvent& event)
|
||||
|
||||
int wxWindow::GetScrollPos(int orient) const
|
||||
{
|
||||
// TODO
|
||||
if (orient == wxHORIZONTAL)
|
||||
return m_scrollPosX;
|
||||
else
|
||||
return m_scrollPosY;
|
||||
/*
|
||||
Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
|
||||
if (scrollBar)
|
||||
{
|
||||
int pos;
|
||||
XtVaGetValues(scrollBar,
|
||||
XmNvalue, &pos, NULL);
|
||||
return pos;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
// This now returns the whole range, not just the number
|
||||
// of positions that we can scroll.
|
||||
int wxWindow::GetScrollRange(int orient) const
|
||||
{
|
||||
// TODO
|
||||
Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
|
||||
if (scrollBar)
|
||||
{
|
||||
int range;
|
||||
XtVaGetValues(scrollBar,
|
||||
XmNmaximum, &range, NULL);
|
||||
return range;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int wxWindow::GetScrollThumb(int orient) const
|
||||
{
|
||||
// TODO
|
||||
Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
|
||||
if (scrollBar)
|
||||
{
|
||||
int thumb;
|
||||
XtVaGetValues(scrollBar,
|
||||
XmNsliderSize, &thumb, NULL);
|
||||
return thumb;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wxWindow::SetScrollPos(int orient, int pos, bool refresh)
|
||||
void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
|
||||
{
|
||||
// TODO
|
||||
return;
|
||||
Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
|
||||
if (scrollBar)
|
||||
{
|
||||
XtVaSetValues (scrollBar,
|
||||
XmNvalue, pos,
|
||||
NULL);
|
||||
}
|
||||
if (orient == wxHORIZONTAL)
|
||||
m_scrollPosX = pos;
|
||||
else
|
||||
m_scrollPosY = pos;
|
||||
|
||||
}
|
||||
|
||||
// New function that will replace some of the above.
|
||||
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
|
||||
int range, bool refresh)
|
||||
int range, bool WXUNUSED(refresh))
|
||||
{
|
||||
// TODO
|
||||
Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
|
||||
if (!scrollBar)
|
||||
return;
|
||||
|
||||
if (range == 0)
|
||||
range = 1;
|
||||
if (thumbVisible == 0)
|
||||
thumbVisible = 1;
|
||||
|
||||
XtVaSetValues(scrollBar,
|
||||
XmNvalue, pos,
|
||||
XmNminimum, 0,
|
||||
XmNmaximum, range,
|
||||
XmNsliderSize, thumbVisible,
|
||||
NULL);
|
||||
|
||||
if (orient == wxHORIZONTAL)
|
||||
m_scrollPosX = pos;
|
||||
else
|
||||
m_scrollPosY = pos;
|
||||
}
|
||||
|
||||
// Does a physical scroll
|
||||
void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect)
|
||||
{
|
||||
// TODO
|
||||
return;
|
||||
// cerr << "Scrolling. delta = " << dx << ", " << dy << endl;
|
||||
int x, y, w, h;
|
||||
if (rect)
|
||||
{
|
||||
// Use specified rectangle
|
||||
x = rect->x; y = rect->y; w = rect->width; h = rect->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use whole client area
|
||||
x = 0; y = 0;
|
||||
GetClientSize(& w, & h);
|
||||
}
|
||||
|
||||
int x1 = (dx >= 0) ? x : x - dx ;
|
||||
int y1 = (dy >= 0) ? y : y - dy;
|
||||
int w1 = w - abs(dx);
|
||||
int h1 = h - abs(dy);
|
||||
int x2 = (dx >= 0) ? x + dx : x;
|
||||
int y2 = (dy >= 0) ? y + dy : y;
|
||||
|
||||
wxClientDC dc(this);
|
||||
|
||||
dc.SetLogicalFunction (wxCOPY);
|
||||
|
||||
Widget widget = (Widget) GetMainWidget();
|
||||
Window window = XtWindow(widget);
|
||||
Display* display = XtDisplay(widget);
|
||||
|
||||
XCopyArea(display, window,
|
||||
window, (GC) dc.GetGC(),
|
||||
x1, y1,
|
||||
w1, h1,
|
||||
x2, y2);
|
||||
|
||||
dc.SetAutoSetting(TRUE);
|
||||
wxBrush brush(GetBackgroundColour(), wxSOLID);
|
||||
dc.SetBrush(brush); // ??
|
||||
|
||||
// We'll add rectangles to the list of update rectangles
|
||||
// according to which bits we've exposed.
|
||||
wxList updateRects;
|
||||
|
||||
if (dx > 0)
|
||||
{
|
||||
wxRect *rect = new wxRect;
|
||||
rect->x = x;
|
||||
rect->y = y;
|
||||
rect->width = dx;
|
||||
rect->height = h;
|
||||
|
||||
XFillRectangle(display, window,
|
||||
(GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
rect->x = rect->x;
|
||||
rect->y = rect->y;
|
||||
rect->width = rect->width;
|
||||
rect->height = rect->height;
|
||||
|
||||
updateRects.Append((wxObject*) rect);
|
||||
}
|
||||
else if (dx < 0)
|
||||
{
|
||||
wxRect *rect = new wxRect;
|
||||
|
||||
rect->x = x + w + dx;
|
||||
rect->y = y;
|
||||
rect->width = -dx;
|
||||
rect->height = h;
|
||||
|
||||
XFillRectangle(display, window,
|
||||
(GC) dc.GetGC(), rect->x, rect->y, rect->width,
|
||||
rect->height);
|
||||
|
||||
rect->x = rect->x;
|
||||
rect->y = rect->y;
|
||||
rect->width = rect->width;
|
||||
rect->height = rect->height;
|
||||
|
||||
updateRects.Append((wxObject*) rect);
|
||||
}
|
||||
if (dy > 0)
|
||||
{
|
||||
wxRect *rect = new wxRect;
|
||||
|
||||
rect->x = x;
|
||||
rect->y = y;
|
||||
rect->width = w;
|
||||
rect->height = dy;
|
||||
|
||||
XFillRectangle(display, window,
|
||||
(GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
rect->x = rect->x;
|
||||
rect->y = rect->y;
|
||||
rect->width = rect->width;
|
||||
rect->height = rect->height;
|
||||
|
||||
updateRects.Append((wxObject*) rect);
|
||||
}
|
||||
else if (dy < 0)
|
||||
{
|
||||
wxRect *rect = new wxRect;
|
||||
|
||||
rect->x = x;
|
||||
rect->y = y + h + dy;
|
||||
rect->width = w;
|
||||
rect->height = -dy;
|
||||
|
||||
XFillRectangle(display, window,
|
||||
(GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
rect->x = rect->x;
|
||||
rect->y = rect->y;
|
||||
rect->width = rect->width;
|
||||
rect->height = rect->height;
|
||||
|
||||
updateRects.Append((wxObject*) rect);
|
||||
}
|
||||
dc.SetBrush(wxNullBrush);
|
||||
|
||||
// Now send expose events
|
||||
|
||||
wxNode* node = updateRects.First();
|
||||
while (node)
|
||||
{
|
||||
wxRect* rect = (wxRect*) node->Data();
|
||||
XExposeEvent event;
|
||||
|
||||
event.type = Expose;
|
||||
event.display = display;
|
||||
event.send_event = True;
|
||||
event.window = window;
|
||||
|
||||
event.x = rect->x;
|
||||
event.y = rect->y;
|
||||
event.width = rect->width;
|
||||
event.height = rect->height;
|
||||
|
||||
event.count = 0;
|
||||
|
||||
XSendEvent(display, window, False, ExposureMask, (XEvent *)&event);
|
||||
|
||||
node = node->Next();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindow::SetFont(const wxFont& font)
|
||||
{
|
||||
m_windowFont = font;
|
||||
|
||||
Widget w = (Widget) GetMainWidget();
|
||||
Widget w = (Widget) GetLabelWidget(); // Usually the main widget
|
||||
if (w && m_windowFont.Ok())
|
||||
{
|
||||
XtVaSetValues (w,
|
||||
@@ -985,7 +1295,8 @@ void wxWindow::OnPaint(wxPaintEvent& event)
|
||||
|
||||
bool wxWindow::IsEnabled() const
|
||||
{
|
||||
// TODO
|
||||
// TODO. Is this right?
|
||||
// return XtGetSensitive((Widget) GetMainWidget());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2420,6 +2731,74 @@ void wxPanelItemEventHandler (Widget wid,
|
||||
*continueToDispatch = True;
|
||||
}
|
||||
|
||||
void wxScrollBarCallback(Widget scrollbar, XtPointer clientData,
|
||||
XmScaleCallbackStruct *cbs)
|
||||
{
|
||||
Widget scrolledWindow = XtParent (scrollbar);
|
||||
wxWindow *win = (wxWindow *) wxWidgetHashTable->Get ((long) scrolledWindow);
|
||||
int orientation = (int) clientData;
|
||||
|
||||
wxEventType eventType = wxEVT_NULL;
|
||||
switch (cbs->reason)
|
||||
{
|
||||
case XmCR_INCREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_LINEDOWN;
|
||||
break;
|
||||
}
|
||||
case XmCR_DECREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_LINEUP;
|
||||
break;
|
||||
}
|
||||
case XmCR_DRAG:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_THUMBTRACK;
|
||||
break;
|
||||
}
|
||||
case XmCR_VALUE_CHANGED:
|
||||
{
|
||||
// TODO: Should this be intercepted too, or will it cause
|
||||
// duplicate events?
|
||||
eventType = wxEVT_SCROLL_THUMBTRACK;
|
||||
break;
|
||||
}
|
||||
case XmCR_PAGE_INCREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_PAGEDOWN;
|
||||
break;
|
||||
}
|
||||
case XmCR_PAGE_DECREMENT:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_PAGEUP;
|
||||
break;
|
||||
}
|
||||
case XmCR_TO_TOP:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_TOP;
|
||||
break;
|
||||
}
|
||||
case XmCR_TO_BOTTOM:
|
||||
{
|
||||
eventType = wxEVT_SCROLL_BOTTOM;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
// Should never get here
|
||||
wxFAIL_MSG("Unknown scroll event.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wxScrollEvent event(eventType, win->GetId());
|
||||
event.SetEventObject(win);
|
||||
event.SetPosition(cbs->value);
|
||||
event.SetOrientation( (orientation == XmHORIZONTAL) ? wxHORIZONTAL : wxVERTICAL );
|
||||
|
||||
win->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent)
|
||||
{
|
||||
switch (xevent->xany.type)
|
||||
@@ -2670,10 +3049,12 @@ void wxWindow::ChangeColour(WXWidget widget)
|
||||
|
||||
void wxWindow::ChangeFont(WXWidget widget)
|
||||
{
|
||||
/* TODO
|
||||
if (widget && GetFont() && GetFont()->IsOk())
|
||||
if (widget && GetFont() && GetFont()->Ok())
|
||||
{
|
||||
XmFontList fontList = (XmFontList) GetFont()->GetFontList(1.0, GetXDisplay());
|
||||
if (fontList)
|
||||
XtVaSetValues ((Widget) widget,
|
||||
XmNfontList, GetFont()->GetInternalFont (),
|
||||
XmNfontList, fontList,
|
||||
NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
@@ -400,8 +400,9 @@ void wxMenu::SetLabel(int Id, const wxString& label)
|
||||
item->SetName(label);
|
||||
}
|
||||
|
||||
wxString wxMenu::GetLabel(int Id) const
|
||||
wxString wxMenu::GetLabel(int id) const
|
||||
{
|
||||
/*
|
||||
static char tmp[128] ;
|
||||
int len;
|
||||
if (m_hMenu)
|
||||
@@ -412,6 +413,13 @@ wxString wxMenu::GetLabel(int Id) const
|
||||
len = 0 ;
|
||||
tmp[len] = '\0' ;
|
||||
return wxString(tmp) ;
|
||||
|
||||
*/
|
||||
wxMenuItem *pItem = FindItemForId(id) ;
|
||||
if (pItem)
|
||||
return pItem->GetName() ;
|
||||
else
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id)
|
||||
|
Reference in New Issue
Block a user