LunaHook-mirror/LunaHost/GUI/controls.h

82 lines
2.4 KiB
C
Raw Normal View History

2024-02-07 20:59:24 +08:00
#ifndef LUNA_BASE_CONTROLS_H
#define LUNA_BASE_CONTROLS_H
#include"window.h"
2024-02-11 23:49:11 +08:00
#include <CommCtrl.h>
2024-02-07 20:59:24 +08:00
class control:public basewindow{
public:
mainwindow* parent;
control(mainwindow*);
virtual void dispatch(WPARAM);
2024-02-11 23:49:11 +08:00
virtual void dispatch_2(WPARAM wParam, LPARAM lParam);
2024-02-07 20:59:24 +08:00
std::function<HMENU()>oncontextmenu=[](){return (HMENU)nullptr;};
std::function<void(WPARAM)>oncontextmenucallback=[](WPARAM){};
};
class button:public control{
public:
2024-02-12 00:17:58 +08:00
button(mainwindow*,const std::wstring&,int,int,int,int,DWORD=BS_PUSHBUTTON);
2024-02-07 20:59:24 +08:00
void dispatch(WPARAM);
std::function<void()> onclick=[](){};
};
class checkbox:public button{
public:
2024-02-12 00:17:58 +08:00
checkbox(mainwindow*,const std::wstring&,int,int,int,int);
2024-02-07 20:59:24 +08:00
bool ischecked();
2024-02-09 09:25:26 +08:00
void setcheck(bool);
2024-02-07 20:59:24 +08:00
};
class textedit:public control{
public:
2024-02-12 00:17:58 +08:00
textedit(mainwindow*,const std::wstring&,int,int,int,int,DWORD stype=0);
2024-02-07 20:59:24 +08:00
void dispatch(WPARAM);
std::function<void(const std::wstring&)> ontextchange=[&](const std::wstring &text){};
void appendtext(const std::wstring&);
void scrolltoend();
};
class spinbox:public control{
HWND hUpDown;
int minv,maxv;
public:
void dispatch(WPARAM);
2024-02-12 00:17:58 +08:00
spinbox(mainwindow*,const std::wstring&,int,int,int,int,DWORD stype=0);
void setminmax(int,int);
std::pair<int,int>getminmax();
void setcurr(int);
std::function<void(int)> onvaluechange=[&](int){};
};
2024-02-07 20:59:24 +08:00
class label:public control{
public:
2024-02-12 00:17:58 +08:00
label(mainwindow*,const std::wstring&,int,int,int,int);
2024-02-07 20:59:24 +08:00
};
class listbox:public control{
public:
listbox(mainwindow*,int,int,int,int);
void dispatch(WPARAM);
int currentidx();
std::wstring text(int);
std::function<void(int)> oncurrentchange=[](int){};
void clear();
2024-02-12 00:17:58 +08:00
int additem(const std::wstring&);
2024-02-07 20:59:24 +08:00
void deleteitem(int);
void setdata(int,LONG_PTR);
2024-02-12 00:17:58 +08:00
int insertitem(int,const std::wstring&);
2024-02-07 20:59:24 +08:00
LONG_PTR getdata(int);
int count();
};
2024-02-11 23:49:11 +08:00
class listview:public control{
int headernum=1;
HIMAGELIST hImageList;
public:
listview(mainwindow*,int,int,int,int);
int insertitem(int,const std::wstring&,HICON hicon);
int insertcol(int,const std::wstring& );
void clear();
int count();
std::function<void(int)> oncurrentchange=[](int){};
std::wstring text(int,int=0);
void setheader(const std::vector<std::wstring>&);
void autosize();
int additem(const std::wstring&,HICON hicon);
2024-02-12 00:17:58 +08:00
void dispatch_2(WPARAM wParam, LPARAM lParam);
2024-02-11 23:49:11 +08:00
};
2024-02-07 20:59:24 +08:00
#endif