350 lines
8.1 KiB
Plaintext
350 lines
8.1 KiB
Plaintext
//teMenu 菜单按钮
|
|
namespace teMenu;
|
|
import color;
|
|
import win.ui.tooltip;
|
|
import fonts;
|
|
fonts.addFamily($"\res\iconfont.ttf");
|
|
|
|
class TeMenu{
|
|
ctor( winform ){
|
|
this.ico_width = 32;
|
|
this.ico_margin = 3;
|
|
this.ico_size = -25;
|
|
this.toolbar_padding_lr = 5;
|
|
this.balloonTipCtrl = {};
|
|
this.toolbars_left = {
|
|
[1] = {
|
|
tips = "新建";
|
|
text='\uE7A0';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFF80C247;
|
|
default=0xFF72B43A;
|
|
disabled=0xFFBDBDBD
|
|
}
|
|
}
|
|
};
|
|
[2] = {
|
|
tips = "打开";
|
|
text='\uE660';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFFF5B64E;
|
|
default=0xFFF5A623;
|
|
disabled=0xFF6D6D6D
|
|
}
|
|
}
|
|
};
|
|
[3] = {
|
|
tips = "保存";
|
|
text='\uE857';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFF90B5FF;
|
|
default=0xFF85AAFC;
|
|
disabled=0x5D000000
|
|
}
|
|
}
|
|
};
|
|
[4] = {
|
|
tips = "另存为";
|
|
text='\uE7E5';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFF779DED;
|
|
default=0xFF6890DF;
|
|
disabled=0x5D000000
|
|
}
|
|
}
|
|
};
|
|
[5] = {
|
|
tips = "背景色";
|
|
text = '\uE6F8';
|
|
font = LOGFONT(h=this.ico_size-5;name='iconfont');
|
|
style = {
|
|
background={
|
|
default=0xE6FFE0A3;
|
|
};
|
|
foreground={};
|
|
color={
|
|
active=0xE8000000;
|
|
default=0xFF000000;
|
|
disabled=0xFF6D6D6D
|
|
}
|
|
}
|
|
};
|
|
[6] = {
|
|
tips = "前景色";
|
|
text = '\uE602';
|
|
font = LOGFONT(h=this.ico_size+5;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFFD60000;
|
|
default=0xFFD60000;
|
|
disabled=0xFFD60000
|
|
}
|
|
}
|
|
};
|
|
[7] = {
|
|
tips = "【冻结】活动单元格所在的列、行";
|
|
text='\uE692';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xE900B7FF;
|
|
default=0xFF00B4FB;
|
|
disabled=0x5D000000
|
|
}
|
|
}
|
|
};
|
|
[8] = {
|
|
tips = "取消冻结";
|
|
text='\uEE8B';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xE900B7FF;
|
|
default=0xFF00B4FB;
|
|
disabled=0x5D000000
|
|
}
|
|
}
|
|
};
|
|
[9] = {
|
|
tips = "txt 导出 Sqlite3";
|
|
text = '\uE612';
|
|
font = LOGFONT(h=this.ico_size+5;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFF567DCC;
|
|
default=0xFF3366CC;
|
|
disabled=0xFF6D6D6D
|
|
}
|
|
}
|
|
};
|
|
[10] = {
|
|
tips = "Sqlite3 导出 txt";
|
|
text = '\uE612';
|
|
font = LOGFONT(h=this.ico_size+5;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFFCC5858;
|
|
default=0xFFCC3333;
|
|
disabled=0xFF6D6D6D
|
|
}
|
|
}
|
|
};
|
|
[11] = {
|
|
tips = "关于";
|
|
text = '\uE7AB';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFF999999;
|
|
default=0xFF878787;
|
|
disabled=0xFF6D6D6D
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.toolbars_right = {
|
|
[0] = {
|
|
tips = "帮助";
|
|
text='\uE7B0';
|
|
font = LOGFONT(h=this.ico_size;name='iconfont');
|
|
style = {
|
|
background={};
|
|
foreground={};
|
|
color={
|
|
active=0xFF999999;
|
|
default=0xFF878787;
|
|
disabled=0xFF6D6D6D
|
|
}
|
|
}
|
|
};
|
|
}
|
|
this.setStyle = function(cls, style, sameBgColor){
|
|
if(sameBgColor){
|
|
style.background.default = 0x00000000;
|
|
style.foreground.hover = ..color.argb(0,0,0,20);
|
|
style.foreground.active = ..color.argb(0,0,0,40);
|
|
}
|
|
winform[cls].skin(style);
|
|
};
|
|
this.setTipCtrl = function(winform, side, cls, index){
|
|
this.balloonTipCtrl[index] = ..win.ui.tooltip.tracking(winform,false);
|
|
winform[cls].onMouseEnter = function(wParam,lParam){
|
|
var x,y,cx,cy = winform[cls].getPos(true);
|
|
if(side == 0){
|
|
this.balloonTipCtrl[index].setText(this.toolbars_left[index].tips).trackPopup(true,x+20,y+cy );
|
|
}
|
|
elseif(side == 1){
|
|
this.balloonTipCtrl[index].setText(this.toolbars_right[index].tips).trackPopup(true,x+20,y+cy );
|
|
}
|
|
}
|
|
winform[cls].onMouseLeave = function(wParam,lParam){
|
|
this.balloonTipCtrl[index].trackPopup(false);
|
|
}
|
|
};
|
|
this.init = function(){
|
|
for(i=1; #this.toolbars_left;1){
|
|
winform.addCtrl(
|
|
['plus_left'+i] = {
|
|
cls = "plus";
|
|
left = (i - 1) * (this.ico_width + this.ico_margin) + this.toolbar_padding_lr;
|
|
top = winform.top + 2;
|
|
right = (i - 1) * (this.ico_width + this.ico_margin) + this.ico_width + this.toolbar_padding_lr;
|
|
bottom = this.ico_width+2;
|
|
border = {radius=5;color=-1;width=2};
|
|
text = this.toolbars_left[i].text;
|
|
font = this.toolbars_left[i].font;
|
|
textPadding = {top = 3};
|
|
transparent = 1;
|
|
iconText="t";
|
|
dl=1;dt=1;z=2+i
|
|
};
|
|
)
|
|
if(i == 5 || i == 6){
|
|
this.setStyle('plus_left'+i, this.toolbars_left[i].style, false);
|
|
}
|
|
else {
|
|
this.setStyle('plus_left'+i, this.toolbars_left[i].style, true);
|
|
}
|
|
this.setTipCtrl(winform, 0, 'plus_left'+i, i);
|
|
}
|
|
for(i=1; #this.toolbars_right;1){
|
|
var plus_l = winform.right - i * (this.ico_width + this.ico_margin) - this.toolbar_padding_lr;
|
|
var plus_r = winform.right - (i - 1) * (this.ico_width + this.ico_margin) - this.toolbar_padding_lr;
|
|
winform.addCtrl(
|
|
['plus_right'+i] = {
|
|
cls = "plus";
|
|
left = plus_l;
|
|
top = winform.top + 2;
|
|
right = plus_r;
|
|
bottom = this.ico_width+2;
|
|
border = {radius=5;color=-1;width=2};
|
|
text = this.toolbars_right[i].text;
|
|
font = this.toolbars_right[i].font;
|
|
textPadding = {top = 3};
|
|
transparent = 1;
|
|
dr=1;dt=1;z=2+i+#this.toolbars_left
|
|
};
|
|
)
|
|
if(i <= 3){
|
|
this.setStyle('plus_right'+i, this.toolbars_right[i].style, false);
|
|
}
|
|
else {
|
|
this.setStyle('plus_right'+i, this.toolbars_right[i].style, true);
|
|
}
|
|
this.setTipCtrl(winform, 1, 'plus_right'+i, i);
|
|
}
|
|
};
|
|
this.init();
|
|
};
|
|
setCommandFunc = function(side, idx, func){
|
|
select(side) {
|
|
case 0 {
|
|
if (idx > 0 and idx <= #this.toolbars_left) {
|
|
var ctrl = winform['plus_left'+idx];
|
|
winform['plus_left'+idx].oncommand = func(ctrl);
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
case 1 {
|
|
if (idx > 0 and idx <= #this.toolbars_right) {
|
|
var ctrl = winform['plus_right'+idx];
|
|
winform['plus_right'+idx].oncommand = func(ctrl);
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
setRightClickFunc = function(side, idx, func){
|
|
select(side) {
|
|
case 0 {
|
|
if (idx > 0 and idx <= #this.toolbars_left) {
|
|
var ctrl = winform['plus_left'+idx];
|
|
winform['plus_left'+idx].wndproc = function(hwnd,message,wParam,lParam){
|
|
if (message == 0x205/*_WM_RBUTTONUP*/) {
|
|
func(ctrl);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
case 1 {
|
|
if (idx > 0 and idx <= #this.toolbars_right) {
|
|
var ctrl = winform['plus_right'+idx];
|
|
winform['plus_right'+idx].wndproc = function(hwnd,message,wParam,lParam){
|
|
if (message == 0x205/*_WM_RBUTTONUP*/) {
|
|
func(ctrl);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
disabled = function(side, idx, status){
|
|
select(side) {
|
|
case 0 {
|
|
if (idx > 0 and idx <= #this.toolbars_left) {
|
|
winform['plus_left'+idx].disabled = status;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
case 1 {
|
|
if (idx > 0 and idx <= #this.toolbars_right) {
|
|
winform['plus_right'+idx].disabled = status;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|