#include "stdafx.h" #include "common.h" void GetDefaultEditFont(LOGFONT *pLogFont){ #if defined(JPN) //日本語 pLogFont->lfHeight=-13; pLogFont->lfWidth=0; pLogFont->lfEscapement=0; pLogFont->lfOrientation=0; pLogFont->lfWeight=400; pLogFont->lfItalic=NULL; pLogFont->lfUnderline=NULL; pLogFont->lfStrikeOut=NULL; pLogFont->lfCharSet=SHIFTJIS_CHARSET; pLogFont->lfOutPrecision=OUT_STRING_PRECIS; pLogFont->lfClipPrecision=CLIP_STROKE_PRECIS; pLogFont->lfQuality=DRAFT_QUALITY; pLogFont->lfPitchAndFamily=FIXED_PITCH; sprintf(pLogFont->lfFaceName,"MS ゴシック"); #else //英語 pLogFont->lfHeight=-15; pLogFont->lfWidth=0; pLogFont->lfEscapement=0; pLogFont->lfOrientation=0; pLogFont->lfWeight=400; pLogFont->lfItalic=NULL; pLogFont->lfUnderline=NULL; pLogFont->lfStrikeOut=NULL; pLogFont->lfCharSet=ANSI_CHARSET; pLogFont->lfOutPrecision=OUT_STRING_PRECIS; pLogFont->lfClipPrecision=CLIP_STROKE_PRECIS; pLogFont->lfQuality=DRAFT_QUALITY; pLogFont->lfPitchAndFamily=FIXED_PITCH; sprintf(pLogFont->lfFaceName,"Courier New"); #endif } void GetDefaultHintFont(LOGFONT *pLogFont){ #if defined(JPN) //日本語 pLogFont->lfHeight=-12; pLogFont->lfWidth=0; pLogFont->lfEscapement=0; pLogFont->lfOrientation=0; pLogFont->lfWeight=FW_THIN; pLogFont->lfItalic=NULL; pLogFont->lfUnderline=NULL; pLogFont->lfStrikeOut=NULL; pLogFont->lfCharSet=ANSI_CHARSET; pLogFont->lfOutPrecision=OUT_STRING_PRECIS; pLogFont->lfClipPrecision=CLIP_STROKE_PRECIS; pLogFont->lfQuality=DRAFT_QUALITY; pLogFont->lfPitchAndFamily=VARIABLE_PITCH; sprintf(pLogFont->lfFaceName,"MS Pゴシック"); #else //英語 pLogFont->lfHeight=-12; pLogFont->lfWidth=0; pLogFont->lfEscapement=0; pLogFont->lfOrientation=0; pLogFont->lfWeight=FW_THIN; pLogFont->lfItalic=NULL; pLogFont->lfUnderline=NULL; pLogFont->lfStrikeOut=NULL; pLogFont->lfCharSet=ANSI_CHARSET; pLogFont->lfOutPrecision=OUT_STRING_PRECIS; pLogFont->lfClipPrecision=CLIP_STROKE_PRECIS; pLogFont->lfQuality=DRAFT_QUALITY; pLogFont->lfPitchAndFamily=VARIABLE_PITCH; sprintf(pLogFont->lfFaceName,"Arial"); #endif } void GetDefaultPrintFont(LOGFONT *pLogFont){ pLogFont->lfHeight=0; //iPrintFontPointSizeとデバイス情報により決まる pLogFont->lfWidth=0; pLogFont->lfEscapement=0; pLogFont->lfOrientation=0; pLogFont->lfWeight=FW_NORMAL; pLogFont->lfItalic=NULL; pLogFont->lfUnderline=NULL; pLogFont->lfStrikeOut=NULL; pLogFont->lfCharSet=SHIFTJIS_CHARSET; pLogFont->lfOutPrecision=OUT_STRING_PRECIS; pLogFont->lfClipPrecision=CLIP_STROKE_PRECIS; pLogFont->lfQuality=DRAFT_QUALITY; pLogFont->lfPitchAndFamily=FIXED_PITCH; lstrcpy(pLogFont->lfFaceName,"MS ゴシック"); } /////////////////////////// // 不揮発性のデータ管理 /////////////////////////// CNonVolatile::CNonVolatile(){ memset(this,0,sizeof(CNonVolatile)); //拡張子管理オブジェクトを生成 pobj_ExtLink=new CExtLink(); //Web検索用ドメイン管理オブジェクトを生成 pobj_DBDomain=new CDBDomain(); //「最近使ったファイル」オブジェクトを生成 pobj_History=new CHistory(100); //「最近使ったプロジェクト」オブジェクトを生成 pobj_ProjectHistory=new CHistory(200); } CNonVolatile::~CNonVolatile(){ //拡張子管理オブジェクトを破棄 delete pobj_ExtLink; pobj_ExtLink=0; //Web検索用ドメイン管理オブジェクトを破棄 delete pobj_DBDomain; pobj_DBDomain=0; //「最近使ったファイル」オブジェクトを破棄 delete pobj_History; pobj_History=0; //「最近使ったプロジェクト」オブジェクトを破棄 delete pobj_ProjectHistory; pobj_ProjectHistory=0; } BOOL CSettingFile::GetDataLine( const char *name,char *parms){ int i,i2,length; length=lstrlen(name); for(i=0;;i++){ if(buffer[i]=='\0') break; if(i==0||buffer[i]=='\r'&&buffer[i+1]=='\n'){ if(buffer[i]=='\r'&&buffer[i+1]=='\n') i+=2; if(memcmp(buffer+i,name,length)==0&&buffer[i+length]=='='){ i+=length+1; for(i2=0;;i++,i2++){ if(buffer[i]=='\r'&&buffer[i+1]=='\n'||buffer[i]=='\0'){ parms[i2]=0; break; } parms[i2]=buffer[i]; } return 1; } } } return 0; } BOOL CSettingFile::GetWholeValue( const char *name, int *pi32data ){ char temporary[8192]; if(!GetDataLine(name,temporary)) return 0; *pi32data=atoi(temporary); return 1; } bool CSettingFile::GetBoolean( const char *name,bool &b ){ int i=0; if( !GetWholeValue( name, &i ) ){ return 0; } b = ( i != 0 ) ? true:false; return 1; } BOOL CSettingFile::Get3WholeValue(char *name,int *pd1,int *pd2,int *pd3){ char temporary[8192]; if(!GetDataLine(name,temporary)) return 0; sscanf(temporary,"%d,%d,%d",pd1,pd2,pd3); return 1; } BOOL CSettingFile::GetRGBValue(char *name,COLORREF *prgb){ char temporary[8192]; if(!GetDataLine(name,temporary)) return 0; sscanf(temporary,"%x",prgb); return 1; } BOOL CSettingFile::GetStringValue(char *name,char *str){ if(!GetDataLine(name,str)) return 0; return 1; } BOOL CSettingFile::GetRectValue(char *name,RECT *prc){ char temporary[8192]; if(!GetDataLine(name,temporary)) return 0; sscanf(temporary,"%d,%d,%d,%d",&prc->left,&prc->top,&prc->right,&prc->bottom); return 1; } BOOL CSettingFile::GetLogFont(char *name,LOGFONT *plf){ char temporary[8192]; if(!GetDataLine(name,temporary)) return 0; sscanf(temporary,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &plf->lfHeight, &plf->lfWidth, &plf->lfEscapement, &plf->lfOrientation, &plf->lfWeight, &plf->lfItalic, &plf->lfUnderline, &plf->lfStrikeOut, &plf->lfCharSet, &plf->lfOutPrecision, &plf->lfClipPrecision, &plf->lfQuality, &plf->lfPitchAndFamily); int i; for(i=lstrlen(temporary)-1;i>=0;i--){ if(temporary[i]==','){ i++; break; } } lstrcpy(plf->lfFaceName,temporary+i); return 1; } BOOL CSettingFile::GetRebarBand(SAVEREBAR *psr,int num){ char name[32]; char temporary[8192]; sprintf(name,"RebarBand%d",num); if(!GetDataLine(name,temporary)) return 0; sscanf(temporary,"%d,%d,%d",&psr->RebarID,&psr->RebarLength,&psr->IsBandBreak); return 1; } void CNonVolatile::load(){ extern METHODCHECKINFO MethodCheckInfo; int i; char temporary[MAX_PATH]; std::string userAppDir = ActiveBasic::IDE::Program::GetUserAppDir(); /////////////////////////////////// // 関連付け用の拡張子オブジェクト /////////////////////////////////// pobj_ExtLink->load( userAppDir + "\\extlink.ini" ); /////////////////////////////////////// // 「最近使ったファイル」オブジェクト /////////////////////////////////////// pobj_History->load( userAppDir + "\\history.ini" ); //////////////////////////////////////////// // 「最近使ったプロジェクト」オブジェクト //////////////////////////////////////////// pobj_ProjectHistory->load( userAppDir + "\\pj_history.ini" ); //開く buffer=ReadBuffer_NonErrMsg( userAppDir + "\\editor.ini" ); if(!buffer){ //デフォルトの初期設定 InitToDefaultData(); return; } //関連付けを行うかどうか(この関数の最後に呼び出す) if(!GetStringValue("LinkFile",temporary)){ ExtensionLink(NULL); } //ウィンドウサイズを保存するかしないか if(!GetRectValue("WindowRect",&StartupWindowRect)){ StartupWindowRect.left=(int)((double)ScreenX*0.1); StartupWindowRect.top=(int)((double)ScreenX*0.1); StartupWindowRect.right=(int)((double)ScreenX*0.8); StartupWindowRect.bottom=(int)((double)ScreenY*0.8); } //ウィンドウを最大化するか if(!GetWholeValue("IsWindowMax",&bWindowMax)) bWindowMax=0; //実行時のプロジェクトの保存確認の有無 if(!GetWholeValue("Project_SaveCheck",&bSaveCheckProject)) bSaveCheckProject=0; //ラインアジャスタ if(!GetWholeValue("Rad_LineAdjust",&bLineAdjust)) bLineAdjust=1; //ProjectView位置情報 if(!GetRectValue("ProjectViewRect",&rectProjectView)){ rectProjectView.left=StartupWindowRect.right-270; rectProjectView.right=StartupWindowRect.right-5; rectProjectView.top=StartupWindowRect.top+60; rectProjectView.bottom=StartupWindowRect.top+380; } if(rectProjectView.right<=0|| rectProjectView.left>=ScreenX|| rectProjectView.bottom<=0|| rectProjectView.top>=ScreenY|| rectProjectView.right-rectProjectView.left<10|| rectProjectView.bottom-rectProjectView.top<10){ //不正なデータは復元 rectProjectView.left=StartupWindowRect.right-270; rectProjectView.right=StartupWindowRect.right-5; rectProjectView.top=StartupWindowRect.top+60; rectProjectView.bottom=StartupWindowRect.top+380; } //ProjectViewクリップ情報 if(!GetWholeValue("IsClipProjectView",&bClipProjectView)) bClipProjectView=1; if(!GetWholeValue("width_ClipProjectView",&width_ClipProjectView)) width_ClipProjectView=200; //デバッガビュー クリップ情報 if(!GetWholeValue("height_ClipDebuggerView",&height_ClipDebuggerView)) height_ClipDebuggerView=180; //コンパイラビュー クリップ情報 if(!GetWholeValue("height_ClipCompileView",&height_ClipCompileView)) height_ClipCompileView=130; //Web検索クリップ情報 if(!GetWholeValue("width_WebSearchView",&width_WebSearchView)) width_WebSearchView=230; //Rebarバンド情報 for(i=0;ileft,prc->top,prc->right,prc->bottom); } void CSettingFile::SetLogFont(char *name,LOGFONT *plf){ sprintf(buffer+lstrlen(buffer),"%s=%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s\r\n",name, plf->lfHeight, plf->lfWidth, plf->lfEscapement, plf->lfOrientation, plf->lfWeight, plf->lfItalic, plf->lfUnderline, plf->lfStrikeOut, plf->lfCharSet, plf->lfOutPrecision, plf->lfClipPrecision, plf->lfQuality, plf->lfPitchAndFamily, plf->lfFaceName); } void CSettingFile::SetRebarBand(SAVEREBAR *psr,int num){ char name[32]; sprintf(name,"RebarBand%d",num); sprintf(buffer+lstrlen(buffer),"%s=%d,%d,%d\r\n",name,psr->RebarID,psr->RebarLength,psr->IsBandBreak); } void CNonVolatile::save(){ int i; // ユーザ情報保存用のディレクトリを作成 Jenga::Common::Directory dir( ActiveBasic::IDE::Program::GetUserAppDir(), true ); buffer=(char *)HeapAlloc(hHeap,0,65536); buffer[0]=0; //ウィンドウサイズを保存するかしないか SetRectValue("WindowRect",&StartupWindowRect); //ウィンドウを最大化するか SetWholeValue("IsWindowMax",bWindowMax); //実行時のプロジェクトの保存確認の有無 SetWholeValue("Project_SaveCheck",bSaveCheckProject); //ラインアジャスタ SetWholeValue("Rad_LineAdjust",bLineAdjust); //ProjectView位置情報 SetRectValue("ProjectViewRect",&rectProjectView); //ProjectViewクリップ情報 SetWholeValue("IsClipProjectView",bClipProjectView); SetWholeValue("width_ClipProjectView",width_ClipProjectView); //デバッガビュー クリップ情報 SetWholeValue("height_ClipDebuggerView",height_ClipDebuggerView); //コンパイラビュー クリップ情報 SetWholeValue("height_ClipCompileView",height_ClipCompileView); //Web検索クリップ情報 SetWholeValue("width_WebSearchView",width_WebSearchView); //Rebar情報 for(i=0;ibSaveFindStr){ for(i=0;ibSaveFindStr){ for(i=0;ibSaveWebFindStr){ for(i=0;isave( userAppDir + "\\extlink.ini" ); /////////////////////////////////////// // 「最近使ったファイル」オブジェクト /////////////////////////////////////// pobj_History->save( userAppDir + "\\history.ini" ); /////////////////////////////////////// // 「最近使ったファイル」オブジェクト /////////////////////////////////////// pobj_ProjectHistory->save( userAppDir + "\\pj_history.ini" ); }