📄 nxweek.cxx
字号:
case 3: fl_color(FL_DARK1); break; case 4: fl_color(FL_DARK3); break; default: fl_color(FL_LIGHT3); break; } if (H > 0 && hi_val) fl_rectf(x_off + 4 + x(), Y + y(), width, H - 1); } } }}voidWeekGrid::DrawRects(int dy){ int H; int X; int Y; double rem; tm *tt; int width = 0; int x_off = 0; int offset = 0; int top_hash = 0; int bot_hash = 0; appt *p_Appt = first_appt; while (p_Appt) { time_t new_time = p_Appt->start_time; top_hash = 0; bot_hash = 0; tt = localtime(&new_time); rem = GetOffSet(p_Appt->y); Y = (int) rem; if (dy > Y) { if ((Y + (int) p_Appt->h) > dy) { H = (Y + (int) p_Appt->h) - dy; Y = 0; } else H = 0; top_hash = 1; } else { offset = Y; // off set into dy Y = (int) rem - dy; // Y value corrected if (offset >= (dy + (int) (6.5 * b_height))) { bot_hash = 1; H = 0; } else if ((offset + p_Appt->h) <= dy) { H = 0; top_hash = 1; } else if ((offset + p_Appt->h) > (dy + (int) (6.5 * b_height))) { bot_hash = 1; H = (int) (6.5 * b_height) - Y; } else H = (int) p_Appt->h; if (H > (int) (6.5 * b_height)) { bot_hash = 1; H = (int) (6.5 * b_height); } } X = (b_width * tt->tm_wday); int inc = (int) b_width / 4; if (top_hash) { fl_color(FL_BLACK); fl_rectf(x() + X + inc, y() - 5, b_width - (2 * inc), 2); } if (bot_hash) { fl_color(FL_BLACK); fl_rectf(x() + X + inc, y() + h() + 3, b_width - (2 * inc), 2); } DPRINT("DrawRects X [%d]\n", X); if (0 < H) { if (H > (int) (6.5 * b_height)) H = (int) (6.5 * b_height); switch (p_Appt->overlay) { case NO_OVERLAP: // don't draw break; case LEFT: DPRINT("In Left\n"); x_off = X; width = b_width / 2 - 4; fl_color(FL_BLACK); fl_rect(x_off + 4 + x(), Y + y(), width, H); break; case RIGHT: DPRINT("In Right\n"); width = b_width / 2 - 4; x_off = X + width; fl_color(FL_BLACK); fl_rect(x_off + 4 + x(), Y + y(), width, H); break; default: DPRINT("In default\n"); width = b_width - 7; x_off = X; fl_color(FL_BLACK); fl_rect(x_off + 4 + x(), Y + y(), width, H); break; } } p_Appt = p_Appt->next_appt; }}voidWeekGrid::ShowInfo(int X, int Y){ int dy = 0; int day = 0; appt *p_Appt = first_appt;; appt *small_appt = NULL; tm *tt = 0; time_t new_time; int overlap = 0; int big_overlap = 0; int x_off = 0; int left = 0; double rem = 0; int H = 0; int offset = 0; int width = 0; DPRINT("Got X [%d] GOt Y [%d]\n", X, Y); dy = GetGridVal(); Y = dy + Y - y(); day = ((int) ((X - x()) / b_width)); x_off = X - (day * b_width) - x(); Y = (day * (int) day_pix) + Y; X = (day * b_width); DPRINT("day [%d] x_off [%d]\n", day, x_off); DPRINT(" X [%d] Y [%d]\n", X, Y); if (x_off < (int) (b_width / 2)) left = 1; DPRINT("left [%d]\n", left); while (p_Appt) { // find the appt with the largest overlap new_time = p_Appt->start_time; tt = localtime(&new_time); if (tt->tm_wday != day) { p_Appt = p_Appt->next_appt; continue; } if (tt->tm_wday > day) break; DPRINT("p_Appt->y [%.0f] p_Appt->h [%.0f]\n", p_Appt->y, p_Appt->h); if ((Y >= p_Appt->y) && (Y < (p_Appt->y + p_Appt->h))) { DPRINT("checking p_Appt\n"); if ((p_Appt->overlay & LEFT) || (p_Appt->overlay & RIGHT)) { DPRINT("Not Single\n"); if (left && (LEFT & p_Appt->overlay)) { DPRINT("going LEFT\n"); overlap = Overlap(p_Appt); if ((overlap >= big_overlap)) { big_overlap = overlap; if (NULL == small_appt) small_appt = p_Appt; if ((p_Appt->h < small_appt->h)) { small_appt = p_Appt; } } } if (!left && (RIGHT & p_Appt->overlay)) { DPRINT("going RIGHT\n"); overlap = Overlap(p_Appt); if ((overlap >= big_overlap)) { big_overlap = overlap; if (NULL == small_appt) small_appt = p_Appt; if ((p_Appt->h < small_appt->h)) { small_appt = p_Appt; } } } } else { overlap = Overlap(p_Appt); if ((overlap >= big_overlap)) { big_overlap = overlap; if (NULL == small_appt) small_appt = p_Appt; if ((p_Appt->h < small_appt->h)) { small_appt = p_Appt; } } } } p_Appt = p_Appt->next_appt; } if (small_appt) { SetInfoBox(small_appt); DPRINT("Have small appt\n"); rem = GetOffSet(small_appt->y); Y = (int) rem; if (dy > Y) { if ((Y + (int) small_appt->h) > dy) { H = (Y + (int) small_appt->h) - dy; Y = 0; } else H = 0; } else { offset = Y; // off set into dy Y = (int) rem - dy; // Y value corrected if (offset >= (dy + (int) (6.5 * b_height))) { H = 0; } else if ((offset + small_appt->h) <= dy) { H = 0; } else if ((offset + small_appt->h) > (dy + (int) (6.5 * b_height))) { H = (int) (6.5 * b_height) - Y; } else H = (int) small_appt->h; if (H > (int) (6.5 * b_height)) { H = (int) (6.5 * b_height); } } fl_color(FL_BLACK); DPRINT("X [%d]\n", X); DPRINT("Y [%d] H [%d]\n", Y, H); DPRINT("height [%d]\n", (int) (6.5 * b_height)); if ((Y + H) == (int) (6.5 * b_height)) { int new_X = 0; int new_Y = 0; switch (small_appt->overlay) { case RIGHT: width = b_width / 2 - 4; x_off = X + width; new_X = x_off + x(); new_Y = Y + y(); fl_color(FL_BLACK); //draw the top fl_line(new_X + 1, new_Y - 1, new_X + width + 6, new_Y - 1); fl_line(new_X + 1, new_Y - 2, new_X + width + 6, new_Y - 2); fl_line(new_X + 1, new_Y - 3, new_X + width + 6, new_Y - 3); // draw the sides fl_line(new_X + 3, new_Y - 1, new_X + 3, new_Y + H - 1); fl_line(new_X + 2, new_Y - 1, new_X + 2, new_Y + H - 1); fl_line(new_X + 1, new_Y - 1, new_X + 1, new_Y + H - 1); new_X += width; fl_line(new_X + 4, new_Y - 1, new_X + 4, new_Y + H - 1); fl_line(new_X + 5, new_Y - 1, new_X + 5, new_Y + H - 1); fl_line(new_X + 6, new_Y - 1, new_X + 6, new_Y + H - 1); break; case LEFT: x_off = X; width = b_width / 2 - 4; new_X = x_off + x(); new_Y = Y + y(); fl_color(FL_BLACK); //draw the top fl_line(new_X + 1, new_Y - 1, new_X + width + 6, new_Y - 1); fl_line(new_X + 1, new_Y - 2, new_X + width + 6, new_Y - 2); fl_line(new_X + 1, new_Y - 3, new_X + width + 6, new_Y - 3); // draw the sides fl_line(new_X + 3, new_Y - 1, new_X + 3, new_Y + H - 1); fl_line(new_X + 2, new_Y - 1, new_X + 2, new_Y + H - 1); fl_line(new_X + 1, new_Y - 1, new_X + 1, new_Y + H - 1); new_X += width; fl_line(new_X + 4, new_Y - 1, new_X + 4, new_Y + H - 1); fl_line(new_X + 5, new_Y - 1, new_X + 5, new_Y + H - 1); fl_line(new_X + 6, new_Y - 1, new_X + 6, new_Y + H - 1); break; case NO_OVERLAP: break; default: width = b_width - 7; x_off = X; new_X = x_off + x(); new_Y = Y + y(); fl_color(FL_BLACK); //draw the top fl_line(new_X + 1, new_Y - 1, new_X + width + 6, new_Y - 1); fl_line(new_X + 1, new_Y - 2, new_X + width + 6, new_Y - 2); fl_line(new_X + 1, new_Y - 3, new_X + width + 6, new_Y - 3); // draw the sides fl_line(new_X + 3, new_Y - 1, new_X + 3, new_Y + H - 1); fl_line(new_X + 2, new_Y - 1, new_X + 2, new_Y + H - 1); fl_line(new_X + 1, new_Y - 1, new_X + 1, new_Y + H - 1); new_X += width; fl_line(new_X + 4, new_Y - 1, new_X + 4, new_Y + H - 1); fl_line(new_X + 5, new_Y - 1, new_X + 5, new_Y + H - 1); fl_line(new_X + 6, new_Y - 1, new_X + 6, new_Y + H - 1); break; } } else { switch (small_appt->overlay) { case RIGHT: width = b_width / 2 - 4; x_off = X + width; fl_color(FL_BLACK); fl_rect(x_off + 3 + x(), Y + y() - 1, width + 2, H + 2); fl_rect(x_off + 2 + x(), Y + y() - 2, width + 4, H + 4); fl_rect(x_off + 1 + x(), Y + y() - 3, width + 6, H + 6); break; case LEFT: x_off = X; width = b_width / 2 - 4; fl_color(FL_BLACK); fl_rect(x_off + 3 + x(), Y + y() - 1, width + 2, H + 2); fl_rect(x_off + 2 + x(), Y + y() - 2, width + 4, H + 4); fl_rect(x_off + 1 + x(), Y + y() - 3, width + 6, H + 6); break; case NO_OVERLAP: break; default: width = b_width - 7; x_off = X; fl_color(FL_BLACK); fl_rect(x_off + 3 + x(), Y + y() - 1, width + 2, H + 2); fl_rect(x_off + 2 + x(), Y + y() - 2, width + 4, H + 4); fl_rect(x_off + 1 + x(), Y + y() - 3, width + 6, H + 6); break; } } }}voidWeekGrid::SetInfoBox(appt * p_Appt){ time_t new_time = 0; tm *tt = NULL; char desc[100]; char temp_desc[100]; static char buf[150]; int width = 0; char from_date[30]; char to_date[10]; unsigned int idx = 0; int dot_width = 0; memset(from_date, 0, sizeof(from_date)); memset(to_date, 0, sizeof(to_date)); memset(temp_desc, 0, sizeof(temp_desc)); DPRINT("SetInfoBox\n"); if (output_box) { if (p_Appt) { db->Extract(db_name, p_Appt->recno, 10, desc); DPRINT("desc [%s]\n", desc); fl_font(output_box->labelfont(), output_box->labelsize()); width = (int) fl_width(desc); if (width > (output_box->w() - 10)) { dot_width = (int) fl_width("..."); idx = 0; while (width > (output_box->w() - 10)) { idx++; memset(temp_desc, 0, sizeof(temp_desc)); strncpy(temp_desc, desc, strlen(desc) - idx); width = (int) fl_width(temp_desc) + dot_width; } sprintf(desc, "%s...", temp_desc); } new_time = p_Appt->start_time; tt = localtime(&new_time); strftime(from_date, 29, "%a %m/%d/%Y", tt); strcat(buf, from_date);// strcat(buf, " "); strftime(from_date, 29, "%I:%M%P", tt); strcat(buf, from_date); new_time = p_Appt->end_time; tt = localtime(&new_time); strftime(to_date, 29, "%I:%M%P", tt); strcat(buf, "-"); strcat(buf, to_date); strcat(buf, "\n"); // change \n to spaces for (idx = 0; idx <= strlen(desc); idx++) { if ('\n' == desc[idx]) desc[idx] = ' '; } strcat(buf, desc); output_box->label(buf); } else sprintf(buf, " "); output_box->label(buf); }}voidWeekGrid::SetDateSunday(time_t date){ tm *tt = localtime(&date); tt->tm_sec = 0; tt->tm_min = 0; tt->tm_hour = 0; date_sunday = mktime(tt);}intWeekGrid::handle(int event){ switch (event) { case FL_PUSH: if (Fl::event_inside(this)) { info_draw = 1; redraw(); DPRINT("Go push\n"); output_box->redraw(); } return 1; case FL_RELEASE: info_draw = 0; damage(FL_DAMAGE_ALL); SetInfoBox(NULL); output_box->redraw(); DPRINT("Release\n"); return 1; default: return 0; }}voidGridButton::draw(){ Fl_Color col = value()? NxApp::Instance()->getGlobalColor(BUTTON_PUSH) : NxApp::Instance()->getGlobalColor(BUTTON_FACE);#ifndef PDA box(FL_BORDER_BOX);#endif if (damage() & FL_DAMAGE_ALL) draw_box(); int X = x(); int Y = y(); int W = w(); int H = h(); int w1 = (W - 1) | 1; int h1 = (H - 1) | 1; int W1 = w1 / 3; int H1 = h1 / 3; int Y1 = Y + H / 3; int X1 = X + w1 - w() / 2; if (damage()) {#ifdef PDA draw_box(FL_FLAT_BOX, X, Y, W, H, col); if (value()) fl_color(NxApp::Instance()->getGlobalColor(BUTTON_FACE)); else fl_color(NxApp::Instance()->getGlobalColor(BUTTON_TEXT));#else draw_box(value()? (down_box()? down_box() : down(box())) : box(), col);#endif if (0 == strcmp(label(), "@UpArrow")) fl_polygon(X1, Y1, X1 - W1, Y1 + H1, X1 + W1, Y1 + H1); if (0 == strcmp(label(), "@DownArrow")) fl_polygon(X1, Y1 + H1, X1 - W1, Y1, X1 + W1, Y1); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -