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>
47 int iv_mswin_to_pixel(
int);
48 int iv_pixel_to_mswin(
int);
51 w->rep()->WMpaint(0, 0);
55 BringWindowToTop(w->rep()->msWindow());
58 void* mswin_setclip(
Canvas*
c,
int x0,
int y0,
int x1,
int y1) {
59 HRGN
clip = CreateRectRgn(x0, y0, x1, y1);
60 SelectClipRgn(((MWcanvas*)
c)->hdcOf(),
clip);
64 void mswin_delete_object(
void*
v) {
65 DeleteObject((HRGN)
v);
70 void ivoc_win32_cleanup() {
81 static void hidewindow(
void*
v) {
83 ShowWindow(w, SW_HIDE);
86 static int gui_thread_xmove_x;
87 static int gui_thread_xmove_y;
88 void gui_thread_xmove(
void*
v) {
90 w->
xmove(gui_thread_xmove_x, gui_thread_xmove_y);
97 HWND hwnd = Window::rep()->msWindow();
100 if (!nrn_is_gui_thread()) {
101 nrn_gui_exec(hidewindow, hwnd);
105 ShowWindow(hwnd, SW_HIDE);
111 if (!nrn_is_gui_thread()) {
112 gui_thread_xmove_x = x;
113 gui_thread_xmove_y = y;
114 nrn_gui_exec(gui_thread_xmove,
this);
118 HWND hwnd = Window::rep()->msWindow();
122 GetWindowRect(hwnd, &r);
124 hwnd, iv_pixel_to_mswin(x), iv_pixel_to_mswin(y), r.right - r.left, r.bottom - r.top,
TRUE);
129 HWND hwnd = w.msWindow();
131 GetWindowRect(hwnd, &winRect);
132 return iv_mswin_to_pixel(winRect.left);
140 HWND hwnd = w.msWindow();
142 GetWindowRect(hwnd, &winRect);
143 return iv_mswin_to_pixel(winRect.top);
160 DismissableWindow::default_geometry();
162 pplace(iv_pixel_to_mswin(
xleft_),
191 IOHandler::IOHandler() {}
192 IOHandler::~IOHandler() {}
193 int IOHandler::inputReady(
int) {
196 int IOHandler::outputReady(
int) {
199 int IOHandler::exceptionRaised(
int) {
202 void IOHandler::timerExpired(
long,
long) {}
203 void IOHandler::childStatus(pid_t,
int) {}
209 static int bind_tid_;
211 extern int (*iv_bind_enqueue_)(
void (*)(
void*),
void* w);
212 extern void iv_bind_call(
void* w,
int type);
213 extern void nrnpy_setwindowtext(
void*);
215 extern void* (*nrnpy_save_thread)();
219 static void (*nrn_gui_exec_)(
void*);
221 static pthread_mutex_t* mut_;
222 static pthread_cond_t* cond_;
224 bool nrn_is_gui_thread() {
225 if (cond_ && GetCurrentThreadId() != bind_tid_) {
231 int iv_bind_enqueue(
void (*
cb)(
void*),
void* w) {
233 if (GetCurrentThreadId() == bind_tid_) {
240 void nrn_gui_exec(
void (*
cb)(
void*),
void*
v) {
241 assert(GetCurrentThreadId() != bind_tid_);
243 void* gs = (*nrnpy_save_thread)();
244 pthread_mutex_lock(mut_);
248 pthread_cond_wait(cond_, mut_);
250 pthread_mutex_unlock(mut_);
251 (*nrnpy_restore_thread)(gs);
254 void nrniv_bind_call() {
259 pthread_mutex_lock(mut_);
264 pthread_cond_signal(cond_);
266 pthread_mutex_unlock(mut_);
277 bind_tid_ = int(*hoc_getarg(1));
279 iv_bind_enqueue_ = iv_bind_enqueue;
280 cond_ =
new pthread_cond_t;
281 mut_ =
new pthread_mutex_t;
282 pthread_cond_init(cond_,
NULL);
283 pthread_mutex_init(mut_,
NULL);
294 static DWORD main_threadid = -1;
295 if (main_threadid == -1) {
296 main_threadid = GetCurrentThreadId();
299 PostThreadMessage(main_threadid, WM_QUIT, 0, 0);
static Cursor * help_cursor_
void xmove(int left, int top)
void xplace(int left, int top)
virtual void default_geometry()
void rubber_off(Canvas *)
int ivoc_list_look(Object *ob, Object *oblook, char *path, int)
void hoc_class_registration(void)
void(* nrnpy_restore_thread)(void *)
void pwmimpl_redraw(Window *w)
carbon
void ivoc_bring_to_top(Window *w)
double * ivoc_vector_ptr(Object *o, int index)
int ivoc_vector_size(Object *o)