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

TrayNotifyDlg Struct Reference

configuration dialog for notification icons More...

#include <traynotify.h>

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

List of all members.

Public Types

typedef ResizeController< Dialogsuper

Public Member Functions

 TrayNotifyDlg (HWND hwnd)
 ~TrayNotifyDlg ()

Protected Types

typedef pair< NOTIFYICONMODE,
DWORD > 
IconStatePair
typedef map< NotifyIconIndex,
IconStatePair
IconStateMap

Protected Member Functions

virtual LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
virtual int Command (int id, int code)
virtual int Notify (int id, NMHDR *pnmh)
void Refresh ()
void InsertItem (HTREEITEM hparent, HTREEITEM after, const NotifyInfo &, HDC)
void InsertItem (HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo &, HDC, HICON, NOTIFYICONMODE)
void SetIconMode (NOTIFYICONMODE mode)
void RefreshProperties (const NotifyIconDlgInfo &entry)

Protected Attributes

HWND _tree_ctrl
HACCEL _haccel
HIMAGELIST _himl
NotifyArea_pNotifyArea
NotifyIconDlgInfoMap _info
NotifyIconCfgList _cfg_org
IconStateMap _icon_states_org
bool _show_hidden_org
HTREEITEM _hitemCurrent
HTREEITEM _hitemCurrent_visible
HTREEITEM _hitemCurrent_hidden
HTREEITEM _hitemConfig
HTREEITEM _selectedItem

Detailed Description

configuration dialog for notification icons

Definition at line 198 of file traynotify.h.


Member Typedef Documentation

Definition at line 213 of file traynotify.h.

typedef pair<NOTIFYICONMODE, DWORD> TrayNotifyDlg::IconStatePair [protected]

Definition at line 212 of file traynotify.h.

Reimplemented from ResizeController< Dialog >.

Definition at line 200 of file traynotify.h.


Constructor & Destructor Documentation

TrayNotifyDlg::TrayNotifyDlg ( HWND  hwnd )

Definition at line 894 of file traynotify.cpp.

References NotifyArea::_cfg, _cfg_org, _haccel, _himl, ExplorerGlobals::_hInstance, WindowHandle::_hwnd, NotifyArea::_icon_map, _icon_states_org, _pNotifyArea, ResizeController< Dialog >::_resize_mgr, _selectedItem, NotifyArea::_show_hidden, _show_hidden_org, _tree_ctrl, ResizeManager::Add(), g_Globals, ID_SHOW_HIDDEN_ICONS, IDA_TRAYNOTIFY, IDC_LABEL1, IDC_LABEL2, IDC_LABEL3, IDC_LABEL4, IDC_LABEL6, IDC_LAST_CHANGE, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_HIDE, IDC_NOTIFY_ICONS, IDC_NOTIFY_MODULE, IDC_NOTIFY_SHOW, IDC_NOTIFY_TITLE, IDC_NOTIFY_TOOLTIP, IDC_PICTURE, IDI_DOT, IDI_DOT_RED, IDI_DOT_TRANS, IDI_REACTOS, ImageList_AddAlphaIcon(), MOVE, MOVE_Y, Refresh(), Window::register_pretranslate(), ResizeManager::Resize(), RESIZE, RESIZE_X, and SetWindowIcon().

 :  super(hwnd),
    _tree_ctrl(GetDlgItem(hwnd, IDC_NOTIFY_ICONS)),
    _himl(ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR24, 3, 0)),
    _pNotifyArea(static_cast<NotifyArea*>(Window::get_window((HWND)SendMessage(g_Globals._hwndDesktopBar, PM_GET_NOTIFYAREA, 0, 0))))
{
    _selectedItem = 0;

    if (_pNotifyArea) {
         // save original icon states and configuration data
        for(NotifyIconMap::const_iterator it=_pNotifyArea->_icon_map.begin(); it!=_pNotifyArea->_icon_map.end(); ++it)
            _icon_states_org[it->first] = IconStatePair(it->second._mode, it->second._dwState);

        _cfg_org = _pNotifyArea->_cfg;
        _show_hidden_org = _pNotifyArea->_show_hidden;
    }

    SetWindowIcon(hwnd, IDI_REACTOS);

    _haccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_TRAYNOTIFY));

    {
    WindowCanvas canvas(_hwnd);
    HBRUSH hbkgnd = GetStockBrush(WHITE_BRUSH);

    ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT), hbkgnd, canvas);
    ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT_TRANS), hbkgnd, canvas);
    ImageList_AddAlphaIcon(_himl, SmallIcon(IDI_DOT_RED), hbkgnd, canvas);
    }

    (void)TreeView_SetImageList(_tree_ctrl, _himl, TVSIL_NORMAL);

    _resize_mgr.Add(IDC_NOTIFY_ICONS,   RESIZE);
    _resize_mgr.Add(IDC_LABEL1,         MOVE_Y);
    _resize_mgr.Add(IDC_NOTIFY_TOOLTIP, RESIZE_X|MOVE_Y);
    _resize_mgr.Add(IDC_LABEL2,         MOVE_Y);
    _resize_mgr.Add(IDC_NOTIFY_TITLE,   RESIZE_X|MOVE_Y);
    _resize_mgr.Add(IDC_LABEL3,         MOVE_Y);
    _resize_mgr.Add(IDC_NOTIFY_MODULE,  RESIZE_X|MOVE_Y);

    _resize_mgr.Add(IDC_LABEL4,         MOVE_Y);
    _resize_mgr.Add(IDC_NOTIFY_SHOW,    MOVE_Y);
    _resize_mgr.Add(IDC_NOTIFY_HIDE,    MOVE_Y);
    _resize_mgr.Add(IDC_NOTIFY_AUTOHIDE,MOVE_Y);

    _resize_mgr.Add(IDC_PICTURE,        MOVE);
    _resize_mgr.Add(ID_SHOW_HIDDEN_ICONS,MOVE_Y);

    _resize_mgr.Add(IDC_LABEL6,         MOVE_Y);
    _resize_mgr.Add(IDC_LAST_CHANGE,    MOVE_Y);

    _resize_mgr.Add(IDOK,               MOVE);
    _resize_mgr.Add(IDCANCEL,           MOVE);

    _resize_mgr.Resize(+150, +200);

    Refresh();

    SetTimer(_hwnd, 0, 3000, NULL);
    register_pretranslate(hwnd);
}

Here is the call graph for this function:

TrayNotifyDlg::~TrayNotifyDlg (  )

Definition at line 956 of file traynotify.cpp.

References _himl, WindowHandle::_hwnd, and Window::unregister_pretranslate().

{
    KillTimer(_hwnd, 0);
    unregister_pretranslate(_hwnd);
    ImageList_Destroy(_himl);
}

Here is the call graph for this function:


Member Function Documentation

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

Reimplemented from Dialog.

Definition at line 1108 of file traynotify.cpp.

References NotifyArea::_cfg, _cfg_org, NotifyInfo::_dwState, WindowHandle::_hwnd, NotifyArea::_icon_map, _icon_states_org, NotifyIconConfig::_mode, _pNotifyArea, NotifyArea::_show_hidden, _show_hidden_org, ID_REFRESH, ID_SHOW_HIDDEN_ICONS, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_HIDE, IDC_NOTIFY_SHOW, NIM_AUTO, NIM_HIDE, NIM_SHOW, PM_REFRESH, Refresh(), and SetIconMode().

{
    if (code == BN_CLICKED) {
        switch(id) {
          case ID_REFRESH:
            Refresh();
            break;

          case IDC_NOTIFY_SHOW:
            SetIconMode(NIM_SHOW);
            break;

          case IDC_NOTIFY_HIDE:
            SetIconMode(NIM_HIDE);
            break;

          case IDC_NOTIFY_AUTOHIDE:
            SetIconMode(NIM_AUTO);
            break;

          case ID_SHOW_HIDDEN_ICONS:
            if (_pNotifyArea)
                SendMessage(*_pNotifyArea, WM_COMMAND, MAKEWPARAM(id,code), 0);
            break;

          case IDOK:
            EndDialog(_hwnd, id);
            break;

          case IDCANCEL:
             // rollback changes
            if (_pNotifyArea) {
                 // restore original icon states and configuration data
                _pNotifyArea->_cfg = _cfg_org;
                _pNotifyArea->_show_hidden = _show_hidden_org;

                for(IconStateMap::const_iterator it=_icon_states_org.begin(); it!=_icon_states_org.end(); ++it) {
                    NotifyInfo& info = _pNotifyArea->_icon_map[it->first];

                    info._mode = it->second.first;
                    info._dwState = it->second.second;
                }

                SendMessage(*_pNotifyArea, PM_REFRESH, 0, 0);
            }

            EndDialog(_hwnd, id);
            break;
        }

        return 0;
    }

    return 1;
}

Here is the call graph for this function:

void TrayNotifyDlg::InsertItem ( HTREEITEM  hparent,
HTREEITEM  after,
const NotifyInfo entry,
HDC  hdc 
) [protected]

Definition at line 1051 of file traynotify.cpp.

References NotifyInfo::_hIcon, and NotifyIconConfig::_mode.

Referenced by Refresh().

{
    InsertItem(hparent, after, entry, hdc, entry._hIcon, entry._mode);
}

Here is the caller graph for this function:

void TrayNotifyDlg::InsertItem ( HTREEITEM  hparent,
HTREEITEM  after,
const NotifyIconDlgInfo entry,
HDC  hdc,
HICON  hicon,
NOTIFYICONMODE  mode 
) [protected]

Definition at line 1056 of file traynotify.cpp.

References _himl, _info, NotifyIconConfig::_tipText, _tree_ctrl, NotifyIconConfig::_windowTitle, IDS_NOTIFY_AUTOHIDE, IDS_NOTIFY_HIDE, IDS_NOTIFY_SHOW, ImageList_AddAlphaIcon(), NIM_AUTO, NIM_HIDE, NIM_SHOW, String::str(), string_from_mode(), and TEXT.

{
    int idx = _info.size() + 1;
    _info[idx] = entry;

    String mode_str = string_from_mode(mode);

    switch(mode) {
      case NIM_SHOW:    mode_str = ResString(IDS_NOTIFY_SHOW);      break;
      case NIM_HIDE:    mode_str = ResString(IDS_NOTIFY_HIDE);      break;
      case NIM_AUTO:    mode_str = ResString(IDS_NOTIFY_AUTOHIDE);
    }

    FmtString txt(TEXT("%s  -  %s  [%s]"), entry._tipText.c_str(), entry._windowTitle.c_str(), mode_str.c_str());

    TV_INSERTSTRUCT tvi;

    tvi.hParent = hparent;
    tvi.hInsertAfter = after;

    TV_ITEM& tv = tvi.item;
    tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;

    tv.lParam = (LPARAM)idx;
    tv.pszText = txt.str();
    tv.iSelectedImage = tv.iImage = ImageList_AddAlphaIcon(_himl, hicon, GetStockBrush(WHITE_BRUSH), hdc);
    (void)TreeView_InsertItem(_tree_ctrl, &tvi);
}

Here is the call graph for this function:

int TrayNotifyDlg::Notify ( int  id,
NMHDR *  pnmh 
) [protected, virtual]

Reimplemented from Window.

Definition at line 1164 of file traynotify.cpp.

References WindowHandle::_hwnd, _info, _selectedItem, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_SHOW, and RefreshProperties().

{
    switch(pnmh->code) {
      case TVN_SELCHANGED: {
        NMTREEVIEW* pnmtv = (NMTREEVIEW*)pnmh;
        int idx = pnmtv->itemNew.lParam;

        if (idx) {
            RefreshProperties(_info[idx]);
            _selectedItem = pnmtv->itemNew.hItem;
        } else {
            /*
            SetDlgItemText(_hwnd, IDC_NOTIFY_TOOLTIP, NULL);
            SetDlgItemText(_hwnd, IDC_NOTIFY_TITLE, NULL);
            SetDlgItemText(_hwnd, IDC_NOTIFY_MODULE, NULL);
            */
            CheckRadioButton(_hwnd, IDC_NOTIFY_SHOW, IDC_NOTIFY_AUTOHIDE, 0);
        }
        break;}
    }

    return 0;
}

Here is the call graph for this function:

void TrayNotifyDlg::Refresh (  ) [protected]

Todo:
refresh incrementally

Definition at line 963 of file traynotify.cpp.

References NotifyArea::_cfg, NotifyInfo::_dwState, _hitemConfig, _hitemCurrent, _hitemCurrent_hidden, _hitemCurrent_visible, WindowHandle::_hwnd, NotifyArea::_icon_map, _info, NotifyIconConfig::_mode, NotifyIconConfig::_modulePath, _pNotifyArea, NotifyArea::_show_hidden, _tree_ctrl, ID_SHOW_HIDDEN_ICONS, IDS_ITEMS_CONFIGURED, IDS_ITEMS_CUR, IDS_ITEMS_HIDDEN, IDS_ITEMS_VISIBLE, InsertItem(), and String::str().

Referenced by Command(), SetIconMode(), TrayNotifyDlg(), and WndProc().

{
    ///@todo refresh incrementally

    HiddenWindow hide(_tree_ctrl);

    TreeView_DeleteAllItems(_tree_ctrl);

    TV_INSERTSTRUCT tvi;

    tvi.hParent = 0;
    tvi.hInsertAfter = TVI_LAST;

    TV_ITEM& tv = tvi.item;
    tv.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;

    ResString str_cur(IDS_ITEMS_CUR);
    tv.pszText = str_cur.str();
    tv.iSelectedImage = tv.iImage = 0;  // IDI_DOT
    _hitemCurrent = TreeView_InsertItem(_tree_ctrl, &tvi);

    ResString str_conf(IDS_ITEMS_CONFIGURED);
    tv.pszText = str_conf.str();
    tv.iSelectedImage = tv.iImage = 2;  // IDI_DOT_RED
    _hitemConfig = TreeView_InsertItem(_tree_ctrl, &tvi);

    tvi.hParent = _hitemCurrent;

    ResString str_visible(IDS_ITEMS_VISIBLE);
    tv.pszText = str_visible.str();
    tv.iSelectedImage = tv.iImage = 0;  // IDI_DOT
    _hitemCurrent_visible = TreeView_InsertItem(_tree_ctrl, &tvi);

    ResString str_hidden(IDS_ITEMS_HIDDEN);
    tv.pszText = str_hidden.str();
    tv.iSelectedImage = tv.iImage = 1;  // IDI_DOT_TRANS
    _hitemCurrent_hidden = TreeView_InsertItem(_tree_ctrl, &tvi);

    if (_pNotifyArea) {
        _info.clear();

        tv.mask |= TVIF_PARAM;

        WindowCanvas canvas(_hwnd);

         // insert current (visible and hidden) items
        for(NotifyIconMap::const_iterator it=_pNotifyArea->_icon_map.begin(); it!=_pNotifyArea->_icon_map.end(); ++it) {
            const NotifyInfo& entry = it->second;

            InsertItem(entry._dwState&NIS_HIDDEN? _hitemCurrent_hidden: _hitemCurrent_visible, TVI_LAST, entry, canvas);
        }

         // insert configured items in tree view
        const NotifyIconCfgList& cfg = _pNotifyArea->_cfg;
        for(NotifyIconCfgList::const_iterator it=cfg.begin(); it!=cfg.end(); ++it) {
            const NotifyIconConfig& cfg_entry = *it;

            HICON hicon = 0;

            if (!cfg_entry._modulePath.empty()) {
                if ((int)ExtractIconEx(cfg_entry._modulePath, 0, NULL, &hicon, 1) <= 0)
                    hicon = 0;

                if (!hicon) {
                    SHFILEINFO sfi;

                    if (SHGetFileInfo(cfg_entry._modulePath, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_SMALLICON))
                        hicon = sfi.hIcon;
                }
            }

            InsertItem(_hitemConfig, TVI_SORT, cfg_entry, canvas, hicon, cfg_entry._mode);

            if (hicon)
                DestroyIcon(hicon);
        }

        CheckDlgButton(_hwnd, ID_SHOW_HIDDEN_ICONS, _pNotifyArea->_show_hidden? BST_CHECKED: BST_UNCHECKED);
    }

    TreeView_Expand(_tree_ctrl, _hitemCurrent_visible, TVE_EXPAND);
    TreeView_Expand(_tree_ctrl, _hitemCurrent_hidden, TVE_EXPAND);
    TreeView_Expand(_tree_ctrl, _hitemCurrent, TVE_EXPAND);
    TreeView_Expand(_tree_ctrl, _hitemConfig, TVE_EXPAND);

    TreeView_EnsureVisible(_tree_ctrl, _hitemCurrent_visible);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TrayNotifyDlg::RefreshProperties ( const NotifyIconDlgInfo entry ) [protected]

Definition at line 1188 of file traynotify.cpp.

References ExplorerGlobals::_hInstance, WindowHandle::_hwnd, NotifyIconDlgInfo::_lastChange, NotifyIconConfig::_mode, NotifyIconConfig::_modulePath, NotifyIconConfig::_tipText, NotifyIconConfig::_windowTitle, g_Globals, IDC_LAST_CHANGE, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_MODULE, IDC_NOTIFY_SHOW, IDC_NOTIFY_TITLE, IDC_NOTIFY_TOOLTIP, IDC_PICTURE, String::printf(), and TEXT.

Referenced by Notify().

{
    SetDlgItemText(_hwnd, IDC_NOTIFY_TOOLTIP, entry._tipText);
    SetDlgItemText(_hwnd, IDC_NOTIFY_TITLE, entry._windowTitle);
    SetDlgItemText(_hwnd, IDC_NOTIFY_MODULE, entry._modulePath);

    CheckRadioButton(_hwnd, IDC_NOTIFY_SHOW, IDC_NOTIFY_AUTOHIDE, IDC_NOTIFY_SHOW+entry._mode);

    String change_str;
    if (entry._lastChange)
        change_str.printf(TEXT("before %d s"), (GetTickCount()-entry._lastChange+500)/1000);
    SetDlgItemText(_hwnd, IDC_LAST_CHANGE, change_str);

    HICON hicon = 0; //get_window_icon_big(entry._hWnd, false);

     // If we could not find an icon associated with the owner window, try to load one from the owning module.
    if (!hicon && !entry._modulePath.empty()) {
        hicon = ExtractIcon(g_Globals._hInstance, entry._modulePath, 0);

        if (!hicon) {
            SHFILEINFO sfi;

            if (SHGetFileInfo(entry._modulePath, 0, &sfi, sizeof(sfi), SHGFI_ICON|SHGFI_LARGEICON))
                hicon = sfi.hIcon;
        }
    }

    if (hicon) {
        SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, (LPARAM)hicon, 0);
        DestroyIcon(hicon);
    } else
        SendMessage(GetDlgItem(_hwnd, IDC_PICTURE), STM_SETICON, 0, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void TrayNotifyDlg::SetIconMode ( NOTIFYICONMODE  mode ) [protected]

Todo:
select treeview item at new position in tree view -> refresh HTREEITEM in _selectedItem

Definition at line 1222 of file traynotify.cpp.

References NotifyArea::_cfg, _info, NotifyIconConfig::_mode, _pNotifyArea, _selectedItem, _tree_ctrl, NotifyIconConfig::match(), PM_REFRESH, Refresh(), and TreeView_GetItemData().

Referenced by Command().

{
    int idx = TreeView_GetItemData(_tree_ctrl, _selectedItem);

    if (!idx)
        return;

    NotifyIconConfig& entry = _info[idx];

    if (entry._mode != mode) {
        entry._mode = mode;

         // trigger refresh in notify area and this dialog
        if (_pNotifyArea)
            SendMessage(*_pNotifyArea, PM_REFRESH, 0, 0);
    }

    if (_pNotifyArea) {
        bool found = false;

        NotifyIconCfgList& cfg = _pNotifyArea->_cfg;
        for(NotifyIconCfgList::iterator it=cfg.begin(); it!=cfg.end(); ++it) {
            NotifyIconConfig& cfg_entry = *it;

            if (cfg_entry.match(entry)) {
                cfg_entry._mode = mode;
                ++found;
                break;
            }
        }

        if (!found) {
             // insert new configuration entry
            NotifyIconConfig cfg_entry = entry;

            cfg_entry._mode = mode;

            _pNotifyArea->_cfg.push_back(cfg_entry);
        }
    }

    Refresh();
    ///@todo select treeview item at new position in tree view -> refresh HTREEITEM in _selectedItem
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from ResizeController< Dialog >.

Definition at line 1086 of file traynotify.cpp.

References _haccel, WindowHandle::_hwnd, PM_TRANSLATE_MSG, Refresh(), and ResizeController< Dialog >::WndProc().

{
    switch(nmsg) {
      case PM_TRANSLATE_MSG: {
        MSG* pmsg = (MSG*) lparam;

        if (TranslateAccelerator(_hwnd, _haccel, pmsg))
            return TRUE;

        return FALSE;}

      case WM_TIMER:
        Refresh();
        break;

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

    return 0;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 215 of file traynotify.h.

Referenced by Command(), and TrayNotifyDlg().

HACCEL TrayNotifyDlg::_haccel [protected]

Definition at line 207 of file traynotify.h.

Referenced by TrayNotifyDlg(), and WndProc().

HIMAGELIST TrayNotifyDlg::_himl [protected]

Definition at line 208 of file traynotify.h.

Referenced by InsertItem(), TrayNotifyDlg(), and ~TrayNotifyDlg().

HTREEITEM TrayNotifyDlg::_hitemConfig [protected]

Definition at line 222 of file traynotify.h.

Referenced by Refresh().

HTREEITEM TrayNotifyDlg::_hitemCurrent [protected]

Definition at line 219 of file traynotify.h.

Referenced by Refresh().

HTREEITEM TrayNotifyDlg::_hitemCurrent_hidden [protected]

Definition at line 221 of file traynotify.h.

Referenced by Refresh().

HTREEITEM TrayNotifyDlg::_hitemCurrent_visible [protected]

Definition at line 220 of file traynotify.h.

Referenced by Refresh().

Definition at line 216 of file traynotify.h.

Referenced by Command(), and TrayNotifyDlg().

Definition at line 210 of file traynotify.h.

Referenced by InsertItem(), Notify(), Refresh(), and SetIconMode().

Definition at line 209 of file traynotify.h.

Referenced by Command(), Refresh(), SetIconMode(), and TrayNotifyDlg().

HTREEITEM TrayNotifyDlg::_selectedItem [protected]

Definition at line 223 of file traynotify.h.

Referenced by Notify(), SetIconMode(), and TrayNotifyDlg().

Definition at line 217 of file traynotify.h.

Referenced by Command(), and TrayNotifyDlg().

Definition at line 206 of file traynotify.h.

Referenced by InsertItem(), Refresh(), SetIconMode(), and TrayNotifyDlg().


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