]> cygwin.com Git - cygwin-apps/setup.git/blame - PickView.cc
2003-07-27 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / PickView.cc
CommitLineData
97647369
RC
1/*
2 * Copyright (c) 2002 Robert Collins.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <robertc@hotmail.com>
13 *
14 */
15
16#include "PickView.h"
17#include <commctrl.h>
18#include "PickPackageLine.h"
19#include "PickCategoryLine.h"
20#include "package_db.h"
21#include "package_version.h"
22#include "dialog.h"
23#include "resource.h"
0cf68afd 24#include <algorithm>
693916f8
RC
25/* For 'source' */
26#include "state.h"
27#include "LogSingleton.h"
97647369 28
6625e635 29using namespace std;
97647369
RC
30
31static PickView::Header pkg_headers[] = {
32 {"Current", 7, 0, 0},
33 {"New", 3, 0, 0},
2fa7c5a4 34 {"Bin?", 4, 0, 0},
97647369 35 {"Src?", 4, 0, 0},
bfdf6ac2 36 {"Categories", 10, 0, 0},
97647369
RC
37 {"Package", 7, 0, 0},
38 {0, 0, 0, 0}
39};
40
41static PickView::Header cat_headers[] = {
42 {"Category", 8, 0, 0},
43 {"Current", 7, 0, 0},
44 {"New", 3, 0, 0},
2fa7c5a4 45 {"Bin?", 4, 0, 0},
97647369
RC
46 {"Src?", 4, 0, 0},
47 {"Package", 7, 0, 0},
48 {0, 0, 0, 0}
49};
50
51// PickView:: views
52const PickView::views PickView::views::Unknown (0);
53const PickView::views PickView::views::PackageFull (1);
e0aec95e
MB
54const PickView::views PickView::views::Package (2);
55const PickView::views PickView::views::PackageKeeps (3);
56const PickView::views PickView::views::PackageSkips = PickView::views (4);
57const PickView::views PickView::views::Category (5);
97647369 58
693916f8
RC
59ATOM PickView::WindowClassAtom = 0;
60
97647369
RC
61// DoInsertItem - inserts an item into a header control.
62// Returns the index of the new item.
63// hwndHeader - handle to the header control.
64// iInsertAfter - index of the previous item.
65// nWidth - width of the new item.
66// lpsz - address of the item string.
67static int
68DoInsertItem (HWND hwndHeader, int iInsertAfter, int nWidth, LPSTR lpsz)
69{
70 HDITEM hdi;
71 int index;
72
73 hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_WIDTH;
74 hdi.pszText = lpsz;
75 hdi.cxy = nWidth;
76 hdi.cchTextMax = lstrlen (hdi.pszText);
77 hdi.fmt = HDF_LEFT | HDF_STRING;
78
79 index = SendMessage (hwndHeader, HDM_INSERTITEM,
80 (WPARAM) iInsertAfter, (LPARAM) & hdi);
81
82 return index;
83}
84
85
86
87void
88PickView::set_headers ()
89{
90 if (view_mode == views::Unknown)
91 return;
92 if (view_mode == views::PackageFull ||
e0aec95e
MB
93 view_mode == views::Package ||
94 view_mode == views::PackageKeeps ||
95 view_mode == views::PackageSkips)
97647369
RC
96 {
97 headers = pkg_headers;
98 current_col = 0;
99 new_col = 1;
2fa7c5a4
RC
100 bintick_col = new_col + 1;
101 srctick_col = bintick_col + 1;
102 cat_col = srctick_col + 1;
103 pkg_col = cat_col + 1;
931f2755 104 last_col = pkg_col;
97647369
RC
105 }
106 else if (view_mode == views::Category)
107 {
108 headers = cat_headers;
109 current_col = 1;
2fa7c5a4
RC
110 new_col = current_col + 1;
111 bintick_col = new_col + 1;
112 srctick_col = bintick_col + 1;
97647369 113 cat_col = 0;
2fa7c5a4
RC
114 pkg_col = srctick_col + 1;
115 last_col = pkg_col;
97647369
RC
116 }
117 else
118 return;
119 while (int n = SendMessage (listheader, HDM_GETITEMCOUNT, 0, 0))
120 {
121 SendMessage (listheader, HDM_DELETEITEM, n - 1, 0);
122 }
123 int i;
124 for (i = 0; i <= last_col; i++)
125 DoInsertItem (listheader, i, headers[i].width, (char *) headers[i].text);
126}
127
128void
3c054baf 129PickView::note_width (PickView::Header *hdrs, HDC dc, String const &string, int addend,
97647369
RC
130 int column)
131{
3c054baf 132 if (!string.size())
97647369
RC
133 {
134 if (hdrs[column].width < addend)
135 hdrs[column].width = addend;
136 return;
137 }
138 SIZE s;
3c054baf 139 GetTextExtentPoint32 (dc, string.cstr_oneuse(), string.size(), &s);
97647369
RC
140 if (hdrs[column].width < s.cx + addend)
141 hdrs[column].width = s.cx + addend;
142}
143
144void
145PickView::set_view_mode (PickView::views _mode)
146{
147 view_mode = _mode;
148 set_headers ();
149}
150
151const char *
152PickView::mode_caption ()
153{
154 return view_mode.caption ();
155}
156
157const char *
158PickView::views::caption ()
159{
160 switch (_value)
161 {
162 case 1:
163 return "Full";
164 case 2:
165 return "Partial";
166 case 3:
e0aec95e
MB
167 return "Up To Date";
168 case 4:
169 return "Not Installed";
170 case 5:
97647369
RC
171 return "Category";
172 default:
173 return "";
174 }
175}
176
177void
178PickView::insert_pkg (packagemeta & pkg)
179{
180 if (view_mode != views::Category)
181 {
49cf3899 182 PickLine & line = *new PickPackageLine (*this, pkg);
97647369
RC
183 contents.insert (line);
184 }
185 else
186 {
405d7186
RC
187 for (set <String, String::caseless>::const_iterator x
188 = pkg.categories.begin (); x != pkg.categories.end (); ++x)
97647369 189 {
405d7186
RC
190 packagedb db;
191 // Special case - yuck
192 if (x->casecompare ("All") == 0)
193 continue;
194
195 PickCategoryLine & catline =
0cf68afd 196 *new PickCategoryLine (*this,* db.categories.find (*x), 1);
405d7186
RC
197 PickLine & line = *new PickPackageLine(*this, pkg);
198 catline.insert (line);
199 contents.insert (catline);
97647369
RC
200 }
201 }
202}
203
204void
205PickView::insert_category (Category * cat, bool collapsed)
206{
0cf68afd
RC
207 // Urk, special case
208 if (cat->first.casecompare ("All") == 0)
97647369
RC
209 return;
210 PickCategoryLine & catline = *new PickCategoryLine (*this, *cat, 1, collapsed);
0cf68afd
RC
211 for (vector <packagemeta *>::iterator i = cat->second.begin ();
212 i != cat->second.end () ; ++i)
97647369 213 {
405d7186 214 PickLine & line = *new PickPackageLine (*this, **i);
97647369
RC
215 catline.insert (line);
216 }
217 contents.insert (catline);
218}
219
220void
221PickView::clear_view (void)
222{
223 contents.empty ();
224 if (view_mode == views::Unknown)
225 return;
226 if (view_mode == views::PackageFull ||
e0aec95e
MB
227 view_mode == views::Package ||
228 view_mode == views::PackageKeeps ||
229 view_mode == views::PackageSkips)
97647369
RC
230 contents.ShowLabel (false);
231 else if (view_mode == views::Category)
232 contents.ShowLabel ();
233}
234
235PickView::views&
236PickView::views::operator++ ()
237{
238 ++_value;
239 if (_value > Category._value)
240 _value = 1;
241 return *this;
242}
243
244int
245PickView::click (int row, int x)
246{
247 return contents.click (0, row, x);
248}
249
250
251void
252PickView::scroll (HWND hwnd, int which, int *var, int code)
253{
254 SCROLLINFO si;
255 si.cbSize = sizeof (si);
e0aec95e 256 si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
97647369
RC
257 GetScrollInfo (hwnd, which, &si);
258
259 switch (code)
260 {
261 case SB_THUMBTRACK:
262 si.nPos = si.nTrackPos;
263 break;
264 case SB_THUMBPOSITION:
265 break;
266 case SB_BOTTOM:
267 si.nPos = si.nMax;
268 break;
269 case SB_TOP:
270 si.nPos = 0;
271 break;
272 case SB_LINEDOWN:
273 si.nPos += row_height;
274 break;
275 case SB_LINEUP:
276 si.nPos -= row_height;
277 break;
278 case SB_PAGEDOWN:
279 si.nPos += si.nPage * 9 / 10;
280 break;
281 case SB_PAGEUP:
282 si.nPos -= si.nPage * 9 / 10;
283 break;
284 }
285
286 if ((int) si.nPos < 0)
287 si.nPos = 0;
288 if (si.nPos + si.nPage > (unsigned int) si.nMax)
289 si.nPos = si.nMax - si.nPage;
290
291 si.fMask = SIF_POS;
292 SetScrollInfo (hwnd, which, &si, TRUE);
293
294 int ox = scroll_ulc_x;
295 int oy = scroll_ulc_y;
296 *var = si.nPos;
297
298 RECT cr, sr;
693916f8 299 ::GetClientRect (hwnd, &cr);
97647369
RC
300 sr = cr;
301 sr.top += header_height;
302 UpdateWindow (hwnd);
303 ScrollWindow (hwnd, ox - scroll_ulc_x, oy - scroll_ulc_y, &sr, &sr);
304 /*
305 sr.bottom = sr.top;
306 sr.top = cr.top;
307 ScrollWindow (hwnd, ox - scroll_ulc_x, 0, &sr, &sr);
308 */
309 if (ox - scroll_ulc_x)
310 {
693916f8 311 ::GetClientRect (listheader, &cr);
97647369
RC
312 sr = cr;
313// UpdateWindow (htmp);
693916f8 314 ::MoveWindow (listheader, -scroll_ulc_x, 0,
97647369
RC
315 headers[last_col].x +
316 headers[last_col].width, header_height, TRUE);
317 }
318 UpdateWindow (hwnd);
319}
320
321void
322PickView::init_headers (HDC dc)
323{
324 int i;
325
326 for (i = 0; headers[i].text; i++)
327 {
328 headers[i].width = 0;
329 headers[i].x = 0;
330 }
331
332 for (i = 0; headers[i].text; i++)
333 note_width (headers, dc, headers[i].text, HMARGIN, i);
334 /* src checkbox */
2fa7c5a4
RC
335 note_width (headers, dc, 0, HMARGIN + 11, bintick_col);
336 note_width (headers, dc, 0, HMARGIN + 11, srctick_col);
97647369 337 packagedb db;
0cf68afd
RC
338 for (packagedb::categoriesType::iterator n = packagedb::categories.begin();
339 n != packagedb::categories.end(); ++n)
340 note_width (headers, dc, String ("+ ")+n->first, HMARGIN, cat_col);
cfae3b8d
RC
341 for (vector <packagemeta *>::iterator n = db.packages.begin ();
342 n != db.packages.end (); ++n)
97647369 343 {
cfae3b8d 344 packagemeta & pkg = **n;
97647369 345 if (pkg.installed)
3c196821 346 note_width (headers, dc, pkg.installed.Canonical_version (),
97647369 347 HMARGIN, current_col);
3c196821
RC
348 for (set<packageversion>::iterator i=pkg.versions.begin();
349 i != pkg.versions.end(); ++i)
350 if (*i != pkg.installed)
97647369 351 note_width (headers, dc,
3c196821 352 i->Canonical_version (),
97647369 353 NEW_COL_SIZE_SLOP + HMARGIN, new_col);
3c054baf
RC
354 String s = pkg.name;
355 if (pkg.SDesc ().size())
356 s += String (": ") + pkg.SDesc ();
357 note_width (headers, dc, s, HMARGIN, pkg_col);
97647369
RC
358 }
359 note_width (headers, dc, "keep", NEW_COL_SIZE_SLOP + HMARGIN, new_col);
360 note_width (headers, dc, "uninstall", NEW_COL_SIZE_SLOP + HMARGIN, new_col);
361
362 headers[0].x = 0;
363 for (i = 1; i <= last_col; i++)
364 headers[i].x = headers[i - 1].x + headers[i - 1].width;
365}
366
367
693916f8
RC
368PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN),
369contents (*this, cat, 0, false, true)
97647369 370{
693916f8 371}
97647369 372
693916f8
RC
373void
374PickView::init(views _mode)
375{
376 HDC dc = GetDC (GetHWND());
97647369
RC
377 sysfont = GetStockObject (DEFAULT_GUI_FONT);
378 SelectObject (dc, sysfont);
379 GetTextMetrics (dc, &tm);
380
381 bitmap_dc = CreateCompatibleDC (dc);
382 bm_spin = LoadImage (hinstance, MAKEINTRESOURCE (IDB_SPIN), IMAGE_BITMAP, 0, 0, 0);
383 bm_rtarrow = LoadImage (hinstance, MAKEINTRESOURCE (IDB_RTARROW), IMAGE_BITMAP,
384 0, 0, 0);
385
386 bm_checkyes = LoadImage (hinstance, MAKEINTRESOURCE (IDB_CHECK_YES), IMAGE_BITMAP,
387 0, 0, 0);
388 bm_checkno = LoadImage (hinstance, MAKEINTRESOURCE (IDB_CHECK_NO), IMAGE_BITMAP,
389 0, 0, 0);
390 bm_checkna = LoadImage (hinstance, MAKEINTRESOURCE (IDB_CHECK_NA), IMAGE_BITMAP,
391 0, 0, 0);
392
393 row_height = (tm.tmHeight + tm.tmExternalLeading + ROW_MARGIN);
394 int
395 irh =
396 tm.
397 tmExternalLeading +
398 tm.
399 tmDescent +
400 11 +
401 ROW_MARGIN;
402 if (row_height < irh)
403 row_height = irh;
404
405 RECT rcParent;
406 HDLAYOUT hdl;
407 WINDOWPOS wp;
408
409 // Ensure that the common control DLL is loaded, and then create
410 // the header control.
411 INITCOMMONCONTROLSEX controlinfo =
412 {
413 sizeof (INITCOMMONCONTROLSEX), ICC_LISTVIEW_CLASSES};
414 InitCommonControlsEx (&controlinfo);
415
416 if ((listheader = CreateWindowEx (0, WC_HEADER, (LPCTSTR) NULL,
417 WS_CHILD | WS_BORDER | CCS_NORESIZE |
418 // | HDS_BUTTONS
693916f8 419 HDS_HORZ, 0, 0, 0, 0, GetHWND(),
97647369
RC
420 (HMENU) IDC_CHOOSE_LISTHEADER, hinstance,
421 (LPVOID) NULL)) == NULL)
422 // FIXME: throw an exception
423 exit (10);
424
425 // Retrieve the bounding rectangle of the parent window's
426 // client area, and then request size and position values
427 // from the header control.
693916f8 428 ::GetClientRect (GetHWND(), &rcParent);
97647369
RC
429
430 hdl.prc = &rcParent;
431 hdl.pwpos = &wp;
432 if (!SendMessage (listheader, HDM_LAYOUT, 0, (LPARAM) & hdl))
433 // FIXME: throw an exception
434 exit (11);
435
09130e58
RC
436 // Set the font of the listheader, but don't redraw, because its not shown
437 // yet.This message does not return a value, so we are not checking it as we
438 // do above.
439 SendMessage (listheader, WM_SETFONT, (WPARAM) sysfont, FALSE);
97647369
RC
440
441 // Set the size, position, and visibility of the header control.
442 SetWindowPos (listheader, wp.hwndInsertAfter, wp.x, wp.y,
443 wp.cx, wp.cy, wp.flags | SWP_SHOWWINDOW);
444
445 header_height = wp.cy;
446
447 view_mode = PickView::views::Package;
448 set_headers ();
449 init_headers (dc);
450 view_mode = PickView::views::Category;
451 set_headers ();
452 init_headers (dc);
453
454 view_mode = _mode;
455 set_headers ();
456
457 ReleaseDC (lv, dc);
458}
49cf3899
RC
459
460PickView::~PickView()
461{
462}
693916f8
RC
463
464bool PickView::registerWindowClass ()
465{
466 if (WindowClassAtom != 0)
467 return true;
468
469 // We're not registered yet
470 WNDCLASSEX wc;
471
472 wc.cbSize = sizeof (wc);
473 // Some sensible style defaults
474 wc.style = CS_HREDRAW | CS_VREDRAW;
475 // Our default window procedure. This replaces itself
476 // on the first call with the simpler Window::WindowProcReflector().
477 wc.lpfnWndProc = Window::FirstWindowProcReflector;
478 // No class bytes
479 wc.cbClsExtra = 0;
480 // One pointer to REFLECTION_INFO in the extra window instance bytes
481 wc.cbWndExtra = 4;
482 // The app instance
483 wc.hInstance = hinstance; //GetInstance ();
484 // Use a bunch of system defaults for the GUI elements
485 wc.hIcon = LoadIcon (0, IDI_APPLICATION);
486 wc.hIconSm = NULL;
487 wc.hCursor = LoadCursor (0, IDC_ARROW);
488 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
489 // No menu
490 wc.lpszMenuName = NULL;
491 // We'll get a little crazy here with the class name
492 wc.lpszClassName = "listview";
493
494 // All set, try to register
495 WindowClassAtom = RegisterClassEx (&wc);
496 if (WindowClassAtom == 0)
497 log (LOG_BABBLE) << "Failed to register listview " << GetLastError () << endLog;
498 return WindowClassAtom != 0;
499}
500
501LRESULT CALLBACK
502PickView::list_vscroll (HWND hwnd, HWND hctl, UINT code, int pos)
503{
504 chooser->scroll (hwnd, SB_VERT, &chooser->scroll_ulc_y, code);
505 return 0;
506}
507
508LRESULT CALLBACK
509PickView::list_hscroll (HWND hwnd, HWND hctl, UINT code, int pos)
510{
511 chooser->scroll (hwnd, SB_HORZ, &chooser->scroll_ulc_x, code);
512 return 0;
513}
514
515LRESULT CALLBACK
516PickView::list_click (HWND hwnd, BOOL dblclk, int x, int y, UINT hitCode)
517{
518 int row, refresh;
519
520 if (chooser->contents.itemcount () == 0)
521 return 0;
522
523 if (y < chooser->header_height)
524 return 0;
525 x += chooser->scroll_ulc_x;
526 y += chooser->scroll_ulc_y - chooser->header_height;
527
528 row = (y + ROW_MARGIN / 2) / chooser->row_height;
529
530 if (row < 0 || row >= chooser->contents.itemcount ())
531 return 0;
532
533 refresh = chooser->click (row, x);
534
535 // XXX we need a method to queryt he database to see if more
536 // than just one package has changed! Until then...
537#if 0
538 if (refresh)
539 {
540#endif
541 RECT r;
542 ::GetClientRect (lv, &r);
543 SCROLLINFO si;
544 memset (&si, 0, sizeof (si));
545 si.cbSize = sizeof (si);
546 si.fMask = SIF_ALL | SIF_DISABLENOSCROLL; /* SIF_RANGE was giving strange behaviour */
547 si.nMin = 0;
548
549 si.nMax = chooser->contents.itemcount () * chooser->row_height;
550 si.nPage = r.bottom - chooser->header_height;
551
552 /* if we are under the minimum display count ,
553 * set the offset to 0
554 */
555 if ((unsigned int) si.nMax <= si.nPage)
556 chooser->scroll_ulc_y = 0;
557 si.nPos = chooser->scroll_ulc_y;
558
559 SetScrollInfo (lv, SB_VERT, &si, TRUE);
560
561 InvalidateRect (lv, &r, TRUE);
562#if 0
563 }
564 else
565 {
566 RECT rect;
567 rect.left =
568 chooser->headers[chooser->new_col].x - chooser->scroll_ulc_x;
569 rect.right =
570 chooser->headers[chooser->src_col + 1].x - chooser->scroll_ulc_x;
571 rect.top =
572 chooser->header_height + row * chooser->row_height -
573 chooser->scroll_ulc_y;
574 rect.bottom = rect.top + chooser->row_height;
575 InvalidateRect (hwnd, &rect, TRUE);
576 }
577#endif
578 return 0;
579}
580
581/*
582 * LRESULT CALLBACK
583 * PickView::listview_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
584 */
585LRESULT
586PickView::WindowProc (UINT message, WPARAM wParam, LPARAM lParam)
587{
588 switch (message)
589 {
590 case WM_HSCROLL:
591 return HANDLE_WM_HSCROLL (GetHWND(), wParam, lParam, list_hscroll);
592 case WM_VSCROLL:
593 return HANDLE_WM_VSCROLL (GetHWND(), wParam, lParam, list_vscroll);
594 case WM_LBUTTONDOWN:
595 return HANDLE_WM_LBUTTONDOWN (GetHWND(), wParam, lParam, list_click);
596 case WM_PAINT:
597 paint (GetHWND());
598 return 0;
599 case WM_NOTIFY:
600 {
601 // pnmh = (LPNMHDR) lParam
602 LPNMHEADER phdr = (LPNMHEADER) lParam;
603 switch (phdr->hdr.code)
604 {
605 case HDN_ITEMCHANGED:
606 if (phdr->hdr.hwndFrom == chooser->ListHeader ())
607 {
608 if (phdr->pitem && phdr->pitem->mask & HDI_WIDTH)
609 chooser->headers[phdr->iItem].width = phdr->pitem->cxy;
610 for (int i = 1; i <= chooser->last_col; i++)
611 chooser->headers[i].x =
612 chooser->headers[i - 1].x + chooser->headers[i - 1].width;
613 RECT r;
614 ::GetClientRect (GetHWND(), &r);
615 SCROLLINFO si;
616 si.cbSize = sizeof (si);
617 si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
618 GetScrollInfo (GetHWND(), SB_HORZ, &si);
619 int oldMax = si.nMax;
620 si.nMax =
621 chooser->headers[chooser->last_col].x +
622 chooser->headers[chooser->last_col].width;
623 if (si.nTrackPos && oldMax > si.nMax)
624 si.nTrackPos += si.nMax - oldMax;
625 si.nPage = r.right;
626 SetScrollInfo (GetHWND(), SB_HORZ, &si, TRUE);
627 InvalidateRect (GetHWND(), &r, TRUE);
628 if (si.nTrackPos && oldMax > si.nMax)
629 chooser->scroll (GetHWND(), SB_HORZ, &chooser->scroll_ulc_x,
630 SB_THUMBTRACK);
631 }
632 break;
633 default:
634 break;
635 }
636 }
637 default:
638 return DefWindowProc (GetHWND(), message, wParam, lParam);
639 }
640}
641
642
643HWND PickView::lv;
644PickView *PickView::chooser = NULL;
645
646void
647PickView::paint (HWND hwnd)
648{
649 HDC hdc;
650 PAINTSTRUCT ps;
651 int x, y;
652
653 hdc = BeginPaint (hwnd, &ps);
654
655 SelectObject (hdc, chooser->sysfont);
656 SetBkColor (hdc, GetSysColor (COLOR_WINDOW));
657 SetTextColor (hdc, GetSysColor (COLOR_WINDOWTEXT));
658
659 RECT cr;
660 ::GetClientRect (hwnd, &cr);
661
662 x = cr.left - chooser->scroll_ulc_x;
663 y = cr.top - chooser->scroll_ulc_y + chooser->header_height;
664
665 IntersectClipRect (hdc, cr.left, cr.top + chooser->header_height, cr.right,
666 cr.bottom);
667
668 chooser->contents.paint (hdc, x, y, 0, (chooser->get_view_mode () ==
669 PickView::views::Category) ? 0 : 1);
670
671 if (chooser->contents.itemcount () == 0)
672 {
673 static const char *msg = "Nothing to Install/Update";
674 if (source == IDC_SOURCE_DOWNLOAD)
675 msg = "Nothing to Download";
676 TextOut (hdc, HMARGIN, chooser->header_height, msg, strlen (msg));
677 }
678
679 EndPaint (hwnd, &ps);
680}
681
682
683bool
684PickView::Create (Window * parent, DWORD Style, RECT *r)
685{
686
687 // First register the window class, if we haven't already
688 if (!registerWindowClass ())
689 {
690 // Registration failed
691 return false;
692 }
693
694 // Save our parent, we'll probably need it eventually.
695 setParent(parent);
696
697 // Create the window instance
698 CreateWindowEx (
699 // Extended Style
700 WS_EX_CLIENTEDGE,
701 "listview", //MAKEINTATOM(WindowClassAtom), // window class atom (name)
702 "listviewwindow", // no title-bar string yet
703 // Style bits
704 Style,
705 r ? r->left : CW_USEDEFAULT, r ? r->top : CW_USEDEFAULT,
706 r? r->right - r->left + 1 : CW_USEDEFAULT,
707 r? r->bottom - r->top + 1 :CW_USEDEFAULT,
708 // Parent Window
709 parent == NULL ? (HWND) NULL : parent->GetHWND (),
710 // use class menu
711 (HMENU) MAKEINTRESOURCE (IDC_CHOOSE_LIST),
712 // The application instance
713 GetInstance (),
714 // The this ptr, which we'll use to set up the WindowProc reflection.
715 reinterpret_cast<void *>((Window *)this));
716 lv = GetHWND();
717 if (GetHWND() == NULL)
718 {
719 log (LOG_BABBLE) << "Failed to create PickView " << GetLastError () << endLog;
720 return false;
721 }
722
723 return true;
724}
This page took 0.094414 seconds and 5 git commands to generate.