~ubuntu-branches/ubuntu/precise/p7zip/precise-updates

« back to all changes in this revision

Viewing changes to CPP/Windows/Window.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2009-02-14 20:12:27 UTC
  • mfrom: (1.1.11 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090214201227-go63qxm9ozfdma60
Tags: 4.65~dfsg.1-1
* New upstream release.
* Remove wx2.8 Build-Depends added by mistakes (7zG is not yet
  intended to be built).
* Use dh_clean without -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Windows/Window.cpp
 
2
 
 
3
#include "StdAfx.h"
 
4
 
 
5
// For compilers that support precompilation, includes "wx/wx.h".
 
6
#include "wx/wxprec.h"
 
7
 
 
8
#ifdef __BORLANDC__
 
9
    #pragma hdrstop
 
10
#endif
 
11
 
 
12
// for all others, include the necessary headers (this file is usually all you
 
13
// need because it includes almost all "standard" wxWidgets headers)
 
14
#ifndef WX_PRECOMP
 
15
    #include "wx/wx.h"
 
16
#endif  
 
17
 
 
18
#ifndef _UNICODE
 
19
#include "Common/StringConvert.h"
 
20
#endif
 
21
#include "Windows/Window.h"
 
22
 
 
23
class LockGUI
 
24
{
 
25
        bool _IsMain;
 
26
        public:
 
27
                LockGUI() { 
 
28
                        _IsMain = wxThread::IsMain();
 
29
                        if (!_IsMain) wxMutexGuiEnter();
 
30
                }
 
31
                ~LockGUI() { if (!_IsMain) wxMutexGuiLeave(); }
 
32
};
 
33
 
 
34
namespace NWindows {
 
35
 
 
36
HWND GetDlgItem(HWND dialogWindow, int ControlID)
 
37
{
 
38
        LockGUI lock;
 
39
        if (dialogWindow) return dialogWindow->FindWindow(ControlID);
 
40
        return 0;
 
41
}
 
42
 
 
43
void MySetWindowText(HWND wnd, LPCWSTR s)
 
44
 
45
        if (wnd == 0) return;
 
46
 
 
47
        LockGUI lock;
 
48
 
 
49
        wxString str = s;
 
50
        /*
 
51
        int id = wnd->GetId();
 
52
        if (  (id != wxID_OK) && (id != wxID_CANCEL) && (id != wxID_HELP) && (id != wxID_YES) && (id != wxID_NO))
 
53
        */
 
54
        {
 
55
                wnd->SetLabel(str);
 
56
        }
 
57
}
 
58
 
 
59
        bool CWindow::GetText(CSysString &s)
 
60
        {
 
61
                wxString str;
 
62
                {
 
63
                        LockGUI lock;
 
64
                        str = _window->GetLabel();
 
65
                }
 
66
                s = str;
 
67
                return true;
 
68
        }
 
69
 
 
70
        bool CWindow::IsEnabled()
 
71
        {
 
72
                LockGUI lock;
 
73
                return _window->IsEnabled();
 
74
        }
 
75
}
 
76
 
 
77
////////////////////////////////// Windows Compatibility
 
78
#include <sys/resource.h>
 
79
 
 
80
void Sleep(unsigned millisec)
 
81
{
 
82
        wxMilliSleep(millisec);
 
83
}
 
84
 
 
85
t_processID GetCurrentProcess(void)  {
 
86
        return getpid();
 
87
}
 
88
 
 
89
void SetPriorityClass(t_processID pid , int priority) {
 
90
        setpriority(PRIO_PROCESS,pid,priority);
 
91
}
 
92