From 321db4b6bf15df209942b9c0e6c744c8e7074d1b Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 23 Oct 1998 18:22:30 +0000 Subject: [PATCH] More Motif changes (colour/font stuff) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/motif/todo.txt | 17 +++- include/wx/motif/bitmap.h | 5 ++ include/wx/motif/bmpbuttn.h | 12 ++- include/wx/motif/radiobut.h | 6 -- include/wx/msw/wave.h | 5 ++ src/motif/bitmap.cpp | 21 +++++ src/motif/bmpbuttn.cpp | 161 ++++++++++++++++++++++++------------ src/motif/button.cpp | 6 +- src/motif/checkbox.cpp | 19 ++++- src/motif/choice.cpp | 39 ++++++++- src/motif/combobox.cpp | 7 +- src/motif/dialog.cpp | 1 + src/motif/gauge.cpp | 6 +- src/motif/listbox.cpp | 6 +- src/motif/radiobut.cpp | 67 +++------------ src/motif/slider.cpp | 6 +- src/motif/statbmp.cpp | 6 +- src/motif/statbox.cpp | 6 +- src/motif/stattext.cpp | 6 +- src/motif/textctrl.cpp | 6 +- src/motif/toolbar.cpp | 23 ------ src/motif/window.cpp | 4 - src/msw/wave.cpp | 18 ++++ 23 files changed, 273 insertions(+), 180 deletions(-) diff --git a/docs/motif/todo.txt b/docs/motif/todo.txt index 52eb135233..d2f81ce036 100644 --- a/docs/motif/todo.txt +++ b/docs/motif/todo.txt @@ -21,8 +21,16 @@ High Priority up a dialog, e.g. an About box. Widgets are arranged incorrectly. Seems to be OK for non-dialog panels, once the size has been restored after the font setting. + In fact it seems OK for dialogs now!!! Weird. -- Colour setting in widgets. +- ChangeFont should have an extra arg, to allow for not resizing + the window back to the original size after setting the font. + Also don't call SetFont from constructor, assign the font and + call ChangeFont so we can pass FALSE if the size has been passed + as the default (which means: wxWin should choose an appropriate + size, so Motif should expand/contract the widget as appropriate). + +- Colour setting in widgets (almost done). - Implementation of OnEraseBackground. How? Call OnEraseBackground just before OnPaint? Will duplicate Xlib's own erase of the background. @@ -33,8 +41,6 @@ High Priority painting a tiled bitmap, then a slight flicker might be seen unless X can be persuaded not to repaint the window background by default. -- wxBitmapCheckBox, wxBitmapRadioButton - - wxSpinButton - A generic version of wxNotebook that can be used in wxMotif and @@ -101,6 +107,8 @@ Low Priority - wxCheckBoxList +- wxBitmapCheckBox, wxBitmapRadioButton + - Reimplement combobox using Lesstif's widget (avoiding GPL'ed widget currently used). @@ -115,3 +123,6 @@ Low Priority - Could eventually alter the MDI widgets to be more Windows-like -- currently it's half-hearted. + +- Accelerators + diff --git a/include/wx/motif/bitmap.h b/include/wx/motif/bitmap.h index 1fc2e134e6..7d3801bd88 100644 --- a/include/wx/motif/bitmap.h +++ b/include/wx/motif/bitmap.h @@ -203,5 +203,10 @@ public: protected: static wxList sm_handlers; }; + +// Creates a bitmap with transparent areas drawn in +// the given colour. +wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour); + #endif // _WX_BITMAP_H_ diff --git a/include/wx/motif/bmpbuttn.h b/include/wx/motif/bmpbuttn.h index bb5ea2f503..66e0ed7713 100644 --- a/include/wx/motif/bmpbuttn.h +++ b/include/wx/motif/bmpbuttn.h @@ -63,11 +63,21 @@ class WXDLLEXPORT wxBitmapButton: public wxButton inline int GetMarginX() { return m_marginX; } inline int GetMarginY() { return m_marginY; } +// Implementation + void DoSetBitmap(); + virtual void ChangeBackgroundColour(); + protected: + wxBitmap m_buttonBitmapFocus; wxBitmap m_buttonBitmap; + wxBitmap m_buttonBitmapOriginal; // May be different from m_buttonBitmap + // if m_buttonBitmap has been changed + // to reflect button background colour wxBitmap m_buttonBitmapSelected; - wxBitmap m_buttonBitmapFocus; + wxBitmap m_buttonBitmapSelectedOriginal; + wxBitmap m_buttonBitmapDisabled; + wxBitmap m_buttonBitmapDisabledOriginal; int m_marginX; int m_marginY; diff --git a/include/wx/motif/radiobut.h b/include/wx/motif/radiobut.h index 80263ec117..15c4c8e789 100644 --- a/include/wx/motif/radiobut.h +++ b/include/wx/motif/radiobut.h @@ -52,12 +52,6 @@ public: virtual void ChangeFont(); virtual void ChangeBackgroundColour(); virtual void ChangeForegroundColour(); - WXWidget GetTopWidget() const { return m_formWidget; } - WXWidget GetLabelWidget() const { return m_labelWidget; } - -private: - WXWidget m_formWidget; - WXWidget m_labelWidget; }; // Not implemented diff --git a/include/wx/msw/wave.h b/include/wx/msw/wave.h index ce7e14fbe4..80426fc0bd 100644 --- a/include/wx/msw/wave.h +++ b/include/wx/msw/wave.h @@ -23,10 +23,15 @@ class wxWave : public wxObject public: wxWave(); wxWave(const wxString& fileName, bool isResource = FALSE); + wxWave(int size, const byte* data); ~wxWave(); public: + // Create from resource or file bool Create(const wxString& fileName, bool isResource = FALSE); + // Create from data + bool Create(int size, const byte* data); + bool IsOk() const { return (m_waveData ? TRUE : FALSE); }; bool Play(bool async = TRUE, bool looped = FALSE) const; diff --git a/src/motif/bitmap.cpp b/src/motif/bitmap.cpp index e2227b0c30..93eb32f732 100644 --- a/src/motif/bitmap.cpp +++ b/src/motif/bitmap.cpp @@ -20,6 +20,7 @@ #include "wx/icon.h" #include "wx/log.h" #include "wx/control.h" +#include "wx/dcmemory.h" #include @@ -1003,3 +1004,23 @@ static return ipixmap; } +// Creates a bitmap with transparent areas drawn in +// the given colour. +wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour) +{ + wxBitmap newBitmap(bitmap.GetWidth(), + bitmap.GetHeight(), + bitmap.GetDepth()); + wxMemoryDC destDC; + wxMemoryDC srcDC; + srcDC.SelectObject(bitmap); + destDC.SelectObject(newBitmap); + + wxBrush brush(colour, wxSOLID); + destDC.SetOptimization(FALSE); + destDC.SetBackground(brush); + destDC.Clear(); + destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE); + + return newBitmap; +} diff --git a/src/motif/bmpbuttn.cpp b/src/motif/bmpbuttn.cpp index e7d790bcf0..9f8f221f7b 100644 --- a/src/motif/bmpbuttn.cpp +++ b/src/motif/bmpbuttn.cpp @@ -42,6 +42,10 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit const wxString& name) { m_buttonBitmap = bitmap; + m_buttonBitmapOriginal = bitmap; + m_buttonBitmapSelected = bitmap; + m_buttonBitmapSelectedOriginal = bitmap; + SetName(name); SetValidator(validator); parent->AddChild(this); @@ -86,27 +90,9 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit m_mainWidget = (WXWidget) buttonWidget; - if (bitmap.Ok()) - { - Pixmap p1, p2; - - p1 = (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap(m_mainWidget); - p2 = (Pixmap) ((wxBitmap&)bitmap).GetInsensPixmap(m_mainWidget); + ChangeBackgroundColour (); - if(p1 == p2) // <- the Get...Pixmap()-functions return the same pixmap! - { - p2 = - XCreateInsensitivePixmap(DisplayOfScreen(XtScreen(buttonWidget)), p1); - m_insensPixmap = (WXPixmap) p2; - } - - XtVaSetValues (buttonWidget, - XmNlabelPixmap, p1, - XmNlabelInsensitivePixmap, p2, - XmNarmPixmap, (Pixmap) ((wxBitmap&)bitmap).GetArmPixmap (m_mainWidget), - XmNlabelType, XmPIXMAP, - NULL); - } + DoSetBitmap(); XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, (XtPointer) this); @@ -116,8 +102,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit SetFont(* parent->GetFont()); - ChangeBackgroundColour (); - return TRUE; } @@ -132,33 +116,116 @@ wxBitmapButton::~wxBitmapButton() void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap) { + m_buttonBitmapOriginal = bitmap; m_buttonBitmap = bitmap; - if (bitmap.Ok()) + DoSetBitmap(); +} + +void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel) +{ + m_buttonBitmapSelected = sel; + m_buttonBitmapSelectedOriginal = sel; + + DoSetBitmap(); +}; + +void wxBitmapButton::SetBitmapFocus(const wxBitmap& focus) +{ + m_buttonBitmapFocus = focus; + // Not used in Motif +}; + +void wxBitmapButton::SetBitmapDisabled(const wxBitmap& disabled) +{ + m_buttonBitmapDisabled = disabled; + m_buttonBitmapDisabledOriginal = disabled; + + DoSetBitmap(); +}; + +void wxBitmapButton::DoSetBitmap() +{ + if (m_buttonBitmapOriginal.Ok()) { - Pixmap labelPixmap, insensPixmap, armPixmap; + Pixmap pixmap = 0; + Pixmap insensPixmap = 0; + Pixmap armPixmap = 0; - labelPixmap = (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap(m_mainWidget); + // Must re-make the bitmap to have its transparent areas drawn + // in the current widget background colour. + if (m_buttonBitmapOriginal.GetMask()) + { + int backgroundPixel; + XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel, + NULL); + + wxColour col; + col.SetPixel(backgroundPixel); + + wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapOriginal, col); + m_buttonBitmap = newBitmap; - if (m_buttonBitmapSelected.Ok()) - armPixmap = (Pixmap) m_buttonBitmapSelected.GetLabelPixmap(m_mainWidget); + pixmap = (Pixmap) m_buttonBitmap.GetPixmap(); + } else - armPixmap = (Pixmap) ((wxBitmap&)bitmap).GetArmPixmap(m_mainWidget); + pixmap = (Pixmap) m_buttonBitmap.GetLabelPixmap(m_mainWidget); - if (m_buttonBitmapDisabled.Ok()) - insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetLabelPixmap(m_mainWidget); + if (m_buttonBitmapDisabledOriginal.Ok()) + { + if (m_buttonBitmapDisabledOriginal.GetMask()) + { + int backgroundPixel; + XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel, + NULL); + + wxColour col; + col.SetPixel(backgroundPixel); + + wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapDisabledOriginal, col); + m_buttonBitmapDisabled = newBitmap; + + insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetPixmap(); + } + else + insensPixmap = (Pixmap) m_buttonBitmap.GetInsensPixmap(m_mainWidget); + } else - insensPixmap = (Pixmap) ((wxBitmap&)bitmap).GetInsensPixmap(m_mainWidget); + insensPixmap = (Pixmap) m_buttonBitmap.GetInsensPixmap(m_mainWidget); - if (!insensPixmap || (insensPixmap == labelPixmap)) // <- the Get...Pixmap()-functions return the same pixmap! + // Now make the bitmap representing the armed state + if (m_buttonBitmapSelectedOriginal.Ok()) { - insensPixmap = XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), labelPixmap); + if (m_buttonBitmapSelectedOriginal.GetMask()) + { + int backgroundPixel; + XtVaGetValues((Widget) m_mainWidget, XmNarmColor, &backgroundPixel, + NULL); + + wxColour col; + col.SetPixel(backgroundPixel); + + wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapSelectedOriginal, col); + m_buttonBitmapSelected = newBitmap; + + armPixmap = (Pixmap) m_buttonBitmapSelected.GetPixmap(); + } + else + armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget); + } + else + armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget); + + if (insensPixmap == pixmap) // <- the Get...Pixmap()-functions return the same pixmap! + { + insensPixmap = + XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap); m_insensPixmap = (WXPixmap) insensPixmap; } XtVaSetValues ((Widget) m_mainWidget, - XmNlabelPixmap, labelPixmap, - XmNlabelInsensitivePixmap, insensPixmap, + XmNlabelPixmap, pixmap, + XmNlabelInsensitivePixmap, insensPixmap, XmNarmPixmap, armPixmap, XmNlabelType, XmPIXMAP, NULL); @@ -170,26 +237,16 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap) XtVaSetValues ((Widget) m_mainWidget, XmNlabelType, XmSTRING, XmNlabelPixmap, XmUNSPECIFIED_PIXMAP, - XmNlabelInsensitivePixmap, NULL, - XmNarmPixmap, NULL, + XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP, + XmNarmPixmap, XmUNSPECIFIED_PIXMAP, NULL); } } -void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel) +void wxBitmapButton::ChangeBackgroundColour() { - m_buttonBitmapSelected = sel; -}; - -void wxBitmapButton::SetBitmapFocus(const wxBitmap& focus) -{ - m_buttonBitmapFocus = focus; - // Not used in Motif -}; - -void wxBitmapButton::SetBitmapDisabled(const wxBitmap& disabled) -{ - m_buttonBitmapDisabled = disabled; -}; - + DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE); + // Must reset the bitmaps since the colours have changed. + DoSetBitmap(); +} diff --git a/src/motif/button.cpp b/src/motif/button.cpp index dccac3bfbb..6a402a0229 100644 --- a/src/motif/button.cpp +++ b/src/motif/button.cpp @@ -137,16 +137,16 @@ void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr) void wxButton::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxButton::ChangeBackgroundColour() { - // TODO + DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE); } void wxButton::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } diff --git a/src/motif/checkbox.cpp b/src/motif/checkbox.cpp index edf3f857fd..0c59e67684 100644 --- a/src/motif/checkbox.cpp +++ b/src/motif/checkbox.cpp @@ -153,16 +153,27 @@ void wxCheckBoxCallback (Widget w, XtPointer clientData, void wxCheckBox::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxCheckBox::ChangeBackgroundColour() { - // TODO + wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour, + (wxColour*) NULL); + + XtVaSetValues ((Widget) m_mainWidget, + XmNbackground, g_itemColors[wxBACK_INDEX].pixel, + XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel, + XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel, + XmNforeground, g_itemColors[wxFORE_INDEX].pixel, + NULL); + + XtVaSetValues ((Widget) m_mainWidget, + XmNselectColor, g_itemColors[wxSELE_INDEX].pixel, + NULL); } void wxCheckBox::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } - diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index d71587ca85..1c34cb25db 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -164,6 +164,8 @@ void wxChoice::Append(const wxString& item) #endif NULL); + DoChangeBackgroundColour((WXWidget) w, m_backgroundColour); + if (m_windowFont.Ok()) XtVaSetValues (w, XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)), @@ -420,16 +422,45 @@ void wxChoiceCallback (Widget w, XtPointer clientData, void wxChoice::ChangeFont() { - // TODO + // Note that this causes the widget to be resized back + // to its original size! We therefore have to set the size + // back again. TODO: a better way in Motif? + if (m_windowFont.Ok()) + { + int width, height, width1, height1; + GetSize(& width, & height); + + XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_mainWidget)); + XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL); + XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL); + + int i; + for (i = 0; i < m_noStrings; i++) + XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL); + GetSize(& width1, & height1); + if (width != width1 || height != height1) + { + SetSize(-1, -1, width, height); + } + } } void wxChoice::ChangeBackgroundColour() { - // TODO + DoChangeBackgroundColour(m_formWidget, m_backgroundColour); + DoChangeBackgroundColour(m_buttonWidget, m_backgroundColour); + DoChangeBackgroundColour(m_menuWidget, m_backgroundColour); + int i; + for (i = 0; i < m_noStrings; i++) + DoChangeBackgroundColour(m_widgetList[i], m_backgroundColour); } void wxChoice::ChangeForegroundColour() { - // TODO + DoChangeForegroundColour(m_formWidget, m_foregroundColour); + DoChangeForegroundColour(m_buttonWidget, m_foregroundColour); + DoChangeForegroundColour(m_menuWidget, m_foregroundColour); + int i; + for (i = 0; i < m_noStrings; i++) + DoChangeForegroundColour(m_widgetList[i], m_foregroundColour); } - diff --git a/src/motif/combobox.cpp b/src/motif/combobox.cpp index f62a083330..71918fbbc9 100644 --- a/src/motif/combobox.cpp +++ b/src/motif/combobox.cpp @@ -209,17 +209,18 @@ void wxComboBoxCallback (Widget w, XtPointer clientData, void wxComboBox::ChangeFont() { - // TODO + // Don't use the base class wxChoice's ChangeFont + wxWindow::ChangeFont(); } void wxComboBox::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxComboBox::ChangeForegroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } #endif diff --git a/src/motif/dialog.cpp b/src/motif/dialog.cpp index 28b7db5b42..8c521c4b10 100644 --- a/src/motif/dialog.cpp +++ b/src/motif/dialog.cpp @@ -236,6 +236,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, (XtPointer)this); ChangeBackgroundColour(); + SetFont(* parent->GetFont()); return TRUE; } diff --git a/src/motif/gauge.cpp b/src/motif/gauge.cpp index 4067322557..81d9d65c10 100644 --- a/src/motif/gauge.cpp +++ b/src/motif/gauge.cpp @@ -190,17 +190,17 @@ int wxGauge::GetValue() const void wxGauge::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxGauge::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxGauge::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } //// PRIVATE DECLARATIONS FOR XMGAUGE diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index a964a11588..246ee2d909 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -743,16 +743,16 @@ WXWidget wxListBox::GetTopWidget() const void wxListBox::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxListBox::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxListBox::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } diff --git a/src/motif/radiobut.cpp b/src/motif/radiobut.cpp index 4fe1489f09..69e95f82b0 100644 --- a/src/motif/radiobut.cpp +++ b/src/motif/radiobut.cpp @@ -34,8 +34,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) wxRadioButton::wxRadioButton() { - m_labelWidget = (WXWidget) 0; - m_formWidget = (WXWidget) 0; } bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, @@ -65,71 +63,28 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, XmString text = XmStringCreateSimple ((char*) (const char*) label1); - Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name, - xmFormWidgetClass, parentWidget, - XmNmarginHeight, 0, - XmNmarginWidth, 0, - NULL); - - m_formWidget = (WXWidget) formWidget; - - Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1, -#if wxUSE_GADGETS - xmLabelGadgetClass, - formWidget, -#else - xmLabelWidgetClass, formWidget, -#endif - XmNlabelString, text, - NULL); - m_labelWidget = (WXWidget) labelWidget; -/* TODO - if (labelFont) - XtVaSetValues (labelWidget, - XmNfontList, labelFont->GetInternalFont (XtDisplay(formWidget)), - NULL); -*/ - - XmStringFree (text); Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle", #if wxUSE_GADGETS - xmToggleButtonGadgetClass, formWidget, + xmToggleButtonGadgetClass, parentWidget, #else - xmToggleButtonWidgetClass, formWidget, + xmToggleButtonWidgetClass, parentWidget, #endif + XmNlabelString, text, + XmNfillOnSelect, True, + XmNindicatorType, XmONE_OF_MANY, // diamond-shape NULL); + XmStringFree (text); + XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback, (XtCallbackProc) this); m_mainWidget = (WXWidget) radioButtonWidget; -/* TODO - if (labelFont) - XtVaSetValues (radioButtonWidget, - XmNfontList, labelFont->GetInternalFont (XtDisplay(formWidget)), - NULL); -*/ - - if (labelWidget) - XtVaSetValues (labelWidget, - XmNtopAttachment, XmATTACH_FORM, - XmNleftAttachment, XmATTACH_FORM, - XmNbottomAttachment, XmATTACH_FORM, - XmNalignment, XmALIGNMENT_BEGINNING, - NULL); - XtVaSetValues (radioButtonWidget, - XmNleftOffset, 4, - XmNtopAttachment, XmATTACH_FORM, - XmNbottomAttachment, XmATTACH_FORM, - XmNleftAttachment, (Widget) m_labelWidget ? XmATTACH_WIDGET : XmATTACH_FORM, - XmNleftWidget, (Widget) m_labelWidget ? (Widget) m_labelWidget : formWidget, - NULL); - XtManageChild (radioButtonWidget); SetCanAddEventHandler(TRUE); - AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y); + AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y); SetFont(* parent->GetFont()); ChangeBackgroundColour(); @@ -158,17 +113,17 @@ void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxRadioButton::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxRadioButton::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } void wxRadioButtonCallback (Widget w, XtPointer clientData, diff --git a/src/motif/slider.cpp b/src/motif/slider.cpp index 20a1b07711..a270c48241 100644 --- a/src/motif/slider.cpp +++ b/src/motif/slider.cpp @@ -249,17 +249,17 @@ void wxSlider::Command (wxCommandEvent & event) void wxSlider::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxSlider::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxSlider::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruct * cbs) diff --git a/src/motif/statbmp.cpp b/src/motif/statbmp.cpp index 68fb07baad..223a5780d6 100644 --- a/src/motif/statbmp.cpp +++ b/src/motif/statbmp.cpp @@ -121,16 +121,16 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap) void wxStaticBitmap::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxStaticBitmap::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxStaticBitmap::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } diff --git a/src/motif/statbox.cpp b/src/motif/statbox.cpp index d973f83979..01a76c9157 100644 --- a/src/motif/statbox.cpp +++ b/src/motif/statbox.cpp @@ -183,16 +183,16 @@ void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags) void wxStaticBox::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxStaticBox::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxStaticBox::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index 947d81c39d..621a403b87 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -76,16 +76,16 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, void wxStaticText::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxStaticText::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxStaticText::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } diff --git a/src/motif/textctrl.cpp b/src/motif/textctrl.cpp index 284744f326..e645133fcf 100644 --- a/src/motif/textctrl.cpp +++ b/src/motif/textctrl.cpp @@ -638,17 +638,17 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) void wxTextCtrl::ChangeFont() { - // TODO + wxWindow::ChangeFont(); } void wxTextCtrl::ChangeBackgroundColour() { - // TODO + wxWindow::ChangeBackgroundColour(); } void wxTextCtrl::ChangeForegroundColour() { - // TODO + wxWindow::ChangeForegroundColour(); } static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr) diff --git a/src/motif/toolbar.cpp b/src/motif/toolbar.cpp index 903b69be33..163f7fd4cf 100644 --- a/src/motif/toolbar.cpp +++ b/src/motif/toolbar.cpp @@ -40,8 +40,6 @@ static void wxToolButtonCallback (Widget w, XtPointer clientData, static void wxToolButtonPopupCallback (Widget w, XtPointer client_data, XEvent *event, Boolean *continue_to_dispatch); -wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour); - class wxToolBarTimer: public wxTimer { public: @@ -446,27 +444,6 @@ void wxToolButtonCallback (Widget w, XtPointer clientData, } -// Creates a bitmap with transparent areas drawn in -// the given colour. -wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour) -{ - wxBitmap newBitmap(bitmap.GetWidth(), - bitmap.GetHeight(), - bitmap.GetDepth()); - wxMemoryDC destDC; - wxMemoryDC srcDC; - srcDC.SelectObject(bitmap); - destDC.SelectObject(newBitmap); - - wxBrush brush(colour, wxSOLID); - destDC.SetOptimization(FALSE); - destDC.SetBackground(brush); - destDC.Clear(); - destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE); - - return newBitmap; -} - static void wxToolButtonPopupCallback (Widget w, XtPointer client_data, XEvent *event, Boolean *continue_to_dispatch) diff --git a/src/motif/window.cpp b/src/motif/window.cpp index e0d7b1fec2..7f0cc41476 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -3024,8 +3024,6 @@ void wxWindow::ChangeForegroundColour() // Change a widget's foreground and background colours. -// TODO: make this 2 functions, ChangeForegroundColour and ChangeBackgroundColour. - void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour) { // When should we specify the foreground, if it's calculated @@ -3077,7 +3075,6 @@ void wxWindow::ChangeFont() // Note that this causes the widget to be resized back // to its original size! We therefore have to set the size // back again. TODO: a better way in Motif? - /* Widget w = (Widget) GetLabelWidget(); // Usually the main widget if (w && m_windowFont.Ok()) { @@ -3094,7 +3091,6 @@ void wxWindow::ChangeFont() SetSize(-1, -1, width, height); } } - */ } void wxWindow::SetFont(const wxFont& font) diff --git a/src/msw/wave.cpp b/src/msw/wave.cpp index 6486eec941..1f3ba0dd82 100644 --- a/src/msw/wave.cpp +++ b/src/msw/wave.cpp @@ -50,6 +50,11 @@ wxWave::wxWave(const wxString& sFileName, bool isResource) Create(sFileName, isResource); } +wxWave::wxWave(int size, const byte* data) + : m_waveLength(0), m_isResource(FALSE), m_waveData(NULL) +{ + Create(size, data); +} wxWave::~wxWave() { @@ -103,6 +108,19 @@ bool wxWave::Create(const wxString& fileName, bool isResource) } } +bool wxWave::Create(int size, const byte* data) +{ + Free(); + m_isResource = FALSE; + m_waveLength=size; + m_waveData = (byte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength)); + if (!m_waveData) + return FALSE; + + for (int i=0; i