1 /*===========================================================================
2 *
3 * PUBLIC DOMAIN NOTICE
4 * National Center for Biotechnology Information
5 *
6 * This software/database is a "United States Government Work" under the
7 * terms of the United States Copyright Act. It was written as part of
8 * the author's official duties as a United States Government employee and
9 * thus cannot be copyrighted. This software/database is freely available
10 * to the public for use. The National Library of Medicine and the U.S.
11 * Government have not placed any restriction on its use or reproduction.
12 *
13 * Although all reasonable efforts have been taken to ensure the accuracy
14 * and reliability of the software and data, the NLM and the U.S.
15 * Government do not and cannot warrant the performance or results that
16 * may be obtained by using this software or data. The NLM and the U.S.
17 * Government disclaim all warranties, express or implied, including
18 * warranties of performance, merchantability or fitness for any particular
19 * purpose.
20 *
21 * Please cite the author in any work or product based on this material.
22 *
23 * ===========================================================================
24 *
25 */
26
27 #include <klib/rc.h>
28 #include <klib/text.h>
29 #include <tui/tui_dlg.h>
30 #include "tui_widget.h"
31
draw_tabhdr(struct KTUIWidget * w)32 void draw_tabhdr( struct KTUIWidget * w )
33 {
34 tui_rect r;
35 rc_t rc = KTUIDlgAbsoluteRect ( w->dlg, &r, &w->r );
36 if ( rc == 0 )
37 {
38 tui_ac ac;
39 rc = GetWidgetAc( w, ktuipa_label, &ac );
40 if ( rc == 0 )
41 {
42 struct KTUI * tui = w->tui;
43 if ( tui != NULL )
44 {
45 uint32_t x = r.top_left.x;
46 uint32_t y = r.top_left.y;
47
48 rc = draw_background( tui, w -> focused, &( r . top_left ), r. w, r . h, ac . bg );
49
50 //rc = DlgPaint( tui, x, y, r.w, r.h, ac.bg );
51 if ( rc == 0 && w->caption != NULL )
52 {
53 tui_ac hl_ac; // the highlighted style
54 rc = GetWidgetHlAc( w, ktuipa_label, &hl_ac );
55 if ( rc == 0 )
56 draw_highlighted( tui, x + 2, y, r.w - 3, &ac, &hl_ac, w->caption );
57 }
58 }
59 }
60 }
61 }
62
event_tabhdr(struct KTUIWidget * w,tui_event * event,bool hotkey)63 bool event_tabhdr( struct KTUIWidget * w, tui_event * event, bool hotkey )
64 {
65 bool res = hotkey;
66 if ( !res && event -> event_type == ktui_event_kb )
67 {
68 switch( event -> data . kb_data . code )
69 {
70 case ktui_enter : res = true; break;
71 case ktui_alpha : res = event -> data . kb_data . key == ' '; break;
72 }
73 }
74
75 if ( res )
76 KTUIDlgPushEvent( w -> dlg, ktuidlg_event_select, w -> id, 0, 0, NULL );
77 return res;
78 }
79