Thread: WDL in the wild
View Single Post
Old 08-24-2010, 12:47 AM   #32
Human being with feelings
Join Date: Mar 2009
Posts: 256

Tale, do you plan to clean up the duplicate code in the user input any time soon? For the editable text control the only bit that matters is in PromptUserInput() - just move the common code into like I did in my version below. I guess this code could actually be in IGraphics.cpp and used by the windows version too, but that would be a bigger change.

This has all happened at the worst possible time for me, as your code is now in wdl I want to use that, but for me the editable text control is not optional (without it users can't download their licenses!). Meanwhile I'm gearing up to release my first paid for IPlug based plugin, and have all the beta testers lined up waiting!

void IGraphicsMac::PromptUserInput(IControl* pControl, IParam* pParam,bool editableText)
  if (mEdControl) { // paranoia
    if (pControl != mEdControl) {
      if (mGraphicsCocoa) 
        [((IGRAPHICS_COCOA*)mGraphicsCocoa) EndUserEdit];
       else if (mGraphicsCarbon)
     else {

  if (!pControl || (!pParam && !editableText)) {

  IRECT* pR = pControl->GetRECT();
  IRECT r(pR->L,pR->T,pR->R,pR->B);

  int yAdj = 0;
  bool editable=true;
  bool secure=false;
  const char *currentStr;
  char buf[MAX_PARAM_LEN];

  int n = 0;
  if (editableText) {
    currentStr = ((IEditableTextControl *)pControl)->GetText();
    editable = ((IEditableTextControl *)pControl)->IsEditable();
    secure   = ((IEditableTextControl *)pControl)->IsSecure();
  else {
    currentStr = buf;
    n = pParam->GetNDisplayTexts();  
    r.T = MAX(0,r.T - 3);
    r.B = r.T + PARAM_EDIT_H + 6;
    r.R = r.L + PARAM_EDIT_W;
    if (n) {
      // calculate combo box width
      int w = PARAM_LIST_MIN_W; 
      for (int i = 0; i < n; ++i) {
        const char* str = pParam->GetDisplayText(i);
        w = MAX(w, PARAM_LIST_MIN_W + strlen(str) * PARAM_LIST_W_PER_CHAR);
      r.R = r.L + w;

  if (mGraphicsCocoa) {
    [((IGRAPHICS_COCOA*)mGraphicsCocoa) MakeInputPrompt:&r 
          p:pParam s:currentStr ed:editable sec:secure];
  else if (mGraphicsCarbon) {
  mEdControl = pControl;
  mEdParam = pParam;  
cc_ is offline   Reply With Quote