The Goal
          Keep walking……
          posts - 23,  comments - 1,  trackbacks - 0

          要客制化layout,需要繼承抽象類Layout,需要寫2個方法——computeSize() 和layout().

          computeSize()

          protected Point computeSize(Composite composite,
          int wHint, int hHint,
          boolean flushCache)
          {
          Point maxDimensions =
          calculateMaxDimensions(composite.getChildren());
          int stepsPerHemisphere =
          stepsPerHemisphere(composite.getChildren().length);
          int maxWidth = maxDimensions.x;
          int maxHeight = maxDimensions.y;
          int dimensionMultiplier = (stepsPerHemisphere + 1);
          int controlWidth = maxWidth * dimensionMultiplier;
          int controlHeight = maxHeight * dimensionMultiplier;
          int diameter = Math.max(controlWidth, controlHeight);
          Point preferredSize = new Point(diameter,
          diameter);
          ... // code to handle case when our calculations
          // are too large
          return preferredSize;
          }

          參數(shù):
          1.composite--The object we’re going to populate. At the time this method is called, it has children, but neither the composite nor the children have been sized or positioned on the screen.

          2.wHint and hHint--layout所需的最大長寬。若帶有參數(shù)SWT.DEFAULT,表示此layout可以隨意使用use whatever sizes it decides it needs.

          3.flushCache--作為flag,to tell the layout whether it’s safe to use any cached values that it may be maintaining.

          computeSize()的目的主要在于計算我們要layout的composite有多大
          layout()
          ……

          posted on 2006-04-12 17:19 JOO 閱讀(355) 評論(0)  編輯  收藏 所屬分類: SWT & JFace IN ACTION
          Hit the target!

          <2006年4月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          常用鏈接

          留言簿(2)

          隨筆分類(23)

          隨筆檔案(22)

          文章檔案(1)

          相冊

          Neighbor

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 和政县| 闻喜县| 潼南县| 嘉祥县| 兴业县| 大安市| 华坪县| 紫云| 阿拉善左旗| 忻城县| 南平市| 万载县| 宜阳县| 正阳县| 南昌市| 永定县| 蓝山县| 惠州市| 商河县| 泰来县| 农安县| 娱乐| 信宜市| 泗洪县| 嘉义市| 卢氏县| 临汾市| 忻州市| 兴文县| 沙河市| 齐河县| 同心县| 大埔县| 塘沽区| 获嘉县| 双桥区| 太白县| 石河子市| 常山县| 新化县| 毕节市|