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

📄 wwricheditbar.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 3 页
字号:
         {Change Hints}
         FontNameCombo.Hint := FontNameComboHint;
         FontSizeCombo.Hint := FontSizeComboHint;

        {Buttons}
        NewButton.Hint := NewButtonHint;
        LoadButton.Hint := LoadButtonHint;
        SaveAsButton.Hint := SaveAsButtonHint;
        PrintButton.Hint := PrintButtonHint;
        PrintPreviewButton.Hint := PrintPreviewButtonHint;
        FindButton.Hint := FindButtonHint;
        CutButton.Hint := CutButtonHint;
        CopyButton.Hint := CopyButtonHint;
        UndoButton.Hint := UndoButtonHint;
        SpellButton.Hint := SpellCheckHint;

       RedoButton.Hint := RedoButtonHint;
       if RedoButton.Hint='' then RedoButton.Hint:= 'Redo | Reverses the last undo action';

       PasteButton.Hint := PasteButtonHint;
       BoldButton.Hint := BoldButtonHint;
       ColorButton.Hint := ColorButtonHint;

       UnderlineButton.Hint := UnderlineButtonHint;
       ItalicButton.Hint := ItalicButtonHint;
       LeftButton.Hint := LeftButtonHint;
       CenterButton.Hint := CenterButtonHint;
       JustifyButton.Hint := JustifyButtonHint;
       RightButton.Hint := RightButtonHint;
       BulletButton.Hint := BulletButtonHint;
       HighlightButton.Hint:= HighlightButtonHint;

       //File Menu Items
{       Load1.Hint:= LoadButton1.Hint;
       SaveAs1.Hint:= SaveAsButton.Hint;
       SaveExit1.Hint := SaveExitHint;
       Print1.Hint := PrintButton.Hint;
       PrintPreview1.Hint := PrintPreviewButton.Hint;
       PageSetup1.Hint:=PageSetupHint;
       Exit1.Hint:= ExitHint;

       //Edit Menu Items
       Undo1.Hint:= UndoButton.Hint;
       Cut1.Hint:= CutButton.Hint;
       Copy1.Hint:= CopyButton.Hint;
       Paste1.Hint:= PasteButton.Hint;
       Find1.Hint:=FindButton.Hint;
       Clear1.Hint:= ClearHint;
       SelectAll1.Hint:= SelectAllHint;
       FindNext1.Hint:= FindNextHint;
       Replace1.Hint:=ReplaceHint;
       InsertObject1.Hint:=InsertObjectHint;
       Spelling1.Hint:= SpellCheckHint;
}
       {View Menu Items}
       Toolbar.Hint:= ToolbarHint;
       FormatBar.Hint:= FormatBarHint;
//       Options1.Hint:=OptionsHint;

       //Format Menu Items
       {
       Font1.Hint:=FontHint;
       BulletStyle1.Hint:= BulletButton.Hint;
       Paragraph1.Hint:= ParagraphHint;
       Tabs1.Hint:=TabsHint;
       }
    end;

    // Change Menu Item Labels
    {
    File1.Caption := MenuLabels.FileCaption;
    Load1.Caption := MenuLabels.LoadCaption;
    SaveAs1.Caption := MenuLabels.SaveAsCaption;
    SaveExit1.Caption := MenuLabels.SaveExitCaption;
    Print1.Caption := MenuLabels.PrintCaption;
    PrintPreview1.Caption := MenuLabels.PrintPreviewCaption;
    PageSetup1.Caption := MenuLabels.PageSetupCaption;
    Exit1.Caption := MenuLabels.ExitCaption;

    Edit1.Caption := MenuLabels.EditCaption;
    Undo1.Caption := MenuLabels.UndoCaption;
    Cut1.Caption := MenuLabels.CutCaption;
    Copy1.Caption := MenuLabels.CopyCaption;
    Paste1.Caption := MenuLabels.PasteCaption;
    Clear1.Caption := MenuLabels.ClearCaption;
    Selectall1.Caption := MenuLabels.SelectallCaption;
    Find1.Caption:= MenuLabels.FindCaption;
    FindNext1.Caption:=MenuLabels.FindNextCaption;
    Replace1.Caption:=MenuLabels.ReplaceCaption;
    InsertObject1.Caption:=MenuLabels.InsertObjectCaption;

    Insert1.Caption:= MenuLabels.InsertCaption;
    if Insert1.Caption='' then Insert1.caption:= '&Insert';
    Ruler1.Caption:= MenuLabels.RulerCaption;
    if Ruler1.Caption='' then Ruler1.caption:= '&Ruler';
    Redo1.Caption:= MenuLabels.RedoCaption;
    if Redo1.Caption='' then Redo1.caption:= '&Redo';


    View1.Caption := MenuLabels.ViewCaption;
    Tools1.Caption := MenuLabels.ToolCaption;
    Spelling1.Caption := MenuLabels.SpellCheckCaption;
    Toolbar1.Caption:= MenuLabels.ToolbarCaption;
    FormatBar1.Caption:=MenuLabels.FormatBarCaption;
    StatusBar1.Caption:=MenuLabels.ViewStatusBarCaption;
    Options1.Caption:=MenuLabels.OptionsCaption;

    Format1.Caption:=MenuLabels.FormatCaption;
    Font1.Caption:=MenuLabels.FontCaption;
    BulletStyle1.Caption:=MenuLabels.BulletStyleCaption;
    Paragraph1.Caption:=MenuLabels.ParagraphCaption;
    Tabs1.Caption := MenuLabels.TabsCaption;

    Help1.Caption := MenuLabels.HelpCaption;
    }
    end;
end;


procedure TwwRichEditBar.UpdateControlPositions;
var CurrentTop: integer;
begin
   RichEditBarFrame.ResizeBar;
   CurrentTop:= 0;

   with RichEditBarFrame do begin
      LoadButton.Visible:= rebShowLoad in Options;
      SaveAsbutton.visible:= rebShowSaveAs in Options;
      Printbutton.visible:= rebshowPrint in Options;
      PrintPreviewButton.Visible:= rebShowPrintPreview in Options;
      ApplyIntl;

//      PageSetup.Visible:= rebPageSetup in Options;

      
      if (rebShowToolbar in Options) then
      begin
         if csDesigning in ComponentState then
         begin
            ToolBar.ControlStyle:= Toolbar.Controlstyle - [csNoDesignVisible];
         end;
         ToolBar.Width:= ToolBar.Parent.Width;
         ToolBar.Visible:=true;

         CurrentTop:= ToolBar.Top + ToolBar.height + 2;
         if (rebShowFormatBar in Options) then
         begin
            FormatbarBevel.visible:=true;
            FormatBarBevel.Top:= CurrentTop - 2;
         end;

      end
      else begin
         if csDesigning in ComponentState then
         begin
            ToolBar.ControlStyle:= Toolbar.Controlstyle + [csNoDesignVisible];
         end;
         ToolBar.Visible:=false;
         FormatBarBevel.Visible:=false;
      end;

      if (rebShowFormatBar in Options) then
      begin
         Formatbar.Top:= CurrentTop+1;
         FormatBar.Width:= FormatBar.Parent.Width;         
         FormatBar.Visible:=true;
         CurrentTop:= FormatBar.Top + FormatBar.height + 2;
         if (rebShowRuler in Options) then
         begin
            RulerBevel.visible:= true;
            RulerBevel.Top:= CurrentTop;
         end;
//         RulerBevel.Top:= CurrentTop;
      end
      else begin
         FormatBar.Visible:= false;
//         RulerBevel.Top:= CurrentTop;
         RulerBevel.Visible:= false;
      end;

      if (rebShowRuler in Options) then
      begin
//         RulerBevel.visible:=true;
//         RulerBevel.Top:= CurrentTop + 1;
         wwRulerPanel.Top:= CurrentTop+1;
         CurrentTop:= wwRulerPanel.Top + wwRulerPanel.height +1;
      end
      else begin
         RulerBevel.visible:=false;
      end;
      RichEdit.Top:= CurrentTop;
   end;
{
   if not (rebShowToolbar in Options) then
   begin
      Currenttop:=
      if (rebShowFormatbar in Options) then
      begin
         RichEditbarFrame.ToolBar.Visible:= false;
         RichEditbarFrame.FormatBar.Visible:=true;
         RichEditbarFrame.FormatBarBevel.Visible:=false;
         RichEditBarFrame.RulerBevel.visible:=true;
         RichEditbarFrame.FormatBar.Top:=4;
         RichEditbarFrame.RulerBevel.Top:= RichEditBarFrame.FormatBar.Top + 23;
         RichEditBarFrame.wwRulerPanel.Top:= RichEditBarFrame.FormatBar.Top + RichEditBarFrame.FormatBar.height;
      end
      else begin
         RichEditbarFrame.FormatBar.Visible:= false;
         RichEditbarFrame.ToolBar.Visible:= false;
         RichEditbarFrame.FormatBarBevel.Visible:=false;
         RichEditBarFrame.RulerBevel.visible:=false;
         RichEditBarFrame.wwRulerPanel.Top:= 0;
      end;
   end
   else begin
      if (rebShowFormatbar in Options) then
      begin
         CurrentTop:= FormatBar.Top + FormatBar.Height + 2;
      end
      else begin
         RichEditbarFrame.ToolBar.Visible:= true;
         RichEditbarFrame.FormatBarBevel.Visible:=true;
         RichEditbarFrame.FormatBar.Top:=30;
         RichEditbarFrame.RulerBevel.Top:= RichEditBarFrame.FormatBar.Top + 23;
         RichEditBarFrame.wwRulerPanel.Top:= RichEditBarFrame.FormatBar.Top + RichEditBarFrame.FormatBar.height;
         CurrentTop:= RichEditBarFrame.ToolBar.Top + RichEditBarFrame.ToolBar.Height + 2;
      end;
   end;

   RichEdit.Top:= CurrentTop;
 }
end;

procedure TwwRichEditBar.RichEditSelectionChange(Sender: TObject);
begin
  if richedit1.visible then
     self.RichEditBarFrame.RefreshControls;
end;

procedure TwwRichBarFrame.RichEditBarEnter(Sender: TObject);
begin
//  richedit1.setfocus;
end;

procedure TwwRichBarFrame.RightButtonClick(Sender: TObject);
begin
  richedit1.Paragraph.Alignment:= taRightJustify;
  RefreshControls;
end;

procedure TwwRichBarFrame.RedoButtonClick(Sender: TObject);
begin
    SendMessage(RichEdit1.Handle, EM_REDO, 0, 0);
    RefreshControls;

end;

Procedure TwwRichBarFrame.RefreshControls;
var haveSelection, haveText: boolean;
begin
  RichEdit1.HandleNeeded;
  BoldButton.down:= fsBold in richedit1.SelAttributes.Style;
  UnderlineButton.down:= fsUnderline in richedit1.SelAttributes.Style;
  ItalicButton.down:= fsItalic in richedit1.SelAttributes.Style;
  FontNameCombo.itemIndex:= FontNameCombo.items.indexOf(RichEdit1.SelAttributes.Name);
  if FontNameCombo.itemIndex<0 then begin
     FontNameCombo.text:= RichEdit1.SelAttributes.Name;
     FontNameCombo.font.color:=clRed;
  end
  else FontNameCombo.font.color:=clWindowText;
  FontSizeCombo.itemIndex:= FontSizeCombo.items.indexOf(inttostr(RichEdit1.SelAttributes.Size));
  //9/5/2001- If no font size in dropdown still set text to current size. Just like wordpad.
  if FontSizeCombo.itemindex = -1 then
     FontSizeCombo.Text :=inttostr(RichEdit1.SelAttributes.Size);

  BulletButton.down:= richedit1.Paragraph.Numbering = nsBullet;

  //10/02/2001 - More accurate way of determining if background color is highlighted.
  HighlightButton.Down:= (ColorToRGB(richedit1.GetTextBackgroundColor)=ColorToRGB(RichEdit1.HighlightColor));
//  HighlightButton.Down:= (richedit1.GetTextBackgroundColor<>0) and
//                         (richedit1.GetTextBackgroundColor<>ColorToRGB(clWindow));

//  BulletStyle1.checked:= BulletButton.down;
  if ord(richedit1.Paragraph.Alignment) = PFA_FULLJUSTIFY-1 then
     JustifyButton.Down:= True
  else begin
    case richedit1.Paragraph.Alignment of
      taLeftJustify: LeftButton.Down:= True;
      taCenter: CenterButton.Down:= True;
      taRightJustify: RightButton.Down:= True;
    end;
  end;


    PasteButton.enabled:= RichEdit1.CanPaste and (not RichEdit1.readonly);

    UndoButton.enabled:= RichEdit1.CanUndo;
    RedoButton.enabled:= RichEdit1.CanRedo;

    haveSelection:= RichEdit1.CanCut;
//    haveText:= RichEdit1.text<>''; { This line was very slow for larger buffers }
    haveText:= (RichEdit1.Lines.Count>1) or
               (RichEdit1.Lines.Count=1) and (RichEdit1.Lines[0]<>'');

    CutButton.enabled:= haveSelection and (not RichEdit1.readonly);

    CopyButton.enabled:= haveSelection;
    {
    Clear1.enabled:= haveSelection and (not RichEdit1.readOnly);
    SelectAll1.enabled:= haveText;
    Find1.enabled:= haveText;
    FindButton.enabled:= haveText;
    FindNext1.enabled:= RichEdit1.CanFindNext;
    Replace1.enabled:= haveText and (not RichEdit1.readOnly);
     }
    TwwRulerPanel(wwRulerPanel).UpdateDragIcons;

end;



procedure TwwRichBarFrame.ColorClick(Sender: TObject);
begin
   RichEdit1.SelAttributes.Color:= (Sender as TMenuItem).Tag;
end;

procedure TwwRichBarFrame.InitColorMenu;
var i: Integer;
  procedure SetOwnerDraw(Item: TMenuItem);
  type TwwMenuItemInfo = packed record
    cbSize: UINT;
    fMask: UINT;
    fType: UINT;             { used if MIIM_TYPE}
    fState: UINT;            { used if MIIM_STATE}
    wID: UINT;               { used if MIIM_ID}
    hSubMenu: HMENU;         { used if MIIM_SUBMENU}
    hbmpChecked: HBITMAP;    { used if MIIM_CHECKMARKS}
    hbmpUnchecked: HBITMAP;  { used if MIIM_CHECKMARKS}
    dwItemData: DWORD;       { used if MIIM_DATA}
    dwTypeData: PAnsiChar;      { used if MIIM_TYPE}
    cch: UINT;               { used if MIIM_TYPE}
  end;
  var mii: TMenuItemInfo;
  begin
    FillChar(mii, SizeOf(TMenuItemInfo), 0);
    mii.cbSize := SizeOf(TwwMenuItemInfo);
    mii.fMask := MIIM_TYPE or MIIM_DATA;
    mii.fType := MFT_OWNERDRAW;
    mii.dwItemData := Integer(Item);
    SetMenuItemInfo(Item.Parent.Handle, Item.MenuIndex, True, mii);
  end;
begin
  for i := 0 to PopupMenu1.Items.Count - 1 do
  begin
    SetOwnerDraw(PopupMenu1.Items[i]);
    PopupMenu1.Items[i].OnClick:= ColorClick;
  end;
  Automatic1.Tag:= RichEdit1.Font.Color; { Use richedit's font color }
end;

procedure TwwRichBarFrame.BoldButtonClick(Sender: TObject);
begin
  RichEdit1.SetStyleAttribute(fsBold, not TempDown);
  RefreshControls;
end;

procedure TwwRichBarFrame.BoldButtonMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   tempdown:= (Sender as TToolButton).down;
end;

procedure TwwRichBarFrame.BulletButtonClick(Sender: TObject);
begin
  RichEdit1.SetBullet(not TempDown);
  RefreshControls;
end;

procedure TwwRichBarFrame.CenterButtonClick(Sender: TObject);
begin
  richedit1.Paragraph.Alignment:= taCenter;
  RefreshControls;
end;

procedure TwwRichBarFrame.ColorButtonClick(Sender: TObject);
var p: TPoint;
begin
  p:= FormatBar.ClientToScreen(Point(ColorButton.left, ColorButton.Top + ColorButton.Height));

  TrackPopupMenu(PopupMenu1.Handle, TPM_LEFTALIGN,
     p.x-1, p.y, 0, RichEditBar.Parent.handle, nil);
//     p.x-1, p.y, 0, handle, nil);

⌨️ 快捷键说明

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