📄 rowcolc.c
字号:
if ( child->prefWd == newWd && child->prefHt == newHt ) return; if ( debug2 ) cout <<"Resize for child " <<XtName(w) <<" is " <<newWd SP newHt <<endl; child->prefWd = newWd; child->prefHt = newHt; changed = True; if ( deferred ) return; if ( !child->row->visible || !child->col->visible ) return;//// Register a time-out proc to do the drawing. We do this since we are likely// to get several child resizes together and we'd like to refresh only once.// if ( refreshTimer ) {//// Kill the current timer// XtRemoveTimeOut(refreshTimer); refreshTimer = (XtIntervalId)NULL; }//// Start another timer// refreshTimer = XtAppAddTimeOut(halApp->context, 100/*usec*/, (XtTimerCallbackProc)FinishChildResize, (XtPointer)this);} // End ChildResize/*--------------------------------------------------------------- * Timer proc to perform a refresh after a child resize */voidRowColC::FinishChildResize(RowColC *This, XtIntervalId*){ This->refreshTimer = (XtIntervalId)NULL; This->changed = True; This->Refresh();}//----------------------------------------------------------------------------// Method to reset the children to their original sizes and reload them.//voidRowColC::ReloadChildren(){ //cout <<"RowColC(" <<rcw->core.name <<")::ReloadChildren" <<endl; selfResize = True;//// Reset the preferred sizes of the children// unsigned wcount = childList.size(); WidgetListC wlist; wlist.AllowDuplicates(TRUE); for (int i=0; i<wcount; i++) { RowColChildC *child = childList[i]; wlist.add(child->w); child->prefWd = 0; child->prefHt = 0; }//// Re-set the list of widgets// SetChildren(wlist); selfResize = False;}//----------------------------------------------------------------------------// Method to set the number of columns. This is only useful in ROW_MAJOR// orientation.//voidRowColC::SetColCount(int count){ RowColPart *rc = GetRowColPart(rcw); if ( rc->orient == RcCOL_MAJOR || rc->colCount == count ) return;//// Add or delete columns as necessary// if ( count > rc->colCount ) { for (int i=rc->colCount; i<count; i++) { ColC *col = new ColC(this); colList.add(col); } } else { for (int i=rc->colCount-1; i>=count; i--) { ColC *col = (ColC*)colList[i]; colList.remove(i); delete col; } } rc->colCount = count; ReloadChildren();} // End RowColC SetColCount//----------------------------------------------------------------------------// Method to set the number of rows. This is only useful in COL_MAJOR// orientation.//voidRowColC::SetRowCount(int count){ RowColPart *rc = GetRowColPart(rcw); if ( rc->orient == RcROW_MAJOR || rc->rowCount == count ) return;//// Add or delete rows as necessary// if ( count > rc->rowCount ) { for (int i=rc->rowCount; i<count; i++) { RowC *row = new RowC(this); rowList.add(row); } } else { for (int i=rc->rowCount-1; i>=count; i--) { RowC *row = (RowC*)rowList[i]; rowList.remove(i); delete row; } } rc->rowCount = count; ReloadChildren();} // End RowColC SetRowCount//----------------------------------------------------------------------------// Method to set the number of pixels between columns.//voidRowColC::SetColSpacing(int space){ RowColPart *rc = GetRowColPart(rcw); if ( rc->colSpacing == space ) return; rc->colSpacing = space; if ( !deferred ) Refresh(); else changed = True;}//----------------------------------------------------------------------------// Method to set the number of pixels between rows.//voidRowColC::SetRowSpacing(int space){ RowColPart *rc = GetRowColPart(rcw); if ( rc->rowSpacing == space ) return; rc->rowSpacing = space; if ( !deferred ) Refresh(); else changed = True;}//----------------------------------------------------------------------------// Method to set the margin width//voidRowColC::SetMarginWidth(int wd){ RowColPart *rc = GetRowColPart(rcw); if ( rc->marginWd == wd ) return; rc->marginWd = wd; if ( !deferred ) Refresh(); else changed = True;}//----------------------------------------------------------------------------// Method to set the margin height//voidRowColC::SetMarginHeight(int ht){ RowColPart *rc = GetRowColPart(rcw); if ( rc->marginHt == ht ) return; rc->marginHt = ht; if ( !deferred ) Refresh(); else changed = True;}//----------------------------------------------------------------------------// Method to set the orientation. If ROW_MAJOR, new children are added to// a row until there are colCount children in that row. If COL_MAJOR, new// children are added to a column until there are rowCount children in that// column.//voidRowColC::SetOrientation(RcOrientT orient){ RowColPart *rc = GetRowColPart(rcw); if ( rc->orient == orient ) return;//// Delete all rows and columns// unsigned count = colList.size(); int i; for (i=0; i<count; i++) delete (ColC*)colList[i]; colList.removeAll(); count = rowList.size(); for (i=0; i<count; i++) delete (RowC*)rowList[i]; rowList.removeAll(); rc->orient = orient;//// Create new fixed rows or columns// if ( rc->orient == RcROW_MAJOR ) { rc->colCount = rc->rowCount; for (i=0; i<rc->colCount; i++) { ColC *col = new ColC(this); colList.add(col); } } else { rc->rowCount = rc->colCount; for (i=0; i<rc->rowCount; i++) { RowC *row = new RowC(this); rowList.add(row); } } ReloadChildren();} // End RowColC SetOrientation//----------------------------------------------------------------------------// Method to set the height resize flag. If True, the drawing area will// attempt to set its own height. If False, the drawing area will use// whatever is available.//voidRowColC::SetResizeHeight(RcResizeT val){ RowColPart *rc = GetRowColPart(rcw); if ( rc->hResizePolicy == val ) return; rc->hResizePolicy = val; if ( !deferred ) Refresh(); else changed = True;} // End RowColC SetResizeHeight//----------------------------------------------------------------------------// Method to set the width resize flag. If True, the drawing area will// attempt to set its own width. If False, the drawing area will use// whatever is available.//voidRowColC::SetResizeWidth(RcResizeT val){ RowColPart *rc = GetRowColPart(rcw); if ( rc->wResizePolicy == val ) return; rc->wResizePolicy = val; if ( !deferred ) Refresh(); else changed = True;} // End RowColC SetResizeWidth//----------------------------------------------------------------------------// Method to set the flag that determines whether all columns are forced to// the same width. If True, all columns will be as wide as the widest// column.//voidRowColC::SetUniformCols(Boolean val){ RowColPart *rc = GetRowColPart(rcw); if ( (rc->uniformCols && val) || (!rc->uniformCols && !val) ) return; rc->uniformCols = val; if ( !deferred ) Refresh(); else changed = True;} // End RowColC SetUniformCols//----------------------------------------------------------------------------// Method to set the flag that determines whether all rows are forced to// the same height. If True, all rows will be as tall as the tallest// row.//voidRowColC::SetUniformRows(Boolean val){ RowColPart *rc = GetRowColPart(rcw); if ( (rc->uniformRows && val) || (!rc->uniformRows && !val) ) return; rc->uniformRows = val; if ( !deferred ) Refresh(); else changed = True;} // End RowColC SetUniformRows//----------------------------------------------------------------------------// Method to set the alignment of all columns//voidRowColC::SetColAlignment(RcAlignT align){ Defer(True); RowColPart *rc = GetRowColPart(rcw); rc->colAlignment = align; unsigned count = colList.size(); for (int i=0; i<count; i++) SetColAlignment(i, align); Defer(False);} // End RowColC SetColAlignment//----------------------------------------------------------------------------// Method to set the alignment of a single column//voidRowColC::SetColAlignment(int i, RcAlignT align){ if ( i < 0 || i >= colList.size() ) return; Defer(True); colList[i]->SetAlignment(align); Defer(False);} // End RowColC SetColAlignment//----------------------------------------------------------------------------// Method to set the alignment of all rows//voidRowColC::SetRowAlignment(RcAlignT align){ Defer(True); RowColPart *rc = GetRowColPart(rcw); rc->rowAlignment = align; unsigned count = rowList.size(); for (int i=0; i<count; i++) SetRowAlignment(i, align); Defer(False);} // End RowColC SetRowAlignment//----------------------------------------------------------------------------// Method to set the alignment of a single row//voidRowColC::SetRowAlignment(int i, RcAlignT align){ if ( i < 0 || i >= rowList.size() ) return; Defer(True); rowList[i]->SetAlignment(align); Defer(False);} // End RowColC SetRowAlignment//----------------------------------------------------------------------------// Method to set the resize flag for all columns. When True, the columns// will grow as the drawing area widens and shrink as it narrows.//voidRowColC::SetColResize(Boolean val){ Defer(True); unsigned count = colList.size(); for (int i=0; i<count; i++) SetColResize(i, val); Defer(False);} // End RowColC SetColResize//----------------------------------------------------------------------------// Method to set the resize flag for a single column. When True, the column// will grow as the drawing area widens and shrink as it narrows. When// False, the column will always be as wide as its widest member.//voidRowColC::SetColResize(int i, Boolean val){ if ( i < 0 || i >= colList.size() ) return; Defer(True); colList[i]->SetResize(val); Defer(False);} // End RowColC SetColResize//----------------------------------------------------------------------------// Method to set the resize flag for all rows. When True, the rows// will grow as the drawing area grows taller and shrink as it grows shorter.// When False, the rows will always be as tall as their tallest member.//voidRowColC::SetRowResize(Boolean val){ Defer(True); unsigned count = rowList.size(); for (int i=0; i<count; i++) SetRowResize(i, val); Defer(False);} // End RowColC SetRowResize//----------------------------------------------------------------------------// Method to set the resize flag for a single row. When True, the row// will grow as the drawing area grow taller and shrink as it grows shorter.// When False, the row will always be as tall as its tallest member.//voidRowColC::SetRowResize(int i, Boolean val){ if ( i < 0 || i >= rowList.size() ) return; Defer(True); rowList[i]->SetResize(val); Defer(False);} // End RowColC SetRowResize//----------------------------------------------------------------------------// Method to set the width adjust mode of all columns. A column can make all// its members as wide as the column itself, as wide as the widest member// or leave their widths alone.//voidRowColC::SetColWidthAdjust(RcAdjustT mode){ Defer(True); unsigned count = colList.size(); for (int i=0; i<count; i++) SetColWidthAdjust(i, mode); Defer(False);} // End RowColC SetColWidthAdjust//----------------------------------------------------------------------------// Method to set the width adjust mode of a single column. A column can make// all its members as wide as the column itself, as wide as the widest// member or leave their widths alone.//voidRowColC::SetColWidthAdjust(int i, RcAdjustT mode){ if ( i < 0 || i >= colList.size() ) return; Defer(True); colList[i]->SetAdjust(mode); Defer(False);} // End RowColC SetColWidthAdjust//----------------------------------------------------------------------------// Method to set the height adjust mode of all rows. A row can make all// its members as tall as the row itself, as tall as the tallest member// or leave their heights alone.//voidRowColC::SetRowHeightAdjust(RcAdjustT mode){ Defer(True); unsigned count = rowList.size(); for (int i=0; i<count; i++) SetRowHeightAdjust(i, mode); Defer(False);} // End RowColC SetRowHeightAdjust//----------------------------------------------------------------------------// Method to set the height adjust mode of a single row. A row can make// all its members as tall as the row itself, as tall as the tallest// member or leave their heights alone.//voidRowColC::SetRowHeightAdjust(int i, RcAdjustT mode){ if ( i < 0 || i >= rowList.size() ) return; Defer(True); rowList[i]->SetAdjust(mode); Defer(False);} // End RowColC SetRowHeightAdjust//----------------------------------------------------------------------------// Method to set the visibility flag for a single column. When False, the// children in the column are unmanaged.//voidRowColC::SetColVisible(int i, Boolean val){ if ( i < 0 || i >= colList.size() ) return; Defer(True); colList[i]->SetVisible(val); Defer(False);} // End RowColC SetColVisible//----------------------------------------------------------------------------// Method to set the visibility flag for a single row. When False, the// children in the row are unmanaged.//voidRowColC::SetRowVisible(int i, Boolean val){ if ( i < 0 || i >= rowList.size() ) return; Defer(True); rowList[i]->SetVisible(val);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -