1 #include <../../nrnconf.h>
5 #include <IV-Win/MWlib.h>
20 #define DELETE mlhdelete
21 #include <Dispatch/dispatcher.h>
22 #include <InterViews/window.h>
23 #include <IV-Win/window.h>
24 #include <InterViews/display.h>
25 #include <InterViews/cursor.h>
26 #include <IV-Win/canvas.h>
35 #include <condition_variable>
50 int iv_mswin_to_pixel(
int);
51 int iv_pixel_to_mswin(
int);
53 void pwmimpl_redraw(
Window* w) {
54 w->rep()->WMpaint(0, 0);
57 void ivoc_bring_to_top(
Window* w) {
58 BringWindowToTop(w->rep()->msWindow());
61 void* mswin_setclip(
Canvas*
c,
int x0,
int y0,
int x1,
int y1) {
62 HRGN
clip = CreateRectRgn(x0, y0, x1, y1);
63 SelectClipRgn(((MWcanvas*)
c)->hdcOf(),
clip);
67 void mswin_delete_object(
void*
v) {
68 DeleteObject((HRGN)
v);
73 void ivoc_win32_cleanup() {
84 static void hidewindow(
void*
v) {
86 ShowWindow(w, SW_HIDE);
89 static int gui_thread_xmove_x;
90 static int gui_thread_xmove_y;
91 void gui_thread_xmove(
void*
v) {
93 w->
xmove(gui_thread_xmove_x, gui_thread_xmove_y);
100 HWND hwnd = Window::rep()->msWindow();
103 if (!nrn_is_gui_thread()) {
104 nrn_gui_exec(hidewindow, hwnd);
108 ShowWindow(hwnd, SW_HIDE);
114 if (!nrn_is_gui_thread()) {
115 gui_thread_xmove_x = x;
116 gui_thread_xmove_y = y;
117 nrn_gui_exec(gui_thread_xmove,
this);
121 HWND hwnd = Window::rep()->msWindow();
125 GetWindowRect(hwnd, &r);
127 hwnd, iv_pixel_to_mswin(x), iv_pixel_to_mswin(y), r.right - r.left, r.bottom - r.top,
TRUE);
132 HWND hwnd = w.msWindow();
134 GetWindowRect(hwnd, &winRect);
135 return iv_mswin_to_pixel(winRect.left);
143 HWND hwnd = w.msWindow();
145 GetWindowRect(hwnd, &winRect);
146 return iv_mswin_to_pixel(winRect.top);
163 DismissableWindow::default_geometry();
165 pplace(iv_pixel_to_mswin(
xleft_),
166 display()->pheight() - iv_pixel_to_mswin(
xtop_) -
194 IOHandler::IOHandler() {}
195 IOHandler::~IOHandler() {}
196 int IOHandler::inputReady(
int) {
199 int IOHandler::outputReady(
int) {
202 int IOHandler::exceptionRaised(
int) {
205 void IOHandler::timerExpired(
long,
long) {}
206 void IOHandler::childStatus(pid_t,
int) {}
212 static int bind_tid_;
214 extern int (*iv_bind_enqueue_)(void (*)(
void*),
void* w);
215 extern void iv_bind_call(
void* w,
int type);
216 extern void nrnpy_setwindowtext(
void*);
219 static void (*nrn_gui_exec_)(
void*);
222 std::unique_ptr<std::condition_variable> cond_;
226 bool nrn_is_gui_thread() {
227 if (cond_ && GetCurrentThreadId() != bind_tid_) {
233 int iv_bind_enqueue(
void (*cb)(
void*),
void* w) {
235 if (GetCurrentThreadId() == bind_tid_) {
242 void nrn_gui_exec(
void (*cb)(
void*),
void*
v) {
243 assert(GetCurrentThreadId() != bind_tid_);
247 std::unique_lock<std::mutex>
lock{mut_};
250 cond_->wait(
lock, [] {
return !
w_; });
255 void nrniv_bind_call() {
259 std::lock_guard<std::mutex> _{mut_};
279 iv_bind_enqueue_ = iv_bind_enqueue;
280 cond_ = std::make_unique<std::condition_variable>();
291 static DWORD main_threadid = -1;
292 if (main_threadid == -1) {
293 main_threadid = GetCurrentThreadId();
296 PostThreadMessage(main_threadid, WM_QUIT, 0, 0);
static Cursor * help_cursor_
virtual void default_geometry()
void xmove(int left, int top)
void xplace(int left, int top)
void rubber_off(Canvas *)
double * hoc_getarg(int narg)
int ivoc_list_look(Object *ob, Object *oblook, char *path, int)
void hoc_class_registration(void)
double * ivoc_vector_ptr(Object *o, int index)
Object ** new_vect(Vect *v, ssize_t delta, ssize_t start, ssize_t step)
int ivoc_vector_size(Object *o)
impl_ptrs methods
Collection of pointers to functions with python-version-specific implementations.
PyThreadState *(* save_thread)()
void(* restore_thread)(PyThreadState *)