/* Demonstrate using an FFT to detect telephone keys. Setup is the result of creating an FFT setup. F contains a pair of frequencies to inject into a signal. */ void Demonstrate(FFTSetup Setup, FrequencyPair F) { float *Signal = malloc(SampleLength * sizeof *Signal); if (Signal == 0) { fprintf(stderr, "Error, unable to allocate memory.\n"); exit(EXIT_FAILURE); } printf("\tGenerating signal with noise and DTMF tones...\n"); // Initialize the signal with noise. for (int i = 0; i < SampleLength; ++i) Signal[i] = 4 * Random(); // Add one of the tones to the signal. float Phase = Random(); // Start the tone at a pseudo-random time. for (int i = 0; i < SampleLength; ++i) Signal[i] += sin((i*F.Frequency[0] / SamplingFrequency + Phase) * TwoPi); // Add the other tone. Phase = Random(); // Start the tone at a pseudo-random time. for (int i = 0; i < SampleLength; ++i) Signal[i] += sin((i*F.Frequency[1]/SamplingFrequency + Phase) * TwoPi); // Rearrange the signal for vDSP_fft_zrip, using an auxiliary buffer. // Get enough memory for two halves. float *BufferMemory = malloc(SampleLength * sizeof *BufferMemory); if (BufferMemory == 0) { fprintf(stderr, "Error, unable to allocate memory.\n"); exit(EXIT_FAILURE); } // Assign half the memory to reals and half to imaginaries. DSPSplitComplex Buffer = { BufferMemory, BufferMemory + SampleLength/2 }; // Copy (and rearrange) the data to the buffer. vDSP_ctoz((DSPComplex *) Signal, 2, &Buffer, 1, SampleLength / 2); printf("\tAnalyzing signal...\n"); // Compute the DFT of the signal. vDSP_fft_zrip(Setup, &Buffer, 1, Log2SampleLength, FFT_FORWARD); // Use the DFT results to identify the tones in the signal. int Tone0 = FindTone(Buffer, DTMF0, NumberOf(DTMF0)); int Tone1 = FindTone(Buffer, DTMF1, NumberOf(DTMF1)); printf("\tFound frequencies %g and %g for key %c.\n", DTMF0[Tone0], DTMF1[Tone1], Keys[Tone1*4 + Tone0]); // Release resources. free(BufferMemory); free(Signal); }
packagePo createPkg(char *name, char *version) { packagePo pkg = (packagePo) allocPool(pkgPool); uniCpy((char *) &pkg->packageName, NumberOf(pkg->packageName), name); uniCpy((char *) &pkg->version, NumberOf(pkg->version), version); hashPut(packages, pkg, pkg); return pkg; }
/* * ATIIdentProbe -- * * This function determines if the user specified a chipset name acceptable to * this driver, and, if so, sets ATIChipSet accordingly. */ Bool ATIIdentProbe(void) { int Index; static const char *LegacyNames[] = {"vgawonder", "mach8", "mach32", "mach64"}; /* Let ATIProbe continue if no chipset is specified */ if (!vga256InfoRec.chipset) return TRUE; for (; ATIChipSet < NumberOf(ATIChipSetNames); ATIChipSet++) if (!StrCaseCmp(vga256InfoRec.chipset, ATIChipSetNames[ATIChipSet])) return TRUE; /* Reset to default */ ATIChipSet = ATI_CHIPSET_ATI; /* Check for some other chipset names that need changing */ for (Index = 0; StrCaseCmp(vga256InfoRec.chipset, LegacyNames[Index]); ) if (++Index >= NumberOf(LegacyNames)) return FALSE; if (xf86Verbose) ErrorF("XF86Config ChipSet specification changed from \"%s\" to" " \"%s\".\n", LegacyNames[Index], ATIChipSetNames[ATIChipSet]); OFLG_CLR(XCONFIG_CHIPSET, &vga256InfoRec.xconfigFlag); return TRUE; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { PVs pvs = { {0} }; MultiArgRec args[]={ { sizeof(double), 0, (void**)0 }, { sizeof(double), 0, (void**)0 } }; void *pres[NumberOf(args)]; int i; LcaError theErr; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( NumberOf(args) < nlhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Too many output args"); goto cleanup; } if ( 1 != nrhs ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected one rhs argument"); goto cleanup; } for ( i=0; i<NumberOf(args); i++) { args[i].pres = &pres[i]; plhs[i]=0; } if ( buildPVs(prhs[0], &pvs, &theErr) ) goto cleanup; if ( !multi_ezca_get_misc(pvs.names, pvs.m, (MultiEzcaFunc)ezcaGetAlarmLimits, NumberOf(args), args, &theErr) ) goto cleanup; for ( i=0; i<nlhs; i++ ) { if ( !(plhs[i]=mxCreateDoubleMatrix(pvs.m, 1, mxREAL)) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } memcpy(mxGetPr(plhs[i]), *args[i].pres, pvs.m * args[i].size); } nlhs = 0; /* prevent array destruction if everything is OK */ cleanup: for ( i=0; i<nlhs; i++ ) { if ( plhs[i] ) { mxDestroyArray(plhs[i]); plhs[i] = 0; } } for ( i=0; i<NumberOf(args); i++ ) { if ( args[i].pres ) lcaFree(*args[i].pres); } releasePVs(&pvs); /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }
/* * DoSendString - actually sends a string to the X Window having input focus * * The main task of this function is to convert the ascii char values * into X KeyCodes. But they need to be converted to X KeySyms first * and then to the keycodes. The KeyCodes can have any random values * and are not contiguous like the ascii values are. * * Some escape sequences can be converted to the appropriate KeyCodes * by this function. See the code below for details */ void CKeySendImpl::DoSendString(const StringX& str, unsigned delayMS, bool emulateMods) { atGlobals.error_detected = false; atGlobals.errorString[0] = 0; AutotypeEvent event(m_display); // convert all the chars into keycodes and required shift states first // Abort if any of the characters cannot be converted typedef std::vector<KeyPressInfo> KeyPressInfoVector; KeyPressInfoVector keypresses; for (StringX::const_iterator srcIter = str.begin(); srcIter != str.end(); ++srcIter) { //throw away 'vertical tab' chars which are only used on Windows to send a shift+tab //as a workaround for some issues with IE if (*srcIter == _T('\v')) continue; //Try a regular conversion first KeySym sym = wchar2keysym(*srcIter); if (NoSymbol != sym) { KeyPressInfo keypress = {0, 0}; if ((keypress.code = XKeysymToKeycode(event.display, sym)) != 0) { //non-zero return value implies sym -> code was successful keypress.state |= CalcModifiersForKeysym(keypress.code, sym, event.display); keypresses.push_back(keypress); } else { const char* symStr = XKeysymToString(sym); snprintf(atGlobals.errorString, NumberOf(atGlobals.errorString), "Could not get keycode for key char(%s) - sym(%#X) - str(%s). Aborting autotype.\n\nIf \'xmodmap -pk\' does not list this KeySym, you probably need to install an appropriate keyboard layout.", wchar2bytes(*srcIter).str(), static_cast<int>(sym), symStr ? symStr : "NULL"); atGlobals.error_detected = True; return; } } else { snprintf(atGlobals.errorString, NumberOf(atGlobals.errorString), "Cannot convert '%s' [U+%04X] to keysym. Aborting autotype", wchar2bytes(*srcIter).str(), int(*srcIter)); atGlobals.error_detected = True; return; } } m_method->EmulateMods(emulateMods); for (KeyPressInfoVector::const_iterator itr = keypresses.begin(); itr != keypresses.end() && !atGlobals.error_detected; ++itr) { event.keycode = itr->code; event.state = itr->state; event.time = CurrentTime; (*m_method)(event); pws_os::sleep_ms(delayMS); } }
void SendString(CFStringRef str, unsigned delayMS) { //virtual keycodes copied from 10.6 SDK. Could not find them in 10.4 SDK enum { VK_RETURN = 0x24 /*KVK_Return*/, VK_TAB = 0x30 /*kVK_Tab*/, VK_SPACE = 0x31/*kVK_Space*/}; //A list of chars for which we must specify the virtual keycode static const CFStringRef specialChars = CFSTR("\n\t "); static const UniChar verticalTab = CFStringGetCharacterAtIndex(CFSTR("\v"), 0); //each keycode must correspond to the correct char in 'specialChars' CGKeyCode specialKeyCodes[] = {VK_RETURN, VK_TAB, VK_SPACE }; assert(CFStringGetLength(specialChars) == NumberOf(specialKeyCodes)); for (unsigned i = 0, len = CFStringGetLength(str); i < len; ++i) { //The next char to send UniChar c = CFStringGetCharacterAtIndex(str, i); //throw away 'vertical tab' chars which are only used on Windows to send a shift+tab //as a workaround for some issues with IE if (verticalTab == c) continue; //see if we need to specify the virtual keycode for this char CGKeyCode vKey = 0; //0 = kVK_ANSI_A, but I don't know of a more appropriate default value for (size_t j = 0; j < NumberOf(specialKeyCodes); ++j) { if ( CFStringGetCharacterAtIndex(specialChars, j) == c) { vKey = specialKeyCodes[j]; break; } } CGEventRef keyDown = CGEventCreateKeyboardEvent(NULL, vKey, true); CGEventRef keyUp = CGEventCreateKeyboardEvent(NULL, vKey, false); if (keyDown && keyUp) { //may be we should not do this if we found the virtual keycode? CGEventKeyboardSetUnicodeString(keyDown, 1, &c); CGEventKeyboardSetUnicodeString(keyUp, 1, &c); CGEventPost(kCGSessionEventTap, keyDown); CGEventPost(kCGSessionEventTap, keyUp); pws_os::sleep_ms(delayMS); CFRelease(keyDown); CFRelease(keyUp); } else { if (keyDown) CFRelease(keyDown); if (keyUp) CFRelease(keyUp); pws_os::IssueError(_T("Out of memory trying to allocate CGEventRef")); return; } } }
/* * ErrorHandler will be called when X detects an error. This function * just sets a global flag and saves the error message text */ int ErrorHandler(Display *my_dpy, XErrorEvent *event) { char xmsg[512] = {0}; atGlobals.error_detected = TRUE; XGetErrorText(my_dpy, event->error_code, xmsg, NumberOf(xmsg) - 1); snprintf(atGlobals.errorString, NumberOf(atGlobals.errorString)-1, "X error (%d): %s", event->request_code, xmsg); return 0; }
void defltCWD() { // set up working directory if (uniIsLit(CWD, "")) { char cbuff[MAXFILELEN]; char *cwd = getcwd(cbuff, NumberOf(cbuff)); /* compute current starting directory */ if (cwd == NULL) syserr("cant determine current directory"); else uniTrim(cwd, uniStrLen(cwd), "", "/", CWD, NumberOf(CWD)); } }
static char *defltLine(char *src, integer srcLen, integer *actLen) { static char defltLn[MAXLINE] = {'n'}; if (!uniIsTrivial(src, srcLen)) { uniNCpy(defltLn, NumberOf(defltLn), src, srcLen); *actLen = srcLen; return src; } else { *actLen = uniNStrLen(defltLn, NumberOf(defltLn)); return defltLn; } }
static void defineResumeProgs(void) { int ar; for (ar = 0; ar < NumberOf(doResume); ar++) { insWord seq[] = { /* Y[arity] = interrupted code, Y[i] arguments */ instrhb(gcmap, 0, ar), instrh(resume, ar), /* this resumes the execution */ instr(succ) }; ptrI cde = buildCode(seq, 1, NumberOf(seq), 0); doResume[ar] = cde; } }
bool pws_os::MacSimulateApplicationSwitch(unsigned delayMS) { enum { VK_CMD = 55, VK_TAB = 48 }; struct { CGKeyCode virtualKey; bool down; bool mask; } KeySequence[]={ {VK_CMD, true, true}, {VK_TAB, true, true}, {VK_TAB, false, true}, {VK_CMD, false, false} }; for (size_t idx = 0; idx < NumberOf(KeySequence); ++idx) { CGEventRef keystroke = CGEventCreateKeyboardEvent(NULL, KeySequence[idx].virtualKey, KeySequence[idx].down); if (keystroke) { if (KeySequence[idx].mask) { CGEventSetFlags(keystroke, kCGEventFlagMaskCommand); } CGEventPost(kCGSessionEventTap, keystroke); CFRelease(keystroke); pws_os::sleep_ms(delayMS); } else { return false; } } return true; }
/* acceptConnection allows a connection from a connect socket and returns a filePo which can read/write to the remote host */ retCode acceptConnection(sockPo listen, ioEncoding encoding, ioPo *inC, ioPo *outC) { struct sockaddr_in cli_addr; socklen_t clilen = sizeof(cli_addr); int lSock = fileNumber(O_FILE(listen)); int cliSock; memset((char *) &cli_addr, 0, sizeof(cli_addr)); cliSock = accept(lSock, (struct sockaddr *) &cli_addr, &clilen); if (cliSock < 0) { switch (errno) { case EWOULDBLOCK: return Fail; case EINTR: // Interrupted return Eof; default: return Error; } } else { char cl_name[MAXLINE]; struct in_addr addr = *(struct in_addr *) &cli_addr; strMsg(cl_name, NumberOf(cl_name), "%s:%d", inet_ntoa(addr), ntohs(cli_addr.sin_port)); *inC = O_IO(newObject(sockClass, cl_name, cliSock, encoding, ioREAD)); *outC = O_IO(newObject(sockClass, cl_name, cliSock, encoding, ioWRITE)); return Ok; } }
/* * This program is used to map special classes like integer into * L&O programs * This program is only safe before the first GC */ ptrI defineSpecialProg(const char *name) { #ifdef MEMTRACE extern long gcCount; long gCount = gcCount; #endif insWord proc_seq[] = { // (gVar,_,tVar) :- name%3(gVar,name,tVar) instrhb(mAlit, 2, 0), /* name */ instrhb(lkawl, 3, 1), /* name%3 */ }; ptrI obj = buildCode(proc_seq, 3, NumberOf(proc_seq), 2); ptrI nameEnum = newEnumSym(name); updateCodeLit(codeV(obj), 0, nameEnum); /* name */ ptrI nameProg = newProgLbl(name, 3); /* name%3 */ defineProg(nameProg, obj); updateCodeLit(codeV(obj), 1, nameProg); #ifdef MEMTRACE assert(gcCount == gCount); #endif return obj; }
static void defineExitProg(void) { static insWord proc_exit_seq[] = { instrhb(gcmap, 0, 0), instr(die) /* Then we expire */ }; exitProg = buildCode(proc_exit_seq, 0, NumberOf(proc_exit_seq), 0); }
bool PWSDragBar::IsEnabled(int id) const { const int idx = id - DRAGBAR_TOOLID_BASE; wxASSERT( idx >= 0 && size_t(idx) < NumberOf(DragbarElements)); CItemData* item = m_frame->GetSelectedEntry(); return item != 0 && item->GetFieldValue(DragbarElements[idx].ft).empty() == false; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { PVs pvs = { {0} }; int i,j; LcaError theErr; MultiArgRec args[1]; units_string *strbuf MAY_ALIAS = 0; mxArray *tmp; lcaErrorInit(&theErr); LHSCHECK(nlhs, plhs); if ( nlhs > 1 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Too many output args"); goto cleanup; } if ( nrhs < 1 || nrhs > 1 ) { lcaSetError(&theErr, EZCA_INVALIDARG, "Expected 1 rhs argument"); goto cleanup; } if ( buildPVs(prhs[0], &pvs, &theErr) ) goto cleanup; MSetArg(args[0], sizeof(units_string), 0, &strbuf); if ( !multi_ezca_get_misc(pvs.names, pvs.m, (MultiEzcaFunc)ezcaGetUnits, NumberOf(args), args, &theErr) ) goto cleanup; /* convert string array to a matlab cell array of matlab strings */ if ( !(plhs[0] = mxCreateCellMatrix(pvs.m, 1)) ) { lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } for ( i = 0; i < pvs.m; i++ ) { if ( !(tmp = mxCreateString((char*)&strbuf[i])) ) { for ( j=0; j<i; j++ ) { mxDestroyArray(mxGetCell(plhs[0],i)); } mxDestroyArray(plhs[0]); plhs[0] = 0; lcaSetError(&theErr, EZCA_FAILEDMALLOC, "Not enough memory"); goto cleanup; } mxSetCell(plhs[0], i, (mxArray*)tmp); } nlhs = 0; cleanup: if ( strbuf ) lcaFree( strbuf ); releasePVs(&pvs); /* do this LAST (in case mexErrMsgTxt is called) */ ERR_CHECK(nlhs, plhs, &theErr); }
wchar2bytes(wchar_t wc): bytes(new char[MB_CUR_MAX*2 + sizeof(wchar_t)*2 + 2 + 1]) { mbstate_t ps; memset(&ps, 0, sizeof(ps));//initialize mbstate size_t n; if ((n = wcrtomb(bytes, wc, &ps)) == size_t(-1)) snprintf(bytes, NumberOf(bytes), "U+%04X", int(wc)); else bytes[n] = 0; }
static DebugWaitFor dbgShowGlobal(char *line, processPo p, termPo loc, insWord ins, void *cl) { char buff[MAX_SYMB_LEN]; integer pos = 0; integer ix = 0; integer llen = uniStrLen(line); enum { initSte, inVar } st = initSte; while (ix < llen) { codePoint cp = nextCodePoint(line, &ix, llen); switch (st) { case initSte: if (!isSpaceChar(cp)) { st = inVar; appendCodePoint(buff, &pos, NumberOf(buff), cp); } continue; case inVar: if (!isSpaceChar(cp)) { appendCodePoint(buff, &pos, NumberOf(buff), cp); continue; } else break; } } if (uniStrLen(buff) > 0) { appendCodePoint(buff, &pos, NumberOf(buff), 0); globalPo glb = globalVar(buff); if (glb != Null) { termPo val = getGlobal(glb); if (val != Null) outMsg(debugOutChnnl, "%s = %,*T\n", buff, displayDepth, val); else outMsg(debugOutChnnl, "%s not set\n", buff); } } resetDeflt("n"); return moreDebug; }
unsigned pictimerDisable(unsigned timer_no) { unsigned tmp; if ( timer_no > NumberOf(timerConnected) ) return -1; tmp = in_le32( &OpenPIC->Global.Timer[timer_no].Vector_Priority ); out_le32( &OpenPIC->Global.Timer[timer_no].Vector_Priority, tmp | OPENPIC_MASK ); return !(tmp | OPENPIC_MASK); }
/* Check if the terminal name is in the list of terminals we know are * not able to understand basic escape sequences. */ static logical isUnsupportedTerm(void) { static char *unsupported_term[] = {"dumb", "cons25", "emacs"}; char *term = getenv("TERM"); if (term == Null) return True; for (int ix = 0; ix < NumberOf(unsupported_term); ix++) if (uniCmp(term, unsupported_term[ix]) == same) return True; return False; }
bool PWSDragBar::IsEnabled(int id) const { const int idx = id - DRAGBAR_TOOLID_BASE; wxASSERT( idx >= 0 && size_t(idx) < NumberOf(DragbarElements)); const CItemData *pci(nullptr), *pbci(nullptr); pci = m_frame->GetSelectedEntry(); pbci = m_frame->GetBaseEntry(pci); return pci && !pci->IsFieldValueEmpty(DragbarElements[idx].ft, pbci); }
bool pws_os::SelectAll() { enum { VK_A = kVK_ANSI_A, VK_CMD = kVK_Command }; KeyStroke KeySequence[]={ {VK_CMD, true, true}, {VK_A, true, true}, {VK_A, false, true}, {VK_CMD, false, false} }; return EmulateKeyStrokes(KeySequence, NumberOf(KeySequence), 0); }
wxString PWSDragBar::GetText(int id) const { const int idx = id - DRAGBAR_TOOLID_BASE; wxASSERT( idx >= 0 && size_t(idx) < NumberOf(DragbarElements)); const CItemData *pci(nullptr), *pbci(nullptr); pci = m_frame->GetSelectedEntry(); pbci = m_frame->GetBaseEntry(pci); return pci ? towxstring(pci->GetEffectiveFieldValue(DragbarElements[idx].ft, pbci)) : wxString(wxEmptyString); }
bool pws_os::MacSimulateApplicationSwitch(unsigned delayMS) { enum { VK_CMD = 55, VK_TAB = 48 }; KeyStroke KeySequence[] = { {VK_CMD, true, true}, {VK_TAB, true, true}, {VK_TAB, false, true}, {VK_CMD, false, false} }; return EmulateKeyStrokes(KeySequence, NumberOf(KeySequence), delayMS); }
static retCode sockFlush(ioPo io, long count) { filePo f = O_FILE(io); if (count > 0 && f->file.out_pos + count < NumberOf(f->file.out_line)) return Ok; // Nothing to do, we have at least count bytes left in the buffer if (f->file.out_pos > 0) { size_t actual = (size_t) f->file.out_pos; int sock = f->file.fno; long nBytes; byte *buffer = f->file.out_line; byte *cp = buffer; while (actual > 0 && (nBytes = send(sock, cp, actual, 0)) != actual) { if (nBytes == SOCKET_ERROR) { switch (errno) { case EWOULDBLOCK: case ENOBUFS: case EINTR: { if (cp != buffer) { // we were able to write something out ... sockConfigure(f, turnOnBlocking); // so we have to finish while (actual > 0 && (nBytes = send(sock, cp, actual, 0)) != actual) { if (nBytes == SOCKET_ERROR) { // logMsg(logFile,"Problem %s (%d) in sending %d bytes to %U[%d]\n", // strerror(errno),errno,actual,f->filename,f->client); sockConfigure(f, turnOffBlocking); return Error; } cp += nBytes; actual -= nBytes; } sockConfigure(f, turnOffBlocking); f->file.out_pos = 0; return Ok; } else return Fail; } default: // logMsg(logFile,"Problem %s (%d) in sending %d bytes to %U[%d]\n", // strerror(errno),errno,actual,f->filename,f->client); return Error; } } else { cp += nBytes; actual -= nBytes; } } } f->file.out_pos = 0; return Ok; }
/* * ATIIdent -- * * Returns a string name for this driver or NULL. */ char * ATIIdent(int n) { #if 1 /* For now, don't advertise non-default chipset names */ if (n != ATI_CHIPSET_ATI) #else if ((n < 0) || (n >= NumberOf(ATIChipSetNames))) #endif return NULL; else return ATIChipSetNames[n]; }
unsigned pictimerEnable(unsigned timer_no, int v) { unsigned tmp; if ( timer_no > NumberOf(timerConnected) ) return -1; tmp = in_le32( &OpenPIC->Global.Timer[timer_no].Vector_Priority ); if ( v ) out_le32( &OpenPIC->Global.Timer[timer_no].Vector_Priority, tmp & ~OPENPIC_MASK ); return tmp; }
CKeySendImpl::CKeySendImpl(pws_os::AutotypeMethod method): m_display(XOpenDisplay(NULL)) { if (m_display) { m_method = GetAutotypeMethod(m_display, method); } else { if (!atGlobals.error_detected) atGlobals.error_detected = true; if (!atGlobals.errorString[0]) strncpy(atGlobals.errorString, "Could not open X display for autotyping", NumberOf(atGlobals.errorString)); throw autotype_exception(); } }
/* * ATIIdentify -- * * Print the driver's list of chipset names. */ void ATIIdentify ( int flags ) { xf86PrintChipsets(ATI_NAME, (NumberOf(ATIPublicChipsetNames) <= 2) ? "ATI driver (version " ATI_VERSION_NAME ") for chipset" : "ATI driver (version " ATI_VERSION_NAME ") for chipsets", ATIPublicChipsetNames); R128Identify(flags); RADEONIdentify(flags); }
void PWSDragBar::RefreshButtons() { const bool newButtons = PWSprefs::GetInstance()->GetPref(PWSprefs::UseNewToolbar); #define BTN newButtons? wxBitmap(DragbarElements[idx].bitmap) : wxBitmap(DragbarElements[idx].classic_bitmap) #define BTN_DISABLED newButtons? wxBitmap(DragbarElements[idx].bitmap_disabled): wxBitmap(DragbarElements[idx].classic_bitmap_disabled) if (GetToolsCount() == 0) { //being created? for (int idx = 0; size_t(idx) < NumberOf(DragbarElements); ++idx) { AddTool(idx + DRAGBAR_TOOLID_BASE, BTN, wxString(_("Drag this image onto another window to paste the '")) << DragbarElements[idx].name << _("' field."), BTN_DISABLED ); } } else { for (int idx = 0; size_t(idx) < NumberOf(DragbarElements); ++idx) { SetToolBitmaps(idx + DRAGBAR_TOOLID_BASE, BTN, BTN_DISABLED); } } #undef BTN #undef BTN_DISABLED }