wwrcdpnl.pas

来自「infopower 4000 for delphi 2006」· PAS 代码 · 共 1,684 行 · 第 1/5 页

PAS
1,684
字号
            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.create(self)
            else EditControl:= TwwDBDateTimePicker(curEditControl);
            if not CreateEditControl(EditControl) then continue;
         end
         else if (not (csDesigning in ComponentState)) and
            wwIsRichEditField(curField, True) then begin
            if recreate then EditControl:= TwwDBRichEdit.create(self)
            else EditControl:= TWinControl(curEditControl);
            if not CreateEditControl(EditControl) then continue;
         end
         else if (curField.dataType = ftMemo) then begin
            if recreate then begin
               if EditFrame.IsFrameEffective then
                  EditControl:= TwwDBEditMemo.create(self)
               else
                  EditControl:= TwwDBMemo.create(self)
            end
            else EditControl:= TWinControl(curEditControl);
            if not CreateEditControl(EditControl) then continue;
         end
         else if (curField.dataType = ftGraphic) then begin { 8/27/98 - Support images }
            if recreate then editControl:= TDBImage.create(self)
            else EditControl:= TWinControl(curEditControl);
            if not CreateEditControl(EditControl) then continue;
         end
         else begin
            if recreate or (curEditControl=Nil) then begin
               EditControl:= CreateDefaultEditControl(self);
//               EditControl:= TwwDBEdit.create(self);
               EditControl.controlStyle:= EditControl.ControlStyle + [csNoDesignVisible];
            end
            else EditControl:= TWinControl(curEditControl);

            if not CreateEditControl(EditControl) then continue;

         end;
         curLineWidth := curLineWidth + wwmax(curFieldEditWidth,curFieldLabelWidth)+
                         EditSpacing.HorizontalView.BetweenEditsInRow;
         realMaxLineWidth:= wwmax(realMaxLineWidth, curLineWidth - EditSpacing.HorizontalView.BetweenEditsInRow);
      end;

      PrevTop := PrevTop + EditSpacing.HorizontalView.BetweenLabelEdit +
                 LastEditHeight + LastLabelHeight + Margin.BottomOffset; {New Top Value}

      Self.VertScrollBar.Margin:= 6;
      Self.VertScrollBar.Range := PrevTop;

      { Shrink edit controls to fit panel width }
      if (Height-5<PrevTop) then
      begin
          {$ifdef wwDelphi4up}
          ShowingVertScrollBar:= True;
          {$else}
          ShowingVertScrollBar:= False; { Skip Delphi 4 specific code for setting horz scroll range }
          {$endif}
          FixedEditWidth:= FixedEditWidth - GetSystemMetrics(SM_CXHThumb);
          if Recreate then begin
            for j:= 0 to ControlCount-1 do begin
               if TControl(Controls[j]) is TWinControl then begin
                  curEditControl:= Controls[j];
                  if ((rvopShortenEditBox in Options) or
                      (rvopConsistentEditWidth in Options) or
                      (not isSingleLineEditControl(TWinControl(curEditControl)))) then
                     if (curEditControl.Width>FixedEditWidth) then
                         curEditControl.Width:= FixedEditWidth
               end;
            end
          end
          else begin
             for j:= 0 to ControlPositions.count-1 do
             begin
                cp:= TControlPosition(ControlPositions[j]);
                with cp do
                begin
                   if Control is TWinControl then
                   begin
                      if ((rvopShortenEditBox in Options) or
                         (rvopConsistentEditWidth in Options) or
                         (not isSingleLineEditControl(TWinControl(Control)))) then
                        if (Width>FixedEditWidth) then
                           Width:= FixedEditWidth
                   end
                end
             end
         end;
         MaxEditWidth:= 0;
         for j:= 0 to ControlPositions.count-1 do
         begin
            cp:= TControlPosition(Control

⌨️ 快捷键说明

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