source: dev/trunk/abdev/ProjectEditor/History.cpp@ 349

Last change on this file since 349 was 22, checked in by dai_9181, 18 years ago

バックアップ用ディレクトリが消去されていたときは、自動生成する。
プロ版の概念を除去。機能制限を解除。

File size: 2.2 KB
Line 
1#include "common.h"
2
3CHistory::CHistory(int BaseID){
4 iNum=0;
5 iMaxHistoryNum=15;
6
7 m_BaseID=BaseID;
8}
9CHistory::~CHistory(){
10 int i;
11 for(i=0;i<iNum;i++){
12 HeapDefaultFree(lpszPath[i]);
13 }
14}
15
16void CHistory::load(char *path){
17 char temporary[MAX_PATH];
18
19 char *buffer;
20 buffer=ReadBuffer_NonErrMsg(path);
21 if(buffer){
22 int i;
23 i=0;
24 while(buffer[i]){
25 //表示名
26 i=GetOneParameter(buffer,i,temporary);
27 if(temporary[0]=='\0') break;
28
29 if(buffer[i]=='\r'&&buffer[i+1]=='\n'){
30 i+=2;
31 }
32
33 add(temporary);
34 }
35 HeapDefaultFree(buffer);
36 }
37}
38void CHistory::save(char *path){
39 char *buffer;
40 buffer=(char *)HeapAlloc(hHeap,0,iNum*MAX_PATH+1);
41 buffer[0]=0;
42
43 int i;
44 for(i=0;i<iNum;i++){
45 sprintf(buffer+lstrlen(buffer),"%s\r\n",lpszPath[i]);
46 }
47
48 WriteBuffer(path,buffer,lstrlen(buffer));
49
50 HeapDefaultFree(buffer);
51}
52void CHistory::add(char *path){
53 lpszPath[iNum]=(char *)HeapAlloc(hHeap,0,lstrlen(path)+1);
54 lstrcpy(lpszPath[iNum],path);
55 iNum++;
56}
57void CHistory::insert(char *path){
58 //重複チェック
59 int i;
60 for(i=0;i<iNum;i++){
61 if(lstrcmpi(path,lpszPath[i])==0) break;
62 }
63 if(i==iNum){
64 //ローテーション
65 for(i=iNum;i>0;i--){
66 lpszPath[i]=lpszPath[i-1];
67 }
68
69 if(iNum+1 == iMaxHistoryNum){
70 //一番古い情報を削除
71 HeapDefaultFree(lpszPath[iNum]);
72 }
73 else iNum++;
74 }
75 else{
76 //ローテーション
77 HeapDefaultFree(lpszPath[i]);
78
79 for(;i>0;i--){
80 lpszPath[i]=lpszPath[i-1];
81 }
82 }
83
84 lpszPath[0]=(char *)HeapAlloc(hHeap,0,lstrlen(path)+1);
85 lstrcpy(lpszPath[0],path);
86}
87
88void CHistory::ResetFileMenu(CSubMenuEx *pobj_SubMenu,BOOL bOwnerDraw){
89 //古いメニューアイテムを消去
90 while(0<pobj_SubMenu->iMenuItemNum){
91 pobj_SubMenu->RemoveItem(0);
92 }
93
94 if(iNum==0){
95 //なし
96 pobj_SubMenu->InsertItem(0,100,"なし");
97 pobj_SubMenu->EnableItem(100,MF_BYCOMMAND|MF_GRAYED);
98 return;
99 }
100
101
102 int i;
103 for(i=0;i<iNum;i++){
104 //挿入
105 pobj_SubMenu->InsertItem(i,m_BaseID+i,lpszPath[i]);
106
107 //アイコンをセット
108 if(IsExistFile(lpszPath[i])){
109 SHFILEINFO shfi;
110 SHGetFileInfo( lpszPath[i], FILE_ATTRIBUTE_ARCHIVE, &shfi, sizeof(SHFILEINFO), SHGFI_ICON | SHGFI_SMALLICON );
111
112 if(shfi.hIcon){
113 pobj_SubMenu->SetIcon(m_BaseID+i,shfi.hIcon);
114 }
115 }
116 }
117}
Note: See TracBrowser for help on using the repository browser.