]> cygwin.com Git - cygwin-apps/setup.git/blame - window.h
2002-11-25 Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
[cygwin-apps/setup.git] / window.h
CommitLineData
df62e023
RC
1#ifndef CINSTALL_WINDOW_H
2#define CINSTALL_WINDOW_H
3
4/*
5 * Copyright (c) 2001, Gary R. Van Sickle.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * A copy of the GNU General Public License can be found at
13 * http://www.gnu.org/
14 *
15 * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
16 *
17 */
18
19// This is the header for the Window class. It serves both as a window class
20// in its own right and as a base class for other window-like classes (e.g. PropertyPage,
21// PropSheet).
22
23#include <windows.h>
24
58db1046
RC
25class String;
26
df62e023
RC
27class Window
28{
29 static ATOM WindowClassAtom;
30 static HINSTANCE AppInstance;
31
df62e023
RC
32 bool RegisterWindowClass ();
33 static LRESULT CALLBACK FirstWindowProcReflector (HWND hwnd, UINT uMsg,
34 WPARAM wParam,
35 LPARAM lParam);
36 static LRESULT CALLBACK WindowProcReflector (HWND hwnd, UINT uMsg,
37 WPARAM wParam, LPARAM lParam);
38
39 HWND WindowHandle;
40
41 Window *Parent;
42
b7301c43
RC
43 // FIXME: replace with <vector> when we get a chance.
44 static const int MAXFONTS = 5;
45 HFONT Fonts[MAXFONTS];
46 int FontCounter;
47
df62e023
RC
48protected:
49 void SetHWND (HWND h)
50 {
51 WindowHandle = h;
52 };
53
54public:
55 Window ();
56 virtual ~ Window ();
57
58 static void SetAppInstance (HINSTANCE h)
59 {
60 AppInstance = h;
61 };
62
63 virtual LRESULT WindowProc (UINT uMsg, WPARAM wParam, LPARAM lParam);
64 virtual bool MessageLoop ();
65
66 virtual bool Create (Window * Parent = NULL,
67 DWORD Style =
68 WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPCHILDREN);
69 void Show (int State);
70
71 HWND GetHWND () const
72 {
73 return WindowHandle;
74 };
75 HINSTANCE GetInstance () const
76 {
77 return AppInstance;
78 };
79
80 Window *GetParent () const
81 {
82 return Parent;
83 };
84 HWND GetDlgItem (int id) const
85 {
86 return::GetDlgItem (GetHWND (), id);
87 };
58db1046
RC
88 bool SetDlgItemFont (int id, const TCHAR * fontname, int Pointsize,
89 int Weight = FW_NORMAL, bool Italic =
90 false, bool Underline = false, bool Strikeout = false);
b7301c43
RC
91
92 UINT IsButtonChecked (int nIDButton) const;
df62e023
RC
93
94 void PostMessage (UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0);
95
96 virtual bool OnMessageApp (UINT uMsg, WPARAM wParam, LPARAM lParam)
97 {
98 return false;
99 };
100
b7301c43
RC
101 virtual bool OnMessageCmd (int id, HWND hwndctl, UINT code)
102 {
103 // Not processed.
104 return false;
105 };
106
63c82708
RC
107 RECT GetWindowRect() const;
108 RECT GetClientRect() const;
109
df62e023
RC
110 // Center the window on the parent, or on screen if no parent.
111 void CenterWindow ();
112
63c82708
RC
113 // Reposition the window
114 bool MoveWindow(long x, long y, long w, long h, bool Repaint = true);
115
58db1046
RC
116 // Set the title of the window.
117 void SetWindowText (const String & s);
118
63c82708
RC
119 RECT ScreenToClient(const RECT &r) const;
120
df62e023
RC
121};
122
123#endif // CINSTALL_WINDOW_H
This page took 0.038204 seconds and 5 git commands to generate.