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 iv_pixel_to_mswin(x), iv_pixel_to_mswin(y),
125 r.right - r.left, r.bottom - r.top,
TRUE);
130 HWND hwnd = w.msWindow();
132 GetWindowRect(hwnd, &winRect);
133 return iv_mswin_to_pixel(winRect.left);
141 HWND hwnd = w.msWindow();
143 GetWindowRect(hwnd, &winRect);
144 return iv_mswin_to_pixel(winRect.top);
161 DismissableWindow::default_geometry();
163 pplace(iv_pixel_to_mswin(xleft_),
164 display()->pheight() - iv_pixel_to_mswin(xtop_)
192 IOHandler::IOHandler(){}
193 IOHandler::~IOHandler(){}
194 int IOHandler::inputReady(
int){
return 0;}
195 int IOHandler::outputReady(
int){
return 0;}
196 int IOHandler::exceptionRaised(
int){
return 0;}
197 void IOHandler::timerExpired(
long,
long){}
198 void IOHandler::childStatus(pid_t,
int){}
204 static int bind_tid_;
206 extern int (*iv_bind_enqueue_)(
void(*)(
void*),
void* w);
207 extern void iv_bind_call(
void* w,
int type);
208 extern void nrnpy_setwindowtext(
void*);
210 extern void* (*nrnpy_save_thread)();
214 static void (*nrn_gui_exec_)(
void*);
216 static pthread_mutex_t* mut_;
217 static pthread_cond_t* cond_;
219 bool nrn_is_gui_thread() {
220 if (cond_ && GetCurrentThreadId() != bind_tid_) {
226 int iv_bind_enqueue(
void(*
cb)(
void*),
void* w) {
228 if (GetCurrentThreadId() == bind_tid_) {
235 void nrn_gui_exec(
void (*
cb)(
void*),
void* v) {
236 assert(GetCurrentThreadId() != bind_tid_);
238 void* gs = (*nrnpy_save_thread)();
239 pthread_mutex_lock(mut_);
243 pthread_cond_wait(cond_, mut_);
245 pthread_mutex_unlock(mut_);
246 (*nrnpy_restore_thread)(gs);
249 void nrniv_bind_call() {
250 if (!cond_) {
return; }
252 pthread_mutex_lock(mut_);
257 pthread_cond_signal(cond_);
259 pthread_mutex_unlock(mut_);
270 bind_tid_ =
int(*hoc_getarg(1));
272 iv_bind_enqueue_ = iv_bind_enqueue;
273 cond_ =
new pthread_cond_t;
274 mut_ =
new pthread_mutex_t;
275 pthread_cond_init(cond_,
NULL);
276 pthread_mutex_init(mut_,
NULL);
287 static DWORD main_threadid = -1;
288 if (main_threadid == -1) {
289 main_threadid = GetCurrentThreadId();
292 PostThreadMessage(main_threadid, WM_QUIT, 0, 0);
void xmove(int left, int top)
static Cursor * help_cursor_
void pwmimpl_redraw(Window *w)
carbon
int ivoc_list_look(Object *ob, Object *oblook, char *path, int)
int ivoc_vector_size(Object *o)
void(* nrnpy_restore_thread)(void *)
void hoc_class_registration(void)
void xplace(int left, int top)
void ivoc_bring_to_top(Window *w)
void rubber_off(Canvas *)
virtual void default_geometry()
double * ivoc_vector_ptr(Object *o, int index)