bool isBalanced(TreeNode *root) { function<int (TreeNode*)> getheight = [&getheight] (TreeNode* node) -> int { if(node == nullptr){ return 0; } if(node->left == nullptr and node->right == nullptr){ return 1; } unsigned left_height = 0; unsigned right_height = 0; if(node->left != nullptr){ left_height = 1 + getheight(node->left); } if(node->right != nullptr){ right_height = 1 + getheight(node->right); } return std::max(left_height,right_height); }; int lhs,rhs; if(root == nullptr){ return true; } else if(root->left == nullptr and root->right == nullptr){ return true; } else{ lhs = getheight(root->left); rhs = getheight(root->right); } return ((std::abs(lhs - rhs) <= 1) and isBalanced(root->left) and isBalanced(root->right)); }
void MainWin::resize(int rows, int cols) { NGroup::resize(rows, cols); tablheader->resize(1, getwidth()-2-(INFPANWIDTH)-1); int wtaskheight = getheight() * wtaskheightpercent / 10000.0; if (wtaskheight < 5) wtaskheight = 5; if (wtaskheight > getheight() - 10) wtaskheight = getheight() - 10; wtask->resize(wtaskheight/*getheight()/2*/, getwidth()-2-(INFPANWIDTH)-1); //размер окна задач wmsg->resize(getheight()-wtask->getheight()-4, getwidth()-2-(INFPANWIDTH+1)); wmsg->move(wtask->getheight()+3, 1); hline->resize(1, getwidth()-2-(INFPANWIDTH+1)); //горизонтальная линия hline->move(wtask->getheight()+2, 1); // vline->resize(wtask->getheight()+1/*getheight()-2*/, 1); // vline->move(1 , getwidth()-INFPANWIDTH-2); msgscrollbar->resize(wmsg->getheight()+2,1); msgscrollbar->move(wmsg->getbegrow()-1, getwidth()-INFPANWIDTH-2/*vline->getbegcol()*/); taskscrollbar->resize(wtask->getheight()+2,1); taskscrollbar->move(wtask->getbegrow()-2, getwidth()-INFPANWIDTH-2); panel1->resize(getheight()-2,INFPANWIDTH); panel1->move(1,getwidth()-INFPANWIDTH-1); }
Rectangle Rectangle::quadrant( int q ) const { q %= 4; int qWidth = getwidth() / 2 - (getwidth() % 2 ? 0 : 1); int qHeight = getheight() / 2 - (getheight() % 2 ? 0 : 1); switch (q) { case 0: return Rectangle( a.get_x(), a.get_y(), a.get_x() + qWidth, a.get_y() + qHeight ); case 1: return Rectangle( b.get_x() - qWidth, a.get_y(), b.get_x(), a.get_y() + qHeight ); case 2: return Rectangle( a.get_x(), b.get_y() - qHeight, a.get_x() + qWidth, b.get_y() ); case 3: return Rectangle( b.get_x() - qWidth, b.get_y() - qHeight, b.get_x(), b.get_y() ); default: break; } // Error getting rectangle quadrant: assert(0); return Rectangle(); }
static int checkDiff(TLDNode *node){ int nodeDiff; int left; int right; left=getheight(node->left); right=getheight(node->right); nodeDiff=left-right; return nodeDiff; }
void MainWin::eventhandle(NEvent* ev) //обработчик событий { NGroup::eventhandle(ev); //предок if ( ev->done ) return; if (ev->type == NEvent::evKB) //клавиатурные { switch(ev->keycode) { case '-': //меняем размер окна логов case '+': //меняем размер окна логов { int wtaskheight = getheight() * wtaskheightpercent / 10000.0; //высота в строках //игнорировать событие если дошли до ограничителей if ((ev->keycode == '+')&&(wtaskheight < 5)) break; if ((ev->keycode == '-')&&(wtaskheight > getheight() -10)) break; //расчитать новый процентный размер окна int delta = 10000.0/getheight(); if (ev->keycode == '+') delta*=-1; wtaskheightpercent+=delta; if (wtaskheightpercent > 10000) wtaskheightpercent = 10000; wtaskheightpercent-=10; if (wtaskheightpercent < 0) wtaskheightpercent = 0; //сохранить новое значение в конфиге saveopttoconfig(); //ресайз и перерисовка resize(getheight(),getwidth()); refresh(); break; } } } if (ev->type == NEvent::evPROG) //прграммные { switch(ev->cmdcode) { case evCOLVIEWCH: //изменился набор колонок { setcoltitle(); tablheader->refresh(); wtask->refresh(); } } //switch } //событие таймера if (ev->type == NEvent::evTIMER) //таймер { updatecaption(); } }
static void draw_radio(control c, rect r) { int w; rect box, textrect; char *name; int style = (AlignLeft | AlignTop); font f; rgb old = currentcolour(); /* Calculate rectangles. */ f = gettextfont(c); setfont(f); w = strwidth(f,"W"); if (w > r.width) w = r.width; if (w > r.height) w = r.height; box = rect(r.x,r.y+1,w,w); if (w < getheight(f) - getdescent(f)) box.y += getheight(f) - getdescent(f) - w; textrect = rect(r.x+w+w/2,r.y,r.width-(w+w/2),r.height); /* Clear the check area. */ setlinewidth(1); setcolour(White); fillellipse(insetr(box,1)); /* Draw the check area */ if (isenabled(c)) setcolour(Black); else setcolour(Grey); drawellipse(box); /* Provide 'pressed button' effect by black border. */ if (ishighlighted(c)) { setlinewidth(2); drawellipse(box); setlinewidth(1); } /* Put o in circle if checked. */ if (ischecked(c)) fillellipse(insetr(box,3)); name = getname(c); if (isenabled(c)) { /* if (hasfocus(c)) { style |= Underline; setlinewidth(2); } */ setcolour(getforeground(c)); } drawtext(textrect, style, name); setcolour(old); }
MainWin::MainWin(NRect rect/*, Config* cfg*/) : NGroup(rect) { //читаем опции из конфига если нет то создаем wtaskheightpercent = 5000; if (gCfg != NULL) { Item* rootcfg = gCfg->getcfgptr(); if (rootcfg != NULL) { Item* wtask_height_percent = rootcfg->findItem("wtask_height_percent"); if (wtask_height_percent == NULL) //создать { wtask_height_percent = new Item("wtask_height_percent"); wtask_height_percent->setivalue(wtaskheightpercent); rootcfg->addsubitem(wtask_height_percent); } wtaskheightpercent = wtask_height_percent->getivalue(); } } colname.push_back(" # "); colname.push_back("state "); colname.push_back(" done%%"); colname.push_back(" project "); colname.push_back(" est"); colname.push_back(" d/l"); colname.push_back(" application "); colname.push_back(" task"); tablheader = new NStaticText(NRect(1, rect.cols -2-(INFPANWIDTH)-1, 1, 1)); tablheader->setstring(getcolorpair(COLOR_CYAN,COLOR_BLACK) | A_BOLD," # state done%% project est d/l task"); int wtaskheight = getheight() * wtaskheightpercent / 10000.0; if (wtaskheight < 5) wtaskheight = 5; if (wtaskheight > getheight() - 10) wtaskheight = getheight() - 10; wtask = new TaskWin(NRect(wtaskheight/*getheight()/2*/, getwidth()-2-(INFPANWIDTH)-1, 2, 1)); //создаем окно процессов внутри wmain setcoltitle(); taskscrollbar = new NScrollBar(NRect(wtask->getheight()+2,1, wtask->getbegrow()-2, getwidth()-INFPANWIDTH-2), ACS_TTEE | A_BOLD, 0, ACS_VLINE | A_BOLD); //скроллбар панели задач wtask->setscrollbar(taskscrollbar); wmsg = new MsgWin(NRect(getheight()-wtask->getheight()-4, getwidth()-2-(INFPANWIDTH+1), wtask->getheight()+3, 1)); //создаем окно евентов hline = new NHLine(NRect(1, getwidth()-2-(INFPANWIDTH+1), wtask->getheight()+2, 1), NULL); //горизонтальная линия // vline = new NVLine(NRect(wtask->getheight()+1/*getheight()-2*/, 1, 1, getwidth()-INFPANWIDTH-2), NULL); //вертикальная линия msgscrollbar = new NScrollBar(NRect(wmsg->getheight()+2,1, wmsg->getbegrow()-1, getwidth()-INFPANWIDTH-2/*vline->getbegcol()*/),/*ACS_RTEE*/ACS_VLINE | A_BOLD,ACS_BTEE | A_BOLD, ACS_VLINE | A_BOLD); //скроллбар панели сообщений wmsg->setscrollbar(msgscrollbar); panel1 = new InfoPanel(NRect(getheight()-2,INFPANWIDTH,1,getwidth()-INFPANWIDTH-1)); caption = new NColorString(0,""); insert(tablheader); insert(wtask); insert(wmsg); insert(hline); // insert(vline); insert(taskscrollbar); insert(msgscrollbar); insert(panel1); }
static int getDiff(TLDNode *node) { int diff; int leftTree; int rightTree; leftTree = getheight(node->left); rightTree = getheight(node->right); diff = leftTree - rightTree; return diff; }
struct node *rotright(struct node *k2) { struct node *k1 = k2->r; k2->r = k1->l; k1->l = k2; getheight(k2); getheight(k1); // recompute gcd's computegcd(k1); computegcd(k2); return k1; }
bool Rectangle2D::contains(const Rectangle2D &r) { //if the specified rectangle is inside this rectangle if ( ( x - getwidth()/2) < ( r.x - r.getwidth()/2 ) && ( x + getwidth()/2) > ( r.x + r.getwidth()/2 ) && ( y - getheight()/2) > ( r.y - r.getheight()/2 ) && ( y + getheight()/2) < ( r.y + r.getheight()/2 ) ) { return true; } else { return false; } }
int getheight(struct tree *t) { if ( t ==NULL ) return 0; else { int left=getheight(t->left); int right=getheight(t->right); if ( left > right ) return left+1; else return right+1; } }
int main() { initgraph(640, 480); //设置视口矩形区域为(200,100) - (330, 130) //最后一个参数为1表示出了这个区域的图形会被裁剪 //后面所绘画的图形的原点坐标(0,0),会映射到(200,100) setviewport(200, 100, 330, 130, 1); //画一些文字,注意文字会因区域被裁剪的效果 setcolor(EGERGB(0x0, 0xFF, 0x0)); setfontbkcolor(RGB(0x80, 0x00, 0x80)); setfont(18, 0, "宋体"); outtextxy(0, 0, "Hello EGE Graphics"); setbkmode(TRANSPARENT); outtextxy(0, 20, "Hello EGE Graphics"); //还原视口 setviewport(0, 0, getwidth(), getheight(), 1); outtextxy(0, 0, "Hello EGE Graphics"); getch(); closegraph(); return 0; }
struct node *erase(struct node *n, int val) { struct node *t; if (n == NIL) return n; if (n->val == val) { if (n->count > 1) { n->count--; } else { if (n->l == NIL || n->r == NIL) { t = (n->l == NIL) ? n->r : n->l; delete n; return t; } for (t = n->r; t->l != NIL; t = t->l); n->val = t->val; n->count = t->count; n->r = erase(n->r, n->val); } } else if (val < n->val) n->l = erase(n->l, val); else n->r = erase(n->r, val); getheight(n); return rotate(n); }
struct node *insert(struct node *n, int val) { if (n == NIL) { n = new node; n->val = val; n->height = 1; n->count = 1; n->gcd = n->val; n->l = n->r = NIL; return n; } else if (n->val == val) { n->count++; return n; } if (val < n->val) n->l = insert(n->l, val); else n->r = insert(n->r, val); getheight(n); return rotate(n); }
HelpWin::HelpWin(int rows, int cols) : NGroup(NRect(rows, cols, getmaxy(stdscr)/2-rows/2,getmaxx(stdscr)/2-cols/2)) { caption = strdup(" Hot keys list "); modalflag = true; resize(17,60); wattrset(win,getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD); if(asciilinedraw == 1) wborder(win, '|', '|', '-', '-', '+', '+', '+', '+'); else box(win,0,0); mvwprintw(win,0,getwidth()/2-(strlen(caption)/2),caption); text1 = new NStaticText(NRect(getheight()-2,getwidth()-2,/*rect.begrow+*/1,/*rect.begcol+*/1)); int attr1 = getcolorpair(COLOR_YELLOW, COLOR_BLACK) | A_BOLD; int attr2 = getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD; text1->setstring(attr1, "\n Common Controls:\n"); text1->appendstring(attr2," \"N\" - Toogle between BOINC hosts\n"); text1->appendstring(attr2," \"C\" - Edit configuration\n"); text1->appendstring(attr2," \"Q\" - Quit boinctui\n"); text1->appendstring(attr2," \"F9\" - Toogle main menu\n"); text1->appendstring(attr2," \"PgUp\"/\"PgDn\" - Scroll Messages Window\n"); text1->appendstring(attr2,"\n"); text1->appendstring(attr1," Task Controls:\n"); text1->appendstring(attr2," \"Up\"/\"Dn\" - Select task\n"); text1->appendstring(attr2," \"S\" - Suspend selected running task\n"); text1->appendstring(attr2," \"R\" - Resume selected suspended task\n"); text1->appendstring(attr2," \"A\" - Abort selected task\n"); text1->appendstring(attr2," \"Enter\" - View selected task raw info\n"); insert(text1); }
static const char *draw_text_left(char *line, rect r, int line_height, int underline, const char *s) { char *k; point p; int width, height; font f; f = current->fnt; for(p=pt(r.x,r.y); (p.y<=r.y+r.height) && (s); p.y+=line_height) { s = get_next_line(line, r.width, s); for (k=line; *k!='\0'; k++) continue; for (--k; (k>=line) && isspace(*k); k--) *k = '\0'; drawstr(p, line); if (underline) { width = strwidth(f, line); height = p.y+getheight(f)-getdescent(f)+2; drawline(pt(p.x+1, height), pt(p.x+width-1, height)); } } return s; }
listbox newdropfield(char *list[], rect r, scrollfn fn) { listbox obj; int h, i; initapp(0,0); h = getheight(SystemFont); r.height = h+h; for (i = 0; list && list[i]; i++) r.height += h; obj = newchildwin("combobox", NULL, CBS_DROPDOWN | // CBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL, r, NULL); if (! obj) return obj; obj->kind = DroplistObject; obj->hit = fn; changelistbox(obj, list); return obj; }
void init(){ int i; int hei,wid,col; C = H = W = 0; for(i = 0 ;i < N; i++){ if(seq[i]){ Color[C++] = -1; Width[W++] = -1; Height[H++] = -1; }else{ col = getcolor(); wid = getwidth(); hei = getheight(); colcount[col] += (hei*2) + (wid*4) -3; } } i = -1; S = 0; while(++i < MCOL && colcount[i]) S += colcount[i]; K = i; }
void MessageDialog::on_dialog_init() { Gobang::set_font(font_family_.c_str(), font_size_, false, false, dialog_image_); putimage_withalpha(dialog_image_, dialog_icon_, icon_margin_, (height_ - button_area_height_ - getheight(dialog_icon_)) / 2); setcolor(BLACK, dialog_image_); static UINT text_format = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_WORDBREAK | DT_WORD_ELLIPSIS; text_rect_.left = icon_margin_ + getwidth(dialog_icon_) + text_margin_; text_rect_.top = text_margin_; text_rect_.right = width_ - text_margin_; text_rect_.bottom = height_ - button_area_height_ - text_margin_; //rectangle(text_rect_.left, text_rect_.top, text_rect_.right, text_rect_.bottom, dialog_image_); //计算文本高度 int text_height = DrawText(dialog_dc_, text_.c_str(), -1, &text_rect_, text_format | DT_CALCRECT); text_rect_.top = (height_ - button_area_height_ - text_height) / 2; text_rect_.bottom = height_ - button_area_height_ - text_margin_; DrawText(dialog_dc_, text_.c_str(), -1, &text_rect_, text_format); setfillcolor(EGERGB(230, 230, 230), dialog_image_); bar(0, height_ - button_area_height_, width_, height_, dialog_image_); ok_listener_ = OkButtonListener(dialog_handle_); ok_button_->set_on_click_listener(&ok_listener_); }
void cleary(int x, int offset) { int start = 0, end = getheight(); if(offset < 0) { // from 0 to HEIGHT-ABS(OFFSET) start = 0; end = getheight() + offset; } else if(offset > 0) { // from OFFSET to HEIGHT start = offset; end = getheight(); } for(int y = start; y <= end; y++) { gotoxy(x, y); printf(" "); } }
void init() { int g = TRUECOLORSIZE, m = (g_height<<16) | g_width; //initgraph(&g, &m, "碧波荡漾"); //setinitmode(3); initgraph(640, 480); g_width = getwidth(); g_height = getheight(); }
// 主函数 int main( int argc, char* argv[] ) { int i, ms_x = -1024, ms_y = -1024, exitflag = 0; int fps = 60; double dtime; int mode = preinit( argc, argv ); // 记录初始化模式 if ( mode < 0 ) return 0; randomize(); // 初始化随机种子 initgraph( -1, -1 ); // 打开图形窗口,以全屏模式 showmouse( mode ); sc_width = getwidth(); sc_heigh = getheight(); // 初始化所有星星 for ( i = 0; i < g_max; i++ ) { InitStar( i ); star[i].x = randomf(); } // 绘制星空,按任意键或移动鼠标退出 setfont( 12, 6, "宋体" ); setrendermode( RENDER_MANUAL ); dtime = fclock(); while ( kbmsg() ) getkey(); for ( ; !exitflag && is_run() && kbmsg() == 0; delay_fps( fps ) ) { //每秒画120帧,kbhit(1)是获取键盘任意键的消息,详见pdf // 如果有鼠标消息 while ( mousemsg() ) { mouse_msg msg = getmouse(); if ( ms_x <= -1024 ) { ms_x = msg.x; ms_y = msg.y; } // 处理鼠标,移动超出范围就退出 if ( mode == 0 ) { // 仅全屏模式才处理鼠标 int x = msg.x, y = msg.y; x -= ms_x; y -= ms_y; if ( x * x + y * y > 400 ) exitflag = 1; } } // 显示星星 double dt = 1.0 / fps; //fclock() - dtime; dtime += dt; for ( int i = 0; i < g_max; i++ ) { MoveStar( i, dt ); } // 显示FPS { char str[60]; sprintf( str, "%8.2f FPS", getfps()); outtextxy( 0, 0, str ); //显示fps } } closegraph(); // 关闭图形窗口 return 0; }
static const char *draw_text_justified(char *line, rect r, int line_height, int underline, const char *s) { char *j, *k; int w, xw, nl, sc, sw, space_width; point p; int width, height; font f; space_width = strwidth(current->fnt, " "); f = current->fnt; for(p=pt(r.x,r.y); (p.y<=r.y+r.height) && (s); p.y+=line_height) { s = get_next_line(line, r.width, s); p.x = r.x; for(j=line; (*j!='\0') && isspace(*j); j++) p.x += space_width; for (sc=0, k=j; *k!='\0'; k++) if (isspace(*k)) sc++; for (nl=0, --k; (k>=j) && isspace(*k); k--) { if (*k == '\n') nl++; *k = '\0'; sc--; } if ((sc==0) || nl || (! s)) { drawstr(p, j); width = strwidth(f, j); } else { w = strwidth(f, j); sw = space_width + (r.x+r.width-p.x-w)/sc; xw = (r.x+r.width-p.x-w)%sc; for(j=strtok(j," "); j; j=strtok(NULL," ")) { drawstr(p, j); p.x += sw + strwidth(f, j); if (xw) { p.x++; xw--; } } width = r.width; } if (underline) { height = p.y+getheight(f)-getdescent(f)+2; drawline(pt(p.x+1, height), pt(p.x+width-1, height)); } } return s; }
void MsgWin::eventhandle(NEvent* ev) //обработчик событий { NScrollView::eventhandle(ev); //предок if ( ev->done ) return; if ( ev->type == NEvent::evKB ) { ev->done = true; switch(ev->keycode) { case KEY_PPAGE: //wprintw(win,"PgUp"); scrollto(-getheight()/2); //вверх на полокна setautoscroll(false); break; case KEY_NPAGE: //wprintw(win,"PgDn"); if (!getautoscroll()) { int oldpos = startindex; scrollto(getheight()/2); //вниз на пол окна if ( oldpos == startindex) //позиция не изменилась (уже достигли конца) setautoscroll(true); //включаем автоскроллинг } break; case KEY_HOME: scrollto(-content.size()); setautoscroll(false); break; case KEY_END: scrollto(content.size()); setautoscroll(false); break; default: ev->done = false; //нет реакции на этот код } //switch if (ev->done) //если обработали, то нужно перерисоваться refresh(); } if ( ev->type == NEvent::evTIMER ) { updatedata(); //запросить данные с сервера refresh(); //перерисовать окно } }
char *askUserPass(const char *title) { static window win = NULL; dialog_data *d; window prev = current_window; if (! win) { int tw, bw, h, middle; tw = strwidth(SystemFont, G_("Cancel")) * 8; h = getheight(SystemFont); if (tw < 150) tw = 150; win = newwindow(title, rect(0, 0, tw+30, h*9+12), Titlebar | Centered | Modal); setbackground(win, dialog_bg()); add_data(win); d = data(win); d->question = newlabel(G_("User"), rect(10, h, tw+4, h*2+2), AlignLeft); bw = strwidth(SystemFont, G_("Password")); d->text = newfield("", rect(20+bw, h, tw-6-bw, h*3/2)); newlabel(_("Password"), rect(10, h*4, tw+4, h*2+2), AlignLeft); d->pass = newpassword("", rect(20+bw, h*4, tw-6-bw, h*3/2)); middle = (tw+30)/2; bw = strwidth(SystemFont, G_("Cancel")) * 3/2; d->yes = newbutton(G_("OK"), rect(middle-bw-10, h*7, bw, h+10), hit_button); setvalue(d->yes, YES); d->cancel = newbutton(G_("Cancel"), rect(middle+10, h*7, bw, h+10), hit_button); setvalue(d->cancel, CANCEL); setkeydown(win, hit_key); } else { d = data(win); settext(d->text, ""); settext(d->pass, ""); } if (TopmostDialogs & MB_TOPMOST) BringToTop(win, 1); handle_message_dialog(win); current_window = prev; { char *user, *pass; static char buf[1000]; if (d->hit < YES) /* cancelled */ return ""; if (d->text) user = new_string(GA_gettext(d->text)); else return ""; if (d->pass) pass = new_string(GA_gettext(d->pass)); else return ""; snprintf(buf, 1000, "%s:%s", user, pass); return buf; } return ""; /* -Wall */ }
//return the height of current node when value is not NULL static int getheight(TLDNode *node){ int height=0; int left; int right; int last; if (node!=NULL){ left=getheight(node->left); right=getheight(node->right); if (right>left){ last=right; }else{ last=left; } height=1+last; }else{ return 0; } return height; }
const char *drawtext(rect r, int alignment, const char *s) { int h; int nlines; int line_height; int u = 0; rect clip; const char *remains; char line[256]; initapp(0,0); if (! s) return (char *) NULL; if (! current->fnt) current->fnt = SystemFont; clip = getcliprect(); setcliprect(r); line_height = getheight(current->fnt); if ((alignment & VCenter) == VCenter) { h = textheight(r.width, s); if (h < r.height) r.y += (r.height-h)/2; } else if ((alignment & VJustify) == VJustify) { h = textheight(r.width, s); if (h < r.height) { nlines = h / line_height; if (nlines > 1) line_height += ((r.height-h) / (nlines-1)); } } else if ((alignment & AlignBottom) == AlignBottom) { h = textheight(r.width, s); if (h < r.height) r.y += (r.height-h); } u = (alignment & Underline); if ((alignment & Center) == Center) remains = draw_text_centered(line, r, line_height, u, s); else if ((alignment & Justify) == Justify) remains = draw_text_justified(line, r, line_height, u, s); else if ((alignment & AlignRight) == AlignRight) remains = draw_text_right(line, r, line_height, u, s); else remains = draw_text_left(line, r, line_height, u, s); setcliprect(clip); return remains; }
FloatImage *FloatImage::normalize() { int count = getwidth() * getheight(); FloatImage *newimage = new FloatImage(getwidth(), getheight()); /* find minimum and maximum values */ float min,max; get_extrema (min, max); if (max == min) min = max - 1; float scale = 255 * (max - min); float trans = -min; for (int i = 0; i < count; i++) newimage->pixel(i) = (pixel(i) - min) / (max - min); return (newimage); }
void hud::render(void){ glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(0.0f,(GLfloat)getwidth(),(GLfloat)getheight(),0.0f,-1.0f,1.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix for(uint c=0;c<this->getchildren().size();c++){ widget* w = this->getchildren()[c]; w->render(); } printinputline(); glFlush(); }
static int getheight(TLDNode *node) { int ht = 0; int leftTree; int rightTree; int last; if(node == NULL){ return 0; }else{ leftTree = getheight(node->left); rightTree = getheight(node->right); if (leftTree > rightTree) { last = leftTree; } else { last = rightTree; } ht= 1+last; } return ht; }