muhkuh_dirlistbox::muhkuh_dirlistbox(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const wxArrayString& astrPaths, const wxString &strAppPath, long style) : wxVListBox(parent, id, pos, size, style) , m_astrPaths(astrPaths) , m_strApplicationPath(strAppPath) { wxSize tSize; size_t sizCnt; size_t sizMax; wxMemoryDC memoryDC; m_ptTextCtrl = new wxTextCtrl(this, muhkuh_dirlistbox_TextCtrl, wxT(""), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER); m_ptBrowseButton = new wxButton(this, muhkuh_dirlistbox_BrowseButton, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); m_ptTextCtrl->Show(false); m_ptBrowseButton->Show(false); tSize = m_ptTextCtrl->GetEffectiveMinSize(); tDefaultHeight = tSize.GetHeight(); tSize.SetWidth(-1); m_ptBrowseButton->SetMinSize(tSize); tSize = m_ptBrowseButton->GetEffectiveMinSize(); m_iButtonWidth = tSize.GetWidth(); m_ptTextCtrl->Connect(muhkuh_dirlistbox_TextCtrl, wxEVT_KEY_DOWN, wxKeyEventHandler(muhkuh_dirlistbox::OnKeyDown)); // set default config values m_iTextXOffset = 4; m_colTextNormal = *wxBLACK; m_colTextSelected = *wxWHITE; m_fontDirlist = m_ptTextCtrl->GetFont(); // set font for this list SetFont( m_fontDirlist ); // create a paintDC to get the pixel length of the path strings // use this control's font memoryDC.SetFont( m_fontDirlist ); // loop over all strings and get the pixel width sizCnt = 0; sizMax = m_astrPaths.GetCount(); while( sizCnt<sizMax ) { tSize = memoryDC.GetTextExtent( m_astrPaths.Item(sizCnt) ); m_aiPathPixelHeight.Add( tSize.GetHeight() ); m_aiPathPixelWidth.Add( tSize.GetWidth() ); ++sizCnt; } SetLineCount(sizMax); // get the size of "..." tSize = memoryDC.GetTextExtent( wxT("...") ); m_iDotDotDotWidth = tSize.GetWidth(); // no active item sizActiveItem = -1; }
void wxVListBox::SetItemCount(size_t count) { if ( m_selStore ) { // tell the selection store that our number of items has changed m_selStore->SetItemCount(count); } SetLineCount(count); }
// initialise control from current min/max values void wxSymbolListCtrl::SetupCtrl(bool scrollToSelection) { wxSize sz = GetClientSize(); m_symbolsPerLine = sz.x/(m_cellSize.x+m_ptMargins.x); int noLines = (1 + SymbolValueToLineNumber(m_maxSymbolValue)); SetLineCount(noLines); Refresh(); if (scrollToSelection && m_current != wxNOT_FOUND && m_current >= m_minSymbolValue && m_current <= m_maxSymbolValue) { ScrollToLine(SymbolValueToLineNumber(m_current)); } }
void muhkuh_dirlistbox::Delete(unsigned int n) { size_t sizLineCount; // get old line count sizLineCount = m_astrPaths.GetCount(); if( n<sizLineCount ) { // remove the item from the path array m_astrPaths.RemoveAt(n); m_aiPathPixelHeight.RemoveAt(n); m_aiPathPixelWidth.RemoveAt(n); // set new linecount --sizLineCount; SetLineCount(sizLineCount); // Redraw all modified lines RefreshAll(); } }
size_t muhkuh_dirlistbox::Append(const wxString& item) { wxSize tSize; size_t sizLineCount; wxMemoryDC memoryDC; // create a paintDC to get the pixel length of the path strings // use this control's font memoryDC.SetFont( m_fontDirlist ); // get the string's pixel size tSize = memoryDC.GetTextExtent(item); // append the new item to the path array m_astrPaths.Add(item); m_aiPathPixelHeight.Add( tSize.GetHeight() ); m_aiPathPixelWidth.Add( tSize.GetWidth() ); // set the new linecount sizLineCount = m_astrPaths.GetCount(); SetLineCount(sizLineCount); return sizLineCount-1; }
bool BatchStar( Environment *theEnv, const char *fileName) { int inchar; bool done = false; FILE *theFile; char *theString = NULL; size_t position = 0; size_t maxChars = 0; #if (! RUN_TIME) && (! BLOAD_ONLY) char *oldParsingFileName; long oldLineCountValue; #endif /*======================*/ /* Open the batch file. */ /*======================*/ theFile = GenOpen(theEnv,fileName,"r"); if (theFile == NULL) { OpenErrorMessage(theEnv,"batch",fileName); return false; } /*======================================*/ /* Setup for capturing errors/warnings. */ /*======================================*/ #if (! RUN_TIME) && (! BLOAD_ONLY) oldParsingFileName = CopyString(theEnv,GetParsingFileName(theEnv)); SetParsingFileName(theEnv,fileName); CreateErrorCaptureRouter(theEnv); oldLineCountValue = SetLineCount(theEnv,1); #endif /*=====================================*/ /* If embedded, clear the error flags. */ /*=====================================*/ if (EvaluationData(theEnv)->CurrentExpression == NULL) { ResetErrorFlags(theEnv); } /*=============================================*/ /* Evaluate commands from the file one by one. */ /*=============================================*/ while (! done) { inchar = getc(theFile); if (inchar == EOF) { inchar = '\n'; done = true; } theString = ExpandStringWithChar(theEnv,inchar,theString,&position, &maxChars,maxChars+80); if (CompleteCommand(theString) != 0) { FlushPPBuffer(theEnv); SetPPBufferStatus(theEnv,false); RouteCommand(theEnv,theString,false); FlushPPBuffer(theEnv); SetHaltExecution(theEnv,false); SetEvaluationError(theEnv,false); FlushBindList(theEnv,NULL); genfree(theEnv,theString,maxChars); theString = NULL; maxChars = 0; position = 0; #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); #endif } if ((inchar == '\r') || (inchar == '\n')) { IncrementLineCount(theEnv); } } if (theString != NULL) { genfree(theEnv,theString,maxChars); } /*=======================*/ /* Close the batch file. */ /*=======================*/ GenClose(theEnv,theFile); /*========================================*/ /* Cleanup for capturing errors/warnings. */ /*========================================*/ #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); DeleteErrorCaptureRouter(theEnv); SetLineCount(theEnv,oldLineCountValue); SetParsingFileName(theEnv,oldParsingFileName); DeleteString(theEnv,oldParsingFileName); #endif return true; }
bool RemoveBatch( Environment *theEnv) { struct batchEntry *bptr; bool rv, fileBatch = false; if (FileCommandData(theEnv)->TopOfBatchList == NULL) return false; /*==================================================*/ /* Close the source from which batch input is read. */ /*==================================================*/ if (FileCommandData(theEnv)->TopOfBatchList->batchType == FILE_BATCH) { fileBatch = true; GenClose(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileSource); #if (! RUN_TIME) && (! BLOAD_ONLY) FlushParsingMessages(theEnv); DeleteErrorCaptureRouter(theEnv); #endif } else { CloseStringSource(theEnv,FileCommandData(theEnv)->TopOfBatchList->logicalSource); rm(theEnv,(void *) FileCommandData(theEnv)->TopOfBatchList->theString, strlen(FileCommandData(theEnv)->TopOfBatchList->theString) + 1); } /*=================================*/ /* Remove the entry from the list. */ /*=================================*/ DeleteString(theEnv,(char *) FileCommandData(theEnv)->TopOfBatchList->fileName); bptr = FileCommandData(theEnv)->TopOfBatchList; FileCommandData(theEnv)->TopOfBatchList = FileCommandData(theEnv)->TopOfBatchList->next; DeleteString(theEnv,(char *) bptr->logicalSource); rtn_struct(theEnv,batchEntry,bptr); /*========================================================*/ /* If there are no batch files remaining to be processed, */ /* then free the space used by the batch buffer. */ /*========================================================*/ if (FileCommandData(theEnv)->TopOfBatchList == NULL) { FileCommandData(theEnv)->BottomOfBatchList = NULL; FileCommandData(theEnv)->BatchFileSource = NULL; FileCommandData(theEnv)->BatchLogicalSource = NULL; if (FileCommandData(theEnv)->BatchBuffer != NULL) { rm(theEnv,FileCommandData(theEnv)->BatchBuffer,FileCommandData(theEnv)->BatchMaximumPosition); FileCommandData(theEnv)->BatchBuffer = NULL; } FileCommandData(theEnv)->BatchCurrentPosition = 0; FileCommandData(theEnv)->BatchMaximumPosition = 0; rv = false; #if (! RUN_TIME) && (! BLOAD_ONLY) if (fileBatch) { SetParsingFileName(theEnv,FileCommandData(theEnv)->batchPriorParsingFile); DeleteString(theEnv,FileCommandData(theEnv)->batchPriorParsingFile); FileCommandData(theEnv)->batchPriorParsingFile = NULL; } #endif } /*===========================================*/ /* Otherwise move on to the next batch file. */ /*===========================================*/ else { FileCommandData(theEnv)->BatchType = FileCommandData(theEnv)->TopOfBatchList->batchType; FileCommandData(theEnv)->BatchFileSource = FileCommandData(theEnv)->TopOfBatchList->fileSource; FileCommandData(theEnv)->BatchLogicalSource = FileCommandData(theEnv)->TopOfBatchList->logicalSource; FileCommandData(theEnv)->BatchCurrentPosition = 0; rv = true; #if (! RUN_TIME) && (! BLOAD_ONLY) if (FileCommandData(theEnv)->TopOfBatchList->batchType == FILE_BATCH) { SetParsingFileName(theEnv,FileCommandData(theEnv)->TopOfBatchList->fileName); } SetLineCount(theEnv,FileCommandData(theEnv)->TopOfBatchList->lineNumber); #endif } /*====================================================*/ /* Return true if a batch file if there are remaining */ /* batch files to be processed, otherwise false. */ /*====================================================*/ return(rv); }
bool OpenBatch( Environment *theEnv, const char *fileName, bool placeAtEnd) { FILE *theFile; /*======================*/ /* Open the batch file. */ /*======================*/ theFile = GenOpen(theEnv,fileName,"r"); if (theFile == NULL) { OpenErrorMessage(theEnv,"batch",fileName); return false; } /*============================*/ /* Create the batch router if */ /* it doesn't already exist. */ /*============================*/ if (FileCommandData(theEnv)->TopOfBatchList == NULL) { AddRouter(theEnv,"batch",20,QueryBatchCallback,NULL, ReadBatchCallback,UnreadBatchCallback, ExitBatchCallback,NULL); } /*===============================================================*/ /* If a batch file is already open, save its current line count. */ /*===============================================================*/ if (FileCommandData(theEnv)->TopOfBatchList != NULL) { FileCommandData(theEnv)->TopOfBatchList->lineNumber = GetLineCount(theEnv); } #if (! RUN_TIME) && (! BLOAD_ONLY) /*========================================================================*/ /* If this is the first batch file, remember the prior parsing file name. */ /*========================================================================*/ if (FileCommandData(theEnv)->TopOfBatchList == NULL) { FileCommandData(theEnv)->batchPriorParsingFile = CopyString(theEnv,GetParsingFileName(theEnv)); } /*=======================================================*/ /* Create the error capture router if it does not exist. */ /*=======================================================*/ SetParsingFileName(theEnv,fileName); SetLineCount(theEnv,0); CreateErrorCaptureRouter(theEnv); #endif /*====================================*/ /* Add the newly opened batch file to */ /* the list of batch files opened. */ /*====================================*/ AddBatch(theEnv,placeAtEnd,theFile,NULL,FILE_BATCH,NULL,fileName); /*===================================*/ /* Return true to indicate the batch */ /* file was successfully opened. */ /*===================================*/ return true; }