-rw-r--r-- | SelectURLsDlg.cpp | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/SelectURLsDlg.cpp b/SelectURLsDlg.cpp new file mode 100644 index 0000000..bad1cc2 --- a/dev/null +++ b/SelectURLsDlg.cpp | |||
@@ -0,0 +1,164 @@ | |||
1 | // SelectURLsDlg.cpp : implementation file | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "Dipstick.h" | ||
6 | #include "SelectURLsDlg.h" | ||
7 | |||
8 | #ifdef _DEBUG | ||
9 | #define new DEBUG_NEW | ||
10 | #undef THIS_FILE | ||
11 | static char THIS_FILE[] = __FILE__; | ||
12 | #endif | ||
13 | |||
14 | ///////////////////////////////////////////////////////////////////////////// | ||
15 | // CSelectURLsDlg dialog | ||
16 | |||
17 | |||
18 | CSelectURLsDlg::CSelectURLsDlg(CWnd* pParent /*=NULL*/) | ||
19 | : CDialog(CSelectURLsDlg::IDD, pParent), m_minSize(0,0) | ||
20 | { | ||
21 | //{{AFX_DATA_INIT(CSelectURLsDlg) | ||
22 | m_bAdjustInnermost = FALSE; | ||
23 | m_bAdjust = FALSE; | ||
24 | //}}AFX_DATA_INIT | ||
25 | } | ||
26 | |||
27 | |||
28 | void CSelectURLsDlg::DoDataExchange(CDataExchange* pDX) | ||
29 | { | ||
30 | CDialog::DoDataExchange(pDX); | ||
31 | //{{AFX_DATA_MAP(CSelectURLsDlg) | ||
32 | DDX_Control(pDX, IDC_DOADJUST, m_AdjustCtl); | ||
33 | DDX_Control(pDX, IDC_ADJUSTINN, m_AdjustInnCtl); | ||
34 | DDX_Control(pDX, IDOK, m_OkCtl); | ||
35 | DDX_Control(pDX, IDCANCEL, m_CancelCtl); | ||
36 | DDX_Control(pDX, IDC_URLS, m_URLsCtl); | ||
37 | DDX_Check(pDX, IDC_ADJUSTINN, m_bAdjustInnermost); | ||
38 | DDX_Check(pDX, IDC_DOADJUST, m_bAdjust); | ||
39 | //}}AFX_DATA_MAP | ||
40 | } | ||
41 | |||
42 | |||
43 | BEGIN_MESSAGE_MAP(CSelectURLsDlg, CDialog) | ||
44 | //{{AFX_MSG_MAP(CSelectURLsDlg) | ||
45 | ON_WM_SIZE() | ||
46 | ON_WM_GETMINMAXINFO() | ||
47 | ON_LBN_SELCHANGE(IDC_URLS, OnSelchangeUrls) | ||
48 | ON_WM_HELPINFO() | ||
49 | //}}AFX_MSG_MAP | ||
50 | END_MESSAGE_MAP() | ||
51 | |||
52 | ///////////////////////////////////////////////////////////////////////////// | ||
53 | // CSelectURLsDlg message handlers | ||
54 | |||
55 | BOOL CSelectURLsDlg::OnInitDialog() | ||
56 | { | ||
57 | CDialog::OnInitDialog(); | ||
58 | |||
59 | POSITION p = m_URLs.GetHeadPosition(); | ||
60 | while(p){ | ||
61 | CString url = m_URLs.GetNext(p); | ||
62 | ASSERT(!url.IsEmpty()); | ||
63 | m_URLsCtl.AddString(url); | ||
64 | } | ||
65 | CRect rc; | ||
66 | GetWindowRect(rc); | ||
67 | m_minSize.cx = rc.Width(); | ||
68 | m_minSize.cy = rc.Height(); | ||
69 | m_URLsCtl.GetWindowRect(rc); | ||
70 | ScreenToClient(rc); | ||
71 | m_Gap = CSize(rc.left,rc.top); | ||
72 | m_minSize.cy -= rc.Height()-20; | ||
73 | m_URLsCtl.SelItemRange(TRUE,0,m_URLsCtl.GetCount()-1); | ||
74 | |||
75 | return TRUE; // return TRUE unless you set the focus to a control | ||
76 | // EXCEPTION: OCX Property Pages should return FALSE | ||
77 | } | ||
78 | |||
79 | void CSelectURLsDlg::OnSize(UINT nType, int cx, int cy) | ||
80 | { | ||
81 | CDialog::OnSize(nType, cx, cy); | ||
82 | |||
83 | RecalcLayout(cx,cy); | ||
84 | |||
85 | } | ||
86 | |||
87 | void CSelectURLsDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) | ||
88 | { | ||
89 | CDialog::OnGetMinMaxInfo(lpMMI); | ||
90 | if(m_minSize.cx && m_minSize.cy){ | ||
91 | lpMMI->ptMinTrackSize.x = m_minSize.cx; | ||
92 | lpMMI->ptMinTrackSize.y = m_minSize.cy; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void CSelectURLsDlg::RecalcLayout(int cx,int cy) | ||
97 | { | ||
98 | if(!(m_minSize.cx&&m_minSize.cy)) | ||
99 | return; | ||
100 | CRect rcok, rccan, rcadj, rcadjin, rclist; | ||
101 | m_OkCtl.GetWindowRect(rcok); ScreenToClient(rcok); | ||
102 | m_CancelCtl.GetWindowRect(rccan); ScreenToClient(rccan); | ||
103 | m_AdjustCtl.GetWindowRect(rcadj); ScreenToClient(rcadj); | ||
104 | m_AdjustInnCtl.GetWindowRect(rcadjin); ScreenToClient(rcadjin); | ||
105 | m_URLsCtl.GetWindowRect(rclist); ScreenToClient(rclist); | ||
106 | m_CancelCtl.SetWindowPos(NULL,rccan.left,cy-m_Gap.cy-rccan.Height(),0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
107 | m_OkCtl.SetWindowPos(NULL,rcok.left,cy-m_Gap.cy-rcok.Height()-rccan.bottom+rcok.bottom,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
108 | m_AdjustCtl.SetWindowPos(NULL,rcadj.left,cy-m_Gap.cy-rccan.bottom+rcadj.bottom-rcadj.Height(),0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
109 | m_AdjustInnCtl.SetWindowPos(NULL,rcadjin.left,cy-m_Gap.cy-rccan.bottom+rcadjin.bottom-rcadjin.Height(),0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
110 | m_URLsCtl.SetWindowPos(NULL,rclist.left,rclist.top,cx-m_Gap.cx*2,cy-m_Gap.cy*2-rccan.bottom+rclist.bottom,SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCOPYBITS); | ||
111 | } | ||
112 | |||
113 | void CSelectURLsDlg::OnSelchangeUrls() | ||
114 | { | ||
115 | UpdateData(TRUE); | ||
116 | if(!m_bAdjust) | ||
117 | return; | ||
118 | if(m_URLsCtl.GetSelCount()!=1) | ||
119 | return; | ||
120 | INTselection; | ||
121 | VERIFY(m_URLsCtl.GetSelItems(1,&selection)==1); | ||
122 | CCrackURL base; | ||
123 | CString selectedItem; | ||
124 | m_URLsCtl.GetText(selection,selectedItem); | ||
125 | VERIFY(base.Crack(selectedItem)); | ||
126 | CCrackURL item; | ||
127 | int is = m_URLsCtl.GetCount(); | ||
128 | BeginWaitCursor(); | ||
129 | for(int i = 0;i<is;i++){ | ||
130 | if(i==selection) | ||
131 | continue; | ||
132 | CString it; | ||
133 | m_URLsCtl.GetText(i,it); | ||
134 | if(m_bAdjustInnermost) | ||
135 | it = CCrackURL::InnermostURL(it); | ||
136 | VERIFY(item.Crack(it)); | ||
137 | if(item.m_pathFile==base.m_pathFile) | ||
138 | m_URLsCtl.SetSel(i); | ||
139 | } | ||
140 | EndWaitCursor(); | ||
141 | } | ||
142 | |||
143 | void CSelectURLsDlg::OnOK() | ||
144 | { | ||
145 | m_URLs.RemoveAll(); | ||
146 | int is = m_URLsCtl.GetSelCount(); | ||
147 | if(is){ | ||
148 | LPINTitems = new INT[is]; | ||
149 | VERIFY(m_URLsCtl.GetSelItems(is,items)==is); | ||
150 | for(int i=0;i<is;i++){ | ||
151 | CString url; | ||
152 | m_URLsCtl.GetText(items[i],url); | ||
153 | m_URLs.AddTail(url); | ||
154 | } | ||
155 | delete items; | ||
156 | } | ||
157 | CDialog::OnOK(); | ||
158 | } | ||
159 | |||
160 | BOOL CSelectURLsDlg::OnHelpInfo(HELPINFO* pHelpInfo) | ||
161 | { | ||
162 | WinHelp(IDD|0x20000l); | ||
163 | return TRUE; | ||
164 | } | ||