source: dev/trunk/ab5.0/abdev/ProjectEditor/DesignTheme.cpp@ 478

Last change on this file since 478 was 477, checked in by dai_9181, 17 years ago

構成管理を大幅に改良。

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