More Motif additions: mdi and sashtest samples now just about work!

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@873 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-10-19 21:51:15 +00:00
parent 68dda78574
commit 8704bf74fb
45 changed files with 13490 additions and 64 deletions

View File

@@ -4,11 +4,26 @@ src/motif/*.h
src/motif/makefile*
src/motif/*.inc
src/motif/*.xbm
src/motif/combobox/*.c
src/motif/combobox/*.h
src/motif/combobox/*.doc
src/motif/combobox/*.man
src/motif/combobox/*.txt
src/motif/xmcombo/*.c
src/motif/xmcombo/*.h
src/motif/xmcombo/*.doc
src/motif/xmcombo/*.man
src/motif/xmcombo/*.txt
src/motif/mdi/COPYRIGHT
src/motif/mdi/Imakefile
src/motif/mdi/Readme
src/motif/mdi/config/C++.rules
src/motif/mdi/config/MDI.tmpl
src/motif/mdi/doc/*.html
src/motif/mdi/doc/pics/*.gif
src/motif/mdi/lib/*.C
src/motif/mdi/lib/*.h
src/motif/mdi/lib/*.xbm
src/motif/mdi/lib/Imakefile
src/motif/mdi/test/*.C
src/motif/mdi/test/Imakefile
src/make.env
src/makeprog.env

View File

@@ -26,6 +26,9 @@ WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr;
class WXDLLEXPORT wxMDIClientWindow;
class WXDLLEXPORT wxMDIChildFrame;
class XsMDICanvas;
class wxXsMDIWindow;
class WXDLLEXPORT wxMDIParentFrame: public wxFrame
{
DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
@@ -85,7 +88,6 @@ public:
protected:
// TODO maybe have this member
wxMDIClientWindow *m_clientWindow;
DECLARE_EVENT_TABLE()
@@ -120,13 +122,31 @@ public:
// Set menu bar
void SetMenuBar(wxMenuBar *menu_bar);
void SetTitle(const wxString& title);
void SetClientSize(int width, int height);
void GetClientSize(int *width, int *height) const;
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void GetSize(int *width, int *height) const;
void GetPosition(int *x, int *y) const ;
// Set icon
virtual void SetIcon(const wxIcon& icon);
// MDI operations
virtual void Maximize();
inline void Minimize() { Iconize(TRUE); };
virtual void Iconize(bool iconize);
virtual void Restore();
virtual void Activate();
virtual bool IsIconized() const ;
bool Show(bool show);
void BuildClientArea(WXWidget parent);
inline WXWidget GetTopWidget() const { return m_mainWidget; };
inline wxXsMDIWindow *GetMDIWindow() const { return m_mdiWindow; };
protected:
wxXsMDIWindow* m_mdiWindow ;
};
/* The client window is a child of the parent MDI frame, and itself
@@ -149,14 +169,29 @@ class WXDLLEXPORT wxMDIClientWindow: public wxWindow
~wxMDIClientWindow();
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void SetClientSize(int width, int height);
void GetClientSize(int *width, int *height) const;
void GetSize(int *width, int *height) const ;
void GetPosition(int *x, int *y) const ;
// Note: this is virtual, to allow overridden behaviour.
virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL);
// Explicitly call default scroll behaviour
void OnScroll(wxScrollEvent& event);
inline XsMDICanvas* GetMDICanvas() const { return m_mdiCanvas; }
WXWidget GetTopWidget() const { return m_topWidget; }
protected:
XsMDICanvas* m_mdiCanvas;
WXWidget m_topWidget;
DECLARE_EVENT_TABLE()
};

View File

@@ -23,7 +23,7 @@
#include <wx/toolbar.h>
#ifdef __WXGTK__
#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm"
#include "bitmaps/new.xpm"
#include "bitmaps/open.xpm"
@@ -142,6 +142,8 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
// Give it an icon
#ifdef __WXMSW__
subframe->SetIcon(wxIcon("chrt_icn"));
#else
subframe->SetIcon(wxIcon( mondrian_xpm ));
#endif
// Make a menubar
@@ -186,7 +188,7 @@ END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size):
wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER)
wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL)
{
}

View File

@@ -88,6 +88,9 @@ LDLIBS = $(EXTRALDLIBS) $(GUILDLIBS)
.cpp.o :
$(CC) -c $(CPPFLAGS) -o $@ $<
.C.o :
$(CC) -c $(CPPFLAGS) -o $@ $<
####################### Targets to allow multiple GUIs ####################
dummy:

View File

@@ -31,8 +31,7 @@ CC = gcc
CCC = $(CC)
# Compiler used for LEX generated C
# AIX: use $(CCC)
CCLEX=$(CC)
CCLEX=gcc
MAKE=make

View File

@@ -18,7 +18,7 @@
#if wxUSE_COMBOBOX
#include <Xm/Xm.h>
#include "combobox/combobox.h"
#include "xmcombo/xmcombo.h"
void wxComboBoxCallback (Widget w, XtPointer clientData,
XmComboBoxSelectionCallbackStruct * cbs);

View File

@@ -51,7 +51,7 @@
#include "wx/motif/private.h"
void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs);
static void wxFrameFocusProc(Widget workArea, XtPointer clientData,
void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs);
static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
XCrossingEvent * event);
@@ -310,14 +310,21 @@ wxFrame::~wxFrame()
XtDestroyWidget (statusLineWidget);
*/
wxDeleteWindowFromTable((Widget) m_workArea);
if (m_workArea)
{
wxDeleteWindowFromTable((Widget) m_workArea);
XtDestroyWidget ((Widget) m_workArea);
XtDestroyWidget ((Widget) m_frameWidget);
XtDestroyWidget ((Widget) m_workArea);
}
wxDeleteWindowFromTable((Widget) m_frameWidget);
if (m_frameWidget)
{
wxDeleteWindowFromTable((Widget) m_frameWidget);
XtDestroyWidget ((Widget) m_frameWidget);
}
XtDestroyWidget ((Widget) m_frameShell);
if (m_frameShell)
XtDestroyWidget ((Widget) m_frameShell);
SetMainWidget((WXWidget) NULL);
@@ -982,7 +989,7 @@ void wxFrame::SetToolBar(wxToolBar *toolbar)
wxToolBar *wxFrame::GetToolBar() const
{ return m_frameToolBar; }
static void wxFrameFocusProc(Widget workArea, XtPointer clientData,
void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs)
{
wxFrame *frame = (wxFrame *)clientData;

View File

@@ -165,13 +165,22 @@ LIB_C_SRC=\
../common/extended.c
EXTRA_C_SRC=\
combobox/combobox.c
xmcombo/xmcombo.c
EXTRA_CPP_SRC=\
mdi/lib/XsComponent.C\
mdi/lib/XsMDICanvas.C\
mdi/lib/XsMDIWindow.C\
mdi/lib/XsMotifWindow.C\
mdi/lib/XsMoveOutline.C\
mdi/lib/XsOutline.C\
mdi/lib/XsResizeOutline.C
all: $(WXLIB)
# Define library objects
OBJECTS=\
$(LIB_CPP_SRC:.cpp=.o) $(LIB_C_SRC:.c=.o) $(EXTRA_C_SRC:.c=.o)
$(LIB_CPP_SRC:.cpp=.o) $(LIB_C_SRC:.c=.o) $(EXTRA_C_SRC:.c=.o) $(EXTRA_CPP_SRC:.C=.o)
$(WXLIB) : $(OBJECTS)
ar $(AROPTIONS) $@ $(OBJECTS)

View File

@@ -17,8 +17,28 @@
#include "wx/menu.h"
#include "wx/settings.h"
#include <Xm/Xm.h>
#include <Xm/BulletinB.h>
#include <Xm/Form.h>
#include <Xm/MainW.h>
#include <Xm/RowColumn.h>
#include <Xm/CascadeBG.h>
#include <Xm/Text.h>
#include <Xm/PushBG.h>
#include <Xm/AtomMgr.h>
#include <Xm/Protocols.h>
#include "mdi/lib/XsMDICanvas.h"
#include "mdi/lib/XsMotifWindow.h"
#include "wx/motif/private.h"
extern wxList wxModelessWindows;
// Implemented in frame.cpp
extern void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame)
IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
@@ -36,10 +56,155 @@ END_EVENT_TABLE()
#endif
/*
static void _doNothingCallback (Widget, XtPointer, XtPointer)
{
}
*/
// wxXsMDIWindow represents the MDI child frame, as far as the MDI
// package is concerned.
// TODO: override raise, so we can tell which is the 'active'
// (raised) window. We can also use it to send wxActivateEvents,
// and switching menubars when we make the child frame menubar
// appear on the parent frame.
// Note: see XsMotifWindow.C, _XsMotifMenu::_processItem for
// where user menu selections are processed.
// When Close is selected, _win->close() is called.
class wxXsMDIWindow: public XsMotifWindow
{
public:
wxMDIChildFrame* m_childFrame;
wxXsMDIWindow(const char* name, wxMDIChildFrame* frame): XsMotifWindow(name)
{
m_childFrame = frame;
}
virtual void setSize(Dimension w, Dimension h)
{
XsMotifWindow::setSize(w, h);
// Generate wxSizeEvent here, I think. Maybe also restore, maximize
// Probably don't need to generate size event here since work area
// is used
wxSizeEvent event(wxSize(w, h), m_childFrame->GetId());
event.SetEventObject(m_childFrame);
m_childFrame->ProcessEvent(event);
}
virtual void close()
{
XsMotifWindow::close();
m_childFrame->Close();
}
virtual void _buildClientArea(Widget parent)
{
m_childFrame->BuildClientArea((WXWidget) parent);
// Code from MDI sample
#if 0
assert (parent != 0);
Widget pulldown;
Widget cascade;
Widget button;
// Create a main window with some dummy menus
Widget mainW = XtVaCreateWidget ("mainWin", xmMainWindowWidgetClass, parent,
XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
NULL);
// Create a menubar
Widget menuBar = XmCreateMenuBar (mainW, "menuBar", NULL, 0);
// Create the "file" menu
pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0);
cascade = XtVaCreateManagedWidget ("fileMenu", xmCascadeButtonGadgetClass,
menuBar, XmNsubMenuId, pulldown, NULL);
button = XtVaCreateManagedWidget ("openMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
button = XtVaCreateManagedWidget ("newMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
// XtAddCallback (button, XmNactivateCallback, _newWindowCallback, (XtPointer)this);
// Create the "edit" menu
pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0);
cascade = XtVaCreateManagedWidget ("editMenu", xmCascadeButtonGadgetClass,
menuBar, XmNsubMenuId, pulldown, NULL);
button = XtVaCreateManagedWidget ("cutMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
button = XtVaCreateManagedWidget ("copyMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
button = XtVaCreateManagedWidget ("pasteMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
// Create the help menu
pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0);
cascade = XtVaCreateManagedWidget ("helpMenu", xmCascadeButtonGadgetClass,
menuBar, XmNsubMenuId, pulldown, NULL);
button = XtVaCreateManagedWidget ("aboutMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
XtVaSetValues (menuBar, XmNmenuHelpWidget, cascade, NULL);
// Manage the menubar
XtManageChild (menuBar);
// Create the work area
const int nargs = 8;
Arg args[nargs];
int n;
n = 0;
XtSetArg (args[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
XtSetArg (args[n], XmNhighlightThickness, (Dimension)0); n++;
XtSetArg (args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
XtSetArg (args[n], XmNeditable, True); n++;
XtSetArg (args[n], XmNwordWrap, False); n++;
XtSetArg (args[n], XmNcursorPositionVisible, True); n++;
XtSetArg (args[n], XmNverifyBell, True); n++;
assert (n <= nargs);
Widget scrolledText = XmCreateScrolledText (mainW, "scrolledText", args, n);
XtManageChild (scrolledText);
// Set the main window area
XtVaSetValues (mainW, XmNmenuBar, menuBar, XmNworkWindow,
XtParent (scrolledText), NULL);
XtManageChild (mainW);
#endif
}
void Show() { show(); }
};
// Parent frame
wxMDIParentFrame::wxMDIParentFrame()
{
m_clientWindow = NULL;
}
bool wxMDIParentFrame::Create(wxWindow *parent,
@@ -50,49 +215,39 @@ bool wxMDIParentFrame::Create(wxWindow *parent,
long style,
const wxString& name)
{
if (!parent)
wxTopLevelWindows.Append(this);
m_clientWindow = NULL;
SetName(name);
m_windowStyle = style;
bool success = wxFrame::Create(parent, id, title, pos, size, style, name);
if (success)
{
// TODO: app cannot override OnCreateClient since
// wxMDIParentFrame::OnCreateClient will still be called
// (we're in the constructor). How to resolve?
if (parent) parent->AddChild(this);
if ( id > -1 )
m_windowId = id;
m_clientWindow = OnCreateClient();
// Uses own style for client style
m_clientWindow->CreateClient(this, GetWindowStyleFlag());
return TRUE;
}
else
m_windowId = (int)NewControlId();
// TODO: create MDI parent frame
wxModelessWindows.Append(this);
return TRUE;
return FALSE;
}
wxMDIParentFrame::~wxMDIParentFrame()
{
DestroyChildren();
delete m_clientWindow;
}
// Get size *available for subwindows* i.e. excluding menu bar.
void wxMDIParentFrame::GetClientSize(int *x, int *y) const
{
// TODO
wxFrame::GetClientSize(x, y);
}
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
{
// TODO
if (!menu_bar)
{
m_frameMenuBar = NULL;
return;
}
if (menu_bar->m_menuBarFrame)
return;
m_frameMenuBar = menu_bar;
wxFrame::SetMenuBar(menu_bar);
}
void wxMDIParentFrame::OnSize(wxSizeEvent& event)
@@ -187,74 +342,304 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
if (parent) parent->AddChild(this);
// TODO: create child frame
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
wxMDIClientWindow* clientWindow = parent->GetClientWindow();
if (!clientWindow)
return FALSE;
m_mdiWindow = new wxXsMDIWindow("mdiChildWindow", this);
clientWindow->GetMDICanvas()->add(m_mdiWindow);
m_mdiWindow->Show();
#if 0
m_mainWidget = (WXWidget) (Widget) (*m_mdiWindow);
m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
xmMainWindowWidgetClass, (Widget) m_mainWidget,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_workArea = (WXWidget) XtVaCreateWidget("form",
xmFormWidgetClass, (Widget) m_frameWidget,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_clientArea = (WXWidget) XtVaCreateWidget("client",
xmBulletinBoardWidgetClass, (Widget) m_workArea,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
// XmNresizePolicy, XmRESIZE_ANY,
NULL);
XtVaSetValues((Widget) m_frameWidget,
XmNworkWindow, (Widget) m_workArea,
NULL);
XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea);
wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ;
wxAddWindowToTable((Widget) m_workArea, this);
XtTranslations ptr ;
XtOverrideTranslations((Widget) m_workArea,
ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
XtAddCallback((Widget) m_workArea, XmNfocusCallback,
(XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
if (x > -1)
XtVaSetValues((Widget) m_mainWidget, XmNx, x, NULL);
if (y > -1)
XtVaSetValues((Widget) m_mainWidget, XmNy, y, NULL);
if (width > -1)
XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL);
if (height > -1)
XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL);
#endif
SetTitle(title);
PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
wxModelessWindows.Append(this);
return FALSE;
return TRUE;
}
void wxMDIChildFrame::BuildClientArea(WXWidget parent)
{
m_mainWidget = parent;
m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
xmMainWindowWidgetClass, (Widget) m_mainWidget,
XmNresizePolicy, XmRESIZE_NONE,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
m_workArea = (WXWidget) XtVaCreateWidget("form",
xmFormWidgetClass, (Widget) m_frameWidget,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_clientArea = (WXWidget) XtVaCreateWidget("client",
xmBulletinBoardWidgetClass, (Widget) m_workArea,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
// XmNresizePolicy, XmRESIZE_ANY,
NULL);
XtVaSetValues((Widget) m_frameWidget,
XmNworkWindow, (Widget) m_workArea,
NULL);
XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea);
wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ;
wxAddWindowToTable((Widget) m_workArea, this);
XtTranslations ptr ;
XtOverrideTranslations((Widget) m_workArea,
ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
XtAddCallback((Widget) m_workArea, XmNfocusCallback,
(XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
/*
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
if (x > -1)
XtVaSetValues((Widget) m_mainWidget, XmNx, x, NULL);
if (y > -1)
XtVaSetValues((Widget) m_mainWidget, XmNy, y, NULL);
if (width > -1)
XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL);
if (height > -1)
XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL);
*/
XtManageChild((Widget) m_frameWidget);
}
wxMDIChildFrame::~wxMDIChildFrame()
{
wxMDIClientWindow* clientWindow = ((wxMDIParentFrame*)GetParent())->GetClientWindow();
clientWindow->GetMDICanvas()->remove(m_mdiWindow);
m_mainWidget = (WXWidget) 0;
}
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxMDIChildFrame::SetClientSize(int width, int height)
{
// TODO
wxFrame::SetClientSize(width, height);
}
void wxMDIChildFrame::GetClientSize(int* width, int* height) const
{
wxFrame::GetClientSize(width, height);
}
void wxMDIChildFrame::SetSize(int x, int y, int width, int height, int sizeFlags)
{
wxWindow::SetSize(x, y, width, height, sizeFlags);
}
void wxMDIChildFrame::GetSize(int* width, int* height) const
{
wxWindow::GetSize(width, height);
}
void wxMDIChildFrame::GetPosition(int *x, int *y) const
{
// TODO
wxWindow::GetPosition(x, y);
}
bool wxMDIChildFrame::Show(bool show)
{
m_visibleStatus = show; /* show-&-hide fix */
return TRUE;
}
void wxMDIChildFrame::SetMenuBar(wxMenuBar *menu_bar)
{
// TODO
if (!menu_bar)
{
m_frameMenuBar = NULL;
return;
}
// Currently, the menu appears on the child frame.
// It should eventually be recreated on the main frame
// whenever the child is activated.
wxFrame::SetMenuBar(menu_bar);
}
if (menu_bar->m_menuBarFrame)
return;
m_frameMenuBar = menu_bar;
// Set icon
void wxMDIChildFrame::SetIcon(const wxIcon& icon)
{
m_icon = icon;
if (m_icon.Ok())
{
/* TODO: doesn't work yet (crashes in XCopyArea)
Pixmap pixmap = (Pixmap) m_icon.GetPixmap();
m_mdiWindow->setPixmap(pixmap);
*/
}
}
void wxMDIChildFrame::SetTitle(const wxString& title)
{
m_title = title;
m_mdiWindow->setTitle(title);
m_mdiWindow->setIconName(title);
}
// MDI operations
void wxMDIChildFrame::Maximize()
{
// TODO
m_mdiWindow->maximize();
}
void wxMDIChildFrame::Iconize(bool iconize)
{
if (iconize)
m_mdiWindow->minimize();
else
m_mdiWindow->restore();
}
bool wxMDIChildFrame::IsIconized() const
{
return m_mdiWindow->minimized();
}
void wxMDIChildFrame::Restore()
{
// TODO
m_mdiWindow->restore();
}
void wxMDIChildFrame::Activate()
{
// TODO
m_mdiWindow->raise();
}
// Client window
wxMDIClientWindow::wxMDIClientWindow()
{
m_mdiCanvas = NULL;
m_topWidget = (WXWidget) 0;
}
wxMDIClientWindow::~wxMDIClientWindow()
{
DestroyChildren();
delete m_mdiCanvas;
m_mainWidget = (WXWidget) 0;
m_topWidget = (WXWidget) 0;
}
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
{
// TODO create client window
m_windowParent = parent;
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
m_mdiCanvas = new XsMDICanvas("mdiClientWindow", (Widget) parent->GetClientWidget());
m_mainWidget = (WXWidget) m_mdiCanvas->GetDrawingArea();
// m_topWidget = (WXWidget) m_mdiCanvas->GetBase();
m_topWidget = (WXWidget) (Widget) (*m_mdiCanvas);
return FALSE;
m_mdiCanvas->show();
return TRUE;
}
void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
{
wxWindow::SetSize(x, y, width, height, sizeFlags);
}
void wxMDIClientWindow::SetClientSize(int width, int height)
{
wxWindow::SetClientSize(width, height);
}
void wxMDIClientWindow::GetClientSize(int *width, int *height) const
{
wxWindow::GetClientSize(width, height);
}
void wxMDIClientWindow::GetSize(int *width, int *height) const
{
wxWindow::GetSize(width, height);
}
void wxMDIClientWindow::GetPosition(int *x, int *y) const
{
wxWindow::GetPosition(x, y);
}
// Explicitly call default scroll behaviour

29
src/motif/mdi/COPYRIGHT Normal file
View File

@@ -0,0 +1,29 @@
Copyright (c) 1996 Scott W. Sadler
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to use,
copy, modify, and distribute, copies of the Software, and to permit persons to
whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
SCOTT W. SADLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Scott W. Sadler shall not be
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

9
src/motif/mdi/Imakefile Normal file
View File

@@ -0,0 +1,9 @@
#include "config/MDI.tmpl"
#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
SUBDIRS = lib test
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))

View File

@@ -0,0 +1,9 @@
#define CxxRules() @@\
@@\
CxxSuffixRules()
#define CxxSuffixRules() @@\
.SUFFIX: .C .o @@\
.C.o: @@\
$(CXX) $(CFLAGS) $(EXTRA_FLAGS) -c $<

View File

@@ -0,0 +1,45 @@
#undef FOUND_COMPILER
#ifdef SGIArchitecture
CXX = CC
CC = $(CXX)
#define FOUND_COMPILER
#endif
#ifdef SparcArchitecture
CXX = CC
CC = $(CXX)
#define FOUND_COMPILER
#endif
#ifdef HPArchitecture
CXX = CC
CC = $(CXX)
#define FOUND_COMPILER
#endif
#ifdef AIXArchitecture
CXX = xlC
CC = $(CXX)
EXTRA_FLAGS = -U__STR__ -D_POSIX_SOURCE
#define FOUND_COMPILER
#endif
#ifdef OSF1Architecture
CXX = cxx
CC = $(CXX)
#define FOUND_COMPILER
#endif
#ifdef LinuxArchitecture
CXX = gcc
CC = $(CXX)
#define FOUND_COMPILER
#endif
#ifndef FOUND_COMPILER
CXX = gcc
CC = $(CXX)
#endif
#include "C++.rules"

View File

@@ -0,0 +1,140 @@
<HTML>
<HEAD>
<TITLE>XsMDICanvas Class</TITLE>
<LINK REV="made" HREF="mailto:sws@iti-oh.com">
</HEAD>
<H2>
The XsMDICanvas Class
</H2>
<P>
This section describes how to build and manipulate an MDI using the
<I>XsMDICanvas</I> class. Minimally, you must perform the following actions
to build and display an MDI canvas:
<OL>
<LI>Create the <I>XsMDICanvas</I> object.</LI>
<LI>Create the documents as instances of subclasses of <I>XsMDIWindow</I>.</LI>
<LI>Add the documents to the canvas</LI>
<LI>Show the canvas</LI>
</OL>
<P>
<B>Constructor and Destructor:</B>
<P>
The <I>XsMDICanvas</I> accepts two arguments:
<DL>
<DD>XsMDICanvas (const char *name, Widget parent)</DD>
</DL>
<P>
The <I>name</I> parameter specifies the name of the canvas and is used
as the widget name for the underlying implementation. The <I>parent</I>
parameter specifies the widget that is to be used as the parent of the
canvas.
<P>
The <I>XsMDICanvas</I> destructor destroys the canvas, but it <B>does not</B>
destroy any of the underlying documents. It is up to the application to
destroy these.
<P>
<B>Adding and removing documents:</B>
<P>
After the documents are created, they must be added to the canvas. The
<I>XsMDICanvas::add()</I> member-function adds documents to the canvas:
<DL>
<DD>virtual void add (XsMDIWindow *window)</DD>
</DL>
<P>
The behavior of adding the same document to the canvas more than once
is undefined. Documents can be removed from the canvas by using:
<DL>
<DD>virtual void remove (XsMDIWindow *window)</DD>
</DL>
<P>
Additionally, all documents can be removed from the canvas with:
<DL>
<DD>void removeAll ( )</DD>
</DL>
<P>
The number of documents currently installed in the canvas can be
retrieved with:
<DL>
<DD>int numWindows ( ) const</DD>
</DL>
<P>
<B>Showing the canvas:</B>
<P>
In order to show (manage) the canvas call the <I>show</I> member function:
<DL>
<DD>virtual void show ( )</DD>
</DL>
This member-function is responsible for cycling all of the installed documents
and calling their respective <I>XsMDIWindow::_buildClientArea()</I>
member-functions. After each document has been created, <I>show</I> will then
manage each document and, finally, itself.
<P>
<B>Window Placement:</B>
<P>
The current implementation of <I>XsMDICanvas</I> uses a very simple algorithm
to place the documents on the canvas. In order to implement a more specific
placement algorithm, derive a class from <I>XsMDICanvas</I> and override
the member-function:
<DL>
<DD>virtual void _placeWindow (XsMDIWindow *win)</DD>
</DL>
<P>
This member-function is called for each document in the canvas to compute
the location of the document. Please refer to the code (<I>XsMDICanvas.C</I>)
for more details.
<P>
<B>Canvas Behavior:</B>
<P>
The <I>XsMDICanvas</I> is implemented as an <I>XmScrolledWindow</I> with an
<I>XmDrawingArea</I> work-window. The instance name for the work-window
is <I>canvas</I>. Internal callbacks in the canvas class force the work-window
to be at-least the size of the clip-window. This prevents documents from
being clipped as they are moved around.
<P>
By default, the <I>XmDrawingArea</I> work-window has its <I>XmNresizePolicy</I>
set to <I>XmRESIZE_GROW</I>. This will allow the work-area to grow to
whatever size necessary, but it will not automatically shrink as windows
are manipulated. If different behavior is desired, the <I>XmNresizePolicy</I>
resource on the work-area can be set to <I>XmRESIZE_ANY</I>. This will
force the work-window to recompute its size as windows are manipulated, and
it will grow and shrink as necessary. However, the <I>XsMDICanvas</I> will
still force the work-area to be at-least the size of the clip-window.
<P>To change the default behavior, add the following resource:
<DL>
<DD>&ltXsMDICanvas name&gt*canvas.resizePolicy: XmRESIZE_ANY</DD>
</DL>
</BODY>
</HTML>

182
src/motif/mdi/doc/mdi.html Normal file
View File

@@ -0,0 +1,182 @@
<HTML>
<HEAD>
<TITLE>Motif Multi-Document Interface (MDI)</TITLE>
<LINK REV="made" HREF="mailto:sws@iti-oh.com">
</HEAD>
<CENTER>
<IMG SRC="pics/mdi.gif" ALT="[Class Structure]">
<P><H2>
<B>
The Motif Multi-Document Interface
</B>
</H2>
</CENTER>
<P>
The Motif Multi-Document Interface (MDI) is a collection of C++ classes
that emulates the behavior of the Multi-Document Interface in Microsoft
Windows. The MDI framework allows a user to view multiple documents (windows)
constrained to a single parent window.
<P>
<HR SIZE = 4>
<P>
<B>
C<FONT SIZE=-1>LASS</FONT>
S<FONT SIZE=-1>TRUCTURE:</FONT>
</B>
<P>
<IMG SRC="pics/classes.gif" ALT="[Class Structure]">
<BR>
Figure 1. Inheritance Graph for MDI classes
<P>
The <I>XsMDICanvas</I> is a self-contained component used to display and manage
any number of child document windows. All documents windows are derived from
the abstract base-class <I>XsMDIWindow</I>. To get the Motif-like functionality,
document windows should be derived from the <I>XsMotifWindow</I> class.
<P>
<HR SIZE = 4>
<P>
<B>
E<FONT SIZE=-1>XAMPLE:</FONT>
</B>
<P>
The process of building and displaying a Multi-Document Interface using MDI
consists of the following steps:
<OL>
<LI>Creating the application document(s)</LI>
<LI>Creating the MDI canvas</LI>
<LI>Adding the document(s) to the canvas</LI>
</OL>
<PRE>
#include "XsMDICanvas.h"
#include "XsMotifWindow.h"
// Application document (derived from XsMotifWindow)
class MyDocument : public XsMotifWindow {
public:
MyDocument (const char *name);
virtual ~MyDocument ( );
protected:
virtual void _buildClientArea (Widget parent);
};
void createCanvas (Widget parent) {
// Create documents
MyDocument *doc1 = new MyDocument ("doc1");
MyDocument *doc2 = new MyDocument ("doc2");
// Create the canvas
XsMDICanvas *canvas = new XsMDICanvas ("canvas", parent);
// Add documents to canvas
canvas->add (doc1);
canvas->add (doc2);
// Show the canvas
canvas->show ( );
}
</PRE>
<P>
In this example, the application document <I>MyDocument</I> is derived
from <I>XsMotifWindow</I>. This provides a Motif-like window suitable for
use with the <I>XsMDICanvas</I>.
<P>
Next, two <I>MyDocument</I> objects are created along with the <I>XsMDICanvas</I>.
The two documents are then added to the canvas using the <I>add</I>
member-function of the canvas. Lastly, the canvas is shown (managed)
using the <I>show</I> member-function.
<P>
Creating the document <I>MyDocument</I> does not automatically create any
widgets. Rather, it only initializes internal variables. The widgets are
not created until the document is added to the canvas. The <I>XsMDICanvas</I>
is responsible for calling <I>XsMotifWindow::_buildClientArea()</I> at an
appropriate time. In this member-function, the application can create the
actual contents of the document.
<P>
The member-function <I>_buildClientArea</I> is passed a widget to be used as
the parent of the document contents. This parent widget is an unmanaged
<I>XmForm</I> widget. The application is free to create whatever contents
it needs as a child of the <I>XmForm</I> parent.
<P>
<HR SIZE = 4>
<P>
<B>
C<FONT SIZE=-1>LASS</FONT>
R<FONT SIZE=-1>EFERENCES:</FONT>
</B>
<P>
Of the classes in the MDI package, only the following should be of
interest to MDI library users:
<UL>
<LI> <A HREF="canvas.html"> XsMDICanvas </A> </LI>
<LI> <A HREF="mwindow.html"> XsMotifWindow </A> </LI>
</UL>
<P>
<HR SIZE = 4>
<P>
<B>
E<FONT SIZE=-1>XPLORING</FONT>
R<FONT SIZE=-1>ESOURCES:</FONT>
</B>
<P>
The MDI classes support a number of different X-resources (please refer
the the class manual pages for complete details). In order to get a feel
for the customization capabilities of the MDI library, try running the
test program (<I>MDItest</I>) with the following command-line options:
<DL>
<DD>MDItest -xrm "*showBorder:false"</DD>
<DD>MDItest -xrm "*showTitle:false" -xrm "*showResize:false"</DD>
<DD>MDItest -xrm "*showMenu:false" -xrm "*showMaximize:false"</DD>
<DD>MDItest -xrm "*borderSize:4" -xrm "*buttonSize:14"</DD>
<DD>MDItest -xrm "*lowerOnIconify:true" -xrm "*title:Hello World"</DD>
</DL>
<P>
<HR SIZE = 4>
<P>
<B>
A<FONT SIZE=-1>DDITIONAL</FONT>
I<FONT SIZE=-1>INFORMATION:</FONT>
</B>
<P>
The test program <I>MDItest.C</I> gives a complete example of an MDI
application. It should serve as a good reference/example of the MDI library.
</BODY>
</HTML>

View File

@@ -0,0 +1,277 @@
<HTML>
<HEAD>
<TITLE>XsMotifWindow Class</TITLE>
<LINK REV="made" HREF="mailto:sws@iti-oh.com">
</HEAD>
<H2>
The XsMotifWindow Class
</H2>
<P>
The <I>XsMDICanvas</I> requires that all documents be a subclass of
<I>XsMDIWindow</I> or a subclass of a class derived from it. By itself
<I>XsMDIWindow</I> does not define any appearance or behavior for the
documents. However, <I>XsMotifWindow</I>, derived from <I>XsMDIWindow</I>,
defines a MWM-like look-and-feel to a document.
<P>
Documents in your application should be derived from <I>XsMotifWindow</I>.
This class provides the look-and-feel of Motif window and supports the
interaction with the <I>XsMDICanvas</I>. It is up to the application to
define the contents of each document.
<P>
<B>Constructor and Destructor:</B>
<P>
The <I>XsMotifWindow</I> constructor accepts one argument:
<DL>
<DD>XsMotifWindow (const char *name)</DD>
</DL>
<P>
The <I>name</I> parameter specifies the name of the document and is used
as the widget name for the underlying implementation. The name parameter
is also used as the default title and icon-name for the document.
<P>
<B>Note:</B> The <I>XsMotifWindow</I> constructor does not create any
widgets. Rather it only initializes internal variables. The widgets are
not created until the document is added to the canvas. The <I>XsMDICanvas</I>
calls the member-function <I>XsMotifWindow::_buildClientArea()</I> when it needs
to create the document widgets.
<P>
The <I>XsMotifWindow</I> destructor destroys the document widgets (if they have
been created) and frees its internal storage. It is up to the application
to free all documents. The <I>XsMDICanvas</I> will <B>not</B> destroy the
documents for you.
<P>
<B>Document Utilities:</B>
<P>
Although rarely called from the application, the <I>XsMotifWindow</I> supports
a number of utility functions to manipulate the document.
<DL>
<DD>virtual void raise ( )</DD>
<DD>virtual void lower ( )</DD>
<DD>virtual void minimize ( )</DD>
<DD>virtual void maximize ( )</DD>
<DD>virtual void restore ( )</DD>
<DD>virtual void close ( )</DD>
</DL>
<P>
The <I>close</I> member-function does not destroy the document, it simply
hides it from view. You can restore a closed document with
<I>XsMotifWindow::show()</I>.
<P>
The following member-functions are used to change/query the appearance of
the document:
<DL>
<DD>void setTitle (const char *name)</DD>
<DD>const char *title ( ) const</DD>
<DD>void setIconName (const char *name)</DD>
<DD>const char *iconName ( ) const</DD>
<DD>void setPixmap (Pixmap pixmap)</DD>
<DD>Pixmap pixmap ( ) const</DD>
<DD>Widget icon ( ) const</DD>
<DD>Boolean minimized ( ) const</DD>
<DD>Boolean maximized ( ) const</DD>
<DD>virtual void setPosition (Position x, Position y)</DD>
<DD>virtual void setSize (Dimension width, Dimension height)</DD>
</DL>
<P>
The <I>setPixmap</I> member-function accepts a pixmap which the document then
uses as the decoration on the icon. Because the document does not make a copy
of the pixmap, it is important that the application not free the pixmap until
all documents that reference it are deleted. The document does, however, make
a local copy of the title or icon-name string passed to it, so the application
is free to do whatever it wants to the passed-in string. The <I>icon</I>
member-function returns the widget that is used to implement the icon.
<P>
<B>Creating Window Subclasses:</B>
<P>
The application must derive its documents from <I>XsMotifWindow</I> in order to
define the contents of the document. The <I>XsMDICanvas</I> calls the
protected member-function <I>_buildClientArea</I> when it creates the
document. Each class derived from <I>XsMotifWindow</I> <B>must</B> override
this pure-virtual member-function.
<P>
The member-function <I>_buildClientArea</I> is called with a single argument:
<DL>
<DD>virtual void _buildClientArea (Widget parent)</DD>
</DL>
The <I>parent</I> argument should be used as the parent of the contents of
the document. This widget is an unmanaged <I>XmForm</I> widget, and all of
the standard resources and constrains apply to it. The <I>XsMDICanvas</I>
is responsible for managing the parent widget at the appropriate time.
<P>
As an example, consider the following:
<PRE>
// _buildClientArea (called to create document contents)
void MyDocument::_buildClientArea (Widget parent)
{
assert (parent != 0);
// Create a main window with some dummy menus
Widget mainW = XtVaCreateWidget ("mainWin", xmMainWindowWidgetClass, parent,
XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
NULL);
...
XtManageChild (mainW);
}
</PRE>
<P>
In this case, an <I>XmMainWindow</I> is created as the child of the parent
widget. The <I>XmMainWindow</I> is then attached to the 4 sides of the parent
form. Note also that the main window is managed before returning from the
function.
<P>
<B>Resources:</B>
<P>
The <I>XsMotifWindow</I> supports the following resources:
<PRE>
Name Class Type Default
------------------------------------------------------------------------------
borderSize BorderSize Dimension 6
buttonSize ButtonSize Dimension 23
title Title String dynamic
titleFont TitleFont String -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-iso8859-1
iconSize IconSize Dimension 70
iconName IconName String dynamic
iconFont IconFont String *-helvetica-bold-r-normal-*-12-*-*-*-*-*-iso8859-1
XmNiconX XmCIconX Position dynamic
XmNiconY XmCIconY Position dynamic
saveUnder SaveUnder Boolean True
restoreString RestoreString String "Restore"
moveString MoveString String "Move"
sizeString SizeString String "Size"
minimizeString MinimizeString String "Minimize"
maximizeString MaximizeString String "Maximize"
raiseString RaiseString String "Raise"
lowerString LowerString String "Lower"
closeString CloseString String "Close"
menuFont MenuFont String -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-iso8859-1
showBorder ShowBorder Boolean True
showResize ShowResize Boolean True
showTitle ShowTitle Boolean True
showMenu ShowMenu Boolean True
showMinimize ShowMinimize Boolean True
showMaximize ShowMaximize Boolean True
lowerOnIconify LowerOnIconify Boolean False
XmNminWidth XmCMinWidth Dimension dynamic
XmNmaxWidth XmCMaxWidth Dimension dynamic
XmNminHeight XmCMinHeight Dimension dynamic
XmNmaxHeight XmCMaxHeight Dimension dynamic
</PRE>
<DL>
<DD>
<DL>
<DT>borderSize</DT>
<DD>Size of the window border.</DD>
<DT>buttonSize</DT>
<DD>Size of the window buttons.</DD>
<DT>title</DT>
<DD>Title of the window. The default is the name of the window instance.</DD>
<DT>titleFont</DT>
<DD>Font used to draw the window title.</DD>
<DT>iconSize</DT>
<DD>Size of the icon representation.</DD>
<DT>iconName</DT>
<DD>String used on the title. If unspecified, the window title is used.</DD>
<DT>iconFont</DT>
<DD>Font used to draw the icon-name.</DD>
<DT>XmNiconX</DT>
<DD>X-position of the icon. The default location is the top-left
corner of the window when it is iconified.</DD>
<DT>XmNiconY</DT>
<DD>Y-position of the icon. The default location is the top-left
corner of the window when it is iconified.</DD>
<DT>saveUnder</DT>
<DD>Enables/Disables save-unders for the menu.</DD>
<DT>restoreString</DT>
<DD>String used as the "restore" menu item.</DD>
<DT>moveString</DT>
<DD>String used as the "move" menu item.</DD>
<DT>sizeString</DT>
<DD>String used as the "size" menu item.</DD>
<DT>minimizeString</DT>
<DD>String used as the "minimize" menu item.</DD>
<DT>maximizeString</DT>
<DD>String used as the "maximize" menu item.</DD>
<DT>raiseString</DT>
<DD>String used as the "raise" menu item.</DD>
<DT>lowerString</DT>
<DD>String used as the the "lower" menu item.</DD>
<DT>closeString</DT>
<DD>String used as the "close" menu item.</DD>
<DT>menuFont</DT>
<DD>Font used to draw the menu strings.</DD>
<DT>showBorder</DT>
<DD>Enables/Disables the window border. If the border is disabled,
the resize-handles are automatically disabled.</DD>
<DT>showResize</DT>
<DD>Enables/Disables the window resize handles.</DD>
<DT>showTitle</DT>
<DD>Enables/Disables the window title. If the title is disabled,
all of the window buttons are automatically disabled.</DD>
<DT>showMenu</DT>
<DD>Enables/Disables the window menu button.</DD>
<DT>showMinimize</DT>
<DD>Enables/Disables the window minimize button.</DD>
<DT>showMaximize</DT>
<DD>Enables/Disables the window maximize button.</DD>
<DT>lowerOnIconify</DT>
<DD>Automatically lower windows when iconified.</DD>
<DT>XmNminWidth</DT>
<DD>Minimium window width. The default is about four times the size of
the window button.</DD>
<DT>XmNmaxWidth</DT>
<DD>Maximum window width. The default is not to constrain the maximum size.</DD>
<DT>XmNminHeight</DT>
<DD>Minimum window height. The default is about four times the size of
the window button.</DD>
<DT>XmNmaxHeight</DT>
<DD>Maximum window height. The default is not to constrain the maximum size.</DD>
</DL>
</DD>
</DL>
<P>
<B>XsMotifWindow Implementation:</B>
<P>
As a convenience to those who wish to modify the <I>XsMotifWindow</I> code,
here is a diagram of the internal class structure:
<P>
<IMG SRC="pics/winclass.gif" ALT="[Class Structure]">
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -0,0 +1,21 @@
#include "../config/MDI.tmpl"
SRCS = XsComponent.C XsMDICanvas.C XsMDIWindow.C XsMotifWindow.C \
XsMoveOutline.C XsOutline.C XsResizeOutline.C
HEADERS = XsComponent.h XsMDICanvas.h XsMDIWindow.h XsMotifWindow.h \
sMoveOutline.h XsOutline.h XsResizeOutline.h
OBJS = XsComponent.o XsMDICanvas.o XsMDIWindow.o XsMotifWindow.o \
XsMoveOutline.o XsOutline.o XsResizeOutline.o
STD_INCLUDES = -I/usr/include
INCLUDES = -I.
LIBXSW = Xsw
NormalLibraryObjectRule()
NormalLibraryTarget($(LIBXSW),$(OBJS))
DependTarget()
CxxRules()

View File

@@ -0,0 +1,201 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsComponent.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#ifndef NDEBUG
#include <iostream.h>
#endif
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <Xm/Xm.h>
#include "XsComponent.h"
// Constructor
XsComponent::XsComponent (const char *name)
{
assert (name != 0);
// Initialize
_base = 0;
// Copy component name
int len = strlen (name);
_name = new char [len + 1];
strcpy (_name, name);
}
// Destructor
XsComponent::~XsComponent ( )
{
// Destroy the widget
if (_base != 0)
{
_removeDestroyHandler ( );
XtDestroyWidget (_base);
}
delete [] _name;
}
// show
void XsComponent::show ( )
{
#ifndef NDEBUG
if (XtIsManaged (_base))
cout << "Re-managing a widget:" << _name << endl;
#endif
// Make sure the _destroyHandler was installed
assert (XtHasCallbacks (_base, XmNdestroyCallback) == XtCallbackHasSome);
assert (_base != 0);
XtManageChild (_base);
}
// hide
void XsComponent::hide ( )
{
#ifndef NDEBUG
if (!XtIsManaged (_base))
cout << "Re-unmanaging a widget:" << _name << endl;
#endif
assert (_base != 0);
XtUnmanageChild (_base);
}
// Conversion operator
XsComponent::operator Widget ( ) const
{
assert (_base != 0);
return (_base);
}
// operator ==
Boolean XsComponent::operator == (const XsComponent& rval)
{
return (_base == rval._base);
}
// className
const char* XsComponent::className ( ) const
{
return ("XsComponent");
}
// _installDestroyHandler
void XsComponent::_installDestroyHandler ( )
{
assert (_base != 0);
// Install the destroy handler
XtAddCallback (_base, XmNdestroyCallback, _componentDestroyedCallback, (XtPointer)this);
}
// _removeDestroyHandler
void XsComponent::_removeDestroyHandler ( )
{
assert (_base != 0);
// Remove the destroy handler
XtRemoveCallback (_base, XmNdestroyCallback, _componentDestroyedCallback, (XtPointer)this);
}
// _componentDestroyed
void XsComponent::_componentDestroyed ( )
{
_base = 0;
}
// _componentDestroyedCallback
void XsComponent::_componentDestroyedCallback (Widget, XtPointer clientData, XtPointer)
{
XsComponent *obj = (XsComponent*)clientData;
obj->_componentDestroyed ( );
}
// _setResources
void XsComponent::_setResources (Widget w, const String *resources)
{
assert (w != 0);
XrmDatabase rdb = 0;
const int bufSize = 200;
char buffer[bufSize];
int loop;
// Create an empty resource database
rdb = XrmGetStringDatabase ("");
// Add the component resources
loop = 0;
while (resources[loop] != 0)
{
sprintf (buffer, "*%s%s\n", _name, resources[loop++]);
assert (strlen (buffer) < bufSize);
XrmPutLineResource (&rdb, buffer);
}
// Merge these resources into the database
if (rdb != 0)
{
XrmDatabase db = XtDatabase (XtDisplay (w));
XrmCombineDatabase (rdb, &db, FALSE);
}
}
// _getResources
void XsComponent::_getResources (const XtResourceList resources, int num)
{
assert (_base != 0);
assert (resources != 0);
// Validate input
if (num <= 0)
return;
// Get the subresources
XtGetSubresources (XtParent (_base), (XtPointer)this, _name,
className ( ), resources, num, 0, 0);
}

View File

@@ -0,0 +1,98 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsComponent.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSCOMPONENT_H
#define XSCOMPONENT_H
// Includes
#include <X11/Intrinsic.h>
// XsComponent class
class XsComponent {
public:
// Destructor
virtual ~XsComponent ( );
// Component manipulation
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;
// Utilities
Widget base ( ) const;
virtual operator Widget ( ) const;
// Operators
Boolean operator == (const XsComponent&);
// Class name
virtual const char *className ( ) const;
protected:
// Protected constructor
XsComponent (const char *name);
// Component life-cycle
virtual void _componentDestroyed ( );
void _installDestroyHandler ( );
void _removeDestroyHandler ( );
// Resource manager
void _setResources (Widget w, const String *);
void _getResources (const XtResourceList, int);
// Implementation
char *_name; // Component name
Widget _base; // Base widget
private:
// Callbacks
static void _componentDestroyedCallback (Widget, XtPointer, XtPointer);
};
// Inline member functions
inline Widget XsComponent::base ( ) const
{
return (_base);
}
inline const char* XsComponent::name ( ) const
{
return (_name);
}
#endif

View File

@@ -0,0 +1,298 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMDICanvas.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#include <assert.h>
#include <Xm/ScrolledW.h>
#include <Xm/DrawingA.h>
#include "XsMDICanvas.h"
#include "XsMDIWindow.h"
// Static definitions
String XsMDICanvas::_resources[] = {
"*canvas.resizePolicy: XmRESIZE_GROW",
NULL
};
// Constructor
XsMDICanvas::XsMDICanvas (const char *name, Widget parent) : XsComponent (name)
{
assert (parent != 0);
// Initialize
_list = 0;
_num = 0;
_max = 0;
_place = 0;
// Install resources
_setResources (parent, _resources);
// Create the scrolled window
const int nargs = 10;
Arg args[nargs];
int n = 0;
XtSetArg (args[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
XtSetArg (args[n], XmNscrolledWindowMarginHeight, (Dimension)0); n++;
XtSetArg (args[n], XmNscrolledWindowMarginWidth, (Dimension)0); n++;
XtSetArg (args[n], XmNmarginHeight, (Dimension)5); n++;
XtSetArg (args[n], XmNmarginWidth, (Dimension)5); n++;
assert (n <= nargs);
_base = XmCreateScrolledWindow (parent, _name, args, n);
// Install the destroy handler
_installDestroyHandler ( );
// Create the drawing area (canvas)
_drawArea = XtVaCreateWidget ("canvas", xmDrawingAreaWidgetClass,
_base, XmNmarginHeight, (Dimension)0, XmNmarginWidth, (Dimension)0,
NULL);
// Set resize callback on drawing area
XtAddCallback (_drawArea, XmNresizeCallback, _canvasResizeCallback, (XtPointer)this);
// Set resize callback on clip window
XtVaGetValues (_base, XmNclipWindow, &_clipWin, NULL);
XtAddCallback (_clipWin, XmNresizeCallback, _clipResizeCallback, (XtPointer)this);
}
// Destructor
XsMDICanvas::~XsMDICanvas ( )
{
/*
Remove callbacks to prevent calls to destroyed class-part of XsMDICanvas
while children are being destroyed.
*/
if (_drawArea)
XtRemoveCallback (_drawArea, XmNresizeCallback, _canvasResizeCallback, (XtPointer)this);
if (_clipWin)
XtRemoveCallback (_clipWin, XmNresizeCallback, _clipResizeCallback, (XtPointer)this);
// Remove all windows
removeAll ( );
}
// add
void XsMDICanvas::add (XsMDIWindow *win)
{
assert (win != 0);
const int increment = 10;
// Check if we need to allocate more space
if (_num >= _max)
{
XsMDIWindow **newList = new XsMDIWindow*[_max + increment];
for (int loop = 0; loop < _num; loop++)
newList[loop] = _list[loop];
_max += increment;
delete [] _list;
_list = newList;
}
// Add the new window
_list[_num++] = win;
// Install the parent canvas
win->_setWindowParent (_drawArea);
// If the canvas is shown, place the window
if (XtIsManaged (_base))
_placeWindow (win);
}
// remove
void XsMDICanvas::remove (XsMDIWindow *win)
{
assert (win != 0);
// Remove the window
int i, j;
for (i = 0; i < _num; i++)
{
if (_list[i] == win)
{
win->hide ( );
win->_setWindowParent (0);
for (j = i; j < _num - 1; j++)
_list[j] = _list[j + 1];
_num--;
return;
}
}
assert (0); // Couldn't find window
}
// removeAll
void XsMDICanvas::removeAll ( )
{
// Delete and reset the list
delete [] _list;
_list = 0;
_num = 0;
_max = 0;
}
// show
void XsMDICanvas::show ( )
{
assert (_drawArea != 0);
// Place all of the child windows
for (int loop = 0; loop < _num; loop++)
_placeWindow (_list[loop]);
// Manage the drawing area and canvas
XtManageChild (_drawArea);
// Call base class
XsComponent::show ( );
}
// className
const char* XsMDICanvas::className ( ) const
{
return ("XsMDICanvas");
}
// _componentDestroyed
void XsMDICanvas::_componentDestroyed ( )
{
// Remove the callbacks
XtRemoveCallback (_drawArea, XmNresizeCallback, _canvasResizeCallback, (XtPointer)this);
XtRemoveCallback (_clipWin, XmNresizeCallback, _clipResizeCallback, (XtPointer)this);
_drawArea = 0;
_clipWin = 0;
}
// _placeWindow
void XsMDICanvas::_placeWindow (XsMDIWindow *win)
{
assert (win != 0);
// Compute window placement
Position x, y;
const int maxWin = 10;
const Position offset = 20;
const Position minOffset = 10;
x = (_place * offset) + minOffset;
y = (_place * offset) + minOffset;
if (++_place == maxWin)
_place = 0;
// Set the window placement
win->setPosition (x, y);
// Show the window
win->show ( );
}
// _resize
void XsMDICanvas::_resize (XtPointer)
{
Dimension clipHeight;
Dimension clipWidth;
Dimension canvasHeight;
Dimension canvasWidth;
// Check if clip window and canvas are managed
if (!XtIsManaged (_clipWin) || !XtIsManaged (_drawArea))
return;
// Get the clip window size
XtVaGetValues (_clipWin, XmNwidth, &clipWidth, XmNheight, &clipHeight, NULL);
// Get the canvas size
XtVaGetValues (_drawArea, XmNwidth, &canvasWidth, XmNheight, &canvasHeight, NULL);
// Force the canvas to be at least as big as the clip window
if (canvasWidth < clipWidth)
canvasWidth = clipWidth;
if (canvasHeight < clipHeight)
canvasHeight = clipHeight;
XtVaSetValues (_drawArea, XmNwidth, canvasWidth, XmNheight, canvasHeight, NULL);
}
// _clipResizeCallback
void XsMDICanvas::_clipResizeCallback (Widget, XtPointer clientData, XtPointer callData)
{
XsMDICanvas *obj = (XsMDICanvas*)clientData;
obj->_resize (callData);
}
// _canvasResizeCallback
void XsMDICanvas::_canvasResizeCallback (Widget, XtPointer clientData, XtPointer callData)
{
XsMDICanvas *obj = (XsMDICanvas*)clientData;
obj->_resize (callData);
}

View File

@@ -0,0 +1,100 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMDICanvas.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSMDICANVAS_H
#define XSMDICANVAS_H
// Includes
#include "XsComponent.h"
// Forward declarations
class XsMDIWindow;
// XsMDICanvas class
class XsMDICanvas : public XsComponent {
public:
// Constructor/Destructor
XsMDICanvas (const char *name, Widget parent);
virtual ~XsMDICanvas ( );
// MDI Window manipulation
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
// Component methods
virtual void show ( );
// Class name
virtual const char *className ( ) const;
protected:
// Component life-cycle
virtual void _componentDestroyed ( );
// Geometry management
virtual void _placeWindow (XsMDIWindow *win);
// Canvas resize handler
virtual void _resize (XtPointer);
// Implementation
Widget _clipWin;
Widget _drawArea;
XsMDIWindow **_list;
int _num;
int _max;
int _place;
private:
// Callbacks
static void _clipResizeCallback (Widget, XtPointer, XtPointer);
static void _canvasResizeCallback (Widget, XtPointer, XtPointer);
// Resources
static String _resources[];
};
// Inline member functions
inline XsMDICanvas::numWindows ( ) const
{
return (_num);
}
#endif

View File

@@ -0,0 +1,156 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMDIWindow.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#include <assert.h>
#include <Xm/Xm.h>
#include "XsMDIWindow.h"
// Constructor
XsMDIWindow::XsMDIWindow (const char *name) : XsComponent (name)
{
// Initialize
_clientArea = 0;
_parent = 0;
// Initial size and placement
_initX = (Position)-1;
_initY = (Position)-1;
_initH = (Dimension)-1;
_initW = (Dimension)-1;
_placed = False;
}
// Destructor
XsMDIWindow::~XsMDIWindow ( )
{
// Empty
}
// raise
void XsMDIWindow::raise ( )
{
assert (_base != 0);
XRaiseWindow (XtDisplay (_base), XtWindow (_base));
}
// lower
void XsMDIWindow::lower ( )
{
assert (_base != 0);
XLowerWindow (XtDisplay (_base), XtWindow (_base));
}
// show
void XsMDIWindow::show ( )
{
// Create the window (if necessary)
if (_base == 0)
{
assert (_parent != 0);
_createWindow (_parent);
}
// Manage the client area
XtManageChild (_clientArea);
// Configure the window position and size
if (_placed == False)
{
const int nargs = 4;
Arg args[nargs];
int n = 0;
if (_initX != (Position)-1)
{
XtSetArg (args[n], XmNx, _initX); n++;
}
if (_initY != (Position)-1)
{
XtSetArg (args[n], XmNy, _initY); n++;
}
if (_initW != (Dimension)-1)
{
XtSetArg (args[n], XmNwidth, _initW); n++;
}
if (_initH != (Dimension)-1)
{
XtSetArg (args[n], XmNheight, _initH); n++;
}
assert (n <= nargs);
XtSetValues (_base, args, n);
_placed = True;
}
// Call the base class
XsComponent::show ( );
}
// setPosition
void XsMDIWindow::setPosition (Position x, Position y)
{
if (_base != 0)
XtVaSetValues (_base, XmNx, x, XmNy, y, NULL);
else
{
_initX = x;
_initY = y;
}
}
// setSize
void XsMDIWindow::setSize (Dimension w, Dimension h)
{
if (_base != 0)
XtVaSetValues (_base, XmNwidth, w, XmNheight, h, NULL);
else
{
_initW = w;
_initH = h;
}
}
// className
const char* XsMDIWindow::className ( ) const
{
return ("XsMDIWindow");
}
// _setWindowParent
void XsMDIWindow::_setWindowParent (Widget p)
{
// This is called by the canvas to tell us who our parent is
_parent = p;
}

View File

@@ -0,0 +1,89 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMDIWindow.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSMDIWINDOW_H
#define XSMDIWINDOW_H
// Includes
#include "XsComponent.h"
// XsMDIWindow class
class XsMDIWindow : public XsComponent {
friend class XsMDICanvas;
public:
// Constructor/Destructor
XsMDIWindow (const char *name);
virtual ~XsMDIWindow ( );
// Window manipulation
virtual void raise ( );
virtual void lower ( );
// Utilities
Widget clientArea ( ) const;
// Position and size
virtual void setPosition (Position x, Position y);
virtual void setSize (Dimension w, Dimension h);
// Class name
virtual const char *className ( ) const;
protected:
// Only the friendly canvas can show a window
virtual void show ( );
// Window creation functions
virtual void _buildClientArea (Widget parent) = 0;
virtual void _createWindow (Widget parent) = 0;
// Implementation
Widget _clientArea; // Client work area
// Initial window size and placement
Position _initX, _initY;
Dimension _initW, _initH;
Boolean _placed;
private:
// Window parent installation
void _setWindowParent (Widget);
Widget _parent;
};
// Inline member functions
inline Widget XsMDIWindow::clientArea ( ) const
{
return (_clientArea);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,665 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMotifWindow.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSMOTIFWINDOW_H
#define XSMOTIFWINDOW_H
// Includes
#include <Xm/Xm.h>
#include "XsMDIWindow.h"
// Forward declarations
class XsMotifWindow;
/*
----------------------------------------------------------------------------
_XsMotifBase class
*/
class _XsMotifBase : public XsComponent {
public:
// Destructor
virtual ~_XsMotifBase ( );
// Window actions
virtual void show ( );
// Class name
virtual const char *className ( ) const;
protected:
// Protected constructor
_XsMotifBase (const char *name, XsMotifWindow *win);
// Component life-cycle
virtual void _componentDestroyed ( );
// Utilities
void _drawShadows (Position x, Position y, Dimension width,
Dimension height, Dimension thick, Boolean reverse = False);
void _drawLine (Position x1, Position y1, Position x2, Position y2, GC &gc);
// Implementation
XsMotifWindow *_win;
GC _topShadowGC;
GC _bottomShadowGC;
// Event handlers
virtual void _map ( );
// Internal Event handlers
static void _mapEventHandler (Widget, XtPointer, XEvent*, Boolean*);
};
/*
----------------------------------------------------------------------------
_XsMotifComponent class
*/
class _XsMotifComponent : public _XsMotifBase {
public:
// Destructor
virtual ~_XsMotifComponent ( );
// Enumerations
enum Cursors {
TopCursor = 0, BottomCursor, LeftCursor, RightCursor,
TopLeftCursor, TopRightCursor, BottomLeftCursor,
BottomRightCursor, NumCursors };
// Class name
virtual const char *className ( ) const;
protected:
// Protected constructor
_XsMotifComponent (const char *name, XsMotifWindow *win, Widget parent = 0);
// Cursors
static Cursor _cursors[NumCursors];
// Component parameters
Dimension _borderSize;
Dimension _buttonSize;
Dimension _cornerSize;
// Event handlers
virtual void _expose (XEvent*) = 0;
virtual void _input (XEvent*);
private:
// Internal Event handlers
static void _exposeEventHandler (Widget, XtPointer, XEvent*, Boolean*);
static void _inputEventHandler (Widget, XtPointer, XEvent*, Boolean*);
// Resources
static XtResource _resourceList[];
static int _mutex;
};
/*
----------------------------------------------------------------------------
_XsMotifCorner class
*/
class _XsMotifCorner : public _XsMotifComponent {
public:
// Enumerations
enum Corner { TopLeft = 0, TopRight, BottomLeft, BottomRight, Max };
// Constructor/Destructor
_XsMotifCorner (const char *name, XsMotifWindow *win, Corner corner);
virtual ~_XsMotifCorner ( );
// Class name
virtual const char *className ( ) const;
protected:
// Implementation
Corner _corner;
// Event handlers
virtual void _expose (XEvent*);
virtual void _input (XEvent*);
virtual void _map ( );
};
/*
----------------------------------------------------------------------------
_XsMotifSide class
*/
class _XsMotifSide : public _XsMotifComponent {
public:
// Enumerations
enum Side { Top = 0, Bottom, Left, Right, Max };
// Constructor/Destructor
_XsMotifSide (const char *name, XsMotifWindow *win, Side side);
virtual ~_XsMotifSide ( );
// Class name
virtual const char *className ( ) const;
protected:
// Implementation
Side _side;
int _lastW;
int _lastH;
// Event handlers
virtual void _expose (XEvent*);
virtual void _input (XEvent*);
virtual void _map ( );
virtual void _configure (XEvent *);
private:
// Callbacks
static void _configureEventHandler (Widget, XtPointer, XEvent*, Boolean*);
};
/*
----------------------------------------------------------------------------
_XsMotifButton class
*/
class _XsMotifButton : public _XsMotifComponent {
public:
// Enumerations
enum Button { Menu = 0, Minimize, Maximize, Max };
// Constructor/Destructor
_XsMotifButton (const char *name, XsMotifWindow *win, Button button);
virtual ~_XsMotifButton ( );
// Utilities
virtual void redraw ( );
// Class name
virtual const char *className ( ) const;
protected:
// Implementation
Boolean _pressed;
Button _button;
// Event handlers
virtual void _expose (XEvent*);
virtual void _input (XEvent*);
virtual void _map ( );
};
/*
----------------------------------------------------------------------------
_XsMotifTitle class
*/
class _XsMotifTitle : public _XsMotifComponent {
public:
// Constructor/Destructor
_XsMotifTitle (const char *name, XsMotifWindow *win);
virtual ~_XsMotifTitle ( );
// Title string
void setTitle (const char *name);
const char *title ( ) const;
// Class name
virtual const char *className ( ) const;
protected:
// Implementation
Boolean _pressed;
String _titleString;
GC _fontGC;
XFontStruct *_titleFont;
int _lastW;
int _lastH;
// Component life-cycle
virtual void _componentDestroyed ( );
// Utilities
virtual void _redraw ( );
// Event handlers
virtual void _expose (XEvent*);
virtual void _input (XEvent*);
virtual void _map ( );
virtual void _configure (XEvent*);
private:
// Callbacks
static void _configureEventHandler (Widget, XtPointer, XEvent*, Boolean*);
// Resources
static XtResource _resourceList[];
};
// Inline member functions
inline const char *_XsMotifTitle::title ( ) const
{
return (_titleString);
}
/*
----------------------------------------------------------------------------
_XsMotifIcon class
*/
class _XsMotifIcon : public _XsMotifComponent {
public:
// Constructor/Destructor
_XsMotifIcon (const char *name, XsMotifWindow *win, Widget parent);
virtual ~_XsMotifIcon ( );
// Window operations
virtual void show ( );
// Icon name/pixmap
void setIconName (const char *name);
const char *iconName ( ) const;
void setPixmap (Pixmap pm);
Pixmap pixmap ( ) const;
// Class name
virtual const char *className ( ) const;
protected:
// Implementation
GC _fontGC;
GC _pixmapGC;
Dimension _iconSize;
String _iconName;
XFontStruct *_iconFont;
Pixmap _pixmap;
Boolean _freePixmap;
Dimension _width, _height;
Position _iconX, _iconY;
Boolean _placed;
// Component life-cycle
virtual void _componentDestroyed ( );
// Event handlers
virtual void _expose (XEvent*);
virtual void _input (XEvent*);
virtual void _map ( );
private:
// Resources
static XtResource _resourceList[];
};
// Inline member-functions
inline const char *_XsMotifIcon::iconName ( ) const
{
return (_iconName);
}
inline Pixmap _XsMotifIcon::pixmap ( ) const
{
return (_pixmap);
}
/*
----------------------------------------------------------------------------
_XsMotifMenu class
*/
class _XsMotifMenu : public _XsMotifBase {
public:
// Constructor/Destructor
_XsMotifMenu (const char *name, XsMotifWindow *win);
virtual ~_XsMotifMenu ( );
// Utilities
virtual void popup (Boolean atPointer = True);
// Enumerations
enum Item {
NoItem = -1, Restore, Move, Size, Minimize,
Maximize, Raise, Lower, Close, Num
};
// Class name
virtual const char *className ( ) const;
protected:
// Dimensions
enum { ShadowThickness = 1 };
enum { VertTextOffset = 3 };
enum { HorizTextOffset = 10 };
// Implementation
static Cursor _cursor;
static Pixmap _stipple;
static Display *_dpy;
Boolean _saveUnder;
String _strings[Num];
XFontStruct *_menuFont;
GC _fontGC;
GC _grayGC;
GC _backgroundGC;
Item _curItem;
// Component life-cycle
virtual void _componentDestroyed ( );
// Menu event processing
virtual void _processEvents ( );
// Utilities
virtual void _processItem (Item item);
virtual void _redrawMenu ( );
void _redrawItem (Item);
void _toggleItem (Item, Boolean active = False);
Item _trackPointer (XMotionEvent *event);
// Pointer grabs
Boolean _grabPointer ( );
void _ungrabPointer ( );
// Event handlers
virtual void _map ( );
private:
// Work procedure
static Boolean _workProc (XtPointer);
// Resources
static XtResource _resourceList[];
static int _count;
};
/*
----------------------------------------------------------------------------
XsMotifWindow class
*/
class XsMotifWindow : public XsMDIWindow {
public:
// Constructor/Destructor
XsMotifWindow (const char *name);
virtual ~XsMotifWindow ( );
// Window manipulation
virtual void raise ( );
virtual void lower ( );
virtual void minimize ( );
virtual void maximize ( );
virtual void restore ( );
virtual void close ( );
// Window and icon strings
void setTitle (const char *name);
const char *title ( ) const;
void setIconName (const char *name);
const char *iconName ( ) const;
void setPixmap (Pixmap pm);
Pixmap pixmap ( ) const;
// Window icon handle
Widget icon ( ) const;
// Menu settings
void popupMenu (Boolean atPointer = True);
// Utilities
Boolean maximized ( ) const;
Boolean minimized ( ) const;
// Position and size
virtual void setPosition (Position, Position);
virtual void setSize (Dimension, Dimension);
Dimension minWidth ( ) const;
Dimension minHeight ( ) const;
// Class name
virtual const char *className ( ) const;
protected:
// Window creation functions
virtual void _buildClientArea (Widget parent) = 0;
virtual void _createWindow (Widget parent);
// Window components
_XsMotifCorner *_corners[_XsMotifCorner::Max];
_XsMotifSide *_sides[_XsMotifSide::Max];
_XsMotifButton *_buttons[_XsMotifButton::Max];
_XsMotifTitle *_title;
_XsMotifIcon *_icon;
_XsMotifMenu *_menu;
// Window dimensions
Dimension _savedWidth, _savedHeight;
Position _savedX, _savedY;
Dimension _minW, _maxW;
Dimension _minH, _maxH;
// Window parameters
Boolean _showBorder;
Boolean _showResize;
Boolean _showTitle;
Boolean _showMenu;
Boolean _showMinimize;
Boolean _showMaximize;
Boolean _lowerOnIconify;
// Window state
Boolean _maximized;
Boolean _minimized;
// Callbacks
virtual void _mapEvent ( );
private:
// Internal event handlers
static void _mapEventHandler (Widget, XtPointer, XEvent*, Boolean*);
// Resources
static XtResource _resourceList[];
};
// Inline member functions
inline Boolean XsMotifWindow::maximized ( ) const
{
return (_maximized);
}
inline Boolean XsMotifWindow::minimized ( ) const
{
return (_minimized);
}
inline const char *XsMotifWindow::title ( ) const
{
if (_title != 0)
return (_title->title ( ));
else
return (0);
}
inline const char *XsMotifWindow::iconName ( ) const
{
if (_icon != 0)
return (_icon->iconName ( ));
else
return (0);
}
inline Pixmap XsMotifWindow::pixmap ( ) const
{
if (_icon != 0)
return (_icon->pixmap ( ));
else
return (None);
}
inline Widget XsMotifWindow::icon ( ) const
{
if (_icon != 0)
return (_icon->base ( ));
else
return (0);
}
inline Dimension XsMotifWindow::minWidth ( ) const
{
return (_minW);
}
inline Dimension XsMotifWindow::minHeight ( ) const
{
return (_minH);
}
#endif

View File

@@ -0,0 +1,82 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMoveOutline.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#include <assert.h>
#include "XsMoveOutline.h"
#include <X11/cursorfont.h>
// Static definitions
Cursor XsMoveOutline::_fleur = None;
// Constructor
XsMoveOutline::XsMoveOutline (Widget w) : XsOutline (w)
{
unsigned int mask; // Not used
Window root;
int xy;
// Create the cursor (if necessary)
if (_fleur == None)
_fleur = XCreateFontCursor (XtDisplay (_w), XC_fleur);
// Get the current mouse root coordinates
XQueryPointer (XtDisplay (_w), XtWindow (_w), &root, &root, &_rootX,
&_rootY, &xy, &xy, &mask);
}
// Destructor
XsMoveOutline::~XsMoveOutline ( )
{
// Empty
}
// _motionHandler
void XsMoveOutline::_motionHandler (XEvent *event)
{
int curX, curY;
// Get current mouse position
curX = event->xbutton.x_root;
curY = event->xbutton.y_root;
// Compute the new window position
_x += (curX - _rootX);
_y += (curY - _rootY);
// Move the window
_drawOutline (False);
// Save the new root position
_rootX = curX;
_rootY = curY;
}
// _getCursor
Cursor XsMoveOutline::_getCursor ( ) const
{
return (_fleur);
}

View File

@@ -0,0 +1,52 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsMoveOutline.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSMOVEOUTLINE_H
#define XSMOVEOUTLINE_H
// Includes
#include "XsOutline.h"
// XsMoveOutline class
class XsMoveOutline : public XsOutline {
public:
// Constructor/Destructor
XsMoveOutline (Widget w);
virtual ~XsMoveOutline ( );
protected:
// Motion handler
virtual void _motionHandler (XEvent*);
// Moving cursor
virtual Cursor _getCursor ( ) const;
private:
// Implementation
int _rootX;
int _rootY;
static Cursor _fleur;
};
#endif

View File

@@ -0,0 +1,241 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsOutline.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#include <assert.h>
#include <X11/StringDefs.h>
#include "XsOutline.h"
// Constructor
XsOutline::XsOutline (Widget w)
{
assert (w != 0);
// Initialize
_w = w;
// Get window dimensions
unsigned int moreJunk;
unsigned int uw, uh;
Window junk;
XGetGeometry (XtDisplay (_w), XtWindow (_w), &junk, &_x, &_y, &uw, &uh, &moreJunk, &moreJunk);
_width = uw;
_height = uh;
// Get initial settings
_savedX = _x;
_savedY = _y;
_savedH = _savedW = 0;
// Create the graphics context
XGCValues values;
unsigned long valuemask;
Display *dpy = XtDisplay (_w);
valuemask = GCFunction | GCLineWidth | GCSubwindowMode;
values.function = GXinvert;
values.line_width = 0;
values.subwindow_mode = IncludeInferiors;
_gc = XCreateGC (dpy, XtWindow (_w), valuemask, &values);
}
// Destructor
XsOutline::~XsOutline ( )
{
XFreeGC (XtDisplay (_w), _gc);
}
// go
Boolean XsOutline::go (Boolean drawInitial)
{
XtAppContext appContext = XtWidgetToApplicationContext (_w);
XEvent event;
int done = 0;
// Grab the pointer
if (_grabPointer ( ) == False)
return (False);
// Draw the initial box (if requested)
if (drawInitial)
_drawOutline (False);
// Process the events locally
while (!done)
{
XtAppNextEvent (appContext, &event);
switch (event.type)
{
case ButtonRelease:
{
// Clear the outline and break
_drawOutline (True);
done = 1;
break;
}
case MotionNotify:
{
XEvent next;
// Process only the last motion event
while (XPending (XtDisplay (_w)) > 0)
{
XPeekEvent (XtDisplay (_w), &next);
if (next.type != MotionNotify)
break;
XtAppNextEvent (appContext, &event);
}
// Send this event
_motionHandler (&event);
break;
}
default:
{
XtDispatchEvent (&event);
break;
}
}
}
// Ungrab the pointer
_ungrabPointer ( );
return (True);
}
// _drawOutline
void XsOutline::_drawOutline (Boolean clear)
{
// Clear the current outline
if (_savedH || _savedW)
_drawIt (_savedX, _savedY, _savedW, _savedH);
// Save current values
_savedX = _x; _savedY = _y;
_savedW = _width; _savedH = _height;
// Draw the new outline (unless flagged to just clear)
if (!clear)
_drawIt (_x, _y, _width, _height);
}
// _getCursor
Cursor XsOutline::_getCursor ( ) const
{
return (None);
}
// _grabPointer
Boolean XsOutline::_grabPointer ( )
{
// Sync everything up before being grabby
XSync (XtDisplay (_w), False);
// Grab the pointer
if (XGrabPointer (XtDisplay (_w), XtWindow (_w), False, GrabEventMask,
GrabModeAsync, GrabModeAsync, XtWindow (XtParent (_w)), _getCursor ( ),
CurrentTime) != GrabSuccess)
{
XBell (XtDisplay (_w), 100);
return (False);
}
return (True);
}
// _ungrabPointer
void XsOutline::_ungrabPointer ( )
{
// Ungrab the pointer
XUngrabPointer (XtDisplay (_w), CurrentTime);
}
// _drawIt
void XsOutline::_drawIt (int x, int y, int w, int h)
{
const int nsegs = 8;
XSegment segs[nsegs];
// Across the top
segs[0].x1 = x; segs[0].y1 = y;
segs[0].x2 = x + w - 1; segs[0].y2 = y;
segs[1].x1 = x + BorderSize; segs[1].y1 = y + BorderSize;
segs[1].x2 = x + w - BorderSize - 1; segs[1].y2 = y + BorderSize;
// Down the left
segs[2].x1 = x + w - 1; segs[2].y1 = y + 1;
segs[2].x2 = x + w - 1; segs[2].y2 = y + h - 1;
segs[3].x1 = x + w - BorderSize - 1; segs[3].y1 = y + BorderSize + 1;
segs[3].x2 = x + w - BorderSize - 1; segs[3].y2 = y + h - BorderSize - 1;
// Across the bottom
segs[4].x1 = x + 1; segs[4].y1 = y + h - 1;
segs[4].x2 = x + w - 2; segs[4].y2 = y + h - 1;
segs[5].x1 = x + BorderSize + 1; segs[5].y1 = y + h - BorderSize - 1;
segs[5].x2 = x + w - BorderSize - 2; segs[5].y2 = y + h - BorderSize - 1;
// Up the left
segs[6].x1 = x; segs[6].y1 = y + h - 1;
segs[6].x2 = x; segs[6].y2 = y + 1;
segs[7].x1 = x + BorderSize; segs[7].y1 = y + h - BorderSize - 1;
segs[7].x2 = x + BorderSize; segs[7].y2 = y + BorderSize + 1;
// Draw the segments
XDrawSegments (XtDisplay (_w), XtWindow (XtParent (_w)), _gc, segs, nsegs);
}

View File

@@ -0,0 +1,109 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsOutline.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSOUTLINE_H
#define XSOUTLINE_H
// Includes
#include <X11/Intrinsic.h>
// XsOutline class
class XsOutline {
public:
// Constructor/Destructor
XsOutline (Widget w);
virtual ~XsOutline ( );
// Event handler
Boolean go (Boolean drawInitial = False);
// Utilities
int width ( ) const;
int height ( ) const;
int x ( ) const;
int y ( ) const;
protected:
// Enumerations
enum { BorderSize = 6 };
enum { GrabEventMask = (unsigned int)(ButtonPressMask | ButtonReleaseMask | PointerMotionMask) };
// Components
Widget _w;
// Graphics context
GC _gc;
// Current dimensions
int _x, _y;
int _width;
int _height;
// Outline utilities
virtual void _motionHandler (XEvent*) = 0;
virtual Cursor _getCursor ( ) const;
void _drawOutline (Boolean);
private:
// Pointer grabs
Boolean _grabPointer ( );
void _ungrabPointer ( );
// Save dimensions
int _savedX, _savedY;
int _savedW, _savedH;
// Drawing
void _drawIt (int, int, int, int);
};
// Inline member functions
inline int XsOutline::width ( ) const
{
return (_width);
}
inline int XsOutline::height ( ) const
{
return (_height);
}
inline int XsOutline::x ( ) const
{
return (_x);
}
inline int XsOutline::y ( ) const
{
return (_y);
}
#endif

View File

@@ -0,0 +1,231 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsResizeOutline.C
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#include <assert.h>
#include <X11/cursorfont.h>
#include "XsResizeOutline.h"
// Static definitions
Cursor XsResizeOutline::_cursors[XsResizeOutline::NumCursors];
int XsResizeOutline::_mutex = 0;
// Constructor
XsResizeOutline::XsResizeOutline (Widget w, int direction) : XsOutline (w)
{
// Initialize
_minWidth = 5;
_minHeight = 5;
_direction = direction;
// Translate current window location to root coordinates
Position xpos, ypos;
XtTranslateCoords (XtParent (_w), (Position)_x, (Position)_y, &xpos, &ypos);
_rootX = (int)xpos;
_rootY = (int)ypos;
// Save the original window position and size
_origX = _x;
_origY = _y;
_origW = _width;
_origH = _height;
_origRootX = _rootX;
_origRootY = _rootY;
// Create the cursors (if necessary)
if (_mutex == 0)
{
Display *dpy = XtDisplay (_w);
// Create cursors
_cursors[TopCursor] = XCreateFontCursor (dpy, XC_top_side);
_cursors[BottomCursor] = XCreateFontCursor (dpy, XC_bottom_side);
_cursors[LeftCursor] = XCreateFontCursor (dpy, XC_left_side);
_cursors[RightCursor] = XCreateFontCursor (dpy, XC_right_side);
_cursors[TopLeftCursor] = XCreateFontCursor (dpy, XC_top_left_corner);
_cursors[TopRightCursor] = XCreateFontCursor (dpy, XC_top_right_corner);
_cursors[BottomLeftCursor] = XCreateFontCursor (dpy, XC_bottom_left_corner);
_cursors[BottomRightCursor] = XCreateFontCursor (dpy, XC_bottom_right_corner);
_cursors[Fleur] = XCreateFontCursor (dpy, XC_fleur);
_mutex = 1;
}
}
// Destructor
XsResizeOutline::~XsResizeOutline ( )
{
// Empty
}
// setMinSize
void XsResizeOutline::setMinSize (int minWidth, int minHeight)
{
assert (minWidth > 0);
assert (minHeight > 0);
_minWidth = minWidth;
_minHeight = minHeight;
}
// _motionHandler
void XsResizeOutline::_motionHandler (XEvent *event)
{
int curX, curY;
int diff;
int x, y, w, h;
// Get current mouse position
curX = event->xbutton.x_root;
curY = event->xbutton.y_root;
if (_direction & Undetermined)
{
/*
Just let the mouse roam around until it crosses the outline.
When it does so, lock in the direction, change the cursor, and let
it rip.
*/
if (((curX <= _origRootX) || (curX >= (_origRootX + _origW)))
|| ((curY <= _origRootY) || (curY >= (_origRootY + _origH))))
{
const int CornerOffset = 30;
// Crossed box. Figure out where and set direction
_direction = 0;
if (curY <= (_origRootY + CornerOffset))
_direction |= Up;
else if (curY >= (_origRootY + _origH - CornerOffset))
_direction |= Down;
if (curX <= (_origRootX + CornerOffset))
_direction |= Left;
else if (curX >= (_origRootX + _origW - CornerOffset))
_direction |= Right;
// Get the new cursor
XChangeActivePointerGrab (XtDisplay (_w), GrabEventMask,
_getCursor ( ), CurrentTime);
}
else
return;
}
// Get the current values
x = _x; y = _y; w = _width; h = _height;
// Process the motion
if (_direction & Up)
{
if (curY < (_origRootY + _origH - 1 - _minHeight))
{
diff = _rootY - curY;
_rootY = curY;
_y -= diff;
_height = _origRootY + _origH - curY;
}
else
{
_rootY = _origRootY + _origH - 1 - _minHeight;
_y = _origY + _origH - 1 - _minHeight;
_height = _minHeight;
}
}
else if (_direction & Down)
{
if (curY > (_origRootY + _minHeight))
_height = curY - _origRootY - 1;
else
_height = _minHeight;
}
if (_direction & Left)
{
if (curX < (_origRootX + _origW - 1 - _minWidth))
{
diff = _rootX - curX;
_rootX = curX;
_x -= diff;
_width = _origRootX + _origW - curX;
}
else
{
_rootX = _origRootX + _origW - 1 - _minWidth;
_x = _origX + _origW - 1 - _minWidth;
_width = _minWidth;
}
}
else if (_direction & Right)
{
if (curX > (_origRootX + _minWidth))
_width = curX - _origRootX - 1;
else
_width = _minWidth;
}
// Check if the values have "really" changed
if ((w != _width) || (h != _height) || (x != _x) || (y != _y))
_drawOutline (False);
}
// _getCursor
Cursor XsResizeOutline::_getCursor ( ) const
{
if (_direction == Up)
return (_cursors[TopCursor]);
if (_direction == Down)
return (_cursors[BottomCursor]);
if (_direction == Left)
return (_cursors[LeftCursor]);
if (_direction == Right)
return (_cursors[RightCursor]);
if (_direction == (Up | Left))
return (_cursors[TopLeftCursor]);
if (_direction == (Up | Right))
return (_cursors[TopRightCursor]);
if (_direction == (Down | Left))
return (_cursors[BottomLeftCursor]);
if (_direction == (Down | Right))
return (_cursors[BottomRightCursor]);
if (_direction == Undetermined)
return (_cursors[Fleur]);
assert (0);
return (None);
}

View File

@@ -0,0 +1,70 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
XsResizeOutline.h
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#ifndef XSRESIZEOUTLINE_H
#define XSRESIZEOUTLINE_H
// Includes
#include "XsOutline.h"
class XsResizeOutline : public XsOutline {
public:
// Enumerations
enum { Up = 0x0001, Right = 0x0002, Down = 0x0004, Left = 0x0008,
Undetermined = 0x0010 };
enum Cursors {
TopCursor = 0, BottomCursor, LeftCursor, RightCursor, TopLeftCursor,
TopRightCursor, BottomLeftCursor, BottomRightCursor, Fleur,
NumCursors };
// Constructor/Destructor
XsResizeOutline (Widget w, int direction);
virtual ~XsResizeOutline ( );
void setMinSize (int minWidth, int minHeight);
protected:
// Motion handler
virtual void _motionHandler (XEvent*);
// Resize cursor
virtual Cursor _getCursor ( ) const;
private:
// Implementation
int _rootX, _rootY; // Root coordinates
int _origRootX, _origRootY;
int _origX, _origY; // Window coordinates
int _origW, _origH;
int _minWidth, _minHeight;
int _direction;
static Cursor _cursors[NumCursors];
static int _mutex;
};
#endif

View File

@@ -0,0 +1,27 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
xs_motif_icon.xbm
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
#define xs_motif_icon_width 32
#define xs_motif_icon_height 32
static char xs_motif_icon_bits[] = {
0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x00, 0xc0, 0xfc, 0x03, 0x00, 0x60,
0xf8, 0x07, 0x00, 0x30, 0xf8, 0x07, 0x00, 0x18, 0xf0, 0x0f, 0x00, 0x0c,
0xe0, 0x1f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x06, 0xc0, 0x3f, 0x00, 0x03,
0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00,
0x00, 0xfe, 0x31, 0x00, 0x00, 0xfc, 0x33, 0x00, 0x00, 0xf8, 0x1b, 0x00,
0x00, 0xf0, 0x0d, 0x00, 0x00, 0xf0, 0x0e, 0x00, 0x00, 0x60, 0x1f, 0x00,
0x00, 0xb0, 0x3f, 0x00, 0x00, 0x98, 0x7f, 0x00, 0x00, 0x98, 0x7f, 0x00,
0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x03, 0xfc, 0x03,
0x80, 0x01, 0xfc, 0x03, 0xc0, 0x00, 0xf8, 0x07, 0xc0, 0x00, 0xf0, 0x0f,
0x60, 0x00, 0xe0, 0x1f, 0x30, 0x00, 0xe0, 0x1f, 0x18, 0x00, 0xc0, 0x3f,
0x0c, 0x00, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff};

View File

@@ -0,0 +1,25 @@
#include "../config/MDI.tmpl"
SRCS = MDItest.C
OBJS = MDItest.o
STD_INCLUDES = -I/usr/include
INCLUDES = -I../lib
DEPLIBS = ../lib/libXsw.a
#if defined(SunArchitecture)
SYSLIBS = -lgen
#endif
LOCAL_LIBRARIES = ../lib/libXsw.a
SYSTEM_LIBRARIES = -lXm -lXt -lX11 $(SYSLIBS)
PROGRAM = MDItest
AllTarget($(PROGRAM))
NormalProgramTarget($(PROGRAM),$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),$(SYSTEM_LIBRARIES))
DependTarget()
CxxRules()

View File

@@ -0,0 +1,391 @@
/*
Copyright (C) 1996 Scott W. Sadler
All rights reserved.
*/
/*
MDItest.c
History
03-Mar-96 1.0; Scott W. Sadler (sws@iti-oh.com)
Created
*/
// Includes
#include <assert.h>
#include <Xm/MainW.h>
#include <Xm/RowColumn.h>
#include <Xm/CascadeBG.h>
#include <Xm/Text.h>
#include <Xm/PushBG.h>
#include <Xm/AtomMgr.h>
#include <Xm/Protocols.h>
#include "XsMDICanvas.h"
#include "XsMotifWindow.h"
// Fallback resources
static char *fallbacks[] = {
"*MDItest.height: 500",
"*MDItest.width: 500",
"*MDIinner.width: 300",
"*MDIinner.height: 300",
"*fileMenu.labelString: File",
"*fileMenu.mnemonic: F",
"*openMenuItem.labelString: Open...",
"*openMenuItem.mnemonic: O",
"*newMenuItem.labelString: New...",
"*newMenuItem.mnemonic: N",
"*editMenu.labelString: Edit",
"*editMenu.mnemonic: E",
"*cutMenuItem.labelString: Cut",
"*cutMenuItem.mnemonic: t",
"*copyMenuItem.labelString: Copy",
"*copyMenuItem.mnemonic: C",
"*pasteMenuItem.labelString: Paste",
"*pasteMenuItem.mnemonic: P",
"*helpMenu.labelString: Help",
"*helpMenu.mnemonic: H",
"*aboutMenuItem.labelString: About",
"*aboutMenuItem.mnemonic: A",
"*scrolledText.rows: 10",
"*scrolledText.columns: 30",
"*background: grey",
"*fontList: -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-iso8859-1",
NULL
};
/*
----------------------------------------------------------------------------
MyDocument class
*/
class MyDocument : public XsMotifWindow {
public:
// Constructor/Destructor
MyDocument (const char *name, XsMDICanvas *canvas);
virtual ~MyDocument ( );
protected:
// This member function is called to create the document contents
virtual void _buildClientArea (Widget);
// Implementation
XsMDICanvas *_canvas;
// Callbacks
void _newWindow ( );
void _doNothing ( );
private:
// Callbacks
static void _newWindowCallback (Widget, XtPointer, XtPointer);
static void _doNothingCallback (Widget, XtPointer, XtPointer);
};
// Constructor
MyDocument::MyDocument (const char *name, XsMDICanvas *canvas) :
XsMotifWindow (name)
{
assert (canvas != 0);
// Initialize
_canvas = canvas;
}
// Destructor
MyDocument::~MyDocument ( )
{
// Empty
}
// _buildClientArea (called to create document contents)
void MyDocument::_buildClientArea (Widget parent)
{
assert (parent != 0);
Widget pulldown;
Widget cascade;
Widget button;
// Create a main window with some dummy menus
Widget mainW = XtVaCreateWidget ("mainWin", xmMainWindowWidgetClass, parent,
XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
NULL);
// Create a menubar
Widget menuBar = XmCreateMenuBar (mainW, "menuBar", NULL, 0);
// Create the "file" menu
pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0);
cascade = XtVaCreateManagedWidget ("fileMenu", xmCascadeButtonGadgetClass,
menuBar, XmNsubMenuId, pulldown, NULL);
button = XtVaCreateManagedWidget ("openMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
button = XtVaCreateManagedWidget ("newMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _newWindowCallback, (XtPointer)this);
// Create the "edit" menu
pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0);
cascade = XtVaCreateManagedWidget ("editMenu", xmCascadeButtonGadgetClass,
menuBar, XmNsubMenuId, pulldown, NULL);
button = XtVaCreateManagedWidget ("cutMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
button = XtVaCreateManagedWidget ("copyMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
button = XtVaCreateManagedWidget ("pasteMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
// Create the help menu
pulldown = XmCreatePulldownMenu (menuBar, "pulldown", NULL, 0);
cascade = XtVaCreateManagedWidget ("helpMenu", xmCascadeButtonGadgetClass,
menuBar, XmNsubMenuId, pulldown, NULL);
button = XtVaCreateManagedWidget ("aboutMenuItem", xmPushButtonGadgetClass,
pulldown, NULL);
XtAddCallback (button, XmNactivateCallback, _doNothingCallback, (XtPointer)this);
XtVaSetValues (menuBar, XmNmenuHelpWidget, cascade, NULL);
// Manage the menubar
XtManageChild (menuBar);
// Create the work area
const int nargs = 8;
Arg args[nargs];
int n;
n = 0;
XtSetArg (args[n], XmNscrollingPolicy, XmAUTOMATIC); n++;
XtSetArg (args[n], XmNhighlightThickness, (Dimension)0); n++;
XtSetArg (args[n], XmNeditMode, XmMULTI_LINE_EDIT); n++;
XtSetArg (args[n], XmNeditable, True); n++;
XtSetArg (args[n], XmNwordWrap, False); n++;
XtSetArg (args[n], XmNcursorPositionVisible, True); n++;
XtSetArg (args[n], XmNverifyBell, True); n++;
assert (n <= nargs);
Widget scrolledText = XmCreateScrolledText (mainW, "scrolledText", args, n);
XtManageChild (scrolledText);
// Set the main window area
XtVaSetValues (mainW, XmNmenuBar, menuBar, XmNworkWindow,
XtParent (scrolledText), NULL);
XtManageChild (mainW);
}
// _newWindow
void MyDocument::_newWindow ( )
{
// Create a new document (this will leak, but who cares?)
MyDocument *newDoc = new MyDocument ("Document", _canvas);
// Add it to the canvas
_canvas->add (newDoc);
}
// _newWindowCallback
void MyDocument::_newWindowCallback (Widget, XtPointer clientData, XtPointer)
{
MyDocument *obj = (MyDocument*)clientData;
obj->_newWindow ( );
}
// _doNothingCallback
void MyDocument::_doNothingCallback (Widget w, XtPointer, XtPointer)
{
XBell (XtDisplayOfObject (w), 100);
}
/*
----------------------------------------------------------------------------
MyDocument2 class
*/
class MyDocument2 : public XsMotifWindow {
public:
// Constructor/Destructor
MyDocument2 (const char *name);
virtual ~MyDocument2 ( );
protected:
// This member function is called to create the document contents
virtual void _buildClientArea (Widget);
// Implementation
XsMDICanvas *_canvas;
MyDocument *_win1;
};
// Constructor
MyDocument2::MyDocument2 (const char *name) : XsMotifWindow (name)
{
_canvas = 0;
_win1 = 0;
}
// Destructor
MyDocument2::~MyDocument2 ( )
{
delete _canvas;
delete _win1;
}
// _buildClientArea
void MyDocument2::_buildClientArea (Widget parent)
{
assert (parent != 0);
// Create a nested MDI canvas
_canvas = new XsMDICanvas ("MDIinner", parent);
// Attach it up
XtVaSetValues (_canvas->base ( ), XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM, NULL);
// Create a document
_win1 = new MyDocument ("InnerWin", _canvas);
// Add the document to the canvas
_canvas->add (_win1);
// Show the canvas
_canvas->show ( );
}
/*
----------------------------------------------------------------------------
main
*/
static void _destroyCallback (Widget, XtPointer clientData, XtPointer)
{
Boolean *quit = (Boolean*)clientData;
*quit = True;
}
int main (int argc, char **argv)
{
XtAppContext appContext;
Widget topLevel;
Boolean quit = False;
// Initialize toolkit
topLevel = XtVaAppInitialize (&appContext, "MDI", NULL, 0, &argc, argv,
fallbacks, XmNdeleteResponse, XmDO_NOTHING, NULL);
Display *dpy = XtDisplay (topLevel);
// Add protocols
Atom WM_DELETE_WINDOW = XmInternAtom (dpy, "WM_DELETE_WINDOW", False);
XmAddWMProtocolCallback (topLevel, WM_DELETE_WINDOW, _destroyCallback,
&quit);
// Create the MDI canvas
XsMDICanvas *canvas = new XsMDICanvas ("MDItest", topLevel);
// Create the MDI documents
MyDocument *win1 = new MyDocument ("Document", canvas);
MyDocument2 *win2 = new MyDocument2 ("Document 2");
// Add documents to MDI canvas
canvas->add (win1);
canvas->add (win2);
// Show the canvas
canvas->show ( );
// Realize everything
XtRealizeWidget (topLevel);
// Let 'er rip
XEvent event;
while (!quit)
{
XtAppNextEvent (appContext, &event);
XtDispatchEvent (&event);
}
// Cleanup
delete win1;
delete win2;
delete canvas;
// Close the X connection
XtDestroyWidget (topLevel);
XtCloseDisplay (dpy);
XtDestroyApplicationContext (appContext);
return (0);
}

View File

@@ -0,0 +1,220 @@
Welcome to the ComboBox widget for Motif 1.1 or 1.2 (maybe even 2.0...)!
This is now version 1.32.
THERE ARE A LOT OF NEW RESOURCES AVAILABLE SO PLEASE READ THE
DOCUMENTATION (in ComboBox_eng.dvi)!!!
If you're in doubt, the primary source of this widget is
ftp.informatik.rwth-aachen.de (137.226.112.172)
The source is in: /pub/packages/ComboBox/ComboBox.tar.gz
This is our campus server in Aachen, Germany. From outside Europe
please also contact:
ftp.x.org (198.112.44.100)
There you'll find the source in:
/contrib/widgets/motif/ComboBox/ComboBox.tar.gz
There are many local ftp servers that mirror the /contrib directory. Thus
with a delay of one or two days you'll also find the source on many other
ftp sites.
PLEASE READ THIS INFORMATION CAREFULLY. IT ALWAYS CONTAINS THE MOST
RECENT INFORMATION.
Whats new? (changes since the last version are marked with an asterisk)
* Some minor changes concerning the drop down list layout have been made in
order to correct some minor quirks.
* Updated files for VMS users (hellooooo -- where are you?!!)
- A real man page for use with troff/groff. It's in ComboBox.groff.
- Some applications like GUI development tools or TclMotif were unable to
get notice of these special resources because they were implemented
through the core's setValues method. Thus they don't appeared in the
resource list because there aren't any instance variables connected to
them. These mirror resources instead belong to child widgets. With 1.23
the resource list (which can be queried by XtGetResourceList()) contains
entries for all mirror resources although the initial value setting is
always zero. But this should'nt matter. You can switch off these entries
by setting -DDONT_LOOK_IN_THE_MIRROR when compiling ComboBox.c.
- The selection policies XmSINGLE_SELECT and XmBROWSE_SELECT are now
supported.
- A new resource called XmNstaticList has been added, which switches the combo
box into a new mode with the drop down list statically displayed.
- Support of XmNautomaticSelection (like the resource known from XmList).
- New callbacks XmNunselectionCallback, XmNdefaultActionCallback,
XmNmodifyVerifyCallback, XmNmotionVerifyCallback and XmNvalueChangedCallback
added (don't know whether I forgot to mention one...).
- New convenience function XmComboBoxClearItemSelection() for deselecting
any selection in the combo box (if XmNselectionPolicy is XmSINGLE_SELECT).
- New demo app called FontSel. It shows how to realize a full blown
font selection dialog (even for scalable fonts) using combo boxes.
- Some additional casting has been added to the source, so it seems
now really to be ANSI compliant.
- can be compiled with Motif 1.2. (Tested on Sun & HP yet)
- many new resources & a callback that is called whenever the drop down
list gets dropped down or hidden.
- corrected a few minor typos in the header files (mis-spelled function
prototypes) and some minor quirks in the source.
- A FULL-BLOWN ENGLISH DOCUMENTATION (dvi file)
If you can't process dvi files you can download a post script variant
from ftp.informatik.rwth-aachen.de (137.226.112.172) as
/pub/packages/ComboBox/ComboBox_eng.ps.gz
- The XmNitems and XmNitemCount resources can now be set at any time (not
only when creating the ComboBox widget).
- Corrected some minor memory leaks in the source as well as some typos and
errors in the documentation.
- Drag'n'Drop is now supported with Motif 1.2.
- fvwm's handling of FocusOut events supported.
Well - if you never heard of ComboBoxes you'll have to figure out
yourself what these strange widgets really are. The following text
will only explain how to include it into your own code. (Just as a little
hint: combo boxes are well known from M$ Windoze. A combo box consists
of a text input field with an arrow button besides it. When you click
on the arrow button the combo box pops up a list just below its input
area. You can now browse in it or pop it down by pressing the arrow button
again.)
The source code is now in (wide public) use for nearly a year.
(before this time it was tested for half a year in the Institut fuer
Geometrie und Praktische Mathematik, where I'm working). So you get a well
tested piece of widget magic. Please feel free to report any trouble you
have using the ComboBox widget. But be patient - I'm just a student. In the
meantime I've received a couple of reports and hopefully the widget now can
be used on many well known systems as well as with Motif 1.1 and 1.2. I've
heard of people using the ComboBox widget with Motif 2.0, because they need
the many features... But there seems to be problems with the subclassing
mechanism, so the sanity check CheckComboBox() fails. This check is now
disabled if the source detects a Motif 2.0 release.
BTW - I'm collecting picture postcards...if you have one with a nice picture of
the place you're living in, don't hesitate... 8-)
1. To compile you will need at least Motif :-)
(or :-( depending on your point of view...)
and an *ANSI* c compiler (the code is completely ANSI -
no more mess with the old K&R style)!
To compile, try something like
$ cc -DFUNCPROTO -c ComboBox.c
this should do it's work. -DFUNCPROTO is needed because the function
prototypes would be K&R style without it. In addition you often need
to specify to the compiler that the source is ANSI. (-ansi with gcc)
2. Place a
#include "ComboBox.h"
at the top of your source file and create the widget just like any
other ordinary widget. The class is xmComboBoxWidgetClass. There is
no convenience function since it's hardly ever needed with this
widget.
To compile the short demo:
$ cc -DFUNCPROTO ComboBoxDemo.c -o ComboBoxDemo ComboBox.o \
-lXm -lXt -lX11
On some machines you'll need to link additional libs (like network
and socket libs).
Or use the makefile (first edit it accordingly to your needs):
$ make demo
Run the demo with:
$ ./ComboBoxDemo
I don't provide a makefile for every system/compiler combination
because this widget is intended to be placed seamless into the
existing Motif widget set. Thus, compile it and if all is ok, then
copy the includes to the Xm directory and the object file to a
suitable place in your file system -- but don't even think of
/dev/null as a good destination ;-)
To compile the FontSel demo:
Edit the makefile (if you haven't already done so), then do a:
$ make FontSel
And run the Font Selector demo:
$ ./FontSel
If you also have the ButtonFace Library you may want to do a
$ make FontSelX
instead. This will use my pictural push buttons for okay, cancel and help.
3. The ComboBox consists primarily of a XmManager descendant - the
widget you'll get from XtCreateWidget(). This widget contains several
more widgets as its childs: a XmTextField and some other widgets.
You *must* not modify any resources of the TextField directly - this
leads sooner or later to trouble. Instead all the necessary instance
variables of the TextField are accessible through the main widget
(the one XtCreateWidget() returned).
There are many (convenience) functions like the ones for XmTextFields
and XmLists to set the TextField's text, add items to the drop down
list and and and... please see ComboBox.h for details (you know:
the documentation is under work...)
4. There is one special resource called "persistentDropDown". It
defaults to "False". Its purpose it not easy to explain since that
has to do with the way your window manager is set up. If you're
using the explicit focus methode (that is: you move the keyboard
focus from application to application by clicking on the top level
window) you're lucky - don't ever think of this resource. For all
those other people (like me): if the window manager is set up to
give the keyboard focus to the top level window the mouse cursor
is over you'll notice one annoying "feature". (It's really *not*
a bug ;-) ) If you drop down the ComboBox's list (by clicking on
the arrow right beside the text field) and move the mouse cursor
out of the window the ComboBox resides in the list immediatly
disappears. That happens because the ComboBox looses the keyboard
focus. You can try to bypass that behavior by setting
"persistentDropDown" to "True" if you like. In the application's
resource file a line like
*YourApp*ComboBox.persistentDropDown: True
should do the job. But remember: whether this will work depends
on the window manager you're using. I have testet this with
Silicon Graphics' 4dwm (a mwm clone).
5. On some window managers the drop down list gets hidden as soon as
the user moves the mouse cursor into the list. If this happens try
to set the resource "twmHandlingOn" to "True". You can do this
on the command line:
ComboBoxDemo -xrm "*.twmHandlingOn: True"
This should do it's job with twm as well as fvwm. With olwm you shouldn't
need to set one of the special resources.
6. The combo box has been reported to run sucessfully on:
Silicon Graphics, Sun, HP, IBM RS6000, PC, even VMS!
Linux, of course...!
Attention VMS folks! You'll find two files called "motif11.opt" or
"motif12.opt" and "vmsmake.com" in this packages. They are provided by
Vincent Li. You'll hopefully know what to do with these two
files. They are provided "as is" with no warranty. Please read the file
"readme.vms".
42. Known bugs: you will need a german dictionary to understand all the
jokes in the source and in the german documentation.
That's it! Enjoy using this ComboBox widget.
(More than 160 downloads yet within the first 3 weeks -- seems that I've
filled in a real gap in Motif. Thanks to all who encouraged me to do
further work on the ComboBox widget -- especially Chris Marotz!)
You may also want to visit my "Motif Programming Cornor" at
file://ftp.igpm.rwth-aachen.de/arc/pub/unix/html/motifcorner.html
with tips & tricks about Motif.
I really don't understand why the folks at OSF didn't implemented
something like the M$ Windoze ComboBox in Motif. Maybe they have
had their moti"f"es... (Rumor has spread it that the mysterious
Motif 2.0 will have one - whow! after many years, the OSF folk got it!)
P.S.: This software is Free Software. Please refer to the file
COPYING, which you should have received together this
file and the source code of the combo box widget.
However if you find this widget to be usefull, you are encouraged
to donate a reasonable amount to a charitable institution --
there are enough people out there who need help! Sometimes I got
the strong impression that programmers tend to get lost in their
own "virtual reality" - sitting in front of their screen, hacking
new algorithms and forget about everything around them. So please
don't forget about people who need help.
(c) 1993, 1994 Harald Albrecht
Institut fuer Geometrie und Praktische Mathematik
Rheinisch-Westfaelische Technische Universitaet Aachen,
D-52056 Aachen, Germany
albrecht@igpm.rwth-aachen.de
Bad Aachen -- Die Stadt der Printe. Warum Aachen ein Kurbad ist?
-- Wieso Kurbad? "Bad" heisst doch nur, dass es hier staendig regnet (wenn
es eben 'mal nicht schneit...)

File diff suppressed because it is too large Load Diff

131
src/motif/xmcombo/combop.h Normal file
View File

@@ -0,0 +1,131 @@
/*
* ComboBoxP.h - Das schon lange schmerzlich vermisste Combo-Box-
* Widget -- nun endlich auf fuer Motif!
* Wahlweise Motif 1.1 oder 1.2.
*
* Letzte Modifikation: 04.10.1995 Revisionsstand: 1.32a
*
* (c) 1993, 1994 Harald Albrecht
* Institut fuer Geometrie und Praktische Mathematik
* RWTH Aachen, Germany
* albrecht@igpm.rwth-aachen.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see the file COPYING for more details);
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
*/
#ifndef __ComboBoxWidgetP_h
#define __ComboBoxWidgetP_h
#include "xmcombo.h"
#include <Xm/XmP.h>
#if (XmVersion > 1001) /* sounds like tales from 1000 and 1 night.... */
#include <Xm/ManagerP.h>
#endif
/*********************************************************************
* Klassendefinition
*********************************************************************/
/* Neue Datenfelder fuer den Klassenrecord der Center-Widgetklasse */
typedef struct _XmComboBoxClassPart {
int Just_to_keep_the_compiler_happy; /* Der Name ist Programm */
} XmComboBoxClassPart;
/*
* Nun folgt die vollstaendige Klassenstruktur, mit all' den Felder,
* die bereits von den Vorfahren geerbt wurden.
*/
typedef struct _XmComboBoxClassRec {
CoreClassPart core_class;
CompositeClassPart composite_class;
ConstraintClassPart constraint_class;
XmManagerClassPart manager_class;
XmComboBoxClassPart combobox_class;
} XmComboBoxClassRec;
extern XmComboBoxClassRec xmComboBoxClassRec;
/*********************************************************************
*Instanzdefinition
*********************************************************************/
typedef struct _XmComboBoxPart {
/* Resourcen ... hierauf darf von aussen zugegriffen werden! */
Boolean Editable; /* Editierbare Eingabezeile ? */
Boolean StaticList; /* Liste immer dargestellt? */
unsigned char SelectionPolicy; /* Was geht hier ab?! */
unsigned char ScrollBarDisplayPolicy;
unsigned char ListSizePolicy; /* Rollbalken! */
Boolean AutomaticSelection; /* Wann Callbacks aufrufen? */
Boolean Sorted; /* Liste sortiert */
XtCallbackList SortingCBL; /* Wie wird extern sortiert? */
int VisibleItemCount; /* Anz dargstellte Eintraege */
XmFontList Font; /* verwendete Fonts */
XtCallbackList SelectionCBL; /* Auswahl aus Liste */
XtCallbackList UnselectionCBL; /* Auswahl zurueckgenommen */
XtCallbackList DefaultActionCBL; /* bei Doppelklick */
XtCallbackList DropDownCBL; /* Liste angezeigt/versteckt */
XtCallbackList ModifyVerifyCBL; /* Vor Aenderung im Textfeld */
XtCallbackList ValueChangedCBL; /* Danach... */
XtCallbackList MotionVerifyCBL; /* Der Cursor bewegt sich doch*/
XtCallbackList ActivateCBL; /* Eingabe beendet? */
Boolean SquareArrow; /* Quadratischer Pfeil? */
Boolean ArrowSpacingOn; /* Abstand zw. Pfeil und Text */
Boolean Persistent; /* Liste & Focus-Out */
Boolean TwmHandlingOn; /* dto. */
Boolean ShowLabel; /* Label anzeigen? */
Position DropDownOffset; /* delta Ecke Eingabefeld,
Liste */
/* Ab hier wird's privat! */
Widget EditCtrl; /* Editorzeile */
Widget ArrowCtrl; /* Pfeil nach unten */
Widget LabelCtrl; /* Text links neben dem Eingabefeld */
Widget PopupShell; /* Shell, in der die Liste liegt */
Widget ListCtrl; /* Listenfeld */
Widget MyNextShell;
Cursor ArrowCursor;
Boolean InInit;
int LastSelection;
Boolean ListVisible;
Boolean IgnoreFocusOut;
Boolean PendingFocusOut;
Boolean PendingOverrideInOut;
XtWorkProcId WorkProcID;
XEvent xevent;
Boolean PassVerification;
Boolean ConvertBitmapToPixmap,
ConvertBitmapToPixmapInsensitive;
Pixmap LabelPixmap, LabelInsensitivePixmap;
XtPointer Dummy;
} XmComboBoxPart;
/*
* vollstaengige Instanzenstruktur
*/
typedef struct _XmComboBoxRec {
CorePart core;
CompositePart composite;
ConstraintPart constraint;
XmManagerPart manager;
XmComboBoxPart combobox;
} XmComboBoxRec;
#endif
/* Ende von ComboBoxP.h */

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

214
src/motif/xmcombo/demo.c Normal file
View File

@@ -0,0 +1,214 @@
/*
* demo.c -- Example how to use a ComboBox
*
* compile and link with:
* $ cc -DFUNCPROTO ComboBoxDemo.c ComboBox.o -o ComboBoxDemo \
* -lXm -lXt -lX11
* then run:
* $ ./ComboBoxDemo
*
* (c) 1993, 1994 Harald Albrecht
* Institut fuer Geometrie und Praktische Mathematik
* RWTH Aachen, Germany
* albrecht@igpm.rwth-aachen.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see the file COPYING for more details);
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
*/
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/Separator.h>
#include <Xm/PushB.h>
#include "combobox.h"
Widget TopLevel, Form, Button, Text, Sepp, ComboBox1, ComboBox2, ComboBox3, Label;
void QuitCB(Widget w, caddr_t pClientData, caddr_t pCallData)
{
char *text;
text = XmComboBoxGetString(ComboBox1);
fprintf(stderr, "You choosed \"%s\" out of the first ComboBox\n", text);
XtFree(text);
text = XmComboBoxGetString(ComboBox2);
fprintf(stderr, "You entered \"%s\" into the second ComboBox\n", text);
XtFree(text);
fprintf(stderr, "Bye! ... have fun with XmComboBox!\n");
exit(0);
} /* QuitCB */
int main(int argc, String argv[])
{
XmString str;
Boolean Trav;
XtAppContext AppContext;
#if (XmREVISION > 1)
XtSetLanguageProc(NULL,NULL,NULL);
#endif
TopLevel = XtAppInitialize(&AppContext, "XFontSelDemo", NULL, 0,
#if (XmREVISION > 1)
&argc,
#else
(Cardinal *) &argc,
#endif
argv, NULL, NULL, 0);
Form = XtVaCreateManagedWidget("form", xmFormWidgetClass, TopLevel, NULL);
str = XmStringCreateLtoR("Click to quit", XmSTRING_DEFAULT_CHARSET);
Button = XtVaCreateManagedWidget("quit", xmPushButtonWidgetClass, Form,
XmNlabelString, str,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 8,
XmNtopAttachment, XmATTACH_FORM,
XmNtopOffset, 8,
NULL);
XmStringFree(str);
XtAddCallback(Button, XmNactivateCallback, (XtCallbackProc) QuitCB, NULL);
Sepp = XtVaCreateManagedWidget("separator1", xmSeparatorWidgetClass, Form,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopOffset, 8,
XmNtopWidget, Button,
NULL);
str = XmStringCreateLtoR("Choose one:", XmSTRING_DEFAULT_CHARSET);
ComboBox1 = XtVaCreateManagedWidget("combobox1", xmComboBoxWidgetClass, Form,
XmNeditable, False,
XmNsorted, True,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 8,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 8,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopOffset, 8,
XmNtopWidget, Sepp,
XmNshowLabel, True,
XmNlabelString, str,
NULL);
XmStringFree(str);
/* Put string unordered into the combo box! They'll get sorted
* by the box.
*/
str = XmStringCreateLtoR("William the conquerior", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Karl der Gro\337e", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Henry VIII & his chicken band", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Louis XIV", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Louis de Funes", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Helmut Kohl", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("James Major", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("James Bond", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Billy Boy (M$ Windoze)", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Francois Mitterand", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox1, str, 0);
XmComboBoxSelectItem(ComboBox1, str, False);
XmStringFree(str);
str = XmStringCreateLtoR("Choose/edit:", XmSTRING_DEFAULT_CHARSET);
ComboBox2 = XtVaCreateManagedWidget("combobox2", xmComboBoxWidgetClass, Form,
XmNeditable, True,
XmNsorted, True,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 8,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 8,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopOffset, 8,
XmNtopWidget, ComboBox1,
XmNshowLabel, True,
XmNlabelString, str,
NULL);
str = XmStringCreateLtoR("item can be edited after choosing it", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("just to fill the list", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("so it contains more entries", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox2, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Static ComboBox:", XmSTRING_DEFAULT_CHARSET);
ComboBox3 = XtVaCreateManagedWidget("combobox3", xmComboBoxWidgetClass, Form,
XmNeditable, True,
XmNstaticList, True,
XmNsorted, False,
XmNcolumns, 30,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 8,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 8,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopOffset, 8,
XmNtopWidget, ComboBox2,
XmNshowLabel, True,
XmNlabelString, str,
NULL);
XmStringFree(str);
str = XmStringCreateLtoR("ComboBox (noneditable)", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("ComboBox (editable)", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("ComboBox (editable & static List)", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("Center widget", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
str = XmStringCreateLtoR("The ButtonFace Library", XmSTRING_DEFAULT_CHARSET);
XmComboBoxAddItem(ComboBox3, str, 0); XmStringFree(str);
Sepp = XtVaCreateManagedWidget("separator", xmSeparatorWidgetClass, Form,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopOffset, 8,
XmNtopWidget, ComboBox3,
NULL);
str = XmStringCreateLtoR(
"xmComboBoxWidgetClass Demo\n\nby Harald Albrecht\n\n\
albrecht@igpm.rwth-aachen.de", XmSTRING_DEFAULT_CHARSET);
Label = XtVaCreateManagedWidget("label", xmLabelWidgetClass, Form,
XmNlabelString, str,
XmNleftAttachment, XmATTACH_FORM,
XmNleftOffset, 80,
XmNrightAttachment, XmATTACH_FORM,
XmNrightOffset, 80,
XmNbottomAttachment, XmATTACH_FORM,
XmNbottomOffset, 24,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, Sepp,
XmNtopOffset, 24,
NULL);
XmStringFree(str);
XtRealizeWidget(TopLevel);
XtAppMainLoop(AppContext);
return 0; /* Never will reach this */
} /* main */
/* End of ComboBoxDemo.c */

3543
src/motif/xmcombo/xmcombo.c Normal file

File diff suppressed because it is too large Load Diff

223
src/motif/xmcombo/xmcombo.h Normal file
View File

@@ -0,0 +1,223 @@
/*
* ComboBox.h - Das schon lange schmerzlich vermisste Combo-Box-
* Widget -- nun endlich auf fuer Motif!
*
* Letzte Modifikation: 04.10.1995 Revisionsstand: 1.32a
*
* (c) 1993, 1994 Harald Albrecht
* Institut fuer Geometrie und Praktische Mathematik
* RWTH Aachen, Germany
* albrecht@igpm.rwth-aachen.de
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (see the file COPYING for more details);
* if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
* Cambridge, MA 02139, USA.
*
*/
#ifndef __ComboBoxWidget_h
#define __ComboBoxWidget_h
#include <Xm/Xm.h>
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#define XmNselectionCallback "selectionCallback"
#define XmCSelectionCallback "SelectionCallback"
#define XmNunselectionCallback "unselectionCallback"
#define XmCUnselectionCallback "UnselectionCallback"
#define XmNdropDownCallback "dropDownCallback"
#define XmCDropDownCallback "DropDownCallback"
#define XmNdropDownCursor "dropDownCursor"
#define XmCDropDownCursor "DropDownCursor"
/* ICH GLAUB' ES JA EINFACH NICHT! DIESE @#$!%^ BEI DER OSF HABEN
* DOCH TATSAECHLICH VERGESSEN, DASS DIE EINTRAEGE IN DER LISTBOX
* VIELLEICHT AUCH SORTIERT SEIN SOLLEN -- MUSS MAN DENN ALLES
* SELBST MACHEN?!
*/
#define XmNsorted "sorted"
#define XmCSorted "Sorted"
#define XmNsortingCallback "sortingCallback"
#define XmCSortingCallback "SortingCallback"
#define XmNstaticList "staticList"
#define XmCStaticList "StaticList"
#define XmNsquareArrow "squareArrow"
#define XmCSquareArrow "SquareArrow"
#define XmNarrowSpacingOn "arrowSpacingOn"
#define XmCArrowSpacingOn "ArrowSpacingOn"
/*
* Wie verhaeltsich die Liste, wenn der Focus verloren geht, sobald
* der Mauszeiger aus dem Dialog herausbewegt wird?
*/
#define XmNpersistentDropDown "persistentDropDown"
#define XmCPersistentDropDown "PersistentDropDown"
#define XmNtwmHandlingOn "twmHandlingOn"
#define XmCTwmHandlingOn "TwmHandlingOn"
/*
* alles fuer das Label...
*/
#define XmNshowLabel "showLabel"
#define XmCShowLabel "ShowLabel"
#define XmNdropDownOffset "dropDownOffset"
#define XmCDropDownOffset "DropDownOffset"
#define XmNlabelMarginBottom "labelMarginBottom"
#define XmCLabelMarginBottom "LabelMarginBottom"
#define XmNlabelMarginHeight "labelMarginHeight"
#define XmCLabelMarginHeight "LabelMarginHeight"
#define XmNlabelMarginLeft "labelMarginLeft"
#define XmCLabelMarginLeft "LabelMarginLeft"
#define XmNlabelMarginRight "labelMarginRight"
#define XmCLabelMarginRight "LabelMarginRight"
#define XmNlabelMarginTop "labelMarginTop"
#define XmCLabelMarginTop "LabelMarginTop"
#define XmNlabelMarginWidth "labelMarginWidth"
#define XmCLabelMarginWidth "LabelMarginWidth"
/* Callback reasons: (part. predefined)
*
* XmCR_SINGLE_SELECT user selected item in the list
*/
typedef struct {
int reason; /* Grund */
XEvent *event; /* Ausloesender Event */
XmString value; /* Ausgewaehlter Eintrag */
int index; /* Index dieses Eintrages */
} XmComboBoxSelectionCallbackStruct,XmComboBoxDefaultActionCallbackStruct;
typedef struct {
int reason;
XEvent *event;
Boolean doit;
Position currInsert, newInsert;
Position startPos, endPos;
XmTextBlock text;
} XmComboBoxTextVerifyCallbackStruct, *XmComboBoxTextVerifyPtr;
/* Callback reasons: new
*
* XmCR_SHOW_LIST list is dropping down
* XmCR_HIDE_LIST list is getting hidden
*
* XmCR_UNSELECT unselecting item from list or osfDelete
*/
#define XmCR_SHOW_LIST 4200 /* ten times "42", that should */
#define XmCR_HIDE_LIST 4201 /* explain everything of live... */
#define XmCR_UNSELECT 4202
typedef struct {
int reason; /* Grund */
XEvent *event; /* Ausloesender Event */
} XmComboBoxDropDownCallbackStruct, XmComboBoxUnselectionCallbackStruct;
#define XmCR_SORTING 4203
#define XmOP_INIT 1
#define XmOP_DONE 2
#define XmOP_COMPARE 3
typedef struct {
int reason;
XEvent *event; /* IMMER NULL!! */
int operation;
void *item_internal;
XmString item;
int result;
} XmComboBoxSortingCallbackStruct, *XmComboBoxSortingPtr;
/* Alle Funktionen, um auf die Liste der Combo-Box zuzugreifen.
* Bitte immer diese Funktionen dazu benutzen und nicht direkt
* auf das entsprechende Widget in der Combo-Box zugreifen!
* Aus diesem Grunde sind auch nicht alle Funktionen einer Listbox
* verfuegbar, da sich einige Funktionen mit der Verwaltung der
* Combo-Box beissen wuerden.
*/
extern void XmComboBoxAddItem(Widget w, XmString item, int pos);
extern void XmComboBoxAddItems(Widget w, XmString *items, int item_count, int pos);
extern void XmComboBoxAddItemUnselected(Widget w, XmString item, int pos);
extern void XmComboBoxDeleteItem(Widget w, XmString item);
extern void XmComboBoxDeleteItems(Widget w, XmString *items, int item_count);
extern void XmComboBoxDeletePos(Widget w, int pos);
extern void XmComboBoxDeleteItemsPos(Widget w, int item_count, int pos);
extern void XmComboBoxDeleteAllItems(Widget w);
extern void XmComboBoxReplaceItems(Widget w, XmString *old_items, int item_count, XmString *new_items);
extern void XmComboBoxReplaceItemsPos(Widget w, XmString *new_items, int item_count, int position);
extern Boolean XmComboBoxItemExists(Widget w, XmString item);
extern int XmComboBoxItemPos(Widget w, XmString item);
extern Boolean XmComboBoxGetMatchPos(Widget w, XmString item, int **pos_list, int *pos_count);
extern void XmComboBoxSelectPos(Widget w, int pos, Boolean notify);
extern void XmComboBoxSelectItem(Widget w, XmString item, Boolean notify);
/* Etwas anders als bei der Listbox, da es sowieso nur einen ausge-
* waehlten Eintrag in der Listbox geben kann!
* Liefert Index des ausgewaehlten Eintrages oder 0.
*/
extern int XmComboBoxGetSelectedPos(Widget w);
extern void XmComboBoxClearItemSelection(Widget w);
/*
* Nun alle Funktionen, die auf das Eingabefeld zugreifen...
* Auch hier gilt wieder, es gibt 'was auf die Finger, wenn jemand
* versucht, direkt auf das Eingabefeld direkt zuzugreifen!
*/
extern void XmComboBoxClearSelection(Widget w, Time time);
extern Boolean XmComboBoxCopy(Widget w, Time time);
extern Boolean XmComboBoxCut(Widget w, Time time);
extern XmTextPosition XmComboBoxGetInsertionPosition(Widget w);
extern XmTextPosition XmComboBoxGetLastPosition(Widget w);
extern int XmComboBoxGetMaxLength(Widget w);
extern char * XmComboBoxGetSelection(Widget w);
extern Boolean XmComboBoxGetSelectionPosition(Widget w, XmTextPosition *left,
XmTextPosition *right);
extern char * XmComboBoxGetString(Widget w);
extern void XmComboBoxInsert(Widget w, XmTextPosition position, char *value);
extern Boolean XmComboBoxPaste(Widget w);
extern Boolean XmComboBoxRemove(Widget w);
extern void XmComboBoxReplace(Widget w, XmTextPosition from_pos,
XmTextPosition to_pos, char *value);
extern void XmComboBoxSetAddMode(Widget w, Boolean state);
extern void XmComboBoxSetHighlight(Widget w, XmTextPosition left,
XmTextPosition right, XmHighlightMode mode);
extern void XmComboBoxSetInsertionPosition(Widget w, XmTextPosition position);
extern void XmComboBoxSetMaxLength(Widget w, int max_length);
extern void XmComboBoxSetSelection(Widget w, XmTextPosition first,
XmTextPosition last, Time time);
extern void XmComboBoxSetString(Widget w, char *value);
extern void XmComboBoxShowPosition(Widget w, XmTextPosition position);
extern WidgetClass xmComboBoxWidgetClass; /* Die Klasse hoechstselbst */
#ifndef XmIsComboBox
#define XmIsComboBox(w) XtIsSubclass(w, xmComboBoxWidgetClass)
#endif /* XmIsComboBox */
typedef struct _XmComboBoxClassRec *XmComboBoxWidgetClass;
typedef struct _XmComboBoxRec *XmComboBoxWidget;
extern Widget XmCreateComboBox(Widget parent, String name, ArgList arglist,
Cardinal argcount);
/* PLEASE do not use this functions if you really not need to do so !!! */
extern Widget XmComboBoxGetEditWidget(Widget w);
extern Widget XmComboBoxGetListWidget(Widget w);
extern Widget XmComboBoxGetLabelWidget(Widget w);
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif /* __ComboBoxWidget_h */
/* Ende von ComboBox.h */

View File

@@ -258,7 +258,7 @@ $(COMMDIR)/y_tab.$(OBJSUFF): $(COMMDIR)/y_tab.c $(COMMDIR)/lex_yy.c
# problems with lex_yy.c. See also note about LEX_SCANNER
# above.
$(COMMDIR)/lex_yy.c: $(COMMDIR)/lexer.l
$(LEX) $(COMMDIR)/lexer.l > $(COMMDIR)/lex_yy.c
$(LEX) -o$(COMMDIR)/lex_yy.c $(COMMDIR)/lexer.l
# sed -e "s/BUFSIZ/5000/g" < lex.yy.c | \
# sed -e "s/yyoutput(c)/void yyoutput(c)/g" | \