Some OS/2 Modifications for coordinate normalizations and code for some common controls

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12146 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
2001-10-22 05:15:25 +00:00
parent afa59b4e88
commit 987da0d411
12 changed files with 542 additions and 317 deletions

View File

@@ -208,10 +208,5 @@ bool wxAcceleratorTable::Translate(
int x = 1;
}
return (Ok() && rc);
// ::WinTranslateAccel( vHabmain
// ,(HWND)hWnd
// ,GetHaccel()
// ,pMsg
// );
} // end of wxAcceleratorTable::Translate

View File

@@ -332,7 +332,7 @@ bool wxApp::RegisterWindowClasses(
if (!::WinRegisterClass( vHab
,wxFrameClassName
,wxFrameWndProc
,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT | CS_CLIPCHILDREN
,CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPCHILDREN
,sizeof(ULONG)
))
{
@@ -423,7 +423,7 @@ bool wxApp::RegisterWindowClasses(
if (!::WinRegisterClass( vHab
,wxCanvasClassName
,wxWndProc
,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT | CS_CLIPCHILDREN
,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT | CS_CLIPCHILDREN
,sizeof(ULONG)
))
{

View File

@@ -23,48 +23,97 @@
#include "wx/os2/private.h"
#define BUTTON_HEIGHT_FROM_CHAR_HEIGHT(cy) (11*EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)/10)
//
// Should be at the very least less than winDEFAULT_BUTTON_MARGIN
//
#define FOCUS_MARGIN 3
#ifndef BST_CHECKED
#define BST_CHECKED 0x0001
#endif
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
// Button
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
bool wxButton::Create(
wxWindow* pParent
, wxWindowID vId
, const wxString& rsLabel
, const wxPoint& rPos
, const wxSize& rSize
, long lStyle
#if wxUSE_VALIDATORS
const wxValidator& validator,
, const wxValidator& rValidator
#endif
const wxString& name)
, const wxString& rsName
)
{
SetName(name);
SetName(rsName);
#if wxUSE_VALIDATORS
SetValidator(validator);
SetValidator(rValidator);
#endif
m_windowStyle = style;
parent->AddChild((wxButton *)this);
if (id == -1)
m_windowStyle = lStyle;
pParent->AddChild((wxButton *)this);
if (vId == -1)
m_windowId = NewControlId();
else
m_windowId = id;
m_windowId = vId;
lStyle = WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
// TODO: create button
//
// OS/2 PM does not have Right/Left/Top/Bottom styles.
// We will have to define an additional style when we implement notebooks
// for a notebook page button
//
if (m_windowStyle & wxCLIP_SIBLINGS )
lStyle |= WS_CLIPSIBLINGS;
m_hWnd = (WXHWND)::WinCreateWindow( GetHwndOf(pParent) // Parent handle
,WC_BUTTON // A Button class window
,(PSZ)rsLabel.c_str() // Button text
,lStyle // Button style
,0, 0, 0, 0 // Location and size
,GetHwndOf(pParent) // Owner handle
,HWND_TOP // Top of Z-Order
,vId // Identifier
,NULL // No control data
,NULL // No Presentation parameters
);
if (m_hWnd == 0)
{
return FALSE;
}
return FALSE;
}
//
// Subclass again for purposes of dialog editing mode
//
SubclassWin(m_hWnd);
SetFont(pParent->GetFont());
SetSize( rPos.x
,rPos.y
,rSize.x
,rSize.y
);
return TRUE;
} // end of wxButton::Create
wxButton::~wxButton()
{
wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
if ( panel )
wxPanel* pPanel = wxDynamicCast(GetParent(), wxPanel);
if (pPanel)
{
if ( panel->GetDefaultItem() == this )
if (pPanel->GetDefaultItem() == this)
{
// don't leave the panel with invalid default item
panel->SetDefaultItem(NULL);
//
// Don't leave the panel with invalid default item
//
pPanel->SetDefaultItem(NULL);
}
}
}
} // end of wxButton::~wxButton
// ----------------------------------------------------------------------------
// size management including autosizing
@@ -72,33 +121,59 @@ wxButton::~wxButton()
wxSize wxButton::DoGetBestSize() const
{
wxString label = wxGetWindowText(GetHWND());
int wBtn;
GetTextExtent(label, &wBtn, NULL);
wxString rsLabel = wxGetWindowText(GetHWND());
int nWidthButton;
int nWidthChar;
int nHeightChar;
int wChar, hChar;
wxGetCharSize(GetHWND(), &wChar, &hChar, (wxFont*)&GetFont());
GetTextExtent( rsLabel
,&nWidthButton
,NULL
);
// add a margin - the button is wider than just its label
wBtn += 3*wChar;
wxGetCharSize( GetHWND()
,&nWidthChar
,&nHeightChar
,(wxFont*)&GetFont()
);
// the button height is proportional to the height of the font used
int hBtn = 0;// TODO: BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
//
// Add a margin - the button is wider than just its label
//
nWidthButton += 3 * nWidthChar;
return wxSize(wBtn, hBtn);
}
//
// The button height is proportional to the height of the font used
//
int nHeightButton = BUTTON_HEIGHT_FROM_CHAR_HEIGHT(nHeightChar);
//
// Need a little extra to make it look right
//
nHeightButton += nHeightChar/1.5;
wxSize vSize = GetDefaultSize();
if (nWidthButton > vSize.x)
vSize.x = nWidthButton;
if (nHeightButton > vSize.y)
vSize.y = nHeightButton;
return vSize;
} // end of wxButton::DoGetBestSize
/* static */
wxSize wxButton::GetDefaultSize()
{
static wxSize s_sizeBtn;
static wxSize vSizeBtn;
if ( s_sizeBtn.x == 0 )
if (vSizeBtn.x == 0)
{
wxScreenDC dc;
dc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
wxScreenDC vDc;
// the size of a standard button in the dialog units is 50x14,
vDc.SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
//
// The size of a standard button in the dialog units is 50x14,
// translate this to pixels
// NB1: the multipliers come from the Windows convention
// NB2: the extra +1/+2 were needed to get the size be the same as the
@@ -106,17 +181,18 @@ wxSize wxButton::GetDefaultSize()
// this happens, but on my system this size is 75x23 in pixels and
// 23*8 isn't even divisible by 14... Would be nice to understand
// why these constants are needed though!
s_sizeBtn.x = (50 * (dc.GetCharWidth() + 1))/4;
s_sizeBtn.y = ((14 * dc.GetCharHeight()) + 2)/8;
vSizeBtn.x = (50 * (vDc.GetCharWidth() + 1))/4;
vSizeBtn.y = ((14 * vDc.GetCharHeight()) + 2)/8;
}
return vSizeBtn;
} // end of wxButton::GetDefaultSize
return s_sizeBtn;
}
void wxButton::Command (wxCommandEvent & event)
void wxButton::Command (
wxCommandEvent& rEvent
)
{
ProcessCommand (event);
}
ProcessCommand (rEvent);
} // end of wxButton::Command
// ----------------------------------------------------------------------------
// helpers
@@ -124,53 +200,157 @@ void wxButton::Command (wxCommandEvent & event)
bool wxButton::SendClickEvent()
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
event.SetEventObject(this);
wxCommandEvent vEvent( wxEVT_COMMAND_BUTTON_CLICKED
,GetId()
);
return ProcessCommand(event);
}
vEvent.SetEventObject(this);
return ProcessCommand(vEvent);
} // end of wxButton::SendClickEvent
void wxButton::SetDefault()
{
wxWindow *parent = GetParent();
wxButton *btnOldDefault = NULL;
wxPanel *panel = wxDynamicCast(parent, wxPanel);
if (panel)
panel->SetDefaultItem(this);
wxWindow* pParent = GetParent();
wxButton* pBtnOldDefault = NULL;
wxPanel* pPanel = wxDynamicCast(pParent, wxPanel);
long lStyle = 0L;
// TODO: make button the default
}
if (pParent)
{
wxWindow* pWinOldDefault = pParent->SetDefaultItem(this);
pBtnOldDefault = wxDynamicCast(pWinOldDefault, wxButton);
}
if (pBtnOldDefault && pBtnOldDefault != this)
{
//
// Remove the BS_DEFPUSHBUTTON style from the other button
//
lStyle = ::WinQueryWindowULong(GetHwndOf(pBtnOldDefault), QWL_STYLE);
//
// Don't do it with the owner drawn buttons because it will reset
// BS_OWNERDRAW style bit too (BS_OWNERDRAW & BS_DEFPUSHBUTTON != 0)!
//
if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
{
lStyle &= ~BS_DEFAULT;
::WinSetWindowULong(GetHwndOf(pBtnOldDefault), QWL_STYLE, lStyle);
}
else
{
//
// Redraw the button - it will notice itself that it's not the
// default one any longer
//
pBtnOldDefault->Refresh();
}
}
//
// Set this button as the default
//
lStyle = ::WinQueryWindowULong(GetHwnd(), QWL_STYLE);
if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
{
lStyle != BS_DEFAULT;
::WinSetWindowULong(GetHwnd(), QWL_STYLE, lStyle);
}
} // end of wxButton::SetDefault
// ----------------------------------------------------------------------------
// event/message handlers
// ----------------------------------------------------------------------------
bool wxButton::OS2Command(WXUINT param, WXWORD id)
bool wxButton::OS2Command(
WXUINT uParam
, WXWORD wId
)
{
bool processed = FALSE;
// TODO
/*
switch ( param )
bool bProcessed = FALSE;
switch (uParam)
{
case 1: // 1 for accelerator
case BN_CLICKED:
processed = SendClickEvent();
case BN_CLICKED: // normal buttons send this
case BN_DBLCLICKED: // owner-drawn ones also send this
bProcessed = SendClickEvent();
break;
}
*/
return processed;
}
return bProcessed;
} // end of wxButton::OS2Command
WXHBRUSH wxButton::OnCtlColor(WXHDC pDC,
WXHWND pWnd,
WXUINT nCtlColor,
WXUINT message,
WXWPARAM wParam,
WXLPARAM lParam)
WXHBRUSH wxButton::OnCtlColor(
WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
, WXUINT uMessage
, WXWPARAM wParam
, WXLPARAM lParam
)
{
wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
wxBrush* pBackgroundBrush = wxTheBrushList->FindOrCreateBrush( GetBackgroundColour()
,wxSOLID
);
return (WXHBRUSH) backgroundBrush->GetResourceHandle();
}
return (WXHBRUSH)pBackgroundBrush->GetResourceHandle();
} // end of wxButton::OnCtlColor
void wxButton::MakeOwnerDrawn()
{
long lStyle = 0L;
lStyle = ::WinQueryWindowULong(GetHwnd(), QWL_STYLE);
if ((lStyle & BS_USERBUTTON) != BS_USERBUTTON)
{
//
// Make it so
//
lStyle |= BS_USERBUTTON;
::WinSetWindowULong(GetHwnd(), QWL_STYLE, lStyle);
}
} // end of wxCButton::MakeOwnerDrawn
MRESULT wxButton::WindowProc(
WXUINT uMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
{
//
// When we receive focus, we want to become the default button in our
// parent panel
//
if (uMsg == WM_SETFOCUS)
{
SetDefault();
//
// Let the default processign take place too
//
}
else if (uMsg == WM_BUTTON1DBLCLK)
{
//
// Emulate a click event to force an owner-drawn button to change its
// appearance - without this, it won't do it
//
(void)wxControl::OS2WindowProc( WM_BUTTON1DOWN
,wParam
,lParam
);
//
// And conitnue with processing the message normally as well
//
}
//
// Let the base class do all real processing
//
return (wxControl::OS2WindowProc( uMsg
,wParam
,lParam
));
} // end of wxW indowProc

View File

@@ -370,7 +370,7 @@ bool wxFont::RealizeResource()
vError = ::WinGetLastError(vHabmain);
}
strcpy(zFacename, M_FONTDATA->m_vFattrs.szFacename);
M_FONTDATA->m_sFaceName = zFacename;
if(::GpiCreateLogFont( M_FONTDATA->m_hPS
,NULL

View File

@@ -236,6 +236,53 @@ wxFrame::~wxFrame()
}
} // end of wxFrame::~wxFrame
//
// IF we have child controls in the Frame's client we need to alter
// the y position, because, OS/2 controls are positioned relative to
// wxWindows orgin (top left) not the OS/2 origin (bottom left)
void wxFrame::AlterChildPos()
{
//
// OS/2 is the only OS concerned about this
//
wxWindow* pChild = NULL;
wxControl* pCtrl = NULL;
RECTL vRect;
SWP vSwp;
::WinQueryWindowRect(GetHwnd(), &vRect);
for (wxWindowList::Node* pNode = GetChildren().GetFirst();
pNode;
pNode = pNode->GetNext())
{
wxWindow* pChild = pNode->GetData();
::WinQueryWindowPos(pChild->GetHWND(), &vSwp);
vSwp.y += (vRect.yTop - m_vSwpClient.cy);
if (pChild->IsKindOf(CLASSINFO(wxControl)))
{
pCtrl = wxDynamicCast(pChild, wxControl);
//
// Must deal with controls that have margins like ENTRYFIELD. The SWP
// struct of such a control will have and origin offset from its intended
// position by the width of the margins.
//
vSwp.y -= pCtrl->GetYComp();
vSwp.x -= pCtrl->GetXComp();
}
::WinSetWindowPos( pChild->GetHWND()
,HWND_TOP
,vSwp.x
,vSwp.y
,vSwp.cx
,vSwp.cy
,SWP_MOVE
);
::WinQueryWindowPos(pChild->GetHWND(), &vSwp);
pChild = NULL;
}
} // end of wxFrame::AlterChildPos
//
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
//
@@ -375,6 +422,7 @@ bool wxFrame::Show(
::WinQueryWindowPos(m_hFrame, &vSwp);
m_bIconized = vSwp.fl & SWP_MINIMIZE;
::WinQueryWindowPos(m_hWnd, &m_vSwpClient);
::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);
::WinEnableWindow(m_hFrame, TRUE);
vEvent.SetEventObject(this);
@@ -518,6 +566,7 @@ void wxFrame::PositionStatusBar()
if (m_frameStatusBar)
{
int nWidth;
int nY;
int nStatbarWidth;
int nStatbarHeight;
HWND hWndClient;
@@ -525,21 +574,24 @@ void wxFrame::PositionStatusBar()
RECTL vFRect;
::WinQueryWindowRect(m_hFrame, &vRect);
nY = vRect.yTop;
::WinMapWindowPoints(m_hFrame, HWND_DESKTOP, (PPOINTL)&vRect, 2);
vFRect = vRect;
::WinCalcFrameRect(m_hFrame, &vRect, TRUE);
nWidth = vRect.xRight - vRect.xLeft;
nY = nY - (vRect.yBottom - vFRect.yBottom);
m_frameStatusBar->GetSize( &nStatbarWidth
,&nStatbarHeight
);
nY= nY - nStatbarHeight;
//
// Since we wish the status bar to be directly under the client area,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
//
m_frameStatusBar->SetSize( vRect.xLeft - vFRect.xLeft
,vRect.yBottom - vFRect.yBottom
,nY
,nWidth
,nStatbarHeight
);
@@ -1056,6 +1108,17 @@ bool wxFrame::OS2Create(
// Now size everything. If adding a menu the client will need to be resized.
//
if (pParent)
{
nY = pParent->GetSize().y - (nY + nHeight);
}
else
{
RECTL vRect;
::WinQueryWindowRect(HWND_DESKTOP, &vRect);
nY = vRect.yTop - (nY + nHeight);
}
if (!::WinSetWindowPos( m_hFrame
,HWND_TOP
,nX
@@ -1070,23 +1133,6 @@ bool wxFrame::OS2Create(
wxLogError("Error sizing frame. Error: %s\n", sError);
return FALSE;
}
//
// We may have to be smarter here when variable sized toolbars are added!
//
if (!::WinSetWindowPos( m_hWnd
,HWND_TOP
,nX // + 20
,nY // + 20
,nWidth // - 60
,nHeight // - 60
,SWP_SIZE | SWP_MOVE | SWP_ACTIVATE | SWP_ZORDER
))
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
wxLogError("Error sizing client. Error: %s\n", sError);
return FALSE;
}
return TRUE;
} // end of wxFrame::OS2Create
@@ -1446,6 +1492,7 @@ bool wxFrame::HandleSize(
vEvent.SetEventObject(this);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
AlterChildPos();
}
return bProcessed;
} // end of wxFrame::HandleSize

View File

@@ -1495,8 +1495,8 @@ GSocketError GAddress_INET_SetHostName(GAddress *address, const char *hostname)
{
#else
/* Use gethostbyname by default */
// int val = 1; //VA doesn't like constants in conditional expressions at all
if (1)
int val = 1; //VA doesn't like constants in conditional expressions at all
if (val)
{
#endif
struct in_addr *array_addr;

View File

@@ -291,6 +291,7 @@ COMMONOBJS = \
..\common\$D\serbase.obj \
..\common\$D\sizer.obj \
..\common\$D\socket.obj \
..\common\$D\statbar.obj \
..\common\$D\strconv.obj \
..\common\$D\stream.obj \
..\common\$D\string.obj \
@@ -418,6 +419,7 @@ COMLIBOBJS3 = \
serbase.obj \
sizer.obj \
socket.obj \
statbar.obj \
strconv.obj \
stream.obj \
string.obj \
@@ -780,6 +782,7 @@ $(COMLIBOBJS3):
copy ..\common\$D\serbase.obj
copy ..\common\$D\sizer.obj
copy ..\common\$D\socket.obj
copy ..\common\$D\statbar.obj
copy ..\common\$D\strconv.obj
copy ..\common\$D\stream.obj
copy ..\common\$D\string.obj

View File

@@ -73,7 +73,7 @@ static wxString TextToLabel(const wxString& rTitle)
{
wxString Title;
const wxChar *pc;
for (pc = rTitle; *pc != wxT('\0'); pc++ )
for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
{
if (*pc == wxT('&') )
{
@@ -85,10 +85,6 @@ static wxString TextToLabel(const wxString& rTitle)
else
Title << wxT('~');
}
// else if (*pc == wxT('/'))
// {
// Title << wxT('\\');
// }
else
{
if ( *pc == wxT('~') )

View File

@@ -62,7 +62,7 @@ static wxString TextToLabel(const wxString& rTitle)
{
wxString Title;
const wxChar *pc;
for (pc = rTitle; *pc != wxT('\0'); pc++ )
for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
{
if (*pc == wxT('&') )
{
@@ -74,10 +74,6 @@ static wxString TextToLabel(const wxString& rTitle)
else
Title << wxT('~');
}
// else if (*pc == wxT('/'))
// {
// Title << wxT('\\');
// }
else
{
if ( *pc == wxT('~') )

View File

@@ -171,7 +171,7 @@ bool wxTextCtrl::Create(
}
else
{
lSstyle |= ES_LEFT;
lSstyle |= ES_LEFT | ES_AUTOSCROLL | ES_MARGIN;
if (m_windowStyle & wxHSCROLL)
lSstyle |= ES_AUTOSCROLL;
@@ -1130,7 +1130,7 @@ wxSize wxTextCtrl::DoGetBestSize() const
wxGetCharSize(GetHWND(), &nCx, &nCy, (wxFont*)&GetFont());
int wText = DEFAULT_ITEM_WIDTH;
int hText = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy);
int hText = (EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * .8);
if (m_windowStyle & wxTE_MULTILINE)
{

View File

@@ -762,7 +762,7 @@ bool wxColourDisplay()
#else
// I don't see how the PM display could not be color. Besides, this
// was leaking DCs and PSs!!! MN
return true;
return TRUE;
#endif
}

View File

@@ -388,37 +388,12 @@ bool wxWindowOS2::Create(
pParent->AddChild(this);
hParent = GetWinHwnd(pParent);
//
// OS2 uses normal coordinates, no bassackwards Windows ones
//
if (pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
)
{
wxWindow* pGrandParent = NULL;
pGrandParent = pParent->GetParent();
if (pGrandParent)
nTempy = pGrandParent->GetSize().y - (vPos.y + rSize.y);
else
nTempy = pParent->GetSize().y - (vPos.y + rSize.y);
}
else
nTempy = pParent->GetSize().y - (vPos.y + rSize.y);
vPos.y = nTempy;
if ( pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
pParent->IsKindOf(CLASSINFO(wxScrolledWindow))
)
ulCreateFlags |= WS_CLIPSIBLINGS;
}
else
{
RECTL vRect;
::WinQueryWindowRect(HWND_DESKTOP, &vRect);
hParent = HWND_DESKTOP;
vPos.y = vRect.yTop - (vPos.y + rSize.y);
}
//
// Most wxSTYLES are really PM Class specific styles and will be
@@ -614,10 +589,72 @@ bool wxWindowOS2::SetFont(
if (hWnd != 0)
{
wxChar zFont[128];
char zFont[128];
char zFacename[30];
char zWeight[30];
char zStyle[30];
sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
return (bool)::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont);
//
// The fonts available for Presentation Params are just three
// outline fonts, the rest are available to the GPI, so we must
// map the families to one of these three
//
switch(rFont.GetFamily())
{
case wxSCRIPT:
case wxDECORATIVE:
case wxROMAN:
strcpy(zFacename,"Times New Roman");
break;
case wxTELETYPE:
case wxMODERN:
strcpy(zFacename, "Courier");
break;
case wxSWISS:
case wxDEFAULT:
default:
strcpy(zFacename, "Helvetica");
break;
}
switch(rFont.GetWeight())
{
default:
case wxNORMAL:
case wxLIGHT:
zWeight[0] = '\0';
break;
case wxBOLD:
case wxFONTWEIGHT_MAX:
strcpy(zWeight, "Bold");
break;
}
switch(rFont.GetStyle())
{
case wxITALIC:
case wxSLANT:
strcpy(zStyle, "Italic");
break;
default:
zStyle[0] = '\0';
break;
}
sprintf(zFont, "%d.%s", rFont.GetPointSize(), zFacename);
if (zWeight[0] != '\0')
{
strcat(zFont, " ");
strcat(zFont, zWeight);
}
if (zStyle[0] != '\0')
{
strcat(zFont, " ");
strcat(zFont, zStyle);
}
::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont) + 1, (PVOID)zFont);
}
return(TRUE);
}
@@ -1498,29 +1535,41 @@ void wxWindowOS2::DoMoveWindow(
, int nHeight
)
{
#if 0 // x and y coords should already be in os2 coordinates
RECTL vRect;
HWND hParent;
wxWindow* pParent = GetParent();
if (pParent)
hParent = GetWinHwnd(pParent);
else
hParent = HWND_DESKTOP;
::WinQueryWindowRect(hParent, &vRect);
nY = vRect.yTop - (nY + nHeight);
#endif
if ( !::WinSetWindowPos( GetHwnd()
,HWND_TOP
,(LONG)nX
,(LONG)nY
,(LONG)nWidth
,(LONG)nHeight
,SWP_SIZE | SWP_MOVE
))
{
wxLogLastError("MoveWindow");
hParent = GetWinHwnd(pParent);
if (pParent->IsKindOf(CLASSINFO(wxFrame)))
{
if (IsKindOf(CLASSINFO(wxStatusBar)) ||
IsKindOf(CLASSINFO(wxMenuBar)) ||
IsKindOf(CLASSINFO(wxToolBar))
)
nY = pParent->GetSize().y - (nY + nHeight);
else
nY = pParent->GetClientSize().y - (nY + nHeight);
}
else
nY = pParent->GetSize().y - (nY + nHeight);
}
else
{
RECTL vRect;
::WinQueryWindowRect(HWND_DESKTOP, &vRect);
nY = vRect.yTop - (nY + nHeight);
}
::WinSetWindowPos( GetHwnd()
,HWND_TOP
,(LONG)nX
,(LONG)nY
,(LONG)nWidth
,(LONG)nHeight
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
);
} // end of wxWindowOS2::DoMoveWindow
//
@@ -1745,55 +1794,94 @@ void wxWindowOS2::GetTextExtent(
, const wxFont* pTheFont
) const
{
const wxFont* pFontToUse = pTheFont;
HPS hPs;
POINTL avPoint[TXTBOX_COUNT];
POINTL vPtMin;
POINTL vPtMax;
int i;
int l;
FONTMETRICS vFM; // metrics structure
BOOL bRc;
char* pStr;
ERRORID vErrorCode; // last error id code
HPS hPS;
hPs = ::WinGetPS(GetHwnd());
// Just prevent compiler warnings
wxString dummy = rString;
pX = pX;
pY = pY;
pDescent = pDescent;
pExternalLeading = pExternalLeading;
/*
// TODO: Will have to play with fonts later
hPS = ::WinGetPS(GetHwnd());
if (!pFontToUse)
pFontToUse = &m_font;
HFONT hFnt = 0;
HFONT hFfontOld = 0;
if (pFontToUse && pFontToUse->Ok())
l = rString.Length();
if (l > 0L)
{
::GpiCreateLog
hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
if (hFnt)
hFontOld = (HFONT)SelectObject(dc,fnt);
pStr = (PCH)rString.c_str();
//
// In world coordinates.
//
bRc = ::GpiQueryTextBox( hPS
,l
,pStr
,TXTBOX_COUNT // return maximum information
,avPoint // array of coordinates points
);
if (bRc)
{
vPtMin.x = avPoint[0].x;
vPtMax.x = avPoint[0].x;
vPtMin.y = avPoint[0].y;
vPtMax.y = avPoint[0].y;
for (i = 1; i < 4; i++)
{
if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
}
bRc = ::GpiQueryFontMetrics( hPS
,sizeof(FONTMETRICS)
,&vFM
);
if (!bRc)
{
vPtMin.x = 0;
vPtMin.y = 0;
vPtMax.x = 0;
vPtMax.y = 0;
}
}
else
{
vPtMin.x = 0;
vPtMin.y = 0;
vPtMax.x = 0;
vPtMax.y = 0;
}
}
SIZE sizeRect;
TEXTMETRIC tm;
GetTextExtentPoint(dc, string, (int)string.Length(), &sizeRect);
GetTextMetrics(dc, &tm);
if ( fontToUse && fnt && hfontOld )
SelectObject(dc, hfontOld);
ReleaseDC(hWnd, dc);
if ( x )
*x = sizeRect.cx;
if ( y )
*y = sizeRect.cy;
if ( descent )
*descent = tm.tmDescent;
if ( externalLeading )
*externalLeading = tm.tmExternalLeading;
*/
::WinReleasePS(hPs);
}
else
{
vPtMin.x = 0;
vPtMin.y = 0;
vPtMax.x = 0;
vPtMax.y = 0;
}
if (pX)
*pX = (vPtMax.x - vPtMin.x + 1);
if (pY)
*pY = (vPtMax.y - vPtMin.y + 1);
if (pDescent)
{
if (bRc)
*pDescent = vFM.lMaxDescender;
else
*pDescent = 0;
}
if (pExternalLeading)
{
if (bRc)
*pExternalLeading = vFM.lExternalLeading;
else
*pExternalLeading = 0;
}
::WinReleasePS(hPS);
} // end of wxWindow::GetTextExtent
#if wxUSE_CARET && WXWIN_COMPATIBILITY
// ---------------------------------------------------------------------------
@@ -2448,7 +2536,7 @@ MRESULT wxWindowOS2::OS2WindowProc(
if (uKeyFlags & KC_KEYUP)
{
//TODO: check if the cast to WXWORD isn't causing trouble
bProcessed = HandleKeyUp((WXWORD)wParam, lParam);
bProcessed = HandleKeyUp((WXDWORD)wParam, lParam);
break;
}
else // keydown event
@@ -2458,7 +2546,7 @@ MRESULT wxWindowOS2::OS2WindowProc(
// return 0 now (we've handled it). DON't RETURN
// we still need to process further
//
HandleKeyDown((WXWORD)wParam, lParam);
HandleKeyDown((WXDWORD)wParam, lParam);
if (uKeyFlags & KC_VIRTUALKEY)
{
USHORT uVk = SHORT2FROMMP((MPARAM)lParam);
@@ -2492,13 +2580,13 @@ MRESULT wxWindowOS2::OS2WindowProc(
case VK_DOWN:
case VK_UP:
default:
bProcessed = HandleChar((WXWORD)wParam, lParam);
bProcessed = HandleChar((WXDWORD)wParam, lParam);
}
break;
}
else // WM_CHAR -- Always an ASCII character
{
bProcessed = HandleChar((WXWORD)wParam, lParam, TRUE);
bProcessed = HandleChar((WXDWORD)wParam, lParam, TRUE);
break;
}
}
@@ -2542,20 +2630,6 @@ MRESULT wxWindowOS2::OS2WindowProc(
mResult = (MRESULT)(FALSE);
break;
//
// Instead of CTLCOLOR messages PM sends QUERYWINDOWPARAMS to
// things such as colors and fonts and such
//
case WM_QUERYWINDOWPARAMS:
{
PWNDPARAMS pWndParams = (PWNDPARAMS)wParam;
bProcessed = HandleWindowParams( pWndParams
,lParam
);
}
break;
// the return value for this message is ignored
case WM_SYSCOLORCHANGE:
bProcessed = HandleSysColorChange();
@@ -2565,11 +2639,6 @@ MRESULT wxWindowOS2::OS2WindowProc(
bProcessed = HandlePaletteChanged();
break;
case WM_PRESPARAMCHANGED:
bProcessed = HandlePresParamChanged(wParam);
break;
// move all drag and drops to wxDrg
case WM_ENDDRAG:
bProcessed = HandleEndDrag(wParam);
@@ -3282,14 +3351,6 @@ bool wxWindowOS2::HandleCtlColor(
return TRUE;
} // end of wxWindowOS2::HandleCtlColor
bool wxWindowOS2::HandleWindowParams(
PWNDPARAMS WXUNUSED(pWndParams)
, WXLPARAM WXUNUSED(lParam)
)
{
// TODO: I'll do something here, just not sure what yet
return TRUE;
}
// Define for each class of dialog and control
WXHBRUSH wxWindowOS2::OnCtlColor(WXHDC WXUNUSED(hDC),
@@ -3315,21 +3376,6 @@ bool wxWindowOS2::HandlePaletteChanged()
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandlePaletteChanged
bool wxWindowOS2::HandlePresParamChanged(
WXWPARAM WXUNUSED(wParam)
)
{
//
// TODO: Once again I'll do something here when I need it
//
//wxQueryNewPaletteEvent event(GetId());
//event.SetEventObject(this);
// if the background is erased
// bProcessed = HandleEraseBkgnd((WXHDC)(HDC)wParam);
return FALSE; //GetEventHandler()->ProcessEvent(event) && event.GetPaletteRealized();
}
//
// Responds to colour changes: passes event on to children.
//
@@ -3385,65 +3431,6 @@ bool wxWindowOS2::HandlePaint()
vEvent.SetEventObject(this);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
if (!bProcessed)
{
HPS hPS;
hPS = ::WinBeginPaint( GetHwnd()
,NULLHANDLE
,&vRect
);
if(hPS)
{
#if 0
::GpiCreateLogColorTable( hPS
,0L
,LCOLF_CONSECRGB
,0L
,(LONG)wxTheColourDatabase->m_nSize
,(PLONG)wxTheColourDatabase->m_palTable
);
#endif
::GpiCreateLogColorTable( hPS
,0L
,LCOLF_RGB
,0L
,0L
,NULL
);
::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel());
if (m_dwExStyle)
{
LINEBUNDLE vLineBundle;
vLineBundle.lColor = 0x00000000; // Black
vLineBundle.usMixMode = FM_OVERPAINT;
vLineBundle.fxWidth = 1;
vLineBundle.lGeomWidth = 1;
vLineBundle.usType = LINETYPE_SOLID;
vLineBundle.usEnd = 0;
vLineBundle.usJoin = 0;
::GpiSetAttrs( hPS
,PRIM_LINE
,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE
,0L
,&vLineBundle
);
::WinQueryWindowRect(GetHwnd(), &vRect);
wxDrawBorder( hPS
,vRect
,m_dwExStyle
);
}
::WinEndPaint(hPS);
}
}
::GpiDestroyRegion(hPS, hRgn);
::WinReleasePS(hPS);
return GetEventHandler()->ProcessEvent(vEvent); //bProcessed;
} // end of wxWindowOS2::HandlePaint
@@ -3755,7 +3742,7 @@ wxKeyEvent wxWindowOS2::CreateKeyEvent(
// WM_KEYDOWN one
//
bool wxWindowOS2::HandleChar(
WXWORD wParam
WXDWORD wParam
, WXLPARAM lParam
, bool isASCII
)
@@ -3849,7 +3836,7 @@ bool wxWindowOS2::HandleKeyDown(
} // end of wxWindowOS2::HandleKeyDown
bool wxWindowOS2::HandleKeyUp(
WXWORD wParam
WXDWORD wParam
, WXLPARAM lParam
)
{
@@ -3946,13 +3933,34 @@ bool wxWindowOS2::OS2OnScroll(
// ===========================================================================
void wxGetCharSize(
WXHWND WXUNUSED(hWnd)
, int* WXUNUSED(pX)
, int* WXUNUSED(pY)
WXHWND hWnd
, int* pX
, int* pY
,wxFont* WXUNUSED(pTheFont)
)
{
// TODO: we'll do this later
FONTMETRICS vFM;
HPS hPS;
BOOL rc;
hPS =::WinGetPS(hWnd);
rc = ::GpiQueryFontMetrics(hPS, sizeof(FONTMETRICS), &vFM);
if (rc)
{
if (pX)
*pX = vFM.lAveCharWidth;
if (pY)
*pY = vFM.lEmHeight + vFM.lExternalLeading;
}
else
{
if (pX)
*pX = 10;
if (pY)
*pY = 15;
}
::WinReleasePS(hPS);
} // end of wxGetCharSize
//