/* * pawsstackcountwindow.h - Author: Ondrej Hurt * * Copyright (C) 2003 Atomic Blue (info@planeshift.it, http://www.atomicblue.org) * * * 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 (version 2 of the License) * 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. * */ #ifndef PAWS_STACK_COUNT_WINDOW_HEADER #define PAWS_STACK_COUNT_WINDOW_HEADER #include "paws/pawswidget.h" class pawsTextBox; class pawsEditTextBox; class pawsScrollBar; class pawsButton; class iOnCountEnteredAction { public: virtual void Execute(int stackCount) = 0; // can be -1 }; class pawsStackCountWindow : public pawsWidget { public: pawsStackCountWindow(); //from pawsWidget: virtual bool PostSetup(); virtual bool OnButtonPressed( int button, int keyModifier, pawsWidget* widget ); virtual bool OnScroll( int scrollDirection, pawsScrollBar* widget ); virtual bool OnChange(pawsWidget * widget); /** Prepares dialog for reuse */ void ResetDialog(); /** Sets maximal number that the user should be allowed to enter */ void SetMaxCount(int maxCount); /** Sets callback to be called when user finishes input */ void SetAction(iOnCountEnteredAction * action) { this->action = action; } /** * Static method: * Shows pawsStackCountWindow (that is hidden), sets maxCount and callback action * Ownership of 'action' goes to calee. * After the user enters count or hits cancel, the window will hide itself and calls the callback. */ static void GetStackCount(iOnCountEnteredAction * action, int maxCount); protected: /** Sets good position on screen (=under mouse cursor) */ void SetAppropriatePos(); /** Will we allow user to enter 'text' during editation ? */ bool TextIsValidForEditing(const csString & text); /** Will we allow user to return 'text' as the final result ? The difference is that TextIsValidForOutput() won't allow zero and empty string */ bool TextIsValidForOutput(const csString & text); /** This is called when the user enters final count (which is valid) */ void CountWasEntered(int count); int maxCount; int maxDigits; /** This is last valid input from user - we use it to fall back from invalid input */ csString lastValidText; pawsTextBox * maxLabel; pawsEditTextBox * editBox; pawsScrollBar * scrollBar; pawsButton * okButton, * cancelButton; iOnCountEnteredAction * action; }; CREATE_PAWS_FACTORY( pawsStackCountWindow ); #endif