📄 remote_device_tree.cpp~
字号:
#include "alert_gui.h"#include "wordlist.h"#include "MessageBox.h"#include "remote_device_tree.h"Fl_Box *Box = (Fl_Box *)0;Fl_Widget *CurBtn = 0; int nCurBtnIndex = -1;int nscrX=10, nscrY=10;int nFstBtnLeft, nFstBtnTop; int nLstBtnLeft, nLstBtnTop;int nBtnWidth=100, nBtnHeight=40;int nHJJ=15, nZJJ=17; int g_nTypeNum = 0; int g_nCardCount=100; static int GetCurBtnIndex (Fl_Widget *,void *);static void cb_btn_class (Fl_Button *o, void *v);#define Color_BackGround FL_FREE_COL1#define Color_NCLetter FL_FREE_COL2#define Color_TypeWnd_Btn FL_FREE_COL3#define Color_TypeWnd_SelBtn FL_FREE_COL5#define Color_TypeWnd_ComboBackGround FL_FREE_COL5#define Color_CtrlForeGround FL_FREE_COL6void update_remote_device_tree (Fl_Scroll *scr,WordList *WD){ int i; int x,y; char *title; i = scr->children()-1; while (i>=2) { scr->remove(scr->child(i-2)); i--; } x = scr->x(); y = scr->y(); scr->begin(); Fl_Box *box1 = new Fl_Box(x+1, y+1, 30, 10); box1->color(Color_CtrlForeGround); nFstBtnLeft = x+10; nFstBtnTop = y+15; nLstBtnLeft = 0; nLstBtnTop = 0; for (int i=0;i<WD->Count;i++) { title=WD->Get(i); g_nTypeNum ++; int w=nBtnWidth, h=nBtnHeight; if (nLstBtnLeft==0&&nLstBtnTop==0) { nLstBtnLeft = nFstBtnLeft; nLstBtnTop = nFstBtnTop; } else { nLstBtnLeft += w + nHJJ; if (nLstBtnLeft>=nZJJ+5*(w+nHJJ)) { nLstBtnLeft = nFstBtnLeft; nLstBtnTop += h + nZJJ; } } Fl_Button *o = new Fl_Button (nLstBtnLeft, nLstBtnTop, w, h, title); if (o==NULL) printf("Can't new button because no memeroy!\n"); o->callback ((Fl_Callback *) cb_btn_class,(void *)scr); o->align (FL_ALIGN_CENTER | FL_ALIGN_INSIDE); o->when (FL_WHEN_RELEASE_ALWAYS); o->color(Color_TypeWnd_Btn); } int nYpos = scr->yposition(); if (nLstBtnTop==0) Box = new Fl_Box(nscrX+scr->x()+1, nLstBtnTop+46-nYpos+25, 30, 10); else Box = new Fl_Box(nscrX+scr->x()+1, nLstBtnTop+46-nYpos, 30, 10); Box->color(Color_CtrlForeGround); nCurBtnIndex = -1; scr->end(); scr->redraw(); Fl::flush();}void DelCurBtn(Fl_Scroll *scr){ int nYpos; const char *t; g_nTypeNum --; Fl_Widget *b, *last; last = CurBtn; CurBtn->color(Color_TypeWnd_Btn); CurBtn->selection_color(Color_TypeWnd_Btn); CurBtn->labelcolor(FL_BLACK); CurBtn->redraw(); if (nCurBtnIndex!=scr->children()-1) { for (int i=nCurBtnIndex; i<scr->children()-1; i++) { b = scr->child(i); t = scr->child(i+1)->label(); if (t==NULL) { last = b; while (t==NULL&&i<scr->children()-1) { i++; t = scr->child(i)->label(); } if (t==NULL) break; i--; } b->label(t); b->redraw(); } } scr->remove(last); scr->redraw(); nLstBtnLeft -= (nBtnWidth+nHJJ); if (nLstBtnLeft<0) { nLstBtnLeft = nFstBtnLeft + 4*(nBtnWidth+nHJJ); nLstBtnTop -= (nBtnHeight + nZJJ); } nYpos = scr->yposition(); Box->position(nscrX+scr->x()+1, nLstBtnTop+45-nYpos); delete last; CurBtn = NULL; nCurBtnIndex = -1;}void AddNewBtn(Fl_Scroll *scr,char *title){ g_nTypeNum ++; int w=nBtnWidth, h=nBtnHeight; if (nLstBtnLeft==0&&nLstBtnTop==0) { nLstBtnLeft = nFstBtnLeft; nLstBtnTop = nFstBtnTop; } else { nLstBtnLeft += w + nHJJ; if ( nLstBtnLeft >= nZJJ+5*(w+nHJJ) ) { nLstBtnLeft = nFstBtnLeft; nLstBtnTop += h + nZJJ; } } int nYpos = scr->yposition(); Box->position(nscrX+scr->x()+1, nLstBtnTop+45-nYpos); int x = nLstBtnLeft; int y = nLstBtnTop; Fl_Button *o = new Fl_Button (x, y, w, h, title); if (o==NULL) printf("Can't create button because no memeroy!\n"); o->callback ((Fl_Callback *) cb_btn_class,(void *)scr); o->align (FL_ALIGN_CENTER | FL_ALIGN_INSIDE); o->when (FL_WHEN_RELEASE_ALWAYS); o->color(Color_TypeWnd_Btn); scr->add(o); scr->redraw(); }void cb_btn_class (Fl_Button *o, void *v){ if (CurBtn==o) return; bt_setup_del_one->activate(); o->color(Color_TypeWnd_SelBtn); o->selection_color(Color_TypeWnd_SelBtn); o->labelcolor(FL_WHITE); o->redraw (); nCurBtnIndex = GetCurBtnIndex(o,v); if (CurBtn==NULL) { CurBtn = o; return; } CurBtn->color(Color_TypeWnd_Btn); CurBtn->selection_color(Color_TypeWnd_Btn); CurBtn->labelcolor(FL_BLACK); CurBtn->redraw(); CurBtn = o;}int GetCurBtnIndex (Fl_Widget *o,void *v){ Fl_Scroll *scr; scr=(Fl_Scroll *)v; if (NULL==o) return -1; for (int i=0; i<scr->children(); ++i) if (scr->child(i)==o) return i; return -1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -