void QWpsDrawer::WpsInit(QString buffer, bool isFile) { DEBUGF3("QWpsDrawer::WpsInit"); if (!mResolved) if (!tryResolve()) return; if (isFile) { cleanTemp(); DEBUGF1( tr("Loading %1").arg(buffer)); QFile file(buffer); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) mWpsString = file.readAll(); newTempWps(); } else mWpsString = buffer; { QFile tfile(mTmpWpsString+".wps"); if (tfile.open(QIODevice::WriteOnly | QIODevice::Text)) tfile.write(mWpsString.toAscii(),mWpsString.length()); } backdrop.fill(Qt::black); DEBUGF3("clear backdrop"); if (isFile) lib_wps_init(buffer.toAscii(), &api, isFile); else lib_wps_init(QString(mTmpWpsString+".wps").toAscii(), &api, true); pix = new QPixmap(api.getwidth(),api.getheight()); pix->fill(Qt::black); drawBackdrop(); setMinimumWidth(api.getwidth()); setMinimumHeight(api.getheight()); update(); }
FILE * fopen (const char *filename, const char *mode) { #undef fopen FILE *ret = fopen (filename, mode); #if defined (KPSE_COMPAT_API) kpathsea kpse = kpse_def; if (KPATHSEA_DEBUG_P (KPSE_DEBUG_FOPEN)) #if defined(_WIN64) DEBUGF3 ("fopen(%s, %s) => 0x%I64x\n", filename, mode, (unsigned __int64) ret); #else DEBUGF3 ("fopen(%s, %s) => 0x%lx\n", filename, mode, (unsigned long) ret); #endif #endif return ret; }
void QWpsDrawer::paintEvent(QPaintEvent * event) { DEBUGF3("QWpsDrawer::paintEvent()"); if (!mResolved) return; if (pix==NULL) return; QPainter p(this); QRect rect = event->rect(); drawBackdrop(); lib_wps_refresh(); if (showGrid) { QPainter g(pix); viewport_api avp; api.get_current_vp(&avp); g.setPen(Qt::green); for (int i=0;i*avp.fontheight/1.5<avp.width ;i++) { g.drawLine(int(i*avp.fontheight/1.5), 0, int(i*avp.fontheight/1.5), avp.height); } for (int j=0;j*avp.fontheight<avp.height; j++) { g.drawLine(0,j*avp.fontheight,avp.width,j*avp.fontheight); } } p.drawPixmap((rect.width()-pix->width())/2,(rect.height()-pix->height())/2,*pix); }
bool QWpsDrawer::load_wps_backdrop(char* filename) { DEBUGF3("load backdrop: %s", filename); QFile file(filename); QFileInfo info(file); file.copy(mTmpWpsString+"/"+info.fileName()); backdrop.load(filename); return true; }
void QWpsDrawer::drawBackdrop() { DEBUGF3("QWpsDrawer::drawBackdrop()"); if (backdrop.isNull()) return; QPainter b(pix); QImage pink = backdrop.createMaskFromColor(qRgb(255,0,255),Qt::MaskOutColor); backdrop.setAlphaChannel(pink); b.drawImage(0,0,backdrop,0,0,pix->width(),pix->height()); }
fopen P2C(const_string, filename, const_string, mode) { #undef fopen FILE *ret = fopen (filename, mode); if (KPSE_DEBUG_P (KPSE_DEBUG_FOPEN)) DEBUGF3 ("fopen(%s, %s) => 0x%lx\n", filename, mode, (unsigned long) ret); return ret; }
void QWpsDrawer::putsxy(int x, int y, const unsigned char *str) { DEBUGF3("putsxy(int x=%d, int y=%d, *str=%s)",x,y,str); QPainter p(pix); viewport_api avp; api.get_current_vp(&avp); p.setPen(Qt::gray); QFont font("times",avp.fontheight,QFont::Bold); p.setFont(font); p.drawText(x+avp.x,y + avp.fontheight + avp.y,(char*)str); }
void QWpsDrawer::newTempWps() { QTemporaryFile tmpWps; tmpWps.setAutoRemove(false); tmpWps.setFileTemplate(QDir::tempPath()+"/XXXXXXXXXX.wps"); if (tmpWps.open()) { QString tmpDir = tmpWps.fileName().left(tmpWps.fileName().length()-4); if (QDir::temp().mkpath(tmpDir)) { mTmpWpsString = tmpDir; DEBUGF3(QString("Created :"+mTmpWpsString).toAscii()); } } }
int sound_min(int setting) { DEBUGF3("sound_min(int setting=%d)",setting); return -78; //audiohw_settings[setting].minval; }
void sound_set_volume(int value) { DEBUGF3("sound_set_volume(int value=%d)",value); global_settings.volume = value; }
void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw){ DEBUGF3("gui_statusbar_draw"); }
str_list_type * kpathsea_db_search_list (kpathsea kpse, string* names, const_string path_elt, boolean all) { const_string *db_dirs, *orig_dirs; const_string last_slash, name, path; string temp_str = NULL; boolean done; unsigned e; const_string *aliases, *r; int n; str_list_type *ret = NULL; boolean relevant = false; /* If we failed to build the database (or if this is the recursive call to build the db path), quit. */ if (kpse->db.buckets == NULL) return NULL; /* Don't bother doing any lookups if this `path_elt' isn't covered by any of database directories. We do this not so much because the extra couple of hash lookups matter -- they don't -- but rather because we want to return NULL in this case, so path_search can know to do a disk search. */ for (e = 0; !relevant && e < STR_LIST_LENGTH (kpse->db_dir_list); e++) { relevant = elt_in_db (STR_LIST_ELT (kpse->db_dir_list, e), path_elt); } if (!relevant) return NULL; done = false; ret = XTALLOC1 (str_list_type); *ret = str_list_init (); /* Handle each name. */ for (n = 0; !done && names[n]; n++) { name = names[n]; /* Absolute names should have been caught in our caller. */ if (kpathsea_absolute_p(kpse, name, true)) continue; /* When tex-glyph.c calls us looking for, e.g., dpi600/cmr10.pk, we won't find it unless we change NAME to just `cmr10.pk' and append `/dpi600' to PATH_ELT. We are justified in using a literal `/' here, since that's what tex-glyph.c unconditionally uses in DPI_BITMAP_SPEC. But don't do anything if the / begins NAME; that should never happen. */ last_slash = strrchr (name, '/'); if (last_slash && last_slash != name) { unsigned len = last_slash - name + 1; string dir_part = (string)xmalloc (len); strncpy (dir_part, name, len - 1); dir_part[len - 1] = 0; path = temp_str = concat3 (path_elt, "/", dir_part); name = last_slash + 1; free (dir_part); } else { path = path_elt; } /* If we have aliases for this name, use them. */ if (kpse->alias_db.buckets) aliases = hash_lookup (kpse->alias_db, name); else aliases = NULL; if (!aliases) { aliases = XTALLOC1 (const_string); aliases[0] = NULL; } { /* Push aliases up by one and insert the original name at front. */ unsigned i; unsigned len = 1; /* Have NULL element already allocated. */ for (r = aliases; *r; r++) len++; aliases = (const_string *) xrealloc ((void *) aliases, (len + 1) * sizeof(const_string)); for (i = len; i > 0; i--) { aliases[i] = aliases[i - 1]; } aliases[0] = name; } for (r = aliases; !done && *r; r++) { const_string ctry = *r; /* We have an ls-R db. Look up `try'. */ orig_dirs = db_dirs = hash_lookup (kpse->db, ctry); /* For each filename found, see if it matches the path element. For example, if we have .../cx/cmr10.300pk and .../ricoh/cmr10.300pk, and the path looks like .../cx, we don't want the ricoh file. */ while (!done && db_dirs && *db_dirs) { string db_file = concat (*db_dirs, ctry); boolean matched = match (db_file, path); #ifdef KPSE_DEBUG if (KPATHSEA_DEBUG_P (KPSE_DEBUG_SEARCH)) DEBUGF3 ("db:match(%s,%s) = %d\n", db_file, path, matched); #endif /* We got a hit in the database. Now see if the file actually exists, possibly under an alias. */ if (matched) { string found = NULL; if (kpathsea_readable_file (kpse, db_file)) { found = db_file; } else { const_string *a; free (db_file); /* `db_file' wasn't on disk. */ /* The hit in the DB doesn't exist in disk. Now try all its aliases. For example, suppose we have a hierarchy on CD, thus `mf.bas', but ls-R contains `mf.base'. Find it anyway. Could probably work around this with aliases, but this is pretty easy and shouldn't hurt. The upshot is that if one of the aliases actually exists, we use that. */ for (a = aliases + 1; *a && !found; a++) { string atry = concat (*db_dirs, *a); if (kpathsea_readable_file (kpse, atry)) found = atry; else free (atry); } } /* If we have a real file, add it to the list, maybe done. */ if (found) { str_list_add (ret, found); if (!all && found) done = true; } } else { /* no match in the db */ free (db_file); } /* On to the next directory, if any. */ db_dirs++; } /* This is just the space for the pointers, not the strings. */ if (orig_dirs && *orig_dirs) free (orig_dirs); } free ((void *) aliases); if (temp_str) free (temp_str); } return ret; }