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

📄 knotebook.cpp

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*  This file is part of the KDE Libraries    Copyright (C) 1998 Thomas Tanghus (tanghus@earthling.net)    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library 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    Library General Public License for more details.    You should have received a copy of the GNU Library General Public License    along with this library; see the file COPYING.LIB.  If not, write to    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,    Boston, MA 02111-1307, USA.*/  #include "knotebook.h"struct KNoteBookProtected{  KWizard     *currentwiz;  QPushButton *cancel;  QPushButton *ok;  QPushButton *def;  QPushButton *help;  KTabBar     *tabbar;  QWidget     *main;  QPopupMenu  *menu;  int         current;  int         numtabs;  int         currentmenu;  bool        enablepopupmenu;  bool        enablearrowbuttons;  bool        directionsreflectspage;};KNoteBook::KNoteBook(QWidget *parent, const char *name, bool modal, WFlags f) : KDialog(parent, name, modal, f){  initMetaObject();  init();}KNoteBook::~KNoteBook(){  //debug("KNoteBook - destructor");  delete pnote;  delete sections;  //debug("KNoteBook - destructor done");}void KNoteBook::init(){  //debug("KNoteBook::init");  sections = new QList<KWizard>;  sections->setAutoDelete(true);  pnote = new KNoteBookProtected;  pnote->directionsreflectspage = pnote->enablepopupmenu = pnote->enablearrowbuttons = false;  pnote->current = -1;  pnote->numtabs = 0;  pnote->currentwiz = 0L;  pnote->ok = pnote->cancel = pnote->def = pnote->help = 0L;  pnote->tabbar = new KTabBar(this);  connect( pnote->tabbar, SIGNAL(selected(int)), SLOT( showSection(int)) );  connect( pnote->tabbar, SIGNAL(scrolled(ArrowType)),                   SLOT( tabScroll(ArrowType)) );  //debug("tabbar");  pnote->menu = new QPopupMenu();  connect( pnote->menu, SIGNAL(highlighted(int)), SLOT( menuChoice(int)) );  connect( pnote->menu, SIGNAL(activatedRedirect(int)), SLOT( menuChoiceRedirect(int)) );  //debug("init - done");}void KNoteBook::menuChoice(int c){  //debug("Activated: %d", c);  pnote->currentmenu = c;}void KNoteBook::tabScroll( ArrowType ){  //debug("KNoteBook::tabScroll");  // fake a resize event to trigger child widget moves  //QResizeEvent r( size(), size() );  //resizeEvent( &r );  //repaint(true);}void KNoteBook::menuChoiceRedirect(int c){  //debug("ActivatedRedirect: %d", c);  if(pnote->tabbar->isTabEnabled(pnote->currentmenu) &&       sections->at(pnote->currentmenu)->isPageEnabled(c))  {    gotoTab(pnote->currentmenu);    pnote->currentwiz->gotoPage(c);    }}int KNoteBook::addTab(QTab *tab, KWizardPage *p){  //debug("addTab");  int id = 0;  KWizard *wiz = new KWizard(this, 0, false); // non-modal wizard  wiz->setDirectionsReflectsPage(pnote->directionsreflectspage);  wiz->setEnableArrowButtons(pnote->enablearrowbuttons);  wiz->hide();  //debug("KWizard created");  sections->append(wiz);  if(!pnote->numtabs) // the first tab  {    pnote->current = 0;    pnote->currentwiz = wiz;  }  pnote->numtabs++;  connect( wiz, SIGNAL(popup(QPoint)), SLOT(popupMenu(QPoint)) );  connect( wiz, SIGNAL(nomorepages(bool, bool)), SLOT(directionButton(bool, bool)) );  //tab->id = pnote->numtabs;  //debug("Before adding to tabbar");  id = pnote->tabbar->addTab(tab);  pnote->menu->insertItem(tab->label, wiz->getMenu(), id);  pnote->menu->setItemEnabled(id, tab->enabled);  //debug("After adding to tabbar");  if(p)    wiz->addPage(p);  setSizes();  //debug("addTab - done");  return id;}int KNoteBook::addPage(KWizardPage *p){  if(!pnote->numtabs)  {    debug(klocale->translate("Trying to add page when no KWizards are added!"));    return -1;  }  KWizard *wiz = sections->at(pnote->numtabs-1);  CHECK_PTR(wiz);  return (wiz->addPage(p));}void KNoteBook::gotoTab(int t){  int i = 0;  if(t < 0 || t >= pnote->numtabs || t == pnote->current)    return;  else if(t > pnote->current)    for(i = t; i < pnote->numtabs; i++)    {      if(pnote->tabbar->isTabEnabled(i))        break;    }  else    for(i = t; i >= 0; i--)    {      if(pnote->tabbar->isTabEnabled(i))        break;    }  //debug("gototab: %d", i);  if(pnote->tabbar->isTabEnabled(i))    pnote->tabbar->setCurrentTab(i);}void KNoteBook::setCancelButton(){  setCancelButton(klocale->translate("&Cancel"));}void KNoteBook::setCancelButton(const char *name){  if(!pnote->cancel)  {    pnote->cancel = new QPushButton(name, this);    pnote->cancel->show();    connect( pnote->cancel, SIGNAL(clicked()), SLOT(cancelClicked()));  }  else    pnote->cancel->setText(name);  setSizes();}QButton *KNoteBook::getCancelButton(){  return pnote->cancel;}void KNoteBook::setDefaultButton(){  setDefaultButton(klocale->translate("&Default"));}void KNoteBook::setDefaultButton(const char *name){  if(!pnote->def)  {    pnote->def = new QPushButton(name, this);    pnote->def->show();    connect( pnote->def, SIGNAL(clicked()), SLOT(defaultClicked()));  }  else    pnote->def->setText(name);  setSizes();}QButton *KNoteBook::getDefaultButton(){  return pnote->def;}void KNoteBook::setHelpButton(){  setHelpButton(klocale->translate("&Help"));}void KNoteBook::setHelpButton(const char *name){  if(!pnote->help)  {    pnote->help = new QPushButton(name, this);    pnote->help->show();    connect( pnote->help, SIGNAL(clicked()), SLOT(helpClicked()));  }  else    pnote->help->setText(name);  setSizes();}QButton *KNoteBook::getHelpButton(){  return pnote->help;}void KNoteBook::setOkButton(){  setOkButton(klocale->translate("&OK"));}void KNoteBook::setOkButton(const char *name){  if(!pnote->ok)  {    pnote->ok = new QPushButton(name, this);    pnote->ok->show();    connect( pnote->ok, SIGNAL(clicked()), SLOT(okClicked()));  }  else    pnote->ok->setText(name);  setSizes();}QButton *KNoteBook::getOkButton(){  return pnote->ok;}void KNoteBook::okClicked(){  emit okclicked();}void KNoteBook::cancelClicked(){  emit cancelclicked();}void KNoteBook::defaultClicked(){  emit defaultclicked(pnote->current);}void KNoteBook::helpClicked(){  emit helpclicked(pnote->current);}void KNoteBook::showSection(int s){  //debug("showSection: %d", s);  pnote->current = s;  pnote->currentwiz->hide();  pnote->currentwiz = sections->at(s);  pnote->currentwiz->gotoPage(0);  pnote->currentwiz->adjustSize();  // fake a resize event to trigger child widget moves  QResizeEvent r( size(), size() );  resizeEvent( &r );  pnote->currentwiz->show();}void KNoteBook::popupMenu(QPoint pos){  if(pnote->enablepopupmenu)  {    pnote->menu->popup(pos);  }}QSize KNoteBook::childSize(){  //debug("Calculating sizes");  QSize size(0,0);  //int x = 0, y = 0;  for(int i = 0; i < pnote->numtabs; i++)  {    QSize csize = sections->at(i)->sizeHint();    if(csize.isNull())      csize = sections->at(i)->size();    if(size.height() < csize.height())      size.setHeight(csize.height());    if(size.width() < csize.width())      size.setWidth(csize.width());    //debug("Child size: %d x %d", size.width(), size.height());  }  return size;}void KNoteBook::setEnableArrowButtons(bool state){

⌨️ 快捷键说明

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