2017-11-04 07:03:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* fscrollbar.h - Widget FScrollbar *
|
|
|
|
* *
|
|
|
|
* This file is part of the Final Cut widget toolkit *
|
|
|
|
* *
|
2018-02-08 00:25:51 +01:00
|
|
|
* Copyright 2012-2018 Markus Gans *
|
2017-11-04 07:03:53 +01:00
|
|
|
* *
|
|
|
|
* The Final Cut is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* The Final Cut 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 Lesser General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Lesser General Public *
|
|
|
|
* License along with this program. If not, see *
|
|
|
|
* <http://www.gnu.org/licenses/>. *
|
|
|
|
***********************************************************************/
|
2017-10-02 07:32:33 +02:00
|
|
|
|
|
|
|
/* Inheritance diagram
|
|
|
|
* ═══════════════════
|
|
|
|
*
|
2017-10-29 14:27:50 +01:00
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FTerm ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
2017-10-02 07:32:33 +02:00
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
|
2017-10-29 14:27:50 +01:00
|
|
|
* ▕ FVTerm ▏ ▕ FObject ▏
|
2017-10-02 07:32:33 +02:00
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲ ▲
|
|
|
|
* │ │
|
|
|
|
* └─────┬─────┘
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FWidget ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▏
|
|
|
|
* ▲
|
|
|
|
* │
|
|
|
|
* ▕▔▔▔▔▔▔▔▔▔▔▔▔▏
|
|
|
|
* ▕ FScrollbar ▏
|
|
|
|
* ▕▁▁▁▁▁▁▁▁▁▁▁▁▏
|
|
|
|
*/
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#ifndef FSCROLLBAR_H
|
|
|
|
#define FSCROLLBAR_H
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-10-31 00:41:59 +01:00
|
|
|
#if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
|
|
|
|
#error "Only <final/final.h> can be included directly."
|
|
|
|
#endif
|
|
|
|
|
2017-09-17 21:32:46 +02:00
|
|
|
#include "final/fwidget.h"
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2015-09-25 21:37:19 +02:00
|
|
|
|
2015-05-23 13:35:12 +02:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FScrollbar
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma pack(push)
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
class FScrollbar : public FWidget
|
|
|
|
{
|
2017-09-11 03:06:02 +02:00
|
|
|
public:
|
|
|
|
// Using-declarations
|
|
|
|
using FWidget::setGeometry;
|
|
|
|
|
|
|
|
// Enumeration
|
|
|
|
enum sType
|
|
|
|
{
|
|
|
|
noScroll = 0,
|
|
|
|
scrollJump = 1,
|
|
|
|
scrollStepBackward = 2,
|
|
|
|
scrollStepForward = 3,
|
|
|
|
scrollPageBackward = 4,
|
|
|
|
scrollPageForward = 5,
|
|
|
|
scrollWheelUp = 6,
|
|
|
|
scrollWheelDown = 7
|
|
|
|
};
|
|
|
|
|
|
|
|
// Constructors
|
|
|
|
explicit FScrollbar(FWidget* = 0);
|
|
|
|
FScrollbar (int = fc::vertical, FWidget* = 0);
|
|
|
|
|
|
|
|
// Destructor
|
|
|
|
virtual ~FScrollbar();
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
const char* getClassName() const;
|
|
|
|
int getValue() const;
|
|
|
|
sType getScrollType() const;
|
|
|
|
|
|
|
|
// Mutators
|
|
|
|
void setMinimum (int);
|
|
|
|
void setMaximum (int);
|
|
|
|
void setRange (int, int);
|
|
|
|
void setValue (int);
|
|
|
|
void setSteps (double);
|
|
|
|
void setPageSize (int, int);
|
|
|
|
void setOrientation (int);
|
|
|
|
void setGeometry (int, int, int, int, bool = true);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void resize();
|
|
|
|
void redraw();
|
|
|
|
void calculateSliderValues();
|
2017-12-27 23:51:32 +01:00
|
|
|
void drawVerticalBar();
|
|
|
|
void drawHorizontalBar();
|
2017-09-11 03:06:02 +02:00
|
|
|
void drawBar();
|
|
|
|
|
|
|
|
// Event handlers
|
|
|
|
void onMouseDown (FMouseEvent*);
|
|
|
|
void onMouseUp (FMouseEvent*);
|
|
|
|
void onMouseMove (FMouseEvent*);
|
|
|
|
void onWheel (FWheelEvent*);
|
|
|
|
void onTimer (FTimerEvent*);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Disable copy constructor
|
|
|
|
FScrollbar (const FScrollbar&);
|
|
|
|
|
|
|
|
// Disable assignment operator (=)
|
|
|
|
FScrollbar& operator = (const FScrollbar&);
|
|
|
|
|
|
|
|
// Methods
|
|
|
|
void init();
|
|
|
|
void draw();
|
2017-12-27 23:51:32 +01:00
|
|
|
void drawButtons();
|
2017-09-11 03:06:02 +02:00
|
|
|
sType getClickedScrollType (int, int);
|
2018-02-08 00:25:51 +01:00
|
|
|
sType getVerticalClickedScrollType (int);
|
|
|
|
sType getHorizontalClickedScrollType (int);
|
2017-09-11 03:06:02 +02:00
|
|
|
void processMiddleButton (int, int);
|
|
|
|
void processScroll();
|
|
|
|
|
|
|
|
// Data Members
|
|
|
|
sType scroll_type;
|
|
|
|
bool threshold_reached;
|
|
|
|
int threshold_time;
|
|
|
|
int repeat_time;
|
|
|
|
int slider_click_pos;
|
|
|
|
int slider_click_stop_pos;
|
|
|
|
int current_slider_pos;
|
|
|
|
int slider_pos;
|
|
|
|
int slider_length;
|
|
|
|
int bar_length;
|
|
|
|
int val;
|
|
|
|
int min;
|
|
|
|
int max;
|
|
|
|
double steps;
|
2017-10-02 07:32:33 +02:00
|
|
|
int pagesize;
|
2017-09-11 03:06:02 +02:00
|
|
|
int length;
|
|
|
|
int bar_orientation;
|
|
|
|
int max_color;
|
2015-05-23 13:35:12 +02:00
|
|
|
};
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
// FScrollbar inline functions
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline const char* FScrollbar::getClassName() const
|
|
|
|
{ return "FScrollbar"; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
inline int FScrollbar::getValue() const
|
|
|
|
{ return val; }
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2016-09-27 00:46:05 +02:00
|
|
|
inline FScrollbar::sType FScrollbar::getScrollType() const
|
|
|
|
{ return scroll_type; }
|
2015-05-23 13:35:12 +02:00
|
|
|
|
2017-04-09 20:08:53 +02:00
|
|
|
#endif // FSCROLLBAR_H
|