*** empty log message ***

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4043 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-10-18 03:30:47 +00:00
parent 45bee2eea9
commit d90895ac11
28 changed files with 5800 additions and 1646 deletions

View File

@@ -351,6 +351,19 @@ OS2OBJS = \
..\os2\$D\spinctrl.obj \
..\os2\$D\statbmp.obj \
..\os2\$D\statbox.obj \
..\os2\$D\stattext.obj \
..\os2\$D\statbrpm.obj \
..\os2\$D\tabctrl.obj \
..\os2\$D\taskbar.obj \
..\os2\$D\textctrl.obj \
..\os2\$D\thread.obj \
..\os2\$D\timer.obj \
..\os2\$D\toolbar.obj \
..\os2\$D\tooltip.obj \
..\os2\$D\treectrl.obj \
..\os2\$D\utils.obj \
..\os2\$D\utilsexc.obj \
..\os2\$D\wave.obj \
..\os2\$D\window.obj
OS2LIBOBJS1 = \
@@ -417,6 +430,19 @@ OS2LIBOBJS2 = \
spinctrl.obj \
statbmp.obj \
statbox.obj \
stattext.obj \
statbrpm.obj \
tabctrl.obj \
taskbar.obj \
textctrl.obj \
thread.obj \
timer.obj \
toolbar.obj \
tooltip.obj \
treectrl.obj \
utils.obj \
utilsexc.obj \
wave.obj \
window.obj
HTMLOBJS = \
@@ -627,6 +653,19 @@ $(OS2LIBOBJS2):
copy ..\os2\$D\spinctrl.obj
copy ..\os2\$D\statbmp.obj
copy ..\os2\$D\statbox.obj
copy ..\os2\$D\stattext.obj
copy ..\os2\$D\statbrpm.obj
copy ..\os2\$D\tabctrl.obj
copy ..\os2\$D\taskbar.obj
copy ..\os2\$D\textctrl.obj
copy ..\os2\$D\thread.obj
copy ..\os2\$D\timer.obj
copy ..\os2\$D\toolbar.obj
copy ..\os2\$D\tooltip.obj
copy ..\os2\$D\treectrl.obj
copy ..\os2\$D\utils.obj
copy ..\os2\$D\utilsexc.obj
copy ..\os2\$D\wave.obj
copy ..\os2\$D\window.obj
# wxWindows library as DLL

171
src/os2/statbrpm.cpp Normal file
View File

@@ -0,0 +1,171 @@
///////////////////////////////////////////////////////////////////////////////
// Name: statbar.cpp
// Purpose: native implementation of wxStatusBar (optional)
// Author: David Webster
// Modified by:
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) David Webster
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// for compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/frame.h"
#include "wx/settings.h"
#include "wx/dcclient.h"
#endif
#include "wx/log.h"
#include "wx/generic/statusbr.h"
#include "wx/os2/statusbr.h"
#include "wx/os2/private.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarPM, wxStatusBar);
BEGIN_EVENT_TABLE(wxStatusBarPM, wxStatusBar)
EVT_SIZE(wxStatusBarPM::OnSize)
END_EVENT_TABLE()
#endif //USE_SHARED_LIBRARY
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxStatusBarPM class
// ----------------------------------------------------------------------------
wxStatusBarPM::wxStatusBarPM()
{
SetParent(NULL);
m_hWnd = 0;
m_windowId = 0;
}
wxStatusBarPM::wxStatusBarPM(wxWindow *parent, wxWindowID id, long style)
{
Create(parent, id, style);
}
bool wxStatusBarPM::Create(wxWindow *parent, wxWindowID id, long style)
{
SetParent(parent);
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
// TODO: create status bar
return FALSE;
}
void wxStatusBarPM::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
if ( widths != NULL ) {
for ( int i = 0; i < m_nFields; i++ )
m_statusWidths[i] = widths[i];
}
else {
delete [] m_statusWidths;
m_statusWidths = NULL;
}
}
void wxStatusBarPM::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
m_nFields = nFields;
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarPM::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarPM::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
int nWindowWidth, y;
GetClientSize(&nWindowWidth, &y);
if ( m_statusWidths == NULL ) {
// default: all fields have the same width
int nWidth = nWindowWidth / m_nFields;
for ( int i = 0; i < m_nFields; i++ )
pWidths[i] = (i + 1) * nWidth;
}
else {
// -1 doesn't mean the same thing for wxWindows and Win32, recalc
int nTotalWidth = 0,
nVarCount = 0,
i;
for ( i = 0; i < m_nFields; i++ ) {
if ( m_statusWidths[i] == -1 )
nVarCount++;
else
nTotalWidth += m_statusWidths[i];
}
if ( nVarCount == 0 ) {
// wrong! at least one field must be of variable width
wxFAIL;
nVarCount++;
}
int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
// do fill the array
int nCurPos = 0;
for ( i = 0; i < m_nFields; i++ ) {
if ( m_statusWidths[i] == -1 )
nCurPos += nVarWidth;
else
nCurPos += m_statusWidths[i];
pWidths[i] = nCurPos;
}
}
// TODO: set widths
delete [] pWidths;
}
void wxStatusBarPM::SetStatusText(const wxString& strText, int nField)
{
// TODO
}
wxString wxStatusBarPM::GetStatusText(int nField) const
{
wxASSERT( (nField > -1) && (nField < m_nFields) );
// TODO
return wxString("");
}
void wxStatusBarPM::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();
}

View File

@@ -1,21 +1,25 @@
/////////////////////////////////////////////////////////////////////////////
// Name: stattext.cpp
// Purpose: wxStaticText
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: 04/01/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "stattext.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/event.h"
#include "wx/app.h"
#include "wx/brush.h"
#endif
#include "wx/app.h"
#include "wx/stattext.h"
#include "wx/os2/private.h"
#include <stdio.h>
#if !USE_SHARED_LIBRARY
@@ -29,32 +33,105 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
long style,
const wxString& name)
{
SetName(name);
if (parent) parent->AddChild(this);
SetName(name);
if (parent) parent->AddChild(this);
SetBackgroundColour(parent->GetBackgroundColour()) ;
SetForegroundColour(parent->GetForegroundColour()) ;
SetBackgroundColour(parent->GetBackgroundColour()) ;
SetForegroundColour(parent->GetForegroundColour()) ;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowStyle = style;
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
SetFont(parent->GetFont());
m_windowStyle = style;
// TODO
return FALSE;
// TODO
SubclassWin(m_hWnd);
SetFont(parent->GetFont());
SetSize(x, y, width, height);
return FALSE;
}
void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags)
wxSize wxStaticText::DoGetBestSize()
{
// TODO
wxString text(wxGetWindowText(GetHWND()));
int widthTextMax = 0, widthLine,
heightTextTotal = 0, heightLine;
wxString curLine;
for ( const wxChar *pc = text; ; pc++ ) {
if ( *pc == wxT('\n') || *pc == wxT('\0') ) {
GetTextExtent(curLine, &widthLine, &heightLine);
if ( widthLine > widthTextMax )
widthTextMax = widthLine;
heightTextTotal += heightLine;
if ( *pc == wxT('\n') ) {
curLine.Empty();
}
else {
// the end of string
break;
}
}
else {
curLine += *pc;
}
}
return wxSize(widthTextMax, heightTextTotal);
}
void wxStaticText::SetLabel(const wxString& label)
{
// TODO
// 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);
}
WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor,
WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
// TODO:
/*
if (GetParent()->GetTransparentBackground())
SetBkMode((HDC) pDC, TRANSPARENT);
else
SetBkMode((HDC) pDC, OPAQUE);
::SetBkColor((HDC) pDC, RGB(GetBackgroundColour().Red(), GetBackgroundColour().Green(), GetBackgroundColour().Blue()));
::SetTextColor((HDC) pDC, RGB(GetForegroundColour().Red(), GetForegroundColour().Green(), GetForegroundColour().Blue()));
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
// Note that this will be cleaned up in wxApp::OnIdle, if backgroundBrush
// has a zero usage count.
// backgroundBrush->RealizeResource();
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
*/
return (WXHBRUSH)0;
}
MRESULT wxStaticText::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
// Ensure that static items get messages. Some controls don't like this
// message to be intercepted (e.g. RichEdit), hence the tests.
// TODO:
/*
if (nMsg == WM_NCHITTEST)
return (long)HTCLIENT;
*/
return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam);
}

View File

@@ -1,162 +0,0 @@
///////////////////////////////////////////////////////////////////////////////
// Name: statbar.cpp
// Purpose: native implementation of wxStatusBar (optional)
// Author: AUTHOR
// Modified by:
// Created: ??/??/98
// RCS-ID: $Id$
// Copyright: (c) 1998 AUTHOR
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "statusbr.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/stubs/statusbr.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX, wxStatusBar);
BEGIN_EVENT_TABLE(wxStatusBarXX, wxStatusBar)
EVT_SIZE(wxStatusBarXX::OnSize)
END_EVENT_TABLE()
#endif //USE_SHARED_LIBRARY
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxStatusBarXX class
// ----------------------------------------------------------------------------
wxStatusBarXX::wxStatusBarXX()
{
SetParent(NULL);
}
wxStatusBarXX::wxStatusBarXX(wxWindow *parent, wxWindowID id, long style)
{
Create(parent, id, style);
}
bool wxStatusBarXX::Create(wxWindow *parent, wxWindowID id, long style)
{
SetParent(parent);
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
// TODO: create status bar
return FALSE;
}
void wxStatusBarXX::SetFieldsCount(int nFields, const int widths[])
{
wxASSERT( (nFields > 0) && (nFields < 255) );
m_nFields = nFields;
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarXX::SetStatusWidths(int n, const int widths[])
{
wxASSERT( n == m_nFields );
CopyFieldsWidth(widths);
SetFieldsWidth();
}
void wxStatusBarXX::CopyFieldsWidth(const int widths[])
{
if (widths && !m_statusWidths)
m_statusWidths = new int[m_nFields];
if ( widths != NULL ) {
for ( int i = 0; i < m_nFields; i++ )
m_statusWidths[i] = widths[i];
}
else {
delete [] m_statusWidths;
m_statusWidths = NULL;
}
}
void wxStatusBarXX::SetFieldsWidth()
{
int *pWidths = new int[m_nFields];
int nWindowWidth, y;
GetClientSize(&nWindowWidth, &y);
if ( m_statusWidths == NULL ) {
// default: all fields have the same width
int nWidth = nWindowWidth / m_nFields;
for ( int i = 0; i < m_nFields; i++ )
pWidths[i] = (i + 1) * nWidth;
}
else {
// -1 doesn't mean the same thing for wxWindows and Win32, recalc
int nTotalWidth = 0,
nVarCount = 0,
i;
for ( i = 0; i < m_nFields; i++ ) {
if ( m_statusWidths[i] == -1 )
nVarCount++;
else
nTotalWidth += m_statusWidths[i];
}
if ( nVarCount == 0 ) {
// wrong! at least one field must be of variable width
wxFAIL;
nVarCount++;
}
int nVarWidth = (nWindowWidth - nTotalWidth) / nVarCount;
// do fill the array
int nCurPos = 0;
for ( i = 0; i < m_nFields; i++ ) {
if ( m_statusWidths[i] == -1 )
nCurPos += nVarWidth;
else
nCurPos += m_statusWidths[i];
pWidths[i] = nCurPos;
}
}
// TODO: set widths
delete [] pWidths;
}
void wxStatusBarXX::SetStatusText(const wxString& strText, int nField)
{
// TODO
}
wxString wxStatusBarXX::GetStatusText(int nField) const
{
wxASSERT( (nField > -1) && (nField < m_nFields) );
// TODO
return wxString("");
}
void wxStatusBarXX::OnSize(wxSizeEvent& event)
{
// adjust fields widths to the new size
SetFieldsWidth();
}

View File

@@ -1,20 +1,31 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tabctrl.cpp
// Purpose: wxTabCtrl
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "tabctrl.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/control.h"
#include "wx/tabctrl.h"
#include "malloc.h"
#define INCL_PM
#include <os2.h>
//#include "wx/msw/dib.h"
#include "wx/os2/tabctrl.h"
#include "wx/app.h"
#include "wx/os2/private.h"
#include "wx/os2/imaglist.h"
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
@@ -33,28 +44,106 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
{
m_imageList = NULL;
m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
// GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
m_foregroundColour = *wxBLACK ;
SetName(name);
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
m_windowStyle = style;
SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
SetParent(parent);
DWORD msflags = 0;
if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
m_windowId = (id < 0 ? NewControlId() : id);
long tabStyle = 0;
// Create the toolbar control.
HWND hWndTabCtrl = 0;
// TODO: create tab control
m_hWnd = (WXHWND) hWndTabCtrl;
if (parent) parent->AddChild(this);
// TODO: create tab control
SubclassWin((WXHWND) hWndTabCtrl);
return FALSE;
}
wxTabCtrl::~wxTabCtrl()
{
UnsubclassWin();
}
void wxTabCtrl::Command(wxCommandEvent& event)
bool wxTabCtrl::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{
wxTabEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
// TODO:
/*
NMHDR* hdr1 = (NMHDR*) lParam;
switch ( hdr1->code )
{
case TCN_SELCHANGE:
eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
break;
case TCN_SELCHANGING:
eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
break;
case TTN_NEEDTEXT:
{
// TODO
// if (tool->m_shortHelpString != "")
// ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
}
default :
return wxControl::OS2OnNotify(idCtrl, lParam, result);
}
*/
event.SetEventObject( this );
event.SetEventType(eventType);
event.SetInt(idCtrl) ;
return ProcessEvent(event);
}
// Responds to colour changes, and passes event on to children.
void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// TODO:
/*
m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
GetGValue(GetSysColor(COLOR_BTNFACE)),
GetBValue(GetSysColor(COLOR_BTNFACE)));
Refresh();
*/
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
// Delete all items
bool wxTabCtrl::DeleteAllItems()
{
@@ -191,6 +280,73 @@ void wxTabCtrl::SetPadding(const wxSize& padding)
// TODO
}
#if 0
// These are the default colors used to map the bitmap colors
// to the current system colors
#define BGR_BUTTONTEXT (RGB(000,000,000)) // black
#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
#define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
void wxMapBitmap(HBITMAP hBitmap, int width, int height)
{
COLORMAP ColorMap[] = {
{BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
{BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
{BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
{BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
{BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
{BGR_BACKGROUND, COLOR_WINDOW} // magenta
};
int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
int n;
for ( n = 0; n < NUM_MAPS; n++)
{
ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
}
HBITMAP hbmOld;
HDC hdcMem = CreateCompatibleDC(NULL);
if (hdcMem)
{
hbmOld = SelectObject(hdcMem, hBitmap);
int i, j, k;
for ( i = 0; i < width; i++)
{
for ( j = 0; j < height; j++)
{
COLORREF pixel = ::GetPixel(hdcMem, i, j);
/*
BYTE red = GetRValue(pixel);
BYTE green = GetGValue(pixel);
BYTE blue = GetBValue(pixel);
*/
for ( k = 0; k < NUM_MAPS; k ++)
{
if ( ColorMap[k].from == pixel )
{
/* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
break;
}
}
}
}
SelectObject(hdcMem, hbmOld);
DeleteObject(hdcMem);
}
}
#endif
// Tab event
IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
@@ -199,3 +355,4 @@ wxTabEvent::wxTabEvent(wxEventType commandType, int id):
{
}

View File

@@ -2,69 +2,372 @@
// File: taskbar.cpp
// Purpose: Implements wxTaskBarIcon class for manipulating icons on
// the task bar. Optional.
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c)
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "taskbar.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/utils.h"
#include "wx/menu.h"
#endif
#include <wx/taskbar.h>
#define INCL_PM
#include <os2.h>
#include <string.h>
#include <wx/os2/taskbar.h>
#include <wx/os2/private.h>
wxTaskBarIcon::wxTaskBarIcon()
MRESULT wxTaskBarIconWindowProc( HWND hWnd, UINT msg, MPARAM wParam, MPARAM lParam );
wxChar *wxTaskBarWindowClass = wxT("wxTaskBarWindowClass");
wxList wxTaskBarIcon::sm_taskBarIcons;
bool wxTaskBarIcon::sm_registeredClass = FALSE;
UINT wxTaskBarIcon::sm_taskbarMsg = 0;
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxTaskBarIcon, wxEvtHandler)
EVT_TASKBAR_MOVE (wxTaskBarIcon::_OnMouseMove)
EVT_TASKBAR_LEFT_DOWN (wxTaskBarIcon::_OnLButtonDown)
EVT_TASKBAR_LEFT_UP (wxTaskBarIcon::_OnLButtonUp)
EVT_TASKBAR_RIGHT_DOWN (wxTaskBarIcon::_OnRButtonDown)
EVT_TASKBAR_RIGHT_UP (wxTaskBarIcon::_OnRButtonUp)
EVT_TASKBAR_LEFT_DCLICK (wxTaskBarIcon::_OnLButtonDClick)
EVT_TASKBAR_RIGHT_DCLICK (wxTaskBarIcon::_OnRButtonDClick)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIcon, wxEvtHandler)
#endif
wxTaskBarIcon::wxTaskBarIcon(void)
{
// TODO
m_hWnd = 0;
m_iconAdded = FALSE;
AddObject(this);
// TODO:
/*
if (RegisterWindowClass())
m_hWnd = CreateTaskBarWindow();
*/
}
wxTaskBarIcon::~wxTaskBarIcon()
wxTaskBarIcon::~wxTaskBarIcon(void)
{
// TODO
// TODO:
/*
RemoveObject(this);
if (m_iconAdded)
{
RemoveIcon();
}
if (m_hWnd)
{
::DestroyWindow((HWND) m_hWnd);
m_hWnd = 0;
}
*/
}
// Operations
bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
{
// TODO
if (!IsOK())
return FALSE;
// TODO:
/*
NOTIFYICONDATA notifyData;
memset(&notifyData, 0, sizeof(notifyData));
notifyData.cbSize = sizeof(notifyData);
notifyData.hWnd = (HWND) m_hWnd;
notifyData.uCallbackMessage = sm_taskbarMsg;
notifyData.uFlags = NIF_MESSAGE ;
if (icon.Ok())
{
notifyData.uFlags |= NIF_ICON;
notifyData.hIcon = (HICON) icon.GetHICON();
}
if (((const wxChar*) tooltip != NULL) && (tooltip != wxT("")))
{
notifyData.uFlags |= NIF_TIP ;
lstrcpyn(notifyData.szTip, WXSTRINGCAST tooltip, sizeof(notifyData.szTip));
}
notifyData.uID = 99;
if (m_iconAdded)
return (Shell_NotifyIcon(NIM_MODIFY, & notifyData) != 0);
else
{
m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0);
return m_iconAdded;
}
*/
return FALSE;
}
bool wxTaskBarIcon::RemoveIcon()
bool wxTaskBarIcon::RemoveIcon(void)
{
// TODO
if (!m_iconAdded)
return FALSE;
//TODO:
/*
NOTIFYICONDATA notifyData;
memset(&notifyData, 0, sizeof(notifyData));
notifyData.cbSize = sizeof(notifyData);
notifyData.hWnd = (HWND) m_hWnd;
notifyData.uCallbackMessage = sm_taskbarMsg;
notifyData.uFlags = NIF_MESSAGE;
notifyData.hIcon = 0 ; // hIcon;
notifyData.uID = 99;
m_iconAdded = FALSE;
return (Shell_NotifyIcon(NIM_DELETE, & notifyData) != 0);
*/
return FALSE;
}
bool wxTaskBarIcon::PopupMenu(wxMenu *menu) //, int x, int y);
{
// OK, so I know this isn't thread-friendly, but
// what to do? We need this check.
static bool s_inPopup = FALSE;
if (s_inPopup)
return FALSE;
s_inPopup = TRUE;
bool rval = FALSE;
wxWindow* win;
int x, y;
wxGetMousePosition(&x, &y);
// is wxFrame the best window type to use???
win = new wxFrame(NULL, -1, "", wxPoint(x,y), wxSize(-1,-1), 0);
win->PushEventHandler(this);
// Remove from record of top-level windows, or will confuse wxWindows
// if we try to exit right now.
wxTopLevelWindows.DeleteObject(win);
menu->UpdateUI();
rval = win->PopupMenu(menu, 0, 0);
win->PopEventHandler(FALSE);
win->Destroy();
delete win;
s_inPopup = FALSE;
return rval;
}
// Overridables
void wxTaskBarIcon::OnMouseMove()
void wxTaskBarIcon::OnMouseMove(wxEvent&)
{
}
void wxTaskBarIcon::OnLButtonDown()
void wxTaskBarIcon::OnLButtonDown(wxEvent&)
{
}
void wxTaskBarIcon::OnLButtonUp()
void wxTaskBarIcon::OnLButtonUp(wxEvent&)
{
}
void wxTaskBarIcon::OnRButtonDown()
void wxTaskBarIcon::OnRButtonDown(wxEvent&)
{
}
void wxTaskBarIcon::OnRButtonUp()
void wxTaskBarIcon::OnRButtonUp(wxEvent&)
{
}
void wxTaskBarIcon::OnLButtonDClick()
void wxTaskBarIcon::OnLButtonDClick(wxEvent&)
{
}
void wxTaskBarIcon::OnRButtonDClick()
void wxTaskBarIcon::OnRButtonDClick(wxEvent&)
{
}
void wxTaskBarIcon::_OnMouseMove(wxEvent& e) { OnMouseMove(e); }
void wxTaskBarIcon::_OnLButtonDown(wxEvent& e) { OnLButtonDown(e); }
void wxTaskBarIcon::_OnLButtonUp(wxEvent& e) { OnLButtonUp(e); }
void wxTaskBarIcon::_OnRButtonDown(wxEvent& e) { OnRButtonDown(e); }
void wxTaskBarIcon::_OnRButtonUp(wxEvent& e) { OnRButtonUp(e); }
void wxTaskBarIcon::_OnLButtonDClick(wxEvent& e) { OnLButtonDClick(e); }
void wxTaskBarIcon::_OnRButtonDClick(wxEvent& e) { OnRButtonDClick(e); }
wxTaskBarIcon* wxTaskBarIcon::FindObjectForHWND(WXHWND hWnd)
{
wxNode*node = sm_taskBarIcons.First();
while (node)
{
wxTaskBarIcon* obj = (wxTaskBarIcon*) node->Data();
if (obj->GetHWND() == hWnd)
return obj;
node = node->Next();
}
return NULL;
}
void wxTaskBarIcon::AddObject(wxTaskBarIcon* obj)
{
sm_taskBarIcons.Append(obj);
}
void wxTaskBarIcon::RemoveObject(wxTaskBarIcon* obj)
{
sm_taskBarIcons.DeleteObject(obj);
}
bool wxTaskBarIcon::RegisterWindowClass()
{
if (sm_registeredClass)
return TRUE;
// Also register the taskbar message here
// TODO:
/*
sm_taskbarMsg = ::RegisterWindowMessage(wxT("wxTaskBarIconMessage"));
WNDCLASS wc;
bool rc;
HINSTANCE hInstance = GetModuleHandle(NULL);
//
// set up and register window class
//
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) wxTaskBarIconWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
wc.lpszMenuName = NULL;
wc.lpszClassName = wxTaskBarWindowClass ;
rc = (::RegisterClass( &wc ) != 0);
sm_registeredClass = (rc != 0);
return( (rc != 0) );
*/
return FALSE;
}
WXHWND wxTaskBarIcon::CreateTaskBarWindow()
{
// TODO:
/*
HINSTANCE hInstance = GetModuleHandle(NULL);
HWND hWnd = CreateWindowEx (0, wxTaskBarWindowClass,
wxT("wxTaskBarWindow"),
WS_OVERLAPPED,
0,
0,
10,
10,
NULL,
(HMENU) 0,
hInstance,
NULL);
return (WXHWND) hWnd;
*/
return (WXHWND)0;
}
MRESULT wxTaskBarIcon::WindowProc( WXHWND hWnd, UINT msg, MPARAM wParam, MPARAM lParam )
{
wxEventType eventType = 0;
// TODO:
/*
if (msg != sm_taskbarMsg)
return DefWindowProc((HWND) hWnd, msg, wParam, lParam);
switch (lParam)
{
case WM_LBUTTONDOWN:
eventType = wxEVT_TASKBAR_LEFT_DOWN;
break;
case WM_LBUTTONUP:
eventType = wxEVT_TASKBAR_LEFT_UP;
break;
case WM_RBUTTONDOWN:
eventType = wxEVT_TASKBAR_RIGHT_DOWN;
break;
case WM_RBUTTONUP:
eventType = wxEVT_TASKBAR_RIGHT_UP;
break;
case WM_LBUTTONDBLCLK:
eventType = wxEVT_TASKBAR_LEFT_DCLICK;
break;
case WM_RBUTTONDBLCLK:
eventType = wxEVT_TASKBAR_RIGHT_DCLICK;
break;
case WM_MOUSEMOVE:
eventType = wxEVT_TASKBAR_MOVE;
break;
default:
break;
}
*/
if (eventType)
{
wxEvent event;
event.SetEventType(eventType);
event.SetEventObject(this);
ProcessEvent(event);
}
return 0;
}
MRESULT wxTaskBarIconWindowProc(
HWND hWnd
, UINT msg
, MPARAM wParam
, MPARAM lParam
)
{
wxTaskBarIcon* obj = wxTaskBarIcon::FindObjectForHWND((WXHWND) hWnd);
if (obj)
return obj->WindowProc((WXHWND) hWnd, msg, wParam, lParam);
else
return (MRESULT)0;
// return DefWindowProc(hWnd, msg, wParam, lParam);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,52 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: timer.cpp
// Purpose: wxTimer implementation
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "timer.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/window.h"
#include "wx/os2/private.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/list.h"
#include "wx/event.h"
#include "wx/app.h"
#endif
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/timer.h"
#include <time.h>
#include <sys/types.h>
#include <sys/timeb.h>
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
wxList wxTimerList(wxKEY_INTEGER);
UINT wxTimerProc(HWND hwnd, WORD, int idTimer, DWORD);
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject)
#endif
wxTimer::wxTimer()
{
m_milli = 0 ;
m_id = 0;
m_oneShot = FALSE;
milli = 0 ;
id = 0;
oneShot = FALSE;
}
wxTimer::~wxTimer()
{
Stop();
wxTimerList.DeleteObject(this);
}
bool wxTimer::Start(int milliseconds,bool mode)
{
m_oneShot = mode ;
if (milliseconds <= 0)
oneShot = mode;
if (milliseconds < 0)
milliseconds = lastMilli;
wxCHECK_MSG( milliseconds > 0, FALSE, wxT("invalid value for timer timeour") );
lastMilli = milli = milliseconds;
wxTimerList.DeleteObject(this);
// TODO:
/*
TIMERPROC wxTimerProcInst = (TIMERPROC)
MakeProcInstance((FARPROC)wxTimerProc, wxGetInstance());
id = SetTimer(NULL, (UINT)(id ? id : 1),
(UINT)milliseconds, wxTimerProcInst);
*/
if (id > 0)
{
wxTimerList.Append(id, this);
return TRUE;
}
else
{
wxLogSysError(_("Couldn't create a timer"));
return FALSE;
m_milli = milliseconds;
// TODO: set the timer going.
return FALSE;
}
}
void wxTimer::Stop()
{
m_id = 0 ;
m_milli = 0 ;
if ( id )
{
// KillTimer(NULL, (UINT)id);
wxTimerList.DeleteObject(this);
}
id = 0;
milli = 0;
}
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
void wxProcessTimer(wxTimer& timer)
{
// Avoid to process spurious timer events
if ( timer.id == 0)
return;
if ( timer.oneShot )
timer.Stop();
timer.Notify();
}
UINT wxTimerProc(HWND WXUNUSED(hwnd), WORD, int idTimer, DWORD)
{
wxNode *node = wxTimerList.Find((long)idTimer);
wxCHECK_MSG( node, 0, wxT("bogus timer id in wxTimerProc") );
wxProcessTimer(*(wxTimer *)node->Data());
return 0;
}

View File

@@ -1,126 +1,493 @@
/////////////////////////////////////////////////////////////////////////////
// Name: toolbar.cpp
// Purpose: wxToolBar
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: 04/01/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "toolbar.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/wx.h"
#if wxUSE_BUTTONBAR && wxUSE_TOOLBAR && defined(__WIN95__)
#include "malloc.h"
#define INCL_PM
#include <os2.h>
#include "wx/toolbar.h"
#include "wx/app.h"
#include "wx/os2/private.h"
// Styles
#ifndef TBSTYLE_FLAT
#define TBSTYLE_LIST 0x1000
#define TBSTYLE_FLAT 0x0800
#define TBSTYLE_TRANSPARENT 0x8000
#endif
// use TBSTYLE_TRANSPARENT if you use TBSTYLE_FLAT
// Messages
#ifndef TB_GETSTYLE
#define TB_GETSTYLE (WM_USER + 57)
#define TB_SETSTYLE (WM_USER + 56)
#endif
/* Hint from a newsgroup for custom flatbar drawing:
Set the TBSTYLE_CUSTOMERASE style, then handle the
NM_CUSTOMDRAW message and do your custom drawing.
*/
#define DEFAULTBITMAPX 16
#define DEFAULTBITMAPY 15
#define DEFAULTBUTTONX 24
#define DEFAULTBUTTONY 24
#define DEFAULTBARHEIGHT 27
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase)
#endif
BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
EVT_MOUSE_EVENTS(wxToolBar::OnMouseEvent)
EVT_SYS_COLOUR_CHANGED(wxToolBar::OnSysColourChanged)
END_EVENT_TABLE()
#endif
static void wxMapBitmap(HBITMAP hBitmap, int width, int height);
wxToolBar::wxToolBar()
{
m_maxWidth = -1;
m_maxHeight = -1;
m_defaultWidth = 24;
m_defaultHeight = 22;
// TODO
m_hBitmap = 0;
m_defaultWidth = DEFAULTBITMAPX;
m_defaultHeight = DEFAULTBITMAPY;
}
bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
bool wxToolBar::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
m_maxWidth = -1;
m_maxHeight = -1;
m_defaultWidth = 24;
m_defaultHeight = 22;
SetName(name);
m_hWnd = 0;
m_backgroundColour = *wxWHITE; //TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
// GetGValue(GetSysColor(COLOR_BTNFACE)),
// GetBValue(GetSysColor(COLOR_BTNFACE)));
m_foregroundColour = *wxBLACK ;
m_windowStyle = style;
wxASSERT_MSG( (style & wxTB_VERTICAL) == 0,
wxT("Sorry, wxToolBar under Windows 95 only "
"supports horizontal orientation.") );
SetParent(parent);
m_maxWidth = -1;
m_maxHeight = -1;
if (parent) parent->AddChild(this);
m_hBitmap = 0;
// TODO create toolbar
return FALSE;
m_defaultWidth = DEFAULTBITMAPX;
m_defaultHeight = DEFAULTBITMAPY;
SetName(name);
m_windowStyle = style;
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
SetParent(parent);
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
if (width <= 0)
width = 100;
if (height <= 0)
height = 30;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
m_windowId = (id < 0 ? NewControlId() : id);
DWORD msflags = 0;
// TODO:
/*
if (style & wxBORDER)
msflags |= WS_BORDER;
msflags |= WS_CHILD | WS_VISIBLE | TBSTYLE_TOOLTIPS;
if (style & wxTB_FLAT)
{
if (wxTheApp->GetComCtl32Version() > 400)
msflags |= TBSTYLE_FLAT;
}
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
// Even with extended styles, need to combine with WS_BORDER
// for them to look right.
if ( want3D || wxStyleHasBorder(m_windowStyle) )
msflags |= WS_BORDER;
// Create the toolbar control.
HWND hWndToolbar = CreateWindowEx
(
exStyle, // Extended styles.
TOOLBARCLASSNAME, // Class name for the toolbar.
wxT(""), // No default text.
msflags, // Styles
x, y, width, height, // Standard toolbar size and position.
(HWND) parent->GetHWND(), // Parent window of the toolbar.
(HMENU)m_windowId, // Toolbar ID.
wxGetInstance(), // Current instance.
NULL // No class data.
);
wxCHECK_MSG( hWndToolbar, FALSE, wxT("Toolbar creation failed") );
// Toolbar-specific initialisation
::SendMessage(hWndToolbar, TB_BUTTONSTRUCTSIZE,
(WPARAM)sizeof(TBBUTTON), (LPARAM)0);
*/
m_hWnd = (WXHWND) hWndToolbar;
if (parent)
parent->AddChild(this);
SubclassWin((WXHWND)hWndToolbar);
return TRUE;
}
wxToolBar::~wxToolBar()
{
// TODO
UnsubclassWin();
if (m_hBitmap)
{
// ::DeleteObject((HBITMAP) m_hBitmap);
m_hBitmap = 0;
}
}
bool wxToolBar::CreateTools()
{
if (m_tools.Number() == 0)
if (m_tools.Number() == 0)
return FALSE;
HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
int totalBitmapWidth = (int)(m_defaultWidth * m_tools.Number());
int totalBitmapHeight = (int)m_defaultHeight;
// TODO:
/*
// Create a bitmap for all the tool bitmaps
HDC dc = ::GetDC(NULL);
m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc, totalBitmapWidth, totalBitmapHeight);
::ReleaseDC(NULL, dc);
// Now blit all the tools onto this bitmap
HDC memoryDC = ::CreateCompatibleDC(NULL);
HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP) m_hBitmap);
HDC memoryDC2 = ::CreateCompatibleDC(NULL);
int x = 0;
wxNode *node = m_tools.First();
int noButtons = 0;
while (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok() && tool->m_bitmap1.GetHBITMAP())
{
// wxPalette *palette = tool->m_bitmap1->GetPalette();
HBITMAP oldBitmap2 = (HBITMAP) ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
// int bltResult =
BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2,
0, 0, SRCCOPY);
::SelectObject(memoryDC2, oldBitmap2);
x += (int)m_defaultWidth;
noButtons ++;
}
node = node->Next();
}
::SelectObject(memoryDC, oldBitmap);
::DeleteDC(memoryDC);
::DeleteDC(memoryDC2);
// Map to system colours
wxMapBitmap((HBITMAP) m_hBitmap, totalBitmapWidth, totalBitmapHeight);
if ( oldToolBarBitmap )
{
TBREPLACEBITMAP replaceBitmap;
replaceBitmap.hInstOld = NULL;
replaceBitmap.hInstNew = NULL;
replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
replaceBitmap.nIDNew = (UINT) (HBITMAP) m_hBitmap;
replaceBitmap.nButtons = noButtons;
if (::SendMessage((HWND) GetHWND(), TB_REPLACEBITMAP, (WPARAM) 0, (LPARAM) &replaceBitmap) == -1)
{
wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
}
::DeleteObject((HBITMAP) oldToolBarBitmap);
// Now delete all the buttons
int i = 0;
while ( TRUE )
{
// TODO: What about separators???? They don't have an id!
if ( ! ::SendMessage( (HWND) GetHWND(), TB_DELETEBUTTON, i, 0 ) )
break;
}
}
else
{
TBADDBITMAP addBitmap;
addBitmap.hInst = 0;
addBitmap.nID = (UINT)m_hBitmap;
if (::SendMessage((HWND) GetHWND(), TB_ADDBITMAP, (WPARAM) noButtons, (LPARAM) &addBitmap) == -1)
{
wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
}
}
// Now add the buttons.
TBBUTTON buttons[50];
node = m_tools.First();
int i = 0;
int bitmapId = 0;
while (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
{
buttons[i].iBitmap = 0;
buttons[i].idCommand = 0;
buttons[i].fsState = TBSTATE_ENABLED;
buttons[i].fsStyle = TBSTYLE_SEP;
buttons[i].dwData = 0L;
buttons[i].iString = 0;
}
else
{
buttons[i].iBitmap = bitmapId;
buttons[i].idCommand = tool->m_index;
buttons[i].fsState = 0;
if (tool->m_enabled)
buttons[i].fsState |= TBSTATE_ENABLED;
if (tool->m_toggleState)
buttons[i].fsState |= TBSTATE_CHECKED;
buttons[i].fsStyle = tool->m_isToggle ? TBSTYLE_CHECK : TBSTYLE_BUTTON;
buttons[i].dwData = 0L;
buttons[i].iString = 0;
bitmapId ++;
}
i ++;
node = node->Next();
}
long rc = ::SendMessage((HWND) GetHWND(), TB_ADDBUTTONS, (WPARAM)i, (LPARAM)& buttons);
wxCHECK_MSG( rc, FALSE, wxT("failed to add buttons to the toolbar") );
(void)::SendMessage((HWND) GetHWND(), TB_AUTOSIZE, (WPARAM)0, (LPARAM) 0);
SetRows(m_maxRows);
*/
return TRUE;
}
bool wxToolBar::OS2Command(WXUINT cmd, WXWORD id)
{
wxNode *node = m_tools.Find((long)id);
if (!node)
return FALSE;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
// TODO:
/*
if (tool->m_isToggle)
tool->m_toggleState = (1 == (1 & (int)::SendMessage((HWND) GetHWND(), TB_GETSTATE, (WPARAM) id, (LPARAM) 0)));
BOOL ret = OnLeftClick((int)id, tool->m_toggleState);
if (ret == FALSE && tool->m_isToggle)
{
tool->m_toggleState = !tool->m_toggleState;
::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)id, (LPARAM)MAKELONG(tool->m_toggleState, 0));
}
return TRUE;
*/
return FALSE;
}
bool wxToolBar::OS2OnNotify(int WXUNUSED(idCtrl),
WXLPARAM lParam,
WXLPARAM *result)
{
// TODO:
/*
// First check if this applies to us
NMHDR *hdr = (NMHDR *)lParam;
// the tooltips control created by the toolbar is sometimes Unicode, even in
// an ANSI application
int code = (int)hdr->code;
if ( (code != TTN_NEEDTEXTA) && (code != TTN_NEEDTEXTW) )
return FALSE;
// TODO
HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0);
if ( toolTipWnd != hdr->hwndFrom )
return FALSE;
LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam;
int id = (int)ttText->hdr.idFrom;
wxNode *node = m_tools.Find((long)id);
if (!node)
return FALSE;
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
const wxString& help = tool->m_shortHelpString;
if ( !help.IsEmpty() )
{
if ( code == TTN_NEEDTEXTA )
{
ttText->lpszText = (wxChar *)help.c_str();
}
#if (_WIN32_IE >= 0x0300)
else
{
// FIXME this is a temp hack only until I understand better what
// must be done in both ANSI and Unicode builds
size_t lenAnsi = help.Len();
#ifdef __MWERKS__
// MetroWerks doesn't like calling mbstowcs with NULL argument
size_t lenUnicode = 2*lenAnsi;
#else
size_t lenUnicode = mbstowcs(NULL, help, lenAnsi);
#endif
// using the pointer of right type avoids us doing all sorts of
// pointer arithmetics ourselves
wchar_t *dst = (wchar_t *)ttText->szText,
*pwz = new wchar_t[lenUnicode + 1];
mbstowcs(pwz, help, lenAnsi + 1);
memcpy(dst, pwz, lenUnicode*sizeof(wchar_t));
// put the terminating _wide_ NUL
dst[lenUnicode] = 0;
delete [] pwz;
}
#endif // _WIN32_IE >= 0x0300
}
// For backward compatibility...
OnMouseEnter(tool->m_index);
return TRUE;
*/
return FALSE;
}
void wxToolBar::SetToolBitmapSize(const wxSize& size)
{
m_defaultWidth = size.x; m_defaultHeight = size.y;
// TODO
m_defaultWidth = size.x;
m_defaultHeight = size.y;
// ::SendMessage((HWND) GetHWND(), TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG ((int)size.x, (int)size.y));
}
void wxToolBar::SetRows(int nRows)
{
// TODO:
/*
RECT rect;
::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(nRows, TRUE), (LPARAM) & rect);
m_maxWidth = (rect.right - rect.left + 2);
m_maxHeight = (rect.bottom - rect.top + 2);
*/
}
wxSize wxToolBar::GetMaxSize() const
{
// TODO
return wxSize(0, 0);
// TODO:
/*
if ((m_maxWidth == -1) || (m_maxHeight == -1))
{
RECT rect;
::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_maxRows, TRUE), (LPARAM) & rect);
((wxToolBar *)this)->m_maxWidth = (rect.right - rect.left + 2); // ???
((wxToolBar *)this)->m_maxHeight = (rect.bottom - rect.top + 2); // ???
}
*/
return wxSize(m_maxWidth, m_maxHeight);
}
// The button size is bigger than the bitmap size
wxSize wxToolBar::GetToolSize() const
{
// TODO
return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
}
void wxToolBar::EnableTool(int toolIndex, bool enable)
{
wxNode *node = m_tools.Find((long)toolIndex);
if (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
tool->m_enabled = enable;
// TODO enable button
}
wxNode *node = m_tools.Find((long)toolIndex);
if (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
tool->m_enabled = enable;
// ::SendMessage((HWND) GetHWND(), TB_ENABLEBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(enable, 0));
}
}
void wxToolBar::ToggleTool(int toolIndex, bool toggle)
{
wxNode *node = m_tools.Find((long)toolIndex);
if (node)
wxNode *node = m_tools.Find((long)toolIndex);
if (node)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if (tool->m_isToggle)
{
wxToolBarTool *tool = (wxToolBarTool *)node->Data();
if (tool->m_isToggle)
{
tool->m_toggleState = toggle;
// TODO: set toggle state
}
tool->m_toggleState = toggle;
// ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)toolIndex, (LPARAM)MAKELONG(toggle, 0));
}
}
}
bool wxToolBar::GetToolState(int toolIndex) const
{
// return (::SendMessage((HWND) GetHWND(), TB_ISBUTTONCHECKED, (WPARAM)toolIndex, (LPARAM)0) != 0);
return FALSE;
}
void wxToolBar::ClearTools()
{
// TODO
wxToolBarBase::ClearTools();
// TODO: Don't know how to reset the toolbar bitmap, as yet.
// But adding tools and calling CreateTools should probably
// recreate a buttonbar OK.
wxToolBarBase::ClearTools();
}
// If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states.
wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBitmap& pushedBitmap,
bool toggle, long xPos, long yPos, wxObject *clientData, const wxString& helpString1, const wxString& helpString2)
{
@@ -137,9 +504,137 @@ wxToolBarTool *wxToolBar::AddTool(int index, const wxBitmap& bitmap, const wxBit
else
tool->m_y = m_yMargin;
tool->SetSize(GetDefaultButtonWidth(), GetDefaultButtonHeight());
tool->SetSize(GetToolSize().x, GetToolSize().y);
m_tools.Append((long)index, tool);
return tool;
}
// Responds to colour changes, and passes event on to children.
void wxToolBar::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// TODO:
/*
m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
*/
// Remap the buttons
CreateTools();
Refresh();
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
void wxToolBar::OnMouseEvent(wxMouseEvent& event)
{
if (event.RightDown())
{
// For now, we don't have an id. Later we could
// try finding the tool.
OnRightClick((int)-1, event.GetX(), event.GetY());
}
else
{
event.Skip();
}
}
// These are the default colors used to map the bitmap colors
// to the current system colors
#define BGR_BUTTONTEXT (RGB(000,000,000)) // black
#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
#define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
void wxMapBitmap(HBITMAP hBitmap, int width, int height)
{
COLORMAP ColorMap[] = {
{BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
{BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
{BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
{BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
{BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
{BGR_BACKGROUND, COLOR_WINDOW} // magenta
};
int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
int n;
for ( n = 0; n < NUM_MAPS; n++)
{
ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
}
HBITMAP hbmOld;
HDC hdcMem = CreateCompatibleDC(NULL);
if (hdcMem)
{
hbmOld = (HBITMAP) SelectObject(hdcMem, hBitmap);
int i, j, k;
for ( i = 0; i < width; i++)
{
for ( j = 0; j < height; j++)
{
// COLORREF pixel = ::GetPixel(hdcMem, i, j);
/*
BYTE red = GetRValue(pixel);
BYTE green = GetGValue(pixel);
BYTE blue = GetBValue(pixel);
*/
for ( k = 0; k < NUM_MAPS; k ++)
{
if ( ColorMap[k].from == pixel )
{
// /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
break;
}
}
}
}
// SelectObject(hdcMem, hbmOld);
// DeleteObject(hdcMem);
}
}
// Some experiments...
#if 0
// What we want to do is create another bitmap which has a depth of 4,
// and set the bits. So probably we want to convert this HBITMAP into a
// DIB, then call SetDIBits.
// AAAGH. The stupid thing is that if newBitmap has a depth of 4 (less than that of
// the screen), then SetDIBits fails.
HBITMAP newBitmap = ::CreateBitmap(totalBitmapWidth, totalBitmapHeight, 1, 4, NULL);
HANDLE newDIB = ::BitmapToDIB((HBITMAP) m_hBitmap, NULL);
LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) GlobalLock(newDIB);
dc = ::GetDC(NULL);
// LPBITMAPINFOHEADER lpbmi = (LPBITMAPINFOHEADER) newDIB;
int result = ::SetDIBits(dc, newBitmap, 0, lpbmi->biHeight, FindDIBBits((LPSTR)lpbmi), (LPBITMAPINFO)lpbmi,
DIB_PAL_COLORS);
DWORD err = GetLastError();
::ReleaseDC(NULL, dc);
// Delete the DIB
GlobalUnlock (newDIB);
GlobalFree (newDIB);
// WXHBITMAP hBitmap2 = wxCreateMappedBitmap((WXHINSTANCE) wxGetInstance(), (WXHBITMAP) m_hBitmap);
// Substitute our new bitmap for the old one
::DeleteObject((HBITMAP) m_hBitmap);
m_hBitmap = (WXHBITMAP) newBitmap;
#endif
#endif

214
src/os2/tooltip.cpp Normal file
View File

@@ -0,0 +1,214 @@
///////////////////////////////////////////////////////////////////////////////
// Name: msw/tooltip.cpp
// Purpose: wxToolTip class implementation for MSW
// Author: David Webster
// Modified by:
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) David Webster
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
#include "wx/os2/private.h"
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
// the tooltip parent window
WXHWND wxToolTip::hwndTT = (WXHWND)NULL;
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// a simple wrapper around TOOLINFO Win32 structure
class wxToolInfo // define a TOOLINFO for OS/2 here : public TOOLINFO
{
public:
wxToolInfo(wxWindow *win)
{
// initialize all members
// ::ZeroMemory(this, sizeof(TOOLINFO));
cbSize = sizeof(this);
uFlags = 0; // TTF_IDISHWND;
uId = (UINT)win->GetHWND();
}
size_t cbSize;
ULONG uFlags;
UINT uId;
HWND hwnd;
char* lpszText;
};
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// send a message to the tooltip control
inline MRESULT SendTooltipMessage(WXHWND hwnd,
UINT msg,
MPARAM wParam,
MPARAM lParam)
{
// return hwnd ? ::SendMessage((HWND)hwnd, msg, wParam, (MPARAM)lParam)
// : 0;
return (MRESULT)0;
}
// send a message to all existing tooltip controls
static void SendTooltipMessageToAll(WXHWND hwnd,
UINT msg,
MPARAM wParam,
MPARAM lParam)
{
if ( hwnd )
(void)SendTooltipMessage((WXHWND)hwnd, msg, wParam, lParam);
}
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// static functions
// ----------------------------------------------------------------------------
void wxToolTip::Enable(bool flag)
{
// SendTooltipMessageToAll((WXHWND)hwndTT,TTM_ACTIVATE, flag, 0);
}
void wxToolTip::SetDelay(long milliseconds)
{
// SendTooltipMessageToAll((WXHWND)hwndTT,TTM_SETDELAYTIME, TTDT_INITIAL, milliseconds);
}
// ---------------------------------------------------------------------------
// implementation helpers
// ---------------------------------------------------------------------------
// create the tooltip ctrl for our parent frame if it doesn't exist yet
WXHWND wxToolTip::GetToolTipCtrl()
{
// TODO:
/*
if ( !hwndTT )
{
hwndTT = (WXHWND)::CreateWindow(TOOLTIPS_CLASS,
(LPSTR)NULL,
TTS_ALWAYSTIP,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, (HMENU)NULL,
wxGetInstance(),
NULL);
if ( hwndTT )
{
SetWindowPos((HWND)hwndTT, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
}
return (WXHWND)hwndTT;
*/
return (WXHWND)0;
}
void wxToolTip::RelayEvent(WXMSG *msg)
{
// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_RELAYEVENT, 0, msg);
}
// ----------------------------------------------------------------------------
// ctor & dtor
// ----------------------------------------------------------------------------
wxToolTip::wxToolTip(const wxString &tip)
: m_text(tip)
{
m_window = NULL;
}
wxToolTip::~wxToolTip()
{
// there is no need to Remove() this tool - it will be done automatically
// anyhow
}
// ----------------------------------------------------------------------------
// others
// ----------------------------------------------------------------------------
void wxToolTip::Remove()
{
// remove this tool from the tooltip control
if ( m_window )
{
wxToolInfo ti(m_window);
// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_DELTOOL, 0, &ti);
}
}
void wxToolTip::SetWindow(wxWindow *win)
{
Remove();
m_window = win;
if ( m_window )
{
wxToolInfo ti(m_window);
// as we store our text anyhow, it seems useless to waste system memory
// by asking the tooltip ctrl to remember it too - instead it will send
// us TTN_NEEDTEXT (via WM_NOTIFY) when it is about to be shown
ti.hwnd = (HWND)m_window->GetHWND();
// ti.lpszText = LPSTR_TEXTCALLBACK;
// instead of: ti.lpszText = (char *)m_text.c_str();
// TODO:
/*
if ( !SendTooltipMessage(GetToolTipCtrl(), TTM_ADDTOOL, 0, &ti) )
{
wxLogSysError(_("Failed to create the tooltip '%s'"),
m_text.c_str());
}
*/
}
}
void wxToolTip::SetTip(const wxString& tip)
{
m_text = tip;
if ( m_window )
{
// update it immediately
wxToolInfo ti(m_window);
ti.lpszText = (wxChar *)m_text.c_str();
// (void)SendTooltipMessage(GetToolTipCtrl(), TTM_UPDATETIPTEXT, 0, &ti);
}
}
#endif // wxUSE_TOOLTIPS

File diff suppressed because it is too large Load Diff

View File

@@ -9,10 +9,6 @@
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
// #pragma implementation "utils.h" // Note: this is done in utilscmn.cpp now.
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
@@ -40,10 +36,12 @@
#include <errno.h>
#include <stdarg.h>
#define INCL_OS2
#define INCL_DOS
#define INCL_PM
#define INCL_GPI
#include <os2.h>
#include<netdb.h>
#define PURE_32
#include<upm.h>
// In the WIN.INI file
@@ -60,7 +58,7 @@ static const wxChar eUSERNAME[] = _T("UserName");
// Get full hostname (eg. DoDo.BSn-Germany.crg.de)
bool wxGetHostName(wxChar *buf, int maxSize)
{
#ifdef USE_NET_API
#if wxUSE_NET_API
char server[256];
char computer[256];
unsigned long ulLevel;
@@ -80,10 +78,12 @@ bool wxGetHostName(wxChar *buf, int maxSize)
wxChar *sysname;
const wxChar *default_host = _T("noname");
if ((sysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL) {
GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1);
} else
wxStrncpy(buf, sysname, maxSize - 1);
if ((sysname = wxGetenv(_T("SYSTEM_NAME"))) == NULL)
{
// GetProfileString(WX_SECTION, eHOSTNAME, default_host, buf, maxSize - 1);
}
else
wxStrncpy(buf, sysname, maxSize - 1);
buf[maxSize] = _T('\0');
#endif
return *buf ? TRUE : FALSE;
@@ -92,7 +92,7 @@ bool wxGetHostName(wxChar *buf, int maxSize)
// Get user ID e.g. jacs
bool wxGetUserId(wxChar *buf, int maxSize)
{
return(U32ELOCL(bub, maxSize));
return(U32ELOCL((unsigned char*)buf, (unsigned long *)&maxSize));
}
bool wxGetUserName(wxChar *buf, int maxSize)
@@ -100,16 +100,7 @@ bool wxGetUserName(wxChar *buf, int maxSize)
#ifdef USE_NET_API
wxGetUserId(buf, maxSize);
#else
bool ok = GetProfileString(WX_SECTION, eUSERNAME, _T(""), buf, maxSize - 1) != 0;
if ( !ok )
{
ok = wxGetUserId(buf, maxSize);
}
if ( !ok )
{
wxStrncpy(buf, _T("Unknown User"), maxSize);
}
wxStrncpy(buf, _T("Unknown User"), maxSize);
#endif
return TRUE;
}
@@ -140,7 +131,8 @@ bool wxShell(const wxString& command)
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
long wxGetFreeMemory()
{
return (long)GetFreeSpace(0);
// return (long)GetFreeSpace(0);
return 0L;
}
// Sleep for nSecs seconds. Attempt a Windows implementation using timers.
@@ -198,7 +190,6 @@ void wxDebugMsg(const wxChar *fmt ...)
va_start(ap, fmt);
sprintf(buffer,fmt,ap) ;
fflush(buffer) ;
va_end(ap);
}
@@ -211,24 +202,24 @@ void wxError(const wxString& msg, const wxString& title)
,NULL
,(PSZ)wxBuffer
,(PSZ)WXSTRINGCAST title
,0
,MB_ICONEXCLAMATION | MB_YESNO
) == IDNO)
) == MBID_YES)
wxExit();
}
// Fatal error: pop up message box and abort
void wxFatalError(const wxString& msg, const wxString& title)
void wxFatalError(const wxString& rMsg, const wxString& rTitle)
{
YUint32 rc;
HWND hWnd;
unsigned long rc;
WinMessageBox( HWND_DESKTOP
,hWnd
,rMsg.Data()
,rTitle.Data()
,0
,MB_NOICON | MB_OK
);
rc = ::WinMessageBox( HWND_DESKTOP
,NULL
,WXSTRINGCAST rMsg
,WXSTRINGCAST rTitle
,0
,MB_NOICON | MB_OK
);
DosExit(EXIT_PROCESS, rc);
}
@@ -258,13 +249,19 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn)
}
// Reading and writing resources (eg WIN.INI, .Xdefaults)
// TODO: Ability to read and write to an INI file
#if wxUSE_RESOURCES
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
{
// TODO:
/*
if (file != "")
return (WritePrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)value, (PCSZ)WXSTRINGCAST file) != 0);
else
return (WriteProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)WXSTRINGCAST value) != 0);
*/
return FALSE;
}
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
@@ -291,6 +288,8 @@ bool wxWriteResource(const wxString& section, const wxString& entry, int value,
bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file)
{
static const wxChar defunkt[] = _T("$$default");
// TODO:
/*
if (file != "")
{
int n = GetPrivateProfileString((PCSZ)WXSTRINGCAST section, (PCSZ)WXSTRINGCAST entry, (PCSZ)defunkt,
@@ -308,7 +307,9 @@ bool wxGetResource(const wxString& section, const wxString& entry, wxChar **valu
if (*value) delete[] (*value);
*value = copystring(wxBuffer);
return TRUE;
}
*/
return FALSE;
}
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
{
@@ -452,7 +453,7 @@ bool wxCheckForInterrupt(wxWindow *wnd)
HWND win= (HWND) wnd->GetHWND();
while(::WinPeekMsg(hab,&msg,hwndFilter,0,0,PM_REMOVE))
{
::WinDispatchMsg( hab, &qmsg );
::WinDispatchMsg( hab, &msg );
}
return TRUE;//*** temporary?
}
@@ -488,16 +489,16 @@ wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourc
* wxChar *theText = (wxChar *)LockResource(hData);
* if (!theText)
* return NULL;
*
* s = copystring(theText);
*/
s = copystring(theText);
return s;
}
void wxGetMousePosition( int* x, int* y )
{
POINT pt;
GetCursorPos( & pt );
POINTL pt;
::WinQueryPointerPos( HWND_DESKTOP, & pt );
*x = pt.x;
*y = pt.y;
};
@@ -530,7 +531,7 @@ int wxDisplayDepth()
nDepth = nPlanes * nBitsPerPixel;
}
DevCloseDC(hDc);
return (depth);
return (nDepth);
}
// Get size of display
@@ -545,8 +546,8 @@ void wxDisplaySize(int *width, int *height)
,lArray
))
{
*pWidth = (int)lArray[CAPS_WIDTH];
*pHeight = (int)lArray[CAPS_HEIGHT];
*width = (int)lArray[CAPS_WIDTH];
*height = (int)lArray[CAPS_HEIGHT];
}
DevCloseDC(hDc);
}
@@ -565,7 +566,7 @@ wxString WXDLLEXPORT wxGetWindowText(WXHWND hWnd)
{
wxString str;
long len = ::WinQueryWindowTextLength((HWND)hWnd) + 1;
::WinQueryWindowText((HWND)hWnd, str.GetWriteBuf((int)len), len);
::WinQueryWindowText((HWND)hWnd, len, str.GetWriteBuf((int)len));
str.UngetWriteBuf();
return str;
@@ -579,7 +580,7 @@ wxString WXDLLEXPORT wxGetWindowClass(WXHWND hWnd)
for ( ;; )
{
int count = ::WinQueryClassName((HWND)hWnd, str.GetWriteBuf(len), len);
int count = ::WinQueryClassName((HWND)hWnd, len, str.GetWriteBuf(len));
str.UngetWriteBuf();
if ( count == len )

View File

@@ -1,28 +1,262 @@
/////////////////////////////////////////////////////////////////////////////
// Name: utilsexec.cpp
// Purpose: Execution-related utilities
// Author: AUTHOR
// Purpose: Various utilities
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/intl.h"
#endif
#include "wx/utils.h"
#include "wx/log.h"
#include "wx/process.h"
#include "wx/os2/private.h"
#define INCL_DOS
#include <os2.h>
#include <ctype.h>
#include <direct.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#define wxEXECUTE_WIN_MESSAGE 10000
// this message is sent when the process we're waiting for terminates
#define wxWM_PROC_TERMINATED (WM_USER + 10000)
// structure describing the process we're being waiting for
struct wxExecuteData
{
public:
~wxExecuteData()
{
// TODO:
/*
if ( !::CloseHandle(hProcess) )
{
wxLogLastError("CloseHandle(hProcess)");
}
*/
}
HWND hWnd; // window to send wxWM_PROC_TERMINATED to
HANDLE hProcess; // handle of the process
DWORD dwProcessId; // pid of the process
wxProcess *handler;
DWORD dwExitCode; // the exit code of the process
bool state; // set to FALSE when the process finishes
};
static DWORD wxExecuteThread(wxExecuteData *data)
{
// TODO:
/*
WaitForSingleObject(data->hProcess, INFINITE);
// get the exit code
if ( !GetExitCodeProcess(data->hProcess, &data->dwExitCode) )
{
wxLogLastError("GetExitCodeProcess");
}
wxASSERT_MSG( data->dwExitCode != STILL_ACTIVE,
wxT("process should have terminated") );
// send a message indicating process termination to the window
SendMessage(data->hWnd, wxWM_PROC_TERMINATED, 0, (LPARAM)data);
*/
return 0;
}
// window procedure of a hidden window which is created just to receive
// the notification message when a process exits
MRESULT APIENTRY wxExecuteWindowCbk(HWND hWnd, UINT message,
MPARAM wParam, MPARAM lParam)
{
if ( message == wxWM_PROC_TERMINATED )
{
// DestroyWindow(hWnd); // we don't need it any more
wxExecuteData *data = (wxExecuteData *)lParam;
if ( data->handler )
{
data->handler->OnTerminate((int)data->dwProcessId,
(int)data->dwExitCode);
}
if ( data->state )
{
// we're executing synchronously, tell the waiting thread
// that the process finished
data->state = 0;
}
else
{
// asynchronous execution - we should do the clean up
delete data;
}
}
return 0;
}
extern wxChar wxPanelClassName[];
long wxExecute(const wxString& command, bool sync, wxProcess *handler)
{
// TODO
wxCHECK_MSG( !!command, 0, wxT("empty command in wxExecute") );
// the old code is disabled because we really need a process handle
// if we want to execute it asynchronously or even just get its
// return code and for this we must use CreateProcess() and not
// ShellExecute()
// create the process
// TODO:
/*
STARTUPINFO si;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
PROCESS_INFORMATION pi;
if ( ::CreateProcess(
NULL, // application name (use only cmd line)
(wxChar *)command.c_str(), // full command line
NULL, // security attributes: defaults for both
NULL, // the process and its main thread
FALSE, // don't inherit handles
CREATE_DEFAULT_ERROR_MODE, // flags
NULL, // environment (use the same)
NULL, // current directory (use the same)
&si, // startup info (unused here)
&pi // process info
) == 0 )
{
wxLogSysError(_("Execution of command '%s' failed"), command.c_str());
return 0;
}
// close unneeded handle
if ( !::CloseHandle(pi.hThread) )
wxLogLastError("CloseHandle(hThread)");
// create a hidden window to receive notification about process
// termination
HWND hwnd = ::CreateWindow(wxPanelClassName, NULL, 0, 0, 0, 0, 0, NULL,
(HMENU)NULL, wxGetInstance(), 0);
wxASSERT_MSG( hwnd, wxT("can't create a hidden window for wxExecute") );
FARPROC ExecuteWindowInstance = MakeProcInstance((FARPROC)wxExecuteWindowCbk,
wxGetInstance());
::SetWindowLong(hwnd, GWL_WNDPROC, (LONG) ExecuteWindowInstance);
// Alloc data
wxExecuteData *data = new wxExecuteData;
data->hProcess = pi.hProcess;
data->dwProcessId = pi.dwProcessId;
data->hWnd = hwnd;
data->state = sync;
if ( sync )
{
wxASSERT_MSG( !handler, wxT("wxProcess param ignored for sync execution") );
data->handler = NULL;
}
else
{
// may be NULL or not
data->handler = handler;
}
DWORD tid;
HANDLE hThread = ::CreateThread(NULL,
0,
(LPTHREAD_START_ROUTINE)wxExecuteThread,
(void *)data,
0,
&tid);
if ( !hThread )
{
wxLogLastError("CreateThread in wxExecute");
DestroyWindow(hwnd);
delete data;
// the process still started up successfully...
return pi.dwProcessId;
}
if ( !sync )
{
// clean up will be done when the process terminates
// return the pid
return pi.dwProcessId;
}
// waiting until command executed
while ( data->state )
wxYield();
DWORD dwExitCode = data->dwExitCode;
delete data;
// return the exit code
return dwExitCode;
*/
return 0;
}
long wxExecute(char **argv, bool sync, wxProcess *handler)
{
wxString command;
while ( *argv != NULL )
{
command << *argv++ << ' ';
}
command.RemoveLast();
return wxExecute(command, sync, handler);
}
bool wxGetFullHostName(wxChar *buf, int maxSize)
{
DWORD nSize = maxSize ;
// TODO:
/*
if ( !::GetComputerName(buf, &nSize) )
{
wxLogLastError("GetComputerName");
return FALSE;
}
*/
return TRUE;
}

View File

@@ -1,21 +1,33 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wave.cpp
// Purpose: wxWave class implementation: optional
// Author: AUTHOR
// Author: David Webster
// Modified by:
// Created: ??/??/98
// Created: 10/17/99
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
// Copyright: (c) David Webster
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "wave.h"
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
#include "wx/stubs/wave.h"
#include "wx/file.h"
#include "wx/os2/wave.h"
#include "wx/os2/private.h"
#define INCL_DOS
#define INCL_PM
#include <os2.h>
#ifdef RECT
#undef RECT
#endif
#include <mmio.h>
#include <mmsystem.h>
wxWave::wxWave()
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
@@ -23,39 +35,122 @@ wxWave::wxWave()
}
wxWave::wxWave(const wxString& sFileName, bool isResource)
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
: m_waveData(NULL), m_waveLength(0), m_isResource(isResource)
{
Create(sFileName, isResource);
Create(sFileName, isResource);
}
wxWave::wxWave(int size, const wxByte* data)
: m_waveData(NULL), m_waveLength(0), m_isResource(FALSE)
{
Create(size, data);
}
wxWave::~wxWave()
{
Free();
Free();
}
bool wxWave::Create(const wxString& fileName, bool isResource)
{
Free();
Free();
// TODO
if (isResource)
{
m_isResource = TRUE;
// TODO:
/*
HRSRC hresInfo;
#ifdef _UNICODE
hresInfo = ::FindResourceW((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#else
hresInfo = ::FindResourceA((HMODULE) wxhInstance, fileName, wxT("WAVE"));
#endif
if (!hresInfo)
return FALSE;
HGLOBAL waveData = ::LoadResource((HMODULE) wxhInstance, hresInfo);
if (waveData)
{
m_waveData= (wxByte*)::LockResource(waveData);
m_waveLength = (int) ::SizeofResource((HMODULE) wxhInstance, hresInfo);
}
return (m_waveData ? TRUE : FALSE);
*/
return FALSE;
}
else
{
m_isResource = FALSE;
wxFile fileWave;
if (!fileWave.Open(fileName, wxFile::read))
return FALSE;
m_waveLength = (int) fileWave.Length();
// TODO:
/*
m_waveData = (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
fileWave.Read(m_waveData, m_waveLength);
*/
return TRUE;
}
}
bool wxWave::Create(int size, const wxByte* data)
{
Free();
m_isResource = FALSE;
m_waveLength=size;
m_waveData = NULL; // (wxByte*)::GlobalLock(::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, m_waveLength));
if (!m_waveData)
return FALSE;
for (int i=0; i<size; i++) m_waveData[i] = data[i];
return TRUE;
}
bool wxWave::Play(bool async, bool looped) const
{
if (!IsOk())
return FALSE;
// TODO
if (!IsOk())
return FALSE;
// TODO:
/*
return ( ::PlaySound((LPCTSTR)m_waveData, NULL, SND_MEMORY |
SND_NODEFAULT | (async ? SND_ASYNC : SND_SYNC) | (looped ? (SND_LOOP | SND_ASYNC) : 0)) != 0 );
*/
return FALSE;
}
bool wxWave::Free()
{
// TODO
return FALSE;
if (m_waveData)
{
// HGLOBAL waveData = ::GlobalHandle(m_waveData);
// TODO:
/*
if (waveData)
{
if (m_isResource)
::FreeResource(waveData);
else
{
::GlobalUnlock(waveData);
::GlobalFree(waveData);
}
m_waveData = NULL;
m_waveLength = 0;
return TRUE;
}
*/
}
return FALSE;
}