1 /* -*-C++-*- $NetBSD: tabwindow.h,v 1.5 2005/12/11 12:17:28 christos 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 BOOL focusManagerHook(WORD, UINT, HWND); 66 67 // setup child instance. 68 TabWindow *boot(int id); 69 70 // insert child dialog to me. 71 void insert(int id, TC_ITEM &item) { 72 TabCtrl_InsertItem(_window, id, &item); 73 } 74 // return tab-control region. 75 void adjust(RECT &rect) { 76 TabCtrl_AdjustRect(_window, FALSE, &rect); 77 } 78 }; 79 80 class TabWindow : public Window 81 { 82 public: 83 TabWindowBase &_base; 84 RECT _rect; 85 int _id; 86 87 protected: 88 const TCHAR *_name; 89 90 explicit TabWindow(TabWindowBase &base, int id, const TCHAR *name) 91 : Window(base._app, base._window), _base(base), _name(name) { 92 _rect = _base._rect; 93 _id = id; 94 } 95 96 // utility for check box and radio button. 97 BOOL _is_checked(int id); 98 void _set_check(int id, BOOL onoff); 99 100 public: 101 virtual ~TabWindow(void) { /* NO-OP */ } 102 103 virtual BOOL proc(HWND w, UINT msg, WPARAM wparam, LPARAM lparam); 104 virtual BOOL create(LPCREATESTRUCT unused); 105 virtual void init(HWND w); 106 virtual void command(int id, int msg) { /* NO-OP */ } 107 108 // adjust my dialog size to tab-control 109 void adjust(void) { 110 MoveWindow(_window, _rect.left, 0, _rect.right - _rect.left, 111 _rect.bottom - _rect.top, TRUE); 112 } 113 virtual void hide(void) { 114 ShowWindow(_window, SW_HIDE); 115 } 116 virtual void show(void) { 117 adjust(); 118 ShowWindow(_window, SW_SHOW); 119 } 120 void update(void) { 121 InvalidateRect(_window, &_rect, TRUE); 122 } 123 }; 124 #endif // _HPCBOOT_TABWINDOW_H_ 125