Exemplo n.º 1
0
LRESULT CALLBACK
Window::WndProc(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  enum {
#ifndef _WIN32_WCE
    WM_VERY_FIRST = WM_NCCREATE,
#else
    WM_VERY_FIRST = WM_CREATE,
#endif
  };

  AssertNoneLocked();

  if (message == WM_GETMINMAXINFO)
    /* WM_GETMINMAXINFO is called before WM_CREATE, and we havn't set
       a Window pointer yet - let DefWindowProc() handle it */
    return ::DefWindowProc(_hWnd, message, wParam, lParam);

  Window *window;
  if (message == WM_VERY_FIRST) {
    LPCREATESTRUCT cs = (LPCREATESTRUCT)lParam;

    window = (Window *)cs->lpCreateParams;
    window->Created(_hWnd);
    window->SetUserData(window);
  } else {
    window = GetUnchecked(_hWnd);
  }

  LRESULT result = window->OnMessage(_hWnd, message, wParam, lParam);
  AssertNoneLocked();

  return result;
}
Exemplo n.º 2
0
void
EventLoop::Dispatch(const Event &event)
{
  AssertNoneLocked();
  ::TranslateMessage(&event.msg);
  ::DispatchMessage(&event.msg);
  AssertNoneLocked();
}
Exemplo n.º 3
0
  void SetText(tstring::const_pointer _text) {
    AssertNoneLocked();
    AssertThread();

    text = _text;
    Invalidate();
  }
Exemplo n.º 4
0
void
LargeTextWindow::SetText(const TCHAR *text)
{
  AssertNoneLocked();

  // Replace \n by \r\r\n to enable usage of line-breaks in edit control
  unsigned size = _tcslen(text);
  TCHAR buffer[size * sizeof(TCHAR) * 3];
  const TCHAR* p2 = text;
  TCHAR* p3 = buffer;
  for (; *p2 != _T('\0'); p2++) {
    if (*p2 == _T('\n')) {
      *p3 = _T('\r');
      p3++;
      *p3 = _T('\r');
      p3++;
      *p3 = _T('\n');
    } else if (*p2 == _T('\r')) {
      continue;
    } else {
      *p3 = *p2;
    }
    p3++;
  }
  *p3 = _T('\0');

  ::SetWindowText(hWnd, buffer);
}
Exemplo n.º 5
0
  void SetFont(const Font &_font) {
    AssertNoneLocked();
    AssertThread();

    font = &_font;
    Invalidate();
  }
Exemplo n.º 6
0
  void set_text(const TCHAR *_text) {
    AssertNoneLocked();
    AssertThread();

    text = _text;
    Invalidate();
  }
Exemplo n.º 7
0
bool
EventLoop::Get(Event &event)
{
  AssertNoneLocked();

  return queue.Wait(event);
}
Exemplo n.º 8
0
void
ButtonWindow::SetText(const TCHAR *_text)
{
  AssertNoneLocked();
  AssertThread();

  if (GetCustomPainting() || _tcschr(_text, _T('&')) == NULL) {
    ::SetWindowText(hWnd, _text);
    return;
  }

  TCHAR buffer[256]; /* should be large enough for buttons */
  static unsigned const int buffer_size = ARRAY_SIZE(buffer);

  TCHAR const *s=_text;
  TCHAR *d=buffer;

  // Workaround WIN32 special use of '&' (replace every '&' with "&&")
  // Note: Terminates loop two chars before the buffer_size. This might prevent
  // potential char copies but assures that there is always room for
  // two '&'s and the 0-terminator.
  while (*s && d < buffer + buffer_size - 2) {
    if (*s == _T('&'))
      *d++ = *s;
    *d++ = *s++;
  }
  *d=0;

  ::SetWindowText(hWnd, buffer);
}
Exemplo n.º 9
0
void
ProgressWindow::SetMessage(const TCHAR *text)
{
  AssertNoneLocked();
  AssertThread();

  message.set_text(text);
}
Exemplo n.º 10
0
  void BringToBottom() {
    AssertNoneLocked();
    AssertThread();

    ::SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
                   SWP_NOMOVE|SWP_NOSIZE|
                   SWP_NOACTIVATE|SWP_NOOWNERZORDER);
  }
Exemplo n.º 11
0
void
Window::BringToBottom()
{
  AssertNoneLocked();
  AssertThread();

  parent->BringChildToBottom(*this);
}
Exemplo n.º 12
0
  void Close() {
    AssertNoneLocked();

#ifndef USE_GDI
    OnClose();
#else
    ::SendMessage(hWnd, WM_CLOSE, 0, 0);
#endif
  }
Exemplo n.º 13
0
void
Window::SetFont(const Font &_font)
{
  AssertNoneLocked();
  AssertThread();

  ::SendMessage(hWnd, WM_SETFONT,
                (WPARAM)_font.Native(), MAKELPARAM(TRUE, 0));
}
Exemplo n.º 14
0
void
DialogEventLoop::Dispatch(Event &event)
{
  AssertNoneLocked();

  if (::IsDialogMessage(dialog, &event.msg))
    return;

  EventLoop::Dispatch(event);
}
Exemplo n.º 15
0
  void BringToTop() {
    AssertNoneLocked();
    AssertThread();

    /* not using BringWindowToTop() because it activates the
       winddow */
    ::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
                   SWP_NOMOVE|SWP_NOSIZE|
                   SWP_NOACTIVATE|SWP_NOOWNERZORDER);
  }
Exemplo n.º 16
0
void
LargeTextWindow::SetText(const TCHAR *text)
{
    AssertNoneLocked();

    if (text != nullptr)
        value = text;
    else
        value.clear();
    Invalidate();
}
Exemplo n.º 17
0
void
Window::ReleaseCapture()
{
  AssertNoneLocked();
  AssertThread();

  capture = false;

  if (parent != NULL)
    parent->ReleaseChildCapture(this);
}
Exemplo n.º 18
0
void
Window::SetCapture()
{
  AssertNoneLocked();
  AssertThread();

  if (parent != NULL)
    parent->SetChildCapture(this);

  capture = true;
}
Exemplo n.º 19
0
const tstring
ButtonWindow::GetText() const
{
  AssertNoneLocked();
  AssertThread();

  TCHAR buffer[256]; /* should be large enough for buttons */

  int length = GetWindowText(hWnd, buffer, ARRAY_SIZE(buffer));
  return tstring(buffer, length);
}
Exemplo n.º 20
0
  void SetFont(const Font &_font) {
    AssertNoneLocked();
    AssertThread();

#ifndef USE_GDI
    font = &_font;
    Invalidate();
#else
    ::SendMessage(hWnd, WM_SETFONT,
                  (WPARAM)_font.Native(), MAKELPARAM(TRUE,0));
#endif
  }
Exemplo n.º 21
0
void
ProgressWindow::SetValue(unsigned value)
{
  AssertNoneLocked();
  AssertThread();

  if (value == position)
    return;

  position = value;
  progress_bar.SetValue(value);
}
Exemplo n.º 22
0
  void ShowOnTop() {
    AssertNoneLocked();
    AssertThread();

#ifndef USE_GDI
    BringToTop();
    Show();
#else
    ::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
                   SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE|
                   SWP_NOACTIVATE|SWP_NOOWNERZORDER);
#endif
  }
Exemplo n.º 23
0
void
ProgressBar::Step()
{
  AssertNoneLocked();
  AssertThread();

#ifndef USE_GDI
  value += step_size;
  Expose();
#else
  ::SendMessage(hWnd, PBM_STEPIT, (WPARAM)0, (LPARAM)0);
#endif
}
Exemplo n.º 24
0
  /**
   * Like move(), but does not trigger a synchronous redraw.  The
   * caller is responsible for redrawing.
   */
  void FastMove(PixelScalar left, PixelScalar top,
                UPixelScalar width, UPixelScalar height) {
    AssertNoneLocked();
    AssertThread();

#ifndef USE_GDI
    Move(left, top, width, height);
#else /* USE_GDI */
    ::SetWindowPos(hWnd, NULL, left, top, width, height,
                   SWP_NOCOPYBITS | SWP_NOREDRAW | SWP_DEFERERASE |
                   SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
#endif
  }
Exemplo n.º 25
0
void
ProgressBar::SetValue(unsigned value)
{
  AssertNoneLocked();
  AssertThread();

#ifndef USE_GDI
  this->value = value;
  Expose();
#else
  ::SendMessage(hWnd, PBM_SETPOS, value, 0);
#endif
}
Exemplo n.º 26
0
void
ProgressBar::SetStep(unsigned size)
{
  AssertNoneLocked();
  AssertThread();

#ifndef USE_GDI
  step_size = size;
  Expose();
#else
  ::SendMessage(hWnd, PBM_SETSTEP, (WPARAM)size, (LPARAM)0);
#endif
}
Exemplo n.º 27
0
  void Move(PixelScalar left, PixelScalar top) {
    AssertNoneLocked();
    AssertThread();

#ifndef USE_GDI
    position = { left, top };
    Invalidate();
#else
    ::SetWindowPos(hWnd, nullptr, left, top, 0, 0,
                   SWP_NOSIZE | SWP_NOZORDER |
                   SWP_NOACTIVATE | SWP_NOOWNERZORDER);
#endif
  }
Exemplo n.º 28
0
void
Window::SetCapture()
{
  AssertNoneLocked();
  AssertThread();

  if (parent != nullptr)
    parent->SetChildCapture(this);
  else
    EnableCapture();

  capture = true;
}
Exemplo n.º 29
0
void
Window::ReleaseCapture()
{
  AssertNoneLocked();
  AssertThread();

  capture = false;

  if (parent != nullptr)
    parent->ReleaseChildCapture(this);
  else
    DisableCapture();
}
Exemplo n.º 30
0
  /**
   * Move the Window to the specified position within the parent
   * ContainerWindow and make it visible.
   */
  void MoveAndShow(const PixelRect rc) {
    AssertNoneLocked();
    AssertThread();

#ifdef USE_GDI
    ::SetWindowPos(hWnd, NULL,
                   rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
                   SWP_SHOWWINDOW | SWP_NOACTIVATE |
                   SWP_NOZORDER | SWP_NOOWNERZORDER);
#else
    Move(rc);
    Show();
#endif
  }