1. buttons now generate double click events

2. double clicking in the tree ctrl generates an activate event
3. bug with hidden listbox mysteriously being shown fixed
4. tried to adjust the checkbox size


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7364 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-05-07 20:35:00 +00:00
parent 6b958cfc0b
commit cdde63f535
5 changed files with 66 additions and 35 deletions

View File

@@ -74,7 +74,7 @@ bool wxButton::Create(wxWindow *parent,
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD /* | WS_CLIPSIBLINGS */ ;
long msStyle = WS_VISIBLE | WS_TABSTOP | WS_CHILD /* | WS_CLIPSIBLINGS */ ;
#ifdef __WIN32__
if(m_windowStyle & wxBU_LEFT)
@@ -280,11 +280,16 @@ long wxButton::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
// let the default processign take place too
}
// VZ: I don't remember any more why was this needed but everything seems
// to work just fine without this code and it prevents LDCLICK events
// from being generated, so I will probably remoe it completely soon
#if 0
else if ( nMsg == WM_LBUTTONDBLCLK )
{
// trick the base class into thinking that this was just a click
nMsg = WM_LBUTTONDOWN;
}
#endif // 0
// let the base class do all real processing
return wxControl::MSWWindowProc(nMsg, wParam, lParam);

View File

@@ -142,29 +142,39 @@ bool wxCheckBox::Create(wxWindow *parent,
void wxCheckBox::SetLabel(const wxString& label)
{
SetWindowText(GetHwnd(), label);
SetWindowText(GetHwnd(), label);
}
#define CHECK_SIZE 13
wxSize wxCheckBox::DoGetBestSize() const
{
int wCheckbox, hCheckbox;
static int s_checkSize = 0;
if ( !s_checkSize )
{
wxScreenDC dc;
dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
// the height of a standard button in the dialog units is 8,
// translate this to pixels (as one dialog unit is precisely equal to
// 8 character heights, it's just the char height)
s_checkSize = dc.GetCharHeight();
}
wxString str = wxGetWindowText(GetHWND());
int wCheckbox, hCheckbox;
if ( !str.IsEmpty() )
{
GetTextExtent(str, &wCheckbox, &hCheckbox);
wCheckbox += CHECK_SIZE + GetCharWidth();
wCheckbox += s_checkSize + GetCharWidth();
if ( hCheckbox < CHECK_SIZE )
hCheckbox = CHECK_SIZE;
if ( hCheckbox < s_checkSize )
hCheckbox = s_checkSize;
}
else
{
wCheckbox = CHECK_SIZE;
hCheckbox = CHECK_SIZE;
wCheckbox = s_checkSize;
hCheckbox = s_checkSize;
}
return wxSize(wCheckbox, hCheckbox);

View File

@@ -221,8 +221,6 @@ bool wxListBox::Create(wxWindow *parent,
SetSize(x, y, width, height);
Show(TRUE);
return TRUE;
}
@@ -292,7 +290,12 @@ int wxListBox::DoAppend(const wxString& item)
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
{
ShowWindow(GetHwnd(), SW_HIDE);
// avoid flicker - but don't need to do this for a hidden listbox
bool hideAndShow = IsShown();
if ( hideAndShow )
{
ShowWindow(GetHwnd(), SW_HIDE);
}
ListBox_ResetContent(GetHwnd());
@@ -333,7 +336,11 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
SetHorizontalExtent();
ShowWindow(GetHwnd(), SW_SHOW);
if ( hideAndShow )
{
// show the listbox back if we hid it
ShowWindow(GetHwnd(), SW_SHOW);
}
}
int wxListBox::FindString(const wxString& s) const

View File

@@ -1940,25 +1940,6 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
switch ( hdr->code )
{
case NM_RCLICK:
{
if ( wxControl::MSWOnNotify(idCtrl, lParam, result) )
return TRUE;
TV_HITTESTINFO tvhti;
::GetCursorPos(&(tvhti.pt));
::ScreenToClient(GetHwnd(),&(tvhti.pt));
if ( TreeView_HitTest(GetHwnd(),&tvhti) )
{
if( tvhti.flags & TVHT_ONITEM )
{
event.m_item = (WXHTREEITEM) tvhti.hItem;
eventType = wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
}
}
}
break;
case TVN_BEGINDRAG:
eventType = wxEVT_COMMAND_TREE_BEGIN_DRAG;
// fall through
@@ -2203,6 +2184,27 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
break;
#endif // _WIN32_IE >= 0x300
case NM_DBLCLK:
case NM_RCLICK:
{
TV_HITTESTINFO tvhti;
::GetCursorPos(&tvhti.pt);
::ScreenToClient(GetHwnd(), &tvhti.pt);
if ( TreeView_HitTest(GetHwnd(), &tvhti) )
{
if ( tvhti.flags & TVHT_ONITEM )
{
event.m_item = (WXHTREEITEM) tvhti.hItem;
eventType = hdr->code == NM_DBLCLK
? wxEVT_COMMAND_TREE_ITEM_ACTIVATED
: wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK;
}
break;
}
}
// fall through
default:
return wxControl::MSWOnNotify(idCtrl, lParam, result);
}
@@ -2215,6 +2217,12 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
// post processing
switch ( hdr->code )
{
case NM_DBLCLK:
// return TRUE to prevent the default processing which consists in
// toggling the state of the item under the mouse
*result = processed;
break;
case TVN_BEGINDRAG:
case TVN_BEGINRDRAG:
if ( event.IsAllowed() )

View File

@@ -1624,7 +1624,10 @@ bool wxWindow::MSWProcessMessage(WXMSG* pMsg)
#endif // 0
if ( ::IsDialogMessage(GetHwnd(), msg) )
{
// IsDialogMessage() did something...
return TRUE;
}
}
#if wxUSE_TOOLTIPS
@@ -2435,8 +2438,6 @@ bool wxWindow::HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
if ( child->MSWOnNotify(idCtrl, lParam, result) )
{
return TRUE;
break;
}
node = node->GetNext();