/* * lookup a file, create one if not found. if there are no * free files, free the last oldest clean one. */ static File* fileget(Node *node) { File *fp; File *oldest; fp = node->fp; if(fp) return fp; oldest = 0; for(fp = files; fp < &files[Nfile]; fp++){ if(fp->inuse == 0) break; if(fp->dirty == 0 && (oldest == 0 || oldest->atime > fp->atime)) oldest = fp; } if(fp == &files[Nfile]){ uncache(oldest->node); fp = oldest; } node->fp = fp; fp->node = node; fp->atime = now++; fp->inuse = 1; fp->fd = -1; if(fp->mem){ free(fp->mem); fp->mem = nil; } return fp; }
void Fl_Rotated_Text::set(const char *text, Fl_Font font, int size, uchar align, int rotation){ uncache(); if(alloc_array) delete[] ar2; ar2 = 0; array = 0; alloc_array = 0; delete[] text_; text_=0; font_ = font; size_ = size; align_ = align; if(!text || !(*text)){ w(0); h(0); return; } text_ = new char[strlen(text) + 1]; strcpy(text_, text); if(rotation >9) rot_ = (uchar)(((rotation+45)/90) % 4); else rot_ = (uchar) (rotation & 3); int w_ = 0; int h_ = 0; int old_font = fl_font(); int old_size = fl_size(); fl_font(font,size); fl_measure(text_,w_,h_,0); // assure that w() and h() are always available fl_font(old_font,old_size); h_ += fl_height()/2; if(rot_ & 1){ w(h_); h(w_); }else{ w(w_); h(h_); } };
//---------------------------------------------------------------- // Text::TPrivate::~TPrivate // Text::TPrivate::~TPrivate() { uncache(); }