int TrackPopupMenu(HMENU hMenu, int flags, int xpos, int ypos, int resvd, HWND hwnd, const RECT *r) { if (!hMenu || m_trackingMenus.GetSize()) return 0; ReleaseCapture(); m_trackingPar=hwnd; m_trackingFlags=flags; m_trackingRet=-1; m_trackingPt.x=xpos; m_trackingPt.y=ypos; submenuWndProc(new HWND__(NULL,0,NULL,"menu",false,submenuWndProc,NULL),WM_CREATE,0,(LPARAM)hMenu); printf("enter trackpopupmenu loop\n"); while (m_trackingRet<0 && m_trackingMenus.GetSize()) { void SWELL_RunMessageLoop(); SWELL_RunMessageLoop(); Sleep(10); } printf("leave trackpopupmenu loop\n"); int x=m_trackingMenus.GetSize()-1; while (x>=0) { HWND h = m_trackingMenus.Get(x); m_trackingMenus.Delete(x); if (h) DestroyWindow(h); x--; } if (!(flags&TPM_NONOTIFY) && m_trackingRet>0) SendMessage(hwnd,WM_COMMAND,m_trackingRet,0); return m_trackingRet>0?m_trackingRet:0; }
int AddString(const WDL_FastString &s) { WDL_FastString *ns = new WDL_FastString; *ns = s; m_strings.Add(ns); return m_strings.GetSize()-1+STRING_INDEX_BASE; }
// Returns: // -1 = action does not belong to this extension, or does not toggle // 0 = action belongs to this extension and is currently set to "off" // 1 = action belongs to this extension and is currently set to "on" int toggleActionHook(int iCmd) { static WDL_PtrList<const char> sReentrantCmds; if (COMMAND_T* cmd = SWSGetCommandByID(iCmd)) { if (cmd->accel.accel.cmd==iCmd && cmd->getEnabled && cmd->doCommand!=SWS_NOOP) { if (sReentrantCmds.Find(cmd->id) == -1) { sReentrantCmds.Add(cmd->id); int state = cmd->getEnabled(cmd); sReentrantCmds.Delete(sReentrantCmds.Find(cmd->id)); return state; } #ifdef ACTION_DEBUG else { OutputDebugString("toggleActionHook - recursive action: "); OutputDebugString(cmd->id); OutputDebugString("\n"); } #endif } } return -1; }
void RegisterToMarkerRegionUpdates(SNM_MarkerRegionListener* _listener) { #ifdef _SNM_MUTEX SWS_SectionLock lock(&g_mkrRgnListenersMutex); #endif if (_listener && g_mkrRgnListeners.Find(_listener) < 0) g_mkrRgnListeners.Add(_listener); }
void UnregisterToMarkerRegionUpdates(SNM_MarkerRegionListener* _listener) { #ifdef _SNM_MUTEX SWS_SectionLock lock(&g_mkrRgnListenersMutex); #endif int idx = _listener ? g_mkrRgnListeners.Find(_listener) : -1; if (idx >= 0) g_mkrRgnListeners.Delete(idx, false); }
~FontStorage() { int i, n = m_fonts.GetSize(); for (i = 0; i < n; ++i) { delete(m_fonts.Get(i)->font); } m_fonts.Empty(true); }
~BitmapStorage() { int i, n = m_bitmaps.GetSize(); for (i = 0; i < n; ++i) { delete(m_bitmaps.Get(i)->bitmap); } m_bitmaps.Empty(true); }
/****************************************************************************** * Continuous actions * ******************************************************************************/ bool ContinuousActionRegister (BR_ContinuousAction* action) { if (action && kbd_getTextFromCmd(action->cmd, NULL) && g_actions.FindSorted(action, &CompareActionsByCmd) == -1) { g_actions.InsertSorted(action, &CompareActionsByCmd); return true; } else return false; }
LICE_IFont* Find(IText* pTxt) { WDL_MutexLock lock(&m_mutex); int i = 0, n = m_fonts.GetSize(); for (i = 0; i < n; ++i) { FontKey* key = m_fonts.Get(i); if (key->size == pTxt->mSize && key->orientation == pTxt->mOrientation && key->style == pTxt->mStyle && !strcmp(key->face, pTxt->mFont)) return key->font; } return 0; }
LICE_IBitmap* Find(int id) { WDL_MutexLock lock(&m_mutex); int i, n = m_bitmaps.GetSize(); for (i = 0; i < n; ++i) { BitmapKey* key = m_bitmaps.Get(i); if (key->id == id) return key->bitmap; } return 0; }
int AddFontResourceEx(LPCTSTR str, DWORD fl, void *pdv) { if (str && *str) { int x; for (x=0;x<s_registered_fonts.GetSize();x++) if (!strcmp(str,s_registered_fonts.Get(x))) return 0; s_registered_fonts.Add(strdup(str)); return 1; } return 0; }
bool OscInit(OscHandler* osc) { KillOscThread(); if (s_osc_handlers.Find(osc) < 0) { // insert at the top, so new listeners will block existing handlers s_osc_handlers.Insert(0, osc); } StartOscThread(); return true; }
WDL_PtrList<void>* FilteredVisState::GetFilteredTracks() { static WDL_PtrList<void> tracks; tracks.Empty(false); for (int i = 1; i <= GetNumTracks(); i++) { MediaTrack* tr = CSurf_TrackFromID(i, false); if (MatchesFilter(tr)) tracks.Add(tr); } return &tracks; }
void MainWnd::on_list_update() { WDL_PtrList<ShellAction> *actions = NULL; App *the_app = NULL; the_app = App::get(); actions = the_app->get_tasks(); #ifdef WIN32 HWND ctrl = GetDlgItem(m_hwnd, IDC_TASKS); int sel_id = -1; sel_id = ListView_GetCurSel(ctrl); ListView_DeleteAllItems(ctrl); if(!actions->GetSize()) return; for(int i = 0; i < actions->GetSize(); i++) { LVITEM lvitem; WDL_String tmp; char buf[128]; ShellAction *action = actions->Get(i); lvitem.mask = LVIF_TEXT | LVIF_PARAM; lvitem.iItem = i; lvitem.iSubItem = 0; lvitem.lParam = (LPARAM)action->get_id(); lvitem.cchTextMax = strlen(action->get_title()); lvitem.pszText = action->get_title(); ListView_InsertItem(ctrl, &lvitem); ListView_SetItemText(ctrl, i, 1, action->get_path()); tmp = "Every "; itoa(action->get_interval(), buf, 10); tmp.Append(buf); tmp.Append(" "); tmp.Append(RUN_TYPE_LABELS[action->get_interval_type()]); ListView_SetItemText(ctrl, i, 2, tmp.Get()); } if (sel_id >= 0 && m_selected_task) { ShellAction *action = the_app->get_task_by_id(sel_id + 1); the_app->activate_task(action); ListView_SetItemState(ctrl, sel_id, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); } #endif // WIN32 }
void EndDialog(HWND wnd, int ret) { if (!wnd) return; int x; for (x = 0; x < s_modalDialogs.GetSize(); x ++) if (s_modalDialogs.Get(x)->hwnd == wnd) { s_modalDialogs.Get(x)->has_ret=true; s_modalDialogs.Get(x)->ret = ret; } DestroyWindow(wnd); // todo }
void Remove(LICE_IBitmap* bitmap) { WDL_MutexLock lock(&m_mutex); int i, n = m_bitmaps.GetSize(); for (i = 0; i < n; ++i) { if (m_bitmaps.Get(i)->bitmap == bitmap) { m_bitmaps.Delete(i, true); delete(bitmap); break; } } }
// notify marker/region listeners? // polled via SNM_CSurfRun() void UpdateMarkerRegionRun() { if (GetTickCount() > g_mkrRgnNotifyTime) { g_mkrRgnNotifyTime = GetTickCount() + SNM_MKR_RGN_UPDATE_FREQ; #ifdef _SNM_MUTEX SWS_SectionLock lock(&g_mkrRgnListenersMutex); #endif if (int sz=g_mkrRgnListeners.GetSize()) if (int updateFlags = UpdateMarkerRegionCache()) for (int i=sz-1; i>=0; i--) g_mkrRgnListeners.Get(i)->NotifyMarkerRegionUpdate(updateFlags); } }
int sInst::runcode(const char *code, bool showerr, bool canfree) { if (m_vm) { m_pc.Set(""); eel_preprocess_strings(this,m_pc,code); NSEEL_CODEHANDLE code = NSEEL_code_compile_ex(m_vm,m_pc.Get(),1,canfree ? 0 : NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS); char *err; if (!code && (err=NSEEL_code_getcodeerror(m_vm))) { if (NSEEL_code_geterror_flag(m_vm)&1) return 1; if (showerr) fprintf(stderr,"NSEEL_code_compile: %s\n",err); return -1; } else { if (code) { NSEEL_VM_enumallvars(m_vm,varEnumProc, this); NSEEL_code_execute(code); if (canfree) NSEEL_code_free(code); else m_code_freelist.Add((void*)code); } return 0; } } return -1; }
void Add(LICE_IBitmap* bitmap, int id = -1) { WDL_MutexLock lock(&m_mutex); BitmapKey* key = m_bitmaps.Add(new BitmapKey); key->id = id; key->bitmap = bitmap; }
bool hookCommandProc(int iCmd, int flag) { static WDL_PtrList<const char> sReentrantCmds; // for Xen extensions g_KeyUpUndoHandler=0; // "Hack" to make actions will #s less than 1000 work with SendMessage (AHK) // no recursion check here: handled by REAPER if (iCmd < 1000) return KBD_OnMainActionEx(iCmd, 0, 0, 0, g_hwndParent, NULL) ? true : false; // C4800 // Special case for checking recording if (iCmd == 1013 && !RecordInputCheck()) return true; // Ignore commands that don't have anything to do with us from this point forward if (COMMAND_T* cmd = SWSGetCommandByID(iCmd)) { if (cmd->accel.accel.cmd==iCmd && cmd->doCommand && cmd->doCommand!=SWS_NOOP) { if (sReentrantCmds.Find(cmd->id) == -1) { sReentrantCmds.Add(cmd->id); cmd->fakeToggle = !cmd->fakeToggle; #ifndef DEBUG_PERFORMANCE_TIME cmd->doCommand(cmd); #else CommandTimer(cmd); #endif sReentrantCmds.Delete(sReentrantCmds.Find(cmd->id)); return true; } #ifdef ACTION_DEBUG else { OutputDebugString("hookCommandProc - recursive action: "); OutputDebugString(cmd->id); OutputDebugString("\n"); } #endif } } return false; }
void Add(LICE_IFont* font, IText* pTxt) { WDL_MutexLock lock(&m_mutex); FontKey* key = m_fonts.Add(new FontKey); key->size = pTxt->mSize; key->orientation = pTxt->mOrientation; key->style = pTxt->mStyle; strcpy(key->face, pTxt->mFont); key->font = font; }
int TrackPopupMenu(HMENU hMenu, int flags, int xpos, int ypos, int resvd, HWND hwnd, const RECT *r) { if (!hMenu || m_trackingMenus.GetSize()) return 0; ReleaseCapture(); m_trackingPar=hwnd; m_trackingFlags=flags; m_trackingRet=-1; m_trackingPt.x=xpos; m_trackingPt.y=ypos; // HWND oldFoc = GetFocus(); // bool oldFoc_child = oldFoc && (IsChild(hwnd,oldFoc) || oldFoc == hwnd || oldFoc==GetParent(hwnd)); HWND hh; submenuWndProc(hh=new HWND__(NULL,0,NULL,"menu",false,submenuWndProc,NULL),WM_CREATE,0,(LPARAM)hMenu); SetProp(hh,"SWELL_MenuOwner",(HANDLE)hwnd); while (m_trackingRet<0 && m_trackingMenus.GetSize()) { void SWELL_RunMessageLoop(); SWELL_RunMessageLoop(); Sleep(10); } int x=m_trackingMenus.GetSize()-1; while (x>=0) { HWND h = m_trackingMenus.Get(x); m_trackingMenus.Delete(x); if (h) DestroyWindow(h); x--; } // if (oldFoc_child) SetFocus(oldFoc); if (!(flags&TPM_NONOTIFY) && m_trackingRet>0) SendMessage(hwnd,WM_COMMAND,m_trackingRet,0); return m_trackingRet>0?m_trackingRet:0; }
bool ContinuousActionHook (int cmd, int flag) { BR_ContinuousAction ca(cmd, NULL, NULL, NULL, NULL); int id = g_actions.FindSorted(&ca, &CompareActionsByCmd); if (id != -1) { if (!g_actionInProgress) { if (ContinuousActionInit(true, cmd, g_actions.Get(id))) return false; // all good, let it execute from the shortcut the first time else return true; } else { if (flag == ACTION_FLAG && g_actionInProgress->cmd == cmd) return false; // continuous action called from timer, let it pass else return true; } } return false; }
void OscQuit(OscHandler* osc) { if (osc) { int i=s_osc_handlers.Find(osc); if (i >= 0) { KillOscThread(); s_osc_handlers.Delete(i); if (s_osc_handlers.GetSize()) { StartOscThread(); } } } else { KillOscThread(); s_osc_handlers.Empty(); } }
// return a bitmask: &SNM_MARKER_MASK: marker update, &SNM_REGION_MASK: region update int UpdateMarkerRegionCache() { int updateFlags=0; int i=0, x=0, num, col; double pos, rgnend; const char* name; bool isRgn; // added/updated markers/regions? while ((x = EnumProjectMarkers3(NULL, x, &isRgn, &pos, &rgnend, &name, &num, &col))) { MarkerRegion* m = g_mkrRgnCache.Get(i); if (!m || (m && !m->Compare(isRgn, pos, rgnend, name, num, col))) { if (m) g_mkrRgnCache.Delete(i, true); g_mkrRgnCache.Insert(i, new MarkerRegion(isRgn, pos, rgnend, name, num, col)); updateFlags |= (isRgn ? SNM_REGION_MASK : SNM_MARKER_MASK); } i++; } // removed markers/regions? for (int j=g_mkrRgnCache.GetSize()-1; j>=i; j--) { if (MarkerRegion* m = g_mkrRgnCache.Get(j)) updateFlags |= (m->IsRegion() ? SNM_REGION_MASK : SNM_MARKER_MASK); g_mkrRgnCache.Delete(j, true); } // project time mode update? static int sPrevTimemode = *(int*)GetConfigVar("projtimemode"); if (updateFlags != (SNM_MARKER_MASK|SNM_REGION_MASK)) if (int* timemode = (int*)GetConfigVar("projtimemode")) if (*timemode != sPrevTimemode) { sPrevTimemode = *timemode; return SNM_MARKER_MASK|SNM_REGION_MASK; } return updateFlags; }
// callers must unallocate the returned value, if any WDL_PtrList<MediaTrack>* GetChildTracks(MediaTrack* _tr) { int depth = (_tr ? *(int*)GetSetMediaTrackInfo(_tr, "I_FOLDERDEPTH", NULL) : 0); if (depth == 1) { WDL_PtrList<MediaTrack>* childTracks = new WDL_PtrList<MediaTrack>; int trIdx = CSurf_TrackToID(_tr, false) + 1; while (depth > 0 && trIdx <= GetNumTracks()) { MediaTrack* tr = CSurf_TrackFromID(trIdx, false); depth += *(int*)GetSetMediaTrackInfo(tr, "I_FOLDERDEPTH", NULL); childTracks->Add(tr); trIdx++; } if (childTracks->GetSize()) return childTracks; else delete childTracks; } return NULL; }
void AddLeftItem(COMMAND_T* = NULL) { for (int i = 1; i <= GetNumTracks(); i++) { MediaTrack* tr = CSurf_TrackFromID(i, false); WDL_PtrList<void> selItems; // First find selected items for (int j = 0; j < GetTrackNumMediaItems(tr); j++) { MediaItem* selItem = GetTrackMediaItem(tr, j); if (*(bool*)GetSetMediaItemInfo(selItem, "B_UISEL", NULL)) selItems.Add(selItem); } for (int j = 0; j < selItems.GetSize(); j++) { double dLeft = *(double*)GetSetMediaItemInfo((MediaItem*)selItems.Get(j), "D_POSITION", NULL); double dRight = *(double*)GetSetMediaItemInfo((MediaItem*)selItems.Get(j), "D_LENGTH", NULL) + dLeft; double dMaxLeft = -DBL_MAX; MediaItem* leftItem = NULL; for (int k = 0; k < GetTrackNumMediaItems(tr); k++) { MediaItem* mi; mi = GetTrackMediaItem(tr, k); double dLeft2 = *(double*)GetSetMediaItemInfo(mi, "D_POSITION", NULL); double dRight2 = *(double*)GetSetMediaItemInfo(mi, "D_LENGTH", NULL) + dLeft2; if (dLeft2 < dLeft && dRight2 < dRight && dLeft2 > dMaxLeft) { dMaxLeft = dLeft2; leftItem = mi; } } if (leftItem) GetSetMediaItemInfo(leftItem, "B_UISEL", &g_i1); } } UpdateTimeline(); }
int audioStreamer_waveOut::Read(char *buf, int len) // returns 0 if blocked, < 0 if error, > 0 if data { if (!m_hwi) return -1; #if 0 // lame, this doesnt really do what we want it to // check to see if all are full, and if so, kill a lot of em { int x; int cnt=0; for (x = 0; x < m_bufs.GetSize(); x ++) { WAVEHDR *th = (WAVEHDR *) m_bufs.Get(x)->Get(); if (th->dwFlags & WHDR_DONE) cnt++; } if (cnt >= m_bufs.GetSize()-1) { // audiostream_onover(); for (x = 0; x < m_bufs.GetSize(); x ++) { if (x != m_whichbuf) { WAVEHDR *th = (WAVEHDR *) m_bufs.Get(x)->Get(); if (th->dwFlags & WHDR_DONE) { th->dwBytesRecorded=0; th->dwFlags = WHDR_PREPARED; waveInAddBuffer(m_hwi,th,sizeof(WAVEHDR)); } } } } } #endif WAVEHDR *th = (WAVEHDR *) m_bufs.Get(m_whichbuf)->Get(); while (!(th->dwFlags & WHDR_DONE)) { Sleep(WO_SLEEP); } len=min(len,(int)th->dwBytesRecorded); memcpy(buf,th->lpData,len); th->dwBytesRecorded=0; th->dwFlags = WHDR_PREPARED; waveInAddBuffer(m_hwi,th,sizeof(WAVEHDR)); if (++m_whichbuf >= m_bufs.GetSize()) m_whichbuf=0; return len; }
const char *GetStringForIndex(EEL_F val, WDL_FastString **isWriteableAs=NULL) { int idx = (int) (val+0.5); if (idx>=0 && idx < MAX_USER_STRINGS) { if (isWriteableAs) { if (!m_rw_strings[idx]) m_rw_strings[idx] = new WDL_FastString; *isWriteableAs = m_rw_strings[idx]; } return m_rw_strings[idx]?m_rw_strings[idx]->Get():""; } WDL_FastString *s = m_strings.Get(idx - STRING_INDEX_BASE); if (isWriteableAs) *isWriteableAs=s; return s ? s->Get() : NULL; }
int SWELL_DialogBox(SWELL_DialogResourceIndex *reshead, const char *resid, HWND parent, DLGPROC dlgproc, LPARAM param) { SWELL_DialogResourceIndex *p=resById(reshead,resid); if (resid) // allow modal dialogs to be created without template { if (!p||(p->windowTypeFlags&SWELL_DLG_WS_CHILD)) return -1; } int ret=-1; HWND hwnd = SWELL_CreateDialog(reshead,resid,parent,dlgproc,param); // create dialog if (hwnd) { ReleaseCapture(); // force end of any captures WDL_PtrList<HWND__> enwnds; extern HWND__ *SWELL_topwindows; HWND a = SWELL_topwindows; while (a) { if (a->m_enabled && a != hwnd) { EnableWindow(a,FALSE); enwnds.Add(a); } a = a->m_next; } modalDlgRet r = { hwnd,false, -1 }; s_modalDialogs.Add(&r); ShowWindow(hwnd,SW_SHOW); while (s_modalDialogs.Find(&r)>=0 && !r.has_ret) { void SWELL_RunMessageLoop(); SWELL_RunMessageLoop(); Sleep(10); } ret=r.ret; s_modalDialogs.Delete(s_modalDialogs.Find(&r)); a = SWELL_topwindows; while (a) { if (!a->m_enabled && a != hwnd && enwnds.Find(a)>=0) EnableWindow(a,TRUE); a = a->m_next; } } // while in list, do something return ret; }