diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl.cxx | 17 | ||||
| -rw-r--r-- | src/Fl_Menu.cxx | 13 | ||||
| -rw-r--r-- | src/Fl_win32.cxx | 101 | ||||
| -rw-r--r-- | src/Fl_x.cxx | 39 | ||||
| -rw-r--r-- | src/fl_cursor.cxx | 4 | ||||
| -rw-r--r-- | src/fl_draw.cxx | 11 | ||||
| -rw-r--r-- | src/fl_file_chooser.cxx | 16 |
7 files changed, 95 insertions, 106 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx index 25923607e..a0755b6eb 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -122,7 +122,7 @@ void Fl::flush() { if (damage()) { damage_ = 0; for (Fl_X* x = Fl_X::first; x; x = x->next) { - if (x->w->damage() && x->w->visible()) { + if (!x->wait_for_expose && x->w->damage() && x->w->visible()) { x->flush(); x->w->clear_damage(); } @@ -415,10 +415,10 @@ int Fl::handle(int event, Fl_Window* window) fl_xmousewin = window; fl_fix_focus(); } if (Fl::pushed()) { + w = Fl::pushed(); + event = FL_DRAG; Fl::e_x += mouse_dx; Fl::e_y += mouse_dy; - event = FL_DRAG; - w = Fl::pushed(); } else if (Fl::grab()) w = Fl::grab(); else if (Fl::modal() && w != Fl::modal()) @@ -426,11 +426,11 @@ int Fl::handle(int event, Fl_Window* window) break; case FL_RELEASE: { - if (Fl::pushed_) { + if (Fl::pushed()) { + w = Fl::pushed(); + Fl::pushed_ = 0; // must be zero before callback is done! Fl::e_x += mouse_dx; Fl::e_y += mouse_dy; - w = Fl::pushed_; - Fl::pushed_ = 0; // must be zero before callback is done! } int r = w->handle(event); fl_fix_focus(); @@ -527,8 +527,9 @@ void Fl_Window::hide() { #ifdef WIN32 if (x->private_dc) ReleaseDC(x->xid,x->private_dc); if (x->xid == fl_window) fl_GetDC(0); // releases dc belonging to window -#endif +#else if (x->region) XDestroyRegion(x->region); +#endif XDestroyWindow(fl_display, x->xid); delete x; @@ -584,5 +585,5 @@ void fl_throw_focus(Fl_Widget *o) { } // -// End of "$Id: Fl.cxx,v 1.4 1998/10/19 20:45:34 mike Exp $". +// End of "$Id: Fl.cxx,v 1.5 1998/10/19 21:00:20 mike Exp $". // diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index afee88cf0..36cc84557 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -147,7 +147,7 @@ void Fl_Menu_Item::draw(int x, int y, int w, int h, const Fl_Menu_* m, b = m ? m->box() : FL_UP_BOX; } else { r = (Fl_Color)(FL_COLOR_CUBE-1); // white - b = FL_THIN_UP_BOX; + //b = FL_THIN_UP_BOX; } } else { l.color = contrast((Fl_Color)labelcolor_, r); @@ -359,7 +359,7 @@ int menuwindow::find_selected(int mx, int my) { if (!menu || !menu->text) return -1; mx -= x(); my -= y(); - if (my <= 0 || my >= h()) return -1; + if (my < 0 || my >= h()) return -1; if (!itemheight) { // menubar int x = BW; int i = 0; const Fl_Menu_Item* m = menu; @@ -370,11 +370,10 @@ int menuwindow::find_selected(int mx, int my) { } return i; } - if (mx <= 0 || mx >= w()) return -1; - my -= h()-(BOTTOM + numitems*itemheight - LEADING + 2); - if (my <= 0) return -1; - int i = my/itemheight; + if (mx < 0 || mx >= w()) return -1; + int i = (my-(TOP-1))/itemheight; if (i>=numitems) i = numitems-1; + else if (i < 0) i = 0; return i; } @@ -712,5 +711,5 @@ const Fl_Menu_Item* Fl_Menu_Item::test_shortcut() const { } // -// End of "$Id: Fl_Menu.cxx,v 1.3 1998/10/19 20:45:51 mike Exp $". +// End of "$Id: Fl_Menu.cxx,v 1.4 1998/10/19 21:00:20 mike Exp $". // diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx index 5d9febede..604520031 100644 --- a/src/Fl_win32.cxx +++ b/src/Fl_win32.cxx @@ -164,29 +164,29 @@ static int mouse_event(Fl_Window *window, int what, int button, // convert a MSWindows VK_x to an Fltk (X) Keysym: // See also the inverse converter in Fl_get_key_win32.C // This table is in numeric order by VK: -static const struct {unsigned short vk, fltk;} vktab[] = { +static const struct {unsigned short vk, fltk, extended;} vktab[] = { {VK_BACK, FL_BackSpace}, {VK_TAB, FL_Tab}, {VK_CLEAR, FL_KP+'5'}, - {VK_RETURN, FL_Enter}, - {VK_SHIFT, FL_Shift_L}, - {VK_CONTROL, FL_Control_L}, - {VK_MENU, FL_Alt_L}, + {VK_RETURN, FL_Enter, FL_KP_Enter}, + {VK_SHIFT, FL_Shift_L, FL_Shift_R}, + {VK_CONTROL, FL_Control_L, FL_Control_R}, + {VK_MENU, FL_Alt_L, FL_Alt_R}, {VK_PAUSE, FL_Pause}, {VK_CAPITAL, FL_Caps_Lock}, {VK_ESCAPE, FL_Escape}, {VK_SPACE, ' '}, - {VK_PRIOR, FL_KP+'9'}, - {VK_NEXT, FL_KP+'3'}, - {VK_END, FL_KP+'1'}, - {VK_HOME, FL_KP+'7'}, - {VK_LEFT, FL_KP+'4'}, - {VK_UP, FL_KP+'8'}, - {VK_RIGHT, FL_KP+'6'}, - {VK_DOWN, FL_KP+'2'}, + {VK_PRIOR, FL_KP+'9', FL_Page_Up}, + {VK_NEXT, FL_KP+'3', FL_Page_Down}, + {VK_END, FL_KP+'1', FL_End}, + {VK_HOME, FL_KP+'7', FL_Home}, + {VK_LEFT, FL_KP+'4', FL_Left}, + {VK_UP, FL_KP+'8', FL_Up}, + {VK_RIGHT, FL_KP+'6', FL_Right}, + {VK_DOWN, FL_KP+'2', FL_Down}, {VK_SNAPSHOT, FL_Print}, // does not work on NT - {VK_INSERT, FL_KP+'0'}, - {VK_DELETE, FL_KP+'.'}, + {VK_INSERT, FL_KP+'0', FL_Insert}, + {VK_DELETE, FL_KP+'.', FL_Delete}, {VK_LWIN, FL_Meta_L}, {VK_RWIN, FL_Meta_R}, {VK_APPS, FL_Menu}, @@ -211,35 +211,19 @@ static const struct {unsigned short vk, fltk;} vktab[] = { }; static int ms2fltk(int vk, int extended) { static unsigned short vklut[256]; + static unsigned short extendedlut[256]; if (!vklut[1]) { // init the table unsigned int i; for (i = 0; i < 256; i++) vklut[i] = tolower(i); for (i=VK_F1; i<=VK_F16; i++) vklut[i] = i+(FL_F-(VK_F1-1)); for (i=VK_NUMPAD0; i<=VK_NUMPAD9; i++) vklut[i] = i+(FL_KP+'0'-VK_NUMPAD0); - for (i = 0; i < sizeof(vktab)/sizeof(*vktab); i++) + for (i = 0; i < sizeof(vktab)/sizeof(*vktab); i++) { vklut[vktab[i].vk] = vktab[i].fltk; + extendedlut[vktab[i].vk] = vktab[i].extended; } - if (extended) - { - //this is lame, have to check the vk code to make it faster - switch (vk) { - case VK_INSERT: return FL_Insert; - case VK_DELETE: return FL_Delete; - case VK_END: return FL_End; - case VK_DOWN: return FL_Down; - case VK_NEXT: return FL_Page_Down; - case VK_LEFT: return FL_Left; - case VK_RIGHT: return FL_Right; - case VK_HOME: return FL_Home; - case VK_UP: return FL_Up; - case VK_PRIOR: return FL_Page_Up; - case VK_SHIFT: return FL_Shift_R; - case VK_CONTROL : return FL_Control_R; - case VK_MENU: return FL_Alt_R; - case VK_RETURN: return FL_KP_Enter; + for (i = 0; i < 256; i++) if (!extendedlut[i]) extendedlut[i] = vklut[i]; } - } - return vklut[vk]; + return extended ? extendedlut[vk] : vklut[vk]; } #if USE_COLORMAP @@ -275,6 +259,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar // "exposure alert", like the X event. Fl_X *i = Fl_X::i(window); + i->wait_for_expose = 0; + // if region == entire window we should delete i->region, else if (window->damage()) { if (i->region) { InvalidateRgn(hWnd,i->region,FALSE); @@ -336,19 +322,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar goto STUPID_MICROSOFT; } // otherwise use it as a 0-character key... - // otherwise use it as a 0-character key... case WM_DEADCHAR: case WM_SYSDEADCHAR: - buffer[0] = 0; - Fl::e_text = buffer; - Fl::e_length = 0; - goto GETSTATE; case WM_CHAR: case WM_SYSCHAR: - buffer[0] = char(wParam); - Fl::e_text = buffer; - Fl::e_length = 1; - GETSTATE: {ulong state = Fl::e_state & 0xff000000; // keep the mouse button state // if GetKeyState is expensive we might want to comment some of these out: if (GetKeyState(VK_SHIFT)&~1) state |= FL_SHIFT; @@ -363,6 +340,17 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar if (GetKeyState(VK_SCROLL)) state |= FL_SCROLL_LOCK; Fl::e_state = state;} if (lParam & (1<<31)) goto DEFAULT; // ignore up events after fixing shift + if (uMsg == WM_CHAR || uMsg == WM_SYSCHAR) { + buffer[0] = char(wParam); + Fl::e_length = 1; + } else if (Fl::e_keysym >= FL_KP && Fl::e_keysym <= FL_KP_Last) { + buffer[0] = Fl::e_keysym-FL_KP; + Fl::e_length = 1; + } else { + buffer[0] = 0; + Fl::e_length = 0; + } + Fl::e_text = buffer; // for (int i = lParam&0xff; i--;) while (window->parent()) window = window->window(); if (Fl::handle(FL_KEYBOARD,window)) return 0; @@ -426,14 +414,17 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar //////////////////////////////////////////////////////////////// void Fl_Window::resize(int X,int Y,int W,int H) { - int resize_from_program = 1; - if (this == resize_bug_fix) { - resize_from_program = 0; - resize_bug_fix = 0; - } - if (X==x() && Y==y() && W==w() && H==h()) return; + int is_a_resize = (W != w() || H != h()); + int resize_from_program = (this != resize_bug_fix); + if (!resize_from_program) resize_bug_fix = 0; if (X != x() || Y != y()) set_flag(FL_FORCE_POSITION); - if (W != w() || H != h()) Fl_Group::resize(X,Y,W,H); else {x(X); y(Y);} + else if (!is_a_resize) return; + if (is_a_resize) { + Fl_Group::resize(X,Y,W,H); + if (shown()) {redraw(); i->wait_for_expose = 1;} + } else { + x(X); y(Y); + } if (resize_from_program && shown()) { if (border() && !parent()) { X -= GetSystemMetrics(SM_CXFRAME); @@ -442,7 +433,6 @@ void Fl_Window::resize(int X,int Y,int W,int H) { H += 2*GetSystemMetrics(SM_CYFRAME)+GetSystemMetrics(SM_CYCAPTION); } MoveWindow(i->xid, X, Y, W, H, TRUE); - //if (!parent()) redraw(); } } @@ -455,7 +445,6 @@ int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR Fl_X* Fl_X::make(Fl_Window* w) { Fl_Group::current(0); // get rid of very common user bug: forgot end() - w->clear_damage(); // wait for expose events static char* class_name; if (!class_name) { // create a single WNDCLASS used for everything: @@ -555,8 +544,10 @@ Fl_X* Fl_X::make(Fl_Window* w) { // use w->xclass() to set the icon... + x->wait_for_expose = 1; w->set_visible(); w->handle(FL_SHOW); // get child windows to appear + w->redraw(); // force draw to happen // If we've captured the mouse, we dont want do activate any // other windows from the code, or we loose the capture. ShowWindow(x->xid, fl_show_iconic ? SW_SHOWMINNOACTIVE : @@ -737,5 +728,5 @@ void Fl_Window::flush() { } // -// End of "$Id: Fl_win32.cxx,v 1.8 1998/10/19 20:46:19 mike Exp $". +// End of "$Id: Fl_win32.cxx,v 1.9 1998/10/19 21:00:21 mike Exp $". // diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 29599e1d6..030e0a2b2 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -340,11 +340,12 @@ int fl_handle(const XEvent& xevent) break; case Expose: - case GraphicsExpose: -#if 1 // try to keep windows on top even if WM_TRANSIENT_FOR does not work: + Fl_X::i(window)->wait_for_expose = 0; + // try to keep windows on top even if WM_TRANSIENT_FOR does not work: if (Fl::first_window()->non_modal() && window != Fl::first_window()) Fl::first_window()->show(); -#endif + + case GraphicsExpose: window->damage(FL_DAMAGE_EXPOSE, xevent.xexpose.x, xevent.xexpose.y, xevent.xexpose.width, xevent.xexpose.height); return 1; @@ -413,8 +414,8 @@ int fl_handle(const XEvent& xevent) // ascii characters. This won't work on non-PC layout keyboards, // but are there any of those left?? buffer[0] = "7486293150."[keysym-0xff95]; - len = 1; keysym = FL_KP+buffer[0]; + len = 1; } buffer[len] = 0; Fl::e_keysym = int(keysym); @@ -466,23 +467,23 @@ int fl_handle(const XEvent& xevent) //////////////////////////////////////////////////////////////// void Fl_Window::resize(int X,int Y,int W,int H) { - if (resize_bug_fix == this) - resize_bug_fix = 0; - else if (shown()) { - // tell X window manager to change window size: - if (!(flags()&FL_FORCE_POSITION) && X == x() && Y == y()) - XResizeWindow(fl_display, i->xid, W>0 ? W : 1, H>0 ? H : 1); - else if (W != w() || H != h()) + int is_a_resize = (W != w() || H != h()); + int resize_from_program = (this != resize_bug_fix); + if (!resize_from_program) resize_bug_fix = 0; + if (X != x() || Y != y()) set_flag(FL_FORCE_POSITION); + else if (!is_a_resize) return; + if (is_a_resize) { + Fl_Group::resize(X,Y,W,H); + if (shown()) {redraw(); i->wait_for_expose = 1;} + } else { + x(X); y(Y); + } + if (resize_from_program && shown()) { + if (is_a_resize) XMoveResizeWindow(fl_display, i->xid, X, Y, W>0 ? W : 1, H>0 ? H : 1); else XMoveWindow(fl_display, i->xid, X, Y); } - if (X != x() || Y != y()) set_flag(FL_FORCE_POSITION); - if (W != w() || H != h()) Fl_Group::resize(X,Y,W,H); else {x(X); y(Y);} - // Notice that this does *not* set any redraw bits. I assumme - // I will receive damage for the whole window from X. I think - // that "ForgetGravity" forces the expose event for the entire - // window, but this may not be true on some implementations. } //////////////////////////////////////////////////////////////// @@ -497,9 +498,11 @@ Fl_X* Fl_X::set_xid(Fl_Window* w, Window xid) { x->setwindow(w); x->next = Fl_X::first; x->region = 0; + x->wait_for_expose = 1; Fl_X::first = x; w->set_visible(); w->handle(FL_SHOW); // get child windows to appear + w->redraw(); fl_fix_focus(); // if this is modal we must fix focus now return x; } @@ -804,5 +807,5 @@ void Fl_Window::flush() { #endif // -// End of "$Id: Fl_x.cxx,v 1.5 1998/10/19 20:46:20 mike Exp $". +// End of "$Id: Fl_x.cxx,v 1.6 1998/10/19 21:00:22 mike Exp $". // diff --git a/src/fl_cursor.cxx b/src/fl_cursor.cxx index 01ca6a8ae..6254cc919 100644 --- a/src/fl_cursor.cxx +++ b/src/fl_cursor.cxx @@ -84,7 +84,7 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color, Fl_Color) { #define CURSORSIZE 16 #define HOTXY 7 -static struct TableEntry { +struct TableEntry { uchar bits[CURSORSIZE*CURSORSIZE/8]; uchar mask[CURSORSIZE*CURSORSIZE/8]; Cursor cursor; @@ -167,5 +167,5 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) { #endif // -// End of "$Id: fl_cursor.cxx,v 1.3 1998/10/19 20:46:31 mike Exp $". +// End of "$Id: fl_cursor.cxx,v 1.4 1998/10/19 21:00:22 mike Exp $". // diff --git a/src/fl_draw.cxx b/src/fl_draw.cxx index 5215b5f17..1693adc79 100644 --- a/src/fl_draw.cxx +++ b/src/fl_draw.cxx @@ -117,12 +117,6 @@ void fl_draw( Fl_Align align, void (*callthis)(const char*,int,int,int) ) { - if (!str || !*str) return; - - // clip: - if (w && h && !fl_not_clipped(x, y, w, h)) return; - if (align & FL_ALIGN_CLIP) fl_clip(x, y, w, h); - const char* p; const char* e; char buf[MAXBUF]; @@ -171,6 +165,9 @@ void fl_draw( const char* str, // the (multi-line) string int x, int y, int w, int h, // bounding box Fl_Align align) { + if (!str || !*str) return; + if (w && h && !fl_not_clipped(x, y, w, h)) return; + if (align & FL_ALIGN_CLIP) fl_clip(x, y, w, h); fl_draw(str, x, y, w, h, align, fl_draw); } @@ -196,5 +193,5 @@ void fl_measure(const char* str, int& w, int& h) { } // -// End of "$Id: fl_draw.cxx,v 1.2 1998/10/19 20:46:33 mike Exp $". +// End of "$Id: fl_draw.cxx,v 1.3 1998/10/19 21:00:23 mike Exp $". // diff --git a/src/fl_file_chooser.cxx b/src/fl_file_chooser.cxx index 70760e07a..005160c32 100644 --- a/src/fl_file_chooser.cxx +++ b/src/fl_file_chooser.cxx @@ -336,18 +336,16 @@ void FCB::set(const char* buf) { } void FCB::draw() { - if (message) { + if (!message) { + Fl_Browser_::draw(); + if (full_height() > 0) return; + message = "No matching files"; + } Fl_Boxtype b = box(); if (!b) b = Fl_Input_::default_box(); draw_box(b,color()); fl_color(FL_INACTIVE_COLOR); + fl_font(textfont(), textsize(), default_font(), default_size()); fl_draw(message, x()+7, y()+3, w(), h()-3, FL_ALIGN_TOP_LEFT); - } else { - Fl_Browser_::draw(); - if (full_height()<=0) { - message = "No matching files"; - draw(); - } - } } void FCB::clear_prev() { @@ -613,5 +611,5 @@ char* fl_file_chooser(const char* message, const char* pat, const char* fname) } // -// End of "$Id: fl_file_chooser.cxx,v 1.2 1998/10/19 20:46:37 mike Exp $". +// End of "$Id: fl_file_chooser.cxx,v 1.3 1998/10/19 21:00:24 mike Exp $". // |
