virtual void Raise(void);
// event handlers
- void OnActivate(wxActivateEvent& rEvent);
void OnSysColourChanged(wxSysColourChangedEvent& rEvent);
// Toolbar
void SetToolTipCtrl(WXHWND hHwndTT) { m_hWndToolTip = hHwndTT; }
#endif // tooltips
- //
- // Called by wxWindow whenever it gets focus
- //
- void SetLastFocus(wxWindow* pWin) { m_pWinLastFocused = pWin; }
- wxWindow *GetLastFocus(void) const { return m_pWinLastFocused; }
-
void SetClient(WXHWND c_Hwnd);
void SetClient(wxWindow* c_Window);
wxWindow *GetClient();
bool m_bFsIsShowing;
bool m_bWasMinimized;
bool m_bIsShown;
- wxWindow* m_pWinLastFocused;
private:
#if wxUSE_TOOLTIPS
public:
wxPopupWindow() { }
- wxPopupWindow(wxWindow* pParent) { (void)Create(pParent); }
+ wxPopupWindow( wxWindow* pParent
+ ,int nFlags
+ )
+ { (void)Create(pParent, nFlags); }
bool Create( wxWindow* pParent
,int nFlags = wxBORDER_NONE
// Implementation only from now on
// -------------------------------
//
-
- //
- // Override Show() to prevent wxPopupWindow from being activated
- //
- virtual bool Show(bool show = TRUE);
-
- //
- // Find a shown popup window with the given window as parent, return NULL
- // if none
- //
- static wxPopupWindow *FindPopupFor(wxWindow* pWin);
-
protected:
+
virtual void DoGetPosition( int* pnX
,int* pny
) const;
virtual WXDWORD OS2GetStyle( long lFlags
,WXDWORD* dwExstyle
) const;
+ //
+ // Get the HWND to be used as parent of this window with CreateWindow()
+ //
+ virtual WXHWND OS2GetParent(void) const;
+
//
// The list of all currently shown popup windows used by FindPopupFor()
//
void Command(wxCommandEvent& rEvent);
bool ContainsHWND(WXHWND hWnd) const;
- bool Enable(bool bEnable);
+ virtual bool Enable(bool bEnable = TRUE);
void Enable( int nItem
,bool bEnable
);
,WXWORD wId
);
void SendNotificationEvent(void);
- void Show( int nItem
+ virtual void Show( int nItem
,bool bShow = TRUE
) ;
bool Show(bool bShow);
// --------------------------
//
PSWP GetSwpClient(void) { return &m_vSwpClient; }
+
+ void OnActivate(wxActivateEvent& rEvent);
+
+ void SetLastFocus(wxWindow *pWin) { m_pWinLastFocused = pWin; }
+ wxWindow* GetLastFocus(void) const { return m_pWinLastFocused; }
protected:
//
// Common part of all ctors
bool m_bFsIsMaximized;
bool m_bFsIsShowing;
+ wxWindow* m_pWinLastFocused;
+
WXHWND m_hFrame;
SWP m_vSwp;
SWP m_vSwpClient;
static bool m_sbInitialized;
static wxWindow* m_spHiddenParent;
+
+ DECLARE_EVENT_TABLE()
}; // end of CLASS wxTopLevelWindowOS2
//
WXFARPROC OS2GetOldWndProc(void) const { return m_fnOldWndProc; }
void OS2SetOldWndProc(WXFARPROC fnProc) { m_fnOldWndProc = fnProc; }
+ //
+ // Return TRUE if the window is of a standard (i.e. not wxWindows') class
+ //
+ bool IsOfStandardClass(void) const { return m_fnOldWndProc != NULL; }
wxWindow* FindItem(long lId) const;
wxWindow* FindItemByHWND( WXHWND hWnd
bool m_bUseCtl3D:1; // Using CTL3D for this control
bool m_bBackgroundTransparent:1;
bool m_bMouseInWindow:1;
- bool m_bDoubleClickAllowed:1;
bool m_bLastKeydownProcessed:1;
bool m_bWinCaptured:1;
WXDWORD m_dwExStyle;
M_FONTDATA->SetPS(hPS);
RealizeResource();
-} // end of wxFont::SetUnderlined
+} // end of wxFont::SetPS
,(int)lNumFonts
);
- wxString sVals;
-
- //
- // For debugging, delete later
- //
- for (int i = 0; i < lNumFonts; i++)
- {
- sVals << "Face: " << pFM[i].szFacename
- << "Family: " << pFM[i].szFamilyname
- << " PointSize: " << pFM[i].lEmHeight
- << " Height: " << pFM[i].lXHeight
- ;
- sVals = "";
- }
-
//
// Initialize FATTR and FACENAMEDESC
//
pFattrs->usRecordLength = sizeof(FATTRS);
pFattrs->fsFontUse = FATTR_FONTUSE_OUTLINE | // only outline fonts allowed
- FATTR_FONTUSE_TRANSFORMABLE; // may be transformed
+ FATTR_FONTUSE_TRANSFORMABLE; // may be transformed
pFattrs->fsType = 0;
pFattrs->lMaxBaselineExt = pFattrs->lAveCharWidth = 0;
pFattrs->idRegistry = 0;
, PFACENAMEDESC pFaceName
)
{
- //
- // Extract family from facename
- //
- int nFontFamily;
-
- if (strcmp(pLogFont->szFacename, "Times New Roman") == 0)
- nFontFamily = wxROMAN;
- else if (strcmp(pLogFont->szFacename, "WarpSans") == 0)
- nFontFamily = wxSWISS;
- else if (strcmp(pLogFont->szFacename, "Script") == 0)
- nFontFamily = wxSCRIPT;
- else if (strcmp(pLogFont->szFacename, "Courier New") == 0)
- nFontFamily = wxMODERN;
- else
- nFontFamily = wxSWISS;
-
- //
- // Weight and Style
- //
- int nFontWeight = wxNORMAL;
-
- switch (pFaceName->usWeightClass)
- {
- case FWEIGHT_LIGHT:
- nFontWeight = wxLIGHT;
- break;
-
- default:
- case FWEIGHT_NORMAL:
- nFontWeight = wxNORMAL;
- break;
-
- case FWEIGHT_BOLD:
- nFontWeight = wxBOLD;
- break;
- }
-
- int nFontStyle;
-
- if(pLogFont->fsSelection & FATTR_SEL_ITALIC)
- nFontStyle = wxITALIC;
- else
- nFontStyle = wxNORMAL;
-
- bool bFontUnderline = (pLogFont->fsSelection & FATTR_SEL_UNDERSCORE);
- wxString sFontFace = pLogFont->szFacename;
- int nFontPoints = pFM->lEmHeight;
- wxFontEncoding vFontEncoding;
-
- switch (pLogFont->usCodePage)
- {
- default:
- wxFAIL_MSG(wxT("unsupported charset"));
- // fall through
-
- case 850:
- vFontEncoding = wxFONTENCODING_CP1252;
- break;
-
- case 1250:
- vFontEncoding = wxFONTENCODING_CP1250;
- break;
-
- case 921:
- vFontEncoding = wxFONTENCODING_CP1257;
- break;
-
- case 866:
- vFontEncoding = wxFONTENCODING_CP1251;
- break;
-
- case 864:
- vFontEncoding = wxFONTENCODING_CP1256;
- break;
-
- case 869:
- vFontEncoding = wxFONTENCODING_CP1253;
- break;
-
- case 862:
- vFontEncoding = wxFONTENCODING_CP1255;
- break;
-
- case 857:
- vFontEncoding = wxFONTENCODING_CP1254;
- break;
-
- case 874:
- vFontEncoding = wxFONTENCODING_CP437;
- break;
-
- case 437:
- vFontEncoding = wxFONTENCODING_CP437;
- break;
- }
+ wxNativeFontInfo vInfo;
- return wxFont( nFontPoints
- ,nFontFamily
- ,nFontStyle
- ,nFontWeight
- ,bFontUnderline
- ,sFontFace
- ,vFontEncoding
- );
+ vInfo.fa = *pLogFont;
+ vInfo.fm = *pFM;
+ vInfo.fn = *pFaceName;
+ return wxFont(vInfo);
} // end of wxCreateFontFromLogFont
int wxGpiStrcmp(
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
- EVT_ACTIVATE(wxFrame::OnActivate)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
END_EVENT_TABLE()
m_nFsToolBarHeight = 0;
m_hWndToolTip = 0L;
m_bWasMinimized = FALSE;
- m_pWinLastFocused = NULL;
m_frameMenuBar = NULL;
,m_vFsOldSize.height
,SWP_SIZE | SWP_SHOW
);
- return TRUE;
}
+ return wxFrameBase::ShowFullScreen(bShow, lStyle);
} // end of wxFrame::ShowFullScreen
//
// Frame window
//
-//
-// Default activation behaviour - set the focus for the first child
-// subwindow found.
-//
-void wxFrame::OnActivate(
- wxActivateEvent& rEvent
-)
-{
- if ( rEvent.GetActive() )
- {
- // restore focus to the child which was last focused
- wxLogTrace(_T("focus"), _T("wxFrame %08x activated."), m_hWnd);
-
- wxWindow* pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
- : NULL;
- if (!pParent)
- {
- pParent = this;
- }
-
- wxSetFocusToChild( pParent
- ,&m_pWinLastFocused
- );
- }
- else // deactivating
- {
- //
- // Remember the last focused child if it is our child
- //
- m_pWinLastFocused = FindFocus();
-
- for (wxWindowList::Node* pNode = GetChildren().GetFirst();
- pNode;
- pNode = pNode->GetNext())
- {
- // FIXME all this is totally bogus - we need to do the same as wxPanel,
- // but how to do it without duplicating the code?
-
- // restore focus
- wxWindow* pChild = pNode->GetData();
-
- if (!pChild->IsTopLevel()
-#if wxUSE_TOOLBAR
- && !wxDynamicCast(pChild, wxToolBar)
-#endif // wxUSE_TOOLBAR
-#if wxUSE_STATUSBAR
- && !wxDynamicCast(pChild, wxStatusBar)
-#endif // wxUSE_STATUSBAR
- )
- {
- pChild->SetFocus();
- return;
- }
- }
- }
-} // end of wxFrame::OnActivate
-
// ----------------------------------------------------------------------------
// wxFrame size management: we exclude the areas taken by menu/status/toolbars
// from the client area, so the client area is what's really available for the
#include "wx/popupwin.h"
-wxWindowList wxPopupWindow::m_svShownPopups;
+IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow)
// ============================================================================
// implementation
GetParent()->ClientToScreen(pnX, pnY);
} // end of wxPopupWindow::DoGetPosition
+WXHWND wxPopupWindow::OS2GetParent() const
+{
+ // we must be a child of the desktop to be able to extend beyond the parent
+ // window client area (like the comboboxes drop downs do)
+ //
+ return (WXHWND)HWND_DESKTOP;
+} // end of wxPopupWindow::OS2GetParent
+
WXDWORD wxPopupWindow::OS2GetStyle(
long lFlags
, WXDWORD* dwExstyle
return dwStyle;
} // end of wxPopupWindow::OS2GetStyle
-bool wxPopupWindow::Show(
- bool bShow
-)
-{
- SWP vSwp;
- //
- // Skip wxWindow::Show() which calls wxBringWindowToTop(): this results in
- // activating the popup window and stealing the atcivation from our parent
- // which means that the parent frame becomes deactivated when opening a
- // combobox, for example -- definitely not what we want
- //
- if (!wxWindowBase::Show(bShow))
- return FALSE;
-
- if (bShow)
- {
- m_svShownPopups.Append(this);
- }
- else // remove from the shown list
- {
- m_svShownPopups.DeleteObject(this);
- }
- ::WinQueryWindowPos(GetHwnd(), &vSwp);
-
- if (bShow)
- {
- ::WinSetWindowPos( GetHwnd()
- ,HWND_TOP
- ,vSwp.x
- ,vSwp.y
- ,vSwp.cx
- ,vSwp.cy
- ,SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER
- );
- }
- else
- {
- ::WinSetWindowPos( GetHwnd()
- ,HWND_BOTTOM
- ,vSwp.x
- ,vSwp.y
- ,vSwp.cx
- ,vSwp.cy
- ,SWP_HIDE | SWP_ZORDER
- );
- }
- return TRUE;
-} // end of wxPopupWindow::Show
-
-/* static */
-wxPopupWindow* wxPopupWindow::FindPopupFor(
- wxWindow* pWinParent
-)
-{
- //
- // Find a popup with the given parent in the linked list of all shown
- // popups
- //
- for ( wxWindowList::Node *node = m_svShownPopups.GetFirst();
- node;
- node = node->GetNext() )
- {
- wxWindow* pWin = node->GetData();
-
- if (pWin->GetParent() == pWinParent )
- return (wxPopupWindow *)pWin;
- }
- return NULL;
-} // end of wxPopupWindow::FindPopupFor
HMTX m_vMutex;
};
-wxMutex::wxMutex()
+wxMutex::wxMutex(
+ wxMutexType eMutexType
+)
{
APIRET ulrc;
{
wxLogSysError(_("Can not create mutex."));
}
- m_locked = 0;
}
wxMutex::~wxMutex()
{
- if (m_locked > 0)
- wxLogDebug(wxT("Warning: freeing a locked mutex (%d locks)."), m_locked);
::DosCloseMutexSem(m_internal->m_vMutex);
m_internal->m_vMutex = NULL;
}
default:
wxFAIL_MSG(wxT("impossible return value in wxMutex::Lock"));
}
- m_locked++;
return wxMUTEX_NO_ERROR;
}
if (ulrc == ERROR_TIMEOUT || ulrc == ERROR_TOO_MANY_SEM_REQUESTS)
return wxMUTEX_BUSY;
- m_locked++;
return wxMUTEX_NO_ERROR;
}
{
APIRET ulrc;
- if (m_locked > 0)
- m_locked--;
-
ulrc = ::DosReleaseMutexSem(m_internal->m_vMutex);
if (ulrc != 0)
{
m_nWaiters = 0;
}
- inline bool Wait(
+ inline APIRET Wait(
unsigned long ulTimeout
)
{
m_nWaiters++;
ulrc = ::DosWaitEventSem(m_vEvent, ulTimeout);
m_nWaiters--;
- return (ulrc != ERROR_TIMEOUT);
+ return (ulrc);
}
inline ~wxConditionInternal ()
m_internal = NULL;
}
-void wxCondition::Wait()
+wxCondError wxCondition::Wait()
{
- (void)m_internal->Wait(SEM_INDEFINITE_WAIT);
+ APIRET rc = m_internal->Wait(SEM_INDEFINITE_WAIT);
+
+ switch(rc)
+ {
+ case NO_ERROR:
+ return wxCOND_NO_ERROR;
+ case ERROR_INVALID_HANDLE:
+ return wxCOND_INVALID;
+ case ERROR_TIMEOUT:
+ return wxCOND_TIMEOUT;
+ default:
+ return wxCOND_MISC_ERROR;
+ }
}
-bool wxCondition::Wait(
+wxCondError wxCondition::WaitTimeout(
unsigned long lMilliSec
)
{
- return m_internal->Wait(lMilliSec);
+ APIRET rc = m_internal->Wait(lMilliSec);
+
+ switch(rc)
+ {
+ case NO_ERROR:
+ return wxCOND_NO_ERROR;
+ case ERROR_INVALID_HANDLE:
+ return wxCOND_INVALID;
+ case ERROR_TIMEOUT:
+ return wxCOND_TIMEOUT;
+ default:
+ return wxCOND_MISC_ERROR;
+ }
}
-void wxCondition::Signal()
+wxCondError wxCondition::Signal()
{
- ::DosPostEventSem(m_internal->m_vEvent);
+ APIRET rc = ::DosPostEventSem(m_internal->m_vEvent);
+
+ switch(rc)
+ {
+ case NO_ERROR:
+ return wxCOND_NO_ERROR;
+ case ERROR_INVALID_HANDLE:
+ return wxCOND_INVALID;
+ default:
+ return wxCOND_MISC_ERROR;
+ }
}
-void wxCondition::Broadcast()
+wxCondError wxCondition::Broadcast()
{
int i;
+ APIRET rc = NO_ERROR;
for (i = 0; i < m_internal->m_nWaiters; i++)
{
- if (::DosPostEventSem(m_internal->m_vEvent) != 0)
+ if ((rc = ::DosPostEventSem(m_internal->m_vEvent)) != NO_ERROR)
{
wxLogSysError(_("Couldn't change the state of event object."));
+ break;
}
}
+
+ switch(rc)
+ {
+ case NO_ERROR:
+ return wxCOND_NO_ERROR;
+ case ERROR_INVALID_HANDLE:
+ return wxCOND_INVALID;
+ default:
+ return wxCOND_MISC_ERROR;
+ }
}
// ----------------------------------------------------------------------------
bool wxTopLevelWindowOS2::m_sbInitialized = FALSE;
wxWindow* wxTopLevelWindowOS2::m_spHiddenParent = NULL;
+// ============================================================================
+// wxTopLevelWindowOS2 implementation
+// ============================================================================
+
+BEGIN_EVENT_TABLE(wxTopLevelWindowOS2, wxTopLevelWindowBase)
+ EVT_ACTIVATE(wxTopLevelWindowOS2::OnActivate)
+END_EVENT_TABLE()
+
// ============================================================================
// wxTopLevelWindowMSW implementation
// ============================================================================
,MPARAM WXUNUSED(lParam)
)
{
- if (uMessage == WM_INITDLG)
- {
- //
- // For this message, returning TRUE tells system to set focus to the
- // first control in the dialog box.
- //
- return (MRESULT)TRUE;
- }
- else
+ switch(uMessage)
{
- //
- // For all the other ones, FALSE means that we didn't process the
- // message
- //
- return (MRESULT)FALSE;
+ case WM_INITDLG:
+ //
+ // For this message, returning TRUE tells system to set focus to
+ // the first control in the dialog box, but as we set the focus
+ // ourselves, we return FALSE from here as well, so fall through
+ //
+ default:
+ //
+ // For all the other ones, FALSE means that we didn't process the
+ // message
+ //
+ return (MRESULT)FALSE;
}
} // end of wxDlgProc
m_hFrame = NULLHANDLE;
memset(&m_vSwp, 0, sizeof(SWP));
memset(&m_vSwpClient, 0, sizeof(SWP));
+ m_pWinLastFocused = (wxWindow *)NULL;
} // end of wxTopLevelWindowIOS2::Init
+void wxTopLevelWindowOS2::OnActivate(
+ wxActivateEvent& rEvent
+)
+{
+ if (rEvent.GetActive())
+ {
+ //
+ // Restore focus to the child which was last focused
+ //
+ wxLogTrace(_T("focus"), _T("wxTLW %08x activated."), m_hWnd);
+
+ wxWindow* pParent = m_pWinLastFocused ? m_pWinLastFocused->GetParent()
+ : NULL;
+ if (!pParent)
+ {
+ pParent = this;
+ }
+
+ wxSetFocusToChild( pParent
+ ,&m_pWinLastFocused
+ );
+ }
+ else // deactivating
+ {
+ //
+ // Remember the last focused child if it is our child
+ //
+ m_pWinLastFocused = FindFocus();
+
+ //
+ // So we NULL it out if it's a child from some other frame
+ //
+ wxWindow* pWin = m_pWinLastFocused;
+
+ while (pWin)
+ {
+ if (pWin->IsTopLevel())
+ {
+ if (pWin != this)
+ {
+ m_pWinLastFocused = NULL;
+ }
+ break;
+ }
+ pWin = pWin->GetParent();
+ }
+
+ wxLogTrace(_T("focus"),
+ _T("wxTLW %08x deactivated, last focused: %08x."),
+ m_hWnd,
+ m_pWinLastFocused ? GetHwndOf(m_pWinLastFocused)
+ : NULL);
+ rEvent.Skip();
+ }
+} // end of wxTopLevelWindowOS2::OnActivate
+
WXDWORD wxTopLevelWindowOS2::OS2GetStyle(
long lStyle
, WXDWORD* pdwExflags
//
// PM specific
//
- m_bDoubleClickAllowed = 0;
m_bWinCaptured = FALSE;
m_isBeingDeleted = FALSE;
- m_fnOldWndProc = 0;
+ m_fnOldWndProc = NULL;
m_bUseCtl3D = FALSE;
m_bMouseInWindow = FALSE;
m_bLastKeydownProcessed = FALSE;
for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
{
- wxFrame* pFrame = wxDynamicCast(pWin, wxFrame);
+ wxTopLevelWindow* pFrame = wxDynamicCast(pWin, wxTopLevelWindow);
if (pFrame)
{
if (pFrame->GetLastFocus() == this)
- pFrame->SetLastFocus((wxWindow*)NULL);
+ pFrame->SetLastFocus(NULL);
}
}
break;
case WM_QUERYDLGCODE:
- if ( m_lDlgCode )
+ if (!IsOfStandardClass())
{
- mResult = (MRESULT)m_lDlgCode;
- bProcessed = TRUE;
+ if ( m_lDlgCode )
+ {
+ mResult = (MRESULT)m_lDlgCode;
+ bProcessed = TRUE;
+ }
}
//
//else: get the dlg code from the DefWindowProc()