NCBI C++ ToolKit
ptb_gui.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: ptb_gui.cpp 56520 2012-12-11 15:51:23Z gouriano $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Andrei Gourianov
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 #include "proj_builder_app.hpp"
32 #include "ptb_gui.h"
33 
35 
36 #if defined(NCBI_OS_MSWIN)
37 
38 #define COMPILE_MULTIMON_STUBS
39 #include <multimon.h>
40 
41 /////////////////////////////////////////////////////////////////////////////
42 
43 void CenterWindow(HWND hWnd);
44 BOOL UpdateData(HWND hDlg, CProjBulderApp* pApp, BOOL bGet);
45 INT_PTR CALLBACK PtbConfigDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
46 
47 /////////////////////////////////////////////////////////////////////////////
48 
49 void CenterWindow(HWND hWnd)
50 {
51  RECT rcWnd;
52  GetWindowRect(hWnd, &rcWnd);
53  MONITORINFO mi;
54  mi.cbSize = sizeof(mi);
55  GetMonitorInfo( MonitorFromWindow( hWnd, MONITOR_DEFAULTTOPRIMARY), &mi);
56  int xLeft = (mi.rcMonitor.left + mi.rcMonitor.right - rcWnd.right + rcWnd.left)/2;
57  int yTop = (mi.rcMonitor.top + mi.rcMonitor.bottom - rcWnd.bottom + rcWnd.top )/2;
58  SetWindowPos(hWnd, NULL, xLeft, yTop, -1, -1,
59  SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
60 }
61 
63 {
64  if (bGet) {
65  char szBuf[MAX_PATH];
66 
67  GetDlgItemTextA( hDlg,IDC_EDIT_ROOT, szBuf, sizeof(szBuf)); pApp->m_Root = szBuf;
68  GetDlgItemTextA( hDlg,IDC_EDIT_SUBTREE, szBuf, sizeof(szBuf)); pApp->m_Subtree = szBuf;
69  GetDlgItemTextA( hDlg,IDC_EDIT_SLN, szBuf, sizeof(szBuf)); pApp->m_Solution = szBuf;
70  GetDlgItemTextA( hDlg,IDC_EDIT_EXTROOT, szBuf, sizeof(szBuf)); pApp->m_BuildRoot = szBuf;
71  GetDlgItemTextA( hDlg,IDC_EDIT_PROJTAG, szBuf, sizeof(szBuf)); pApp->m_ProjTags = szBuf;
72 
73  GetDlgItemTextA( hDlg,IDC_EDIT_3PARTY, szBuf, sizeof(szBuf));
74  pApp->m_CustomConfiguration.AddDefinition("ThirdPartyBasePath", szBuf);
75  GetDlgItemTextA( hDlg,IDC_EDIT_CNCBI, szBuf, sizeof(szBuf));
76  pApp->m_CustomConfiguration.AddDefinition("ThirdParty_C_ncbi", szBuf);
77 
78  pApp->m_Dll = IsDlgButtonChecked(hDlg,IDC_CHECK_DLL) == BST_CHECKED;
79  pApp->m_BuildPtb = IsDlgButtonChecked(hDlg,IDC_CHECK_NOPTB) != BST_CHECKED;
80  pApp->m_AddMissingLibs = IsDlgButtonChecked(hDlg,IDC_CHECK_EXT) == BST_CHECKED;
81  pApp->m_ScanWholeTree = IsDlgButtonChecked(hDlg,IDC_CHECK_NWT) != BST_CHECKED;
82  pApp->m_TweakVTuneR = IsDlgButtonChecked(hDlg,IDC_CHECK_VTUNER) == BST_CHECKED;
83  pApp->m_TweakVTuneD = IsDlgButtonChecked(hDlg,IDC_CHECK_VTUNED) == BST_CHECKED;
84  } else {
85 
86  SetDlgItemTextA( hDlg,IDC_EDIT_ROOT, pApp->m_Root.c_str());
87  SetDlgItemTextA( hDlg,IDC_EDIT_SUBTREE, pApp->m_Subtree.c_str());
88  SetDlgItemTextA( hDlg,IDC_EDIT_SLN, pApp->m_Solution.c_str());
89  SetDlgItemTextA( hDlg,IDC_EDIT_EXTROOT, pApp->m_BuildRoot.c_str());
90  SetDlgItemTextA( hDlg,IDC_EDIT_PROJTAG, pApp->m_ProjTags.c_str());
91 
92  SetDlgItemTextA( hDlg,IDC_EDIT_PTBINI2, pApp->m_CustomConfFile.c_str());
93  string v;
94  if (pApp->m_CustomConfiguration.GetValue("ThirdPartyBasePath", v)) {
95  SetDlgItemTextA( hDlg,IDC_EDIT_3PARTY, v.c_str());
96  }
97  if (pApp->m_CustomConfiguration.GetValue("ThirdParty_C_ncbi", v)) {
98  SetDlgItemTextA( hDlg,IDC_EDIT_CNCBI, v.c_str());
99  }
100 
101  CheckDlgButton( hDlg,IDC_CHECK_DLL, pApp->m_Dll);
102  CheckDlgButton( hDlg,IDC_CHECK_NOPTB, !pApp->m_BuildPtb);
103  CheckDlgButton( hDlg,IDC_CHECK_EXT, pApp->m_AddMissingLibs);
104  CheckDlgButton( hDlg,IDC_CHECK_NWT, !pApp->m_ScanWholeTree);
105  CheckDlgButton( hDlg,IDC_CHECK_VTUNER, pApp->m_TweakVTuneR);
106  CheckDlgButton( hDlg,IDC_CHECK_VTUNED, pApp->m_TweakVTuneD);
107  }
108  return TRUE;
109 }
110 
111 INT_PTR CALLBACK PtbConfigDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
112 {
113  switch (uMsg) {
114  case WM_INITDIALOG:
115  SetWindowLongPtr( hDlg, DWLP_USER, lParam );
116  UpdateData( hDlg,(CProjBulderApp*)lParam,FALSE );
117  CenterWindow(hDlg);
118  SetFocus( GetDlgItem(hDlg,IDOK));
119  break;
120  case WM_COMMAND:
121  switch (wParam) {
122  case IDOK:
123  if (UpdateData( hDlg,(CProjBulderApp*)GetWindowLongPtr(hDlg,DWLP_USER),TRUE )) {
124  EndDialog(hDlg,IDOK);
125  }
126  break;
127  case IDCANCEL:
128  EndDialog(hDlg,IDCANCEL);
129  break;
130  default:
131  break;
132  }
133  break;
134 /*
135  case WM_NCHITTEST:
136  SetWindowLong(hDlg, DWL_MSGRESULT, HTCAPTION);
137  return TRUE;
138 */
139  default:
140  break;
141  }
142  return FALSE;
143 }
144 
145 #endif
146 
148 {
149 #if defined(NCBI_OS_MSWIN)
150  bool result = ( DialogBoxParam( GetModuleHandle(NULL),
151  MAKEINTRESOURCE(IDD_PTB_GUI_DIALOG),
153  (LPARAM)(LPVOID)this) == IDOK);
154  if (result) {
155  m_CustomConfiguration.AddDefinition("__TweakVTuneR", m_TweakVTuneR ? "yes" : "no");
156  m_CustomConfiguration.AddDefinition("__TweakVTuneD", m_TweakVTuneD ? "yes" : "no");
158  }
159  return result;
160 #else
161  return true;
162 #endif
163 }
164 
166 {
168  return true;
169  }
170 
171  cout << "*PTBGUI{* custom" << endl;
172  list<string> skip;
173  skip.push_back("__AllowedProjects");
174  m_CustomConfiguration.Dump(cout, &skip);
175  cout << "*PTBGUI}* custom" << endl;
176 
177  bool started = false;
178  char buf[512];
179  for (;;) {
180  cin.getline(buf, sizeof(buf));
181  string s(buf);
182  if (NStr::StartsWith(s, "*PTBGUI{*")) {
183  started = true;
184  continue;
185  }
186  if (NStr::StartsWith(s, "*PTBGUIabort*")) {
187  return false;
188  }
189  if (NStr::StartsWith(s, "*PTBGUI}*")) {
190  started = false;
191  break;;
192  }
193  if (started) {
194  string s1, s2;
195  if (NStr::SplitInTwo(s,"=", s1, s2)) {
199  }
200  }
201  }
202 // m_CustomConfiguration.Save(m_CustomConfFile);
204  string v;
205  if (m_CustomConfiguration.GetValue("__TweakVTuneR", v)) {
207  }
208  if (m_CustomConfiguration.GetValue("__TweakVTuneD", v)) {
210  }
211  m_AddUnicode = GetSite().IsProvided("Ncbi_Unicode", false) ||
212  GetSite().IsProvided("Ncbi-Unicode", false);
213  if ( m_MsvcRegSettings.get() ) {
214  GetBuildConfigs(&m_MsvcRegSettings->m_ConfigInfo);
215  }
216  }
217  return true;
218 }
219 
221 {
222  string prjid;
223  cout << "*PTBGUI{* projects" << endl;
224  ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) {
225 /*
226  if (p->second.m_MakeType == eMakeType_Excluded ||
227  p->second.m_MakeType == eMakeType_ExcludedByReq) {
228  continue;
229  }
230 */
231  if (p->first.Type() == CProjKey::eDll ||
232  p->first.Type() == CProjKey::eDataSpec) {
233  continue;
234  }
235  prjid = CreateProjectName(p->first);
236  cout << prjid << ",";
237  if (p->first.Type() == CProjKey::eLib ||
238  p->first.Type() == CProjKey::eDll) {
239  cout << "lib";
240  } else if (p->first.Type() == CProjKey::eApp) {
241  cout << "app";
242  } else {
243  cout << "other";
244  }
245  cout << ",";
246 
247  if (m_CustomConfiguration.DoesValueContain( "__AllowedProjects", prjid)) {
248  cout << "select";
249  } else {
250  cout << "unselect";
251  }
252  cout << "," << NStr::Replace(p->second.m_SourcesBaseDir,"\\","/");
253  cout << "," << NStr::Join(p->second.m_ProjTags,"/");
254  cout << endl;
255  }
256  cout << "*PTBGUI}* projects" << endl;
257 
258  bool started = false;
259  char buf[512];
260  list<string> prj;
261  for (;;) {
262  cin.getline(buf, sizeof(buf));
263  string s(buf);
264  if (NStr::StartsWith(s, "*PTBGUI{*")) {
265  started = true;
266  continue;
267  }
268  if (NStr::StartsWith(s, "*PTBGUIabort*")) {
269  return false;
270  }
271  if (NStr::StartsWith(s, "*PTBGUI}*")) {
272  started = false;
273  break;;
274  }
275  if (started) {
277  prj.push_back(s);
278  }
279  }
280  m_CustomConfiguration.AddDefinition("__AllowedProjects", NStr::Join(prj," "));
282  return true;
283 }
284 
285 
static EMsvcPlatform GetMsvcPlatform(void)
bool IsProvided(const string &thing, bool deep=true, const SConfigInfo *cfg=nullptr) const
Definition: msvc_site.cpp:203
CProjBulderApp –.
void GetBuildConfigs(list< SConfigInfo > *configs)
CSimpleMakeFileContents m_CustomConfiguration
bool Gui_ConfirmProjects(CProjectItemsTree &projects_tree)
Definition: ptb_gui.cpp:220
bool ConfirmConfiguration(void)
Definition: ptb_gui.cpp:147
unique_ptr< CMsvc7RegSettings > m_MsvcRegSettings
bool Gui_ConfirmConfiguration(void)
Definition: ptb_gui.cpp:165
const CMsvcSite & GetSite(void)
CProjectItemsTree –.
Definition: proj_tree.hpp:54
TProjects m_Projects
Definition: proj_tree.hpp:70
void Dump(CNcbiOstream &ostr, const list< string > *skip=0) const
Debug dump.
bool DoesValueContain(const string &key, const string &value, bool ifnokey=true) const
void AddDefinition(const string &key, const string &value)
bool GetValue(const string &key, string &value) const
void Save(const string &filename) const
void * LPVOID
Definition: sqlfront.h:38
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool StringToBool(const CTempString str)
Convert string to bool.
Definition: ncbistr.cpp:2819
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3197
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3310
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3550
char * buf
string CreateProjectName(const CProjKey &project_id)
Project naming schema.
INT_PTR CALLBACK PtbConfigDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ptb_gui.cpp:111
void CenterWindow(HWND hWnd)
Definition: ptb_gui.cpp:49
BOOL UpdateData(HWND hDlg, CProjBulderApp *pApp, BOOL bGet)
Definition: ptb_gui.cpp:62
#define IDC_CHECK_NOPTB
Definition: ptb_gui.h:10
#define IDD_PTB_GUI_DIALOG
Definition: ptb_gui.h:1
#define IDC_EDIT_PTBINI2
Definition: ptb_gui.h:21
#define IDC_EDIT_PROJTAG
Definition: ptb_gui.h:16
#define IDC_EDIT_SLN
Definition: ptb_gui.h:8
#define IDC_EDIT_ROOT
Definition: ptb_gui.h:4
#define IDC_CHECK_EXT
Definition: ptb_gui.h:11
#define IDC_CHECK_NWT
Definition: ptb_gui.h:12
#define IDC_EDIT_CNCBI
Definition: ptb_gui.h:25
#define IDC_EDIT_EXTROOT
Definition: ptb_gui.h:14
#define IDC_EDIT_3PARTY
Definition: ptb_gui.h:23
#define IDC_CHECK_DLL
Definition: ptb_gui.h:9
#define IDC_EDIT_SUBTREE
Definition: ptb_gui.h:6
#define IDC_CHECK_VTUNED
Definition: ptb_gui.h:19
#define IDC_CHECK_VTUNER
Definition: ptb_gui.h:18
unsigned int UINT
Definition: sqltypes.h:263
void * HWND
Definition: sqltypes.h:73
#define CALLBACK
Definition: sqltypes.h:65
int BOOL
Definition: sybdb.h:150
@ FALSE
Definition: testodbc.c:27
@ TRUE
Definition: testodbc.c:27
else result
Definition: token2.c:20
void SetFocus(CRef< objects::CSeq_entry > entry)
Modified on Mon Mar 04 05:11:26 2024 by modify_doxy.py rev. 669887