// -------------------------------------------------------------------------------------- void SetPrefsWindowHelpTags(WindowRef prefsWindow) { CFBundleRef mainBundle; CFStringRef dataBrowserString, userPaneString, staticTextString; HMHelpContentRec dataBrowserContent, userPaneContent, staticTextContent; ControlID dataBrowserID = {kAppSignature, kIconDataBrowserID}; ControlRef dataBrowser, rootControl, userPane, staticText; UInt16 panelIndex; mainBundle = CFBundleGetMainBundle(); // set the help tag for the data browser dataBrowserString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Window Data Browser"), NULL, mainBundle, NULL); dataBrowserContent.version = kMacHelpVersion; SetRect(&dataBrowserContent.absHotRect, 0, 0, 0, 0); dataBrowserContent.tagSide = kHMDefaultSide; dataBrowserContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; dataBrowserContent.content[kHMMinimumContentIndex].u.tagCFString = dataBrowserString; dataBrowserContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; GetControlByID(prefsWindow, &dataBrowserID, &dataBrowser); HMSetControlHelpContent(dataBrowser, &dataBrowserContent); CFRelease(dataBrowserString); // set the help tags for the user panes userPaneString = CFCopyLocalizedStringFromTableInBundle(CFSTR("User Pane"), NULL, mainBundle, NULL); userPaneContent.version = kMacHelpVersion; SetRect(&userPaneContent.absHotRect, 0, 0, 0, 0); userPaneContent.tagSide = kHMDefaultSide; userPaneContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; userPaneContent.content[kHMMinimumContentIndex].u.tagCFString = userPaneString; userPaneContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; // set the help tags for the static texts staticTextString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Static Text"), NULL, mainBundle, NULL); staticTextContent.version = kMacHelpVersion; SetRect(&staticTextContent.absHotRect, 0, 0, 0, 0); staticTextContent.tagSide = kHMDefaultSide; staticTextContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; staticTextContent.content[kHMMinimumContentIndex].u.tagCFString = staticTextString; staticTextContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; GetRootControl(prefsWindow, &rootControl); for (panelIndex = 1; panelIndex <= kNumberOfRows; panelIndex++) { GetIndexedSubControl(rootControl, panelIndex, &userPane); HMSetControlHelpContent(userPane, &userPaneContent); GetIndexedSubControl(userPane, 1, &staticText); HMSetControlHelpContent(staticText, &staticTextContent); } CFRelease(userPaneString); CFRelease(staticTextString); }
// -------------------------------------------------------------------------------------- void SetPrefsDialogHelpTags(DialogRef prefsDialog) { HMHelpContentRec helpContent; CFBundleRef mainBundle; CFStringRef helpString; ControlRef control; SInt16 itemIndex; helpContent.version = kMacHelpVersion; SetRect(&helpContent.absHotRect, 0, 0, 0, 0); // use the current location of the controls helpContent.tagSide = kHMDefaultSide; mainBundle = CFBundleGetMainBundle(); // set the help tag for the data browser helpString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Dialog Data Browser"), NULL, mainBundle, NULL); helpContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; helpContent.content[kHMMinimumContentIndex].u.tagCFString = helpString; helpContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; GetDialogItemAsControl(prefsDialog, iIconDataBrowser, &control); HMSetControlHelpContent(control, &helpContent); // this retains the help string CFRelease(helpString); // so we can safely release it // set the help tags for the user panes helpString = CFCopyLocalizedStringFromTableInBundle(CFSTR("User Pane"), NULL, mainBundle, NULL); helpContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; helpContent.content[kHMMinimumContentIndex].u.tagCFString = helpString; helpContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; for (itemIndex = iUserPane1; itemIndex <= iUserPane10; itemIndex += 2) { GetDialogItemAsControl(prefsDialog, itemIndex, &control); HMSetControlHelpContent(control, &helpContent); } CFRelease(helpString); // set the help tags for the static texts helpString = CFCopyLocalizedStringFromTableInBundle(CFSTR("Static Text"), NULL, mainBundle, NULL); helpContent.content[kHMMinimumContentIndex].contentType = kHMCFStringContent; helpContent.content[kHMMinimumContentIndex].u.tagCFString = helpString; helpContent.content[kHMMaximumContentIndex].contentType = kHMNoContent; for (itemIndex = iUserPane1 + 1; itemIndex <= iUserPane10 + 1; itemIndex += 2) { GetDialogItemAsControl(prefsDialog, itemIndex, &control); HMSetControlHelpContent(control, &helpContent); } CFRelease(helpString); }
void tool_wind_fill_group_combo(void) { int n,group_idx; char str[256]; CFStringRef cf_str; HMHelpContentRec tag; // old settings group_idx=GetControl32BitValue(group_combo); // delete old control and menu DisposeControl(group_combo); DeleteMenu(160); DisposeMenu(group_menu); // recreate the menu CreateNewMenu(group_combo_menu_id,0,&group_menu); cf_str=CFStringCreateWithCString(kCFAllocatorDefault,"No Group",kCFStringEncodingMacRoman); AppendMenuItemTextWithCFString(group_menu,cf_str,0,FOUR_CHAR_CODE('gp01'),NULL); CFRelease(cf_str); AppendMenuItemTextWithCFString(group_menu,NULL,kMenuItemAttrSeparator,0,NULL); for (n=0;n<map.ngroup;n++) { sprintf(str,"%s (%d)",map.groups[n].name,group_count(n)); cf_str=CFStringCreateWithCString(kCFAllocatorDefault,str,kCFStringEncodingMacRoman); AppendMenuItemTextWithCFString(group_menu,cf_str,0,FOUR_CHAR_CODE('gp03'),NULL); CFRelease(cf_str); } InsertMenu(group_menu,kInsertHierarchicalMenu); // recreate the contorl CreatePopupButtonControl(toolwind,&group_box,NULL,group_combo_menu_id,FALSE,0,0,0,&group_combo); Draw1Control(group_combo); // build the help tag.version=kMacHelpVersion; tag.tagSide=kHMDefaultSide; SetRect(&tag.absHotRect,0,0,0,0); tag.content[kHMMinimumContentIndex].contentType=kHMCFStringContent; tag.content[kHMMinimumContentIndex].u.tagCFString=CFStringCreateWithCString(NULL,"Segment Groups",kCFStringEncodingMacRoman); tag.content[kHMMaximumContentIndex].contentType=kHMNoContent; HMSetControlHelpContent(group_combo,&tag); // reset the control SetControl32BitValue(group_combo,group_idx); }