More Motif changes (colour/font stuff)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@902 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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
|
||||
|
||||
|
@@ -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_
|
||||
|
@@ -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_buttonBitmap;
|
||||
wxBitmap m_buttonBitmapSelected;
|
||||
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_buttonBitmapSelectedOriginal;
|
||||
|
||||
wxBitmap m_buttonBitmapDisabled;
|
||||
wxBitmap m_buttonBitmapDisabledOriginal;
|
||||
|
||||
int m_marginX;
|
||||
int m_marginY;
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include "wx/icon.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/dcmemory.h"
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
ChangeBackgroundColour ();
|
||||
|
||||
p1 = (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap(m_mainWidget);
|
||||
p2 = (Pixmap) ((wxBitmap&)bitmap).GetInsensPixmap(m_mainWidget);
|
||||
|
||||
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,32 +116,115 @@ wxBitmapButton::~wxBitmapButton()
|
||||
|
||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_buttonBitmapOriginal = bitmap;
|
||||
m_buttonBitmap = bitmap;
|
||||
|
||||
if (bitmap.Ok())
|
||||
DoSetBitmap();
|
||||
}
|
||||
|
||||
void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel)
|
||||
{
|
||||
Pixmap labelPixmap, insensPixmap, armPixmap;
|
||||
m_buttonBitmapSelected = sel;
|
||||
m_buttonBitmapSelectedOriginal = sel;
|
||||
|
||||
labelPixmap = (Pixmap) ((wxBitmap&)bitmap).GetLabelPixmap(m_mainWidget);
|
||||
DoSetBitmap();
|
||||
};
|
||||
|
||||
if (m_buttonBitmapSelected.Ok())
|
||||
armPixmap = (Pixmap) m_buttonBitmapSelected.GetLabelPixmap(m_mainWidget);
|
||||
else
|
||||
armPixmap = (Pixmap) ((wxBitmap&)bitmap).GetArmPixmap(m_mainWidget);
|
||||
|
||||
if (m_buttonBitmapDisabled.Ok())
|
||||
insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetLabelPixmap(m_mainWidget);
|
||||
else
|
||||
insensPixmap = (Pixmap) ((wxBitmap&)bitmap).GetInsensPixmap(m_mainWidget);
|
||||
|
||||
if (!insensPixmap || (insensPixmap == labelPixmap)) // <- the Get...Pixmap()-functions return the same pixmap!
|
||||
void wxBitmapButton::SetBitmapFocus(const wxBitmap& focus)
|
||||
{
|
||||
insensPixmap = XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), labelPixmap);
|
||||
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 pixmap = 0;
|
||||
Pixmap insensPixmap = 0;
|
||||
Pixmap armPixmap = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
pixmap = (Pixmap) m_buttonBitmap.GetPixmap();
|
||||
}
|
||||
else
|
||||
pixmap = (Pixmap) m_buttonBitmap.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) m_buttonBitmap.GetInsensPixmap(m_mainWidget);
|
||||
|
||||
// Now make the bitmap representing the armed state
|
||||
if (m_buttonBitmapSelectedOriginal.Ok())
|
||||
{
|
||||
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,
|
||||
XmNlabelPixmap, pixmap,
|
||||
XmNlabelInsensitivePixmap, insensPixmap,
|
||||
XmNarmPixmap, armPixmap,
|
||||
XmNlabelType, XmPIXMAP,
|
||||
@@ -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();
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -236,6 +236,7 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
(XtPointer)this);
|
||||
|
||||
ChangeBackgroundColour();
|
||||
SetFont(* parent->GetFont());
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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<size; i++) m_waveData[i] = data[i];
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxWave::Play(bool async, bool looped) const
|
||||
{
|
||||
if (!IsOk())
|
||||
|
Reference in New Issue
Block a user