⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 limitwindow.cpp

📁 LINUX下
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/* * btg Copyright (C) 2005 Michael Wojciechowski. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//* * $Id: limitwindow.cpp,v 1.1.4.6 2007/09/17 15:34:50 wojci Exp $ */#include "limitwindow.h"#include <bcore/t_string.h>#include <bcore/hru.h>#include <bcore/hrr.h>#include "helpwindow.h"namespace btg{   namespace UI   {      namespace cli      {         limitWindow::limitWindow(keyMapping const& _kmap,                                  windowSize const& _ws,                                  t_int _counter1_value,                                  t_int _counter1_min,                                  t_int _counter1_max,                                  std::string const& _counter1label,                                  t_int _counter2_value,                                  t_int _counter2_min,                                  t_int _counter2_max,                                  std::string const& _counter2label,                                  t_int _counter3_value,                                  t_int _counter3_min,                                  t_int _counter3_max,                                  std::string const& _counter3label,                                  t_int _counter4_value,                                  t_int _counter4_min,                                  t_int _counter4_max,                                  std::string const& _counter4label)            : baseWindow(_kmap),              size_(_ws),              currentLimit_(limitWindow::COUNTER1),              counter_(1),              choice_(limitWindow::COUNTER1),              limitSet_(false)         {            counters_[limitWindow::COUNTER1].value = _counter1_value;            counters_[limitWindow::COUNTER2].value = _counter2_value;            counters_[limitWindow::COUNTER3].value = _counter3_value;            counters_[limitWindow::COUNTER4].value = _counter4_value;            counters_[limitWindow::COUNTER1].initial = _counter1_value;            counters_[limitWindow::COUNTER2].initial = _counter2_value;            counters_[limitWindow::COUNTER3].initial = _counter3_value;            counters_[limitWindow::COUNTER4].initial = _counter4_value;            counters_[limitWindow::COUNTER1].minimum = _counter1_min;            counters_[limitWindow::COUNTER2].minimum = _counter2_min;            counters_[limitWindow::COUNTER3].minimum = _counter3_min;            counters_[limitWindow::COUNTER4].minimum = _counter4_min;            counters_[limitWindow::COUNTER1].maximum = _counter1_max;            counters_[limitWindow::COUNTER2].maximum = _counter2_max;            counters_[limitWindow::COUNTER3].maximum = _counter3_max;            counters_[limitWindow::COUNTER4].maximum = _counter4_max;            counters_[limitWindow::COUNTER1].label = _counter1label;            counters_[limitWindow::COUNTER2].label = _counter2label;            counters_[limitWindow::COUNTER3].label = _counter3label;            counters_[limitWindow::COUNTER4].label = _counter4label;         }         dialog::RESULT limitWindow::run()         {            if (!init(size_))               {                  return dialog::R_NCREAT;               }            refresh();            keyMapping::KEYLABEL label;            bool cont = true;            while (cont)               {                  label = handleKeyboard();                  switch (label)                     {                     case keyMapping::K_QUIT:                        {                           cont = false;                           break;                        }                     case keyMapping::K_NEXT:                        {                           nextChoice();                           refresh();                           break;                        }                     case keyMapping::K_PREV:                        {                           prevChoice();                           refresh();                           break;                        }                     case keyMapping::K_DOWN:                        {                           decValue();                           refresh();                           break;                        }                     case keyMapping::K_UP:                        {                           incValue();                           refresh();                           break;                        }                     case keyMapping::K_LIST_START:                        {                           incValue(50);                           refresh();                           break;                        }                     case keyMapping::K_LIST_END:                        {                           decValue(50);                           refresh();                           break;                        }                     case keyMapping::K_HELP:                        {                           if (showHelp())                              {                                 // Resized.                                 return dialog::R_RESIZE;                              }                           refresh();                           break;                        }                     case keyMapping::K_SELECT:                        {                           // Done setting limits.                           limitSet_ = true;                           cont      = false;                           break;                        }                     case keyMapping::K_RESIZE:                        {                           return dialog::R_RESIZE;                           break;                        }                     default:                        {                           refresh();                           break;                        }                     }               }            return dialog::R_QUIT;         }         void limitWindow::resize(windowSize const& _ws)         {         }         void limitWindow::refresh()         {            if (window_ == 0)               {                  return;               }            clear();            draw();            wrefresh(window_);         }         void limitWindow::draw()         {            setColor(Colors::C_NORMAL);            counter_ = 1;            // Draw the counters.	                for (t_uint cnt = COUNTER1;                 cnt <= COUNTER4;                 cnt++)               {                  LIMIT l = static_cast<LIMIT>(cnt);                  addTopic(counters_[l].label);		                  bool changed = false;                  if (counters_[l].initial !=                       counters_[l].value)                     {                        changed = true;                     }                  addValue(l,                            counters_[l].value,                            changed);		               }            unSetColor(Colors::C_NORMAL);         }         bool limitWindow::getLimits(t_int & _counter1,                                     t_int & _counter2,                                     t_int & _counter3,                                     t_int & _counter4) const         {            if (limitSet_)               {                  _counter1 = counters_[COUNTER1].value;                  _counter2 = counters_[COUNTER2].value;                  _counter3 = counters_[COUNTER3].value;                  _counter4 = counters_[COUNTER4].value;               }            return limitSet_;         }         void limitWindow::addTopic(std::string const& _text)         {            ::wattron(window_, A_BOLD);            mvwprintw(window_, counter_, 0, "%s", _text.c_str());            ::wattroff(window_, A_BOLD);            counter_++;         }         void limitWindow::addValue(LIMIT const _type,                                     t_int const _value,                                     bool const _changed)         {            if (_changed)               {                  unSetColor(Colors::C_NORMAL);                  setColor(Colors::C_MARK);               }            if (_type == choice_)               {                  // Hightlight on.                  ::wattron(window_, A_REVERSE);               }            if (_value == -1)               {                  mvwprintw(window_, counter_, 0, "%s", "unlimited");               }            else               {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -