src/zlib/*.mms
include/wx/*.h
+include/wx/*.cpp
include/wx/protocol/*.h
include/wx/*.cpp
include/wx/wx_setup.vms
tidied up in wxApp so that events are filtered through ProcessXEvent.
- wxWindow::GetUpdateRegion should now work.
+25/11/98
+--------
+
+- Reimplemented MDI using wxNotebook instead of the MDI widgets, which
+ were too buggy (probably not design for dynamic addition/removal of
+ child frames).
+- Some improvements to the wxNotebook implementation.
+- wxToolBar now uses a bulletin board instead of a form, in an attempt
+ to make it possible to add ordinary wxControls to a toolbar.
+- Cured problem with not being able to use global memory operators,
+ by defining two more global operators, so that the delete will match
+ the debugging implementation.
+- Added wxUSE_DEBUG_NEW_ALWAYS so we can distinguish between using
+ global memory operators (usually OK) and #defining new to be
+ WXDEBUG_NEW (sometimes it might not be OK).
+- Added time.cpp to makefile; set wxUSE_DATETIME to 1.
+- Added a parent-existance check to popup menu code to make it not crash.
+- Added some optimization in wxWindow::SetSize to produce less flicker.
+ It remains to be seen whether this produces any resize bugs.
\ No newline at end of file
NOTE: only a few samples have up-to-date makefiles, e.g.
minimal, docview, mdi. The utils makefile does not yet work.
-Gnu-Win32 b19/Mingw32 compilation
+Gnu-Win32 b19/b20/Mingw32 compilation
---------------------------------
-wxWindows 2.0 supports Gnu-Win32 b19, Mingw32, and Mingw32/EGCS.
+wxWindows 2.0 supports Gnu-Win32/Cygwin b19, b20, Mingw32, and Mingw32/EGCS.
Thanks are due to Keith Garry Boyce (garp@opustel.com) and Cygnus for making
it all possible.
-From wxWindows 2.0 beta 9, both Gnu-Win32 b19 and Mingw32 (the minimal
+From wxWindows 2.0 beta 9, both Gnu-Win32 and Mingw32 (the minimal
distribution of Gnu-Win32) can be used with the same makefiles.
Here are the steps required:
- install.exe doesn't have built-in decompression because lzexpand.lib
isn't available with Gnu-Win32. However, you can use it with external
decompression utilities.
-- Doesn't compile socket-related files due to a syntax error in
- GnuWin32's Sockets.h.
- Doesn't compile src/msw/ole files, so no drag and drop.
References:
void ClearTabs(bool deleteTabs = TRUE);
+ bool SetTabText(int id, const wxString& label);
+ wxString GetTabText(int id) const;
+
// Layout tabs (optional, e.g. if resizing window)
void Layout(void);
#undef new
#endif
+// Added JACS 25/11/98: needed for some compilers
+void * operator new (size_t size);
+void * operator new[] (size_t size);
+
void * operator new (size_t size, char * fileName, int lineNum);
void operator delete (void * buf);
virtual void ChangeForegroundColour();
virtual wxRect GetAvailableClientSize();
+ // Implementation: calculate the layout of the view rect
+ // and resize the children if required
+ bool RefreshLayout(bool force = TRUE);
+
protected:
// common part of all ctors
void Init();
// NOW MANDATORY: don't change.
#define wxUSE_MEMORY_TRACING 1
// If 1, enables debugging versions of wxObject::new and
- // wxObject::delete *IF* WXDEBUG is also defined.
+ // wxObject::delete *IF* __WXDEBUG__ is also defined.
// WARNING: this code may not work with all architectures, especially
// if alignment is an issue.
#define wxUSE_DEBUG_CONTEXT 1
// since you may well need to output
// an error log in a production
// version (or non-debugging beta)
-#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
+
+#define wxUSE_GLOBAL_MEMORY_OPERATORS 1
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors), set this to 0.
- // In wxMotif, causes an 'all bets are off'
- // memory error (generated by wxWindows)
+
+#define wxUSE_DEBUG_NEW_ALWAYS 1
+ // In debug mode, causes new to be defined to
+ // be WXDEBUG_NEW (see object.h).
+ // If this causes problems (e.g. link errors), set this to 0.
#define REMOVE_UNUSED_ARG 1
// Set this to 0 if your compiler can't cope
#define wxUSE_GADGETS 0
// Use gadgets where possible
-#define wxUSE_MDI_WIDGETS 1
- // Use Scott Sadler's MDI widgets (buggy).
- // If 0, uses normal frames.
-
-
+#define wxUSE_TIMEDATE 1
+ // Use time and date
/*
* Finer detail
*
int FindIndexForWidget(WXWidget w);
WXWidget FindWidgetForIndex(int index);
+ WXWidget GetTopWidget() const;
+ WXWidget GetClientWidget() const;
+ WXWidget GetMainWidget() const;
+
protected:
// List of widgets in the toolbar, indexed by tool index
wxList m_widgets;
#define wxUSE_DYNAMIC_CLASSES 1
// If 1, enables provision of run-time type information.
// NOW MANDATORY: don't change.
-#define wxUSE_MEMORY_TRACING 0
+#define wxUSE_MEMORY_TRACING 1
// If 1, enables debugging versions of wxObject::new and
// wxObject::delete *IF* __WXDEBUG__ is also defined.
// WARNING: this code may not work with all architectures, especially
// if alignment is an issue.
-#define wxUSE_DEBUG_CONTEXT 0
+#define wxUSE_DEBUG_CONTEXT 1
// If 1, enables wxDebugContext, for
// writing error messages to file, etc.
// If __WXDEBUG__ is not defined, will still use
// since you may well need to output
// an error log in a production
// version (or non-debugging beta)
-#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
+#define wxUSE_GLOBAL_MEMORY_OPERATORS 1
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors), set this to 0.
+#define wxUSE_DEBUG_NEW_ALWAYS 1
+ // In debug mode, causes new to be defined to
+ // be WXDEBUG_NEW (see object.h).
+ // If this causes problems (e.g. link errors), set this to 0.
+
// GnuWin32 (b19) can't copy with these operators.
#ifdef __GNUWIN32__
#undef wxUSE_GLOBAL_MEMORY_OPERATORS 1
int m_count;
};
-#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS
-// JACS: not necessary now that new can be defined globally
-//#ifndef WXDEBUG_NEW
-//#define WXDEBUG_NEW new(__FILE__,__LINE__)
-//#endif
+#ifdef __WXDEBUG__
+#ifndef WXDEBUG_NEW
+#define WXDEBUG_NEW new(__FILE__,__LINE__)
+#endif
+#else
+#define WXDEBUG_NEW new
+#endif
+
+// Redefine new to be the debugging version. This doesn't
+// work with all compilers, in which case you need to
+// use WXDEBUG_NEW explicitly if you wish to use the debugging version.
+
+#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
#define new new(__FILE__,__LINE__)
#endif
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors), set this to 0.
+#define wxUSE_DEBUG_NEW_ALWAYS 1
+ // In debug mode, causes new to be defined to
+ // be WXDEBUG_NEW (see object.h).
+ // If this causes problems (e.g. link errors), set this to 0.
+
#define REMOVE_UNUSED_ARG 1
// Set this to 0 if your compiler can't cope
// with omission of prototype parameters.
#include "wx/date.h"
-#ifdef __WXGTK__
+#if defined(__WXGTK__) || defined(__WXMOTIF__)
#include "mondrian.xpm"
#endif
#error This program must be compiled in debug mode.
#endif
+// Normally, new is automatically defined to be the
+// debugging version. If not, this does it.
+#if !defined(new) && defined(WXDEBUG_NEW)
+#define new WXDEBUG_NEW
+#endif
+
// Define a new application type
class MyApp: public wxApp
{ public:
MyFrame *frame = new MyFrame((wxFrame *) NULL);
// Give it an icon
-#ifdef __WXMSW__
- frame->SetIcon(wxIcon("mondrian"));
-#else
- frame->SetIcon(wxIcon(mondrian_xpm));
-#endif
+ frame->SetIcon(wxICON(mondrian));
// Make a menubar
wxMenu *file_menu = new wxMenu;
frame->Show(TRUE);
wxDebugContext::SetCheckpoint();
-// wxDebugContext::SetFile("debug.log");
wxString *thing = new wxString;
wxDate* date = new wxDate;
wxBitmapList::~wxBitmapList ()
{
-#ifdef __WXMSW__
-
+#if defined(__WXMSW__) || defined(__WXMOTIF__)
wxNode *node = First ();
while (node)
{
// Pen and Brush lists
wxPenList::~wxPenList ()
{
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXMOTIF__)
wxNode *node = First ();
while (node)
{
wxBrushList::~wxBrushList ()
{
-#ifdef __WXMSW__
+#if defined(__WXMSW__) || defined(__WXMOTIF__)
wxNode *node = First ();
while (node)
{
case wxLOG_Trace:
case wxLOG_Debug:
#ifdef __WXDEBUG__
- DoLogString(str << (level == wxLOG_Trace ? _("Trace") : _("Debug"))
- << ": " << szString);
+ // DoLogString(str << (level == wxLOG_Trace ? _("Trace") : _("Debug"))
+ // << ": " << szString);
+ // JACS: we don't really want to prefix with 'Debug'. It's just extra
+ // verbiage.
+ DoLogString(szString);
#endif
break;
OutputDebugString(strTime + szString + "\n\r");
#else
// send them to stderr
+ /*
fprintf(stderr, "%s %s: %s\n",
strTime.c_str(),
level == wxLOG_Trace ? _("Trace") : _("Debug"),
szString);
+ */
+ fprintf(stderr, "%s\n",
+ szString);
fflush(stderr);
#endif
}
#endif
}
+// Added JACS 25/11/98
+void * operator new (size_t size)
+{
+#ifdef NO_DEBUG_ALLOCATION
+ return malloc(size);
+#else
+ return wxDebugAlloc(size, NULL, 0, FALSE);
+#endif
+}
+
+void * operator new[] (size_t size)
+{
+#ifdef NO_DEBUG_ALLOCATION
+ return malloc(size);
+#else
+ return wxDebugAlloc(size, NULL, 0, FALSE, TRUE);
+#endif
+}
+
#if !( defined (_MSC_VER) && (_MSC_VER <= 1020) )
void * operator new[] (size_t size, char * fileName, int lineNum)
{
#ifndef yywrap
#define yywrap() 1
#endif
-#else if !defined(__alpha) && !defined(__ultrix)
+#else if !defined(__alpha___) && !defined(__ultrix)
int yywrap() { return 1; }
#endif
#endif
int wxString::PrintfV(const char* pszFormat, va_list argptr)
{
-#ifdef __BORLANDC__
+#if defined(__BORLANDC__) || defined(__GNUWIN32__)
static char s_szScratch[1024];
int iLen = vsprintf(s_szScratch, pszFormat, argptr);
-rem Cygnus Gnu-Win32 environment variables
-rem Assumes that compiler and wxWindows are installed on the g: drive.
-rem
-set WXWIN=d:\wx2
-path C:\WINDOWS;C:\WINDOWS\COMMAND;g:\gnuwin32\b19\H-i386-cygwin32\bin;g:\gnuwin32\b19\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2-970404;c:\bin;g:\gnuwin32\b19\tcl\bin
-set GCC_EXEC_PREFIX=G:\gnuwin32\b19\H-i386-cygwin32\lib\gcc-lib\
-set RCINCLUDE=%WXWIN\include
-set CPLUS_INCLUDE_PATH=/g/gnuwin32/b19/h-i386-cygwin32/i386-cygwin32/include:/g/gnuwin32/b19/include/g++:/g/gnuwin32/b19/H-i386-cygwin32/lib/gcc-lib/i386-cygwin32/cygnus-2.7.2-970404/include:/d/wx2/include:/g/gnuwin32/b19/include/g++
-set MAKE_MODE=unix
-mount G: /g
-mount D: /d
-
+@ECHO OFF
+SET MAKE_MODE=UNIX
+rem SET PATH=g:\GNUWIN32\B20\CYGWIN~1\H-I586~1\BIN;%PATH%
+PATH C:\WINDOWS;C:\WINDOWS\command;g:\GNUWIN32\B20\CYGWIN~1\H-I586~1\BIN;d:\wx\utils\tex2rtf\bin;g:\ast\astex;g:\ast\emtex\bin;g:\cvs;c:\bin
+set BISON_SIMPLE=g:\gnuwin32\b20\cygwin-b20\share\bison.simple
+set BISON_HAIRY=g:\gnuwin32\b20\cygwin-b20\share\bison.hairy
+rem bash
rem 4DOS users only...
unalias make
alias makegnu make -f makefile.g95
bool
-wxExtHelpController::LoadFile(const wxString& ifile = "")
+wxExtHelpController::LoadFile(const wxString& ifile)
{
wxString mapFile, file, url, doc;
int id,i,len;
file = ifile;
if(! wxIsAbsolutePath(file))
{
- file = wxGetWorkingDirectory();
+ char* f = wxGetWorkingDirectory();
+ file = f;
+ delete[] f; // wxGetWorkingDirectory returns new memory
file << WXEXTHELP_SEPARATOR << ifile;
}
else
dc.GetTextExtent(GetLabel(), &textWidth, &textHeight);
int textX = (int)(tabX + (GetWidth() - textWidth)/2.0);
+ if (textX < (tabX + 2))
+ textX = (tabX + 2);
+
+ dc.SetClippingRegion(tabX, tabY, GetWidth(), GetHeight());
dc.DrawText(GetLabel(), textX, textY);
+ dc.DestroyClippingRegion();
if (m_isSelected)
{
m_tabSelection = -1;
delete tab;
delete tabNode;
+ m_noTabs --;
// The layout has changed
Layout();
}
return FALSE;
}
+
+bool wxTabView::SetTabText(int id, const wxString& label)
+{
+ wxTabControl* control = FindTabControlForId(id);
+ if (!control)
+ return FALSE;
+ control->SetLabel(label);
+ return TRUE;
+}
+
+wxString wxTabView::GetTabText(int id) const
+{
+ wxTabControl* control = FindTabControlForId(id);
+ if (!control)
+ return wxEmptyString;
+ else
+ return control->GetLabel();
+}
// Returns the total height of the tabs component -- this may be several
// times the height of a tab, if there are several tab layers (rows).
delete layerNode;
layerNode = nextLayerNode;
}
+ m_noTabs = 0;
}
// Draw all tabs
void wxTabView::Draw(wxDC& dc)
{
+ // Don't draw anything if there are no tabs.
+ if (GetNumberOfTabs() == 0)
+ return;
+
// Draw top margin area (beneath tabs and above view area)
if (GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR)
{
########################## Compiler flags #############################
# Misc options
-OPTIONS = -D__WXDEBUG__ # -DDEBUG='$(DEBUG)' # -DWXDEBUG
+OPTIONS = -D__WXDEBUG__
COPTIONS =
DEBUGFLAGS = -ggdb
INCLUDE =
{
Pixmap myStipple;
- oldStipple = NULL; // For later reset!!
+ oldStipple = (wxBitmap*) NULL; // For later reset!!
switch (m_currentFill)
{
return StartDrawingOnTop(& rect);
}
-bool wxScreenDC::StartDrawingOnTop(wxRect* rect = NULL)
+bool wxScreenDC::StartDrawingOnTop(wxRect* rect)
{
if (sm_overlayWindow)
return FALSE;
if (!(height == -1 && width == -1))
{
PreResize();
+ /* JACS: not sure if this is necessary
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
+ */
}
}
if (!m_frameShell)
return;
- // TODO
- /*
if (!icon.Ok() || !icon.GetPixmap())
return;
- XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon->.GetPixmap(), NULL);
- */
+ XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL);
}
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
../common/textfile.cpp \
../common/tbarbase.cpp \
../common/tbarsmpl.cpp \
+ ../common/time.cpp \
../common/timercmn.cpp \
../common/utilscmn.cpp \
../common/wincmn.cpp \
void wxMDIChildFrame::SetTitle(const wxString& title)
{
m_title = title;
- // TODO: set parent frame title
+ wxMDIClientWindow* clientWindow = GetMDIParentFrame()->GetClientWindow();
+ int pageNo = clientWindow->FindPagePosition(this);
+ if (pageNo > -1)
+ clientWindow->SetPageText(pageNo, title);
}
// MDI operations
// m_windowParent = parent;
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
- return wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
+ bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
+ if (success)
+ {
+ wxFont font(10, wxSWISS, wxNORMAL, wxNORMAL);
+ wxFont selFont(10, wxSWISS, wxNORMAL, wxBOLD);
+ GetTabView()->SetTabFont(font);
+ GetTabView()->SetSelectedTabFont(selFont);
+ GetTabView()->SetTabSize(120, 18);
+ GetTabView()->SetTabSelectionHeight(20);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
oldChild->GetEventHandler()->ProcessEvent(event);
}
}
- wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
- if (activeChild)
+ if (event.GetSelection() != -1)
{
+ wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
+ if (activeChild)
+ {
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
event.SetEventObject( activeChild );
activeChild->GetEventHandler()->ProcessEvent(event);
activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
}
+ }
}
event.Skip();
}
wxMenu *menu = (wxMenu *)clientData;
if (menu->GetMainWidget()) {
- wxList& list = menu->GetParent()->GetItems();
- list.DeleteObject(menu);
+ if (menu->GetParent())
+ {
+ wxList& list = menu->GetParent()->GetItems();
+ list.DeleteObject(menu);
+ }
menu->DestroyMenu(TRUE);
}
/* Mark as no longer popped up */
wxNotebookPage* pPage = GetPage(nPage);
m_tabView->SetTabSelection((int) (long) pPage);
- // ChangePage(m_nSelection, nPage);
// TODO
return 0;
{
wxASSERT( IS_VALID_PAGE(nPage) );
- // TODO
+ wxNotebookPage* page = GetPage(nPage);
+ if (page)
+ {
+ m_tabView->SetTabText((int) (long) page, strText);
+ Refresh();
+ return TRUE;
+ }
+
return FALSE;
}
{
wxASSERT( IS_VALID_PAGE(nPage) );
- // TODO
- return wxString("");
+ wxNotebookPage* page = ((wxNotebook*)this)->GetPage(nPage);
+ if (page)
+ return m_tabView->GetTabText((int) (long) page);
+ else
+ return wxEmptyString;
}
int wxNotebook::GetPageImage(int nPage) const
m_nSelection = -1;
m_tabView->SetTabSelection(-1, FALSE);
}
- else if (m_nSelection > 0)
+ else if (m_nSelection > -1)
{
m_nSelection = -1;
m_tabView->SetTabSelection((int) (long) GetPage(0), FALSE);
- ChangePage(-1, 0);
+ if (m_nSelection != 0)
+ ChangePage(-1, 0);
}
+ RefreshLayout(FALSE);
+
return TRUE;
}
{
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
- if (m_nSelection != -1)
- {
- m_aPages[m_nSelection]->Show(FALSE);
- m_aPages[m_nSelection]->Lower();
- }
+ m_aPages[nPage]->Show(FALSE);
+ // m_aPages[nPage]->Lower();
wxNotebookPage* pPage = GetPage(nPage);
m_tabView->RemoveTab((int) (long) pPage);
if (m_aPages.GetCount() == 0)
{
m_nSelection = -1;
- m_tabView->SetTabSelection(-1, FALSE);
+ m_tabView->SetTabSelection(-1, TRUE);
}
- else if (m_nSelection > 0)
+ else if (m_nSelection > -1)
{
- m_nSelection = -1;
- m_tabView->SetTabSelection((int) (long) GetPage(0), FALSE);
- ChangePage(-1, 0);
+ // Only change the selection if the page we
+ // deleted was the selection.
+ if (nPage == m_nSelection)
+ {
+ m_nSelection = -1;
+ // Select the first tab. Generates a ChangePage.
+ m_tabView->SetTabSelection((int) (long) GetPage(0), TRUE);
+ }
+ else
+ {
+ // We must adjust which tab we think is selected.
+ // If greater than the page we deleted, it must be moved down
+ // a notch.
+ if (m_nSelection > nPage)
+ m_nSelection -- ;
+ }
}
+ RefreshLayout(FALSE);
+
return TRUE;
}
if ( m_nSelection == -1 )
ChangePage(-1, 0);
+ RefreshLayout(FALSE);
+
return TRUE;
}
s_bFirstTime = FALSE;
}
+ RefreshLayout();
+
+ // Processing continues to next OnSize
+ event.Skip();
+}
+
+// Implementation: calculate the layout of the view rect
+// and resize the children if required
+bool wxNotebook::RefreshLayout(bool force)
+{
if (m_tabView)
{
+ wxRect oldRect = m_tabView->GetViewRect();
+
int cw, ch;
GetClientSize(& cw, & ch);
m_tabView->SetViewRect(rect);
m_tabView->Layout();
- /*
- // emulate page change (it's esp. important to do it first time because
- // otherwise our page would stay invisible)
- int nSel = m_nSelection;
- m_nSelection = -1;
- SetSelection(nSel);
- */
+
+ if (!force && (rect == oldRect))
+ return FALSE;
// fit the notebook page to the tab control's display area
}
Refresh();
}
-
- // Processing continues to next OnSize
- event.Skip();
+ return TRUE;
}
void wxNotebook::OnSelChange(wxNotebookEvent& event)
{
// is it our tab control?
if ( event.GetEventObject() == this )
- ChangePage(event.GetOldSelection(), event.GetSelection());
+ {
+ if (event.GetSelection() != m_nSelection)
+ ChangePage(event.GetOldSelection(), event.GetSelection());
+ }
// we want to give others a chance to process this message as well
event.Skip();
// hide the currently active panel and show the new one
void wxNotebook::ChangePage(int nOldSel, int nSel)
{
+ // cout << "ChangePage: " << nOldSel << ", " << nSel << "\n";
wxASSERT( nOldSel != nSel ); // impossible
if ( nOldSel != -1 ) {
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget toolbar = XtVaCreateManagedWidget("toolbar",
- xmFormWidgetClass, parentWidget,
+ xmBulletinBoardWidgetClass, (Widget) parentWidget,
+ XmNmarginWidth, 0,
+ XmNmarginHeight, 0,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
+/*
+ Widget toolbar = XtVaCreateManagedWidget("toolbar",
+ xmFormWidgetClass, (Widget) m_clientWidget,
XmNtraversalOn, False,
XmNhorizontalSpacing, 0,
XmNverticalSpacing, 0,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
NULL);
+*/
m_mainWidget = (WXWidget) toolbar;
DestroyPixmaps();
}
+bool wxToolBar::CreateTools()
+{
+ if (m_tools.Number() == 0)
+ return FALSE;
+
+ // Separator spacing
+ const int separatorSize = GetToolSeparation(); // 8;
+ wxSize margins = GetToolMargins();
+ int marginX = margins.x;
+ int marginY = margins.y;
+
+ int currentX = marginX;
+ int currentY = marginY;
+
+ int buttonHeight = 0;
+
+ int currentSpacing = 0;
+
+ m_widgets.Clear();
+ Widget prevButton = (Widget) 0;
+ wxNode* node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+
+ if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
+ currentX += separatorSize;
+ else if (tool->m_bitmap1.Ok())
+ {
+ Widget button = (Widget) 0;
+
+ if (tool->m_isToggle)
+ {
+ button = XtVaCreateWidget("toggleButton",
+ xmToggleButtonWidgetClass, (Widget) m_mainWidget,
+ XmNx, currentX, XmNy, currentY,
+ // XmNpushButtonEnabled, True,
+ XmNmultiClick, XmMULTICLICK_KEEP,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
+ (XtPointer) this);
+ }
+ else
+ {
+ button = XtVaCreateWidget("button",
+ xmPushButtonWidgetClass, (Widget) m_mainWidget,
+ XmNx, currentX, XmNy, currentY,
+ XmNpushButtonEnabled, True,
+ XmNmultiClick, XmMULTICLICK_KEEP,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ XtAddCallback (button,
+ XmNactivateCallback, (XtCallbackProc) wxToolButtonCallback,
+ (XtPointer) this);
+ }
+
+ // For each button, if there is a mask, we must create
+ // a new wxBitmap that has the correct background colour
+ // for the button. Otherwise the background will just be
+ // e.g. black if a transparent XPM has been loaded.
+ wxBitmap originalBitmap = tool->m_bitmap1;
+
+ if (tool->m_bitmap1.GetMask())
+ {
+ int backgroundPixel;
+ XtVaGetValues(button, XmNbackground, &backgroundPixel,
+ NULL);
+
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ wxBitmap newBitmap = wxCreateMaskedBitmap(tool->m_bitmap1, col);
+
+ tool->m_bitmap1 = newBitmap;
+ }
+
+ // Create a selected/toggled bitmap. If there isn't a m_bitmap2,
+ // we need to create it (with a darker, selected background)
+ int backgroundPixel;
+ if (tool->m_isToggle)
+ XtVaGetValues(button, XmNselectColor, &backgroundPixel,
+ NULL);
+ else
+ XtVaGetValues(button, XmNarmColor, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ if (tool->m_bitmap2.Ok() && tool->m_bitmap2.GetMask())
+ {
+ // Use what's there
+ wxBitmap newBitmap = wxCreateMaskedBitmap(tool->m_bitmap2, col);
+ tool->m_bitmap2 = newBitmap;
+ }
+ else
+ {
+ // Use unselected bitmap
+ if (originalBitmap.GetMask())
+ {
+ wxBitmap newBitmap = wxCreateMaskedBitmap(originalBitmap, col);
+ tool->m_bitmap2 = newBitmap;
+ }
+ else
+ tool->m_bitmap2 = tool->m_bitmap1;
+ }
+
+ Pixmap pixmap = (Pixmap) tool->m_bitmap1.GetPixmap();
+ Pixmap insensPixmap = (Pixmap) tool->m_bitmap1.GetInsensPixmap();
+
+ if (tool->m_isToggle)
+ {
+ // Toggle button
+ Pixmap pixmap2 = (Pixmap) 0;
+ Pixmap insensPixmap2 = (Pixmap) 0;
+
+ // If there's a bitmap for the toggled state, use it,
+ // otherwise generate one.
+ if (tool->m_bitmap2.Ok())
+ {
+ pixmap2 = (Pixmap) tool->m_bitmap2.GetPixmap();
+ insensPixmap2 = (Pixmap) tool->m_bitmap2.GetInsensPixmap();
+ }
+ else
+ {
+ pixmap2 = (Pixmap) tool->m_bitmap1.GetArmPixmap(button);
+ insensPixmap2 = XCreateInsensitivePixmap((Display*) wxGetDisplay(), pixmap2);
+ m_pixmaps.Append((wxObject*) insensPixmap2); // Store for later deletion
+ }
+ XtVaSetValues (button,
+ XmNindicatorOn, False,
+ XmNshadowThickness, 2,
+ // XmNborderWidth, 0,
+ // XmNspacing, 0,
+ XmNmarginWidth, 0,
+ XmNmarginHeight, 0,
+ XmNfillOnSelect, True,
+ XmNlabelPixmap, pixmap,
+ XmNselectPixmap, pixmap2,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNselectInsensitivePixmap, insensPixmap2,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ }
+ else
+ {
+ Pixmap pixmap2 = (Pixmap) 0;
+
+ // If there's a bitmap for the armed state, use it,
+ // otherwise generate one.
+ if (tool->m_bitmap2.Ok())
+ {
+ pixmap2 = (Pixmap) tool->m_bitmap2.GetPixmap();
+ }
+ else
+ {
+ pixmap2 = (Pixmap) tool->m_bitmap1.GetArmPixmap(button);
+
+ }
+ // Normal button
+ XtVaSetValues(button,
+ XmNlabelPixmap, pixmap,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNarmPixmap, pixmap2,
+ NULL);
+ }
+ XtManageChild(button);
+
+ Dimension width, height;
+ XtVaGetValues(button, XmNwidth, & width, XmNheight, & height,
+ NULL);
+ currentX += width + marginX;
+ buttonHeight = wxMax(buttonHeight, height);
+
+ XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
+ False, wxToolButtonPopupCallback, (XtPointer) this);
+ m_widgets.Append(tool->m_index, (wxObject*) button);
+
+ prevButton = button;
+ currentSpacing = 0;
+ }
+ node = node->Next();
+ }
+
+ SetSize(-1, -1, currentX, buttonHeight + 2*marginY);
+
+ return TRUE;
+}
+
+// Old version, assuming we use a form. Now we use
+// a bulletin board, so we can create controls on the toolbar.
+#if 0
bool wxToolBar::CreateTools()
{
if (m_tools.Number() == 0)
return TRUE;
}
+#endif
void wxToolBar::SetToolBitmapSize(const wxSize& size)
{
return (WXWidget) node->Data();
}
+WXWidget wxToolBar::GetTopWidget() const
+{
+ return m_mainWidget;
+}
+
+WXWidget wxToolBar::GetClientWidget() const
+{
+ return m_mainWidget;
+}
+
+WXWidget wxToolBar::GetMainWidget() const
+{
+ return m_mainWidget;
+}
+
+
void wxToolButtonCallback (Widget w, XtPointer clientData,
XtPointer ptr)
{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#ifdef VMS
/*steve*/
void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
{
+ // A bit of optimization to help sort out the flickers.
+ int oldX, oldY, oldW, oldH;
+ GetSize(& oldW, & oldH);
+ GetPosition(& oldX, & oldY);
+
+ bool useOldPos = FALSE;
+ bool useOldSize = FALSE;
+
+ if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
+ useOldPos = TRUE;
+ else if (x == oldX && y == oldY)
+ useOldPos = TRUE;
+
+ if ((width == -1) && (height == -1))
+ useOldSize = TRUE;
+ else if (width == oldW && height == oldH)
+ useOldSize = TRUE;
+
+ if (useOldPos && useOldSize)
+ return;
+
if (m_drawingArea)
{
CanvasSetSize(x, y, width, height, sizeFlags);
int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags);
- if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- XtVaSetValues(widget, XmNx, xx, NULL);
- if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- XtVaSetValues(widget, XmNy, yy, NULL);
- if (width > -1)
- XtVaSetValues(widget, XmNwidth, width, NULL);
- if (height > -1)
- XtVaSetValues(widget, XmNheight, height, NULL);
+ if (!useOldPos)
+ {
+ if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ XtVaSetValues(widget, XmNx, xx, NULL);
+ if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ XtVaSetValues(widget, XmNy, yy, NULL);
+ }
+ if (!useOldSize)
+ {
+ if (width > -1)
+ XtVaSetValues(widget, XmNwidth, width, NULL);
+ if (height > -1)
+ XtVaSetValues(widget, XmNheight, height, NULL);
+ }
if (managed)
XtManageChild(widget);
+ // How about this bit. Maybe we don't need to generate size events
+ // all the time -- they'll be generated when the window is sized anyway.
+ /*
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
+ */
}
void wxWindow::SetClientSize(int width, int height)
// SetSize, but as per old wxCanvas (with drawing widget etc.)
void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
{
+ // A bit of optimization to help sort out the flickers.
+ int oldX, oldY, oldW, oldH;
+ GetSize(& oldW, & oldH);
+ GetPosition(& oldX, & oldY);
+
+ bool useOldPos = FALSE;
+ bool useOldSize = FALSE;
+
+ if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
+ useOldPos = TRUE;
+ else if (x == oldX && y == oldY)
+ useOldPos = TRUE;
+
+ if ((w == -1) && (h == -1))
+ useOldSize = TRUE;
+ else if (w == oldW && h == oldH)
+ useOldSize = TRUE;
+
+ if (useOldPos && useOldSize)
+ return;
+
Widget drawingArea = (Widget) m_drawingArea;
bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags);
- if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ if (!useOldPos)
+ {
+ if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
XmNx, xx, NULL);
}
- if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
XmNy, yy, NULL);
}
+ }
- if (w > -1)
+ if (!useOldSize)
+ {
+
+ if (w > -1)
{
if (m_borderWidget)
{
XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
}
+ }
+
if (managed)
XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+ /*
int ww, hh;
GetClientSize (&ww, &hh);
wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
+ */
+
}
void wxWindow::CanvasSetClientSize (int w, int h)
DoRefresh ();
*/
+ /*
wxSizeEvent sizeEvent(wxSize(w, h), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
+ */
}
void wxWindow::CanvasGetClientSize (int *w, int *h) const