2 * Copyright 2003 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Martin Fuchs, 23.07.2003
29 #include "../utility/utility.h"
31 #include "../explorer.h"
32 #include "../globals.h"
34 #include "../explorer_intres.h"
38 IMG_NONE=-1, IMG_FILE=0, IMG_DOCUMENT, IMG_EXECUTABLE,
39 IMG_FOLDER, IMG_OPEN_FOLDER, IMG_FOLDER_PLUS,IMG_OPEN_PLUS, IMG_OPEN_MINUS,
40 IMG_FOLDER_UP, IMG_FOLDER_CUR
44 #define IMAGE_WIDTH 16
45 #define IMAGE_HEIGHT 13
48 static int is_exe_file(LPCTSTR ext)
50 static const LPCTSTR executable_extensions[] = {
61 TCHAR ext_buffer[_MAX_EXT];
66 for(s=ext+1,d=ext_buffer; (*d=tolower(*s)); s++)
69 for(p=executable_extensions; *p; p++)
70 if (!lstrcmp(ext_buffer, *p))
76 static int is_registered_type(LPCTSTR ext)
84 static const LPTSTR g_pos_names[COLUMNS] = {
85 TEXT(""), /* symbol */
97 static const int g_pos_align[] = {
100 HDF_RIGHT, /* Size */
101 HDF_LEFT, /* CDate */
102 HDF_LEFT, /* ADate */
103 HDF_LEFT, /* MDate */
104 HDF_LEFT, /* Index */
105 HDF_CENTER, /* Links */
106 HDF_CENTER, /* Attributes */
107 HDF_LEFT /* Security */
111 Pane::Pane(HWND hparent, int id, int id_header, Entry* root, bool treePane, int visible_cols)
112 : super(CreateWindow(TEXT("ListBox"), TEXT(""), WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|
113 LBS_DISABLENOSCROLL|LBS_NOINTEGRALHEIGHT|LBS_OWNERDRAWFIXED|LBS_NOTIFY,
114 0, 0, 0, 0, hparent, (HMENU)id, g_Globals._hInstance, 0)),
117 _visible_cols(visible_cols)
119 // insert entries into listbox
120 Entry* entry = _root;
123 insert_entries(entry, -1);
127 create_header(hparent, id_header);
131 LRESULT Pane::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
139 FileChildWindow* child = (FileChildWindow*) SendMessage(GetParent(_hwnd), PM_GET_FILEWND_PTR, 0, 0);
141 child->set_focus_pane(this);
142 ListBox_SetSel(_hwnd, TRUE, 1);
143 /*TODO: check menu items */
147 FileChildWindow* child = (FileChildWindow*) SendMessage(GetParent(_hwnd), PM_GET_FILEWND_PTR, 0, 0);
149 if (wparam == VK_TAB) {
150 /*TODO: SetFocus(g_Globals.hdrivebar) */
151 child->switch_focus_pane();
156 return super::WndProc(nmsg, wparam, lparam);
160 bool Pane::create_header(HWND hparent, int id)
162 HWND hwnd = CreateWindow(WC_HEADER, 0, WS_CHILD|WS_VISIBLE|HDS_HORZ/*TODO: |HDS_BUTTONS + sort orders*/,
163 0, 0, 0, 0, hparent, (HMENU)id, g_Globals._hInstance, 0);
167 SetWindowFont(hwnd, GetStockFont(DEFAULT_GUI_FONT), FALSE);
171 hdi.mask = HDI_TEXT|HDI_WIDTH|HDI_FORMAT;
173 for(int idx=0; idx<COLUMNS; idx++) {
174 hdi.pszText = g_pos_names[idx];
175 hdi.fmt = HDF_STRING | g_pos_align[idx];
176 hdi.cxy = _widths[idx];
177 Header_InsertItem(hwnd, idx, &hdi);
188 _himl = ImageList_LoadBitmap(g_Globals._hInstance, MAKEINTRESOURCE(IDB_IMAGES), 16, 0, RGB(0,255,0));
190 SetWindowFont(_hwnd, _out_wrkr._hfont, FALSE);
192 // calculate column widths
193 _out_wrkr.init_output(_hwnd);
198 // calculate prefered width for all visible columns
200 bool Pane::calc_widths(bool anyway)
202 int col, x, cx, spc=3*_out_wrkr._spaceSize.cx;
203 int entries = ListBox_GetCount(_hwnd);
204 int orgWidths[COLUMNS];
205 int orgPositions[COLUMNS+1];
211 memcpy(orgWidths, _widths, sizeof(orgWidths));
212 memcpy(orgPositions, _positions, sizeof(orgPositions));
215 for(col=0; col<COLUMNS; col++)
219 hfontOld = SelectFont(hdc, _out_wrkr._hfont);
221 for(cnt=0; cnt<entries; cnt++) {
222 Entry* entry = (Entry*) ListBox_GetItemData(_hwnd, cnt);
231 dis.hwndItem = _hwnd;
235 dis.rcItem.right = 0;
236 dis.rcItem.bottom = 0;
237 /*dis.itemData = 0; */
239 draw_item(&dis, entry, COLUMNS);
242 SelectObject(hdc, hfontOld);
243 ReleaseDC(_hwnd, hdc);
246 for(col=0; col<COLUMNS; col++) {
253 if (cx < IMAGE_WIDTH)
262 _positions[COLUMNS] = x;
264 ListBox_SetHorizontalExtent(_hwnd, x);
267 if (!memcmp(orgWidths, _widths, sizeof(orgWidths)))
270 // don't move, if only collapsing an entry
271 if (!anyway && _widths[0]<orgWidths[0] &&
272 !memcmp(orgWidths+1, _widths+1, sizeof(orgWidths)-sizeof(int))) {
273 _widths[0] = orgWidths[0];
274 memcpy(_positions, orgPositions, sizeof(orgPositions));
279 InvalidateRect(_hwnd, 0, TRUE);
285 static void format_date(const FILETIME* ft, TCHAR* buffer, int visible_cols)
291 *buffer = TEXT('\0');
293 if (!ft->dwLowDateTime && !ft->dwHighDateTime)
296 if (!FileTimeToLocalFileTime(ft, &lft))
297 {err: lstrcpy(buffer,TEXT("???")); return;}
299 if (!FileTimeToSystemTime(&lft, &systime))
302 if (visible_cols & COL_DATE) {
303 len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, buffer, BUFFER_LEN);
308 if (visible_cols & COL_TIME) {
314 if (!GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, buffer+len, BUFFER_LEN-len))
315 buffer[len] = TEXT('\0');
320 void Pane::draw_item(LPDRAWITEMSTRUCT dis, Entry* entry, int calcWidthCol)
322 TCHAR buffer[BUFFER_LEN];
324 int visible_cols = _visible_cols;
325 COLORREF bkcolor, textcolor;
326 RECT focusRect = dis->rcItem;
332 attrs = entry->_data.dwFileAttributes;
334 if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
335 if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('.')
336 && entry->_data.cFileName[2]==TEXT('\0'))
338 else if (entry->_data.cFileName[0]==TEXT('.') && entry->_data.cFileName[1]==TEXT('\0'))
339 img = IMG_FOLDER_CUR;
340 else if ((_treePane && (dis->itemState&ODS_FOCUS)))
341 img = IMG_OPEN_FOLDER;
345 LPCTSTR ext = _tcsrchr(entry->_data.cFileName, '.');
349 if (is_exe_file(ext))
350 img = IMG_EXECUTABLE;
351 else if (is_registered_type(ext))
363 img_pos = dis->rcItem.left + entry->_level*(IMAGE_WIDTH+_out_wrkr._spaceSize.cx);
365 if (calcWidthCol == -1) {
367 int y = dis->rcItem.top + IMAGE_HEIGHT/2;
370 HRGN hrgn_org = CreateRectRgn(0, 0, 0, 0);
373 rt_clip.left = dis->rcItem.left;
374 rt_clip.top = dis->rcItem.top;
375 rt_clip.right = dis->rcItem.left+_widths[col];
376 rt_clip.bottom = dis->rcItem.bottom;
378 hrgn = CreateRectRgnIndirect(&rt_clip);
380 if (!GetClipRgn(dis->hDC, hrgn_org)) {
381 DeleteObject(hrgn_org);
385 //HGDIOBJ holdPen = SelectObject(dis->hDC, GetStockObject(BLACK_PEN));
386 ExtSelectClipRgn(dis->hDC, hrgn, RGN_AND);
389 if ((up=entry->_up) != NULL) {
390 MoveToEx(dis->hDC, img_pos-IMAGE_WIDTH/2, y, 0);
391 LineTo(dis->hDC, img_pos-2, y);
393 x = img_pos - IMAGE_WIDTH/2;
396 x -= IMAGE_WIDTH+_out_wrkr._spaceSize.cx;
400 && (up->_next->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
403 MoveToEx(dis->hDC, x, dis->rcItem.top, 0);
404 LineTo(dis->hDC, x, dis->rcItem.bottom);
406 } while((up=up->_up) != NULL);
409 x = img_pos - IMAGE_WIDTH/2;
411 MoveToEx(dis->hDC, x, dis->rcItem.top, 0);
412 LineTo(dis->hDC, x, y);
416 && (entry->_next->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
419 LineTo(dis->hDC, x, dis->rcItem.bottom);
421 if (entry->_down && entry->_expanded) {
422 x += IMAGE_WIDTH + _out_wrkr._spaceSize.cx;
423 MoveToEx(dis->hDC, x, dis->rcItem.top+IMAGE_HEIGHT, 0);
424 LineTo(dis->hDC, x, dis->rcItem.bottom);
427 SelectClipRgn(dis->hDC, hrgn_org);
428 if (hrgn_org) DeleteObject(hrgn_org);
429 //SelectObject(dis->hDC, holdPen);
430 } else if (calcWidthCol==col || calcWidthCol==COLUMNS) {
431 int right = img_pos + IMAGE_WIDTH - _out_wrkr._spaceSize.cx;
433 if (right > _widths[col])
434 _widths[col] = right;
437 img_pos = dis->rcItem.left;
440 img_pos = dis->rcItem.left;
442 if (calcWidthCol==col || calcWidthCol==COLUMNS)
443 _widths[col] = IMAGE_WIDTH;
446 if (calcWidthCol == -1) {
447 focusRect.left = img_pos -2;
449 if (attrs & FILE_ATTRIBUTE_COMPRESSED)
450 textcolor = COLOR_COMPRESSED;
452 textcolor = RGB(0,0,0);
454 if (dis->itemState & ODS_FOCUS) {
455 textcolor = RGB(255,255,255);
456 bkcolor = COLOR_SELECTION;
458 bkcolor = RGB(255,255,255);
461 HBRUSH hbrush = CreateSolidBrush(bkcolor);
462 FillRect(dis->hDC, &focusRect, hbrush);
463 DeleteObject(hbrush);
465 SetBkMode(dis->hDC, TRANSPARENT);
466 SetTextColor(dis->hDC, textcolor);
470 if (cx && img!=IMG_NONE) {
471 if (cx > IMAGE_WIDTH)
474 if (entry->_hIcon && entry->_hIcon!=(HICON)-1)
475 DrawIconEx(dis->hDC, img_pos, dis->rcItem.top, entry->_hIcon, cx, GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);
477 ImageList_DrawEx(_himl, img, dis->hDC,
478 img_pos, dis->rcItem.top, cx,
479 IMAGE_HEIGHT, bkcolor, CLR_DEFAULT, ILD_NORMAL);
489 if (calcWidthCol == -1)
490 _out_wrkr.output_text(dis, _positions, col, entry->_data.cFileName, 0);
491 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
492 calc_width(dis, col, entry->_data.cFileName);
497 if (visible_cols & COL_SIZE) {
498 ULONGLONG size = ((ULONGLONG)entry->_data.nFileSizeHigh << 32) | entry->_data.nFileSizeLow;
500 _stprintf(buffer, TEXT("%") LONGLONGARG TEXT("d"), size);
502 if (calcWidthCol == -1)
503 _out_wrkr.output_number(dis, _positions, col, buffer);
504 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
505 calc_width(dis, col, buffer); // TODO: not ever time enough
511 if (visible_cols & (COL_DATE|COL_TIME)) {
512 format_date(&entry->_data.ftCreationTime, buffer, visible_cols);
513 if (calcWidthCol == -1)
514 _out_wrkr.output_text(dis, _positions, col, buffer, 0);
515 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
516 calc_width(dis, col, buffer);
519 format_date(&entry->_data.ftLastAccessTime, buffer, visible_cols);
520 if (calcWidthCol == -1)
521 _out_wrkr.output_text(dis,_positions, col, buffer, 0);
522 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
523 calc_width(dis, col, buffer);
526 format_date(&entry->_data.ftLastWriteTime, buffer, visible_cols);
527 if (calcWidthCol == -1)
528 _out_wrkr.output_text(dis, _positions, col, buffer, 0);
529 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
530 calc_width(dis, col, buffer);
534 if (entry->_bhfi_valid) {
535 ULONGLONG index = ((ULONGLONG)entry->_bhfi.nFileIndexHigh << 32) | entry->_bhfi.nFileIndexLow;
537 if (visible_cols & COL_INDEX) {
538 _stprintf(buffer, TEXT("%") LONGLONGARG TEXT("X"), index);
539 if (calcWidthCol == -1)
540 _out_wrkr.output_text(dis, _positions, col, buffer, DT_RIGHT);
541 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
542 calc_width(dis, col, buffer);
546 if (visible_cols & COL_LINKS) {
547 wsprintf(buffer, TEXT("%d"), entry->_bhfi.nNumberOfLinks);
548 if (calcWidthCol == -1)
549 _out_wrkr.output_text(dis, _positions, col, buffer, DT_CENTER);
550 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
551 calc_width(dis, col, buffer);
557 // show file attributes
558 if (visible_cols & COL_ATTRIBUTES) {
559 lstrcpy(buffer, TEXT(" \t \t \t \t \t \t \t \t \t \t \t "));
561 if (attrs & FILE_ATTRIBUTE_NORMAL) buffer[ 0] = 'N';
563 if (attrs & FILE_ATTRIBUTE_READONLY) buffer[ 2] = 'R';
564 if (attrs & FILE_ATTRIBUTE_HIDDEN) buffer[ 4] = 'H';
565 if (attrs & FILE_ATTRIBUTE_SYSTEM) buffer[ 6] = 'S';
566 if (attrs & FILE_ATTRIBUTE_ARCHIVE) buffer[ 8] = 'A';
567 if (attrs & FILE_ATTRIBUTE_COMPRESSED) buffer[10] = 'C';
568 if (attrs & FILE_ATTRIBUTE_DIRECTORY) buffer[12] = 'D';
569 if (attrs & FILE_ATTRIBUTE_ENCRYPTED) buffer[14] = 'E';
570 if (attrs & FILE_ATTRIBUTE_TEMPORARY) buffer[16] = 'T';
571 if (attrs & FILE_ATTRIBUTE_SPARSE_FILE) buffer[18] = 'P';
572 if (attrs & FILE_ATTRIBUTE_REPARSE_POINT) buffer[20] = 'Q';
573 if (attrs & FILE_ATTRIBUTE_OFFLINE) buffer[22] = 'O';
574 if (attrs & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) buffer[24] = 'X';
577 if (calcWidthCol == -1)
578 _out_wrkr.output_tabbed_text(dis, _positions, col, buffer);
579 else if (calcWidthCol==col || calcWidthCol==COLUMNS)
580 calc_tabbed_width(dis, col, buffer);
586 if (flags.security) {
587 DWORD rights = get_access_mask();
589 tcscpy(buffer, TEXT(" \t \t \t \t \t \t \t \t \t \t \t "));
591 if (rights & FILE_READ_DATA) buffer[ 0] = 'R';
592 if (rights & FILE_WRITE_DATA) buffer[ 2] = 'W';
593 if (rights & FILE_APPEND_DATA) buffer[ 4] = 'A';
594 if (rights & FILE_READ_EA) {buffer[6] = 'entry'; buffer[ 7] = 'R';}
595 if (rights & FILE_WRITE_EA) {buffer[9] = 'entry'; buffer[10] = 'W';}
596 if (rights & FILE_EXECUTE) buffer[12] = 'X';
597 if (rights & FILE_DELETE_CHILD) buffer[14] = 'D';
598 if (rights & FILE_READ_ATTRIBUTES) {buffer[16] = 'a'; buffer[17] = 'R';}
599 if (rights & FILE_WRITE_ATTRIBUTES) {buffer[19] = 'a'; buffer[20] = 'W';}
600 if (rights & WRITE_DAC) buffer[22] = 'C';
601 if (rights & WRITE_OWNER) buffer[24] = 'O';
602 if (rights & SYNCHRONIZE) buffer[26] = 'S';
604 output_text(dis, col++, buffer, DT_LEFT, 3, psize);
607 if (flags.description) {
608 get_description(buffer);
609 output_text(dis, col++, buffer, 0, psize);
615 void Pane::calc_width(LPDRAWITEMSTRUCT dis, int col, LPCTSTR str)
617 RECT rt = {0, 0, 0, 0};
619 DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX);
621 if (rt.right > _widths[col])
622 _widths[col] = rt.right;
625 void Pane::calc_tabbed_width(LPDRAWITEMSTRUCT dis, int col, LPCTSTR str)
627 RECT rt = {0, 0, 0, 0};
629 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
630 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
632 DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_CALCRECT|DT_SINGLELINE|DT_EXPANDTABS|DT_TABSTOP|(2<<8));
635 if (rt.right > _widths[col])
636 _widths[col] = rt.right;
640 // insert listbox entries after index idx
642 void Pane::insert_entries(Entry* dir, int idx)
649 SendMessage(_hwnd, WM_SETREDRAW, FALSE, 0); //ShowWindow(_hwnd, SW_HIDE);
651 for(; entry; entry=entry->_next) {
653 if (_treePane && !(entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY))
657 // don't display entries "." and ".." in the left pane
658 if (_treePane && (entry->_data.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
659 && entry->_data.cFileName[0]==TEXT('.'))
660 if (entry->_data.cFileName[1]==TEXT('\0') ||
661 (entry->_data.cFileName[1]==TEXT('.') && entry->_data.cFileName[2]==TEXT('\0')))
667 ListBox_InsertItemData(_hwnd, idx, entry);
669 if (_treePane && entry->_expanded)
670 insert_entries(entry->_down, idx);
673 SendMessage(_hwnd, WM_SETREDRAW, TRUE, 0); //ShowWindow(_hwnd, SW_SHOW);
677 void Pane::set_header()
680 int scroll_pos = GetScrollPos(_hwnd, SB_HORZ);
683 item.mask = HDI_WIDTH;
686 for(; x+_widths[i]<scroll_pos && i<COLUMNS; i++) {
688 Header_SetItem(_hwndHeader, i, &item);
693 item.cxy = x - scroll_pos;
694 Header_SetItem(_hwndHeader, i++, &item);
696 for(; i<COLUMNS; i++) {
697 item.cxy = _widths[i];
699 Header_SetItem(_hwndHeader, i, &item);
705 // calculate one prefered column width
707 void Pane::calc_single_width(int col)
714 int entries = ListBox_GetCount(_hwnd);
719 hfontOld = SelectFont(hdc, _out_wrkr._hfont);
721 for(cnt=0; cnt<entries; cnt++) {
722 Entry* entry = (Entry*) ListBox_GetItemData(_hwnd, cnt);
731 dis.hwndItem = _hwnd;
735 dis.rcItem.right = 0;
736 dis.rcItem.bottom = 0;
737 /*dis.itemData = 0; */
739 draw_item(&dis, entry, col);
742 SelectObject(hdc, hfontOld);
743 ReleaseDC(_hwnd, hdc);
748 cx += 3*_out_wrkr._spaceSize.cx;
750 if (cx < IMAGE_WIDTH)
756 x = _positions[col] + cx;
758 for(; col<COLUMNS; ) {
759 _positions[++col] = x;
763 ListBox_SetHorizontalExtent(_hwnd, x);
767 int Pane::Notify(int id, NMHDR* pnmh)
772 HD_NOTIFY* phdn = (HD_NOTIFY*) pnmh;
773 int idx = phdn->iItem;
774 int dx = phdn->pitem->cxy - _widths[idx];
777 ClientRect clnt(_hwnd);
779 // move immediate to simulate HDS_FULLDRAG (for now [04/2000] not realy needed with WINELIB)
780 Header_SetItem(_hwndHeader, idx, phdn->pitem);
784 for(i=idx; ++i<=COLUMNS; )
788 int scroll_pos = GetScrollPos(_hwnd, SB_HORZ);
792 rt_scr.left = _positions[idx+1]-scroll_pos;
794 rt_scr.right = clnt.right;
795 rt_scr.bottom = clnt.bottom;
797 rt_clip.left = _positions[idx]-scroll_pos;
799 rt_clip.right = clnt.right;
800 rt_clip.bottom = clnt.bottom;
802 if (rt_scr.left < 0) rt_scr.left = 0;
803 if (rt_clip.left < 0) rt_clip.left = 0;
805 ScrollWindowEx(_hwnd, dx, 0, &rt_scr, &rt_clip, 0, 0, SW_INVALIDATE);
807 rt_clip.right = _positions[idx+1];
808 RedrawWindow(_hwnd, &rt_clip, 0, RDW_INVALIDATE|RDW_UPDATENOW);
810 if (pnmh->code == HDN_ENDTRACK) {
811 ListBox_SetHorizontalExtent(_hwnd, _positions[COLUMNS]);
813 if (GetScrollPos(_hwnd, SB_HORZ) != scroll_pos)
821 case HDN_DIVIDERDBLCLICK: {
822 HD_NOTIFY* phdn = (HD_NOTIFY*) pnmh;
825 calc_single_width(phdn->iItem);
826 item.mask = HDI_WIDTH;
827 item.cxy = _widths[phdn->iItem];
829 Header_SetItem(_hwndHeader, phdn->iItem, &item);
830 InvalidateRect(_hwnd, 0, TRUE);
834 return super::Notify(id, pnmh);
841 OutputWorker::OutputWorker()
843 _hfont = CreateFont(-MulDiv(8,GetDeviceCaps(WindowCanvas(0),LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("MS Sans Serif"));
846 void OutputWorker::init_output(HWND hwnd)
850 WindowCanvas canvas(hwnd);
852 if (GetNumberFormat(LOCALE_USER_DEFAULT, 0, TEXT("1000"), 0, b, 16) > 4)
855 _num_sep = TEXT('.');
857 FontSelection font(canvas, _hfont);
858 GetTextExtentPoint32(canvas, TEXT(" "), 1, &_spaceSize);
862 void OutputWorker::output_text(LPDRAWITEMSTRUCT dis, int* positions, int col, LPCTSTR str, DWORD flags)
864 int x = dis->rcItem.left;
867 rt.left = x+positions[col]+_spaceSize.cx;
868 rt.top = dis->rcItem.top;
869 rt.right = x+positions[col+1]-_spaceSize.cx;
870 rt.bottom = dis->rcItem.bottom;
872 DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|flags);
875 void OutputWorker::output_tabbed_text(LPDRAWITEMSTRUCT dis, int* positions, int col, LPCTSTR str)
877 int x = dis->rcItem.left;
880 rt.left = x+positions[col]+_spaceSize.cx;
881 rt.top = dis->rcItem.top;
882 rt.right = x+positions[col+1]-_spaceSize.cx;
883 rt.bottom = dis->rcItem.bottom;
885 /* DRAWTEXTPARAMS dtp = {sizeof(DRAWTEXTPARAMS), 2};
886 DrawTextEx(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_NOPREFIX|DT_EXPANDTABS|DT_TABSTOP, &dtp);*/
888 DrawText(dis->hDC, (LPTSTR)str, -1, &rt, DT_SINGLELINE|DT_EXPANDTABS|DT_TABSTOP|(2<<8));
891 void OutputWorker::output_number(LPDRAWITEMSTRUCT dis, int* positions, int col, LPCTSTR str)
893 int x = dis->rcItem.left;
900 rt.left = x+positions[col]+_spaceSize.cx;
901 rt.top = dis->rcItem.top;
902 rt.right = x+positions[col+1]-_spaceSize.cx;
903 rt.bottom = dis->rcItem.bottom;
908 // insert number separator characters
909 pos = lstrlen(s) % 3;
919 DrawText(dis->hDC, b, d-b, &rt, DT_RIGHT|DT_SINGLELINE|DT_NOPREFIX|DT_END_ELLIPSIS);
923 BOOL Pane::command(UINT cmd)
931 InvalidateRect(_hwnd, 0, TRUE);
932 MenuInfo* menu_info = Frame_GetMenuInfo(GetParent(_hwnd));
934 CheckMenuItem(menu_info->_hMenuView, ID_VIEW_NAME, MF_BYCOMMAND|MF_CHECKED);
935 CheckMenuItem(menu_info->_hMenuView, ID_VIEW_ALL_ATTRIBUTES, MF_BYCOMMAND);
936 CheckMenuItem(menu_info->_hMenuView, ID_VIEW_SELECTED_ATTRIBUTES, MF_BYCOMMAND);
941 case ID_VIEW_ALL_ATTRIBUTES:
942 if (_visible_cols != COL_ALL) {
943 _visible_cols = COL_ALL;
946 InvalidateRect(_hwnd, 0, TRUE);
947 MenuInfo* menu_info = Frame_GetMenuInfo(GetParent(_hwnd));
949 CheckMenuItem(menu_info->_hMenuView, ID_VIEW_NAME, MF_BYCOMMAND);
950 CheckMenuItem(menu_info->_hMenuView, ID_VIEW_ALL_ATTRIBUTES, MF_BYCOMMAND|MF_CHECKED);
951 CheckMenuItem(menu_info->_hMenuView, ID_VIEW_SELECTED_ATTRIBUTES, MF_BYCOMMAND);
956 case ID_PREFERED_SIZES: {
959 InvalidateRect(_hwnd, 0, TRUE);
962 /* TODO: more command ids... */
971 MainFrame* Pane::get_frame()
973 HWND owner = GetParent(_hwnd);
975 return (MainFrame*)owner;