Index: window.h =================================================================== RCS file: /cvs/cygwin-apps/setup/window.h,v retrieving revision 2.5 diff -p -u -b -r2.5 window.h --- window.h 26 Nov 2002 12:11:35 -0000 2.5 +++ window.h 4 Jun 2003 04:17:18 -0000 @@ -1,8 +1,8 @@ -#ifndef CINSTALL_WINDOW_H -#define CINSTALL_WINDOW_H +#ifndef SETUP_WINDOW_H +#define SETUP_WINDOW_H /* - * Copyright (c) 2001, Gary R. Van Sickle. + * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include class String; +class RECTWrapper; class Window { @@ -36,6 +37,7 @@ class Window static LRESULT CALLBACK WindowProcReflector (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + // Our Windows(tm) window handle. HWND WindowHandle; Window *Parent; @@ -55,21 +57,25 @@ public: Window (); virtual ~ Window (); + virtual bool Create (Window * Parent = NULL, + DWORD Style = + WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); + static void SetAppInstance (HINSTANCE h) { + // This only has to be called once in the entire app, before + // any Windows are created. AppInstance = h; }; virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam); virtual bool MessageLoop (); - virtual bool Create (Window * Parent = NULL, - DWORD Style = - WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN); void Show (int State); HWND GetHWND () const { + // Ideally this could be hidden from the user completely. return WindowHandle; }; HINSTANCE GetInstance () const @@ -95,12 +101,15 @@ public: virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam) { + // Not processed by default. Override in derived classes to + // do something with app messages if you need to. return false; }; virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code) { - // Not processed. + // Not processed by default. Override in derived classes to + // do something with command messages if you need to. return false; }; @@ -112,12 +121,12 @@ public: // Reposition the window bool MoveWindow(long x, long y, long w, long h, bool Repaint = true); + bool MoveWindow(const RECTWrapper &r, bool Repaint = true); // Set the title of the window. void SetWindowText (const String & s); RECT ScreenToClient(const RECT &r) const; - }; -#endif // CINSTALL_WINDOW_H +#endif // SETUP_WINDOW_H Index: window.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/window.cc,v retrieving revision 2.5 diff -p -u -b -r2.5 window.cc --- window.cc 26 Nov 2002 12:11:35 -0000 2.5 +++ window.cc 4 Jun 2003 04:17:19 -0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Gary R. Van Sickle. + * Copyright (c) 2001, 2002, 2003 Gary R. Van Sickle. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ #include #include "window.h" #include "String++.h" +#include "RECTWrapper.h" ATOM Window::WindowClassAtom = 0; HINSTANCE Window::AppInstance = NULL; @@ -61,7 +62,7 @@ Window::FirstWindowProcReflector (HWND h wnd = reinterpret_cast(((LPCREATESTRUCT)lParam)->lpCreateParams); // Set a backreference to this class instance in the HWND. - SetWindowLongPtr (hwnd, GWL_USERDATA, (LONG_PTR) wnd); + SetWindowLongPtr (hwnd, GWL_USERDATA, reinterpret_cast(wnd)); // Set a new WindowProc now that we have the peliminaries done. // We could instead simply do the contents of Window::WindowProcReflector @@ -85,7 +86,7 @@ Window::WindowProcReflector (HWND hwnd, Window *This; // Get our this pointer - This = (Window *) GetWindowLongPtr (hwnd, GWL_USERDATA); + This = reinterpret_cast(GetWindowLongPtr (hwnd, GWL_USERDATA)); return This->WindowProc (uMsg, wParam, lParam); } @@ -99,6 +100,7 @@ bool Window::Create (Window * parent, DW return false; } + // Save our parent, we'll probably need it eventually. Parent = parent; // Create the window instance @@ -204,6 +206,12 @@ Window::MoveWindow(long x, long y, long return ::MoveWindow (WindowHandle, x, y, w, h, Repaint); } +bool +Window::MoveWindow(const RECTWrapper &r, bool Repaint) +{ + return ::MoveWindow (WindowHandle, r.left, r.top, r.width(), r.height(), Repaint); +} + void Window::CenterWindow () { @@ -287,7 +295,7 @@ Window::PostMessage (UINT uMsg, WPARAM w UINT Window::IsButtonChecked (int nIDButton) const { - return::IsDlgButtonChecked (GetHWND (), nIDButton); + return ::IsDlgButtonChecked (GetHWND (), nIDButton); } bool @@ -322,7 +330,7 @@ bool return false; } - // Set the new fint, and redraw any text which was already in the item. + // Set the new font, and redraw any text which was already in the item. SendMessage (ctrl, WM_SETFONT, (WPARAM) hfnt, TRUE); // Save it for later.