?? fl.cxx
字號:
w->handle(FL_MOVE); } } else { Fl::belowmouse(0); } }}#ifndef WIN32Fl_Widget *fl_selection_requestor; // from Fl_cutpaste.C#endif// This function is called by ~Fl_Widget() and by Fl_Widget::deactivate// and by Fl_Widget::hide(). It indicates that the widget does not want// to receive any more events, and also removes all global variables that// point at the widget.// I changed this from the 1.0.1 behavior, the older version could send// FL_LEAVE or FL_UNFOCUS events to the widget. This appears to not be// desirable behavior and caused flwm to crash.void fl_throw_focus(Fl_Widget *o) { if (o->contains(Fl::pushed())) Fl::pushed_ = 0; if (o->contains(Fl::selection_owner())) Fl::selection_owner_ = 0;#ifndef WIN32 if (o->contains(fl_selection_requestor)) fl_selection_requestor = 0;#endif if (o->contains(Fl::belowmouse())) Fl::belowmouse_ = 0; if (o->contains(Fl::focus())) Fl::focus_ = 0; if (o == fl_xfocus) fl_xfocus = 0; if (o == fl_xmousewin) fl_xmousewin = 0; fl_fix_focus();}////////////////////////////////////////////////////////////////// Call to->handle but first replace the mouse x/y with the correct// values to account for nested X windows. 'window' is the outermost#if 0static int send(int event, Fl_Widget* to, Fl_Window* window) { // Microwindows Hack int ret = to->handle(event); return ret;}#else// window the event was posted to by X:static int send(int event, Fl_Widget* to, Fl_Window* window) { int dx = window->x(); int dy = window->y(); for (const Fl_Widget* w = to; w; w = w->parent()) if (w->type()>=FL_WINDOW) { dx -= w->x(); dy -= w->y(); } int save_x = Fl::e_x; Fl::e_x += dx; int save_y = Fl::e_y; Fl::e_y += dy; int ret = to->handle(event); Fl::e_y = save_y; Fl::e_x = save_x; return ret;}#endifint Fl::handle(int event, Fl_Window* window){ Fl_Widget* w = window; switch (event) { case FL_CLOSE: if (grab() || modal() && window != modal()) return 0; w->do_callback(); return 1; case FL_SHOW: ((Fl_Widget*)w)->show(); return 1; case FL_HIDE: ((Fl_Widget*)w)->hide(); return 1; case FL_PUSH: if (grab()) w = grab(); else if (modal() && w != modal()) return 0; pushed_ = w; if (send(event, w, window)) return 1; // raise windows that are clicked on: window->show(); return 1; case FL_MOVE: case FL_DRAG: fl_xmousewin = window; // this should already be set, but just in case. if (pushed()) { w = pushed(); event = FL_DRAG; } else if (modal() && w != modal()) { w = 0; } if (grab()) w = grab(); break; case FL_RELEASE: { if (pushed()) { w = pushed(); pushed_ = 0; // must be zero before callback is done! } if (grab()) w = grab(); int r = send(event, w, window); fl_fix_focus(); return r;} case FL_UNFOCUS: window = 0; case FL_FOCUS: fl_xfocus = window; e_keysym = 0; // make sure it is not confused with navigation key fl_fix_focus(); return 1; case FL_KEYBOARD: fl_xfocus = window; // this should already be set, but just in case. // Try it as keystroke, sending it to focus and all parents: for (w = grab() ? grab() : focus(); w; w = w->parent()) if (send(FL_KEYBOARD, w, window)) return 1; // recursive call to try shortcut: if (handle(FL_SHORTCUT, window)) return 1; // and then try a shortcut with the case of the text swapped, by // changing the text and falling through to FL_SHORTCUT case: if (!isalpha(event_text()[0])) return 0; *(char*)(event_text()) ^= ('A'^'a'); event = FL_SHORTCUT; case FL_SHORTCUT: if (grab()) {w = grab(); break;} // send it to grab window // Try it as shortcut, sending to mouse widget and all parents: w = belowmouse(); if (!w) {w = modal(); if (!w) w = window;} for (; w; w = w->parent()) if (send(FL_SHORTCUT, w, window)) return 1; // try using add_handle() functions: if (send_handlers(FL_SHORTCUT)) return 1; // make Escape key close windows: if (event_key()==FL_Escape) { w = modal(); if (!w) w = window; w->do_callback(); return 1; } return 0; case FL_ENTER: fl_xmousewin = window; fl_fix_focus(); return 1; case FL_LEAVE: if (window == fl_xmousewin) {fl_xmousewin = 0; fl_fix_focus();} return 1; default: break; } if (w && send(event, w, window)) return 1; return send_handlers(event);}////////////////////////////////////////////////////////////////// hide() destroys the X window, it does not do unmap!void Fl_Window::hide() { clear_visible(); if (!shown()) return; // remove from the list of windows: Fl_X* x = i; Fl_X** pp = &Fl_X::first; for (; *pp != x; pp = &(*pp)->next) if (!*pp) return; *pp = x->next; i = 0; // recursively remove any subwindows: for (Fl_X *w = Fl_X::first; w;) { Fl_Window* W = w->w; if (W->window() == this) { W->hide(); W->set_visible(); w = Fl_X::first; } else w = w->next; } if (this == Fl::modal_) { // we are closing the modal window, find next one: Fl_Window* w; for (w = Fl::first_window(); w; w = Fl::next_window(w)) if (w->modal()) break; Fl::modal_ = w; } // Make sure no events are sent to this window: fl_throw_focus(this); handle(FL_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#else#ifdef NANO_X if (x->region) GrDestroyRegion(x->region);#else if (x->region) XDestroyRegion(x->region);#endif#endif#ifdef NANO_X GrDestroyWindow(x->xid);#else XDestroyWindow(fl_display, x->xid);#endif delete x;}Fl_Window::~Fl_Window() { hide();}// Child windows must respond to FL_SHOW and FL_HIDE by actually// doing unmap operations. Outer windows assumme FL_SHOW & FL_HIDE// are messages from X:int Fl_Window::handle(int event) { if (parent()) switch (event) { case FL_SHOW: if (!shown()) show(); else {#ifdef NANO_X GrMapWindow(fl_xid(this));#else XMapWindow(fl_display, fl_xid(this));#endif } break; case FL_HIDE:#ifdef NANO_X if (shown()) GrUnmapWindow(fl_xid(this));#else if (shown()) XUnmapWindow(fl_display, fl_xid(this));#endif break; } return Fl_Group::handle(event);}////////////////////////////////////////////////////////////////// ~Fl_Widget() calls this: this function must get rid of any// global pointers to the widget. This is also called by hide()// and deactivate().// call this to free a selection (or change the owner):void Fl::selection_owner(Fl_Widget *owner) { if (selection_owner_ && owner != selection_owner_) selection_owner_->handle(FL_SELECTIONCLEAR); if (focus_ && owner != focus_ && focus_ != selection_owner_) focus_->handle(FL_SELECTIONCLEAR); // clear non-X-selection highlight selection_owner_ = owner;}#include <FL/fl_draw.H>void Fl_Widget::redraw() {damage(FL_DAMAGE_ALL);}void Fl_Widget::damage(uchar flags) { if (type() < FL_WINDOW) { // damage only the rectangle covered by a child widget: damage(flags, x(), y(), w(), h()); } else { // damage entire window by deleting the region: Fl_X* i = Fl_X::i((Fl_Window*)this); if (!i) return; // window not mapped, so ignore it if (i->region) {#ifdef NANO_X GrDestroyRegion(i->region);#else XDestroyRegion(i->region);#endif i->region = 0; } damage_ |= flags; Fl::damage(FL_DAMAGE_CHILD); }}void Fl_Widget::damage(uchar flags, int X, int Y, int W, int H) { Fl_Widget* window = this; // mark all parent widgets between this and window with FL_DAMAGE_CHILD: while (window->type() < FL_WINDOW) { window->damage_ |= flags; window = window->parent(); if (!window) return; flags = FL_DAMAGE_CHILD; } Fl_X* i = Fl_X::i((Fl_Window*)window); if (!i) return; // window not mapped, so ignore it if (X<=0 && Y<=0 && W>=window->w() && H>=window->h()) { // if damage covers entire window delete region: window->damage(flags); return; } // clip the damage to the window and quit if none: if (X < 0) {W += X; X = 0;} if (Y < 0) {H += Y; Y = 0;} if (W > window->w()-X) W = window->w()-X; if (H > window->h()-Y) H = window->h()-Y; if (W <= 0 || H <= 0) return; if (window->damage()) { // if we already have damage we must merge with existing region: if (i->region) {#ifndef WIN32#ifdef NANO_X GR_RECT R; R.x = X; R.y = Y; R.width = W; R.height = H; GrUnionRectWithRegion(i->region, &R);#else XRectangle R; R.x = X; R.y = Y; R.width = W; R.height = H; XUnionRectWithRegion(&R, i->region, i->region);#endif#else Region R = XRectangleRegion(X, Y, W, H); CombineRgn(i->region, i->region, R, RGN_OR); XDestroyRegion(R);#endif } window->damage_ |= flags; } else { // create a new region:#ifdef NANO_X if (i->region) GrDestroyRegion(i->region);#else if (i->region) XDestroyRegion(i->region);#endif i->region = XRectangleRegion(X,Y,W,H); window->damage_ = flags; } Fl::damage(FL_DAMAGE_CHILD);}void Fl_Window::flush() { make_current();//if (damage() == FL_DAMAGE_EXPOSE && can_boxcheat(box())) fl_boxcheat = this; fl_clip_region(i->region); i->region = 0; draw();}int fl_old_shortcut(const char* s) { if (!s || !*s) return 0; int n = 0; if (*s == '#') {n |= FL_ALT; s++;} if (*s == '+') {n |= FL_SHIFT; s++;} if (*s == '^') {n |= FL_CTRL; s++;} return n | *s;}//// End of "$Id: Fl.cxx,v 1.1.1.1 2003/08/07 21:18:39 jasonk Exp $".//
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -