#define wxByte wxUint8
#define wxWord wxUint16
-// base floating point types
+// base floating point types
// wxFloat32 : 32 bit IEEE float ( 1 sign , 8 exponent bits , 23 fraction bits
// wxFloat64 : 64 bit IEEE float ( 1 sign , 11 exponent bits , 52 fraction bits
// wxDouble : native fastest representation that has at least wxFloat64
// precision, so use the IEEE types for storage , and this for calculations
-typedef float wxFloat32 ;
-#if defined( __WXMAC__ ) && defined (__MWERKS__)
+typedef float wxFloat32 ;
+#if defined( __WXMAC__ ) && defined (__MWERKS__)
typedef short double wxFloat64;
#else
typedef double wxFloat64;
#endif
-#if defined( __WXMAC__ ) && !defined( __POWERPC__ )
+#if defined( __WXMAC__ ) && !defined( __POWERPC__ )
typedef long double wxDouble;
#else
typedef double wxDouble ;
#if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh )
// assembler versions for these
#ifdef __POWERPC__
- inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i )
+ inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i )
{return (__lhbrx( &i , 0 ) ) ;}
- inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i )
+ inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i )
{return (__lhbrx( &i , 0 ) ) ;}
- inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i )
+ inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i )
{return (__lwbrx( &i , 0 ) ) ;}
- inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i )
+ inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i )
{return (__lwbrx( &i , 0 ) ) ;}
#else
#pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0)
typedef void* WXRESULT;
typedef int (*WXFARPROC)();
// some windows handles not defined by PM
-typedef unsigned long COLORREF;
typedef unsigned long HANDLE;
typedef unsigned long HICON;
typedef unsigned long HFONT;
typedef unsigned long HGLOBAL;
typedef unsigned long DWORD;
typedef unsigned short WORD;
-#endif
+
+// WIN32 graphics types for OS/2 GPI
+
+// RGB under OS2 is more like a PALETTEENTRY struct under Windows so we need a real RGB def
+#define OS2RGB(r,g,b) ((DWORD ((BYTE) (r) | ((WORD) (g) << 8)) | (((DWORD)(BYTE)(b)) << 16)))
+
+typedef unsigned long COLORREF;
+#define GetBValue(rgb) ((BYTE)((rgb) >> 16))
+#define GetGValue(rgb) ((BYTE)(((WORD)(rgb)) >> 8))
+#define GetRValue(rgb) ((BYTE)(rgb))
+#define PALETTEINDEX(i) ((COLORREF)(0x01000000 | (DWORD)(WORD)(i)))
+#define PALETTERGB(r,g,b) (0x02000000 | OS2RGB(r,g,b))
+// OS2's RGB/RGB2 is backwards from this
+typedef struct tagPALETTEENTRY
+{
+ char bRed;
+ char bGreen;
+ char bBlue;
+ char bFlags;
+} PALETTEENTRY;
+typedef struct tagLOGPALETTE
+{
+ WORD palVersion;
+ WORD palNumentries;
+ WORD PALETTEENTRY[1];
+} LOGPALETTE;
+#endif //__WXPM__
#if defined(__GNUWIN32__) || defined(__WXWINE__)
typedef int (*WXFARPROC)();
wxLIST_NEXT_ALL, // Searches for subsequent item by index
wxLIST_NEXT_BELOW, // Searches for an item below the specified item
wxLIST_NEXT_LEFT, // Searches for an item to the left of the specified item
- wxLIST_NEXT_RIGHT, // Searches for an item to the right of the specified item
+ wxLIST_NEXT_RIGHT // Searches for an item to the right of the specified item
};
// Alignment flags for Arrange (MSW only except wxLIST_ALIGN_LEFT)
class WXDLLEXPORT wxLog;
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
-HAB vHabmain;
+WXDLLEXPORT_DATA(extern HAB) vHabmain;
// Force an exit from main loop
void WXDLLEXPORT wxExit(void);
protected:
WXHBITMAP m_hMaskBitmap;
DECLARE_DYNAMIC_CLASS(wxMask)
+private:
+ HDC m_hDc;
+ HPS m_hPs;
};
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
{
- DECLARE_DYNAMIC_CLASS(wxPNGFileHandler)
+ DECLARE_DYNAMIC_CLASS(wxPNGFileHandler)
public:
- inline wxPNGFileHandler(void)
- {
- m_name = "PNG bitmap file";
- m_extension = "bmp";
- m_type = wxBITMAP_TYPE_PNG;
- };
+ inline wxPNGFileHandler(void)
+ {
+ m_sName = "PNG bitmap file";
+ m_sExtension = "bmp";
+ m_lType = wxBITMAP_TYPE_PNG;
+ };
- virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight);
- virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
+ virtual bool LoadFile( wxBitmap* pBitmap
+ ,const wxString& rName
+ ,long lFlags
+ ,int nDesiredWidth
+ ,int nDesiredHeight
+ );
+ virtual bool SaveFile( wxBitmap* pBitmap
+ ,const wxString& rName
+ ,int nType
+ ,const wxPalette* pPalette = NULL
+ );
};
#endif
#ifdef __GNUG__
#pragma implementation "imaglist.h"
#endif
-
+
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
return m_images.Number()-1;
}
-const wxBitmap *wxImageList::GetBitmap( int index ) const
+const wxBitmap *wxImageList::GetBitmap( int index ) const
{
wxNode *node = m_images.Nth( index );
-
+
wxCHECK_MSG( node, (wxBitmap *) NULL, wxT("wrong index in image list") );
-
+
return (wxBitmap*)node->Data();
}
-
+
bool wxImageList::Replace( int index, const wxBitmap &bitmap )
{
wxNode *node = m_images.Nth( index );
-
+
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
wxBitmap* newBitmap = NULL;
if (bitmap.IsKindOf(CLASSINFO(wxIcon)))
+#if defined(__VISAGECPP__)
+//just can't do this in VisualAge now, with all this new Bitmap-Icon stuff
+//so construct it from a bitmap object until I can figure this nonsense out. (DW)
+ newBitmap = new wxBitmap(bitmap) ;
+#else
newBitmap = new wxIcon( (const wxIcon&) bitmap );
+#endif
else
newBitmap = new wxBitmap(bitmap) ;
m_images.DeleteNode( node );
m_images.Insert( next, newBitmap );
}
-
+
return TRUE;
}
bool wxImageList::Remove( int index )
{
wxNode *node = m_images.Nth( index );
-
+
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
-
+
m_images.DeleteNode( node );
-
+
return TRUE;
}
bool wxImageList::RemoveAll()
{
m_images.Clear();
-
+
return TRUE;
}
{
width = 0;
height = 0;
-
+
wxNode *node = m_images.Nth( index );
-
+
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
-
+
wxBitmap *bm = (wxBitmap*)node->Data();
width = bm->GetWidth();
height = bm->GetHeight();
-
+
return TRUE;
}
int flags, bool WXUNUSED(solidBackground) )
{
wxNode *node = m_images.Nth( index );
-
+
wxCHECK_MSG( node, FALSE, wxT("wrong index in image list") );
-
+
wxBitmap *bm = (wxBitmap*)node->Data();
if (bm->IsKindOf(CLASSINFO(wxIcon)))
HINSTANCE wxhInstance = 0;
QMSG svCurrentMsg;
wxApp* wxTheApp = NULL;
+HAB vHabmain = NULL;
// FIXME why not const? and not static?
bool wxApp::OnInitGui()
{
- m_vHab = WinInitialize(0);
- m_hMq = WinCreateMsgQueue(m_vHab, 0);
+ vHabmain = WinInitialize(0);
+ m_hMq = WinCreateMsgQueue(vHabmain, 0);
return TRUE;
}
//
bool wxApp::DoMessage()
{
- BOOL bRc = ::WinGetMsg(m_vHab, &m_vMsg, HWND(NULL), 0, 0);
+ BOOL bRc = ::WinGetMsg(vHabmain, &m_vMsg, HWND(NULL), 0, 0);
if (bRc == 0)
{
if ( !ProcessMessage((WXMSG *)&vMsg) )
{
- ::WinDispatchMsg(m_vHab, &vMsg);
+ ::WinDispatchMsg(vHabmain, &vMsg);
}
}
svSavedMessages.Empty();
// Process the message
if (!ProcessMessage((WXMSG *)&svCurrentMsg) )
{
- ::WinDispatchMsg(m_vHab, (PQMSG)&svCurrentMsg);
+ ::WinDispatchMsg(vHabmain, (PQMSG)&svCurrentMsg);
}
}
return TRUE;
#if wxUSE_THREADS
wxMutexGuiLeaveOrEnter();
#endif // wxUSE_THREADS
- while (!::WinPeekMsg(m_vHab, &svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) &&
+ while (!::WinPeekMsg(vHabmain, &svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) &&
ProcessIdle() )
{
}
bool wxApp::Pending()
{
- return (::WinPeekMsg(m_vHab, (PQMSG)&svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) != 0);
+ return (::WinPeekMsg(vHabmain, (PQMSG)&svCurrentMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) != 0);
}
void wxApp::Dispatch()
m_refData = pRefData;
- refData->m_width = rIcon.GetWidth();
- refData->m_height = rIcon.GetHeight();
- refData->m_depth = wxDisplayDepth();
+ pRefData->m_nWidth = rIcon.GetWidth();
+ pRefData->m_nHeight = rIcon.GetHeight();
+ pRefData->m_nDepth = wxDisplayDepth();
- refData->m_hBitmap = (WXHBITMAP)rIcon.GetHandle();
+ pRefData->m_hBitmap = (WXHBITMAP)rIcon.GetHandle();
// no mask???
- refData->m_bitmapMask = new wxMask();
+ pRefData->m_pBitmapMask = new wxMask();
#if WXWIN_COMPATIBILITY_2
- refData->m_ok = TRUE;
+ pRefData->m_bOk = TRUE;
#endif // WXWIN_COMPATIBILITY_2
-
return(TRUE);
}
if (!rCursor.Ok())
return(FALSE);
- return CopyFromIconOrCursor(wxGDIImage)rCursor);
+ return(CopyFromIconOrCursor(rCursor));
}
bool wxBitmap::CopyFromIcon(
refData->m_ok = TRUE;
#endif // WXWIN_COMPATIBILITY_2
- return CopyFromIconOrCursor(icon);
+ return CopyFromIconOrCursor(rIcon);
}
wxBitmap::~wxBitmap()
BITMAPINFO2 vInfo;
HDC hDc;
HPS hPs;
- DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+ DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
SIZEL vSize = {0, 0};
- wxAssert(vHabmain != NULL);
+ wxASSERT(vHabmain != NULL);
hDc = ::DevOpenDC(vHabmain, OD_MEMORY, (PSZ)"*", 1L, (PDEVOPENDATA)&vDop, 0L);
vHeader.ulColorEncoding = 0;
vHeader.ulIdentifier = 0;
- hPs = ::GpiCreatePS(vHabMain, hdc, &vSize, GPIA_ASSOC | PU_PELS);
+ hPs = ::GpiCreatePS(vHabmain, hDc, &vSize, GPIA_ASSOC | PU_PELS);
if (hPs == 0)
{
wxLogLastError("GpiCreatePS Failure");
m_refData = pRefData;
- refData->m_width = nTheWidth;
- refData->m_height = nTheHeight;
- refData->m_depth = nNoBits;
- refData->m_numColors = 0;
- refData->m_selectedInto = NULL;
+ pRefData->m_nWidth = nTheWidth;
+ pRefData->m_nHeight = nTheHeight;
+ pRefData->m_nDepth = nNoBits;
+ pRefData->m_nNumColors = 0;
+ pRefData->m_pSelectedInto = NULL;
HBITMAP hBmp = ::GpiCreateBitmap(hPs, &vHeader, 0L, NULL, &vInfo);
- if ( !hbmp )
+ if (!hBmp)
{
wxLogLastError("CreateBitmap");
}
- SetHBITMAP((WXHBITMAP)hbmp);
+ SetHBITMAP((WXHBITMAP)hBmp);
}
// Create from XPM data
{
Init();
-F (void)Create( (void *)ppData
+ (void)Create( (void *)ppData
,wxBITMAP_TYPE_XPM_DATA
,0
,0
BITMAPINFO2 vInfo;
HPS hpsScreen;
HDC hdcScreen;
- DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+ DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
SIZEL vSize = {0, 0};
LONG lBitCount;
- wxAssert(vHabmain != NULL);
+ wxASSERT(vHabmain != NULL);
hpsScreen = ::WinGetScreenPS(HWND_DESKTOP);
hdcScreen = ::GpiQueryDevice(hpsScreen);
- ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, &lBitCount);
+ ::DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitCount);
vHeader.cbFix = sizeof(vHeader);
vHeader.cx = (USHORT)nW;
vHeader.ulColorEncoding = 0;
vHeader.ulIdentifier = 0;
-
UnRef();
m_refData = new wxBitmapRefData;
- GetBitmapData()->m_width = nW;
- GetBitmapData()->m_height = nH;
- GetBitmapData()->m_depth = nD;
+ GetBitmapData()->m_nWidth = nW;
+ GetBitmapData()->m_nHeight = nH;
+ GetBitmapData()->m_nDepth = nD;
if (nD > 0)
{
{
LONG lPlanes;
- ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, &lPlanes);
+ ::DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes);
hBmp = ::GpiCreateBitmap(hpsScreen, &vHeader, 0L, NULL, &vInfo);
if (!hBmp)
{
wxLogLastError("CreateBitmap");
}
- GetBitmapData()->m_depth = wxDisplayDepth();
+ GetBitmapData()->m_nDepth = wxDisplayDepth();
}
SetHBITMAP((WXHBITMAP)hBmp);
,lType
, -1
, -1
- );
+ ));
}
else
{
wxImage vImage;
- if (!vImage.LoadFile(rFilename, lType) || !image.Ok() )
+ if (!vImage.LoadFile(rFilename, lType) || !vImage.Ok() )
return(FALSE);
*this = vImage.ConvertToBitmap();
if (!pHandler)
{
wxLogDebug(wxT("Failed to create bitmap: no bitmap handler for "
- "type %d defined."), type);
+ "type %d defined."), lType);
return(FALSE);
}
m_refData = new wxBitmapRefData;
- return(handler->Create( this
- ,pData
- ,lType
- ,nWidth
- ,nHeight
- ,nDepth
- ));
+ return(pHandler->Create( this
+ ,pData
+ ,lType
+ ,nWidth
+ ,nHeight
+ ,nDepth
+ ));
}
bool wxBitmap::SaveFile(
,this->GetHeight()
,rDc.GetDepth()
);
+ WXHBITMAP vOldBitmap;
HPS hMemoryPS;
HPS hPs;
POINTL vPoint[4];
- SIZEL vSize = {0,0}
+ SIZEL vSize = {0,0};
- hMemoryPS = ::GpiCreatePS(habMain, (HDC)vMemDC.m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPI_ASSOC);
- hPs = ::GpiCreatePS(habMain, (HDC)rDc.m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPI_ASSOC);
+ hMemoryPS = ::GpiCreatePS(vHabmain, (HDC)vMemDC.GetHDC(), &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
+ hPs = ::GpiCreatePS(vHabmain, (HDC)rDc.GetHDC(), &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
// TODO: Set the points
- rDc.m_oldBitmap = (WXHBITMAP)::GpiSetBitMap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP());
- :GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY | BBO_IGNORE);
+ vOldBitmap = (WXHBITMAP)::GpiSetBitmap(hPs, (HBITMAP)vTmpBitmap.GetHBITMAP());
+ ::GpiBitBlt(hPs, hMemoryPS, 4L, vPoint, ROP_SRCCOPY, BBO_IGNORE);
return(vTmpBitmap);
}
)
{
BITMAPINFOHEADER2 vHeader;
- DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+ DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
SIZEL vSize = {0, 0};
POINTL vPoint[4];
HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
::GpiSetBitmap(srcPS, (HBITMAP)m_hMaskBitmap);
// TODO: Set the point array
- :GpiBitBlt(destPs, srcPS, 4L, vPoint, ROP_SRCCOPY | BBO_IGNORE);
+ ::GpiBitBlt(destPS, srcPS, 4L, vPoint, ROP_SRCCOPY , BBO_IGNORE);
::GpiDestroyPS(srcPS);
::GpiDestroyPS(destPS);
}
if (rBitmap.Ok() && rBitmap.GetPalette()->Ok())
{
- unsigned char red, green, blue;
+ unsigned char cRed;
+ unsigned char cGreen;
+ unsigned char cBlue;
+
if (rBitmap.GetPalette()->GetRGB( nPaletteIndex
- ,&rRed
- ,&rGreen
- ,&rBlue
+ ,&cRed
+ ,&cGreen
+ ,&cBlue
))
{
- wxColour vTransparentColour( rRed
- ,rGreen
- ,rBlue
+ wxColour vTransparentColour( cRed
+ ,cGreen
+ ,cBlue
);
return (Create( rBitmap
)
{
BITMAPINFOHEADER2 vHeader;
- DEVOPENSTRUCT vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+ DEVOPENSTRUC vDop = { NULL, "DISPLAY", NULL, NULL, NULL, NULL, NULL, NULL, NULL };
SIZEL vSize = {0, 0};
POINTL vPoint[4];
,NULL
,NULL
);
- );
+
HPS srcPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
::GpiSetBitmap(srcPS, (HBITMAP)rBitmap.GetHBITMAP());
HPS destPS = ::GpiCreatePS(vHabmain, m_hDc, &vSize, PU_PELS | GPIT_MICRO | GPIA_ASSOC);
vPoint.x = w;
vPoint.y = h;
- COLORREF col = ::GpiQueryPel(srcPS, w, h);
+ COLORREF col = ::GpiQueryPel(srcPS, &vPoint);
if (col == vMaskColour)
{
, int nHeight
)
{
- wxBitmap* bitmap = wxDynamicCast( pImage
- ,wxBitmap
- );
+ wxBitmap* pBitmap = wxDynamicCast( pImage
+ ,wxBitmap
+ );
return(pBitmap ? LoadFile( pBitmap
,rName
, int WXUNUSED(nDesiredHeight)
)
{
- return(FALSE(;
+ return(FALSE);
}
bool wxBitmapHandler::SaveFile(
wxCursorRefData::wxCursorRefData(void)
{
- m_width = 32; m_height = 32;
+ m_nWidth = 32;
+ m_nHeight = 32;
m_hCursor = 0 ;
m_destroyCursor = FALSE;
}
M_CURSORDATA->m_destroyCursor = FALSE;
M_CURSORDATA->m_hCursor = 0;
- M_CURSORDATA->m_ok = FALSE;
// TODO:
/*
+ M_CURSORDATA->m_bOK = FALSE;
if (flags & wxBITMAP_TYPE_CUR_RESOURCE)
{
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
void wxIconRefData::Free()
{
- if ( m_hIcon )
- ::DestroyIcon((HICON) m_hIcon);
+ if (m_hIcon)
+ ::WinFreeFileIcon((HPOINTER)m_hIcon);
}
// ----------------------------------------------------------------------------
, int nDesiredHeight
)
{
- wxGDIImageHandler* pHandler = FindHandler(type);
+ wxGDIImageHandler* pHandler = FindHandler(lType);
UnRef();
m_refData = new wxIconRefData;
#endif
-void
-ima_png_error(png_struct *png_ptr, char *message)
+void ima_png_error(png_struct *png_ptr, char *message)
{
// wxMessageBox(message, "PNG error");
Init();
SetName(rName);
- if (pParent) parent->AddChild(this);
+ if (pParent)
+ pParent->AddChild(this);
- m_backgroundColour = parent->GetBackgroundColour() ;
- m_foregroundColour = parent->GetForegroundColour() ;
+ m_backgroundColour = pParent->GetBackgroundColour() ;
+ m_foregroundColour = pParent->GetForegroundColour() ;
- if ( id == -1 )
+ if (nId == -1)
m_windowId = (int)NewControlId();
else
m_windowId = nId;
m_windowStyle = lStyle;
- int nX= pos.x;
- int nY = pos.y;
- int nWidth = size.x;
- int nHeight = size.y;
+ int nX= rPos.x;
+ int nY = rPos.y;
+ int nWidth = rSize.x;
+ int nHeight = rSize.y;
m_windowStyle = lStyle;
// TODO: create static bitmap control
const wxChar* zClassname = wxT("WX_STATIC");
- int nWinstyle ? SS_ICON : SS_BITMAP;
+ int nWinstyle = m_bIsIcon ? SS_ICON : SS_BITMAP;
- m_hWnd = (WXWHND)::WinCreateWindow( pParent->GetHWND()
+ m_hWnd = (WXHWND)::WinCreateWindow( pParent->GetHWND()
,zClassname
,wxT("")
,nWinstyle | WS_VISIBLE
bool wxStaticBitmap::ImageIsOk() const
{
- return(m_pImage ** m_pImage->Ok());
+ return(m_pImage && m_pImage->Ok());
}
void wxStaticBitmap::Free()
int nH;
GetPosition(&nX, &nY);
- GetSize(&nW, &nHh);
+ GetSize(&nW, &nH);
::WinSendMsg( GetHwnd()
,SM_SETHANDLE
wxThread* m_pThread; // pointer to the wxWindows thread object
// if it's FALSE, some secondary thread is holding the GUI lock
-static bool s_bGuiOwnedByMainThread = TRUE;
+static bool gs_bGuiOwnedByMainThread = TRUE;
// critical section which controls access to all GUI functions: any secondary
// thread (i.e. except the main one) must enter this crit section before doing
// any GUI calls
-static wxCriticalSection *s_pCritsectGui = NULL;
+static wxCriticalSection *gs_pCritsectGui = NULL;
// critical section which protects s_nWaitingForGui variable
-static wxCriticalSection *s_pCritsectWaitingForGui = NULL;
+static wxCriticalSection *gs_pCritsectWaitingForGui = NULL;
// number of threads waiting for GUI in wxMutexGuiEnter()
-static size_t s_nWaitingForGui = 0;
+static size_t gs_nWaitingForGui = 0;
// are we waiting for a thread termination?
-static bool s_bWaitingForThread = FALSE;
+static bool gs_bWaitingForThread = FALSE;
// ============================================================================
// OS/2 implementation of thread classes
void wxCondition::Wait()
{
- (void)m_internal->Wait(SEM_INFINITE_WAIT);
+ (void)m_internal->Wait(SEM_INDEFINITE_WAIT);
}
bool wxCondition::Wait(
// enter m_critsect before changing the thread state
pThread->m_critsect.Enter();
- bool bWasCancelled = thread->m_internal->GetState() == STATE_CANCELED;
+ bool bWasCancelled = pThread->m_internal->GetState() == STATE_CANCELED;
pThread->m_internal->SetState(STATE_EXITED);
- thread->m_critsect.Leave();
+ pThread->m_critsect.Leave();
pThread->OnExit();
if (pThread->IsDetached() && !bWasCancelled)
{
// auto delete
- delete thread;
+ delete pThread;
}
//else: the joinable threads handle will be closed when Wait() is done
return dwRet;
{
// translate wxWindows priority to the PM one
ULONG ulOS2_Priority;
+ ULONG ulrc;
m_nPriority = nPriority;
if (IsMain())
{
// set flag for wxIsWaitingForThread()
- gs_waitingForThread = TRUE;
+ gs_bWaitingForThread = TRUE;
#if wxUSE_GUI
wxBeginBusyCursor();
if ( IsMain() )
{
- gs_waitingForThread = FALSE;
+ gs_bWaitingForThread = FALSE;
#if wxUSE_GUI
wxEndBusyCursor();
delete this;
}
- wxASSERT_MSG( (DWORD)rc != STILL_ACTIVE,
- wxT("thread must be already terminated.") );
-
if ( pRc )
*pRc = rc;
bool wxThreadModule::OnInit()
{
- s_pCritsectWaitingForGui = new wxCriticalSection();
+ gs_pCritsectWaitingForGui = new wxCriticalSection();
- s_pCritsectGui = new wxCriticalSection();
- s_pCritsectGui->Enter();
+ gs_pCritsectGui = new wxCriticalSection();
+ gs_pCritsectGui->Enter();
PTIB ptib;
PPIB ppib;
void wxThreadModule::OnExit()
{
- if (s_pCritsectGui)
+ if (gs_pCritsectGui)
{
- s_pCritsectGui->Leave();
- delete s_pCritsectGui;
- s_pCritsectGui = NULL;
+ gs_pCritsectGui->Leave();
+ delete gs_pCritsectGui;
+ gs_pCritsectGui = NULL;
}
- wxDELETE(s_pCritsectWaitingForGui);
+ wxDELETE(gs_pCritsectWaitingForGui);
}
// ----------------------------------------------------------------------------
void WXDLLEXPORT wxMutexGuiLeave()
{
- wxCriticalSectionLocker enter(*s_pCritsectWaitingForGui);
+ wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui);
if ( wxThread::IsMain() )
{
- s_bGuiOwnedByMainThread = FALSE;
+ gs_bGuiOwnedByMainThread = FALSE;
}
else
{
// decrement the number of waiters now
- wxASSERT_MSG( s_nWaitingForGui > 0,
+ wxASSERT_MSG(gs_nWaitingForGui > 0,
wxT("calling wxMutexGuiLeave() without entering it first?") );
- s_nWaitingForGui--;
+ gs_nWaitingForGui--;
wxWakeUpMainThread();
}
- s_pCritsectGui->Leave();
+ gs_pCritsectGui->Leave();
}
void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
wxASSERT_MSG( wxThread::IsMain(),
wxT("only main thread may call wxMutexGuiLeaveOrEnter()!") );
- wxCriticalSectionLocker enter(*s_pCritsectWaitingForGui);
+ wxCriticalSectionLocker enter(*gs_pCritsectWaitingForGui);
- if ( s_nWaitingForGui == 0 )
+ if (gs_nWaitingForGui == 0)
{
// no threads are waiting for GUI - so we may acquire the lock without
// any danger (but only if we don't already have it)
if (!wxGuiOwnedByMainThread())
{
- s_pCritsectGui->Enter();
+ gs_pCritsectGui->Enter();
- s_bGuiOwnedByMainThread = TRUE;
+ gs_bGuiOwnedByMainThread = TRUE;
}
//else: already have it, nothing to do
}
bool WXDLLEXPORT wxGuiOwnedByMainThread()
{
- return s_bGuiOwnedByMainThread;
+ return gs_bGuiOwnedByMainThread;
}
bool WXDLLEXPORT wxIsWaitingForThread()
{
- return s_bWaitingForThread;
+ return gs_bWaitingForThread;
}
#endif