Solved wxMotif scrolling display problem; added wxImageModule;

added wxRETAINED support in wxMotif; changed wxDC::SetBackground behaviour;
changed OnKeyDown/OnChar behaviour; fixed wxToolBar toggle bugs; fixed
wxImage on wxMotif bug whereby new was used to allocate XImage data


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1677 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1999-02-11 16:00:33 +00:00
parent b4b92fa660
commit a91b47e800
24 changed files with 353 additions and 288 deletions

View File

@@ -34,6 +34,7 @@ extern "C" {
#include "wx/filefn.h"
#include "wx/wfstream.h"
#include "wx/intl.h"
#include "wx/module.h"
#ifdef __SALFORDC__
#ifdef FAR
@@ -1957,7 +1958,7 @@ wxBitmap wxImage::ConvertToBitmap() const
wxBitmap bitmap;
wxCHECK_MSG( Ok(), bitmap, "invalid image" );
int width = GetWidth();
int height = GetHeight();
@@ -1971,10 +1972,10 @@ wxBitmap wxImage::ConvertToBitmap() const
// Create image
XImage *data_image = XCreateImage( dpy, vis, bpp, ZPixmap, 0, 0, width, height, 32, 0 );
data_image->data = new char[ data_image->bytes_per_line * data_image->height ];
data_image->data = (char*) malloc( data_image->bytes_per_line * data_image->height );
bitmap.Create( width, height, bpp );
/*
// Create mask
@@ -2012,7 +2013,7 @@ wxBitmap wxImage::ConvertToBitmap() const
}
XFree( vi );
if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15;
if (bpp < 8) bpp = 8;
@@ -2278,3 +2279,19 @@ wxImage::wxImage( const wxBitmap &bitmap )
*/
}
#endif
// A module to allow wxImage initialization/cleanup
// without calling these functions from app.cpp or from
// the user's application.
class wxImageModule: public wxModule
{
DECLARE_DYNAMIC_CLASS(wxImageModule)
public:
wxImageModule() {}
bool OnInit() { wxImage::InitStandardHandlers(); return TRUE; };
void OnExit() { wxImage::CleanUpHandlers(); };
};
IMPLEMENT_DYNAMIC_CLASS(wxImageModule, wxModule)

View File

@@ -40,6 +40,11 @@ IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxWindow)
#include "windows.h"
#endif
#ifdef __WXMOTIF__
// For wxRETAINED implementation
#include <Xm/Xm.h>
#endif
wxScrolledWindow::wxScrolledWindow(void)
{
m_xScrollPixelsPerLine = 0;
@@ -104,6 +109,39 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY,
m_yScrollPosition = yPos;
m_xScrollLines = noUnitsX;
m_yScrollLines = noUnitsY;
#ifdef __WXMOTIF__
// Sorry, some Motif-specific code to implement a backing pixmap
// for the wxRETAINED style. Implementing a backing store can't
// be entirely generic because it relies on the wxWindowDC implementation
// to duplicate X drawing calls for the backing pixmap.
if ((m_windowStyle & wxRETAINED) == wxRETAINED)
{
Display* dpy = XtDisplay((Widget) GetMainWidget());
int totalPixelWidth = m_xScrollLines * m_xScrollPixelsPerLine;
int totalPixelHeight = m_yScrollLines * m_yScrollPixelsPerLine;
if (m_backingPixmap &&
!((m_pixmapWidth == totalPixelWidth) &&
(m_pixmapHeight == totalPixelHeight)))
{
XFreePixmap (dpy, (Pixmap) m_backingPixmap);
m_backingPixmap = (WXPixmap) 0;
}
if (!m_backingPixmap &&
(noUnitsX != 0) && (noUnitsY != 0))
{
int depth = wxDisplayDepth();
m_pixmapWidth = totalPixelWidth;
m_pixmapHeight = totalPixelHeight;
m_backingPixmap = (WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
m_pixmapWidth, m_pixmapHeight, depth);
}
}
#endif
AdjustScrollbars();

View File

@@ -538,10 +538,11 @@ WXColormap wxApp::GetMainColormap(WXDisplay* display)
{
if (!display) /* Must be called first with non-NULL display */
return m_mainColormap;
int defaultScreen = DefaultScreen((Display*) display);
Screen* screen = XScreenOfDisplay((Display*) display, defaultScreen);
Colormap c =
DefaultColormapOfScreen(XScreenOfDisplay((Display*) display,
DefaultScreen((Display*) display)));
Colormap c = DefaultColormapOfScreen(screen);
if (!m_mainColormap)
m_mainColormap = (WXColormap) c;

View File

@@ -37,6 +37,8 @@ About pens, brushes, and the autoSetting flag:
#include "wx/dcmemory.h"
#include "wx/window.h"
#include "wx/app.h"
#include "wx/image.h"
#include <math.h>
#include <Xm/Xm.h>
@@ -144,6 +146,8 @@ wxWindowDC::wxWindowDC( wxWindow *window )
XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
m_oldFont = (WXFont) valReturn.font;
SetBackground(wxBrush(m_window->GetBackgroundColour(), wxSOLID));
};
wxWindowDC::~wxWindowDC(void)
@@ -935,8 +939,41 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
// last selected background color. [::SetBackground]
if (m_pen.Ok() && m_autoSetting)
SetPen (m_pen);
if (m_pixmap && sourceDC->m_pixmap)
// Do bitmap scaling if necessary
wxBitmap *scaledBitmap = (wxBitmap*) NULL;
Pixmap sourcePixmap = (Pixmap) NULL;
double scaleX, scaleY;
GetUserScale(& scaleX, & scaleY);
// Sorry, can't scale masks just yet
if (!useMask && (scaleX != 1.0 || scaleY != 1.0) && sourceDC->IsKindOf(CLASSINFO(wxMemoryDC)))
{
wxMemoryDC* memDC = (wxMemoryDC*) sourceDC;
wxBitmap& bitmap = memDC->GetBitmap();
wxASSERT_MSG( (bitmap.Ok()), "Bad source bitmap in wxWindowDC::Blit");
wxImage image(bitmap);
if (!image.Ok())
{
sourcePixmap = (Pixmap) bitmap.GetPixmap();
}
else
{
int scaledW = (int) (bitmap.GetWidth() * scaleX);
int scaledH = (int) (bitmap.GetHeight() * scaleY);
image = image.Scale(scaledW, scaledH);
scaledBitmap = new wxBitmap(image.ConvertToBitmap());
sourcePixmap = (Pixmap) scaledBitmap->GetPixmap();
}
}
else
sourcePixmap = (Pixmap) sourceDC->m_pixmap;
if (m_pixmap && sourcePixmap)
{
/* MATTHEW: [9] */
int orig = m_logicalFunction;
@@ -949,7 +986,7 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
if (m_window && m_window->GetBackingPixmap())
XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display,
(Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),
(Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),
(GC) m_gcBacking,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
@@ -969,7 +1006,7 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
}
}
XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
@@ -990,7 +1027,7 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
// +++ MARKUS (mho@comnets.rwth-aachen): error on blitting bitmaps with depth 1
if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && ((wxMemoryDC*) source)->GetBitmap().GetDepth() == 1)
{
XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
@@ -999,7 +1036,7 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
}
else
{
XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
@@ -1022,7 +1059,7 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
if (source->IsKindOf(CLASSINFO(wxMemoryDC)) &&
((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1))
{
XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
XCopyPlane ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
@@ -1031,7 +1068,7 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
}
else
{
XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
XCopyArea ((Display*) m_display, (Pixmap) sourcePixmap, (Pixmap) m_pixmap, (GC) m_gc,
source->LogicalToDeviceX (xsrc),
source->LogicalToDeviceY (ysrc),
source->LogicalToDeviceXRel(width),
@@ -1050,9 +1087,13 @@ bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
CalcBoundingBox (xdest + width, ydest + height);
SetLogicalFunction(orig);
if (scaledBitmap) delete scaledBitmap;
return TRUE;
}
if (scaledBitmap) delete scaledBitmap;
return FALSE;
};
@@ -1878,10 +1919,14 @@ void wxWindowDC::SetBackground( const wxBrush &brush )
return;
int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
// New behaviour, 10/2/99: setting the background brush of a DC
// doesn't affect the window background colour.
/*
// XSetWindowBackground doesn't work for non-Window pixmaps
if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
*/
// Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
// And Blit,... (Any fct that use XCopyPlane, in fact.)

View File

@@ -649,9 +649,7 @@ static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent
if (event -> xexpose.count == 0)
{
wxPaintEvent event(win->GetId());
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
win->DoPaint();
win->ClearUpdateRects();
}
@@ -699,8 +697,16 @@ static void wxDialogBoxEventHandler (Widget wid,
}
else
{
keyEvent.SetEventType(wxEVT_CHAR);
dialog->GetEventHandler()->ProcessEvent(keyEvent);
// For simplicity, OnKeyDown is the same as OnChar
// TODO: filter modifier key presses from OnChar
keyEvent.SetEventType(wxEVT_KEY_DOWN);
// Only process OnChar if OnKeyDown didn't swallow it
if (!dialog->GetEventHandler()->ProcessEvent (keyEvent))
{
keyEvent.SetEventType(wxEVT_CHAR);
dialog->GetEventHandler()->ProcessEvent(keyEvent);
}
}
}
}

View File

@@ -19,6 +19,7 @@
#include "wx/filedlg.h"
#include "wx/intl.h"
#include "wx/app.h"
#include "wx/settings.h"
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
@@ -142,6 +143,38 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
m_pos = pos;
}
static void wxChangeListBoxColours(wxWindow* win, Widget widget)
{
win->DoChangeBackgroundColour((WXWidget) widget, *wxWHITE);
// Change colour of the scrolled areas of the listboxes
Widget listParent = XtParent (widget);
win->DoChangeBackgroundColour((WXWidget) listParent, *wxWHITE, TRUE);
Widget hsb = (Widget) 0;
Widget vsb = (Widget) 0;
XtVaGetValues (listParent,
XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
*/
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
win->DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
win->DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
if (hsb)
XtVaSetValues (hsb,
XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)),
NULL);
if (vsb)
XtVaSetValues (vsb,
XmNtroughColor, backgroundColour.AllocColour(XtDisplay(vsb)),
NULL);
}
int wxFileDialog::ShowModal()
{
wxBeginBusyCursor();
@@ -157,6 +190,15 @@ int wxFileDialog::ShowModal()
Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
Widget dirListWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_DIR_LIST);
Widget fileListWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_LIST);
Widget okWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_OK_BUTTON);
Widget applyWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_APPLY_BUTTON);
Widget cancelWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_CANCEL_BUTTON);
Widget shell = XtParent(fileSel);
@@ -180,7 +222,6 @@ int wxFileDialog::ShowModal()
if (entirePath != "")
{
Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
}
@@ -192,7 +233,6 @@ int wxFileDialog::ShowModal()
else
filter = m_wildCard;
Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
XmTextSetString(filterWidget, (char*) (const char*) filter);
XmFileSelectionDoSearch(fileSel, NULL);
}
@@ -229,9 +269,21 @@ int wxFileDialog::ShowModal()
XmNresizePolicy, XmRESIZE_NONE,
NULL);
#endif
DoChangeBackgroundColour((WXWidget) fileSel, m_backgroundColour);
DoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE);
DoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE);
/* For some reason this crashes
DoChangeBackgroundColour((WXWidget) okWidget, m_backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) cancelWidget, m_backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) applyWidget, m_backgroundColour, TRUE);
*/
wxChangeListBoxColours(this, dirListWidget);
wxChangeListBoxColours(this, fileListWidget);
XtManageChild(fileSel);
m_fileSelectorAnswer = "";
m_fileSelectorReturned = FALSE;

View File

@@ -760,8 +760,8 @@ void wxListBox::ChangeBackgroundColour()
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
*/
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);

View File

@@ -201,14 +201,19 @@ $(WXLIB) : $(OBJECTS)
# problems with lex_yy.c. See also note about LEX_SCANNER
# above.
../common/lex_yy.c: ../common/lexer.l
$(LEX) -o../common/lex.yy.c ../common/lexer.l
sed -e "s/BUFSIZ/5000/g" < ../common/lex.yy.c | \
$(LEX) ../common/lexer.l
sed -e "s/BUFSIZ/5000/g" < lex.yy.c | \
sed -e "s/yyoutput(c)/void yyoutput(c)/g" | \
sed -e "s/YYLMAX 200/YYLMAX 5000/g" > ../common/lex_yy.c
/bin/rm -f ../common/lex.yy.c
/bin/rm -f lex.yy.c
# N.B. if you have lex instead of flex, replace the $(LEX) line above
# with the following:
# The above should work with both lex and flex, but just in case not,
# here are alternative syntaxes.
#
# Flex-style syntax:
# $(LEX) -olex.yy.c ../common/lexer.l
# Lex-style syntax:
# $(LEX) ../common/lexer.l
# Replace yacc with bison if you run into compilation

View File

@@ -167,6 +167,10 @@ bool wxToolBar::CreateTools()
NULL);
XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
(XtPointer) this);
XtVaSetValues ((Widget) button,
XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
NULL);
}
else
{
@@ -318,190 +322,6 @@ bool wxToolBar::CreateTools()
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 FALSE;
// Separator spacing
const int separatorSize = GetToolSeparation(); // 8;
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)
currentSpacing = separatorSize;
else if (tool->m_bitmap1.Ok())
{
Widget button = (Widget) 0;
if (tool->m_isToggle)
{
button = XtVaCreateManagedWidget("toggleButton",
xmToggleButtonWidgetClass, (Widget) m_mainWidget,
XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET,
XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton,
XmNleftOffset, currentSpacing,
XmNtopAttachment, XmATTACH_FORM,
// XmNpushButtonEnabled, True,
XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP,
NULL);
XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
(XtPointer) this);
}
else
{
button = XtVaCreateManagedWidget("button",
xmPushButtonWidgetClass, (Widget) m_mainWidget,
XmNleftAttachment, (prevButton == (Widget) 0) ? XmATTACH_FORM : XmATTACH_WIDGET,
XmNleftWidget, (prevButton == (Widget) 0) ? NULL : prevButton,
XmNleftOffset, currentSpacing,
XmNtopAttachment, XmATTACH_FORM,
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);
}
XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
False, wxToolButtonPopupCallback, (XtPointer) this);
m_widgets.Append(tool->m_index, (wxObject*) button);
prevButton = button;
currentSpacing = 0;
}
node = node->Next();
}
return TRUE;
}
#endif
void wxToolBar::SetToolBitmapSize(const wxSize& size)
{
// TODO not necessary?
@@ -605,7 +425,7 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit
else
tool->m_y = m_yMargin;
wxSize& size = GetToolSize();
wxSize size = GetToolSize();
tool->SetSize(size.x, size.y);
m_tools.Append((long)index, tool);
@@ -663,7 +483,7 @@ void wxToolButtonCallback (Widget w, XtPointer clientData,
return;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if (tool->m_isToggle)
tool->m_toggleState = toolBar->GetToolState(index);
tool->m_toggleState = !tool->m_toggleState;
(void) toolBar->OnLeftClick(index, tool->m_toggleState);
}

View File

@@ -27,6 +27,7 @@
#include "wx/settings.h"
#include "wx/msgdlg.h"
#include "wx/frame.h"
#include "wx/scrolwin.h"
#include "wx/menuitem.h"
#include "wx/log.h"
@@ -114,6 +115,7 @@ wxWindow::wxWindow()
m_clientData = NULL;
/// Motif-specific
m_needsRefresh = TRUE;
m_mainWidget = (WXWidget) 0;
m_button1Pressed = FALSE;
m_button2Pressed = FALSE;
@@ -295,6 +297,7 @@ bool wxWindow::Create(wxWindow *parent, wxWindowID id,
m_clientData = NULL;
// Motif-specific
m_needsRefresh = TRUE;
m_canAddEventHandler = FALSE;
m_mainWidget = (WXWidget) 0;
m_button1Pressed = FALSE;
@@ -991,6 +994,7 @@ void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
{
m_needsRefresh = TRUE;
Display *display = XtDisplay((Widget) GetMainWidget());
Window thisWindow = XtWindow((Widget) GetMainWidget());
@@ -1477,11 +1481,13 @@ void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
delete rect;
node = node->Next();
}
XmUpdateDisplay((Widget) GetMainWidget());
}
void wxWindow::OnChar(wxKeyEvent& event)
{
event.Skip();
/* ??
if ( event.KeyCode() == WXK_TAB ) {
// propagate the TABs to the parent - it's up to it to decide what
@@ -1496,12 +1502,12 @@ return;
void wxWindow::OnKeyDown(wxKeyEvent& event)
{
Default();
event.Skip();
}
void wxWindow::OnKeyUp(wxKeyEvent& event)
{
Default();
event.Skip();
}
void wxWindow::OnPaint(wxPaintEvent& event)
@@ -2359,10 +2365,13 @@ void wxCanvasRepaintProc (Widget drawingArea, XtPointer clientData,
if (event -> xexpose.count == 0)
{
/*
wxPaintEvent event(win->GetId());
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
*/
win->DoPaint();
win->ClearUpdateRects();
}
break;
@@ -2617,10 +2626,6 @@ void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallba
wxEventType eventType = wxEVT_CHAR;
// TODO: Is this the correct criterion for wxEVT_KEY_DOWN down versus wxEVT_CHAR?
if (id > WXK_START) // Non-ASCII values
eventType = wxEVT_KEY_DOWN;
wxKeyEvent event (eventType);
if (local_event.xkey.state & ShiftMask)
@@ -2647,10 +2652,18 @@ void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallba
event.SetEventType(wxEVT_CHAR_HOOK);
if (parent->GetEventHandler()->ProcessEvent(event))
return;
event.SetEventType(wxEVT_CHAR);
}
canvas->GetEventHandler()->ProcessEvent (event);
// For simplicity, OnKeyDown is the same as OnChar
// TODO: filter modifier key presses from OnChar
event.SetEventType(wxEVT_KEY_DOWN);
// Only process OnChar if OnKeyDown didn't swallow it
if (!canvas->GetEventHandler()->ProcessEvent (event))
{
event.SetEventType(wxEVT_CHAR);
canvas->GetEventHandler()->ProcessEvent (event);
}
}
break;
}
@@ -2708,28 +2721,68 @@ void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallba
void wxWindow::DoPaint()
{
//TODO : make a temporary gc so we can do the XCopyArea below
if (0) // m_backingPixmap)
if (m_backingPixmap && !m_needsRefresh)
{
/*
Widget drawingArea = (Widget) m_drawingArea;
// int orig = GetDC()->GetLogicalFunction();
// GetDC()->SetLogicalFunction (wxCOPY);
wxPaintDC dc(this);
GC tempGC = (GC) dc.GetBackingGC();
Widget widget = (Widget) GetMainWidget();
int scrollPosX = 0;
int scrollPosY = 0;
// We have to test whether it's a wxScrolledWindow (hack!)
// because otherwise we don't know how many pixels have been
// scrolled. We might solve this in the future by defining
// virtual wxWindow functions to get the scroll position in pixels.
// Or, each kind of scrolled window has to implement backing
// stores itself, using generic wxWindows code.
if (this->IsKindOf(CLASSINFO(wxScrolledWindow)))
{
wxScrolledWindow* scrolledWindow = (wxScrolledWindow*) this;
int x, y;
scrolledWindow->CalcScrolledPosition(0, 0, & x, & y);
scrollPosX = - x;
scrollPosY = - y;
}
// TODO: This could be optimized further by only copying the
// areas in the current update region.
// Only blit the part visible in the client area. The backing pixmap
// always starts at 0, 0 but we may be looking at only a portion of it.
wxSize clientArea = GetClientSize();
int toBlitX = m_pixmapWidth - scrollPosX;
int toBlitY = m_pixmapHeight - scrollPosY;
// Copy whichever is samller, the amount of pixmap we have to copy,
// or the size of the client area.
toBlitX = wxMin(toBlitX, clientArea.x);
toBlitY = wxMin(toBlitY, clientArea.y);
// Make sure we're not negative
toBlitX = wxMax(0, toBlitX);
toBlitY = wxMax(0, toBlitY);
// TODO: it may not be necessary to store m_pixmapOffsetX/Y; we
// should be able to calculate them.
XCopyArea (XtDisplay (drawingArea), m_backingPixmap, XtWindow (drawingArea), GetDC ()->gc,
m_pixmapOffsetX, m_pixmapOffsetY,
m_pixmapWidth, m_pixmapHeight,
0, 0);
// GetDC()->SetLogicalFunction (orig);
*/
XCopyArea (XtDisplay (widget), (Pixmap) m_backingPixmap, XtWindow (widget), tempGC,
scrollPosX, scrollPosY, // Start at the scroll position
toBlitX, toBlitY, // How much of the pixmap to copy
0, 0); // Destination
}
else
{
// Set an erase event first
wxEraseEvent eraseEvent(GetId());
eraseEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(eraseEvent);
wxPaintEvent event(GetId());
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
m_needsRefresh = FALSE;
}
}

View File

@@ -808,7 +808,14 @@ void wxDC::SetBackground(const wxBrush& brush)
}
else
{
m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
// New behaviour, 10/2/99: setting the background brush of a DC
// doesn't affect the window background colour. However,
// I'm leaving in the transparency setting because it's needed by
// various controls (e.g. wxStaticText) to determine whether to draw
// transparently or not. TODO: maybe this should be a new function
// wxWindow::SetTransparency(). Should that apply to the child itself, or the
// parent?
// m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
m_canvas->m_backgroundTransparent = FALSE;
}
}

View File

@@ -49,6 +49,8 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
// m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
m_hDC = (WXHDC) ::GetWindowDC((HWND) the_canvas->GetHWND() );
m_hDCCount ++;
SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
}
wxWindowDC::~wxWindowDC(void)
@@ -77,6 +79,8 @@ wxClientDC::wxClientDC(wxWindow *the_canvas)
m_canvas = the_canvas;
// BeginDrawing();
m_hDC = (WXHDC) ::GetDC((HWND) the_canvas->GetHWND());
SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
}
wxClientDC::~wxClientDC(void)
@@ -128,6 +132,8 @@ wxPaintDC::wxPaintDC(wxWindow *canvas)
ms_PaintCount = 1;
m_hDCCount++;
}
SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
}
wxPaintDC::~wxPaintDC()

View File

@@ -279,7 +279,8 @@ $(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) $(COMMDIR)/lexer.l
mv lex.yy.c $(COMMDIR)/lex_yy.c
# The following may be required for FLEX
# $(LEX) -o$(COMMDIR)/lex_yy.c $(COMMDIR)/lexer.l

View File

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