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;
          }

          參數:
          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所需的最大長寬。若帶有參數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

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 肥东县| 陇西县| 沈丘县| 青河县| 乐昌市| 讷河市| 衡水市| 土默特右旗| 栖霞市| 延长县| 湟源县| 敖汉旗| 万载县| 仪征市| 虹口区| 阿拉善右旗| 衢州市| 讷河市| 张北县| 新疆| 吉木萨尔县| 临汾市| 乌鲁木齐县| 清水河县| 库车县| 田阳县| 卢氏县| 化隆| 金溪县| 裕民县| 郎溪县| 华容县| 英吉沙县| 抚顺市| 昌邑市| 文登市| 叙永县| 邻水| 普格县| 德庆县| 湘潭市|