void CUITalkWnd::SendMessage(CUIWindow* pWnd, s16 msg, void* pData) { if(pWnd == UITalkDialogWnd && msg == TALK_DIALOG_TRADE_BUTTON_CLICKED) { SwitchToTrade(); } else if(pWnd == UITalkDialogWnd && msg == TALK_DIALOG_UPGRADE_BUTTON_CLICKED) { SwitchToUpgrade(); } else if(pWnd == UITalkDialogWnd && msg == TALK_DIALOG_QUESTION_CLICKED) { AskQuestion(); } inherited::SendMessage(pWnd, msg, pData); }
BOOL ColourGallery::PrepareToDelete(void) { SequenceItem *Ptr = FindFirstSelected(); DWORD ItemsInUse = 0; DWORD TotalItems = 0; // Determine how many items are selected, and how many of these are in use while (Ptr != NULL) { if ( ((IndexedColour *)FindRealItem(Ptr))->IsInUse() ) ItemsInUse++; TotalItems++; Ptr = FindNextSelected(Ptr); } // If some are in use, determine if the user really wants to delete them INT32 ButtonPressed = 2; if (ItemsInUse != 0) { ButtonPressed = AskQuestion(_R(IDS_COLGAL_COLINUSE), _R(IDS_COLGAL_KILL), _R(IDS_COLGAL_NOKILL), _R(IDS_CANCEL), 0, 2, 3); // NOKILL=default, CANCEL=cancel if (ButtonPressed == 3) // Delete was cancelled - return FALSE return(FALSE); } if (ButtonPressed == 1) // Force-delete all items, so go ahead and delete return(TRUE); if (ButtonPressed == 2 && TotalItems - ItemsInUse <= 0) return(FALSE); // No items left to delete (all in use) so abort // Remove all in-use items from the selection so we only delete 'free' colours Ptr = FindFirstSelected(); while (Ptr != NULL) { if ( ((IndexedColour *) FindRealItem(Ptr))->IsInUse() ) SetDisplayItemSelState(Ptr, FALSE); // Item won't be deleted- deselect it //else // the item will be deleted - leave it selected Ptr = FindNextSelected(Ptr); } return(TRUE); }
static void ProcessCourse(courseDB course) { questionT q; int qnum; string ans; int index; printf("%s\n", course->title); qnum = 1; while (qnum != 0) { q = course->questions[qnum]; AskQuestion(q); ans = ConvertToUpperCase(GetLine()); index = FindAnswer(ans, q); if (index == -1) { printf("I don't understand that.\n"); } else { qnum = q->answers[index].nextq; } } }
BOOL OpMenuLoad::LoadFile(CCLexFile* pFileToLoad, UINT32 nPrefFilter) { // Make sure we have a valid file to load. /* TRACEUSER( "JustinF", _T("In OpMenuLoad::LoadFile(%p, %u)\n"), (LPVOID) pFileToLoad, nPrefFilter); */ ERROR3IF(!pFileToLoad, "Null CCLexFile* in OpMenuLoad::LoadFile"); // Find out the position of the filter selected by the user in the open dialog INT32 SelectedPos = 0; #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX) SelectedPos = BaseFileDialog::SelectedFilter; #endif // Go get the first filter in the list Filter* pFilter = Filter::GetFirst(); // Do we know which filter was used? (we know nothing about things in the recent file // list). If we don't, then use the preferred one, by default the generic filter. if (nPrefFilter != FILTERID_USERCHOICE || SelectedPos == 0) { // We know nothing. We will have to go and have a look at all the possibles // We will find the Filter Family and ask it to try and load the file. UINT32 nID = (nPrefFilter != FILTERID_USERCHOICE) ? nPrefFilter : FILTERID_GENERIC; while (pFilter != NULL && pFilter->FilterID != nID) { // Try the next filter pFilter = Filter::GetNext(pFilter); } } else { // We know which type of filter the user had selected in the file dialog // Find the filter that the user chose. while (pFilter != NULL) { // This is the filter? if (pFilter->GetFlags().CanImport && pFilter->pOILFilter->Position == SelectedPos) break; // Try the next filter pFilter = Filter::GetNext(pFilter); } } // Check that the Filter existed if (pFilter == NULL) { // It did not... InformError(_R(IDT_CANT_FIND_FILTER)); return FALSE; } // Get pointer to current doc 'cos we'll need it several times... Document* pCurDoc = Document::GetCurrent(); // If this is not a filter family, check for compatibility before asking // filter to load the file. // This means the user has chosen an explicit filter to handle the import PathName Path = pFileToLoad->GetPathName(); String_256 FilePath = Path.GetPath(); // FilePath will be null if a pathname is not valid if (!pFilter->IS_KIND_OF(FilterFamily) && !FilePath.IsEmpty()) { UINT32 Size = 1024; size_t FileSize; ADDR FilterBuf = pFilter->LoadInitialSegment(Path, &Size, &FileSize); // If there has been a problem in the load initial segment then fail now. if (FilterBuf == NULL) { // Tell the user about the problem and get out now while the goings good InformError(); return FALSE; } // Inform any filters that we are about to do a HowCompatible call. // This would allow a set of filters which have common functionality hidden in a // filter that cannot import and cannot export handle this call and hence set // itself up. This would allow it to maybe cache a result which should only be // checked by the first filter in the group. pFilter->PreHowCompatible(); // Change this to be less than 8 as the filters like the Accusoft forms return // 8 and 9 to make sure that they are last in the chain. if (pFilter->HowCompatible(Path, FilterBuf, Size, UINT32(FileSize)) < 8) { // Not 100% happy with this file - ask for confirmation. ErrorInfo Question; Question.ErrorMsg = _R(IDW_OPENQUERY_NOTSURE); Question.Button[0] = _R(IDB_OPENQUERY_OPEN); Question.Button[1] = _R(IDB_OPENQUERY_DONTOPEN); if ((ResourceID)AskQuestion(&Question) != _R(IDB_OPENQUERY_OPEN)) { // User asked for this to be cancelled. TRACEUSER( "Tim", _T("Filter compatibility was less than 10\n")); // Close the file, report the abort and finish. CCFree(FilterBuf); //InformMessage(_R(IDT_IMP_USERABORT)); return FALSE; } } // Get rid of initial file header CCFree(FilterBuf); } // we have to try and open the file try { // Found the Filter, so ask it to import the file please if (!pFilter->DoImport(this, pFileToLoad, pCurDoc)) { // Something went a bit wrong - tell the user what it was. // Only tell them if not special user cancelled error message if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) { // Only supress the error if not the special user abort error // ***** For now use the native EPS filter if (pFilter->FilterID == FILTERID_NATIVE_EPS && Error::GetErrorNumber() != _R(IDT_IMPORT_USERABORT)) { Error::ClearError(); InformError(_R(IDS_ERRORINARTFILE)); } else { // Tell the user what the problem was InformError(); wxMessageDialog dlg( NULL, _T( "Xara LX failed to load the design.\n\n") _T( "This is an early demonstration version of the program which does ") _T( "not yet support all of the data types that can appear in XAR designs."), _T("Load failed"), wxOK ); dlg.ShowModal() ; } } else { // otherwise remove the error so it won't get reported Error::ClearError(); } // and fail return FALSE; } } // See if there was a file io errir catch( CFileException ) { // Report the error if no one else did, otherwise clear it. if (Error::GetErrorNumber() != _R(IDN_USER_CANCELLED)) InformError(); else Error::ClearError(); // and fail return FALSE; } // Success. return TRUE; }
BOOL ColourGallery::DoRedefineItem(ListItem *ItemToRedefine) { // Bring up the colour editor on the new colour if (ItemToRedefine != NULL) DoSpecialClick(ItemToRedefine); return(TRUE); #if FALSE ColourList *ColList = ColourManager::GetColourList(); if (ColList == NULL) return(FALSE); DocColour *SourceColour = NULL; if (ColourManager::GetCurrentLineAndFillColours(NULL, &SourceColour)) SourceColour = NULL; // Sourcecolour returned was current attr - don't use if (SourceColour == NULL) { // Nothing to copy to redefine the colour. Report this to the user InformError(_R(IDE_COLGAL_NOSOURCE), _R(IDS_OK)); return(FALSE); } // We have a colour to copy... INT32 Result; IndexedColour *ParentColour = SourceColour->FindParentIndexedColour(); if (ParentColour == NULL) { Result = AskQuestion(_R(IDS_COLGAL_QREDEFINE), _R(IDS_COLGAL_YREDEFINE), _R(IDS_CANCEL)); if (Result == 1) // The user said to go ahead... { // Source is an immediate colour - generate an IndexedColour from its definition ColourGeneric Bob; SourceColour->GetSourceColour(&Bob); *((IndexedColour *)ItemToRedefine) = IndexedColour(SourceColour->GetColourModel(), &Bob); return(TRUE); } return(FALSE); // The user cancelled } if (ParentColour == (IndexedColour *) ItemToRedefine) { InformError(_R(IDE_COLGAL_SAMEITEM)); return(FALSE); } Result = 3; // Default to making a copy of the colour { IndexedColour *NewCol = (IndexedColour *)ItemToRedefine; *NewCol = *ParentColour; if (ParentColour->IsNamed()) { String_128 NewName; // Accomodate overflow- SetName clips this to String_64 NewName.MakeMsg(_R(IDS_COPYOFCOLOUR), (TCHAR *) (*ParentColour->GetName())); ((IndexedColour *)ItemToRedefine)->SetName(NewName); // If the parent was named, then remember it as the 'parent' colour, even // if it was not tint/linked. This will allow the colour editor to default // to linking to a useful colour if tint/link is turned on at a later date. NewCol->SetLinkedParent(ParentColour, NewCol->GetType()); } } if (Result != 0) // Finally, inform the world if this item has changed ColourManager::ColourHasChanged(GetGalleryDocument(), ColList, (IndexedColour *) ItemToRedefine); return(Result != 0); // if Cancelled, return FALSE (no change), else TRUE #endif }