1. wxStaticBox doesn't draw over the underlying controls any more
2. a couple of new helper functions in msw/private.h: wxColourToRGB and wxRGBToColour are handy to avoid writing horribly long and ugly RGB <-> wxColour conversions explicitly 3. modified wxDirDialog to be more comprehensible (to me), hopefully it also works better git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,8 +34,8 @@ public:
|
|||||||
virtual void Command(wxCommandEvent &event);
|
virtual void Command(wxCommandEvent &event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// creates the controls (invokes wxWindowBase::CreateBase) and adds it to
|
// creates the control (calls wxWindowBase::CreateBase inside) and adds it
|
||||||
// the list of parents children
|
// to the list of parents children
|
||||||
bool CreateControl(wxWindowBase *parent,
|
bool CreateControl(wxWindowBase *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
@@ -50,6 +50,18 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
const wxString& name);
|
const wxString& name);
|
||||||
|
|
||||||
|
// an overloaded version for the controls without validators
|
||||||
|
bool CreateControl(wxWindowBase *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
return CreateControl(parent, id, pos, size, style,
|
||||||
|
wxDefaultValidator, name);
|
||||||
|
}
|
||||||
|
|
||||||
// inherit colour and font settings from the parent window
|
// inherit colour and font settings from the parent window
|
||||||
void InheritAttributes();
|
void InheritAttributes();
|
||||||
};
|
};
|
||||||
|
@@ -76,8 +76,8 @@ protected:
|
|||||||
bool MSWCreateControl(const wxChar *classname, WXDWORD style);
|
bool MSWCreateControl(const wxChar *classname, WXDWORD style);
|
||||||
|
|
||||||
// determine the extended styles combination for this window (may slightly
|
// determine the extended styles combination for this window (may slightly
|
||||||
// modify styl parameter)
|
// modify style parameter, this is why it's non const)
|
||||||
WXDWORD GetExStyle(WXDWORD& style) const;
|
WXDWORD GetExStyle(WXDWORD& style, bool *want3D) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -286,7 +286,11 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) )
|
|||||||
|
|
||||||
void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
|
void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
wxDirDialog dialog(this, "Testing directory picker", "");
|
// pass some initial dir to wxDirDialog
|
||||||
|
wxString dirHome;
|
||||||
|
wxGetHomeDir(&dirHome);
|
||||||
|
|
||||||
|
wxDirDialog dialog(this, "Testing directory picker", dirHome);
|
||||||
|
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
|
@@ -889,6 +889,7 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
|
|||||||
textData.AddFile( "/file2.txt" );
|
textData.AddFile( "/file2.txt" );
|
||||||
*/
|
*/
|
||||||
wxDropSource source(textData, this
|
wxDropSource source(textData, this
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
,wxCURSOR_PENCIL, // for copy
|
,wxCURSOR_PENCIL, // for copy
|
||||||
wxCURSOR_SPRAYCAN, // for move
|
wxCURSOR_SPRAYCAN, // for move
|
||||||
@@ -1043,15 +1044,23 @@ void DnDFrame::OnPasteBitmap(wxCommandEvent& WXUNUSED(event))
|
|||||||
void DnDFrame::OnCopyFiles(wxCommandEvent& WXUNUSED(event))
|
void DnDFrame::OnCopyFiles(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
wxFileDataObject *dobj = new wxFileDataObject;
|
|
||||||
|
|
||||||
wxFileDialog dialog(this, "Select a file to copy", "", "",
|
wxFileDialog dialog(this, "Select a file to copy", "", "",
|
||||||
"All files (*.*)|*.*", 0);
|
"All files (*.*)|*.*", 0);
|
||||||
|
|
||||||
if ( dialog.ShowModal() == wxID_OK )
|
wxArrayString filenames;
|
||||||
|
while ( dialog.ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
wxString filename = dialog.GetPath();
|
filenames.Add(dialog.GetPath());
|
||||||
dobj->AddFile(filename);
|
}
|
||||||
|
|
||||||
|
if ( !filenames.IsEmpty() )
|
||||||
|
{
|
||||||
|
wxFileDataObject *dobj = new wxFileDataObject;
|
||||||
|
size_t count = filenames.GetCount();
|
||||||
|
for ( size_t n = 0; n < count; n++ )
|
||||||
|
{
|
||||||
|
dobj->AddFile(filenames[n]);
|
||||||
|
}
|
||||||
|
|
||||||
wxClipboardLocker locker;
|
wxClipboardLocker locker;
|
||||||
if ( !locker )
|
if ( !locker )
|
||||||
@@ -1062,12 +1071,12 @@ void DnDFrame::OnCopyFiles(wxCommandEvent& WXUNUSED(event))
|
|||||||
{
|
{
|
||||||
if ( !wxTheClipboard->AddData(dobj) )
|
if ( !wxTheClipboard->AddData(dobj) )
|
||||||
{
|
{
|
||||||
wxLogError("Can't copy file to the clipboard");
|
wxLogError("Can't copy file(s) to the clipboard");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogStatus(this, "File '%s' copied to the clipboard",
|
wxLogStatus(this, "%d file%s copied to the clipboard",
|
||||||
filename.c_str());
|
count, count == 1 ? "" : "s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -60,9 +60,17 @@ wxControl::~wxControl()
|
|||||||
|
|
||||||
bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style)
|
bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style)
|
||||||
{
|
{
|
||||||
|
// VZ: if someone could put a comment here explaining what exactly this is
|
||||||
|
// needed for, it would be nice...
|
||||||
|
bool want3D;
|
||||||
|
|
||||||
|
// all controls have these childs (wxWindows creates all controls visible
|
||||||
|
// by default)
|
||||||
|
style |= WS_CHILD | WS_VISIBLE;
|
||||||
|
|
||||||
m_hWnd = (WXHWND)::CreateWindowEx
|
m_hWnd = (WXHWND)::CreateWindowEx
|
||||||
(
|
(
|
||||||
GetExStyle(style), // extended style
|
GetExStyle(style, &want3D), // extended style
|
||||||
classname, // the kind of control to create
|
classname, // the kind of control to create
|
||||||
NULL, // the window name
|
NULL, // the window name
|
||||||
style, // the window style
|
style, // the window style
|
||||||
@@ -82,6 +90,14 @@ bool wxControl::MSWCreateControl(const wxChar *classname, WXDWORD style)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_CTL3D
|
||||||
|
if ( want3D )
|
||||||
|
{
|
||||||
|
Ctl3dSubclassCtl(GetHwnd());
|
||||||
|
m_useCtl3D = TRUE;
|
||||||
|
}
|
||||||
|
#endif // wxUSE_CTL3D
|
||||||
|
|
||||||
// subclass again for purposes of dialog editing mode
|
// subclass again for purposes of dialog editing mode
|
||||||
SubclassWin(m_hWnd);
|
SubclassWin(m_hWnd);
|
||||||
|
|
||||||
@@ -168,26 +184,25 @@ void wxControl::OnEraseBackground(wxEraseEvent& event)
|
|||||||
// might flicker.
|
// might flicker.
|
||||||
|
|
||||||
RECT rect;
|
RECT rect;
|
||||||
::GetClientRect((HWND) GetHWND(), &rect);
|
::GetClientRect(GetHwnd(), &rect);
|
||||||
|
|
||||||
HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(),
|
HBRUSH hBrush = ::CreateSolidBrush(wxColourToRGB(GetBackgroundColour()));
|
||||||
GetBackgroundColour().Green(),
|
|
||||||
GetBackgroundColour().Blue()));
|
|
||||||
int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
|
|
||||||
|
|
||||||
::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
|
HDC hdc = GetHdcOf((*event.GetDC()));
|
||||||
|
int mode = ::SetMapMode(hdc, MM_TEXT);
|
||||||
|
|
||||||
|
::FillRect(hdc, &rect, hBrush);
|
||||||
::DeleteObject(hBrush);
|
::DeleteObject(hBrush);
|
||||||
::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
|
::SetMapMode(hdc, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
WXDWORD wxControl::GetExStyle(WXDWORD& style) const
|
WXDWORD wxControl::GetExStyle(WXDWORD& style, bool *want3D) const
|
||||||
{
|
{
|
||||||
bool want3D;
|
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, want3D);
|
||||||
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
|
|
||||||
|
|
||||||
// Even with extended styles, need to combine with WS_BORDER
|
// Even with extended styles, need to combine with WS_BORDER for them to
|
||||||
// for them to look right.
|
// look right.
|
||||||
if ( want3D || wxStyleHasBorder(m_windowStyle) )
|
if ( *want3D || wxStyleHasBorder(m_windowStyle) )
|
||||||
style |= WS_BORDER;
|
style |= WS_BORDER;
|
||||||
|
|
||||||
return exStyle;
|
return exStyle;
|
||||||
|
@@ -9,6 +9,13 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "dirdlg.h"
|
#pragma implementation "dirdlg.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -21,139 +28,163 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/defs.h"
|
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/dirdlg.h"
|
#include "wx/dirdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(__WIN95__) && !defined(__GNUWIN32__))||defined(wxUSE_NORLANDER_HEADERS)
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
|
#if defined(__WIN95__) && \
|
||||||
|
(!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS))
|
||||||
|
#define CAN_COMPILE_DIRDLG
|
||||||
|
//#else: we provide a stub version which doesn't do anything
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CAN_COMPILE_DIRDLG
|
||||||
#include "shlobj.h" // Win95 shell
|
#include "shlobj.h" // Win95 shell
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/cmndata.h"
|
// constants
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <math.h>
|
#ifndef MAX_PATH
|
||||||
#include <stdlib.h>
|
#define MAX_PATH 4096 // be generuous
|
||||||
#include <string.h>
|
#endif
|
||||||
|
|
||||||
#define wxDIALOG_DEFAULT_X 300
|
// ----------------------------------------------------------------------------
|
||||||
#define wxDIALOG_DEFAULT_Y 300
|
// wxWindows macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_CLASS(wxDirDialog, wxDialog)
|
IMPLEMENT_CLASS(wxDirDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int CALLBACK
|
// ----------------------------------------------------------------------------
|
||||||
BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
|
// private functions prototypes
|
||||||
{
|
// ----------------------------------------------------------------------------
|
||||||
TCHAR szDir[MAX_PATH];
|
|
||||||
|
|
||||||
switch(uMsg)
|
// free the parameter
|
||||||
{
|
static void ItemListFree(LPITEMIDLIST pidl);
|
||||||
case BFFM_INITIALIZED:
|
|
||||||
// We have put m_path into pData.
|
|
||||||
// TRUE -> passing char *, not dir id.
|
|
||||||
SendMessage(hwnd,BFFM_SETSELECTION,TRUE,pData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BFFM_SELCHANGED:
|
// the callback proc for the dir dlg
|
||||||
// Set the status window to the currently selected path.
|
static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp,
|
||||||
if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir))
|
LPARAM pData);
|
||||||
{
|
|
||||||
SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
// ============================================================================
|
||||||
break;
|
// implementation
|
||||||
}
|
// ============================================================================
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxDirDialog
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
|
wxDirDialog::wxDirDialog(wxWindow *parent,
|
||||||
// const wxString& caption,
|
const wxString& message,
|
||||||
const wxString& defaultPath,
|
const wxString& defaultPath,
|
||||||
long style, const wxPoint& pos)
|
long WXUNUSED(style),
|
||||||
|
const wxPoint& WXUNUSED(pos))
|
||||||
{
|
{
|
||||||
m_message = message;
|
m_message = message;
|
||||||
// m_caption = caption;
|
|
||||||
m_dialogStyle = style;
|
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
m_path = defaultPath;
|
m_path = defaultPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxDirDialog::ShowModal(void)
|
int wxDirDialog::ShowModal()
|
||||||
{
|
{
|
||||||
// Unfortunately Gnu-Win32 doesn't yet have COM support
|
#ifdef CAN_COMPILE_DIRDLG
|
||||||
#if (defined(__WIN95__) && !defined(__GNUWIN32__))||defined(wxUSE_NORLANDER_HEADERS)
|
|
||||||
HWND hWnd = 0;
|
|
||||||
if (m_parent) hWnd = (HWND) m_parent->GetHWND();
|
|
||||||
|
|
||||||
BROWSEINFO bi;
|
BROWSEINFO bi;
|
||||||
LPTSTR lpBuffer;
|
bi.hwndOwner = m_parent ? GetHwndOf(m_parent) : NULL;
|
||||||
// LPITEMIDLIST pidlPrograms; // PIDL for Programs folder
|
bi.pidlRoot = NULL;
|
||||||
LPITEMIDLIST pidlBrowse; // PIDL selected by user
|
bi.pszDisplayName = NULL;
|
||||||
LPMALLOC pMalloc = NULL;
|
bi.lpszTitle = m_message.c_str();
|
||||||
|
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
|
||||||
HRESULT result = ::SHGetMalloc(&pMalloc);
|
|
||||||
|
|
||||||
if (result != NOERROR)
|
|
||||||
return wxID_CANCEL;
|
|
||||||
|
|
||||||
// Allocate a buffer to receive browse information.
|
|
||||||
if ((lpBuffer = (LPTSTR) pMalloc->Alloc(MAX_PATH)) == NULL)
|
|
||||||
{
|
|
||||||
pMalloc->Release();
|
|
||||||
return wxID_CANCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Get the PIDL for the Programs folder.
|
|
||||||
if (!SUCCEEDED(SHGetSpecialFolderLocation(
|
|
||||||
parent->GetSafeHwnd(), CSIDL_PROGRAMS, &pidlPrograms))) {
|
|
||||||
pMalloc->Free(lpBuffer);
|
|
||||||
pMalloc->Release();
|
|
||||||
return wxID_CANCEL;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Fill in the BROWSEINFO structure.
|
|
||||||
bi.hwndOwner = hWnd;
|
|
||||||
bi.pidlRoot = NULL; // pidlPrograms;
|
|
||||||
bi.pszDisplayName = lpBuffer;
|
|
||||||
bi.lpszTitle = m_message; // BC++ 4.52 says LPSTR, not LPTSTR?
|
|
||||||
bi.ulFlags = 0;
|
|
||||||
bi.lpfn = BrowseCallbackProc;
|
bi.lpfn = BrowseCallbackProc;
|
||||||
bi.lParam = (LPARAM)m_path.c_str();
|
bi.lParam = (LPARAM)m_path.c_str(); // param for the callback
|
||||||
|
|
||||||
// Browse for a folder and return its PIDL.
|
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
|
||||||
pidlBrowse = SHBrowseForFolder(&bi);
|
|
||||||
|
|
||||||
int id = wxID_OK;
|
if ( bi.pidlRoot )
|
||||||
if (pidlBrowse != NULL) {
|
{
|
||||||
|
ItemListFree((LPITEMIDLIST)bi.pidlRoot);
|
||||||
|
}
|
||||||
|
|
||||||
// Show the display name, title, and file system path.
|
if ( !pidl )
|
||||||
if (SHGetPathFromIDList(pidlBrowse, lpBuffer))
|
{
|
||||||
m_path = lpBuffer;
|
// Cancel button pressed
|
||||||
|
return wxID_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
// Free the PIDL returned by SHBrowseForFolder.
|
BOOL ok = SHGetPathFromIDList(pidl, m_path.GetWriteBuf(MAX_PATH));
|
||||||
pMalloc->Free(pidlBrowse);
|
m_path.UngetWriteBuf();
|
||||||
|
|
||||||
|
ItemListFree(pidl);
|
||||||
|
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
|
wxLogLastError("SHGetPathFromIDList");
|
||||||
|
|
||||||
|
return wxID_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxID_OK;
|
||||||
|
#else // !CAN_COMPILE_DIRDLG
|
||||||
|
return wxID_CANCEL;
|
||||||
|
#endif // CAN_COMPILE_DIRDLG/!CAN_COMPILE_DIRDLG
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static int CALLBACK
|
||||||
|
BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
|
||||||
|
{
|
||||||
|
switch(uMsg)
|
||||||
|
{
|
||||||
|
case BFFM_INITIALIZED:
|
||||||
|
// sent immediately after initialisation and so we may set the
|
||||||
|
// initial selection here
|
||||||
|
//
|
||||||
|
// wParam = TRUE => lParam is a string and not a PIDL
|
||||||
|
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BFFM_SELCHANGED:
|
||||||
|
{
|
||||||
|
// Set the status window to the currently selected path.
|
||||||
|
TCHAR szDir[MAX_PATH];
|
||||||
|
if ( SHGetPathFromIDList((LPITEMIDLIST)lp, szDir) )
|
||||||
|
{
|
||||||
|
SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
//case BFFM_VALIDATEFAILED: -- might be used to provide custom message
|
||||||
|
// if the user types in invalid dir name
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void ItemListFree(LPITEMIDLIST pidl)
|
||||||
|
{
|
||||||
|
if ( pidl )
|
||||||
|
{
|
||||||
|
LPMALLOC pMalloc;
|
||||||
|
SHGetMalloc(&pMalloc);
|
||||||
|
if ( pMalloc )
|
||||||
|
{
|
||||||
|
pMalloc->Free(pidl);
|
||||||
|
pMalloc->Release();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
id = wxID_CANCEL;
|
{
|
||||||
|
wxLogLastError("SHGetMalloc");
|
||||||
// Clean up.
|
}
|
||||||
// pMalloc->Free(pidlPrograms);
|
}
|
||||||
pMalloc->Free(lpBuffer);
|
|
||||||
pMalloc->Release();
|
|
||||||
|
|
||||||
return id;
|
|
||||||
#else
|
|
||||||
return wxID_CANCEL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: statbox.cpp
|
// Name: msw/statbox.cpp
|
||||||
// Purpose: wxStaticBox
|
// Purpose: wxStaticBox
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by:
|
||||||
@@ -9,6 +9,14 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "statbox.h"
|
#pragma implementation "statbox.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -20,9 +28,6 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/window.h"
|
|
||||||
#include "wx/msw/private.h"
|
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
@@ -30,6 +35,12 @@
|
|||||||
|
|
||||||
#include "wx/statbox.h"
|
#include "wx/statbox.h"
|
||||||
|
|
||||||
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
||||||
|
|
||||||
@@ -39,62 +50,29 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// ============================================================================
|
||||||
* Group box
|
// implementation
|
||||||
*/
|
// ============================================================================
|
||||||
|
|
||||||
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxStaticBox
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxStaticBox::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
const wxString& label,
|
const wxString& label,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
const wxString& name)
|
const wxString& name)
|
||||||
{
|
{
|
||||||
SetName(name);
|
if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (parent) parent->AddChild(this);
|
if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
SetBackgroundColour(parent->GetBackgroundColour()) ;
|
SetSize(pos.x, pos.y, size.x, size.y);
|
||||||
SetForegroundColour(parent->GetForegroundColour()) ;
|
|
||||||
|
|
||||||
if ( id == -1 )
|
|
||||||
m_windowId = (int)NewControlId();
|
|
||||||
else
|
|
||||||
m_windowId = id;
|
|
||||||
|
|
||||||
int x = pos.x;
|
|
||||||
int y = pos.y;
|
|
||||||
int width = size.x;
|
|
||||||
int height = size.y;
|
|
||||||
|
|
||||||
m_windowStyle = style;
|
|
||||||
|
|
||||||
long msStyle = BS_GROUPBOX | WS_CHILD | WS_VISIBLE ; // GROUP_FLAGS;
|
|
||||||
|
|
||||||
bool want3D;
|
|
||||||
WXDWORD exStyle = Determine3DEffects(0, &want3D) ;
|
|
||||||
|
|
||||||
HWND wx_button =
|
|
||||||
CreateWindowEx(exStyle, wxT("BUTTON"), (const wxChar *)label, msStyle,
|
|
||||||
0, 0, 0, 0, (HWND) parent->GetHWND(), (HMENU)m_windowId,
|
|
||||||
wxGetInstance(), NULL);
|
|
||||||
#if wxUSE_CTL3D
|
|
||||||
if (want3D)
|
|
||||||
{
|
|
||||||
Ctl3dSubclassCtl(wx_button);
|
|
||||||
m_useCtl3D = TRUE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_hWnd = (WXHWND)wx_button;
|
|
||||||
|
|
||||||
// Subclass again for purposes of dialog editing mode
|
|
||||||
SubclassWin(GetHWND());
|
|
||||||
|
|
||||||
SetFont(parent->GetFont());
|
|
||||||
|
|
||||||
SetSize(x, y, width, height);
|
|
||||||
ShowWindow(wx_button, SW_SHOW);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -124,24 +102,28 @@ WXHBRUSH wxStaticBox::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
|
|||||||
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
|
HBRUSH hbrush = Ctl3dCtlColorEx(message, wParam, lParam);
|
||||||
return (WXHBRUSH) hbrush;
|
return (WXHBRUSH) hbrush;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // wxUSE_CTL3D
|
||||||
|
|
||||||
|
HDC hdc = (HDC)pDC;
|
||||||
if (GetParent()->GetTransparentBackground())
|
if (GetParent()->GetTransparentBackground())
|
||||||
SetBkMode((HDC) pDC, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
else
|
else
|
||||||
SetBkMode((HDC) pDC, OPAQUE);
|
SetBkMode(hdc, OPAQUE);
|
||||||
|
|
||||||
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
|
const wxColour& colBack = GetBackgroundColour();
|
||||||
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
|
::SetBkColor(hdc, wxColourToRGB(colBack));
|
||||||
|
::SetTextColor(hdc, wxColourToRGB(GetForegroundColour()));
|
||||||
|
|
||||||
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
|
wxBrush *brush= wxTheBrushList->FindOrCreateBrush(colBack, wxSOLID);
|
||||||
|
|
||||||
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
|
return (WXHBRUSH)brush->GetResourceHandle();
|
||||||
// has a zero usage count.
|
|
||||||
// backgroundBrush->RealizeResource();
|
|
||||||
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VZ: this is probably the most commented function in wxWindows, but I still
|
||||||
|
// don't understand what it does and why. Wouldn't it be better to _never_
|
||||||
|
// erase the background here? What would we lose if we didn't do it?
|
||||||
|
// (FIXME)
|
||||||
|
|
||||||
// Shouldn't erase the whole window, since the static box must only paint its
|
// Shouldn't erase the whole window, since the static box must only paint its
|
||||||
// outline.
|
// outline.
|
||||||
void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
|
void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
|
||||||
@@ -162,25 +144,17 @@ void wxStaticBox::OnEraseBackground(wxEraseEvent& event)
|
|||||||
// few other circumstances where it matters about child clipping. But what about painting onto
|
// few other circumstances where it matters about child clipping. But what about painting onto
|
||||||
// to panel, inside a groupbox? Doesn't appear, because the box wipes it out.
|
// to panel, inside a groupbox? Doesn't appear, because the box wipes it out.
|
||||||
wxWindow *parent = GetParent();
|
wxWindow *parent = GetParent();
|
||||||
if ( parent && parent->GetHWND() && (::GetWindowLong((HWND) parent->GetHWND(), GWL_STYLE) & WS_CLIPCHILDREN) )
|
if ( parent && parent->GetHWND() &&
|
||||||
|
(::GetWindowLong(GetHwndOf(parent), GWL_STYLE) & WS_CLIPCHILDREN) )
|
||||||
{
|
{
|
||||||
// TODO: May in fact need to generate a paint event for inside this
|
// TODO: May in fact need to generate a paint event for inside this
|
||||||
// control's rectangle, otherwise all controls are going to be clipped -
|
// control's rectangle, otherwise all controls are going to be clipped -
|
||||||
// ugh.
|
// ugh.
|
||||||
HBRUSH hBrush = ::CreateSolidBrush(PALETTERGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
|
|
||||||
int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT);
|
|
||||||
|
|
||||||
RECT rect;
|
// let wxControl::OnEraseBackground() do the job
|
||||||
|
|
||||||
::GetClientRect(GetHwnd(), &rect);
|
|
||||||
::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush);
|
|
||||||
::DeleteObject(hBrush);
|
|
||||||
::SetMapMode((HDC) event.GetDC()->GetHDC(), mode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
//else: do *not* call event.Skip() or wxControl will erase the background
|
||||||
}
|
}
|
||||||
|
|
||||||
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
long wxStaticBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||||
|
Reference in New Issue
Block a user