More Motif stuff, minor stubs correction

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@758 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-09-20 07:35:20 +00:00
parent a5e0e655cb
commit 02e8b2f9fb
17 changed files with 834 additions and 89 deletions

View File

@@ -15,6 +15,13 @@
#include "wx/button.h"
#include <Xm/PushBG.h>
#include <Xm/PushB.h>
#include "wx/motif/private.h"
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
#endif
@@ -38,14 +45,40 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
else
m_windowId = id;
// TODO: create button
char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
return FALSE;
}
XmString text = XmStringCreateSimple (label1);
Widget parentWidget = (Widget) parent->GetClientWidget();
void wxButton::SetSize(int x, int y, int width, int height, int sizeFlags)
{
// TODO
/*
* Patch Note (important)
* There is no major reason to put a defaultButtonThickness here.
* Not requesting it give the ability to put wxButton with a spacing
* as small as requested. However, if some button become a DefaultButton,
* other buttons are no more aligned -- This is why we set
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
* in the ::SetDefaultButton method.
*/
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button",
xmPushButtonWidgetClass,
parentWidget,
XmNlabelString, text,
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
NULL);
XmStringFree (text);
XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
(XtPointer) this);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeColour(m_mainWidget);
return TRUE;
}
void wxButton::SetDefault()
@@ -54,18 +87,32 @@ void wxButton::SetDefault()
if (parent)
parent->SetDefaultItem(this);
// TODO: make button the default
}
// We initially do not set XmNdefaultShadowThickness, to have small buttons.
// Unfortunately, buttons are now mis-aligned. We try to correct this
// now -- setting this ressource to 1 for each button in the same row.
// Because it's very hard to find wxButton in the same row,
// correction is straighforward: we set resource for all wxButton
// in this parent (but not sub panels)
for (wxNode * node = parent->GetChildren ()->First (); node; node = node->Next ())
{
wxButton *item = (wxButton *) node->Data ();
if (item->IsKindOf(CLASSINFO(wxButton)))
{
bool managed = XtIsManaged((Widget) item->GetMainWidget());
if (managed)
XtUnmanageChild ((Widget) item->GetMainWidget());
wxString wxButton::GetLabel() const
{
// TODO
return wxString("");
}
XtVaSetValues ((Widget) item->GetMainWidget(),
XmNdefaultButtonShadowThickness, 1,
NULL);
void wxButton::SetLabel(const wxString& label)
{
// TODO
if (managed)
XtManageChild ((Widget) item->GetMainWidget());
}
} // while
// XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL);
XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL);
}
void wxButton::Command (wxCommandEvent & event)
@@ -73,3 +120,14 @@ void wxButton::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr)
{
if (!wxGetWindowFromTable(w))
// Widget has been deleted!
return;
wxButton *item = (wxButton *) clientData;
wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
event.SetEventObject(item);
item->ProcessCommand (event);
}