|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // 独自スクロールバー
9: //
10:
11: #pragma once
12:
1.1.1.3 root 13: #include "wxtextpanel.h"
1.1 root 14:
15: wxDECLARE_EVENT(NONO_EVT_SCROLL, wxScrollEvent);
16:
1.1.1.3 root 17: class WXScrollBar : public WXTextPanel
1.1 root 18: {
1.1.1.3 root 19: using inherited = WXTextPanel;
1.1 root 20:
21: public:
22: WXScrollBar(wxWindow *parent, wxWindowID id, long style);
23: ~WXScrollBar() override;
24:
1.1.1.3 root 25: void FontChanged() override;
1.1.1.4 ! root 26: void Fit() override;
1.1.1.3 root 27:
1.1 root 28: void SetScrollParam(int pos_, int thumbsize_, int range_, int pagesize_);
29:
1.1.1.3 root 30: bool SetThumbPosition(int pos_);
1.1 root 31:
32: int GetThumbPosition() const { return thumbpos; }
33: int GetThumbSize() const { return thumbsize; }
34: int GetRange() const { return range; }
35:
36: void Draw() override;
37:
38: private:
39: void OnSize(wxSizeEvent& event);
40: void OnMouse(wxMouseEvent& event);
1.1.1.2 root 41: void OnTimer(wxTimerEvent& event);
1.1 root 42:
43: // つまみの位置を変更する (内部用)
44: void MoveThumb(int pos_);
45:
1.1.1.2 root 46: int PosCmp() const;
1.1 root 47:
48: bool is_vertical {};
1.1.1.4 ! root 49: // スクロール領域の太さというか従方向の長さ。
! 50: // 縦スクロールバーなら横幅、横スクロールバーなら高さ。
! 51: int subpx {};
1.1 root 52:
53: int thumbpos {}; // つまみの上(左)位置
54: int thumbsize {}; // つまみのサイズ
1.1.1.3 root 55: int thumbmin {}; // つまみの最小サイズ
1.1 root 56: int range {}; // スクロール領域の高さ(幅)
57: int pagesize {}; // ページアップ、ダウンの移動量
58:
59: int p1 {}; // つまみの上(左)ピクセル座標
60: int p2 {}; // つまみの下(右)ピクセル座標(開区間)
61: int range_px {}; // スクロール領域の高さ(幅)ピクセル
62:
63: int start_thumb; // ドラッグ開始時のつまみの位置
64: int start_px {}; // ドラッグ開始時のピクセル座標
65:
1.1.1.2 root 66: int mouse_px {}; // 直近のマウスカーソルのピクセル座標
67: bool left_click {}; // 左クリック継続中か
68:
69: wxTimer timer {};
70:
1.1 root 71: wxDECLARE_EVENT_TABLE();
72: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.