More Motif stuff incl. beginnings of wxToolBar

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-10-21 21:43:20 +00:00
parent b0f1bdde5a
commit 0d57be4594
77 changed files with 982 additions and 234 deletions

View File

@@ -302,7 +302,7 @@ int wxApp::MainLoop()
XtDispatchEvent(&event);
DeletePendingObjects();
ProcessIdle();
}
}

View File

@@ -619,8 +619,17 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla
M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask);
}
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
Window rootWindowRet;
XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
&widthRet, &heightRet, &borderWidthRet, &depthRet);
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
/*
if ( xpmAttr.npixels > 2 )
{
M_BITMAPHANDLERDATA->m_depth = 8; // TODO: next time not just a guess :-) ...
@@ -628,6 +637,9 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla
{
M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
*/
M_BITMAPHANDLERDATA->m_depth = depthRet;
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
@@ -714,6 +726,15 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt
// Set attributes
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
Window rootWindowRet;
XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
&widthRet, &heightRet, &borderWidthRet, &depthRet);
/*
if ( xpmAttr.npixels > 2 )
{
M_BITMAPHANDLERDATA->m_depth = 8; // next time not just a guess :-) ...
@@ -721,6 +742,10 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt
{
M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
*/
M_BITMAPHANDLERDATA->m_depth = depthRet;
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
@@ -846,6 +871,18 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
{
Display *dpy = (Display*) M_BITMAPDATA->m_display;
if (M_BITMAPDATA->m_insensPixmap)
return M_BITMAPDATA->m_insensPixmap;
if (!w)
{
M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap);
if (M_BITMAPDATA->m_insensPixmap)
return M_BITMAPDATA->m_insensPixmap;
else
return M_BITMAPDATA->m_pixmap;
}
if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;

View File

@@ -116,7 +116,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
SetFont(* parent->GetFont());
ChangeColour (m_mainWidget);
ChangeBackgroundColour ();
return TRUE;

View File

@@ -38,6 +38,8 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
SetName(name);
SetValidator(validator);
m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
parent->AddChild((wxButton *)this);
@@ -77,7 +79,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -132,3 +134,19 @@ void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr)
event.SetEventObject(item);
item->ProcessCommand (event);
}
void wxButton::ChangeFont()
{
// TODO
}
void wxButton::ChangeBackgroundColour()
{
// TODO
}
void wxButton::ChangeForegroundColour()
{
// TODO
}

View File

@@ -40,6 +40,8 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
SetName(name);
SetValidator(validator);
m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
@@ -67,7 +69,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
SetFont(* parent->GetFont());
return TRUE;
@@ -148,3 +150,19 @@ void wxCheckBoxCallback (Widget w, XtPointer clientData,
event.SetEventObject(item);
item->ProcessCommand (event);
}
void wxCheckBox::ChangeFont()
{
// TODO
}
void wxCheckBox::ChangeBackgroundColour()
{
// TODO
}
void wxCheckBox::ChangeForegroundColour()
{
// TODO
}

View File

@@ -64,6 +64,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
else
m_windowId = id;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
Widget parentWidget = (Widget) parent->GetClientWidget();
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
@@ -125,7 +128,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -415,3 +418,18 @@ void wxChoiceCallback (Widget w, XtPointer clientData,
}
}
void wxChoice::ChangeFont()
{
// TODO
}
void wxChoice::ChangeBackgroundColour()
{
// TODO
}
void wxChoice::ChangeForegroundColour()
{
// TODO
}

View File

@@ -40,6 +40,8 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
SetValidator(validator);
m_noStrings = n;
m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
@@ -85,7 +87,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -205,5 +207,20 @@ void wxComboBoxCallback (Widget w, XtPointer clientData,
}
}
void wxComboBox::ChangeFont()
{
// TODO
}
void wxComboBox::ChangeBackgroundColour()
{
// TODO
}
void wxComboBox::ChangeForegroundColour()
{
// TODO
}
#endif

View File

@@ -1855,7 +1855,9 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
// XSetWindowBackground doesn't work for non-Window pixmaps
if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
// And Blit,... (Any fct that use XCopyPlane, in fact.)

View File

@@ -80,7 +80,7 @@ END_EVENT_TABLE()
wxDialog::wxDialog()
{
m_modalShowing = FALSE;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
}
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
@@ -94,7 +94,9 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
m_modalShowing = FALSE;
m_dialogTitle = title;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = *wxBLACK;
SetName(name);
if (!parent)
@@ -233,6 +235,8 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
wxDialogBoxEventHandler,
(XtPointer)this);
ChangeBackgroundColour();
return TRUE;
}
@@ -739,3 +743,19 @@ static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call)
client->m_isShown = FALSE;
*/
}
void wxDialog::ChangeFont()
{
// TODO
}
void wxDialog::ChangeBackgroundColour()
{
// TODO
}
void wxDialog::ChangeForegroundColour()
{
// TODO
}

View File

@@ -126,7 +126,8 @@ bool wxFrame::Create(wxWindow *parent,
m_visibleStatus = TRUE;
m_title = "";
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK;
if ( id > -1 )
m_windowId = id;
@@ -264,6 +265,8 @@ bool wxFrame::Create(wxWindow *parent,
#endif
#endif
ChangeBackgroundColour();
PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
@@ -1037,6 +1040,21 @@ WXWidget wxFrame::GetClientWidget() const
return m_clientArea;
}
void wxFrame::ChangeFont()
{
// TODO
}
void wxFrame::ChangeBackgroundColour()
{
// TODO
}
void wxFrame::ChangeForegroundColour()
{
// TODO
}
void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs)
{
wxFrame *frame = (wxFrame *)client_data;
@@ -1047,3 +1065,4 @@ void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStr
// May delete the frame (with delayed deletion)
frame->GetEventHandler()->ProcessEvent(closeEvent);
}

View File

@@ -85,6 +85,8 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
SetValidator(validator);
m_rangeMax = range;
m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
@@ -125,7 +127,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -186,6 +188,21 @@ int wxGauge::GetValue() const
// return m_gaugePos;
}
void wxGauge::ChangeFont()
{
// TODO
}
void wxGauge::ChangeBackgroundColour()
{
// TODO
}
void wxGauge::ChangeForegroundColour()
{
// TODO
}
//// PRIVATE DECLARATIONS FOR XMGAUGE
#include <Xm/PrimitiveP.h>

View File

@@ -53,6 +53,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style;
m_noItems = n;
m_selected = 0;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetValidator(validator);
@@ -107,11 +109,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
wxSystemSettings settings;
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -739,3 +740,19 @@ WXWidget wxListBox::GetTopWidget() const
{
return (WXWidget) XtParent( (Widget) m_mainWidget );
}
void wxListBox::ChangeFont()
{
// TODO
}
void wxListBox::ChangeBackgroundColour()
{
// TODO
}
void wxListBox::ChangeForegroundColour()
{
// TODO
}

View File

@@ -127,6 +127,7 @@ LIB_CPP_SRC=\
textctrl.cpp \
thread.cpp \
timer.cpp \
toolbar.cpp \
utils.cpp \
utilsexc.cpp \
wave.cpp \
@@ -157,7 +158,6 @@ LIB_CPP_SRC=\
# listctrl.cpp \
# imaglist.cpp \
# statusbr.cpp \
# toolbar.cpp \
LIB_C_SRC=\
\

View File

@@ -88,7 +88,7 @@ public:
// Generate wxSizeEvent here, I think. Maybe also restore, maximize
// Probably don't need to generate size event here since work area
// is used
// is used (???)
wxSizeEvent event(wxSize(w, h), m_childFrame->GetId());
event.SetEventObject(m_childFrame);
m_childFrame->ProcessEvent(event);
@@ -98,6 +98,16 @@ public:
XsMotifWindow::close();
m_childFrame->Close();
}
virtual void raise()
{
XsMotifWindow::raise();
m_childFrame->OnRaise();
}
virtual void lower()
{
XsMotifWindow::lower();
m_childFrame->OnLower();
}
virtual void _buildClientArea(Widget parent)
{
m_childFrame->BuildClientArea((WXWidget) parent);
@@ -204,7 +214,8 @@ public:
wxMDIParentFrame::wxMDIParentFrame()
{
m_clientWindow = NULL;
m_clientWindow = (wxMDIClientWindow*) NULL;
m_activeChild = (wxMDIChildFrame*) NULL;
}
bool wxMDIParentFrame::Create(wxWindow *parent,
@@ -215,7 +226,8 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
long style,
const wxString& name)
{
m_clientWindow = NULL;
m_clientWindow = (wxMDIClientWindow*) NULL;
m_activeChild = (wxMDIChildFrame*) NULL;
bool success = wxFrame::Create(parent, id, title, pos, size, style, name);
if (success)
@@ -273,8 +285,7 @@ void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
// Returns the active MDI child window
wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
{
// TODO
return NULL;
return m_activeChild;
}
// Create the client window class (don't Create the window,
@@ -344,14 +355,32 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
if (width == -1)
width = 200; // TODO: give reasonable default
if (height == -1)
height = 200; // TODO: give reasonable default
wxMDIClientWindow* clientWindow = parent->GetClientWindow();
if (!clientWindow)
return FALSE;
// We're deactivating the old child
wxMDIChildFrame* oldActiveChild = parent->GetActiveChild();
if (oldActiveChild)
{
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event);
}
m_mdiWindow = new wxXsMDIWindow("mdiChildWindow", this);
clientWindow->GetMDICanvas()->add(m_mdiWindow);
// This is the currently active child
parent->SetActiveChild((wxMDIChildFrame*) this);
m_mdiWindow->Show();
#if 0
m_mainWidget = (WXWidget) (Widget) (*m_mdiWindow);
@@ -411,10 +440,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
m_mdiWindow->setSize(width, height);
wxModelessWindows.Append(this);
return TRUE;
@@ -490,11 +516,50 @@ void wxMDIChildFrame::BuildClientArea(WXWidget parent)
wxMDIChildFrame::~wxMDIChildFrame()
{
wxMDIClientWindow* clientWindow = ((wxMDIParentFrame*)GetParent())->GetClientWindow();
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
if (parentFrame->GetActiveChild() == this)
parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
clientWindow->GetMDICanvas()->remove(m_mdiWindow);
m_mainWidget = (WXWidget) 0;
}
// Implementation: intercept and act upon raise and lower commands.
void wxMDIChildFrame::OnRaise()
{
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
parentFrame->SetActiveChild(this);
if (oldActiveChild)
{
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event);
}
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
event.SetEventObject( this );
this->GetEventHandler()->ProcessEvent(event);
}
void wxMDIChildFrame::OnLower()
{
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
if (oldActiveChild == this)
{
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event);
}
// TODO: unfortunately we don't now know which is the top-most child,
// so make the active child NULL.
parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
}
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxMDIChildFrame::SetClientSize(int width, int height)

View File

@@ -1,4 +1,4 @@
Copyright (c) 1996 Scott W. Sadler
Copyright (c) 1996, 1998 Scott W. Sadler
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -21,9 +21,8 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization.
Scott W. Sadler
Software Engineer
International TechneGroup Incorporated
5303 DuPont Circle
Milford, OH 45150
sws@iti-oh.com
http://www.iti-oh.com/~sws
Cisco Systems
7025 Kit Creek Road
P.O. Box 14987
Research Triangle Park NC, 27709
ssadler@cisco.com

View File

@@ -37,6 +37,13 @@ CC = $(CXX)
#define FOUND_COMPILER
#endif
#ifdef i386SVR4Architecture
CXX = CC
CC = $(CXX)
CCOPTIONS=
#define COMPILER_FOUND
#endif
#ifndef FOUND_COMPILER
CXX = gcc
CC = $(CXX)

View File

@@ -2,7 +2,7 @@
<HEAD>
<TITLE>XsMDICanvas Class</TITLE>
<LINK REV="made" HREF="mailto:sws@iti-oh.com">
<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>
<H2>

View File

@@ -2,7 +2,7 @@
<HEAD>
<TITLE>Motif Multi-Document Interface (MDI)</TITLE>
<LINK REV="made" HREF="mailto:sws@iti-oh.com">
<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>
<CENTER>

View File

@@ -2,7 +2,7 @@
<HEAD>
<TITLE>XsMotifWindow Class</TITLE>
<LINK REV="made" HREF="mailto:sws@iti-oh.com">
<LINK REV="made" HREF="mailto:ssadler@cisco.com">
</HEAD>
<H2>

View File

@@ -7,7 +7,7 @@
XsComponent.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
@@ -62,8 +62,8 @@ void XsComponent::show ( )
{
#ifndef NDEBUG
if (XtIsManaged (_base))
cout << "Re-managing a widget:" << _name << endl;
// if (XtIsManaged (_base))
// cout << "Re-managing a widget:" << _name << endl;
#endif
// Make sure the _destroyHandler was installed
@@ -80,8 +80,8 @@ void XsComponent::hide ( )
{
#ifndef NDEBUG
if (!XtIsManaged (_base))
cout << "Re-unmanaging a widget:" << _name << endl;
// if (!XtIsManaged (_base))
// cout << "Re-unmanaging a widget:" << _name << endl;
#endif
assert (_base != 0);

View File

@@ -7,7 +7,7 @@
XsComponent.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
@@ -33,9 +33,6 @@ class XsComponent {
virtual void show ( ); // Show the component
virtual void hide ( ); // Hide the component
// Added JACS 19/10/98
inline Widget GetBase() const { return _base; }
// Component name
const char *name ( ) const;

View File

@@ -7,7 +7,7 @@
XsMDICanvas.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsMDICanvas.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
@@ -38,13 +38,11 @@ class XsMDICanvas : public XsComponent {
virtual void add (XsMDIWindow *win); // Add an MDI window
virtual void remove (XsMDIWindow *win); // Remove an MDI window
void removeAll ( ); // Remove all MDI windows
// Added JACS 19/10/98
inline Widget GetDrawingArea() const { return _drawArea; }
// Utilities
int numWindows ( ) const; // Number of MDI windows
Widget GetDrawingArea() const { return _drawArea; }
// Component methods

View File

@@ -7,7 +7,7 @@
XsMDIWindow.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsMDIWindow.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsMotifWindow.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/
@@ -2880,12 +2880,6 @@ void XsMotifWindow::restore ( )
setPosition (_savedX, _savedY);
setSize (_savedWidth, _savedHeight);
_maximized = False;
// Redraw the maximize button
_buttons[_XsMotifButton::Maximize]->redraw ( );
}
}
@@ -2972,6 +2966,17 @@ void XsMotifWindow::setSize (Dimension w, Dimension h)
if (_minimized == False)
XtVaSetValues (_base, XmNwidth, w, XmNheight, h, NULL);
// If window was maximized, change the window state back to normal
if (_maximized == True)
{
_maximized = False;
// Redraw the maximize button
_buttons[_XsMotifButton::Maximize]->redraw ( );
}
}
else
XsMDIWindow::setSize (w, h); // Cache the points

View File

@@ -7,7 +7,7 @@
XsMotifWindow.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsMoveOutline.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsMoveOutline.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsOutline.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsOutline.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsResizeOutline.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
XsResizeOutline.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -7,7 +7,7 @@
xs_motif_icon.xbm
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
03-Mar-96 1.0; Scott W. Sadler (ssadler@cisco.com)
Created
*/

View File

@@ -365,3 +365,18 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
m_nSelection = nSel;
}
void wxNotebook::ChangeFont()
{
// TODO
}
void wxNotebook::ChangeBackgroundColour()
{
// TODO
}
void wxNotebook::ChangeForegroundColour()
{
// TODO
}

View File

@@ -57,6 +57,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
m_labelWidget = (WXWidget) 0;
m_radioButtons = (WXWidget*) NULL;
m_radioButtonLabels = (wxString*) NULL;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetValidator(val);
@@ -176,7 +178,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -389,6 +391,21 @@ void wxRadioBox::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxRadioBox::ChangeFont()
{
// TODO
}
void wxRadioBox::ChangeBackgroundColour()
{
// TODO
}
void wxRadioBox::ChangeForegroundColour()
{
// TODO
}
void wxRadioBoxCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs)
{

View File

@@ -47,6 +47,8 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
{
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
@@ -130,7 +132,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -154,6 +156,21 @@ void wxRadioButton::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxRadioButton::ChangeFont()
{
// TODO
}
void wxRadioButton::ChangeBackgroundColour()
{
// TODO
}
void wxRadioButton::ChangeForegroundColour()
{
// TODO
}
void wxRadioButtonCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs)
{

View File

@@ -40,7 +40,9 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
return FALSE;
parent->AddChild(this);
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
SetValidator(validator);
m_windowStyle = style;
@@ -91,7 +93,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -150,6 +152,21 @@ void wxScrollBar::Command(wxCommandEvent& event)
ProcessCommand(event);
}
void wxScrollBar::ChangeFont()
{
// TODO
}
void wxScrollBar::ChangeBackgroundColour()
{
// TODO
}
void wxScrollBar::ChangeForegroundColour()
{
// TODO
}
void wxScrollBarCallback(Widget widget, XtPointer clientData,
XmScaleCallbackStruct *cbs)
{

View File

@@ -54,6 +54,8 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
{
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
@@ -101,7 +103,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -245,6 +247,21 @@ void wxSlider::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxSlider::ChangeFont()
{
// TODO
}
void wxSlider::ChangeBackgroundColour()
{
// TODO
}
void wxSlider::ChangeForegroundColour()
{
// TODO
}
void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs)
{
wxSlider *slider = (wxSlider *) clientData;

View File

@@ -68,6 +68,21 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
// TODO
}
void wxSpinButton::ChangeFont()
{
// TODO
}
void wxSpinButton::ChangeBackgroundColour()
{
// TODO
}
void wxSpinButton::ChangeForegroundColour()
{
// TODO
}
// Spin event
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)

View File

@@ -39,6 +39,8 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
{
m_messageBitmap = bitmap;
SetName(name);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
if ( id == -1 )
@@ -69,7 +71,7 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
SetFont(* parent->GetFont());
ChangeColour (m_mainWidget);
ChangeBackgroundColour ();
return TRUE;
}
@@ -117,3 +119,18 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
}
}
void wxStaticBitmap::ChangeFont()
{
// TODO
}
void wxStaticBitmap::ChangeBackgroundColour()
{
// TODO
}
void wxStaticBitmap::ChangeForegroundColour()
{
// TODO
}

View File

@@ -51,6 +51,8 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
{
m_formWidget = (WXWidget) 0;
m_labelWidget = (WXWidget) 0;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
SetName(name);
@@ -112,7 +114,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) frameWidget, pos.x, pos.y, size.x, size.y);
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -179,3 +181,18 @@ void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags)
}
}
void wxStaticBox::ChangeFont()
{
// TODO
}
void wxStaticBox::ChangeBackgroundColour()
{
// TODO
}
void wxStaticBox::ChangeForegroundColour()
{
// TODO
}

View File

@@ -36,8 +36,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
SetName(name);
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour()) ;
SetForegroundColour(parent->GetForegroundColour()) ;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if ( id == -1 )
m_windowId = (int)NewControlId();
@@ -69,8 +69,23 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
SetFont(* parent->GetFont());
ChangeColour (m_mainWidget);
ChangeBackgroundColour ();
return TRUE;
}
void wxStaticText::ChangeFont()
{
// TODO
}
void wxStaticText::ChangeBackgroundColour()
{
// TODO
}
void wxStaticText::ChangeForegroundColour()
{
// TODO
}

View File

@@ -80,6 +80,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
m_modified = FALSE;
m_processedDefault = FALSE;
m_fileName = "";
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
SetName(name);
SetValidator(validator);
@@ -145,7 +147,7 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
ChangeBackgroundColour();
return TRUE;
}
@@ -617,6 +619,21 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
}
}
void wxTextCtrl::ChangeFont()
{
// TODO
}
void wxTextCtrl::ChangeBackgroundColour()
{
// TODO
}
void wxTextCtrl::ChangeForegroundColour()
{
// TODO
}
static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr)
{
if (!wxGetWindowFromTable(w))

View File

@@ -14,13 +14,39 @@
#endif
#include "wx/timer.h"
#include "wx/app.h"
#include "wx/list.h"
#include <Xm/Xm.h>
#include "wx/motif/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif
static wxList wxTimerList(wxKEY_INTEGER);
void wxTimerCallback (wxTimer * timer)
{
// Check to see if it's still on
if (!wxTimerList.Find((long)timer))
return;
if (timer->m_id == 0)
return; // Avoid to process spurious timer events
if (!timer->m_oneShot)
timer->m_id = XtAppAddTimeOut ((XtAppContext) wxTheApp->GetAppContext(), timer->m_milli,
(XtTimerCallbackProc) wxTimerCallback, (XtPointer) timer);
else
timer->m_id = 0;
timer->Notify ();
}
wxTimer::wxTimer()
{
m_id = 0;
m_milli = 0 ;
m_id = 0;
m_oneShot = FALSE;
@@ -31,21 +57,34 @@ wxTimer::~wxTimer()
Stop();
}
bool wxTimer::Start(int milliseconds,bool mode)
bool wxTimer::Start(int milliseconds, bool mode)
{
m_oneShot = mode ;
Stop();
m_oneShot = mode;
if (milliseconds < 0)
milliseconds = m_lastMilli;
if (milliseconds <= 0)
return FALSE;
m_milli = milliseconds;
m_lastMilli = m_milli = milliseconds;
// TODO: set the timer going.
return FALSE;
if (!wxTimerList.Find((long)this))
wxTimerList.Append((long)this, this);
m_id = XtAppAddTimeOut ((XtAppContext) wxTheApp->GetAppContext(), milliseconds,
(XtTimerCallbackProc) wxTimerCallback, (XtPointer) this);
return TRUE;
}
void wxTimer::Stop()
{
m_id = 0 ;
if (m_id > 0)
{
XtRemoveTimeOut (m_id);
m_id = 0;
}
m_milli = 0 ;
}

View File

@@ -14,7 +14,16 @@
#endif
#include "wx/wx.h"
#include "wx/toolbar.h"
#include "wx/motif/toolbar.h"
#include <Xm/Xm.h>
#include <Xm/PushBG.h>
#include <Xm/PushB.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include <Xm/Form.h>
#include "wx/motif/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
@@ -23,7 +32,8 @@ BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
END_EVENT_TABLE()
#endif
wxToolBar::wxToolBar()
wxToolBar::wxToolBar():
m_widgets(wxKEY_INTEGER)
{
m_maxWidth = -1;
m_maxHeight = -1;
@@ -41,16 +51,32 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
m_defaultWidth = 24;
m_defaultHeight = 22;
SetName(name);
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = parent->GetForegroundColour();
m_windowStyle = style;
SetParent(parent);
if (parent) parent->AddChild(this);
// TODO create toolbar
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget toolbar = XtVaCreateManagedWidget("toolbar",
xmFormWidgetClass, parentWidget,
XmNtraversalOn, False,
XmNhorizontalSpacing, 0,
XmNverticalSpacing, 0,
NULL);
m_mainWidget = (WXWidget) toolbar;
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return FALSE;
return TRUE;
}
wxToolBar::~wxToolBar()
@@ -63,8 +89,150 @@ bool wxToolBar::CreateTools()
if (m_tools.Number() == 0)
return FALSE;
// TODO
return FALSE;
m_widgets.Clear();
Widget prevButton = (Widget) 0;
wxNode* node = m_tools.First();
while (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok())
{
Widget button = (Widget) 0;
if (tool->m_isToggle)
{
button = XtVaCreateManagedWidget("toggleButton",
xmToggleButtonWidgetClass, (Widget) m_mainWidget,
XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET,
XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton,
XmNleftOffset, 0,
XmNtopAttachment, XmATTACH_FORM,
// XmNpushButtonEnabled, True,
XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP,
NULL);
}
else
{
button = XtVaCreateManagedWidget("button",
xmPushButtonWidgetClass, (Widget) m_mainWidget,
XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET,
XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton,
XmNleftOffset, 0,
XmNtopAttachment, XmATTACH_FORM,
XmNpushButtonEnabled, True,
XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP,
NULL);
}
// For each button, if there is a mask, we must create
// a new wxBitmap that has the correct background colour
// for the button. Otherwise the background will just be
// e.g. black if a transparent XPM has been loaded.
if (tool->m_bitmap1.GetMask())
{
wxBitmap newBitmap(tool->m_bitmap1.GetWidth(),
tool->m_bitmap1.GetHeight(),
tool->m_bitmap1.GetDepth());
int backgroundPixel;
XtVaGetValues(button, XmNbackground, &backgroundPixel,
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
wxMemoryDC destDC;
wxMemoryDC srcDC;
srcDC.SelectObject(tool->m_bitmap1);
destDC.SelectObject(newBitmap);
wxBrush brush(col, wxSOLID);
destDC.SetOptimization(FALSE);
destDC.SetBackground(brush);
destDC.Clear();
destDC.Blit(0, 0, tool->m_bitmap1.GetWidth(), tool->m_bitmap1.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
tool->m_bitmap1 = newBitmap;
}
if (tool->m_bitmap2.Ok() && tool->m_bitmap2.GetMask())
{
wxBitmap newBitmap(tool->m_bitmap2.GetWidth(),
tool->m_bitmap2.GetHeight(),
tool->m_bitmap2.GetDepth());
int backgroundPixel;
XtVaGetValues(button, XmNbackground, &backgroundPixel,
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
wxMemoryDC destDC;
wxMemoryDC srcDC;
srcDC.SelectObject(tool->m_bitmap2);
destDC.SelectObject(newBitmap);
wxBrush brush(col, wxSOLID);
destDC.SetOptimization(FALSE);
destDC.SetBackground(brush);
destDC.Clear();
destDC.Blit(0, 0, tool->m_bitmap2.GetWidth(), tool->m_bitmap2.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
tool->m_bitmap2 = newBitmap;
}
Pixmap pixmap = (Pixmap) tool->m_bitmap1.GetPixmap();
Pixmap insensPixmap = (Pixmap) tool->m_bitmap1.GetInsensPixmap();
if (tool->m_isToggle)
{
Pixmap pixmap2 = (Pixmap) 0;
Pixmap insensPixmap2 = (Pixmap) 0;
// If there's a bitmap for the toggled state, use it,
// otherwise generate one.
if (tool->m_bitmap2.Ok())
{
pixmap2 = (Pixmap) tool->m_bitmap2.GetPixmap();
insensPixmap2 = (Pixmap) tool->m_bitmap2.GetInsensPixmap();
}
else
{
pixmap2 = (Pixmap) tool->m_bitmap1.GetArmPixmap(button);
// This has to be both toggled and insensitive, but
// wxBitmap doesn't yet have a member to store & destroy
// it, so make it the same as pixmap2. Actually it's not
// used!
insensPixmap2 = pixmap2;
}
XtVaSetValues (button,
XmNlabelPixmap, pixmap,
XmNselectPixmap, pixmap,
XmNlabelInsensitivePixmap, insensPixmap,
XmNselectInsensitivePixmap, insensPixmap,
XmNarmPixmap, pixmap2,
XmNlabelType, XmPIXMAP,
NULL);
}
else
{
XtVaSetValues(button,
XmNlabelPixmap, pixmap,
XmNlabelInsensitivePixmap, insensPixmap,
NULL);
}
m_widgets.Append(tool->m_index, (wxObject*) button);
prevButton = button;
}
node = node->Next();
}
return TRUE;
}
void wxToolBar::SetToolBitmapSize(const wxSize& size)
@@ -113,7 +281,15 @@ void wxToolBar::ToggleTool(int toolIndex, bool toggle)
void wxToolBar::ClearTools()
{
// TODO
wxNode* node = m_widgets.First();
while (node)
{
Widget button = (Widget) node->Data();
XtDestroyWidget(button);
node = node->Next();
}
m_widgets.Clear();
wxToolBarBase::ClearTools();
}

View File

@@ -1280,33 +1280,6 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRectangle *rect)
}
}
void wxWindow::SetFont(const wxFont& font)
{
m_windowFont = font;
// Note that this causes the widget to be resized back
// to its original size! We therefore have to set the size
// back again. TODO: a better way in Motif?
/*
Widget w = (Widget) GetLabelWidget(); // Usually the main widget
if (w && m_windowFont.Ok())
{
int width, height, width1, height1;
GetSize(& width, & height);
XtVaSetValues (w,
XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
NULL);
GetSize(& width1, & height1);
if (width != width1 || height != height1)
{
SetSize(-1, -1, width, height);
}
}
*/
}
void wxWindow::OnChar(wxKeyEvent& event)
{
if ( event.KeyCode() == WXK_TAB ) {
@@ -1977,26 +1950,9 @@ wxWindow *wxWindow::FindWindow(const wxString& name)
void wxWindow::OnIdle(wxIdleEvent& event)
{
/* TODO: you may need to do something like this
* if your GUI doesn't generate enter/leave events
// Check if we need to send a LEAVE event
if (m_mouseInWindow)
{
POINT pt;
::GetCursorPos(&pt);
if (::WindowFromPoint(pt) != (HWND) GetHWND())
{
// Generate a LEAVE event
m_mouseInWindow = FALSE;
MSWOnMouseLeave(pt.x, pt.y, 0);
}
}
*/
// This calls the UI-update mechanism (querying windows for
// menu/toolbar/control state information)
UpdateWindowUI();
UpdateWindowUI();
}
// Raise the window to the top of the Z order
@@ -2990,11 +2946,9 @@ bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEve
return FALSE;
}
// TODO From wxWin 1.68. What does it do exactly?
#define YAllocColor XAllocColor
XColor itemColors[5];
int wxComputeColors (Display *display, wxColour * back, wxColour * fore)
XColor g_itemColors[5];
int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
{
int result;
static XmColorProc colorProc;
@@ -3003,10 +2957,10 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore)
if (back)
{
itemColors[0].red = (((long) back->Red ()) << 8);
itemColors[0].green = (((long) back->Green ()) << 8);
itemColors[0].blue = (((long) back->Blue ()) << 8);
itemColors[0].flags = DoRed | DoGreen | DoBlue;
g_itemColors[0].red = (((long) back->Red ()) << 8);
g_itemColors[0].green = (((long) back->Green ()) << 8);
g_itemColors[0].blue = (((long) back->Blue ()) << 8);
g_itemColors[0].flags = DoRed | DoGreen | DoBlue;
if (colorProc == (XmColorProc) NULL)
{
// Get a ptr to the actual function
@@ -3014,19 +2968,19 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore)
// And set it back to motif.
XmSetColorCalculation (colorProc);
}
(*colorProc) (&itemColors[wxBACK_INDEX],
&itemColors[wxFORE_INDEX],
&itemColors[wxSELE_INDEX],
&itemColors[wxTOPS_INDEX],
&itemColors[wxBOTS_INDEX]);
(*colorProc) (&g_itemColors[wxBACK_INDEX],
&g_itemColors[wxFORE_INDEX],
&g_itemColors[wxSELE_INDEX],
&g_itemColors[wxTOPS_INDEX],
&g_itemColors[wxBOTS_INDEX]);
result = wxBACK_COLORS;
}
if (fore)
{
itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
if (result == wxNO_COLORS)
result = wxFORE_COLORS;
}
@@ -3038,13 +2992,13 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore)
{
/* 5 Colours to allocate */
for (int i = 0; i < 5; i++)
if (!YAllocColor (dpy, cmap, &itemColors[i]))
if (!YAllocColor (dpy, cmap, &g_itemColors[i]))
result = wxNO_COLORS;
}
else if (fore)
{
/* Only 1 colour to allocate */
if (!YAllocColor (dpy, cmap, &itemColors[wxFORE_INDEX]))
if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX]))
result = wxNO_COLORS;
}
@@ -3052,58 +3006,101 @@ int wxComputeColors (Display *display, wxColour * back, wxColour * fore)
}
void wxWindow::ChangeColour(WXWidget widget)
// Changes the foreground and background colours to be derived
// from the current background colour.
// To change the foreground colour, you must call SetForegroundColour
// explicitly.
void wxWindow::ChangeBackgroundColour()
{
// TODO
#if 0
int change;
if (GetMainWidget())
DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
}
// TODO: how to determine whether we can change this item's colours?
// We used to have wxUSER_COLOURS. Now perhaps we assume we always
// can change it.
// if (!(parent->GetWindowStyleFlag() & wxUSER_COLOURS))
// return;
void wxWindow::ChangeForegroundColour()
{
if (GetMainWidget())
DoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
}
change = wxComputeColors (XtDisplay((Widget)widget), panel->GetBackgroundColour(),
panel->GetLabelColour());
if (change == wxBACK_COLORS)
// Change a widget's foreground and background colours.
// TODO: make this 2 functions, ChangeForegroundColour and ChangeBackgroundColour.
void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
{
// When should we specify the foreground, if it's calculated
// by wxComputeColours?
// Solution: say we start with the default (computed) foreground colour.
// If we call SetForegroundColour explicitly for a control or window,
// then the foreground is changed.
// Therefore SetBackgroundColour computes the foreground colour, and
// SetForegroundColour changes the foreground colour. The ordering is
// important.
XtVaSetValues ((Widget) widget,
XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
NULL);
}
void wxWindow::DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour)
{
wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
(wxColour*) NULL);
XtVaSetValues ((Widget) widget,
XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
NULL);
if (changeArmColour)
XtVaSetValues ((Widget) widget,
XmNbackground, itemColors[wxBACK_INDEX].pixel,
XmNtopShadowColor, itemColors[wxTOPS_INDEX].pixel,
XmNbottomShadowColor, itemColors[wxBOTS_INDEX].pixel,
XmNforeground, itemColors[wxFORE_INDEX].pixel,
NULL);
else if (change == wxFORE_COLORS)
XtVaSetValues (formWidget,
XmNforeground, itemColors[wxFORE_INDEX].pixel,
NULL);
change = wxComputeColors (XtDisplay((Widget)formWidget), GetBackgroundColour(), GetLabelColour());
if (change == wxBACK_COLORS)
XtVaSetValues (labelWidget,
XmNbackground, itemColors[wxBACK_INDEX].pixel,
XmNtopShadowColor, itemColors[wxTOPS_INDEX].pixel,
XmNbottomShadowColor, itemColors[wxBOTS_INDEX].pixel,
XmNarmColor, itemColors[wxSELE_INDEX].pixel,
XmNforeground, itemColors[wxFORE_INDEX].pixel,
NULL);
else if (change == wxFORE_COLORS)
XtVaSetValues (labelWidget,
XmNforeground, itemColors[wxFORE_INDEX].pixel,
NULL);
#endif
XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
NULL);
}
void wxWindow::ChangeFont(WXWidget widget)
void wxWindow::SetBackgroundColour(const wxColour& col)
{
/*
if (widget && GetFont() && GetFont()->Ok())
{
XmFontList fontList = (XmFontList) GetFont()->GetFontList(1.0, GetXDisplay());
if (fontList)
XtVaSetValues ((Widget) widget,
XmNfontList, fontList,
NULL);
}
*/
m_backgroundColour = col;
ChangeBackgroundColour();
}
void wxWindow::SetForegroundColour(const wxColour& col)
{
m_foregroundColour = col;
ChangeForegroundColour();
}
void wxWindow::ChangeFont()
{
// Note that this causes the widget to be resized back
// to its original size! We therefore have to set the size
// back again. TODO: a better way in Motif?
/*
Widget w = (Widget) GetLabelWidget(); // Usually the main widget
if (w && m_windowFont.Ok())
{
int width, height, width1, height1;
GetSize(& width, & height);
XtVaSetValues (w,
XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
NULL);
GetSize(& width1, & height1);
if (width != width1 || height != height1)
{
SetSize(-1, -1, width, height);
}
}
*/
}
void wxWindow::SetFont(const wxFont& font)
{
m_windowFont = font;
ChangeFont();
}