⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flv_style.cxx

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CXX
📖 第 1 页 / 共 2 页
字号:
//      Undefine column widthvoidFlv_Style::clear_width(void){    CLEAR(STYLE_DEFINE_WIDTH);}//      Is column width defined?boolFlv_Style::width_defined(void) const{    return DEFINED(STYLE_DEFINE_WIDTH);}//      ==================================================================//      Set x marginintFlv_Style::x_margin(int x){    if (x < 0)	x = 0;    if (x != vx_margin) {	vdefined |= STYLE_DEFINE_X_MARGIN;	vx_margin = (unsigned char) x;    }    return vx_margin;}//      Undefine x marginvoidFlv_Style::clear_x_margin(void){    CLEAR(STYLE_DEFINE_X_MARGIN);}//      Is x margin definedboolFlv_Style::x_margin_defined(void) const{    return DEFINED(STYLE_DEFINE_X_MARGIN);}//      ==================================================================//      Set y marginintFlv_Style::y_margin(int y){    if (y < 0)	y = 0;    if (y != vy_margin) {	vdefined |= STYLE_DEFINE_Y_MARGIN;	vy_margin = (unsigned char) y;    }    return vy_margin;}//      Undefine y marginvoidFlv_Style::clear_y_margin(void){    CLEAR(STYLE_DEFINE_Y_MARGIN);}//      Is y margin definedboolFlv_Style::y_margin_defined(void) const{    return DEFINED(STYLE_DEFINE_Y_MARGIN);}//      ==================================================================//      Cumulative assignment operator//      This will only assign portions that are defined.const Flv_Style &Flv_Style::operator=(const Flv_Style & n){    if (n.align_defined())	align(n.valign);    if (n.background_defined())	background(n.vbackground);    if (n.border_defined())	border(n.vborder);    if (n.border_color_defined())	border_color(n.vborder_color);    if (n.border_spacing_defined())	border_spacing(n.vborder_spacing);    if (n.editor_defined())	editor(n.veditor);    if (n.font_defined())	font(n.vfont);    if (n.font_size_defined())	font_size(n.vfont_size);    if (n.foreground_defined())	foreground(n.vforeground);    if (n.frame_defined())	frame(n.vframe);    if (n.height_defined())	height(n.vheight);    if (n.locked_defined())	locked(n.vlocked);    if (n.resizable_defined())	resizable(n.vresizable);    if (n.width_defined())	width(n.vwidth);    if (n.x_margin_defined())	x_margin(n.vx_margin);    if (n.y_margin_defined())	y_margin(n.vy_margin);    //      I'm not copying value because it seems meaningless in every context    //      I can think of.    //      I'm not copying cell_style either for the same reason.  It just seems like    //      a REALLY bad idea.    return *this;}//      **********************************************************************//      Routines for Flv_Style_List////      Implemented as a dynamic sparse array//      **********************************************************************Flv_Style_List::Flv_Style_List(){    list = NULL;    vcount = vallocated = vcurrent = 0;}voidFlv_Style_List::compact(void){    int n, t;    //    Release memory for any dead items    for (t = 0; t < vcount; t++) {	list[t]->cell_style.compact();	//      Compact cells!	if (list[t]->cell_style.count() == 0 && list[t]->all_clear()) {	    delete list[t];	    list[t] = NULL;	}    }    //    Compact list now    for (t = n = 0; t < vcount; t++) {	if (list[t])	    list[n++] = list[t];	else if (vcurrent <= t && vcurrent > 0)	    vcurrent--;    }    //    Make list easy to view, wasted CPU cycles    for (t = n; t < vcount; t++)	list[t] = NULL;    vcount = n;			//      Update count    if (!vcount && list) {	delete[]list;	list = NULL;	vcount = vcurrent = vallocated = 0;    }}//      Undefine all styles in listvoidFlv_Style_List::clear(void){    int t;    for (t = 0; t < vcount; t++)	//      Make all entries clear	list[t]->clear_all();    compact();			//      Remove dead space thats left}//      Free memory for all (including cellvoidFlv_Style_List::release(void){    int t;    for (t = 0; t < vcount; t++) {	list[t]->cell_style.release();	delete list[t];    }    if (list)	delete[]list;    list = NULL;    vcurrent = vcount = vallocated = 0;}Flv_Style *Flv_Style_List::current(void)	//      Current node{    if (!list)	return NULL;    return list[vcurrent];}//      Find closest match//      It will find the first value >= nFlv_Style *Flv_Style_List::find(int n){    int t, l, h;    if (!list || vcount == 0)	//      If list is empty, there will be no matches	return NULL;    //      How a about a nice binary search?  It will be slower for sequential    //      processing and a small number of styles, but worlds faster as the    //      number of styles increases.  Use skip_to for sequential processing    //      and find for random access.    l = 0;    h = vcount - 1;    while (l + 1 < h) {	vcurrent = (l + h) / 2;	t = list[vcurrent]->value();	if (t == n)	    return list[vcurrent];	else if (t < n)	    l = vcurrent;	else	    h = vcurrent;    }    //      This needs cleaning, I fairly certain there's way too much logic here    //      While this will work, I think we only need to check one of the values    //      but I've been wrong before... :)    vcurrent = l;    t = list[vcurrent]->value();    if (t == n)	return list[vcurrent];    if (t < n && vcurrent < vcount - 1) {	vcurrent = h;	t = list[vcurrent]->value();	if (t == n)	    return list[vcurrent];    }    return NULL;}Flv_Style *Flv_Style_List::first(void)	//      Get first style{    if (!list)	return NULL;    vcurrent = 0;    return list[vcurrent];}boolFlv_Style_List::insert(Flv_Style * n)	//      Add style (if doesn't exist){    int t;    //      Make sure there is room for a new item    if (vcount == vallocated) {	Flv_Style **a = new Flv_Style *[vallocated + ADDSIZE];	if (!a)	    return false;	//  Wasted CPU cycles, but list is pretty	memset(a, 0, sizeof(Flv_Style *) * (vallocated + ADDSIZE));	if (vcount)	    memcpy(a, list, sizeof(Flv_Style *) * vcount);	vallocated += ADDSIZE;	if (list)	    delete[]list;	list = a;    }    if (vcount) {	find(n->value());	//      Point to insert candidate	if (n->value() == list[vcurrent]->value())	//      No duplicates	    return false;	if (n->value() > list[vcurrent]->value())	//      Insert at end of list	    vcurrent++;    }    //      Make room for insert if not appending    for (t = vcount; t > vcurrent; t--)	list[t] = list[t - 1];    list[vcurrent] = n;    vcount++;    return true;}Flv_Style *Flv_Style_List::next(void)	//      Next style{    if (!list || vcurrent >= vcount - 1)	return NULL;    vcurrent++;    return list[vcurrent];}Flv_Style *Flv_Style_List::prior(void){    if (!vcurrent || !list)	return 0;    vcurrent--;    return list[vcurrent];}boolFlv_Style_List::clear_current(void){    if (!list)	return false;    if (list[vcurrent]->cell_style.count() == 0)	return release_current();    list[vcurrent]->clear_all();    return true;}boolFlv_Style_List::release_current(void)	//      Remove current style{    if (!list)	return false;    delete list[vcurrent];    if (vcurrent < vcount - 1) {	memmove(list + vcurrent, list + vcurrent + 1,		sizeof(Flv_Style *) * (vcount - vcurrent));	vcount--;	list[vcount] = NULL;    }    if (vcurrent == vcount)	vcurrent--;    return true;}//      From n skip up to value vFlv_Style *Flv_Style_List::skip_to(int v){    int c;    if (!list || !vcount)	return NULL;    //      In case we're backing up or starting over    //      We're checking vcurrent-1 so if the last search found    //      an entry > the desired value, and this search isn't quite    //      to the last found value, we don't want to start over, just    //      stay where we are.    //      Style 1, 2, 3, 7 & 10 defined    //      search for 4 (current points to 7) returns false    //      search for 5 (stay at seven since 3 is < value, return false)    //              If we started at 0 we'd end up here anyway... :)    //      search for 7 (stay at seven, we'll find it quick, return true)    if (vcurrent) {	if (list[vcurrent - 1]->value() >= v)	    vcurrent = 0;    }    for (; vcurrent < vcount; vcurrent++) {	c = list[vcurrent]->value();	if (c == v)	    return list[vcurrent];	else if (c > v)	    return NULL;    }    vcurrent--;    return NULL;}//      Note: this could be a little wierd since it's actually returning//      the style with value 'value' instead of list index 'value'//      Plus: it's going to define the style if it doesn't already exist!////      If you don't want extraneous styles getting inserted, be sure to//      use the find operator first.  (I.e. If your reading a style value//      and the style didn't previously exist, all the style information//      will be undefined!Flv_Style & Flv_Style_List::operator[](int value) {    Flv_Style *	p;    if (find(value))		//      If it exists	return *(list[vcurrent]);	//              return it    p = new Flv_Style;    p->value(value);    insert(p);    return *p;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -