// private methods of FFileDialog //---------------------------------------------------------------------- void FFileDialog::init() { static constexpr std::size_t w = 42; static constexpr std::size_t h = 15; int x, y; setGeometry(FPoint(1, 1), FSize(w, h), false); auto parent_widget = getParentWidget(); if ( parent_widget ) { x = 1 + int((parent_widget->getWidth() - w) / 2); y = 1 + int((parent_widget->getHeight() - h) / 3); } else x = y = 1; if ( dlg_type == FFileDialog::Save ) FDialog::setText("Save file"); else FDialog::setText("Open file"); widgetSettings (FPoint(x, y)); // Create widgets initCallbacks(); setModal(); readDir(); }
static void FilePosInit( a_window *wnd ) { file_window *file = WndFile( wnd ); if( file->viewhndl == NULL ) { file->size = 0; } else { file->size = FSize( file->viewhndl ); } WndSetThumbPercent( wnd, 0 ); }
void WriteLog(PCHAR buf, WORD len) { WORD F; if (LogPath != NULL) { F = FOpen((PCHARFAR)&LogPath); if (F == 0xffff) { F = FCreate((PCHARFAR)&LogPath); } FSize(F); FWrite(F, (PCHARFAR)buf, len); FClose(F); } }
//---------------------------------------------------------------------- inline void FFileDialog::widgetSettings (const FPoint& pos) { filename.setLabelText ("File&name"); filename.setText (filter_pattern); filename.setGeometry (FPoint(11, 1), FSize(28, 1)); filename.setFocus(); filebrowser.setGeometry (FPoint(2, 3), FSize(38, 6)); printPath (directory); hidden.setText ("&hidden files"); hidden.setGeometry (FPoint(2, 10), FSize(16, 1)); cancel.setText ("&Cancel"); cancel.setGeometry(FPoint(19, 10), FSize(9, 1)); if ( dlg_type == FFileDialog::Save ) open.setText ("&Save"); else open.setText ("&Open"); open.setGeometry(FPoint(30, 10), FSize(9, 1)); setGeometry (pos, getSize()); }
CFile *FOpen(U8 *filename,U8 *flags,I64 cnt=0) { //allows flags "r","w","w+". Include a "c" for contiguous. CFile *f=CAlloc(sizeof(CFile)); CFileAccess *fa; U8 *full_name; Bool contiguous=StrOcc(flags,'c'); f->cluster=INVALID_CLUSTER; f->fblk_num=0; if (cnt>0) f->max_blk=cnt-1; else f->max_blk=MAX_I64; f->file_cluster_num=INVALID_CLUSTER; full_name=FileNameAbs(filename); f->p=Drv2Prt(*full_name); if (f->p->type==PT_REDSEA) contiguous=TRUE; if (contiguous) { f->flags|=FF_CONTIGUOUS; if (f->p->type!=PT_REDSEA) { if (!(FileAttr(filename) & _ATTR_CONTIGUOUS)) throw(EXCEPT_FILE,2); } } f->cluster_buf=CAlloc(f->p->spc<<BLK_SIZE_BITS); if (StrOcc(flags,'w')) { f->flags=f->flags|FF_WRITE|FF_NEEDS_WRITE; if (StrOcc(flags,'+')) { if (FileFind(full_name,&f->de,FUF_JUST_FILES)) { Free(full_name); if (contiguous) f->max_blk=(FSize(f)+BLK_SIZE-1)>>BLK_SIZE_BITS-1; return f; } } else