projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wxWindow::Fit() infinite loop bug fixed
[wxWidgets.git]
/
src
/
msw
/
choice.cpp
diff --git
a/src/msw/choice.cpp
b/src/msw/choice.cpp
index 2945076d06597fdb53d1a98224d17e05632c3c1b..cf0aec140ebdc5638817d3bee0f0fe7d7d188542 100644
(file)
--- a/
src/msw/choice.cpp
+++ b/
src/msw/choice.cpp
@@
-6,7
+6,7
@@
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
-// Licence: wxWindows license
+// Licence:
wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@
-22,6
+22,7
@@
#ifndef WX_PRECOMP
#include "wx/choice.h"
#ifndef WX_PRECOMP
#include "wx/choice.h"
+#include "wx/utils.h"
#endif
#include "wx/msw/private.h"
#endif
#include "wx/msw/private.h"
@@
-37,35
+38,36
@@
bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId);
event.SetInt(GetSelection());
event.SetEventObject(this);
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId);
event.SetInt(GetSelection());
event.SetEventObject(this);
- event.SetString(
copystring(GetStringSelection()
));
+ event.SetString(
GetStringSelection(
));
ProcessCommand(event);
ProcessCommand(event);
- delete[] event.GetString();
+
return TRUE;
}
return TRUE;
}
- else return FALSE;
+ else
+ return FALSE;
}
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
}
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
-
int n, const wxString choices[],
-
long style,
+ int n, const wxString choices[],
+ long style,
const wxValidator& validator,
const wxString& name)
{
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
const wxValidator& validator,
const wxString& name)
{
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
- SetBackgroundColour(parent->Get
Default
BackgroundColour()) ;
- SetForegroundColour(parent->Get
Default
ForegroundColour()) ;
- m_noStrings =
n
;
+ SetBackgroundColour(parent->GetBackgroundColour()) ;
+ SetForegroundColour(parent->GetForegroundColour()) ;
+ m_noStrings =
0
;
m_windowStyle = style;
if ( id == -1 )
m_windowStyle = style;
if ( id == -1 )
-
m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
else
-
m_windowId = id;
+ m_windowId = id;
int x = pos.x;
int y = pos.y;
int x = pos.x;
int y = pos.y;
@@
-82,16
+84,18
@@
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
- if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) ||
- (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))
+ if ( want3D || wxStyleHasBorder(m_windowStyle) )
msStyle |= WS_BORDER;
msStyle |= WS_BORDER;
-
HWND wx_combo =
CreateWindowEx(exStyle, "COMBOBOX", NULL,
+
m_hWnd = (WXHWND)::
CreateWindowEx(exStyle, "COMBOBOX", NULL,
msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
msStyle,
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
wxGetInstance(), NULL);
+
+ wxCHECK_MSG( m_hWnd, FALSE, "Failed to create combobox" );
+
/*
/*
-#if CTL3D
+#if
wxUSE_
CTL3D
if (want3D)
{
m_useCtl3D = TRUE;
if (want3D)
{
m_useCtl3D = TRUE;
@@
-100,17
+104,17
@@
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
#endif
*/
#endif
*/
- m_hWnd = (WXHWND) wx_combo;
-
// Subclass again for purposes of dialog editing mode
// Subclass again for purposes of dialog editing mode
- SubclassWin(
(WXHWND) wx_combo
);
+ SubclassWin(
m_hWnd
);
- SetFont(
*
parent->GetFont());
+ SetFont(parent->GetFont());
int i;
for (i = 0; i < n; i++)
int i;
for (i = 0; i < n; i++)
- SendMessage(wx_combo, CB_INSERTSTRING, i, (LONG)(const char *)choices[i]);
- SendMessage(wx_combo, CB_SETCURSEL, i, 0);
+ {
+ Append(choices[i]);
+ }
+ SetSelection(n);
SetSize(x, y, width, height);
SetSize(x, y, width, height);
@@
-177,7
+181,7
@@
wxString wxChoice::GetString(int n) const
return wxString(wxBuffer);
}
return wxString(wxBuffer);
}
-void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
+void wxChoice::
Do
SetSize(int x, int y, int width, int height, int sizeFlags)
{
int currentX, currentY;
GetPosition(¤tX, ¤tY);
{
int currentX, currentY;
GetPosition(¤tX, ¤tY);
@@
-202,9
+206,9
@@
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
int cx; // button font dimensions
int cy;
int cx; // button font dimensions
int cy;
- wxGetCharSize(GetHWND(), &cx, &cy, GetFont());
+ wxGetCharSize(GetHWND(), &cx, &cy,
& this->
GetFont());
-
floa
t control_width, control_height;
+
in
t control_width, control_height;
// Ignore height parameter because height doesn't
// mean 'initially displayed' height, it refers to the
// Ignore height parameter because height doesn't
// mean 'initially displayed' height, it refers to the
@@
-219,52
+223,58
@@
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
{
// Find the longest string
if (m_noStrings == 0)
{
// Find the longest string
if (m_noStrings == 0)
- control_width = (float)100.0;
+ {
+ control_width = 100;
+ }
else
{
int len, ht;
else
{
int len, ht;
-
float longest = (float)0.
0;
+
int longest =
0;
int i;
for (i = 0; i < m_noStrings; i++)
{
wxString str(GetString(i));
int i;
for (i = 0; i < m_noStrings; i++)
{
wxString str(GetString(i));
- GetTextExtent(str, &len, &ht, NULL, NULL,GetFont());
- if ( len > longest) longest = len;
+ GetTextExtent(str, &len, &ht, NULL, NULL, & this->GetFont());
+ if ( len > longest)
+ longest = len;
}
}
- control_width =
(float)(int)(longest + cx*5)
;
+ control_width =
longest + cx*5
;
}
}
}
}
+ else
+ {
+ // If non-default width...
+ control_width = w1;
+ }
+
// Choice drop-down list depends on number of items (limited to 10)
if (h1 <= 0)
{
if (m_noStrings == 0)
// Choice drop-down list depends on number of items (limited to 10)
if (h1 <= 0)
{
if (m_noStrings == 0)
- h1 = (int)(EDIT_CONTROL_FACTOR*cy*10.0);
- else h1 = (int)(EDIT_CONTROL_FACTOR*cy*(wxMin(10, m_noStrings) + 1));
+ h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*10;
+ else
+ h1 = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMin(10, m_noStrings) + 1);
}
}
- // If non-default width...
- if (width >= 0)
- control_width = (float)width;
-
- control_height = (float)h1;
+ control_height = h1;
// Calculations may have made text size too small
if (control_height <= 0)
// Calculations may have made text size too small
if (control_height <= 0)
- control_height =
(float)(int)(cy*EDIT_CONTROL_FACTOR)
;
+ control_height =
EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)
;
if (control_width <= 0)
if (control_width <= 0)
- control_width =
(float)100.
0;
+ control_width =
10
0;
- MoveWindow((HWND)
GetHWND(), x1, y1,
-
(int)control_width, (int)
control_height, TRUE);
+ MoveWindow((HWND)GetHWND(), x1, y1,
+
control_width,
control_height, TRUE);
}
WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
}
WXHBRUSH wxChoice::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
-
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
+ WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
{
-
return 0;
+ return 0;
}
long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
}
long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
@@
-303,7
+313,7
@@
long wxChoice::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
// with x = 65535 and y = 65535.
// Filter out this nonsense.
if (x == 65535 && y == 65535)
// with x = 65535 and y = 65535.
// Filter out this nonsense.
if (x == 65535 && y == 65535)
- return
Default()
;
+ return
0
;
break;
}
}
break;
}
}