📄 flv_list.cxx
字号:
slider_size((double) ((double) x / (double) (W - vscrollbar_width * 2)));#endif hscrollbar.Fl_Valuator::value(vrow_offset); // , 1, 0, vrows ); if (!hscrollbar.visible()) hscrollbar.set_visible(); draw_child(hscrollbar); } else hscrollbar.clear_visible(); if (sh > 0 && sv > 0) // Draw box at ends { if (parent()) fl_color(parent()->color()); else fl_color(FL_WHITE); fl_rectf(X + W, Y + H, vscrollbar_width, vscrollbar_width); }}voidFlv_List::update_top_row(int H){ int rh, r; if (vrow < vtop_row) { vtop_row = vrow; vlast_row = vrow; // Make sure we update the entire widget } else { if (label()) H -= row_height(-3); if (row_header()) H -= row_height(-1); if (row_footer()) H -= row_height(-2); for (r = vtop_row; r <= vrow && r < vrows; r++, H -= rh) { rh = row_height(r); if (rh > H) break; } if (r <= vrow) // Move top row down, so we can see current line { vlast_row = vrow; // Make sure we update the entire widget for (; r <= vrow; r++, H -= rh) { rh = row_height(r); vtop_row++; } } // If there're visible rows below the current row// if (rh<H)// {// // Finish computing visible rows// for (; r<vrows; r++, H-=rh )// {// rh = row_height(r);// if (rh>H)// break;// }// }// // Do we need to move the top row up?// if (rh<H)// {// // Too much space at bottom, we need to move top row toward 0// // If possible.// vlast_row = vrow; // Make sure we update the entire widget// for (; vtop_row>0; vtop_row--, H -= rh )// {// rh = row_height(vtop_row);// if (rh>H)// break;// }// } }}voidFlv_List::start_draw(int &X, int &Y, int &W, int &H, int &trow_width){ int rh, CX, CY, CW, CH; label_type(FL_NO_LABEL); if (damage() & FL_DAMAGE_ALL) {#if FL_MAJOR_VERSION == 2 draw_box(x(), y(), w(), h(), flags() & FL_FRAME_ONLY);#else draw_box();#endif } // Get dimension inside box X = x(); Y = y(); W = w(); H = h();#if FL_MAJOR_VERSION == 2 box()->inset(X, Y, W, H);#else Fl_Boxtype b = box(); X += Fl::box_dx(b); Y += Fl::box_dy(b); W -= Fl::box_dw(b); H -= Fl::box_dh(b);#endif draw_scrollbars(X, Y, W, H); // Place/set values, update bounding box trow_width = vrow_width; if (!trow_width) trow_width = W; // Update top row if nessasary// update_top_row(H); // Draw Title if (label()) { rh = row_height(-3); fl_clip(X, Y, W, rh); CX = X; CY = Y; CW = W; CH = rh; Flv_List::draw_row(0, CX, CY, CW, CH, -3); fl_pop_clip(); Y += rh; H -= rh; } // Draw header if visible if (row_header()) { rh = row_height(-1); fl_clip(X, Y, W, rh); CX = X; CY = Y; CW = trow_width; CH = rh; draw_row(vrow_offset, CX, CY, CW, CH, -1); fl_pop_clip(); Y += rh; H -= rh; } // Draw footer if (row_footer()) { rh = row_height(-2); H -= rh; fl_clip(X, Y + H, W, rh); CX = X; CY = Y + H; CW = trow_width; CH = rh; draw_row(vrow_offset, CX, CY, CW, CH, -2); fl_pop_clip(); }}// Perform actual draw functionvoidFlv_List::draw(){ int r, rh, rw; int X, Y, W, H, B; int CX, CY, CW, CH; Flv_Style s; // Initially verify we aren't on a locked cell r = row(); while (!select_locked()) { get_style(s, r); if (!s.locked()) { row(r); break; } if (r == rows()) break; else r++; } // Make sure we have an editor if editing! if (vediting && !veditor) switch_editor(row()); start_draw(X, Y, W, H, rw); B = W - (rw - vrow_offset); // Fill-in area at right of list if (B > 0) { fl_color(dead_space_color()); CY = Y; CH = H; if (row_header()) { CY -= row_height(-1); CH += row_height(-1); } if (row_footer()) CH += row_height(-2); fl_rectf(X + rw - vrow_offset, CY, B, CH); } B = Y + H; fl_clip(X, Y, W, H); // Draw rows for (r = vtop_row; Y < B && r < vrows; r++, Y += rh) { rh = row_height(r); if (vlast_row == vrow || (vlast_row != vrow && (r == vlast_row || r == vrow))) { fl_clip(X, Y, rw, rh); CX = X; CY = Y; CW = rw; CH = rh; draw_row(vrow_offset, CX, CY, CW, CH, r); fl_pop_clip(); } } vlast_row = vrow; // Fill-in area at bottom of list if (Y < B) { fl_color(dead_space_color()); fl_rectf(X, Y, W, B - Y); } fl_pop_clip();}intFlv_List::page_size(void){ int ps, H; if (vrows_per_page) ps = vrows_per_page; else { H = h() - 2 * vscrollbar_width; ps = 11; if (H) ps = (H / row_height(0)); ps--; if (ps < 1) ps = 1; } return ps;}boolFlv_List::move_row(int amount){ int r = row(); Flv_Style s; r += amount; if (r >= rows()) r = rows() - 1; if (r < 0) r = 0; while (!select_locked()) { get_style(s, r); if (!s.locked()) break; r += (amount < 0 ? -1 : 1); if (r < 0 || r >= rows()) return false; } if (r != row()) { row(r); return true; } return false;}voidFlv_List::get_default_style(Flv_Style & s){ int r, rh; // Make sure EVERY feature is defined s.align(FL_ALIGN_LEFT);#if FL_MAJOR_VERSION == 2 s.background(color());#else s.background(FL_WHITE);#endif s.border(FLVB_NONE); if (parent()) s.border_color(parent()->color()); else s.border_color(FL_WHITE); s.border_spacing(0); s.editor(NULL); // No editor s.font(text_font()); s.font_size(text_size()); s.foreground(text_color()); s.frame(FL_FLAT_BOX); fl_font(text_font(), text_size()); fl_measure("X", r, rh); s.height(rh); s.locked(true); s.resizable(false); s.width(40); s.x_margin(2); s.y_margin(1);}voidFlv_List::add_selection_style(Flv_Style & s, int R, int){ if (!multi_select()) // If not multi row selection select_start_row(row()); // Handle row selection if (row_selected(R)) { s.background(selection_color()); s.foreground(fl_contrast(text_color(), selection_color())); }}static Fl_Cursor last_cursor = FL_CURSOR_DEFAULT;static int drag_row = -4, anchor_top;boolFlv_List::check_resize(void){ int ey, h; bool w = false; ey = Fl::event_y(); if (drag_row > -4) { if (drag_row == -2) { h = anchor_top - ey + row_height(drag_row); if (h > 1) { row_style[drag_row].height(h); damage(FL_DAMAGE_CHILD); anchor_top = ey; w = true; } } else { h = ey - anchor_top; if (h < 1) h = 1; row_style[drag_row].height(h); damage(FL_DAMAGE_CHILD); w = true; } } return w;}// See if we can resize, if so change cursorvoidFlv_List::check_cursor(void){ int X, Y, W, H, ey, move = 0, WW, size; int v; Fl_Cursor cursor; ey = Fl::event_y(); client_area(X, Y, W, H); if (label() && *label()) { Y += row_height(-3); H -= row_height(-3); }// if (full_resize()) // Trival test first { if (row_header()) { size = row_height(-1); if (ey >= Y + size - FUDGE && ey <= Y + size + FUDGE) { if (row_resizable(-1)) { drag_row = -1; anchor_top = Y; move |= MOVE_Y; // Moving } } Y += size; H -= size; } if (row_footer()) { size = row_height(-2); if (ey >= Y + H - size - FUDGE && ey <= Y + H - size + FUDGE) { if (row_resizable(-2)) { drag_row = -2; anchor_top = ey; move |= MOVE_Y; // Moving } } H -= size; } if ((move & MOVE_Y) == 0) { WW = Y; for (v = top_row(); v < rows(); WW += size, v++) { size = row_height(v); if (WW + size + FUDGE >= Y + H) break; if (ey >= WW + size - FUDGE && ey <= WW + size + FUDGE) { if (row_resizable(v)) { drag_row = v; anchor_top = WW; move |= MOVE_Y; // Moving } break; } } } } switch (move) { case MOVE_Y: cursor = FL_CURSOR_NS; break; default: drag_row = -4; cursor = FL_CURSOR_DEFAULT; break; } if (cursor != last_cursor) { fl_cursor(cursor, FL_BLACK, FL_WHITE); last_cursor = cursor; }}voidFlv_List::end_edit(void){ switch_editor(-1);}voidFlv_List::start_edit(void) // Start editing{ if (!vediting) { vediting = true; switch_editor(row()); }}voidFlv_List::cancel_edit(void) // Cancel editing{ if (veditor) veditor->hide(); veditor = NULL; edit_row = -1; if (edit_when() != FLV_EDIT_ALWAYS) vediting = false; switch_editor(row());}voidFlv_List::switch_editor(int nr){ Flv_Style s; if (veditor) { if (edit_row > -1) save_editor(veditor, edit_row); edit_row = -1; veditor->hide(); veditor = NULL; } if (edit_when() == FLV_EDIT_ALWAYS) vediting = true; if (nr && vediting) { get_style(s, nr); if (s.editor_defined() && !s.locked()) { veditor = s.editor(); if (veditor) { edit_row = nr; load_editor(veditor, nr); veditor->damage(FL_DAMAGE_ALL); veditor->hide(); veditor->show(); Fl::focus(veditor); } } } if (veditor && veditor->parent() != this) veditor->parent(this);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -