Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Attributes
Laxkit::FilePreviewer Class Reference

Previews images if possible, otherwise shows a snippet of text. More...

Inheritance diagram for Laxkit::FilePreviewer:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 FilePreviewer (anXWindow *pwindow, const char *nname, const char *ntitle, unsigned long nstyle, int nx, int ny, int nw, int nh, int brder, const char *file=NULL, int sz=5000)
virtual const chartooltip ()
virtual void Refresh ()
virtual const charwhattype ()
virtual int SetText (const char *newtext)
virtual int Preview (const char *file)
 Change what is being previewed to file. ***this function currently rather sucks.
virtual const charPreview ()
 Return name of file being previewed.
- Public Member Functions inherited from Laxkit::MessageBar
 MessageBar (anXWindow *pwindow, const char *nname, const char *ntitle, unsigned long nstyle, int nx, int ny, int nw, int nh, int brder, const char *newtext)
 Pass in the new text after the regular window parameters.
virtual int SetupMetrics ()
 If window dimensions are initially == 0 this sets them to extent of the message plus pads.
virtual charGetText ()
 Get a char[] copy of the message text, with '\n' for the linebreaks.
virtual int init ()
virtual int Event (const EventData *e, const char *mes)
virtual int LBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int MBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int RBDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int LBUp (int x, int y, unsigned int state, const LaxMouse *d)
virtual int MBUp (int x, int y, unsigned int state, const LaxMouse *d)
virtual int RBUp (int x, int y, unsigned int state, const LaxMouse *d)
virtual int WheelUp (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int WheelDown (int x, int y, unsigned int state, int count, const LaxMouse *d)
virtual int MouseMove (int x, int y, unsigned int state, const LaxMouse *d)
virtual int MoveResize (int nx, int ny, int nw, int nh)
virtual int Resize (int nw, int nh)
virtual LaxFiles::Attributedump_out_atts (LaxFiles::Attribute *att, int what, anObject *context)
virtual void dump_in_atts (LaxFiles::Attribute *att, int flag, anObject *context)
- Public Member Functions inherited from Laxkit::anXWindow
 anXWindow (anXWindow *parnt, const char *nname, const char *ntitle, unsigned long nstyle, int xx, int yy, int ww, int hh, int brder, anXWindow *prev, unsigned long nowner, const char *nsend)
 Constructor.
virtual ~anXWindow ()
 anXWindow destructor. Its X window should have been XDestroy'd before here.
virtual const charWindowTitle (int which=0)
 Return basically the name of the window.
virtual void WindowTitle (const char *newtitle)
 Change the title of the window. This text would usually be displayed in the bar provided by a window manager.
virtual const chartooltip (int mouseid=0)
 By default, return win_tooltip.
virtual const chartooltip (const char *newtooltip)
 Replace the current tooltip, return the current tooltip (after replacing).
virtual anXWindowfindChildWindowByTitle (const char *title)
 Find the first immediate child window that has win_title==title.
virtual anXWindowfindChildWindowByName (const char *name)
 Find the first immediate child window that has win_name==name.
virtual int Grayed ()
 Return whether this window is grayed.
virtual int Grayed (int g)
 Set the gray state of this window. Returns Grayed(void).
virtual int preinit ()
virtual int close ()
 Called by anXApp from anXApp::destroywindow() when a window is to be destroyed.
virtual int Idle (int tid=0)
 anXWindow::Idle() is an empty placeholeder. Just returns 1.
virtual DisplayerMakeCurrent ()
virtual int Needtodraw ()
 Default is to return needtodraw.
virtual void Needtodraw (int nntd)
 If 0, then the window does not need refreshing. Otherwise it does.
virtual int deletenow ()
 Return whether the window is allowed to be deleted.
virtual int setWinStyle (unsigned int stylebit, int newvalue)
 Control various window related basic styling of win_style.
virtual int getWinStyle (unsigned int stylebit)
 Currently, simply return win_style&stylebit.
virtual void installColors (WindowColors *newcolors)
 Dec_count old and inc_count new.
virtual ShortcutHandlerGetShortcuts ()
 Return a ShortcutHandler that contains stacks of bound shortcuts and possible window actions.
virtual int PerformAction (int action_number)
virtual int ExposeChange (ScreenEventData *e)
 Default behavior on Expose events is to call Needtodraw(1).
virtual int DeviceChange (const DeviceEventData *e)
virtual int CharInput (unsigned int ch, const char *buffer, int len, unsigned int state, const LaxKeyboard *kb)
 Input of character data or control character presses.
virtual int KeyUp (unsigned int ch, unsigned int state, const LaxKeyboard *kb)
 Called when a key is released.
virtual int ButtonDown (int button, int x, int y, unsigned int state, int count, const LaxMouse *m)
virtual int ButtonUp (int button, int x, int y, unsigned int state, const LaxMouse *m)
virtual int FocusOn (const FocusChangeData *e)
 Increment win_active, and highlights the window's border, if the event refers to this window.
virtual int FocusOff (const FocusChangeData *e)
 Decrements win_active, and de-highlights the window's border if win_active==0, if event is a real focus off.
virtual void contentChanged ()
 Windows may call this when their contents change.
virtual void selectionChanged ()
 Windows may call this when their selections change.
virtual anXWindowGetController ()
 Return the window most relevant for tab control loops.
virtual int SelectNextControl (const LaxDevice *d)
 Transfer focus to nextcontrol.
virtual int SelectPrevControl (const LaxDevice *d)
 Transfer the focus to prevcontrol.
virtual void ControlActivation (int on)
 Do special activation or not when controls are activated by tabbing.
virtual int AddPrevControl (anXWindow *prev)
virtual int AddNextControl (anXWindow *next)
virtual int ConnectControl (anXWindow *towhat, int after=1)
 Connect towhat to this. Used for tab loops.
virtual int CloseControlLoop ()
 Close a tab loop.
virtual void SetOwner (anXWindow *nowner, const char *mes=NULL, unsigned int send_mask=0)
 Set the new owner and control message.
virtual void SetOwner (unsigned long nowner_id, const char *mes=NULL, unsigned int send_mask=0)
virtual void dump_out (FILE *f, int indent, int what, anObject *context)
 Simple dumping function.
- Public Member Functions inherited from Laxkit::Tagged
virtual int HasTag (const char *tag, int casematters)
 Return whether the tag exists.
virtual int NumberOfTags ()
 Return the number of tags, strangely enough.
virtual const charGetTag (int i)
 Return const pointer to the tag text for tag number i, where i==0 is the first tag.
virtual charGetAllTags ()
 Return a new char[] with a space separated list of all the tags.
virtual int InsertTags (const char *tags, int casematters)
 Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'.
virtual int InsertTag (const char *tag, int casematters)
 Insert tag if it doesn't exist already.
virtual int RemoveTag (const char *tag)
 The tag must be an exact match.
virtual int RemoveTag (int i)
 Remove tag number i. i must be in range [0..NumberOfTags()-1].
virtual void FlushTags ()
- Public Member Functions inherited from LaxFiles::DumpUtility
virtual void dump_in (FILE *f, int indent, int what, Laxkit::anObject *loadcontext, Attribute **att)
 Read in a file segment as an Attribute, and pass parsing duties to dump_in_atts.
virtual ~DumpUtility ()
 Empty virtual destructor.
- Public Member Functions inherited from Laxkit::aDrawable
 aDrawable (Drawable d=0)
virtual int DrawableType ()
virtual int ValidDrawable ()

Public Attributes

int pad
- Public Attributes inherited from Laxkit::MessageBar
int padx
int pady
- Public Attributes inherited from Laxkit::anXWindow
WindowColorswin_colors
anXAppapp
charwin_name
 An arbitrary string to be used as an id.
charwin_title
 The title of the window.
anXWindowwin_parent
int win_screen
unsigned long win_style
int win_x
int win_y
int win_w
int win_h
unsigned int win_border
int win_pointer_shape
 Identifier for a stock mouse shape.
char win_on
 Nonzero if the window is mapped.
char win_active
 Should be positive when the window has a keyboard focus, 0 otherwise.
unsigned long win_owner
 Who gets control messages from this window.
unsigned int win_owner_send_mask
charwin_sendthis
 The type of message that gets sent to owner.
anXWindownextcontrol
anXWindowprevcontrol
- Public Attributes inherited from Laxkit::Tagged
int sorttags

Protected Attributes

charfilename
long sizelimit
 File size above which images are not loaded, in kilobytes.
int state
 What is being previewed.
Imlib_Image image
- Protected Attributes inherited from Laxkit::MessageBar
int lbdown
int firsttime
int msx
int msy
int ox
 The x coordinate of the left edge of the text extent.
int oy
 The y coordinate of the baseline of the top line of text.
double ex
 The x extent of the text.
double ey
 The y extent of the text.
double fasc
double fdes
char ** thetext
int nlines
double * indents
unsigned long textcolor
unsigned long bkcolor
unsigned long bordercolor
ButtonDownInfo buttondown
- Protected Attributes inherited from Laxkit::anXWindow
charwin_tooltip
 Convenience variable to hold the window's tooltip, if any.
int needtodraw
RefPtrStack< anXWindow_kids
 Stack of children of the window.
- Protected Attributes inherited from Laxkit::Tagged
PtrStack< charlist_of_tags

Detailed Description

Previews images if possible, otherwise shows a snippet of text.

This class only shows a basic box with file name written in it. For a previewer with some changeable dialog info see ImageDialog.

If you compile the Laxkit with Imlib2 support, then this class allows you to preview any image that Imlib2 can load. If you use this, then your application should also call InitLaxImlib() shortly after creating your anXApp.

If you do not compile in Imlib2 support, then you only get some garbled text for all non-text files.

If a file cannot be recognized as an image, the previewer puts some text roughly corresponding to the contents of the file. Utf8, latin-1, and ascii text it prints as it is.. If there are '\0' bytes in the file, it is assumed to be binary, and each non-ascii is printed as '*' or 'FF' or some such.

If FILEPREV_SHOW_DIMS is passed in as a style, then when showing images, also write out the dimensions and file size.

Todo:

***if text, should be able to toggle between ascii(latin-1)/utf-8, binary hex.

*** make this not depend on Imlib!


Member Function Documentation

void Laxkit::FilePreviewer::Refresh ( )
virtual

Member Data Documentation

int Laxkit::FilePreviewer::state
protected

What is being previewed.

  • 0=question mark (usually NULL filename)
  • 1=bad filename
  • 2=text
  • 3=image

The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:52:59, Laxkit