some os/2 icon-bitmap fixes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Webster
1999-12-06 05:01:46 +00:00
parent 58b1642453
commit 43543d985b
13 changed files with 202 additions and 158 deletions

View File

@@ -1686,7 +1686,6 @@ typedef unsigned long WXMSGID;
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;
@@ -1700,7 +1699,33 @@ typedef unsigned long HIMAGELIST;
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)();

View File

@@ -59,7 +59,7 @@ enum
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)

View File

@@ -22,7 +22,7 @@ class WXDLLEXPORT wxKeyEvent;
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);

View File

@@ -272,6 +272,9 @@ public:
protected:
WXHBITMAP m_hMaskBitmap;
DECLARE_DYNAMIC_CLASS(wxMask)
private:
HDC m_hDc;
HPS m_hPs;
};
// ----------------------------------------------------------------------------

View File

@@ -22,14 +22,22 @@ class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
public:
inline wxPNGFileHandler(void)
{
m_name = "PNG bitmap file";
m_extension = "bmp";
m_type = wxBITMAP_TYPE_PNG;
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

View File

@@ -75,7 +75,13 @@ bool wxImageList::Replace( int index, const wxBitmap &bitmap )
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) ;

View File

@@ -68,6 +68,7 @@ extern wxCursor* g_globalCursor;
HINSTANCE wxhInstance = 0;
QMSG svCurrentMsg;
wxApp* wxTheApp = NULL;
HAB vHabmain = NULL;
// FIXME why not const? and not static?
@@ -481,8 +482,8 @@ int wxEntry(
bool wxApp::OnInitGui()
{
m_vHab = WinInitialize(0);
m_hMq = WinCreateMsgQueue(m_vHab, 0);
vHabmain = WinInitialize(0);
m_hMq = WinCreateMsgQueue(vHabmain, 0);
return TRUE;
}
@@ -530,7 +531,7 @@ bool wxApp::Initialized()
//
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)
{
@@ -592,7 +593,7 @@ bool wxApp::DoMessage()
if ( !ProcessMessage((WXMSG *)&vMsg) )
{
::WinDispatchMsg(m_vHab, &vMsg);
::WinDispatchMsg(vHabmain, &vMsg);
}
}
svSavedMessages.Empty();
@@ -603,7 +604,7 @@ bool wxApp::DoMessage()
// Process the message
if (!ProcessMessage((WXMSG *)&svCurrentMsg) )
{
::WinDispatchMsg(m_vHab, (PQMSG)&svCurrentMsg);
::WinDispatchMsg(vHabmain, (PQMSG)&svCurrentMsg);
}
}
return TRUE;
@@ -633,7 +634,7 @@ int wxApp::MainLoop()
#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() )
{
}
@@ -678,7 +679,7 @@ void wxApp::ExitMainLoop()
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()

View File

@@ -95,18 +95,17 @@ bool wxBitmap::CopyFromIconOrCursor(
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);
}
@@ -118,7 +117,7 @@ bool wxBitmap::CopyFromCursor(
if (!rCursor.Ok())
return(FALSE);
return CopyFromIconOrCursor(wxGDIImage)rCursor);
return(CopyFromIconOrCursor(rCursor));
}
bool wxBitmap::CopyFromIcon(
@@ -134,7 +133,7 @@ bool wxBitmap::CopyFromIcon(
refData->m_ok = TRUE;
#endif // WXWIN_COMPATIBILITY_2
return CopyFromIconOrCursor(icon);
return CopyFromIconOrCursor(rIcon);
}
wxBitmap::~wxBitmap()
@@ -157,10 +156,10 @@ 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);
@@ -182,7 +181,7 @@ wxBitmap::wxBitmap(
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");
@@ -193,18 +192,18 @@ wxBitmap::wxBitmap(
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
@@ -214,7 +213,7 @@ wxBitmap::wxBitmap(
{
Init();
F (void)Create( (void *)ppData
(void)Create( (void *)ppData
,wxBITMAP_TYPE_XPM_DATA
,0
,0
@@ -277,15 +276,15 @@ bool wxBitmap::Create(
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;
@@ -305,13 +304,12 @@ bool wxBitmap::Create(
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)
{
@@ -325,13 +323,13 @@ bool wxBitmap::Create(
{
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);
@@ -362,13 +360,13 @@ bool wxBitmap::LoadFile(
,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();
@@ -394,14 +392,14 @@ bool wxBitmap::Create(
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
return(pHandler->Create( this
,pData
,lType
,nWidth
@@ -495,18 +493,19 @@ wxBitmap wxBitmap::GetBitmapForDC(
,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);
}
@@ -567,7 +566,7 @@ bool wxMask::Create(
)
{
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];
@@ -598,7 +597,7 @@ bool wxMask::Create(
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);
@@ -619,16 +618,19 @@ bool wxMask::Create(
}
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
@@ -647,7 +649,7 @@ bool wxMask::Create(
)
{
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];
@@ -678,7 +680,7 @@ bool wxMask::Create(
,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);
@@ -695,7 +697,7 @@ bool wxMask::Create(
vPoint.x = w;
vPoint.y = h;
COLORREF col = ::GpiQueryPel(srcPS, w, h);
COLORREF col = ::GpiQueryPel(srcPS, &vPoint);
if (col == vMaskColour)
{
@@ -747,7 +749,7 @@ bool wxBitmapHandler::Load(
, int nHeight
)
{
wxBitmap* bitmap = wxDynamicCast( pImage
wxBitmap* pBitmap = wxDynamicCast( pImage
,wxBitmap
);
@@ -795,7 +797,7 @@ bool wxBitmapHandler::LoadFile(
, int WXUNUSED(nDesiredHeight)
)
{
return(FALSE(;
return(FALSE);
}
bool wxBitmapHandler::SaveFile(

View File

@@ -32,7 +32,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
wxCursorRefData::wxCursorRefData(void)
{
m_width = 32; m_height = 32;
m_nWidth = 32;
m_nHeight = 32;
m_hCursor = 0 ;
m_destroyCursor = FALSE;
}
@@ -59,9 +60,9 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
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);

View File

@@ -44,7 +44,7 @@
void wxIconRefData::Free()
{
if (m_hIcon)
::DestroyIcon((HICON) m_hIcon);
::WinFreeFileIcon((HPOINTER)m_hIcon);
}
// ----------------------------------------------------------------------------
@@ -88,7 +88,7 @@ bool wxIcon::LoadFile(
, int nDesiredHeight
)
{
wxGDIImageHandler* pHandler = FindHandler(type);
wxGDIImageHandler* pHandler = FindHandler(lType);
UnRef();
m_refData = new wxIconRefData;

View File

@@ -56,8 +56,7 @@ extern "C" void png_write_init PNGARG((png_structp png_ptr));
#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");

View File

@@ -47,22 +47,23 @@ bool wxStaticBitmap::Create(
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;
@@ -70,9 +71,9 @@ bool wxStaticBitmap::Create(
// 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
@@ -97,7 +98,7 @@ bool wxStaticBitmap::Create(
bool wxStaticBitmap::ImageIsOk() const
{
return(m_pImage ** m_pImage->Ok());
return(m_pImage && m_pImage->Ok());
}
void wxStaticBitmap::Free()
@@ -131,7 +132,7 @@ void wxStaticBitmap::SetImage(
int nH;
GetPosition(&nX, &nY);
GetSize(&nW, &nHh);
GetSize(&nW, &nH);
::WinSendMsg( GetHwnd()
,SM_SETHANDLE

View File

@@ -53,21 +53,21 @@ wxMutex* p_wxMainMutex;
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
@@ -232,7 +232,7 @@ wxCondition::~wxCondition()
void wxCondition::Wait()
{
(void)m_internal->Wait(SEM_INFINITE_WAIT);
(void)m_internal->Wait(SEM_INDEFINITE_WAIT);
}
bool wxCondition::Wait(
@@ -356,10 +356,10 @@ ULONG wxThreadInternal::OS2ThreadStart(
// 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();
@@ -368,7 +368,7 @@ ULONG wxThreadInternal::OS2ThreadStart(
if (pThread->IsDetached() && !bWasCancelled)
{
// auto delete
delete thread;
delete pThread;
}
//else: the joinable threads handle will be closed when Wait() is done
return dwRet;
@@ -380,6 +380,7 @@ void wxThreadInternal::SetPriority(
{
// translate wxWindows priority to the PM one
ULONG ulOS2_Priority;
ULONG ulrc;
m_nPriority = nPriority;
@@ -582,7 +583,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
if (IsMain())
{
// set flag for wxIsWaitingForThread()
gs_waitingForThread = TRUE;
gs_bWaitingForThread = TRUE;
#if wxUSE_GUI
wxBeginBusyCursor();
@@ -611,7 +612,7 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
if ( IsMain() )
{
gs_waitingForThread = FALSE;
gs_bWaitingForThread = FALSE;
#if wxUSE_GUI
wxEndBusyCursor();
@@ -626,9 +627,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
delete this;
}
wxASSERT_MSG( (DWORD)rc != STILL_ACTIVE,
wxT("thread must be already terminated.") );
if ( pRc )
*pRc = rc;
@@ -729,10 +727,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule)
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;
@@ -745,14 +743,14 @@ bool wxThreadModule::OnInit()
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);
}
// ----------------------------------------------------------------------------
@@ -766,24 +764,24 @@ void WXDLLEXPORT wxWakeUpMainThread()
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()
@@ -791,17 +789,17 @@ 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
}
@@ -818,12 +816,12 @@ void WXDLLEXPORT wxMutexGuiLeaveOrEnter()
bool WXDLLEXPORT wxGuiOwnedByMainThread()
{
return s_bGuiOwnedByMainThread;
return gs_bGuiOwnedByMainThread;
}
bool WXDLLEXPORT wxIsWaitingForThread()
{
return s_bWaitingForThread;
return gs_bWaitingForThread;
}
#endif