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

📄 wwrcdpnl.pas

📁 InfoPower_Studio 2007 v5.0.1.3 banben
💻 PAS
📖 第 1 页 / 共 5 页
字号:
       end;

       curFieldEditWidth:= TempWidth;
       MaxEditWidth:= wwmax(MaxEditWidth, TempWidth);
       LastEditHeight:= wwMax(LastEditHeight, EditControl.Height);

       EditControl.tabOrder:= NextTabOrder; {9/3/98 - Fix tab order problem }
       inc(NextTabOrder);
       result:= True;

       if recreate then curField.FreeNotification(self);

    end;


begin
   tempControlCount:= 0;
   for i:= 0 to ControlCount-1 do
      if Controls[i].owner=self then inc(TempControlCount);
   if TempControlCount=0 then Recreate:= True;

   if FDataLink.Active or (DataSource=Nil) or (Datasource.dataset=Nil) then
   begin
      if (Recreate) then FreeNonCustomControls(True);
      if (DataSource=nil) or (Datasource.dataset=nil) then exit;
   end
   else begin
//      if (Recreate) then FreeNonCustomControls; { If inactive then don't show controls }
      exit;
   end;

   PrevTop:= Margin.TopOffset;

   if (selected.count=0) then numFields:= DataSource.DataSet.FieldCount
   else numFields:= Selected.count;

   Bitmap:= TBitmap.create;
   ControlPositions.Clear;

   try
      Bitmap.Canvas.Font := Font;

      { Compute desired form length }
      MaxEditWidth:= 0;
      RealMaxLineWidth:= 0;
      curFieldDisplayWidth:= 0;

      for i:= 0 to numFields-1 do begin
         if (Selected.count=0)then
         begin
            curField:= DataSource.dataset.fields[i];
            curFieldDisplayWidth:= curField.DisplayWidth;
            curFieldReadOnly:= curfield.ReadOnly;
         end
         else begin
            APos:= 1;
            curField:= DataSource.dataset.findField(strGetToken(Selected[i], #9, APos));
            if curfield<>nil then begin
               curFieldDisplayWidth:= strToInt(strGetToken(Selected[i], #9, APos));
               strGetToken(Selected[i], #9, APos); { Display label }
               curFieldReadOnly := (strGetToken(Selected[i], #9, APos) = 'T')
            end
         end;
         if not ShowField(curfield, curFieldReadOnly) then continue;

         MaxEditWidth:= wwmax(MaxEditWidth,
               (CurFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3);
      end;
      OrigMaxEditWidth:= MaxEditWidth;

      { Limit form length }
      EditStartOffset:= Margin.LeftOffset;

      MaxEditWidth:= 0;
      lastEditHeight := 0;
      lastLabelHeight := 0;
      CurLineWidth:= 0;
      NextTabOrder:= 0;

      FixedEditWidth:= Width - (EditStartOffset + Margin.RightOffset + FixedEditWidthConst);
      if BorderStyle=bsSingle then FixedEditWidth:= FixedEditWidth - 4;

      MaxLineWidth:= FixedEditWidth;
//      MinEditHeight:= 21;

      for i:= 0 to numFields-1 do begin
         APos:= 1;
         if (Selected.count=0) or FUseTFields then
         begin
            curField:= DataSource.dataset.fields[i];
            curFieldDisplayWidth:= curfield.DisplayWidth;
            curFieldDisplayLabel:= curField.displayLabel;
            curFieldReadOnly:= curfield.ReadOnly; { 10/14/98 }
         end
         else begin
            curField:= DataSource.dataset.findField(strGetToken(Selected[i], #9, APos));
            if curfield = nil then begin
               {NEW LINE}
               curLineWidth := 0;
               PrevTop := PrevTop + EditSpacing.HorizontalView.BetweenLabelEdit+
                          LastEditHeight + EditSpacing.HorizontalView.BetweenRow +
                          LastLabelHeight;{New Top Value}
               LastEditHeight := 0;
               continue;
            end
            else begin
               curFieldDisplayWidth:= strToInt(strGetToken(Selected[i], #9, APos));
               curFieldDisplayLabel:= strGetToken(Selected[i], #9, APos);
               curFieldReadOnly := (strGetToken(Selected[i], #9, APos) = 'T');
            end
         end;

         if not ShowField(curfield, curFieldReadOnly) then continue;

         Bitmap.Canvas.Font := LabelFont;
         curFieldLabelWidth := (Bitmap.Canvas.TextWidth(curFieldDisplayLabel));
         Bitmap.Canvas.Font := Font;

         if (rvopMaximizeMemoWidth in Options) and
            ((wwIsCustomEditCell(self, wwGetOwnerFrameOrForm(self), curField, customEdit) and
             wwisclass(customedit.classtype,'TwwCustomRichEdit'))
             or (curField is TBlobField)) then { 9/25/98 }
            curFieldEditWidth:= FixedEditWidth
         else
            curFieldEditWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3;

         if (curlineWidth > 0) and
            (curLineWidth + EditSpacing.HorizontalView.BetweenEditsInRow +
             wwmax(curFieldEditWidth,curFieldLabelWidth+EditSpacing.HorizontalView.LabelIndent) >= MaxLineWidth-8) then
         begin
            {Won't fit on current line so go to next line}
            curLineWidth := 0;
            PrevTop := PrevTop + EditSpacing.HorizontalView.BetweenLabelEdit +
                       EditSpacing.HorizontalView.BetweenRow + LastEditHeight + LastLabelHeight;{New Top Value}
            LastEditHeight := 0;
         end;

         accept:= True;
         if Recreate then
            DoOnBeforeCreateControl(Self, curField, accept);
         if not accept then continue;

         curLabel:= nil;
         curEditControl:= nil;

         if (not Recreate)  then begin
            for j:= 0 to CustomControlList.count-1 do begin
               TwwCustomControlItem(CustomControlList[j]).control.parent:= self;
            end;
            for j:= 0 to ControlCount-1 do begin
               if TControl(Controls[j]) is TWinControl then begin
                  if wwEqualStr(wwGetControlDataField(TWinControl(Controls[j])),
                                curField.fieldname) then
                  begin
                     curEditControl:= Controls[j];
                     break;
                  end
               end
            end;
            if curEditControl<>Nil then begin
               for j:= 0 to ControlCount-1 do begin
                  if TControl(Controls[j]) is TLabel then begin
                     curLabel:= TLabel(Controls[j]);
                     if TLabel(Controls[j]).FocusControl=curEditControl then
                     begin
                        curLabel:= TLabel(Controls[j]);
                        break;
                     end
                  end
               end
            end
            else continue; { 3/11/99 - No edit control exists for this field }
         end;

         if curLabel=Nil then begin
            if (rvopUseCustomControls in Options) and
               wwIsCheckbox(self, curField, checkboxOn, checkboxOff) then
               curLabel:= TwwLabel.create(self)
            else
               curLabel:= TLabel.create(self);
         end;
         self.curlabel:= curLabel;

         with curLabel do begin
            if recreate then begin
              parent:= self;
              AutoSize:= True;
              font:= self.labelFont;
              Caption:= strReplaceChar(curfieldDisplayLabel, '~', ' ');
              alignment:= taLeftJustify;
            end
            else begin
              if AutoSize<>True then AutoSize:= True;
              if Alignment<>taLeftJustify then alignment:= taLeftJustify;
            end;

            font:= self.labelFont;

            ControlPositionLeft:= Margin.LeftOffset+ CurLineWidth+EditSpacing.HorizontalView.LabelIndent;
            ControlPositionTop:= PrevTop;
            if recreate then
            begin
               Left:= ControlPositionLeft;
               Top:= ControlPositionTop;
            end
            else AddControlPosition(curLabel,
                      ControlPositionLeft, ControlPositionTop, curlabel.Width, curLabel.Height);
         end;

         if Recreate then
         begin
            if rvcTransparentLabels in ControlOptions then curLabel.transparent:= true;
            DoOnAfterCreateControl(self, curField, curLabel);
         end;
         LastLabelHeight := curLabel.height;
         curFieldLabelWidth := curlabel.width+EditSpacing.HorizontalView.LabelIndent;

         if (rvopUseCustomControls in Options) and
            wwIsCheckbox(self, curField, checkboxOn, checkboxOff) then
         begin
            if (not Recreate) and (curEditControl<>Nil) then
            begin
               checkbox:= TwwDBCheckBox(curEditControl);
               ControlPositionLeft:= EditStartOffset+curLineWidth;
               ControlPositionTop:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+ curlabel.Height;
               UpdateTopPosition(Checkbox.height, ControlPositionTop);
               AddControlPosition(CheckBox, ControlPositionLeft, ControlPositionTop,
                                   Checkbox.Width, Checkbox.Height);
            end
            else begin
              checkbox:= TwwDBCheckBox.create(self);
              checkbox.LabelControl:= curLabel;
              curLabel.FocusControl:= checkBox;
              with checkbox do begin
                 visible:= false;
                 parent:= self;
                 datasource:= self.DataSource;
                 datafield:= curfield.fieldName;
                 caption:= '';
                 valueChecked:= checkboxOn;
                 valueUnchecked:= checkboxOff;
                 Width:= 17;
                 left:= EditStartOffset+curLineWidth;
                 Top:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+ curlabel.Height;
                 if curFieldReadonly or Field.calculated then
                 begin
                    tabStop:= False;
                    Enabled:=False; { 3/9/99 - Readonly checkbox }
                 end;
                 visible:=true;  // 2/20/04 - Make visible later to solve painting problem
                                 // where bottom of checkbox's caption was hidden
                                 // after calling recreatecontrols
              end;
              if Recreate then
                 DoOnAfterCreateControl(self, curField, checkbox);
            end;
            curFieldEditWidth := checkbox.Width;
            MaxEditWidth:= wwmax(MaxEditWidth, checkbox.Width);
            LastEditHeight:= wwMax(LastEditHeight,checkbox.Height);
            Checkbox.Height:= LastEditHeight;

            { 9/20/98 - Set tab orders for checkbox }
            checkbox.TabOrder:= NextTabOrder;  { 3/11/99 - Previously didn't have checkbox.taborder }
            inc(NextTabOrder);
         end
         else if useCustomControls and
            IsCustomEditCell(curField, customEdit) then
         with TEdit(CustomEdit) do begin
            curLabel.FocusControl:= CustomEdit;
            parent:= self;

            if Recreate then begin
               AddCustomControl(CustomEdit);
               if not wwSetControlDataSource(customEdit, datasource) then continue;
               if not wwSetControlDataField(customEdit, '') then continue;
               if not wwSetControlDataField(customEdit, curField.fieldName) then continue;
            end;

//            visible:= True; { Causes custom control's to flicker when coming up }
            Ctl3d:= True;
            if not HasFrame(customEdit) then BorderStyle:= bsSingle;

            ControlPositionLeft:= EditStartOffset+curLineWidth;
            ControlPositionTop:= PrevTop+EditSpacing.HorizontalView.BetweenLabelEdit+curlabel.Height;

            if (customEdit is TwwRadioGroup) and TwwRadioGroup(CustomEdit).ShowGroupCaption then
            begin
               LastLabelHeight := 0;
            end;
            if wwIsClass(customedit.classtype,'TwwCustomRichEdit') and
               (rvopMaximizeMemoWidth in Options) then
               TempWidth:= wwMax(OrigMaxEditWidth, FixedEditWidth)
            else
               TempWidth:= (curFieldDisplayWidth+1) * Bitmap.Canvas.TextWidth('0') + 3;

            if rvopShortenEditBox in Options then begin
               if TempWidth>FixedEditWidth then TempWidth:= FixedEditWidth;
            end;

            TEdit(CustomEdit).HandleNeeded;

//            if Recreate then
//               DoOnAfterCreateControl(self, curField, customEdit);

            if not Recreate then begin
               ControlPositionWidth:= TempWidth;
               ControlPositionHeight:= CustomEdit.Height;
               UpdateTopPosition(ControlPositionHeight, ControlPositionTop);
               AddControlPosition(CustomEdit, ControlPositionLeft, ControlPositionTop,
                                 TempWidth, ControlPositionHeight);
            end
            else begin
               Left:= ControlPositionLeft;
               Top:= ControlPositionTop;
               OldWidth:= CustomEdit.Width; { 10/22/98 }

               if (Patch[0]=True) and curFieldReadOnly then
               begin
                  CustomEdit.tabStop:= not curFieldReadOnly;
                  CustomEdit.enabled:= not curFieldReadOnly;
                  TEdit(CustomEdit).Color:= ReadOnlyColor;
               end;

               DoOnAfterCreateControl(self, curField, CustomEdit);
               if CustomEdit.Width<>OldWidth then { 10/22/98 }
                  TempWidth:= CustomEdit.Width;
               customEdit.Width:= TempWidth;
            end;

            curFieldEditWidth := TempWidth; //customEdit.Width;
            MaxEditWidth:= wwmax(MaxEditWidth, curFieldEditWidth);
            LastEditHeight:= wwMax(LastEditHeight,customEdit.Height);
            tabOrder:= NextTabOrder;
            inc(NextTabOrder);
         end
         else if (curField is TDateTimeField) and
                 (rvopUseDateTimePicker in Options) then
         begin
            if recreate or (curEditControl=Nil) then
               EditControl:= TwwDBDateTimePicker.c

⌨️ 快捷键说明

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