summaryrefslogtreecommitdiffstats
path: root/src/libs/7zip/unix/CPP/Windows/Window.cpp
blob: e92228c7060a2e1d71e11026c8562b66c8c146cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Windows/Window.cpp

#include "StdAfx.h"

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
 
#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif  

#undef _WIN32
 
#ifndef _UNICODE
#include "Common/StringConvert.h"
#endif
#include "Windows/Window.h"

void verify_main_thread(void);

class LockGUI
{
	bool _IsMain;
	public:
		LockGUI() {
			verify_main_thread();
			
			_IsMain = wxThread::IsMain();
			if (!_IsMain) {
				printf("LockGUI-Windows\n");
				abort(); // FIXME wxMutexGuiEnter();
			}
	       	}
		~LockGUI() { if (!_IsMain) wxMutexGuiLeave(); }
};

namespace NWindows {

HWND GetDlgItem(HWND dialogWindow, int ControlID)
{
	LockGUI lock;
	if (dialogWindow) return dialogWindow->FindWindow(ControlID);
	return 0;
}

void MySetWindowText(HWND wnd, LPCWSTR s)
{ 
	if (wnd == 0) return;

	LockGUI lock;

	wxString str = s;
	/*
	int id = wnd->GetId();
	if (  (id != wxID_OK) && (id != wxID_CANCEL) && (id != wxID_HELP) && (id != wxID_YES) && (id != wxID_NO))
	*/
	{
		wnd->SetLabel(str);
	}
}

	bool CWindow::GetText(CSysString &s)
	{
	  	wxString str;
		{
			LockGUI lock;
	  		str = _window->GetLabel();
		}
	  	s = str;
	  	return true;
	}

	bool CWindow::IsEnabled()
	{
		LockGUI lock;
		return _window->IsEnabled();
	}
}

////////////////////////////////// Windows Compatibility
#include <sys/resource.h>

void Sleep(unsigned millisec)
{
	wxMilliSleep(millisec);
}

t_processID GetCurrentProcess(void)  {
	return getpid();
}

void SetPriorityClass(t_processID pid , int priority) {
	setpriority(PRIO_PROCESS,pid,priority);
}