Source code of file oscpmwin/colorsel.pas from the
osCommerce Product Manager for Windows.


0000:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001:   osCommerce Product Manager for Windows (oscpmwin).
0002:   Copyright �2003-2006 by Mario A. Valdez-Ramirez.
0003:   
0004:   You can contact Mario A. Valdez-Ramirez
0005:   by email at mario@mariovaldez.org or paper mail at
0006:   Olmos 809, San Nicolas, NL. 66495, Mexico.
0007:   
0008:   This program is free software; you can redistribute it and/or modify
0009:   it under the terms of the GNU General Public License as published by
0010:   the Free Software Foundation; either version 2 of the License, or (at
0011:   your option) any later version.
0012:   
0013:   This program is distributed in the hope that it will be useful, but
0014:   WITHOUT ANY WARRANTY; without even the implied warranty of
0015:   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0016:   General Public License for more details.
0017:   
0018:   You should have received a copy of the GNU General Public License
0019:   along with this program; if not, write to the Free Software
0020:   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0021:   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0022:   unit colorsel;
0023:   
0024:   interface
0025:   
0026:   uses
0027:     SysUtils, Classes, Graphics, Controls, Forms,
0028:     StdCtrls, Buttons, ExtCtrls, Spin;
0029:   
0030:   type
0031:     Topm_Form_ColorSel = class(TForm)
0032:       opm_BitBtn_ColorSelOk: TBitBtn;
0033:       opm_BitBtn_ColorSelCancel: TBitBtn;
0034:       opm_Image_ColorSelTable: TImage;
0035:       opm_Panel_ColorSelSample: TPanel;
0036:       opm_Edit_ColorSelInput: TEdit;
0037:       procedure opm_Image_ColorSelTableMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
0038:       procedure opm_Image_ColorSelTableMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
0039:       procedure opm_Image_ColorSelTableMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
0040:       procedure FormShow(Sender: TObject);
0041:       procedure FormCreate(Sender: TObject);
0042:       procedure opm_BitBtn_ColorSelOkClick(Sender: TObject);
0043:       procedure opm_Edit_ColorSelInputExit(Sender: TObject);
0044:     private
0045:       opmG_ChoosingColor : BOOLEAN;
0046:     public
0047:       opmG_ColorChoosed : TColor;
0048:       opmG_ColorChoosedDec : LONGINT;
0049:       opmG_ColorChoosedRGB : STRING;
0050:     end;
0051:   
0052:   var
0053:     opm_Form_ColorSel: Topm_Form_ColorSel;
0054:   
0055:   
0056:   implementation
0057:   
0058:   Uses gnugettext, dataman;
0059:   
0060:   
0061:   {$R *.dfm}
0062:   
0063:   
0064:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0065:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0066:   procedure Topm_Form_ColorSel.opm_Image_ColorSelTableMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
0067:   begin
0068:     opmG_ColorChoosed := opm_Image_ColorSelTable.Canvas.Pixels[X,Y];
0069:     opmG_ColorChoosedRGB := FNopm_ColorToRGB (opmG_ColorChoosed);
0070:     opmG_ColorChoosedDec := FNopm_ColorToDecColor (opmG_ColorChoosed);
0071:     opmG_ColorChoosed := FNopm_DecColorToColor (opmG_ColorChoosedDec);
0072:     opm_Panel_ColorSelSample.Color := opmG_ColorChoosed;
0073:     opm_Panel_ColorSelSample.Caption := opmG_ColorChoosedRGB;
0074:     opm_Panel_ColorSelSample.Font.Color := FNopm_ComplementaryColor (opmG_ColorChoosed);
0075:     opm_Edit_ColorSelInput.Text := opmG_ColorChoosedRGB;
0076:     opmG_ChoosingColor := TRUE;
0077:   end;
0078:   
0079:   
0080:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0081:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0082:   procedure Topm_Form_ColorSel.opm_Image_ColorSelTableMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
0083:   begin
0084:     IF (opmG_ChoosingColor = TRUE) THEN
0085:       BEGIN
0086:         opmG_ColorChoosed := opm_Image_ColorSelTable.Canvas.Pixels[X,Y];
0087:         opmG_ColorChoosedRGB := FNopm_ColorToRGB (opmG_ColorChoosed);
0088:         opmG_ColorChoosedDec := FNopm_ColorToDecColor (opmG_ColorChoosed);
0089:         opmG_ColorChoosed := FNopm_DecColorToColor (opmG_ColorChoosedDec);
0090:         opm_Panel_ColorSelSample.Color := opmG_ColorChoosed;
0091:         opm_Panel_ColorSelSample.Caption := opmG_ColorChoosedRGB;
0092:         opm_Panel_ColorSelSample.Font.Color := FNopm_ComplementaryColor (opmG_ColorChoosed);
0093:         opm_Edit_ColorSelInput.Text := opmG_ColorChoosedRGB;
0094:       END;
0095:   end;
0096:   
0097:   
0098:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0099:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0100:   procedure Topm_Form_ColorSel.opm_Image_ColorSelTableMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
0101:   begin
0102:     opmG_ChoosingColor := FALSE;
0103:   END;
0104:   
0105:   
0106:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0107:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0108:   procedure Topm_Form_ColorSel.FormShow(Sender: TObject);
0109:   begin
0110:     opm_Form_ColorSel.Caption := _('Choose a color...');
0111:     opmG_ChoosingColor := FALSE;
0112:     opm_Panel_ColorSelSample.Color := opmG_ColorChoosed;
0113:     opmG_ColorChoosedRGB := FNopm_ColorToRGB (opmG_ColorChoosed);
0114:     opm_Panel_ColorSelSample.Caption := opmG_ColorChoosedRGB;
0115:     opm_Panel_ColorSelSample.Font.Color := FNopm_ComplementaryColor (opmG_ColorChoosed);
0116:     opmG_ColorChoosedDec := FNopm_ColorToDecColor (opmG_ColorChoosed);
0117:     opm_Edit_ColorSelInput.Text := opmG_ColorChoosedRGB;
0118:   end;
0119:   
0120:   
0121:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0122:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0123:   procedure Topm_Form_ColorSel.FormCreate(Sender: TObject);
0124:   begin
0125:     TranslateComponent (self);
0126:     opm_Panel_ColorSelSample.DoubleBuffered := TRUE;
0127:     opmG_ColorChoosed := clWhite;
0128:     opmG_ColorChoosedRGB := 'FFFFFF';
0129:   end;
0130:   
0131:   
0132:   
0133:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0134:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0135:   procedure Topm_Form_ColorSel.opm_BitBtn_ColorSelOkClick(Sender: TObject);
0136:   begin
0137:     opm_Edit_ColorSelInput.Text := FNopm_CleanHexNumber (opm_Edit_ColorSelInput.Text, 6);
0138:     opmG_ColorChoosed := STRTOINT ('$00' + COPY (opm_Edit_ColorSelInput.Text, 5, 2) + COPY (opm_Edit_ColorSelInput.Text, 3, 2) + COPY (opm_Edit_ColorSelInput.Text, 1, 2));
0139:     opmG_ColorChoosedRGB := FNopm_ColorToRGB (opmG_ColorChoosed);
0140:     opmG_ColorChoosedDec := FNopm_ColorToDecColor (opmG_ColorChoosed);
0141:     opmG_ColorChoosed := FNopm_DecColorToColor (opmG_ColorChoosedDec);
0142:   end;
0143:   
0144:   
0145:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0146:   {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
0147:   procedure Topm_Form_ColorSel.opm_Edit_ColorSelInputExit(Sender: TObject);
0148:   begin
0149:     opm_Edit_ColorSelInput.Text := FNopm_CleanHexNumber (opm_Edit_ColorSelInput.Text, 6);
0150:     opmG_ColorChoosed := STRTOINT ('$00' + COPY (opm_Edit_ColorSelInput.Text, 5, 2) + COPY (opm_Edit_ColorSelInput.Text, 3, 2) + COPY (opm_Edit_ColorSelInput.Text, 1, 2));
0151:     opmG_ColorChoosedRGB := FNopm_ColorToRGB (opmG_ColorChoosed);
0152:     opmG_ColorChoosedDec := FNopm_ColorToDecColor (opmG_ColorChoosed);
0153:     opmG_ColorChoosed := FNopm_DecColorToColor (opmG_ColorChoosedDec);
0154:     opm_Panel_ColorSelSample.Color := opmG_ColorChoosed;
0155:     opm_Panel_ColorSelSample.Caption := opmG_ColorChoosedRGB;
0156:     opm_Panel_ColorSelSample.Font.Color := FNopm_ComplementaryColor (opmG_ColorChoosed);
0157:   end;
0158:   
0159:   end.
 
 
NA fum/lmd: 2007.07.15
Copyright ©1994-2024 by Mario A. Valdez-Ramírez.
no siga este enlace / do not follow this link