1 /* -*-C++-*- $NetBSD: tabwindow.h,v 1.6 2008/04/28 20:23:20 martin 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _HPCBOOT_TABWINDOW_H_ 33 #define _HPCBOOT_TABWINDOW_H_ 34 35 class TabWindow; 36 37 class TabWindowBase : public Window { 38 public: 39 RECT _rect; 40 int _id; 41 42 private: 43 void _load_bitmap(HIMAGELIST, const TCHAR *); 44 45 public: TabWindowBase(HpcBootApp & app,HWND parent,RECT & rect,int id)46 explicit TabWindowBase(HpcBootApp &app, HWND parent, 47 RECT &rect, int id) 48 : Window(app, parent) { 49 _rect = rect; 50 _id = id; 51 } ~TabWindowBase(void)52 virtual ~TabWindowBase(void) { /* NO-OP */ } 53 54 static LRESULT CALLBACK 55 _tab_proc(HWND h, UINT msg, WPARAM param, LPARAM lparam); 56 virtual BOOL create(LPCREATESTRUCT aux); 57 58 BOOL focusManagerHook(WORD, UINT, HWND); 59 60 // setup child instance. 61 TabWindow *boot(int id); 62 63 // insert child dialog to me. insert(int id,TC_ITEM & item)64 void insert(int id, TC_ITEM &item) { 65 TabCtrl_InsertItem(_window, id, &item); 66 } 67 // return tab-control region. adjust(RECT & rect)68 void adjust(RECT &rect) { 69 TabCtrl_AdjustRect(_window, FALSE, &rect); 70 } 71 }; 72 73 class TabWindow : public Window 74 { 75 public: 76 TabWindowBase &_base; 77 RECT _rect; 78 int _id; 79 80 protected: 81 const TCHAR *_name; 82 TabWindow(TabWindowBase & base,int id,const TCHAR * name)83 explicit TabWindow(TabWindowBase &base, int id, const TCHAR *name) 84 : Window(base._app, base._window), _base(base), _name(name) { 85 _rect = _base._rect; 86 _id = id; 87 } 88 89 // utility for check box and radio button. 90 BOOL _is_checked(int id); 91 void _set_check(int id, BOOL onoff); 92 93 public: ~TabWindow(void)94 virtual ~TabWindow(void) { /* NO-OP */ } 95 96 virtual BOOL proc(HWND w, UINT msg, WPARAM wparam, LPARAM lparam); 97 virtual BOOL create(LPCREATESTRUCT unused); 98 virtual void init(HWND w); command(int id,int msg)99 virtual void command(int id, int msg) { /* NO-OP */ } 100 101 // adjust my dialog size to tab-control adjust(void)102 void adjust(void) { 103 MoveWindow(_window, _rect.left, 0, _rect.right - _rect.left, 104 _rect.bottom - _rect.top, TRUE); 105 } hide(void)106 virtual void hide(void) { 107 ShowWindow(_window, SW_HIDE); 108 } show(void)109 virtual void show(void) { 110 adjust(); 111 ShowWindow(_window, SW_SHOW); 112 } update(void)113 void update(void) { 114 InvalidateRect(_window, &_rect, TRUE); 115 } 116 }; 117 #endif // _HPCBOOT_TABWINDOW_H_ 118