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

ClockWindow Struct Reference

window for displaying the time in the tray notification area More...

#include <traynotify.h>

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

List of all members.

Public Types

typedef Window super

Public Member Functions

 ClockWindow (HWND hwnd)
void TimerTick ()

Static Public Member Functions

static HWND Create (HWND hwndParent)

Protected Member Functions

LRESULT WndProc (UINT nmsg, WPARAM wparam, LPARAM lparam)
int Notify (int id, NMHDR *pnmh)
bool FormatTime ()
void Paint ()

Protected Attributes

TCHAR _time [16]
ToolTip _tooltip

Detailed Description

window for displaying the time in the tray notification area

Definition at line 238 of file traynotify.h.


Member Typedef Documentation

Definition at line 240 of file traynotify.h.


Constructor & Destructor Documentation

ClockWindow::ClockWindow ( HWND  hwnd )

Definition at line 1268 of file traynotify.cpp.

References WindowHandle::_hwnd, _time, _tooltip, ToolTip::add(), FormatTime(), and TEXT.

 :  super(hwnd),
    _tooltip(hwnd)
{
    *_time = TEXT('\0');
    FormatTime();

    _tooltip.add(_hwnd, _hwnd);
}

Here is the call graph for this function:


Member Function Documentation

HWND ClockWindow::Create ( HWND  hwndParent ) [static]

Definition at line 1278 of file traynotify.cpp.

References CLASSNAME_CLOCKWINDOW, TEXT, and WINDOW_CREATOR.

{
    static BtnWindowClass wcClock(CLASSNAME_CLOCKWINDOW, CS_DBLCLKS);

    ClientRect clnt(hwndParent);

    WindowCanvas canvas(hwndParent);
    FontSelection font(canvas, GetStockFont(DEFAULT_GUI_FONT));

    RECT rect = {0, 0, 0, 0};
    TCHAR buffer[8];

    if (!GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, buffer, sizeof(buffer)/sizeof(TCHAR)))
        _tcscpy(buffer, TEXT("00:00"));

    DrawText(canvas, buffer, -1, &rect, DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT);
    int clockwindowWidth = rect.right-rect.left + 4;

    return Window::Create(WINDOW_CREATOR(ClockWindow), 0,
                            wcClock, NULL, WS_CHILD|WS_VISIBLE,
                            clnt.right-(clockwindowWidth), 1, clockwindowWidth, clnt.bottom-2, hwndParent);
}
bool ClockWindow::FormatTime (  ) [protected]

Definition at line 1344 of file traynotify.cpp.

References _time.

Referenced by ClockWindow(), and TimerTick().

{
    TCHAR buffer[16];

    if (GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, buffer, sizeof(buffer)/sizeof(TCHAR)))
        if (_tcscmp(buffer, _time)) {
            _tcscpy(_time, buffer);
            return true;    // The text to display has changed.
        }

    return false;   // no change
}

Here is the caller graph for this function:

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

Reimplemented from Window.

Definition at line 1319 of file traynotify.cpp.

{
    if (pnmh->code == TTN_GETDISPINFO) {
        LPNMTTDISPINFO pdi = (LPNMTTDISPINFO)pnmh;

        SYSTEMTIME systime;
        TCHAR buffer[64];

        GetLocalTime(&systime);

        if (GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &systime, NULL, buffer, 64))
            _tcscpy(pdi->szText, buffer);
        else
            pdi->szText[0] = '\0';
    }

    return 0;
}
void ClockWindow::Paint (  ) [protected]

Definition at line 1357 of file traynotify.cpp.

References WindowHandle::_hwnd, and _time.

Referenced by WndProc().

{
    PaintCanvas canvas(_hwnd);

    FillRect(canvas, &canvas.rcPaint, GetSysColorBrush(COLOR_BTNFACE));

    BkMode bkmode(canvas, TRANSPARENT);
    FontSelection font(canvas, GetStockFont(ANSI_VAR_FONT));

    DrawText(canvas, _time, -1, ClientRect(_hwnd), DT_SINGLELINE|DT_VCENTER|DT_NOPREFIX);
}

Here is the caller graph for this function:

void ClockWindow::TimerTick (  )

Definition at line 1338 of file traynotify.cpp.

References WindowHandle::_hwnd, and FormatTime().

Referenced by NotifyArea::WndProc().

{
    if (FormatTime())
        InvalidateRect(_hwnd, NULL, TRUE);  // refresh displayed time
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from Window.

Definition at line 1301 of file traynotify.cpp.

References WindowHandle::_hwnd, launch_cpanel(), Paint(), TEXT, and Window::WndProc().

{
    switch(nmsg) {
      case WM_PAINT:
        Paint();
        break;

      case WM_LBUTTONDBLCLK:
        launch_cpanel(_hwnd, TEXT("timedate.cpl"));
        break;

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

    return 0;
}

Here is the call graph for this function:


Member Data Documentation

TCHAR ClockWindow::_time[16] [protected]

Definition at line 255 of file traynotify.h.

Referenced by ClockWindow(), FormatTime(), and Paint().

Definition at line 256 of file traynotify.h.

Referenced by ClockWindow().


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