Tag Archives: rkView

SmartView sample application

This is the source code of the teaser program. Take note that this is just a sample and not, in any way, a complete application.

It uses a lot of my components so I suggest you download and install all of them.

Original a D2007 project but now a D2010 project. This means that the saving and loading of the albums are in ansi code and not unicode. When compiling in D2010 you will get a lot of warnings. I needed it to be in ansi code to be compatible with my existing album files. It should not be to difficult to come up with a different way of loading and saving albums.

Hope this helps a little in working with rkSmartView.

Some keys…
Ctrl + arrow left and right to expand and close all groups.
Space = Preview
Alt + left mousebutton will show image information.
F8 will show statistic information.
Press and hold left mousebutton in imagepreview to zoom.

Download project code

rkView component

rkView v1.1 is done and ready for download. ParentFont support have been added and a problem with scrollbar calculation have been fixed. Please do report back if the problem is not solved.

What is rkView?
rkView is my solution for a listview/gridview. I do not like the included TListview that comes with Delphi so I made my own. That way I have full control of how it works and act.

The best way to see what you can do with rkView is to download any of the thumbnail demos. More demos will come later. If you make a demo using rkView I would love to see it, maybe it could be included as a demo?

Download rkView

Roy M Klever

Cool thumbnails

An extra thumbnail post, the last one for a while.  I will show you how to edit caption of the thumbnail and how you can rate it using your mouse. The main activity is done in the CellHit event so make sure that CellSelect is set to false, somehow this must be done in code so a good place to do it is in formCreate event.

Rated thumbs

Rated thumbs

Here is the code for CellHit. One thing to remember about this event is that y is counted from the bottom and not from the top as normal. This can be a bit confusing.

procedure TfrmMain.viewMainCellHit(Sender: TObject; Canvas: TCanvas; Idx, x,
  y: Integer; var Selected: Boolean);
var
  i: Integer;
begin
  if (y < 20 ) then begin
    i:= 0;
    if (CellStyle = 0) and (y < 20) then i:= 1;
    if i <> CellEditIdx then begin
      CellEditIdx:= i;
      ViewMain.Invalidate;
    end;
  end else begin
    if CellEditIdx <> -1 then ViewMain.Invalidate;
    CellEditIdx:= -1;
  end;
  if CellStyle <> 1 then Exit;
  // Check if over rating stars
  if (x > HSX) and (x < HSX + 70) and (y < 20) then begin
    CellEditIdx:= 2;
    i:= 1 + (x - HSX) div 14;
    if i <> HotStars then begin
      HotStars:= i;
      ViewMain.Invalidate;
    end;
  end else begin
    if HotStars <> -1 then ViewMain.Invalidate;
    HotStars:= -1;
  end;
end;

This event code is called whenever mouse is over a cell to check if it is selected we use it to do some checking and set some flags which we use in the OnMouseDown event.

CellEditIdx is used to signal what to check for. If it is one we simply check if mouse is in the lower part of the thumb if it is we mark it and do a repaint. The same with rating we do a check to see if it is within the rating area and do a repaint if it changes value.

In the MouseDownEvent the action is done. If rating is active the selected thumb will be updated with the current rating. If rating is not active an editbox is activated giving you a chance to change the filename of the selected thumb. Note that in demo changing the name of the thumb will not change the real name of the file, it is just for showing you how to do it.

When tumbnail component got focus you can press F8 to see some statistic of current state.

Hope this helps a little. You should also update the rkView component used in this demo as some small bugs have been fixed. I will later publish rkview as a single post in its own with some more samples.

Next post up is how to adjust brightness, contrast and saturation to an image.

Download: Cool thumbnails

Showing thumbnails part #2

In part one I showed you how to show thumbnails in one predefined size, now it is time to take it to the next level. I show you how to make realtime resizable thumbnails.

Thumbs demo

Screenshot of thumbnails demo

The trick to make it work is to use an additional  list of bitmap thumbnails. Thumbnails is still kept as jpegs in the items list. The diffrence between previus version and this one is that when rendred to screen they are converted to bitmaps and cached in a bitmap list. This makes screen update faster and more pleasent.

I use a cache size of one point five the screensize but you can set it to whatever you want.

rkView has been updated so it is recommended that you recompile the package where you installed the rkView.

Enough said download the code and see for yourself. Enjoy and have fun!

Download: Thumbnails demo

Showing thumbnails part #1

I have split the thumbnail project into to parts. In part one, this one,  I will show you how to view thumbnails the easy way using rkView.

rkView is just like a virtual grid view, no data is stored inside it.  rkView was made to ease the task of viewing tumbnails but are not in any way limited to this task.  I also use this component as a ownerdraw listview. So go ahead an install this component (it is included in the download).

Screenshot of Thumbs demo

Screenshot of thumbnails demo

Showing thumbnails using rkView is an easy task all we need is a list of thumbnails and some code to draw it. rkView will call the ‘OnCellPaint’ event for each cell, giving us a canvas to paint on.

In this demo I have chosen to store the thumbnails as jpeg since it occupies less space than using bitmaps.

Well it is time to download and run the code.

Download: Thumbnails demo