예제 #1
0
static void SaveColorFile(HWND hWnd,TSTR &name)
   {
    MaxSDK::Util::TextFile::Writer file;	

   	Interface14 *iface = GetCOREInterface14();
	UINT codepage  = iface-> DefaultTextSaveCodePage(true); //dll\PaintLayerMod\ColorPaletteTool.cpp :: SaveColorFile, UTF8 allowed, keep to same.

   if(!file.Open(fname, false, MaxSDK::Util::TextFile::Writer::WRITE_BOM | codepage )){
      TSTR buf2 = GetString(IDS_RB_COLORCLIPBOARD);
      TSTR buf1;
      buf1.printf(GetString(IDS_RB_CANTOPENFILE),fname);       
      MessageBox(hWnd,buf1,buf2,MB_ICONEXCLAMATION);
      return;
      }

   for (int i=0; i<12; i++) {
      int r, g, b;
      IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i]));
      COLORREF col = cs->GetColor();
      ReleaseIColorSwatch(cs);
      r = GetRValue(col); g = GetGValue(col); b = GetBValue(col);
      file.Printf(_T("%d %d %d\n"), r, g, b);
      }  

   for (int i=0; i<12; i++) {
      IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i]));
      AColor col = cs->GetAColor();
      ReleaseIColorSwatch(cs);
      file.Printf(_T("%f %f %f %f\n"), col.r, col.g, col.b, col.a);
   }  

   SetupTitle(hWnd,name);
   file.Close();
   }
logical pc_ADK_Field :: SetupColumn ( )
{
  PropertyHandle        *pfc = GetParentProperty();
  PropertyHandle        *my_class  = pfc->GPH("class");
  PropertyHandle        *member;
  logical                coll_opt;
  char                  *type;
  char                  *propnames = NULL;
  logical                term = NO;
BEGINSEQ
  if ( IsInitialized() )                             LEAVESEQ
  
  propnames = strdup(GPH("sys_ident")->GetString());
  if ( !my_class->Get(FIRST_INSTANCE) )              ERROR
    
  pc_ADK_Class   structure(*my_class);  
  if ( member = structure.GetMember(propnames) )
    coll_opt = pc0_SDB_Member(member).IsMultipleRef() ? YES : NO;
  else
  {
    pc_ADK_Class  all_class(GetObjectHandle(),PI_Read);  
    PropertyHandle phpropnames(propnames);
    if ( all_class.Get(phpropnames) )
    {
      type     = "DRT_Extent";
      coll_opt = YES;
    }
  }

  *GPH("auto_open") = YES;
  *GPH("size.oszwdth") = -1;
  *GPH("size.oszhgth") = 20;
  SetupDataSource(propnames,type,coll_opt);
  SetupTitle(propnames);

RECOVER
  term = YES;
ENDSEQ
  if ( propnames )
    free(propnames);
  return(term);
}
예제 #3
0
extern bool DoMainLoop( dlg_state * state )
/*****************************************/
{
    const char          *diag_list[MAX_DIAGS + 1];
    const char          *diags;
    const char          *dstdir;
    int                 dstlen;
    bool                got_disk_sizes = FALSE;
    int                 i;
    char                newdst[_MAX_PATH];
    char                *next;
    bool                ret = FALSE;

    SetupTitle();

    // display initial dialog
    diags = GetVariableStrVal( "DialogOrder" );
    if( stricmp( diags, "" ) == 0 ) {
        diags = "Welcome";
    }
    i = 0;
    for( ;; ) {
        diag_list[i] = diags;
        next = strchr( diags, ',' );
        if( next == NULL ) break;
        *next = '\0';
        diags = next + 1;
        ++i;
    }
    diag_list[i + 1] = NULL;
    /* process installation dialogs */

    i = 0;
    for( ;; ) {
        if( i < 0 ) break;
        if( diag_list[i] == NULL ) {
            if( GetVariableIntVal( "DoCopyFiles" ) == 1 ) {
                if( !CheckDrive( TRUE ) ) {
                    i = 0;
                }
            }
            if( GetVariableByName( "SetupPath" ) != NO_VAR ) {
                ret = TRUE;
                break;
            }
            if( diag_list[i] == NULL ) {
                    StatusShow( TRUE );
                    ret = SetupOperations();
                    StatusShow( FALSE );
                    if( ret ) DoDialog( "Finished" );
                    break;
            }
        }
        if( stricmp( diag_list[i], "GetDiskSizesHere" ) == 0 ) {
            if( *state == DLG_NEXT ) {

                dstdir = GetVariableStrVal( "DstDir" );
                dstlen = strlen( dstdir );
                if( dstlen != 0 &&
                    (dstdir[dstlen - 1] == '\\' || dstdir[dstlen - 1] == '/') ) {
                    strcpy( newdst, dstdir );
                    if( dstlen == 3 && dstdir[1] == ':' ) {
                        newdst[dstlen] = '.';
                        newdst[dstlen + 1] = '\0';
                    } else {
                        newdst[dstlen - 1] = '\0';
                    }
                    SetVariableByName( "DstDir", newdst );
                }
                SimSetNeedGetDiskSizes();
                ResetDiskInfo();
                got_disk_sizes = TRUE;

            }
        } else {
            *state = DoDialog( diag_list[i] );
            GUIWndDirty( NULL );
            StatusCancelled();
        }
        if( *state == DLG_CAN ) {
            if( MsgBox( NULL, "IDS_QUERYABORT", GUI_YES_NO ) == GUI_RET_YES ) {
                CancelSetup = TRUE;
                break;
            }
        } else if( *state == DLG_DONE ) {
            CancelSetup = TRUE;
            break;
        }
        if( got_disk_sizes ) {
            if( !CheckDrive( FALSE ) ) {
                break;
            }
        }
        if( *state == DLG_SAME ) {
            /* nothing */
        } else if( *state == DLG_NEXT || *state == DLG_SKIP ) {
            if( SkipDialogs ) {
                ++i;
            } else {
                for( ;; ) {
                    ++i;
                    if( diag_list[i] == NULL ) break;
                    if( CheckDialog( diag_list[i] ) ) break;
                }
            }
        } else if( *state == DLG_PREV ) {
            for( ;; ) {
                --i;
                if( i < 0 ) break;
                if( CheckDialog( diag_list[i] ) ) break;
            }
        } else if( *state == DLG_START ) {
            i = 0;
        }
    } /* for */

    return( ret );
}
logical pc_ADK_Field :: SetupField ( )
{
  PropertyHandle        *pfc = GetParentProperty();
  PropertyHandle        *my_class  = pfc->GPH("class");
  PropertyHandle        *member;
  PropertyHandle        *fc;
  logical                vgrow = YES;
  logical                hgrow = YES;
  logical                coll_opt;
  char                  *ref_type;  
  char                  *propnames = NULL;
  char                   strnames[ID_SIZE+1];
  logical                term = NO;
BEGINSEQ
  if ( IsInitialized() )                             LEAVESEQ
    
  propnames = strdup(GPH("sys_ident")->GetString());
    
  SetupFromParent();
  
  if ( !my_class->Get(FIRST_INSTANCE) )              ERROR
    
  pc_ADK_Class   new_class(GetObjectHandle(),PI_Update);  
  PropertyHandle extent(GetObjectHandle(),"SDB_Extend",PI_Read);  
  PropertyHandle phpropnames(propnames);
  pc_ADK_Class    structure(*my_class);  
  if ( member = structure.GetMember(propnames) )
  {
    if ( !(fc = new_class.ProvideDefaultControl(member,hgrow,vgrow)) ||
         !fc->Exist()  )                             ERROR
    coll_opt = pc0_SDB_Member(member).IsMultipleRef() ? YES : NO;
    ref_type = "DRT_PropertyPath";
    strcpy(strnames,member->GetString("ddetype"));
  }
  else if ( extent.Get(phpropnames) )
  {
    if ( !(fc = new_class.ProvideDefaultControl(&extent,hgrow,vgrow)) ||
         !fc->Exist()  )                             ERROR
    coll_opt = YES;
    ref_type = "DRT_Extent";
    strcpy(strnames,extent.GetString("ddetype"));
  }
  else                                               ERROR
    
  if ( !hgrow )
    *GPH("allign.hori_sizing") = "SIZE_Fixed";
  if ( !vgrow )
    *GPH("allign.vert_sizing") = "SIZE_Fixed";
  
  *GPH("auto_open") = YES;
  SetupDataSource(propnames,ref_type,coll_opt);
  SetupFromFieldControl(fc);
  SetupTitle(propnames);

  GPH("class")->Add(new_class.ExtractKey());        CTXCERR
  GPH("field_control")->Add(fc->ExtractKey());      CTXCERR


RECOVER
  term = YES;
ENDSEQ
  if ( propnames )
    free(propnames);
  return(term);
}
예제 #5
0
static void LoadColorFile(HWND hWnd)
   {  
   // RB 10/15/2000: Init directory string
   if (fdir[0]==_T('\0')) {
      _tcscpy(fdir, GetCOREInterface()->GetDir(APP_IMAGE_DIR));
      }

   OPENFILENAME ofn;
   memset(&ofn,0,sizeof(ofn));
   FilterList fl;
   fl.Append(GetString(IDS_RB_COLORCLIPFILES));
   fl.Append(_T("*.ccb"));
   TSTR title = GetString(IDS_RB_LOADCOLOR);
   ofn.lStructSize     = sizeof(OPENFILENAME);  // No OFN_ENABLEHOOK
   ofn.hwndOwner       = hWnd;
   ofn.lpstrFilter     = fl;
   ofn.lpstrFile       = fname;
   ofn.nMaxFile        = 256;    
   ofn.lpstrInitialDir = fdir;
   ofn.Flags           = OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST;
   ofn.FlagsEx         = OFN_EX_NOPLACESBAR;
   ofn.lpstrDefExt     = _T("ccb");
   ofn.lpstrTitle      = title;

   if (GetOpenFileName(&ofn)) {
      MaxSDK::Util::TextFile::Reader file;	
      if(!file.Open(fname)) {
         TSTR buf2 = GetString(IDS_RB_COLORCLIPBOARD);
         TSTR buf1;
         buf1.printf(GetString(IDS_RB_CANTOPENFILE),fname);       
         MessageBox(hWnd,buf1,buf2,MB_ICONEXCLAMATION);
         return;
         }
      TSTR colorLine;
      // pre-R6
      for (int i=0; i<12; i++) {
         int r, g, b;
		 colorLine = file.ReadLine();
		 if(EOF == _stscanf(colorLine, _T("%d %d %d\n"), &r, &g, &b)) break;
         Color color(float(r)/255.0f,float(g)/255.0f,float(b)/255.0f);
         TSTR name;
         name.printf(GetString(IDS_RB_COLORNUM),i);
         IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i]),color,name);
         ReleaseIColorSwatch(cs);
         }     
      
      // post-R6
      for (int i=0; i<12; i++) {
         float r, g, b, a;
		 colorLine = file.ReadLine();
         if(EOF == _stscanf(colorLine, _T("%f %f %f %f\n"),&r, &g, &b, &a)) break;
         AColor color(r,g,b,a);
         TSTR name;
         name.printf(GetString(IDS_RB_COLORNUM),i);
         IColorSwatch *cs = GetIColorSwatch(GetDlgItem(hWnd,csIDs[i]),color,name);
         ReleaseIColorSwatch(cs);
      }     

      file.Close();

      TSTR *fileName = DLGetWindowLongPtr<TSTR*>(hWnd);
      delete fileName;
      fileName = new TSTR(fname);
      DLSetWindowLongPtr(hWnd, fileName);
      SetupTitle(hWnd,*fileName);
      }  
   }