Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

SDIMainFrame Struct Reference

#include <mainframe.h>

Inheritance diagram for SDIMainFrame:
Inheritance graph
[legend]
Collaboration diagram for SDIMainFrame:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ExtContextMenuHandlerT
< ShellBrowserChildT
< MainFrameBase > > 
super

Public Member Functions

 SDIMainFrame (HWND hwnd)

Static Public Member Functions

static HWND Create ()
static HWND Create (LPCTSTR path, int mode=OWM_EXPLORE|OWM_DETAILS)
static HWND Create (LPCITEMIDLIST pidl, int mode=OWM_EXPLORE|OWM_DETAILS|OWM_PIDL)

Protected Member Functions

LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
int Command (int id, int code)
void resize_frame (int cx, int cy)
void resize_children ()
void update_clnt_rect ()
void update_shell_browser ()
void jump_to (LPCTSTR path, int mode)
void jump_to (LPCITEMIDLIST path, int mode)
virtual void entry_selected (Entry *entry)
void set_url (LPCTSTR url)

Protected Attributes

ShellPathInfo _shellpath_info
WindowHandle _left_hwnd
WindowHandle _right_hwnd
int _split_pos
int _last_split
RECT _clnt_rect
String _url

Detailed Description

Definition at line 141 of file mainframe.h.


Member Typedef Documentation

Reimplemented from ExtContextMenuHandlerT< ShellBrowserChildT< MainFrameBase > >.

Definition at line 147 of file mainframe.h.


Constructor & Destructor Documentation

SDIMainFrame::SDIMainFrame ( HWND  hwnd )

Definition at line 1365 of file mainframe.cpp.

References _last_split, _split_pos, and DEFAULT_SPLIT_POS.

 :  super(hwnd)
{
    _split_pos = DEFAULT_SPLIT_POS;
    _last_split = DEFAULT_SPLIT_POS;

    /* wait for PM_OPEN_WINDOW message before creating a shell view
    update_shell_browser();*/
}

Member Function Documentation

int SDIMainFrame::Command ( int  id,
int  code 
) [protected, virtual]

Reimplemented from MainFrameBase.

Definition at line 1555 of file mainframe.cpp.

References _url, MainFrameBase::Command(), Create(), MainFrameBase::ExecuteCommandbar(), ID_VIEW_MDI, and IDW_COMMANDBAR.

{
    switch(id) {
      case ID_VIEW_MDI:
        MainFrameBase::Create(ExplorerCmd(_url, true));
        break;

      case IDW_COMMANDBAR:
        if (code == 1)
            ExecuteCommandbar(_url);
        break;

      default:
        return super::Command(id, code);
    }

    return 0;
}

Here is the call graph for this function:

HWND SDIMainFrame::Create (  ) [static]

Definition at line 1375 of file mainframe.cpp.

References ExplorerGlobals::_hframeClass, ExplorerGlobals::_hInstance, g_Globals, IDM_SDIFRAME, IDS_TITLE, and WINDOW_CREATOR.

Referenced by Command(), and Create().

{
    HMENU hMenuFrame = LoadMenu(g_Globals._hInstance, MAKEINTRESOURCE(IDM_SDIFRAME));

    return Window::Create(WINDOW_CREATOR(SDIMainFrame), 0,
                (LPCTSTR)(int)g_Globals._hframeClass, ResString(IDS_TITLE), WS_OVERLAPPEDWINDOW,
                CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
                0/*hwndDesktop*/, hMenuFrame);
}

Here is the caller graph for this function:

HWND SDIMainFrame::Create ( LPCTSTR  path,
int  mode = OWM_EXPLORE|OWM_DETAILS 
) [static]

Definition at line 1401 of file mainframe.cpp.

References Create(), MDIMainFrame::CreateChild(), GET_WINDOW, and HWND.

{
    HWND hFrame = Create();
    if (!hFrame)
        return 0;

    ShowWindow(hFrame, SW_SHOW);

    MDIMainFrame* pMainFrame = GET_WINDOW(MDIMainFrame, hFrame);

    if (pMainFrame)
        pMainFrame->CreateChild(path, mode);

    return hFrame;
}

Here is the call graph for this function:

HWND SDIMainFrame::Create ( LPCITEMIDLIST  pidl,
int  mode = OWM_EXPLORE|OWM_DETAILS|OWM_PIDL 
) [static]

Definition at line 1385 of file mainframe.cpp.

References Create(), GET_WINDOW, HWND, and jump_to().

{
    HWND hFrame = Create();
    if (!hFrame)
        return 0;

    ShowWindow(hFrame, SW_SHOW);

    SDIMainFrame* pFrame = GET_WINDOW(SDIMainFrame, hFrame);

    if (pFrame)
        pFrame->jump_to(pidl, mode);

    return hFrame;
}

Here is the call graph for this function:

void SDIMainFrame::entry_selected ( Entry entry ) [protected, virtual]

Implements BrowserCallback.

Definition at line 1692 of file mainframe.cpp.

References _left_hwnd, ShellBrowserChildT< MainFrameBase >::_shellBrowser, COUNTOF, Entry::get_path(), Entry::get_shell_folder(), String::printf(), resize_children(), set_url(), and TEXT.

{
    if (_left_hwnd)
        _shellBrowser->select_folder(entry, false);

    _shellBrowser->UpdateFolderView(entry->get_shell_folder());

     // set size of new created shell view windows
    resize_children();

    TCHAR path[MAX_PATH];

    if (entry->get_path(path, COUNTOF(path))) {
        String url;

        if (path[0] == ':')
            url.printf(TEXT("shell://%s"), path);
        else
            url.printf(TEXT("file://%s"), path);

        set_url(url);
    }
}

Here is the call graph for this function:

void SDIMainFrame::jump_to ( LPCTSTR  path,
int  mode 
) [protected]

Definition at line 1725 of file mainframe.cpp.

References ShellPathInfo::_open_mode, ShellPathInfo::_shell_path, _shellpath_info, and update_shell_browser().

Referenced by Create(), and WndProc().

{/*@@todo
    if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
        _shellBrowser->jump_to(path);

        _shellpath_info._shell_path = path;
    } else */{
        _shellpath_info._open_mode = mode;
        _shellpath_info._shell_path = path;

        update_shell_browser();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SDIMainFrame::jump_to ( LPCITEMIDLIST  path,
int  mode 
) [protected]

Definition at line 1739 of file mainframe.cpp.

References ShellPathInfo::_open_mode, ShellPathInfo::_shell_path, ShellBrowserChildT< MainFrameBase >::_shellBrowser, _shellpath_info, OWM_PIDL, and update_shell_browser().

{
    if (_shellBrowser.get() && (_shellpath_info._open_mode&~OWM_PIDL)==(mode&~OWM_PIDL)) {
        ShellPath shell_path = path;

        _shellBrowser->jump_to(shell_path);

        _shellpath_info._shell_path = shell_path;
    } else {
        _shellpath_info._open_mode = mode;
        _shellpath_info._shell_path = path;

        update_shell_browser();
    }
}

Here is the call graph for this function:

void SDIMainFrame::resize_children (  ) [protected]

Definition at line 1624 of file mainframe.cpp.

References _clnt_rect, _left_hwnd, _right_hwnd, _split_pos, and SPLIT_WIDTH.

Referenced by entry_selected(), resize_frame(), and WndProc().

{
    HDWP hdwp = BeginDeferWindowPos(2);

    int cx = _clnt_rect.left;

    if (_left_hwnd) {
        cx = _split_pos + SPLIT_WIDTH/2;

        hdwp = DeferWindowPos(hdwp, _left_hwnd, 0, _clnt_rect.left, _clnt_rect.top, _split_pos-SPLIT_WIDTH/2-_clnt_rect.left, _clnt_rect.bottom-_clnt_rect.top, SWP_NOZORDER|SWP_NOACTIVATE);
    } else {
        //_split_pos = -1;
        cx = 0;
    }

    if (_right_hwnd)
        hdwp = DeferWindowPos(hdwp, _right_hwnd, 0, _clnt_rect.left+cx+1, _clnt_rect.top, _clnt_rect.right-cx, _clnt_rect.bottom-_clnt_rect.top, SWP_NOZORDER|SWP_NOACTIVATE);

    EndDeferWindowPos(hdwp);
}

Here is the caller graph for this function:

void SDIMainFrame::resize_frame ( int  cx,
int  cy 
) [protected, virtual]

Todo:
use split bar

Reimplemented from MainFrameBase.

Definition at line 1574 of file mainframe.cpp.

References _clnt_rect, MainFrameBase::_haddressedit, MainFrameBase::_hcommandedit, MainFrameBase::_hsidebar, MainFrameBase::_hstatusbar, MainFrameBase::_htoolbar, MainFrameBase::_hwndrebar, and resize_children().

Referenced by update_clnt_rect(), update_shell_browser(), and WndProc().

{
    if (cy <= 0)
        return; // avoid resizing children when receiving RBN_AUTOSIZE while getting minimized

    RECT rect = {0, 0, cx, cy};

    if (_hwndrebar) {
        int height = ClientRect(_hwndrebar).bottom;
        rect.top += height;
        rect.top += 5;
    } else {
        if (IsWindowVisible(_htoolbar)) {
            SendMessage(_htoolbar, WM_SIZE, 0, 0);
            WindowRect rt(_htoolbar);
            rect.top = rt.bottom;
        //  rect.bottom -= rt.bottom;
        }
    }

    if (IsWindowVisible(_hstatusbar)) {
        int parts[] = {300, 500};

        SendMessage(_hstatusbar, WM_SIZE, 0, 0);
        SendMessage(_hstatusbar, SB_SETPARTS, 2, (LPARAM)&parts);
        ClientRect rt(_hstatusbar);
        rect.bottom -= rt.bottom;
    }

    if (IsWindowVisible(_haddressedit) || IsWindowVisible(_hcommandedit)) {
        ClientRect rt(_haddressedit);
        rect.bottom -= rt.bottom;

        int mid = (rect.right-rect.left) / 2;   ///@todo use split bar
        SetWindowPos(_haddressedit, 0, 0, rect.bottom, mid, rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
        SetWindowPos(_hcommandedit, 0, mid+1, rect.bottom, rect.right-(mid+1), rt.bottom, SWP_NOACTIVATE|SWP_NOZORDER);
    }

    if (IsWindowVisible(_hsidebar)) {
        WindowRect rt(_hsidebar);
        rect.left += rt.right-rt.left;

        SetWindowPos(_hsidebar, 0, -1, rect.top-1, rt.right-rt.left, rect.bottom-rect.top+1, SWP_NOACTIVATE|SWP_NOZORDER);
    }

    _clnt_rect = rect;

    resize_children();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SDIMainFrame::set_url ( LPCTSTR  url ) [protected]

Definition at line 1716 of file mainframe.cpp.

References MainFrameBase::_haddressedit, and _url.

Referenced by entry_selected().

{
    if (_url != url) {
        _url = url;

        SetWindowText(_haddressedit, url); //SendMessage(_hwndFrame, PM_URL_CHANGED, 0, (LPARAM)url);
    }
}

Here is the caller graph for this function:

void SDIMainFrame::update_clnt_rect (  ) [protected]

Definition at line 1645 of file mainframe.cpp.

References WindowHandle::_hwnd, and resize_frame().

Referenced by update_shell_browser().

{
    ClientRect rect(_hwnd);

    resize_frame(rect.right, rect.bottom);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SDIMainFrame::update_shell_browser (  ) [protected]

Definition at line 1652 of file mainframe.cpp.

References ExtContextMenuHandlerT< ShellBrowserChildT< MainFrameBase > >::_cm_ifs, ExplorerGlobals::_hInstance, WindowHandle::_hwnd, _left_hwnd, ShellPathInfo::_open_mode, _right_hwnd, ShellBrowserChildT< MainFrameBase >::_shellBrowser, _shellpath_info, _split_pos, DEFAULT_SPLIT_POS, g_Globals, IDC_FILETREE, OWM_EXPLORE, resize_frame(), SPLIT_WIDTH, and update_clnt_rect().

Referenced by jump_to().

{
    int split_pos = DEFAULT_SPLIT_POS;

    if (_shellBrowser.get()) {
        split_pos = _split_pos;
        delete _shellBrowser.release();
    }

     // create explorer treeview
    if (_shellpath_info._open_mode & OWM_EXPLORE) {
        if (!_left_hwnd) {
            ClientRect rect(_hwnd);

            _left_hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
                            WS_CHILD|WS_TABSTOP|WS_VISIBLE|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_NOTOOLTIPS|TVS_SHOWSELALWAYS,
                            0, rect.top, split_pos-SPLIT_WIDTH/2, rect.bottom-rect.top,
                            _hwnd, (HMENU)IDC_FILETREE, g_Globals._hInstance, 0);

             // display tree window as long as the shell view is not yet visible
            resize_frame(rect.right, rect.bottom);
            MoveWindow(_left_hwnd, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, TRUE);
        }
    } else {
        if (_left_hwnd) {
            DestroyWindow(_left_hwnd);
            _left_hwnd = 0;
        }
    }

    _shellBrowser = auto_ptr<ShellBrowser>(new ShellBrowser(_hwnd, _hwnd, _left_hwnd, _right_hwnd,
                                                _shellpath_info, this, _cm_ifs));

    if (_left_hwnd)
        _shellBrowser->Init();

     // update _clnt_rect and set size of new created shell view windows
    update_clnt_rect();
}

Here is the call graph for this function:

Here is the caller graph for this function:

LRESULT SDIMainFrame::WndProc ( UINT  nmsg,
WPARAM  wparam,
LPARAM  lparam 
) [protected, virtual]

Todo:
read paths and window placements from registry
Todo:
content of 'path' not used any more

Reimplemented from ExtContextMenuHandlerT< ShellBrowserChildT< MainFrameBase > >.

Definition at line 1417 of file mainframe.cpp.

References WindowHandle::_hwnd, _last_split, _left_hwnd, _right_hwnd, ShellPathInfo::_root_shell_path, _shellpath_info, _split_pos, ShellPath::assign(), COLOR_SPLITBAR, CONTEXT, jump_to(), LOG, OWM_PIDL, OWM_ROOTED, PM_OPEN_WINDOW, resize_children(), resize_frame(), ScreenToClient(), SPLIT_WIDTH, TEXT, and ExtContextMenuHandlerT< ShellBrowserChildT< MainFrameBase > >::WndProc().

{
    switch(nmsg) {
      case WM_SIZE:
        resize_frame(LOWORD(lparam), HIWORD(lparam));
        break;

      case WM_PAINT: {
        PaintCanvas canvas(_hwnd);

        if (_left_hwnd) {
            ClientRect rt(_hwnd);
            rt.left = _split_pos-SPLIT_WIDTH/2;
            rt.right = _split_pos+SPLIT_WIDTH/2+1;

            if (_right_hwnd) {
                WindowRect right_rect(_right_hwnd);
                ScreenToClient(_hwnd, &right_rect);
                rt.top = right_rect.top;
                rt.bottom = right_rect.bottom;
            }

            HBRUSH lastBrush = SelectBrush(canvas, GetStockBrush(COLOR_SPLITBAR));
            Rectangle(canvas, rt.left, rt.top-1, rt.right, rt.bottom+1);
            SelectObject(canvas, lastBrush);
        }
        break;}

      case WM_SETCURSOR:
        if (_left_hwnd)
            if (LOWORD(lparam) == HTCLIENT) {
                POINT pt;
                GetCursorPos(&pt);
                ScreenToClient(_hwnd, &pt);

                if (pt.x>=_split_pos-SPLIT_WIDTH/2 && pt.x<_split_pos+SPLIT_WIDTH/2+1) {
                    SetCursor(LoadCursor(0, IDC_SIZEWE));
                    return TRUE;
                }
            }
        goto def;

      case WM_LBUTTONDOWN:
        if (_left_hwnd) {
            int x = GET_X_LPARAM(lparam);

            ClientRect rt(_hwnd);

            if (x>=_split_pos-SPLIT_WIDTH/2 && x<_split_pos+SPLIT_WIDTH/2+1) {
                _last_split = _split_pos;
                SetCapture(_hwnd);
            }
        }
        break;

      case WM_LBUTTONUP:
        if (GetCapture() == _hwnd)
            ReleaseCapture();
        break;

      case WM_KEYDOWN:
        if (wparam == VK_ESCAPE)
            if (GetCapture() == _hwnd) {
                _split_pos = _last_split;
                resize_children();
                _last_split = -1;
                ReleaseCapture();
                SetCursor(LoadCursor(0, IDC_ARROW));
            }
        break;

      case WM_MOUSEMOVE:
        if (GetCapture() == _hwnd) {
            int x = GET_X_LPARAM(lparam);

            ClientRect rt(_hwnd);

            if (x>=0 && x<rt.right) {
                _split_pos = x;
                resize_children();
                rt.left = x-SPLIT_WIDTH/2;
                rt.right = x+SPLIT_WIDTH/2+1;
                InvalidateRect(_hwnd, &rt, FALSE);
                UpdateWindow(_left_hwnd);
                UpdateWindow(_hwnd);
                UpdateWindow(_right_hwnd);
            }
        }
        break;

      case PM_OPEN_WINDOW: {
        CONTEXT("SDIMainFrame PM_OPEN_WINDOW");

        TCHAR buffer[MAX_PATH];
        LPCTSTR path;
        ShellPath shell_path = DesktopFolderPath();

        if (lparam) {
            if (wparam & OWM_PIDL) {
                 // take over PIDL from lparam
                shell_path.assign((LPCITEMIDLIST)lparam);   // create as "rooted" window
                FileSysShellPath fsp(shell_path);
                path = fsp;

                if (path) {
                    LOG(FmtString(TEXT("SDIMainFrame PM_OPEN_WINDOW: path=%s"), path));
                    lstrcpy(buffer, path);
                    path = buffer;
                }
            } else {
                 // take over path from lparam
                path = (LPCTSTR)lparam;
                shell_path = path;  // create as "rooted" window
            }
        } else {
            ///@todo read paths and window placements from registry
            if (!GetCurrentDirectory(MAX_PATH, buffer))
                *buffer = '\0';

            path = buffer;
            shell_path = path;
        }

        if (wparam & OWM_ROOTED)
            _shellpath_info._root_shell_path = shell_path;
        else
            _shellpath_info._root_shell_path = DesktopFolderPath(); //SpecialFolderPath(CSIDL_DRIVES, _hwnd);

        jump_to(shell_path, wparam);    ///@todo content of 'path' not used any more
        return TRUE;}   // success

      default: def:
        return super::WndProc(nmsg, wparam, lparam);
    }

    return 0;
}

Here is the call graph for this function:


Member Data Documentation

RECT SDIMainFrame::_clnt_rect [protected]

Definition at line 167 of file mainframe.h.

Referenced by resize_children(), and resize_frame().

int SDIMainFrame::_last_split [protected]

Definition at line 166 of file mainframe.h.

Referenced by SDIMainFrame(), and WndProc().

Definition at line 158 of file mainframe.h.

Referenced by entry_selected(), resize_children(), update_shell_browser(), and WndProc().

Definition at line 159 of file mainframe.h.

Referenced by resize_children(), update_shell_browser(), and WndProc().

Definition at line 156 of file mainframe.h.

Referenced by jump_to(), update_shell_browser(), and WndProc().

int SDIMainFrame::_split_pos [protected]
Todo:
focus handling for TAB switching int _focus_pane; // 0: left 1: right

Definition at line 165 of file mainframe.h.

Referenced by resize_children(), SDIMainFrame(), update_shell_browser(), and WndProc().

Definition at line 169 of file mainframe.h.

Referenced by Command(), and set_url().


The documentation for this struct was generated from the following files:

ROS Explorer Source Code Documentation
generated on 02.01.2013 by doxygen

ROS Explorer Homepage