source: dev/ProjectEditor/DesignTheme.cpp@ 87

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

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

File size: 4.2 KB
RevLine 
[3]1#include "common.h"
2
3
4CDBTheme *pobj_DBTheme;
5
6
7CTheme::CTheme(char *path,char *name){
8 bActive=0;
9 lstrcpy(m_name,name);
10 if(path==0) return;
11
12 buffer=ReadBuffer(path);
13
14
15 //通常の文字色
16 GetRGBValue("rgbDefault",&TextColorInfo.rgbDefault);
17
18 //コメント文字色
19 GetRGBValue("rgbComment",&TextColorInfo.rgbComment);
20
21 //特殊ステートメント
22 GetRGBValue("rgbStatement",&TextColorInfo.rgbStatement);
23
24 //文字列色
25 GetRGBValue("rgbString",&TextColorInfo.rgbString);
26
27 //背景色(カーソル行)
28 GetRGBValue("rgbCursorBack",&TextColorInfo.rgbCursorBack);
29
30 //背景色(一般)
31 GetRGBValue("rgbBackground",&TextColorInfo.rgbBackground);
32
33 //背景画像
34 if(!GetStringValue("BackgroundImagePath",szBackgroundImagePath)) szBackgroundImagePath[0]=0;
35
36 HeapDefaultFree(buffer);
37}
38CTheme::CTheme(){
39 CTheme(0,THEMENAME_USER);
40}
41CTheme::~CTheme(){
42}
43
44void CTheme::save(){
45 buffer=(char *)HeapAlloc(hHeap,0,65536);
46 buffer[0]=0;
47
48
49 //通常の文字色
50 SetRGBValue("rgbDefault",TextColorInfo.rgbDefault);
51
52 //コメント文字色
53 SetRGBValue("rgbComment",TextColorInfo.rgbComment);
54
55 //特殊ステートメント
56 SetRGBValue("rgbStatement",TextColorInfo.rgbStatement);
57
58 //文字列色
59 SetRGBValue("rgbString",TextColorInfo.rgbString);
60
61 //背景色(カーソル行)
62 SetRGBValue("rgbCursorBack",TextColorInfo.rgbCursorBack);
63
64 //背景色(一般)
65 SetRGBValue("rgbBackground",TextColorInfo.rgbBackground);
66
67 //背景画像
68 SetStringValue("BackgroundImagePath",szBackgroundImagePath);
69
70 char path[MAX_PATH];
71 sprintf(path,"%sTheme\\%s",pj_editor_Dir,m_name);
[22]72 if(!IsExistFile(path)){
[3]73 CreateDirectory(path,NULL);
74 }
75
76 sprintf(path,"%sTheme\\%s\\design.ini",pj_editor_Dir,m_name);
77 WriteBuffer(path,buffer,lstrlen(buffer));
78
79 HeapDefaultFree(buffer);
80}
81
82
83CDBTheme::CDBTheme(){
84 hBackBmp=0;
85
86 iNum=0;
87 ppobj_Theme=(CTheme **)HeapAlloc(hHeap,0,1);
88
89 char temporary[MAX_PATH];
90 sprintf(temporary,"%sTheme\\*",pj_editor_Dir);
91
92 HANDLE hFind;
93 WIN32_FIND_DATA wfd;
94 hFind=FindFirstFile(temporary,&wfd);
95 if(hFind!=INVALID_HANDLE_VALUE){
96 do{
97 if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
98 if(!(lstrcmp(wfd.cFileName,".")==0||lstrcmp(wfd.cFileName,"..")==0)){
99 //ディレクトリのとき
100 sprintf(temporary,"%sTheme\\%s\\design.ini",pj_editor_Dir,wfd.cFileName);
[22]101 if(IsExistFile(temporary)){
[3]102 add(temporary,wfd.cFileName);
103 }
104 }
105 }
106 else{
107 //ファイルのとき
108 //無視
109 }
110 }while(FindNextFile(hFind,&wfd));
111 }
112}
113CDBTheme::~CDBTheme(){
114 int i;
115 for(i=0;i<iNum;i++){
116 delete ppobj_Theme[i];
117 }
118 HeapDefaultFree(ppobj_Theme);
119
120 unlock();
121}
122
123CTheme *CDBTheme::dupli_check(char *name){
124 //重複チェック
125 int i;
126 for(i=0;i<iNum;i++){
127 if(lstrcmpi(ppobj_Theme[i]->m_name,name)==0){
128 return ppobj_Theme[i];
129 }
130 }
131 return 0;
132}
133
134CTheme *CDBTheme::add(char *path,char *name){
135 ppobj_Theme=(CTheme **)HeapReAlloc(hHeap,0,ppobj_Theme,(iNum+1)*sizeof(CTheme *));
136 ppobj_Theme[iNum]=new CTheme(path,name);
137 iNum++;
138
139 return ppobj_Theme[iNum-1];
140}
141void CDBTheme::ResetTheme_ToComboBox(HWND hCombo){
142 int i;
143 for(i=0;i<iNum;i++){
144 SendMessage(hCombo,CB_ADDSTRING,0,(LPARAM)ppobj_Theme[i]->m_name);
145 }
146
147 //選択する
148 for(i=0;i<iNum;i++){
149 if(lstrcmp(ppobj_Theme[i]->m_name,pobj_nv->szActiveTheme)==0){
150 i=SendMessage(hCombo,CB_FINDSTRINGEXACT,0,(LPARAM)ppobj_Theme[i]->m_name);
151 SendMessage(hCombo,CB_SETCURSEL,i,0);
152 break;
153 }
154 }
155}
156CTheme *CDBTheme::GetActiveTheme(){
157 int i;
158 for(i=0;i<iNum;i++){
159 if(lstrcmp(ppobj_Theme[i]->m_name,pobj_nv->szActiveTheme)==0){
160 return ppobj_Theme[i];
161 }
162 }
163 return 0;
164}
165
166void CDBTheme::lock(void){
167 CTheme *pobj_Theme;
168 pobj_Theme=GetActiveTheme();
169
170 if(pobj_Theme->szBackgroundImagePath[0]=='\0'){
171 hBackBmp=0;
172 return;
173 }
174
175 char szThemeDir[MAX_PATH];
176 sprintf(szThemeDir,"%sTheme\\%s\\",pj_editor_Dir,pobj_Theme->m_name);
177
178 char temporary[MAX_PATH];
179 lstrcpy(temporary,pobj_Theme->szBackgroundImagePath);
180 GetFullPath(temporary,szThemeDir);
181
182 hBackBmp=(HBITMAP)LoadImage(0,temporary,IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
183
184 BITMAP Bitmap;
185 GetObject(hBackBmp,sizeof(BITMAP),&Bitmap);
186 sizeBackBmp.cx=Bitmap.bmWidth;
187 sizeBackBmp.cy=Bitmap.bmHeight;
188}
189void CDBTheme::unlock(void){
190 if(hBackBmp) DeleteObject(hBackBmp);
191}
Note: See TracBrowser for help on using the repository browser.