tabwindow.h revision 1.2 1 /* -*-C++-*- $NetBSD: tabwindow.h,v 1.2 2001/05/08 18:51:24 uch Exp $ */
2
3 /*-
4 * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _HPCBOOT_TABWINDOW_H_
40 #define _HPCBOOT_TABWINDOW_H_
41
42 class TabWindow;
43
44 class TabWindowBase : public Window {
45 public:
46 RECT _rect;
47 int _id;
48
49 private:
50 void _load_bitmap(HIMAGELIST, const TCHAR *);
51
52 public:
53 explicit TabWindowBase(HpcBootApp &app, HWND parent,
54 RECT &rect, int id)
55 : Window(app, parent) {
56 _rect = rect;
57 _id = id;
58 }
59 virtual ~TabWindowBase(void) { /* NO-OP */ }
60
61 static LRESULT CALLBACK
62 _tab_proc(HWND h, UINT msg, WPARAM param, LPARAM lparam);
63 virtual BOOL create(LPCREATESTRUCT aux);
64
65 // setup child instance.
66 TabWindow *boot(int id);
67
68 // insert child dialog to me.
69 void insert(int id, TC_ITEM &item) {
70 TabCtrl_InsertItem(_window, id, &item);
71 }
72 // return tab-control region.
73 void adjust(RECT &rect) {
74 TabCtrl_AdjustRect(_window, FALSE, &rect);
75 }
76 };
77
78 class TabWindow : public Window
79 {
80 public:
81 TabWindowBase &_base;
82 RECT _rect;
83 int _id;
84
85 protected:
86 const TCHAR *_name;
87
88 explicit TabWindow(TabWindowBase &base, int id, const TCHAR *name)
89 : Window(base._app, base._window), _base(base), _name(name) {
90 _rect = _base._rect;
91 _id = id;
92 }
93
94 // utility for check box and radio button.
95 BOOL _is_checked(int id);
96 void _set_check(int id, BOOL onoff);
97
98 public:
99 virtual ~TabWindow(void) { /* NO-OP */ }
100
101 virtual BOOL proc(HWND w, UINT msg, WPARAM wparam, LPARAM lparam);
102 virtual BOOL create(LPCREATESTRUCT unused);
103 virtual void init(HWND w);
104 virtual void command(int id, int msg) { /* NO-OP */ }
105
106 // adjust my dialog size to tab-control
107 void adjust(void) {
108 MoveWindow(_window, _rect.left, 0, _rect.right - _rect.left,
109 _rect.bottom - _rect.top, TRUE);
110 }
111 virtual void hide(void) {
112 ShowWindow(_window, SW_HIDE);
113 }
114 virtual void show(void) {
115 adjust();
116 ShowWindow(_window, SW_SHOW);
117 }
118 void update(void) {
119 InvalidateRect(_window, &_rect, TRUE);
120 }
121 };
122 #endif // _HPCBOOT_TABWINDOW_H_
123