1. DoSetSize() simplified, DoGetBestSize() introduced
2. code cleanup here and there 3. attempts to make static boxes behave better (i.e. stay below other controls) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2947 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,9 +63,7 @@ protected:
|
||||
// send a notification event, return TRUE if processed
|
||||
bool SendClickEvent();
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual wxSize DoGetBestSize();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -53,9 +53,7 @@ public:
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
protected:
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual wxSize DoGetBestSize();
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxBitmapCheckBox: public wxCheckBox
|
||||
@@ -82,15 +80,7 @@ public:
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxCheckBoxNameStr);
|
||||
|
||||
virtual void SetValue(bool value);
|
||||
virtual bool GetValue() const ;
|
||||
|
||||
virtual void SetLabel(const wxBitmap& bitmap);
|
||||
|
||||
protected:
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
#endif
|
||||
// _WX_CHECKBOX_H_
|
||||
|
@@ -73,6 +73,7 @@ public:
|
||||
protected:
|
||||
int m_noStrings;
|
||||
|
||||
virtual wxSize DoGetBestSize();
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#define _WX_COMBOBOX_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "combobox.h"
|
||||
#pragma interface "combobox.h"
|
||||
#endif
|
||||
|
||||
#include "wx/choice.h"
|
||||
@@ -23,15 +23,18 @@
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr;
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
|
||||
|
||||
// Combobox item
|
||||
// ----------------------------------------------------------------------------
|
||||
// Combobox control
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxComboBox: public wxChoice
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxComboBox)
|
||||
|
||||
public:
|
||||
inline wxComboBox(void) {}
|
||||
public:
|
||||
wxComboBox() { }
|
||||
|
||||
inline wxComboBox(wxWindow *parent, wxWindowID id,
|
||||
wxComboBox(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
@@ -55,27 +58,29 @@ class WXDLLEXPORT wxComboBox: public wxChoice
|
||||
// List functions: see wxChoice
|
||||
|
||||
// Text field functions
|
||||
virtual wxString GetValue(void) const ;
|
||||
wxString GetValue() const { return GetLabel(); }
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
// Clipboard operations
|
||||
virtual void Copy(void);
|
||||
virtual void Cut(void);
|
||||
virtual void Paste(void);
|
||||
virtual void Copy();
|
||||
virtual void Cut();
|
||||
virtual void Paste();
|
||||
virtual void SetInsertionPoint(long pos);
|
||||
virtual void SetInsertionPointEnd(void);
|
||||
virtual long GetInsertionPoint(void) const ;
|
||||
virtual long GetLastPosition(void) const ;
|
||||
virtual void SetInsertionPointEnd();
|
||||
virtual long GetInsertionPoint() const;
|
||||
virtual long GetLastPosition() const;
|
||||
virtual void Replace(long from, long to, const wxString& value);
|
||||
virtual void Remove(long from, long to);
|
||||
virtual void SetSelection(int n)
|
||||
{
|
||||
wxChoice::SetSelection(n);
|
||||
}
|
||||
virtual void SetSelection(int n) { wxChoice::SetSelection(n); }
|
||||
virtual void SetSelection(long from, long to);
|
||||
virtual void SetEditable(bool editable);
|
||||
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
|
||||
protected:
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
#endif // wxUSE_COMBOBOX
|
||||
|
@@ -69,6 +69,8 @@ protected:
|
||||
// For controls like radiobuttons which are really composite
|
||||
wxList m_subControls;
|
||||
|
||||
virtual wxSize DoGetBestSize();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -70,10 +70,6 @@ public:
|
||||
protected:
|
||||
int m_rangeMax;
|
||||
int m_gaugePos;
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -70,10 +70,6 @@ public:
|
||||
protected:
|
||||
int m_rangeMax;
|
||||
int m_gaugePos;
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -133,10 +133,6 @@ protected:
|
||||
// control items
|
||||
wxListBoxItemsArray m_aItems;
|
||||
#endif
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -83,9 +83,7 @@ protected:
|
||||
wxBitmap *bitmap;
|
||||
} m_image;
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual wxSize DoGetBestSize();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -45,12 +45,13 @@ public:
|
||||
long style = 0,
|
||||
const wxString& name = wxStaticBoxNameStr);
|
||||
|
||||
// implementation from now on
|
||||
// --------------------------
|
||||
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
|
||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
void SetLabel(const wxString& label);
|
||||
|
||||
virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
@@ -61,6 +62,7 @@ protected:
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual wxSize DoGetBestSize();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -56,9 +56,7 @@ public:
|
||||
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
|
||||
|
||||
protected:
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual wxSize DoGetBestSize();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -59,7 +59,8 @@ public:
|
||||
wxTextCtrl(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = 0,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr)
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
@@ -72,13 +73,15 @@ public:
|
||||
bool Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = wxTE_PROCESS_TAB,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxTextCtrlNameStr);
|
||||
|
||||
// accessors
|
||||
// ---------
|
||||
virtual wxString GetValue() const ;
|
||||
|
||||
virtual wxString GetValue() const;
|
||||
virtual void SetValue(const wxString& value);
|
||||
|
||||
virtual int GetLineLength(long lineNo) const;
|
||||
@@ -148,25 +151,9 @@ public:
|
||||
virtual void ShowPosition(long pos);
|
||||
virtual void Clear();
|
||||
|
||||
// callbacks
|
||||
// ---------
|
||||
void OnDropFiles(wxDropFilesEvent& event);
|
||||
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
||||
// Implementation from now on
|
||||
// --------------------------
|
||||
|
||||
void OnCut(wxCommandEvent& event);
|
||||
void OnCopy(wxCommandEvent& event);
|
||||
void OnPaste(wxCommandEvent& event);
|
||||
void OnUndo(wxCommandEvent& event);
|
||||
void OnRedo(wxCommandEvent& event);
|
||||
|
||||
void OnUpdateCut(wxUpdateUIEvent& event);
|
||||
void OnUpdateCopy(wxUpdateUIEvent& event);
|
||||
void OnUpdatePaste(wxUpdateUIEvent& event);
|
||||
void OnUpdateUndo(wxUpdateUIEvent& event);
|
||||
void OnUpdateRedo(wxUpdateUIEvent& event);
|
||||
|
||||
// Implementation
|
||||
// --------------
|
||||
virtual void Command(wxCommandEvent& event);
|
||||
virtual bool MSWCommand(WXUINT param, WXWORD id);
|
||||
|
||||
@@ -184,6 +171,23 @@ public:
|
||||
|
||||
virtual bool AcceptsFocus() const;
|
||||
|
||||
// callbacks
|
||||
// ---------
|
||||
void OnDropFiles(wxDropFilesEvent& event);
|
||||
void OnChar(wxKeyEvent& event); // Process 'enter' if required
|
||||
|
||||
void OnCut(wxCommandEvent& event);
|
||||
void OnCopy(wxCommandEvent& event);
|
||||
void OnPaste(wxCommandEvent& event);
|
||||
void OnUndo(wxCommandEvent& event);
|
||||
void OnRedo(wxCommandEvent& event);
|
||||
|
||||
void OnUpdateCut(wxUpdateUIEvent& event);
|
||||
void OnUpdateCopy(wxUpdateUIEvent& event);
|
||||
void OnUpdatePaste(wxUpdateUIEvent& event);
|
||||
void OnUpdateUndo(wxUpdateUIEvent& event);
|
||||
void OnUpdateRedo(wxUpdateUIEvent& event);
|
||||
|
||||
protected:
|
||||
#if wxUSE_RICHEDIT
|
||||
bool m_isRich; // Are we using rich text edit to implement this?
|
||||
@@ -195,9 +199,7 @@ protected:
|
||||
// limit is big enough)
|
||||
void AdjustSpaceLimit();
|
||||
|
||||
virtual void DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual wxSize DoGetBestSize();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -399,6 +399,10 @@ protected:
|
||||
int sizeFlags = wxSIZE_AUTO);
|
||||
virtual void DoSetClientSize(int width, int height);
|
||||
|
||||
// get the size which best suits the window: e.g., for a static text it
|
||||
// will be the width and height of the text
|
||||
virtual wxSize DoGetBestSize();
|
||||
|
||||
#if wxUSE_TOOLTIPS
|
||||
virtual void DoSetToolTip( wxToolTip *tip );
|
||||
#endif // wxUSE_TOOLTIPS
|
||||
|
@@ -113,55 +113,28 @@ wxButton::~wxButton()
|
||||
// size management including autosizing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxButton::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
wxSize wxButton::DoGetBestSize()
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
wxString label = wxGetWindowText(GetHWND());
|
||||
int wBtn;
|
||||
GetTextExtent(label, &wBtn, NULL);
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
int wChar, hChar;
|
||||
wxGetCharSize(GetHWND(), &wChar, &hChar, &GetFont());
|
||||
|
||||
int actualWidth = width;
|
||||
int actualHeight = height;
|
||||
int ww, hh;
|
||||
GetSize(&ww, &hh);
|
||||
// add a margin - the button is wider than just its label
|
||||
wBtn += 3*wChar;
|
||||
|
||||
int current_width;
|
||||
int cyf;
|
||||
wxString buf = wxGetWindowText(GetHWND());
|
||||
GetTextExtent(buf, ¤t_width, &cyf, NULL, NULL, &GetFont());
|
||||
// the button height is proportional to the height of the font used
|
||||
int hBtn = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
|
||||
|
||||
// If we're prepared to use the existing width, then...
|
||||
if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH))
|
||||
{
|
||||
actualWidth = ww;
|
||||
}
|
||||
else if (width == -1)
|
||||
{
|
||||
int cx;
|
||||
int cy;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
|
||||
actualWidth = (int)(current_width + 3*cx) ;
|
||||
}
|
||||
|
||||
// If we're prepared to use the existing height, then...
|
||||
if (height == -1 && ((sizeFlags & wxSIZE_AUTO_HEIGHT) != wxSIZE_AUTO_HEIGHT))
|
||||
{
|
||||
actualHeight = hh;
|
||||
}
|
||||
else if (height == -1)
|
||||
{
|
||||
actualHeight = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cyf);
|
||||
}
|
||||
|
||||
MoveWindow(GetHwnd(), x1, y1, actualWidth, actualHeight, TRUE);
|
||||
return wxSize(wBtn, hBtn);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// set this button as the default one in its panel
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxButton::SetDefault()
|
||||
{
|
||||
wxWindow *parent = GetParent();
|
||||
|
@@ -9,29 +9,49 @@
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "checkbox.h"
|
||||
#pragma implementation "checkbox.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/brush.h"
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/brush.h"
|
||||
#endif
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxCheckBox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxCheckBox::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id))
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId);
|
||||
@@ -84,10 +104,10 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
|
||||
// Even with extended styles, need to combine with WS_BORDER
|
||||
// for them to look right.
|
||||
/*
|
||||
/*
|
||||
if ( want3D || wxStyleHasBorder(m_windowStyle) )
|
||||
msStyle |= WS_BORDER;
|
||||
*/
|
||||
*/
|
||||
|
||||
m_hWnd = (WXHWND)CreateWindowEx(exStyle, _T("BUTTON"), Label,
|
||||
msStyle,
|
||||
@@ -98,7 +118,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
#if wxUSE_CTL3D
|
||||
if (want3D)
|
||||
{
|
||||
Ctl3dSubclassCtl((HWND)m_hWnd);
|
||||
Ctl3dSubclassCtl(GetHwnd());
|
||||
m_useCtl3D = TRUE;
|
||||
}
|
||||
#endif
|
||||
@@ -115,59 +135,35 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
|
||||
void wxCheckBox::SetLabel(const wxString& label)
|
||||
{
|
||||
SetWindowText((HWND)GetHWND(), label);
|
||||
SetWindowText(GetHwnd(), label);
|
||||
}
|
||||
|
||||
void wxCheckBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
wxSize wxCheckBox::DoGetBestSize()
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
int wCheckbox, hCheckbox;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
int current_width, cyf;
|
||||
HWND button = (HWND) GetHWND();
|
||||
|
||||
int nLen = GetWindowTextLength(button);
|
||||
wxString str;
|
||||
GetWindowText(button, str.GetWriteBuf(nLen), nLen);
|
||||
str.UngetWriteBuf();
|
||||
wxString str = wxGetWindowText(GetHWND());
|
||||
|
||||
if ( !str.IsEmpty() )
|
||||
{
|
||||
GetTextExtent(str, ¤t_width, &cyf, NULL, NULL, & this->GetFont());
|
||||
if (w1 < 0)
|
||||
w1 = (int)(current_width + RADIO_SIZE);
|
||||
if (h1 < 0)
|
||||
{
|
||||
h1 = (int)(cyf);
|
||||
if (h1 < RADIO_SIZE)
|
||||
h1 = RADIO_SIZE;
|
||||
}
|
||||
GetTextExtent(str, &wCheckbox, &hCheckbox);
|
||||
wCheckbox += RADIO_SIZE;
|
||||
|
||||
if ( hCheckbox < RADIO_SIZE )
|
||||
hCheckbox = RADIO_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w1 < 0)
|
||||
w1 = RADIO_SIZE;
|
||||
if (h1 < 0)
|
||||
h1 = RADIO_SIZE;
|
||||
wCheckbox = RADIO_SIZE;
|
||||
hCheckbox = RADIO_SIZE;
|
||||
}
|
||||
|
||||
MoveWindow(button, x1, y1, w1, h1, TRUE);
|
||||
return wxSize(wCheckbox, hCheckbox);
|
||||
}
|
||||
|
||||
void wxCheckBox::SetValue(bool val)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), BM_SETCHECK, val, 0);
|
||||
SendMessage(GetHwnd(), BM_SETCHECK, val, 0);
|
||||
}
|
||||
|
||||
#ifndef BST_CHECKED
|
||||
@@ -177,9 +173,9 @@ void wxCheckBox::SetValue(bool val)
|
||||
bool wxCheckBox::GetValue() const
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
return (SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
return (SendMessage(GetHwnd(), BM_GETCHECK, 0, 0) == BST_CHECKED);
|
||||
#else
|
||||
return ((0x003 & SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0)) == 0x003);
|
||||
return ((0x003 & SendMessage(GetHwnd(), BM_GETCHECK, 0, 0)) == 0x003);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -217,6 +213,10 @@ void wxCheckBox::Command (wxCommandEvent & event)
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmapCheckBox
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
@@ -263,53 +263,14 @@ bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *l
|
||||
// Subclass again for purposes of dialog editing mode
|
||||
SubclassWin((WXHWND)wx_button);
|
||||
|
||||
// SetFont(parent->GetFont());
|
||||
|
||||
SetSize(x, y, width, height);
|
||||
|
||||
ShowWindow(wx_button, SW_SHOW);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxBitmapCheckBox::SetLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
wxFAIL_MSG("not implemented");
|
||||
}
|
||||
|
||||
void wxBitmapCheckBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
HWND button = (HWND) GetHWND();
|
||||
/*
|
||||
if (w1<0)
|
||||
w1 = checkWidth + FB_MARGIN ;
|
||||
if (h1<0)
|
||||
h1 = checkHeight + FB_MARGIN ;
|
||||
*/
|
||||
MoveWindow(button, x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
|
||||
void wxBitmapCheckBox::SetValue(bool val)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), BM_SETCHECK, val, 0);
|
||||
}
|
||||
|
||||
bool wxBitmapCheckBox::GetValue() const
|
||||
{
|
||||
return ((0x003 & SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0)) == 0x003);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -123,19 +123,19 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
void wxChoice::Append(const wxString& item)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), CB_ADDSTRING, 0, (LONG)(const wxChar *)item);
|
||||
SendMessage(GetHwnd(), CB_ADDSTRING, 0, (LONG)(const wxChar *)item);
|
||||
|
||||
m_noStrings ++;
|
||||
}
|
||||
|
||||
void wxChoice::Delete(int n)
|
||||
{
|
||||
m_noStrings = (int)SendMessage((HWND) GetHWND(), CB_DELETESTRING, n, 0);
|
||||
m_noStrings = (int)SendMessage(GetHwnd(), CB_DELETESTRING, n, 0);
|
||||
}
|
||||
|
||||
void wxChoice::Clear(void)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), CB_RESETCONTENT, 0, 0);
|
||||
SendMessage(GetHwnd(), CB_RESETCONTENT, 0, 0);
|
||||
|
||||
m_noStrings = 0;
|
||||
}
|
||||
@@ -143,12 +143,12 @@ void wxChoice::Clear(void)
|
||||
|
||||
int wxChoice::GetSelection(void) const
|
||||
{
|
||||
return (int)SendMessage((HWND) GetHWND(), CB_GETCURSEL, 0, 0);
|
||||
return (int)SendMessage(GetHwnd(), CB_GETCURSEL, 0, 0);
|
||||
}
|
||||
|
||||
void wxChoice::SetSelection(int n)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), CB_SETCURSEL, n, 0);
|
||||
SendMessage(GetHwnd(), CB_SETCURSEL, n, 0);
|
||||
}
|
||||
|
||||
int wxChoice::FindString(const wxString& s) const
|
||||
@@ -159,14 +159,14 @@ int wxChoice::FindString(const wxString& s) const
|
||||
char buf[512];
|
||||
for (int i = 0; i < Number(); i++)
|
||||
{
|
||||
int len = (int)SendMessage((HWND) GetHWND(), CB_GETLBTEXT, i, (LPARAM)(LPSTR)buf);
|
||||
int len = (int)SendMessage(GetHwnd(), CB_GETLBTEXT, i, (LPARAM)(LPSTR)buf);
|
||||
buf[len] = 0;
|
||||
if (strcmp(buf, (const char *)s) == 0)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
#else
|
||||
int pos = (int)SendMessage((HWND) GetHWND(), CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)(LPSTR)(const wxChar *)s);
|
||||
int pos = (int)SendMessage(GetHwnd(), CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)(LPSTR)(const wxChar *)s);
|
||||
if (pos == LB_ERR)
|
||||
return -1;
|
||||
else
|
||||
@@ -176,99 +176,60 @@ int wxChoice::FindString(const wxString& s) const
|
||||
|
||||
wxString wxChoice::GetString(int n) const
|
||||
{
|
||||
int len = (int)SendMessage((HWND) GetHWND(), CB_GETLBTEXT, n, (long)wxBuffer);
|
||||
wxBuffer[len] = 0;
|
||||
return wxString(wxBuffer);
|
||||
size_t len = (size_t)::SendMessage(GetHwnd(), CB_GETLBTEXTLEN, n, 0);
|
||||
wxString str;
|
||||
if ( ::SendMessage(GetHwnd(), CB_GETLBTEXT, n,
|
||||
(LPARAM)str.GetWriteBuf(len)) == CB_ERR )
|
||||
{
|
||||
wxLogLastError("SendMessage(CB_GETLBTEXT)");
|
||||
}
|
||||
|
||||
str.UngetWriteBuf();
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
void wxChoice::DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
// Ignore height parameter because height doesn't mean 'initially
|
||||
// displayed' height, it refers to the drop-down menu as well. The
|
||||
// wxWindows interpretation is different; also, getting the size returns
|
||||
// the _displayed_ size (NOT the drop down menu size) so
|
||||
// setting-getting-setting size would not work.
|
||||
wxControl::DoSetSize(x, y, width, -1, sizeFlags);
|
||||
}
|
||||
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
{
|
||||
GetSize(&w1, &h1);
|
||||
}
|
||||
|
||||
int cx; // button font dimensions
|
||||
int cy;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
|
||||
|
||||
int control_width, control_height;
|
||||
|
||||
// Ignore height parameter because height doesn't
|
||||
// mean 'initially displayed' height, it refers to the
|
||||
// drop-down menu as well. The wxWindows interpretation
|
||||
// is different; also, getting the size returns the
|
||||
// _displayed_ size (NOT the drop down menu size)
|
||||
// so setting-getting-setting size would not work.
|
||||
h1 = -1;
|
||||
|
||||
// Deal with default size (using -1 values)
|
||||
if (width <= 0)
|
||||
{
|
||||
// Find the longest string
|
||||
if (m_noStrings == 0)
|
||||
{
|
||||
control_width = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
int len, ht;
|
||||
int longest = 0;
|
||||
int i;
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
wxSize wxChoice::DoGetBestSize()
|
||||
{
|
||||
// find the widest string
|
||||
int wLine;
|
||||
int wChoice = 0;
|
||||
for ( int i = 0; i < m_noStrings; i++ )
|
||||
{
|
||||
wxString str(GetString(i));
|
||||
GetTextExtent(str, &len, &ht, NULL, NULL, & this->GetFont());
|
||||
if ( len > longest)
|
||||
longest = len;
|
||||
GetTextExtent(str, &wLine, NULL);
|
||||
if ( wLine > wChoice )
|
||||
wChoice = wLine;
|
||||
}
|
||||
|
||||
control_width = longest + cx*5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If non-default width...
|
||||
control_width = w1;
|
||||
}
|
||||
// give it some reasonable default value if there are no strings in the
|
||||
// list
|
||||
if ( wChoice == 0 )
|
||||
wChoice = 100;
|
||||
|
||||
// the combobox should be larger than the widest string
|
||||
int cx, cy;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
|
||||
|
||||
wChoice += 5*cx;
|
||||
|
||||
// Choice drop-down list depends on number of items (limited to 10)
|
||||
if (h1 <= 0)
|
||||
{
|
||||
if (m_noStrings == 0)
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*10;
|
||||
else
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMin(10, m_noStrings) + 1);
|
||||
}
|
||||
size_t nStrings = m_noStrings == 0 ? 10 : wxMin(10, m_noStrings) + 1;
|
||||
int hChoice = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*nStrings;
|
||||
|
||||
control_height = h1;
|
||||
|
||||
// Calculations may have made text size too small
|
||||
if (control_height <= 0)
|
||||
control_height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
|
||||
|
||||
if (control_width <= 0)
|
||||
control_width = 100;
|
||||
|
||||
MoveWindow((HWND)GetHWND(), x1, y1,
|
||||
control_width, control_height, TRUE);
|
||||
return wxSize(wChoice, hChoice);
|
||||
}
|
||||
|
||||
WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
|
@@ -146,11 +146,6 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetValue() const
|
||||
{
|
||||
return wxGetWindowText(GetHWND());
|
||||
}
|
||||
|
||||
void wxComboBox::SetValue(const wxString& value)
|
||||
{
|
||||
// If newlines are denoted by just 10, must stick 13 in front.
|
||||
@@ -177,43 +172,43 @@ void wxComboBox::SetValue(const wxString& value)
|
||||
j ++;
|
||||
}
|
||||
tmp[j] = 0;
|
||||
SetWindowText((HWND) GetHWND(), tmp);
|
||||
SetWindowText(GetHwnd(), tmp);
|
||||
delete[] tmp;
|
||||
}
|
||||
else
|
||||
SetWindowText((HWND) GetHWND(), (const wxChar *)value);
|
||||
SetWindowText(GetHwnd(), value);
|
||||
}
|
||||
|
||||
// Clipboard operations
|
||||
void wxComboBox::Copy()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
SendMessage(hWnd, WM_COPY, 0, 0L);
|
||||
}
|
||||
|
||||
void wxComboBox::Cut()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
SendMessage(hWnd, WM_CUT, 0, 0L);
|
||||
}
|
||||
|
||||
void wxComboBox::Paste()
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
SendMessage(hWnd, WM_PASTE, 0, 0L);
|
||||
}
|
||||
|
||||
void wxComboBox::SetEditable(bool editable)
|
||||
{
|
||||
// Can't implement in MSW?
|
||||
// HWND hWnd = (HWND) GetHWND();
|
||||
// HWND hWnd = GetHwnd();
|
||||
// SendMessage(hWnd, EM_SETREADONLY, (WPARAM)!editable, (LPARAM)0L);
|
||||
}
|
||||
|
||||
void wxComboBox::SetInsertionPoint(long pos)
|
||||
{
|
||||
/*
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
#ifdef __WIN32__
|
||||
SendMessage(hWnd, EM_SETSEL, pos, pos);
|
||||
SendMessage(hWnd, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
|
||||
@@ -236,7 +231,7 @@ void wxComboBox::SetInsertionPointEnd()
|
||||
long wxComboBox::GetInsertionPoint() const
|
||||
{
|
||||
/*
|
||||
DWORD Pos=(DWORD)SendMessage((HWND) GetHWND(), EM_GETSEL, 0, 0L);
|
||||
DWORD Pos=(DWORD)SendMessage(GetHwnd(), EM_GETSEL, 0, 0L);
|
||||
return Pos&0xFFFF;
|
||||
*/
|
||||
return 0;
|
||||
@@ -245,7 +240,7 @@ long wxComboBox::GetInsertionPoint() const
|
||||
long wxComboBox::GetLastPosition() const
|
||||
{
|
||||
/*
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
|
||||
// Will always return a number > 0 (according to docs)
|
||||
int noLines = (int)SendMessage(hWnd, EM_GETLINECOUNT, (WPARAM)0, (LPARAM)0L);
|
||||
@@ -265,7 +260,7 @@ long wxComboBox::GetLastPosition() const
|
||||
void wxComboBox::Replace(long from, long to, const wxString& value)
|
||||
{
|
||||
#if wxUSE_CLIPBOARD
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
long fromChar = from;
|
||||
long toChar = to;
|
||||
|
||||
@@ -287,7 +282,7 @@ void wxComboBox::Replace(long from, long to, const wxString& value)
|
||||
|
||||
void wxComboBox::Remove(long from, long to)
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
long fromChar = from;
|
||||
long toChar = to;
|
||||
|
||||
@@ -302,7 +297,7 @@ void wxComboBox::Remove(long from, long to)
|
||||
|
||||
void wxComboBox::SetSelection(long from, long to)
|
||||
{
|
||||
HWND hWnd = (HWND) GetHWND();
|
||||
HWND hWnd = GetHwnd();
|
||||
long fromChar = from;
|
||||
long toChar = to;
|
||||
// if from and to are both -1, it means
|
||||
@@ -323,6 +318,22 @@ void wxComboBox::SetSelection(long from, long to)
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxComboBox::DoSetSize(int x, int y,
|
||||
int width, int height,
|
||||
int sizeFlags)
|
||||
{
|
||||
wxControl::DoSetSize(x, y, width, height, sizeFlags);
|
||||
|
||||
// VZ: for unknown (to me) reasons, if we don't do this, the combobox
|
||||
// somehow is hidden by the static boxes, although static boxes do
|
||||
// put themselves at the very end of Z-order.
|
||||
if ( !::SetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE) )
|
||||
{
|
||||
wxLogLastError(_T("SetWindowPos"));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
// wxUSE_COMBOBOX
|
||||
|
||||
|
@@ -58,6 +58,11 @@ wxControl::~wxControl()
|
||||
m_isBeingDeleted = TRUE;
|
||||
}
|
||||
|
||||
wxSize wxControl::DoGetBestSize()
|
||||
{
|
||||
return wxSize(DEFAULT_ITEM_WIDTH, DEFAULT_ITEM_HEIGHT);
|
||||
}
|
||||
|
||||
bool wxControl::ProcessCommand(wxCommandEvent& event)
|
||||
{
|
||||
#if WXWIN_COMPATIBILITY
|
||||
|
@@ -241,24 +241,7 @@ void wxFrame::DoGetPosition(int *x, int *y) const
|
||||
|
||||
void wxFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
GetPosition(¤tX, ¤tY);
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
int ww,hh ;
|
||||
GetSize(&ww,&hh) ;
|
||||
if (width == -1) w1 = ww ;
|
||||
if (height==-1) h1 = hh ;
|
||||
|
||||
MoveWindow(GetHwnd(), x1, y1, w1, h1, (BOOL)TRUE);
|
||||
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
|
||||
|
||||
wxSizeEvent event(wxSize(width, height), m_windowId);
|
||||
event.SetEventObject( this );
|
||||
|
@@ -108,38 +108,6 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxGauge95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
{
|
||||
GetSize(&w1, &h1);
|
||||
}
|
||||
|
||||
// Deal with default size (using -1 values)
|
||||
if (w1<=0)
|
||||
w1 = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
if (h1<=0)
|
||||
h1 = DEFAULT_ITEM_HEIGHT;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
|
||||
void wxGauge95::SetShadowWidth(int w)
|
||||
{
|
||||
}
|
||||
|
@@ -126,8 +126,8 @@ bool wxGaugeMSW::Create(wxWindow *parent, wxWindowID id,
|
||||
SendMessage(wx_button, ZYZG_SETORIENTATION, wOrient, 0);
|
||||
SendMessage(wx_button, ZYZG_SETRANGE, range, 0);
|
||||
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
|
||||
SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
|
||||
SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
|
||||
|
||||
SetFont(parent->GetFont());
|
||||
|
||||
@@ -137,85 +137,53 @@ bool wxGaugeMSW::Create(wxWindow *parent, wxWindowID id,
|
||||
height = 50;
|
||||
SetSize(x, y, width, height);
|
||||
|
||||
ShowWindow((HWND) GetHWND(), SW_SHOW);
|
||||
ShowWindow(GetHwnd(), SW_SHOW);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxGaugeMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
{
|
||||
GetSize(&w1, &h1);
|
||||
}
|
||||
|
||||
// Deal with default size (using -1 values)
|
||||
if (w1<=0)
|
||||
w1 = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
if (h1<=0)
|
||||
h1 = DEFAULT_ITEM_HEIGHT;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
|
||||
void wxGaugeMSW::SetShadowWidth(int w)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETWIDTH3D, w, 0);
|
||||
SendMessage(GetHwnd(), ZYZG_SETWIDTH3D, w, 0);
|
||||
}
|
||||
|
||||
void wxGaugeMSW::SetBezelFace(int w)
|
||||
{
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETBEZELFACE, w, 0);
|
||||
SendMessage(GetHwnd(), ZYZG_SETBEZELFACE, w, 0);
|
||||
}
|
||||
|
||||
void wxGaugeMSW::SetRange(int r)
|
||||
{
|
||||
m_rangeMax = r;
|
||||
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETRANGE, r, 0);
|
||||
SendMessage(GetHwnd(), ZYZG_SETRANGE, r, 0);
|
||||
}
|
||||
|
||||
void wxGaugeMSW::SetValue(int pos)
|
||||
{
|
||||
m_gaugePos = pos;
|
||||
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETPOSITION, pos, 0);
|
||||
SendMessage(GetHwnd(), ZYZG_SETPOSITION, pos, 0);
|
||||
}
|
||||
|
||||
int wxGaugeMSW::GetShadowWidth(void) const
|
||||
{
|
||||
return (int) SendMessage((HWND) GetHWND(), ZYZG_GETWIDTH3D, 0, 0);
|
||||
return (int) SendMessage(GetHwnd(), ZYZG_GETWIDTH3D, 0, 0);
|
||||
}
|
||||
|
||||
int wxGaugeMSW::GetBezelFace(void) const
|
||||
{
|
||||
return (int) SendMessage((HWND) GetHWND(), ZYZG_GETBEZELFACE, 0, 0);
|
||||
return (int) SendMessage(GetHwnd(), ZYZG_GETBEZELFACE, 0, 0);
|
||||
}
|
||||
|
||||
int wxGaugeMSW::GetRange(void) const
|
||||
{
|
||||
return (int) SendMessage((HWND) GetHWND(), ZYZG_GETRANGE, 0, 0);
|
||||
return (int) SendMessage(GetHwnd(), ZYZG_GETRANGE, 0, 0);
|
||||
}
|
||||
|
||||
int wxGaugeMSW::GetValue(void) const
|
||||
{
|
||||
return (int) SendMessage((HWND) GetHWND(), ZYZG_GETPOSITION, 0, 0);
|
||||
return (int) SendMessage(GetHwnd(), ZYZG_GETPOSITION, 0, 0);
|
||||
}
|
||||
|
||||
bool wxGaugeMSW::SetForegroundColour(const wxColour& col)
|
||||
@@ -223,7 +191,7 @@ bool wxGaugeMSW::SetForegroundColour(const wxColour& col)
|
||||
if ( !wxControl::SetForegroundColour(col) )
|
||||
return FALSE;
|
||||
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
|
||||
SendMessage(GetHwnd(), ZYZG_SETFGCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -233,7 +201,7 @@ bool wxGaugeMSW::SetBackgroundColour(const wxColour& col)
|
||||
if ( !wxControl::SetBackgroundColour(col) )
|
||||
return FALSE;
|
||||
|
||||
SendMessage((HWND) GetHWND(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
|
||||
SendMessage(GetHwnd(), ZYZG_SETBKCOLOR, 0, RGB(col.Red(), col.Green(), col.Blue()));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -518,65 +518,8 @@ wxString wxListBox::GetString(int N) const
|
||||
return result;
|
||||
}
|
||||
|
||||
void wxListBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
{
|
||||
GetSize(&w1, &h1);
|
||||
}
|
||||
|
||||
int cx; // button font dimensions
|
||||
int cy;
|
||||
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
|
||||
|
||||
float control_width, control_height, control_x, control_y;
|
||||
|
||||
// Deal with default size (using -1 values)
|
||||
if (w1<=0)
|
||||
w1 = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
if (h1<=0)
|
||||
h1 = DEFAULT_ITEM_HEIGHT;
|
||||
|
||||
control_x = (float)x1;
|
||||
control_y = (float)y1;
|
||||
control_width = (float)w1;
|
||||
control_height = (float)h1;
|
||||
|
||||
// Calculations may have made size too small
|
||||
if (control_height <= 0)
|
||||
control_height = (float)DEFAULT_ITEM_HEIGHT;
|
||||
|
||||
if (control_width <= 0)
|
||||
control_width = (float)DEFAULT_ITEM_WIDTH;
|
||||
|
||||
MoveWindow(GetHwnd(),
|
||||
(int)control_x, (int)control_y,
|
||||
(int)control_width, (int)control_height,
|
||||
TRUE);
|
||||
|
||||
}
|
||||
|
||||
// Windows-specific code to set the horizontal extent of
|
||||
// the listbox, if necessary. If s is non-NULL, it's
|
||||
// used to calculate the horizontal extent.
|
||||
// Windows-specific code to set the horizontal extent of the listbox, if
|
||||
// necessary. If s is non-NULL, it's used to calculate the horizontal extent.
|
||||
// Otherwise, all strings are used.
|
||||
void wxListBox::SetHorizontalExtent(const wxString& s)
|
||||
{
|
||||
|
@@ -361,7 +361,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
yy = currentY;
|
||||
|
||||
wxChar buf[400];
|
||||
wxString buf;
|
||||
|
||||
int y_offset = yy;
|
||||
int x_offset = xx;
|
||||
@@ -369,9 +369,9 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
|
||||
int cx1,cy1;
|
||||
wxGetCharSize(m_hWnd, &cx1, &cy1, & GetFont());
|
||||
// Attempt to have a look coherent with other platforms:
|
||||
// We compute the biggest toggle dim, then we align all
|
||||
// items according this value.
|
||||
|
||||
// Attempt to have a look coherent with other platforms: We compute the
|
||||
// biggest toggle dim, then we align all items according this value.
|
||||
int maxWidth = -1;
|
||||
int maxHeight = -1;
|
||||
|
||||
@@ -383,8 +383,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (m_radioWidth[i]<0)
|
||||
{
|
||||
// It's a labelled toggle
|
||||
GetWindowText((HWND) m_radioButtons[i], buf, 300);
|
||||
GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL, & GetFont());
|
||||
buf = wxGetWindowText(m_radioButtons[i]);
|
||||
GetTextExtent(buf, ¤t_width, &cyf);
|
||||
eachWidth = (int)(current_width + RADIO_SIZE);
|
||||
eachHeight = (int)((3*cyf)/2);
|
||||
}
|
||||
@@ -393,8 +393,11 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
eachWidth = m_radioWidth[i];
|
||||
eachHeight = m_radioHeight[i];
|
||||
}
|
||||
if (maxWidth<eachWidth) maxWidth = eachWidth;
|
||||
if (maxHeight<eachHeight) maxHeight = eachHeight;
|
||||
|
||||
if (maxWidth<eachWidth)
|
||||
maxWidth = eachWidth;
|
||||
if (maxHeight<eachHeight)
|
||||
maxHeight = eachHeight;
|
||||
}
|
||||
|
||||
if (m_hWnd)
|
||||
@@ -413,12 +416,18 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
totHeight = nbVer * (maxHeight+cy1/2);
|
||||
totWidth = nbHor * (maxWidth+cx1);
|
||||
|
||||
#if (!CTL3D)
|
||||
int extraHeight = cy1;
|
||||
|
||||
#if !CTL3D
|
||||
// Requires a bigger group box in plain Windows
|
||||
MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+(3*cy1)/2,TRUE);
|
||||
#else
|
||||
MoveWindow((HWND) m_hWnd,x_offset,y_offset,totWidth+cx1,totHeight+cy1,TRUE);
|
||||
extraHeight *= 3;
|
||||
extraHeight /= 2;
|
||||
#endif
|
||||
|
||||
MoveWindow(GetHwnd(), x_offset, y_offset,
|
||||
totWidth+cx1, totHeight+extraHeight,
|
||||
TRUE);
|
||||
|
||||
x_offset += cx1;
|
||||
y_offset += cy1;
|
||||
}
|
||||
@@ -453,8 +462,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (m_radioWidth[i]<0)
|
||||
{
|
||||
// It's a labeled item
|
||||
GetWindowText((HWND) m_radioButtons[i], buf, 300);
|
||||
GetTextExtent(buf, ¤t_width, &cyf,NULL,NULL, & GetFont());
|
||||
buf = wxGetWindowText(m_radioButtons[i]);
|
||||
GetTextExtent(buf, ¤t_width, &cyf);
|
||||
|
||||
// How do we find out radio button bitmap size!!
|
||||
// By adjusting them carefully, manually :-)
|
||||
@@ -467,7 +476,10 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
eachHeight = m_radioHeight[i];
|
||||
}
|
||||
|
||||
MoveWindow((HWND) m_radioButtons[i],x_offset,y_offset,eachWidth,eachHeight,TRUE);
|
||||
MoveWindow((HWND)m_radioButtons[i], x_offset, y_offset,
|
||||
eachWidth, eachHeight,
|
||||
TRUE);
|
||||
|
||||
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
||||
{
|
||||
y_offset += maxHeight;
|
||||
@@ -479,7 +491,6 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void wxRadioBox::GetSize(int *width, int *height) const
|
||||
{
|
||||
RECT rect;
|
||||
|
@@ -277,12 +277,12 @@ wxSlider95::~wxSlider95()
|
||||
|
||||
int wxSlider95::GetValue() const
|
||||
{
|
||||
return ::SendMessage((HWND) GetHWND(), TBM_GETPOS, 0, 0);
|
||||
return ::SendMessage(GetHwnd(), TBM_GETPOS, 0, 0);
|
||||
}
|
||||
|
||||
void wxSlider95::SetValue(int value)
|
||||
{
|
||||
::SendMessage((HWND) GetHWND(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value);
|
||||
::SendMessage(GetHwnd(), TBM_SETPOS, (WPARAM)TRUE, (LPARAM)value);
|
||||
if (m_staticValue)
|
||||
{
|
||||
wxSprintf(wxBuffer, _T("%d"), value);
|
||||
@@ -344,6 +344,8 @@ void wxSlider95::GetPosition(int *x, int *y) const
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
// TODO one day, make sense of all this horros and replace it with a readable
|
||||
// DoGetBestSize()
|
||||
void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int x1 = x;
|
||||
@@ -413,7 +415,7 @@ void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (slider_length < 100)
|
||||
slider_length = 100;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_length, slider_height, TRUE);
|
||||
MoveWindow(GetHwnd(), x_offset, y_offset, slider_length, slider_height, TRUE);
|
||||
x_offset += slider_length + cx;
|
||||
|
||||
MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE);
|
||||
@@ -430,7 +432,7 @@ void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
w1 = 200;
|
||||
if ( h1 < 0 )
|
||||
h1 = 20;
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
|
||||
MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -479,7 +481,7 @@ void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (slider_length < 100)
|
||||
slider_length = 100;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_width, slider_length, TRUE);
|
||||
MoveWindow(GetHwnd(), x_offset, y_offset, slider_width, slider_length, TRUE);
|
||||
y_offset += slider_length;
|
||||
|
||||
MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE);
|
||||
@@ -496,7 +498,7 @@ void wxSlider95::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
w1 = 20;
|
||||
if ( h1 < 0 )
|
||||
h1 = 200;
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
|
||||
MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -506,7 +508,7 @@ void wxSlider95::SetRange(int minValue, int maxValue)
|
||||
m_rangeMin = minValue;
|
||||
m_rangeMax = maxValue;
|
||||
|
||||
::SendMessage((HWND) GetHWND(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
|
||||
::SendMessage(GetHwnd(), TBM_SETRANGE, TRUE, MAKELONG(minValue, maxValue));
|
||||
|
||||
wxChar buf[40];
|
||||
if ( m_staticMin )
|
||||
@@ -545,12 +547,12 @@ WXHBRUSH wxSlider95::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
void wxSlider95::SetTickFreq(int n, int pos)
|
||||
{
|
||||
m_tickFreq = n;
|
||||
::SendMessage( (HWND) GetHWND(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos );
|
||||
::SendMessage( GetHwnd(), TBM_SETTICFREQ, (WPARAM) n, (LPARAM) pos );
|
||||
}
|
||||
|
||||
void wxSlider95::SetPageSize(int pageSize)
|
||||
{
|
||||
::SendMessage( (HWND) GetHWND(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize );
|
||||
::SendMessage( GetHwnd(), TBM_SETPAGESIZE, (WPARAM) 0, (LPARAM) pageSize );
|
||||
m_pageSize = pageSize;
|
||||
}
|
||||
|
||||
@@ -561,53 +563,53 @@ int wxSlider95::GetPageSize() const
|
||||
|
||||
void wxSlider95::ClearSel()
|
||||
{
|
||||
::SendMessage( (HWND) GetHWND(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 );
|
||||
::SendMessage( GetHwnd(), TBM_CLEARSEL, (WPARAM) TRUE, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
void wxSlider95::ClearTicks()
|
||||
{
|
||||
::SendMessage( (HWND) GetHWND(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 );
|
||||
::SendMessage( GetHwnd(), TBM_CLEARTICS, (WPARAM) TRUE, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
void wxSlider95::SetLineSize(int lineSize)
|
||||
{
|
||||
m_lineSize = lineSize;
|
||||
::SendMessage( (HWND) GetHWND(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize );
|
||||
::SendMessage( GetHwnd(), TBM_SETLINESIZE, (WPARAM) 0, (LPARAM) lineSize );
|
||||
}
|
||||
|
||||
int wxSlider95::GetLineSize() const
|
||||
{
|
||||
return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 );
|
||||
return (int) ::SendMessage( GetHwnd(), TBM_GETLINESIZE, (WPARAM) 0, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
int wxSlider95::GetSelEnd() const
|
||||
{
|
||||
return (int) ::SendMessage( (HWND) GetHWND(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 );
|
||||
return (int) ::SendMessage( GetHwnd(), TBM_SETSELEND, (WPARAM) 0, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
int wxSlider95::GetSelStart() const
|
||||
{
|
||||
return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 );
|
||||
return (int) ::SendMessage( GetHwnd(), TBM_GETSELSTART, (WPARAM) 0, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
void wxSlider95::SetSelection(int minPos, int maxPos)
|
||||
{
|
||||
::SendMessage( (HWND) GetHWND(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) );
|
||||
::SendMessage( GetHwnd(), TBM_SETSEL, (WPARAM) TRUE, (LPARAM) MAKELONG( minPos, maxPos) );
|
||||
}
|
||||
|
||||
void wxSlider95::SetThumbLength(int len)
|
||||
{
|
||||
::SendMessage( (HWND) GetHWND(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 );
|
||||
::SendMessage( GetHwnd(), TBM_SETTHUMBLENGTH, (WPARAM) len, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
int wxSlider95::GetThumbLength() const
|
||||
{
|
||||
return (int) ::SendMessage( (HWND) GetHWND(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 );
|
||||
return (int) ::SendMessage( GetHwnd(), TBM_GETTHUMBLENGTH, (WPARAM) 0, (LPARAM) 0 );
|
||||
}
|
||||
|
||||
void wxSlider95::SetTick(int tickPos)
|
||||
{
|
||||
::SendMessage( (HWND) GetHWND(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos );
|
||||
::SendMessage( GetHwnd(), TBM_SETTIC, (WPARAM) 0, (LPARAM) tickPos );
|
||||
}
|
||||
|
||||
bool wxSlider95::ContainsHWND(WXHWND hWnd) const
|
||||
|
@@ -248,12 +248,12 @@ wxSliderMSW::~wxSliderMSW()
|
||||
|
||||
int wxSliderMSW::GetValue() const
|
||||
{
|
||||
return ::GetScrollPos((HWND) GetHWND(), SB_CTL);
|
||||
return ::GetScrollPos(GetHwnd(), SB_CTL);
|
||||
}
|
||||
|
||||
void wxSliderMSW::SetValue(int value)
|
||||
{
|
||||
::SetScrollPos((HWND) GetHWND(), SB_CTL, value, TRUE);
|
||||
::SetScrollPos(GetHwnd(), SB_CTL, value, TRUE);
|
||||
if (m_staticValue)
|
||||
{
|
||||
wxSprintf(wxBuffer, _T("%d"), value);
|
||||
@@ -315,6 +315,8 @@ void wxSliderMSW::GetPosition(int *x, int *y) const
|
||||
*y = point.y;
|
||||
}
|
||||
|
||||
// TODO one day, make sense of all this horros and replace it with a readable
|
||||
// DoGetBestSize()
|
||||
void wxSliderMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int x1 = x;
|
||||
@@ -379,7 +381,7 @@ void wxSliderMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (slider_length < 100)
|
||||
slider_length = 100;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_length, slider_height, TRUE);
|
||||
MoveWindow(GetHwnd(), x_offset, y_offset, slider_length, slider_height, TRUE);
|
||||
x_offset += slider_length + cx;
|
||||
|
||||
MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE);
|
||||
@@ -391,7 +393,7 @@ void wxSliderMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
w1 = 200;
|
||||
if ( h1 < 0 )
|
||||
h1 = 20;
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
|
||||
MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -435,7 +437,7 @@ void wxSliderMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
if (slider_length < 100)
|
||||
slider_length = 100;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x_offset, y_offset, slider_width, slider_length, TRUE);
|
||||
MoveWindow(GetHwnd(), x_offset, y_offset, slider_width, slider_length, TRUE);
|
||||
y_offset += slider_length;
|
||||
|
||||
MoveWindow((HWND) m_staticMax, x_offset, y_offset, (int)max_len, cy, TRUE);
|
||||
@@ -447,7 +449,7 @@ void wxSliderMSW::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
w1 = 20;
|
||||
if ( h1 < 0 )
|
||||
h1 = 200;
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, w1, h1, TRUE);
|
||||
MoveWindow(GetHwnd(), x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -457,7 +459,7 @@ void wxSliderMSW::SetRange(int minValue, int maxValue)
|
||||
m_rangeMin = minValue;
|
||||
m_rangeMax = maxValue;
|
||||
|
||||
::SetScrollRange((HWND) GetHWND(), SB_CTL, m_rangeMin, m_rangeMax, TRUE);
|
||||
::SetScrollRange(GetHwnd(), SB_CTL, m_rangeMin, m_rangeMax, TRUE);
|
||||
wxChar buf[40];
|
||||
if ( m_staticMin )
|
||||
{
|
||||
|
@@ -140,39 +140,11 @@ void wxStaticBitmap::Free()
|
||||
m_image.icon = NULL;
|
||||
}
|
||||
|
||||
void wxStaticBitmap::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
wxSize wxStaticBitmap::DoGetBestSize()
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
int actualWidth = width;
|
||||
int actualHeight = height;
|
||||
|
||||
int ww, hh;
|
||||
GetSize(&ww, &hh);
|
||||
|
||||
// If we're prepared to use the existing width, then...
|
||||
if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH))
|
||||
actualWidth = ww;
|
||||
else
|
||||
actualWidth = width;
|
||||
|
||||
// If we're prepared to use the existing height, then...
|
||||
if (height == -1 && ((sizeFlags & wxSIZE_AUTO_HEIGHT) != wxSIZE_AUTO_HEIGHT))
|
||||
actualHeight = hh;
|
||||
else
|
||||
actualHeight = height;
|
||||
|
||||
MoveWindow((HWND) GetHWND(), x1, y1, actualWidth, actualHeight, TRUE);
|
||||
// reuse the current size (as wxWindow does) instead of using some
|
||||
// arbitrary default size (as wxControl, our immediate base class, does)
|
||||
return wxWindow::DoGetBestSize();
|
||||
}
|
||||
|
||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||
|
@@ -99,50 +99,31 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxStaticBox::SetLabel(const wxString& label)
|
||||
wxSize wxStaticBox::DoGetBestSize()
|
||||
{
|
||||
SetWindowText((HWND)m_hWnd, (const wxChar *)label);
|
||||
int cx, cy;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
|
||||
|
||||
int wBox;
|
||||
GetTextExtent(wxGetWindowText(m_hWnd), &wBox, &cy);
|
||||
|
||||
wBox += 3*cx;
|
||||
int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
|
||||
|
||||
return wxSize(wBox, hBox);
|
||||
}
|
||||
|
||||
void wxStaticBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
wxControl::DoSetSize(x, y, width, height, sizeFlags);
|
||||
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
// the static box should always be on the bottom of the Z-order, otherwise
|
||||
// it may hide controls which are positioned inside it
|
||||
if ( !::SetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0,
|
||||
SWP_NOMOVE | SWP_NOSIZE) )
|
||||
{
|
||||
GetSize(&w1, &h1);
|
||||
wxLogLastError(_T("SetWindowPos"));
|
||||
}
|
||||
|
||||
int current_width;
|
||||
|
||||
int cx;
|
||||
int cy;
|
||||
int cyf;
|
||||
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
|
||||
|
||||
GetTextExtent(wxGetWindowText(m_hWnd), ¤t_width, &cyf,
|
||||
NULL,NULL, & this->GetFont());
|
||||
if ( w1 < 0 )
|
||||
w1 = current_width + 3*cx;
|
||||
if ( h1 < 0 )
|
||||
h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cyf);
|
||||
|
||||
MoveWindow((HWND)m_hWnd, x1, y1, w1, h1, TRUE);
|
||||
}
|
||||
|
||||
WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
||||
@@ -202,7 +183,7 @@ void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
|
||||
|
||||
RECT rect;
|
||||
|
||||
::GetClientRect((HWND) GetHWND(), &rect);
|
||||
::GetClientRect(GetHwnd(), &rect);
|
||||
::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
|
||||
::DeleteObject(hBrush);
|
||||
::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
|
||||
@@ -215,7 +196,7 @@ void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
|
||||
|
||||
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
if (nMsg == WM_NCHITTEST)
|
||||
if ( 0 )//nMsg == WM_NCHITTEST)
|
||||
{
|
||||
int xPos = LOWORD(lParam); // horizontal position of cursor
|
||||
int yPos = HIWORD(lParam); // vertical position of cursor
|
||||
|
@@ -94,24 +94,8 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxStaticText::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
wxSize wxStaticText::DoGetBestSize()
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
int actualWidth = width;
|
||||
int actualHeight = height;
|
||||
|
||||
wxString text(wxGetWindowText(GetHWND()));
|
||||
|
||||
int widthTextMax = 0, widthLine,
|
||||
@@ -138,36 +122,16 @@ void wxStaticText::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
}
|
||||
}
|
||||
|
||||
int ww, hh;
|
||||
GetSize(&ww, &hh);
|
||||
|
||||
// If we're prepared to use the existing width, then...
|
||||
if (width == -1 && ((sizeFlags & wxSIZE_AUTO_WIDTH) != wxSIZE_AUTO_WIDTH))
|
||||
{
|
||||
actualWidth = ww;
|
||||
}
|
||||
else if (width == -1)
|
||||
{
|
||||
actualWidth = widthTextMax;
|
||||
}
|
||||
|
||||
// If we're prepared to use the existing height, then...
|
||||
if (height == -1 && ((sizeFlags & wxSIZE_AUTO_HEIGHT) != wxSIZE_AUTO_HEIGHT))
|
||||
{
|
||||
actualHeight = hh;
|
||||
}
|
||||
else if (height == -1)
|
||||
{
|
||||
actualHeight = heightTextTotal;
|
||||
}
|
||||
|
||||
MoveWindow(GetHwnd(), x1, y1, actualWidth, actualHeight, TRUE);
|
||||
return wxSize(widthTextMax, heightTextTotal);
|
||||
}
|
||||
|
||||
void wxStaticText::SetLabel(const wxString& label)
|
||||
{
|
||||
SetWindowText(GetHwnd(), label);
|
||||
|
||||
// adjust the size of the window to fit to the label (this behaviour is
|
||||
// backward compatible and generally makes sense but we might want to still
|
||||
// provide the user a way to disable it) (VZ)
|
||||
DoSetSize(-1, -1, -1, -1, wxSIZE_AUTO_WIDTH | wxSIZE_AUTO_HEIGHT);
|
||||
}
|
||||
|
||||
|
@@ -336,53 +336,15 @@ void wxTextCtrl::SetValue(const wxString& value)
|
||||
AdjustSpaceLimit();
|
||||
}
|
||||
|
||||
void wxTextCtrl::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
wxSize wxTextCtrl::DoGetBestSize()
|
||||
{
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int w1 = width;
|
||||
int h1 = height;
|
||||
int cx, cy;
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, &GetFont());
|
||||
|
||||
if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
x1 = currentX;
|
||||
if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
y1 = currentY;
|
||||
int wText = DEFAULT_ITEM_WIDTH;
|
||||
int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
|
||||
|
||||
AdjustForParentClientOrigin(x1, y1, sizeFlags);
|
||||
|
||||
int cx; // button font dimensions
|
||||
int cy;
|
||||
|
||||
wxGetCharSize(GetHWND(), &cx, &cy, & this->GetFont());
|
||||
|
||||
int control_width, control_height, control_x, control_y;
|
||||
|
||||
// If we're prepared to use the existing size, then...
|
||||
if (width == -1 && height == -1 && ((sizeFlags & wxSIZE_AUTO) != wxSIZE_AUTO))
|
||||
{
|
||||
GetSize(&w1, &h1);
|
||||
}
|
||||
|
||||
// Deal with default size (using -1 values)
|
||||
if (w1<=0)
|
||||
w1 = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
control_x = x1;
|
||||
control_y = y1;
|
||||
control_width = w1;
|
||||
control_height = h1;
|
||||
|
||||
// Calculations may have made text size too small
|
||||
if (control_height <= 0)
|
||||
control_height = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy);
|
||||
|
||||
if (control_width <= 0)
|
||||
control_width = DEFAULT_ITEM_WIDTH;
|
||||
|
||||
MoveWindow(GetHwnd(), (int)control_x, (int)control_y,
|
||||
(int)control_width, (int)control_height, TRUE);
|
||||
return wxSize(wText, hText);
|
||||
}
|
||||
|
||||
// Clipboard operations
|
||||
@@ -759,18 +721,23 @@ void wxTextCtrl::ShowPosition(long pos)
|
||||
int wxTextCtrl::GetLineLength(long lineNo) const
|
||||
{
|
||||
long charIndex = XYToPosition(0, lineNo);
|
||||
HWND hWnd = GetHwnd();
|
||||
int len = (int)SendMessage(hWnd, EM_LINELENGTH, (WPARAM)charIndex, (LPARAM)0);
|
||||
int len = (int)SendMessage(GetHwnd(), EM_LINELENGTH, charIndex, 0);
|
||||
return len;
|
||||
}
|
||||
|
||||
wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||
{
|
||||
HWND hWnd = GetHwnd();
|
||||
*(WORD *)wxBuffer = 512;
|
||||
int noChars = (int)SendMessage(hWnd, EM_GETLINE, (WPARAM)lineNo, (LPARAM)wxBuffer);
|
||||
wxBuffer[noChars] = 0;
|
||||
return wxString(wxBuffer);
|
||||
size_t len = (size_t)GetLineLength(lineNo);
|
||||
char *buf = (char *)malloc(len);
|
||||
*(WORD *)buf = len;
|
||||
int noChars = (int)SendMessage(GetHwnd(), EM_GETLINE, lineNo, (LPARAM)buf);
|
||||
buf[noChars] = 0;
|
||||
|
||||
wxString str(buf);
|
||||
|
||||
free(buf);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
bool wxTextCtrl::CanCopy() const
|
||||
|
@@ -1172,35 +1172,80 @@ void wxWindow::DoGetClientSize(int *x, int *y) const
|
||||
*y = rect.bottom;
|
||||
}
|
||||
|
||||
// set the size of the window: if the dimensions are positive, just use them,
|
||||
// but if any of them is equal to -1, it means that we must find the value for
|
||||
// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
|
||||
// which case -1 is a valid value for x and y)
|
||||
//
|
||||
// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
|
||||
// the width/height to best suit our contents, otherwise we reuse the current
|
||||
// width/height
|
||||
void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
// get the current size and position...
|
||||
int currentX, currentY;
|
||||
GetPosition(¤tX, ¤tY);
|
||||
int currentW,currentH;
|
||||
GetSize(¤tW, ¤tH);
|
||||
|
||||
if ( x == currentX && y == currentY && width == currentW && height == currentH )
|
||||
// ... and don't do anything (avoiding flicker) if it's already ok
|
||||
if ( x == currentX && y == currentY &&
|
||||
width == currentW && height == currentH )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int actualWidth = width;
|
||||
int actualHeight = height;
|
||||
int actualX = x;
|
||||
int actualY = y;
|
||||
if ( x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
||||
actualX = currentX;
|
||||
x = currentX;
|
||||
if ( y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
|
||||
actualY = currentY;
|
||||
y = currentY;
|
||||
|
||||
AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
|
||||
AdjustForParentClientOrigin(x, y, sizeFlags);
|
||||
|
||||
wxSize size(-1, -1);
|
||||
if ( width == -1 )
|
||||
actualWidth = currentW;
|
||||
if ( height == -1 )
|
||||
actualHeight = currentH;
|
||||
{
|
||||
if ( sizeFlags && wxSIZE_AUTO_WIDTH )
|
||||
{
|
||||
size = DoGetBestSize();
|
||||
width = size.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
// just take the current one
|
||||
width = currentW;
|
||||
}
|
||||
}
|
||||
|
||||
HWND hWnd = GetHwnd();
|
||||
if ( hWnd )
|
||||
MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE);
|
||||
if ( height == -1 )
|
||||
{
|
||||
if ( sizeFlags && wxSIZE_AUTO_HEIGHT )
|
||||
{
|
||||
if ( size.x == -1 )
|
||||
{
|
||||
size= DoGetBestSize();
|
||||
}
|
||||
//else: already called DoGetBestSize() above
|
||||
|
||||
height = size.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
// just take the current one
|
||||
height = currentH;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !::MoveWindow(GetHwnd(), x, y, width, height, TRUE) )
|
||||
{
|
||||
wxLogLastError("MoveWindow");
|
||||
}
|
||||
}
|
||||
|
||||
// for a generic window there is no natural best size - just use the current one
|
||||
wxSize wxWindow::DoGetBestSize()
|
||||
{
|
||||
return GetSize();
|
||||
}
|
||||
|
||||
void wxWindow::DoSetClientSize(int width, int height)
|
||||
@@ -1316,7 +1361,7 @@ void wxWindow::GetTextExtent(const wxString& string,
|
||||
|
||||
SIZE sizeRect;
|
||||
TEXTMETRIC tm;
|
||||
GetTextExtentPoint(dc, (const wxChar *)string, (int)string.Length(), &sizeRect);
|
||||
GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
|
||||
GetTextMetrics(dc, &tm);
|
||||
|
||||
if ( fontToUse && fnt && hfontOld )
|
||||
|
Reference in New Issue
Block a user