int x = 1;
}
return (Ok() && rc);
-// ::WinTranslateAccel( vHabmain
-// ,(HWND)hWnd
-// ,GetHaccel()
-// ,pMsg
-// );
} // end of wxAcceleratorTable::Translate
if (!::WinRegisterClass( vHab
,wxFrameClassName
,wxFrameWndProc
- ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT | CS_CLIPCHILDREN
+ ,CS_SIZEREDRAW | CS_SYNCPAINT | CS_CLIPCHILDREN
,sizeof(ULONG)
))
{
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)
))
{
#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;
-
- // TODO: create button
+ m_windowId = vId;
+ lStyle = WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON;
+
+ //
+ // 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
wxSize wxButton::DoGetBestSize() const
{
- wxString label = wxGetWindowText(GetHWND());
- int wBtn;
- GetTextExtent(label, &wBtn, NULL);
-
- int wChar, hChar;
- wxGetCharSize(GetHWND(), &wChar, &hChar, (wxFont*)&GetFont());
-
- // add a margin - the button is wider than just its label
- wBtn += 3*wChar;
-
- // the button height is proportional to the height of the font used
- int hBtn = 0;// TODO: BUTTON_HEIGHT_FROM_CHAR_HEIGHT(hChar);
-
- return wxSize(wBtn, hBtn);
-}
+ wxString rsLabel = wxGetWindowText(GetHWND());
+ int nWidthButton;
+ int nWidthChar;
+ int nHeightChar;
+
+ GetTextExtent( rsLabel
+ ,&nWidthButton
+ ,NULL
+ );
+
+ wxGetCharSize( GetHWND()
+ ,&nWidthChar
+ ,&nHeightChar
+ ,(wxFont*)&GetFont()
+ );
+
+ //
+ // Add a margin - the button is wider than just its label
+ //
+ nWidthButton += 3 * nWidthChar;
+
+ //
+ // 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
// 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
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;
+
+ 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();
+ }
+ }
- // TODO: make button the default
-}
+ //
+ // 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;
-}
-
-WXHBRUSH wxButton::OnCtlColor(WXHDC pDC,
- WXHWND pWnd,
- WXUINT nCtlColor,
- WXUINT message,
- WXWPARAM wParam,
- WXLPARAM lParam)
+ return bProcessed;
+} // end of wxButton::OS2Command
+
+WXHBRUSH wxButton::OnCtlColor(
+ WXHDC pDC
+, WXHWND pWnd
+, WXUINT nCtlColor
+, WXUINT uMessage
+, WXWPARAM wParam
+, WXLPARAM lParam
+)
+{
+ wxBrush* pBackgroundBrush = wxTheBrushList->FindOrCreateBrush( GetBackgroundColour()
+ ,wxSOLID
+ );
+
+ return (WXHBRUSH)pBackgroundBrush->GetResourceHandle();
+} // end of wxButton::OnCtlColor
+
+void wxButton::MakeOwnerDrawn()
{
- wxBrush *backgroundBrush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(), wxSOLID);
+ long lStyle = 0L;
- return (WXHBRUSH) backgroundBrush->GetResourceHandle();
-}
+ 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
vError = ::WinGetLastError(vHabmain);
}
- strcpy(zFacename, M_FONTDATA->m_vFattrs.szFacename);
+ M_FONTDATA->m_sFaceName = zFacename;
if(::GpiCreateLogFont( M_FONTDATA->m_hPS
,NULL
}
} // 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.
//
::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);
if (m_frameStatusBar)
{
int nWidth;
+ int nY;
int nStatbarWidth;
int nStatbarHeight;
HWND hWndClient;
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
);
// 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
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
vEvent.SetEventObject(this);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+ AlterChildPos();
}
return bProcessed;
} // end of wxFrame::HandleSize
{
#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;
..\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 \
serbase.obj \
sizer.obj \
socket.obj \
+ statbar.obj \
strconv.obj \
stream.obj \
string.obj \
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
{
wxString Title;
const wxChar *pc;
- for (pc = rTitle; *pc != wxT('\0'); pc++ )
+ for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
{
if (*pc == wxT('&') )
{
else
Title << wxT('~');
}
-// else if (*pc == wxT('/'))
-// {
-// Title << wxT('\\');
-// }
else
{
if ( *pc == wxT('~') )
{
wxString Title;
const wxChar *pc;
- for (pc = rTitle; *pc != wxT('\0'); pc++ )
+ for (pc = rTitle.c_str(); *pc != wxT('\0'); pc++ )
{
if (*pc == wxT('&') )
{
else
Title << wxT('~');
}
-// else if (*pc == wxT('/'))
-// {
-// Title << wxT('\\');
-// }
else
{
if ( *pc == wxT('~') )
}
else
{
- lSstyle |= ES_LEFT;
+ lSstyle |= ES_LEFT | ES_AUTOSCROLL | ES_MARGIN;
if (m_windowStyle & wxHSCROLL)
lSstyle |= ES_AUTOSCROLL;
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)
{
#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
}
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
if (hWnd != 0)
{
- wxChar zFont[128];
+ char zFont[128];
+ char zFacename[30];
+ char zWeight[30];
+ char zStyle[30];
+
+ //
+ // 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;
- sprintf(zFont, "%d.%s", rFont.GetPointSize(), rFont.GetFaceName().c_str());
- return (bool)::WinSetPresParam(hWnd, PP_FONTNAMESIZE, strlen(zFont), (PVOID)zFont);
+ 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);
}
, 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);
+ 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
- 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");
+ 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
//
, const wxFont* pTheFont
) const
{
- const wxFont* pFontToUse = pTheFont;
- HPS hPs;
-
- hPs = ::WinGetPS(GetHwnd());
+ 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;
- // Just prevent compiler warnings
- wxString dummy = rString;
- pX = pX;
- pY = pY;
- pDescent = pDescent;
- pExternalLeading = pExternalLeading;
-/*
-// TODO: Will have to play with fonts later
- if (!pFontToUse)
- pFontToUse = &m_font;
+ hPS = ::WinGetPS(GetHwnd());
- HFONT hFnt = 0;
- HFONT hFfontOld = 0;
+ l = rString.Length();
+ if (l > 0L)
+ {
+ pStr = (PCH)rString.c_str();
- if (pFontToUse && pFontToUse->Ok())
+ //
+ // 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;
+ }
+ }
+ else
{
- ::GpiCreateLog
- hFnt = (HFONT)((wxFont *)pFontToUse)->GetResourceHandle(); // const_cast
- if (hFnt)
- hFontOld = (HFONT)SelectObject(dc,fnt);
+ 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);
-}
+ 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
// ---------------------------------------------------------------------------
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
// 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);
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;
}
}
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();
bProcessed = HandlePaletteChanged();
break;
- case WM_PRESPARAMCHANGED:
- bProcessed = HandlePresParamChanged(wParam);
- break;
-
-
// move all drag and drops to wxDrg
case WM_ENDDRAG:
bProcessed = HandleEndDrag(wParam);
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),
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.
//
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
// WM_KEYDOWN one
//
bool wxWindowOS2::HandleChar(
- WXWORD wParam
+ WXDWORD wParam
, WXLPARAM lParam
, bool isASCII
)
} // end of wxWindowOS2::HandleKeyDown
bool wxWindowOS2::HandleKeyUp(
- WXWORD wParam
+ WXDWORD wParam
, WXLPARAM lParam
)
{
// ===========================================================================
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
//