libyui-ncurses-pkg  2.50.8
NCPkgMenuHelp.cc
1 /****************************************************************************
2 |
3 | Copyright (c) [2002-2011] Novell, Inc.
4 | All Rights Reserved.
5 |
6 | This program is free software; you can redistribute it and/or
7 | modify it under the terms of version 2 of the GNU General Public License as
8 | published by the Free Software Foundation.
9 |
10 | This program is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | GNU General Public License for more details.
14 |
15 | You should have received a copy of the GNU General Public License
16 | along with this program; if not, contact Novell, Inc.
17 |
18 | To contact Novell about this file by physical or electronic mail,
19 | you may find current contact information at www.novell.com
20 |
21 |***************************************************************************/
22 
23 
24 /*---------------------------------------------------------------------\
25 | |
26 | __ __ ____ _____ ____ |
27 | \ \ / /_ _/ ___|_ _|___ \ |
28 | \ V / _` \___ \ | | __) | |
29 | | | (_| |___) || | / __/ |
30 | |_|\__,_|____/ |_| |_____| |
31 | |
32 | core system |
33 | (C) SuSE GmbH |
34 \----------------------------------------------------------------------/
35 
36  File: NCPkgMenuHelp.cc
37 
38  Author: Hedgehog Painter <kmachalkova@suse.cz>
39 
40 /-*/
41 #define YUILogComponent "ncurses-pkg"
42 #include <YUILog.h>
43 
44 #include "NCPkgMenuHelp.h"
45 #include "NCPkgStrings.h"
46 #include "NCPackageSelector.h"
47 
48 using std::endl;
49 
50 /*
51  Textdomain "ncurses-pkg"
52 */
53 
54 NCPkgMenuHelp::NCPkgMenuHelp (YWidget *parent, std::string label, NCPackageSelector *pkger)
55  : NCMenuButton( parent, label)
56  , pkg( pkger)
57 {
58  createLayout();
59  setFunctionKey( 1 );
60 }
61 
62 NCPkgMenuHelp::~NCPkgMenuHelp()
63 {
64 
65 }
66 
67 void NCPkgMenuHelp::createLayout()
68 {
69  if ( !pkg->isYouMode())
70  {
71  generalHelp = new YMenuItem( _( "&General Help" ) );
72  items.push_back( generalHelp );
73 
74  statusHelp = new YMenuItem( _( "&Package Status and Symbols" ) );
75  items.push_back( statusHelp );
76 
77  filterHelp = new YMenuItem( _( "&How to Use the Filters" ) );
78  items.push_back( filterHelp );
79 
80  menuHelp = new YMenuItem( _( "&Useful Functions in Menu" ) );
81  items.push_back( menuHelp );
82  }
83  else
84  {
85  patchHelp = new YMenuItem( _( "&Patch Status and Patch Installation" ));
86  items.push_back ( patchHelp );
87  }
88 
89  addItems( items);
90 }
91 
92 bool NCPkgMenuHelp::handleEvent ( const NCursesEvent & event)
93 {
94  if (!event.selection)
95  return false;
96 
97  std::string text = "";
98  std::string headline = "";
99 
100  if ( event.selection == generalHelp )
101  {
102  headline = NCPkgStrings::PackageHelp();
103  text += NCPkgStrings::HelpPkgGen1();
104  text += NCPkgStrings::HelpPkgGen2();
105  text += NCPkgStrings::HelpPkgGen3();
106  text += NCPkgStrings::HelpPkgGen4();
107  text += NCPkgStrings::HelpPkgGen5();
108  text += NCPkgStrings::HelpPkgGen6();
109 
110  }
111  else if ( event.selection == statusHelp )
112  {
113  headline = NCPkgStrings::PackageStatusHelp();
114  text += NCPkgStrings::HelpOnStatus1();
115  text += NCPkgStrings::HelpOnStatus2();
116  text += NCPkgStrings::HelpOnStatus3();
117  text += NCPkgStrings::HelpOnStatus4();
118  text += NCPkgStrings::HelpOnStatus5();
119  }
120  else if ( event.selection == menuHelp )
121  {
122  headline = NCPkgStrings::PackageMenuHelp();
123  text += NCPkgStrings::HelpPkgMenu1();
124  text += NCPkgStrings::HelpPkgMenu2();
125  text += NCPkgStrings::HelpPkgMenu2_2();
126  text += NCPkgStrings::HelpPkgMenu2_3();
127  text += NCPkgStrings::HelpPkgMenu3();
128  text += NCPkgStrings::HelpPkgMenu4();
129  text += NCPkgStrings::HelpPkgMenu5();
130  }
131  else if ( event.selection == filterHelp )
132  {
133  headline = NCPkgStrings::PackageFiltersHelp();
134  text += NCPkgStrings::HelpOnFilters1();
135  text += NCPkgStrings::HelpOnFilters2();
136  text += NCPkgStrings::HelpOnFilters3();
137  text += NCPkgStrings::HelpOnFilters4();
138  text += NCPkgStrings::HelpOnFilters5();
139  }
140  else if ( event.selection == patchHelp )
141  {
142  headline = NCPkgStrings::YouHelp();
143  text += NCPkgStrings::YouHelp1();
144  text += NCPkgStrings::YouHelp2();
145  text += NCPkgStrings::YouHelp3();
146  text += NCPkgStrings::YouHelp4();
147  text += NCPkgStrings::YouHelp5();
148  }
149  else
150  yuiError() << "zatim nic" << endl;
151 
152  NCPopupInfo * pkgHelp = new NCPopupInfo( wpos( (NCurses::lines()*8)/100, (NCurses::cols()*18)/100 ),
153  headline,
154  text
155  );
156  pkgHelp->setPreferredSize( (NCurses::cols()*65)/100, (NCurses::lines()*85)/100 );
157  pkgHelp->showInfoPopup();
158 
159  YDialog::deleteTopmostDialog();
160 
161  return true;
162 }
static const std::string YouHelp()
The headline of the help YOU popup.
static const std::string YouHelp1()
help text package status