/fontforgeexe/cvpalettes.c
C | 4443 lines | 3820 code | 433 blank | 190 comment | 983 complexity | 8f7bb73147e3a5162aad5752bd1dd8bc MD5 | raw file
Possible License(s): AGPL-1.0, GPL-3.0, Unlicense
Large files files are truncated, but you can click here to view the full file
- /* Copyright (C) 2000-2012 by George Williams */
- /*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include "fontforgeui.h"
- #include "collabclientui.h"
- int palettes_docked=1;
- int rectelipse=0, polystar=0, regular_star=1;
- int center_out[2] = { false, true };
- float rr_radius=0;
- int ps_pointcnt=6;
- float star_percent=1.7320508; /* Regular 6 pointed star */
- extern int interpCPsOnMotion;
- #include <gkeysym.h>
- #include <math.h>
- #include "splinefont.h"
- #include <ustring.h>
- #include <utype.h>
- #include <gresource.h>
- #include "charview_private.h"
- #include "gdraw/hotkeys.h"
- static void CVLCheckLayerCount(CharView *cv, int resize);
- extern void CVDebugFree(DebugView *dv);
- extern GBox _ggadget_Default_Box;
- #define ACTIVE_BORDER (_ggadget_Default_Box.active_border)
- #define MAIN_FOREGROUND (_ggadget_Default_Box.main_foreground)
- extern GDevEventMask input_em[];
- extern const int input_em_cnt;
- int cvvisible[2] = { 1, 1}, bvvisible[3]= { 1,1,1 };
- static GWindow cvlayers, cvtools, bvlayers, bvtools, bvshades;
- static GWindow cvlayers2=NULL;
- #define LSHOW_CUBIC 1
- #define LSHOW_FG 2
- #define LSHOW_PREVIEW 4
- static int layerscols = LSHOW_CUBIC|LSHOW_FG|LSHOW_PREVIEW; /* which columns to show in layers1 palette */
- static int layer_height = 0; /* height of each layer row in layers1 palette */
- static int layer_header_height = 0; /* height of initial stuff in layers1 palette */
- static int layer_footer_height = 0; /* height of +/- buttons at bottom of layers1 palette */
- static int layers_max = 2; /* Maximum number of layers for which widgets have been allocated in layers1 palette */
- struct l2 {
- int active; /* index of the active layer */
- int offtop; /* first layer to show at the top line in layers palette */
- int visible_layers; /* number of layers apart from the guides layer to show before using a scrollbar */
- int current_layers; /* number of layers for the current character, and the number used in l2.layers */
- int max_layers; /* maximum number of layers for which layer controls and previews have been allocated */
- BDFChar **layers; /* layer thumbnail previews */
- int sb_start; /* x pixel position of the scrollbar */
- int column_width; /* width of various indicator columns */
- int mo_col, mo_layer; /* mouse over column and layer */
- int rename_active; /* If >=2, layer number for which the edit box for layer names is active */
- GClut *clut;
- GFont *font; /* font to draw text in the palette with */
- } layerinfo = { /* info about the current layers in the layers palette */
- 2, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, NULL, NULL
- };
- struct l2 layer2 = { 2, 0, 0, 0, 0, NULL, 0, 0, 0, 0, 0, NULL, NULL };
- static int layers2_active = -1;
- static GPoint cvtoolsoff = { -9999, -9999 }, cvlayersoff = { -9999, -9999 }, bvlayersoff = { -9999, -9999 }, bvtoolsoff = { -9999, -9999 }, bvshadesoff = { -9999, -9999 };
- int palettes_fixed=1;
- static GCursor tools[cvt_max+1] = { ct_pointer }, spirotools[cvt_max+1];
- enum cvtools cv_b1_tool = cvt_pointer, cv_cb1_tool = cvt_pointer,
- cv_b2_tool = cvt_magnify, cv_cb2_tool = cvt_ruler;
- static GFont *toolsfont=NULL, *layersfont=NULL;
- #define CV_TOOLS_WIDTH 53
- #define CV_TOOLS_HEIGHT (10*27+4*12+2)
- #define CV_LAYERS_WIDTH 104
- #define CV_LAYERS_HEIGHT 100
- #define CV_LAYERS_INITIALCNT 6
- #define CV_LAYERS_LINE_HEIGHT 25
- #define CV_LAYERS2_WIDTH 120
- #define CV_LAYERS2_HEIGHT 196
- #define CV_LAYERS2_LINE_HEIGHT 25
- #define CV_LAYERS2_HEADER_HEIGHT 20
- #define CV_LAYERS2_VISLAYERS ( (CV_LAYERS2_HEIGHT-CV_LAYERS2_HEADER_HEIGHT-2*CV_LAYERS2_LINE_HEIGHT)/CV_LAYERS2_LINE_HEIGHT )
- #define BV_TOOLS_WIDTH 53
- #define BV_TOOLS_HEIGHT 80
- #define BV_LAYERS_HEIGHT 73
- #define BV_LAYERS_WIDTH 73
- #define BV_SHADES_HEIGHT (8+9*16)
- /* These are control ids for the layers palette controls */
- #define CID_VBase 1000
- #define CID_VGrid (CID_VBase+ly_grid)
- #define CID_VBack (CID_VBase+ly_back)
- #define CID_VFore (CID_VBase+ly_fore)
- #define CID_EBase 3000
- #define CID_EGrid (CID_EBase+ly_grid)
- #define CID_EBack (CID_EBase+ly_back)
- #define CID_EFore (CID_EBase+ly_fore)
- #define CID_QBase 5000
- #define CID_QGrid (CID_QBase+ly_grid)
- #define CID_QBack (CID_QBase+ly_back)
- #define CID_QFore (CID_QBase+ly_fore)
- #define CID_FBase 7000
- #define CID_SB 8000
- #define CID_Edit 8001
- #define CID_AddLayer 9000
- #define CID_RemoveLayer 9001
- #define CID_RenameLayer 9002
- #define CID_LayersMenu 9003
- static void ReparentFixup(GWindow child,GWindow parent, int x, int y, int width, int height ) {
- /* This is so nice */
- /* KDE does not honor my request for a border for top level windows */
- /* KDE does not honor my request for size (for narrow) top level windows */
- /* Gnome gets very confused by reparenting */
- /* If we've got a top level window, then reparenting it removes gnome's */
- /* decoration window, but sets the new parent to root (rather than what */
- /* we asked for */
- /* I have tried reparenting it twice, unmapping & reparenting. Nothing works */
- GWidgetReparentWindow(child,parent,x,y);
- if ( width!=0 )
- GDrawResize(child,width,height);
- GDrawSetWindowBorder(child,1,GDrawGetDefaultForeground(NULL));
- }
- void onCollabSessionStateChanged( GObject* gobj, FontViewBase* fv )
- {
- bool inCollab = collabclient_inSessionFV( fv );
- if (cvlayers != NULL) {
- GGadgetSetEnabled(GWidgetGetControl(cvlayers,CID_AddLayer), !inCollab );
- GGadgetSetEnabled(GWidgetGetControl(cvlayers,CID_RemoveLayer), !inCollab );
- GGadgetSetEnabled(GWidgetGetControl(cvlayers,CID_RenameLayer), !inCollab );
- } else if (cvlayers2 != NULL && 0) {
- // These controls seem not to exist in cvlayers2. We can look deeper into this later.
- GGadgetSetEnabled(GWidgetGetControl(cvlayers2,CID_AddLayer), !inCollab );
- GGadgetSetEnabled(GWidgetGetControl(cvlayers2,CID_RemoveLayer), !inCollab );
- GGadgetSetEnabled(GWidgetGetControl(cvlayers2,CID_RenameLayer), !inCollab );
- }
- }
- /* Initialize a window that is to be used for a palette. Specific widgets and other functionality are added elsewhere. */
- static GWindow CreatePalette(GWindow w, GRect *pos, int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs, GWindow v) {
- GWindow gw;
- GPoint pt, base;
- GRect newpos;
- GWindow root;
- GRect ownerpos, screensize;
- pt.x = pos->x; pt.y = pos->y;
- if ( !palettes_fixed ) {
- root = GDrawGetRoot(NULL);
- GDrawGetSize(w,&ownerpos);
- GDrawGetSize(root,&screensize);
- GDrawTranslateCoordinates(w,root,&pt);
- base.x = base.y = 0;
- GDrawTranslateCoordinates(w,root,&base);
- if ( pt.x<0 ) {
- if ( base.x+ownerpos.width+20+pos->width+20 > screensize.width )
- pt.x=0;
- else
- pt.x = base.x+ownerpos.width+20;
- }
- if ( pt.y<0 ) pt.y=0;
- if ( pt.x+pos->width>screensize.width )
- pt.x = screensize.width-pos->width;
- if ( pt.y+pos->height>screensize.height )
- pt.y = screensize.height-pos->height;
- }
- wattrs->mask |= wam_bordcol|wam_bordwidth;
- wattrs->border_width = 1;
- wattrs->border_color = GDrawGetDefaultForeground(NULL);
- newpos.x = pt.x; newpos.y = pt.y; newpos.width = pos->width; newpos.height = pos->height;
- wattrs->mask|= wam_positioned;
- wattrs->positioned = true;
- gw = GDrawCreateTopWindow(NULL,&newpos,eh,user_data,wattrs);
- if ( palettes_docked )
- ReparentFixup(gw,v,0,pos->y,pos->width,pos->height);
- collabclient_addSessionJoiningCallback( onCollabSessionStateChanged );
- collabclient_addSessionLeavingCallback( onCollabSessionStateChanged );
-
- return( gw );
- }
- /* Return screen coordinates of the palette in off, relative to the root window origin. */
- static void SaveOffsets(GWindow main, GWindow palette, GPoint *off) {
- if ( !palettes_docked && !palettes_fixed && GDrawIsVisible(palette)) {
- GRect mr, pr;
- GWindow root, temp;
- root = GDrawGetRoot(NULL);
- while ( (temp=GDrawGetParentWindow(main))!=root )
- main = temp;
- GDrawGetSize(main,&mr);
- GDrawGetSize(palette,&pr);
- off->x = pr.x-mr.x;
- off->y = pr.y-mr.y;
- if ( off->x<0 ) off->x = 0;
- if ( off->y<0 ) off->y = 0;
- }
- }
- /* Set the palette window position to off, a point in the root window space. */
- static void RestoreOffsets(GWindow main, GWindow palette, GPoint *off) {
- GPoint pt;
- GWindow root,temp;
- GRect screensize, pos;
- if ( palettes_fixed )
- return;
- pt = *off;
- root = GDrawGetRoot(NULL);
- GDrawGetSize(root,&screensize);
- GDrawGetSize(palette,&pos);
- while ( (temp=GDrawGetParentWindow(main))!=root )
- main = temp;
- GDrawTranslateCoordinates(main,root,&pt);
- if ( pt.x<0 ) pt.x=0;
- if ( pt.y<0 ) pt.y=0;
- if ( pt.x+pos.width>screensize.width )
- pt.x = screensize.width-pos.width;
- if ( pt.y+pos.height>screensize.height )
- pt.y = screensize.height-pos.height;
- GDrawTrueMove(palette,pt.x,pt.y);
- GDrawRaise(palette);
- }
- static void CVMenuTool(GWindow gw,struct gmenuitem *mi,GEvent *e) {
- CharView *cv = (CharView *) GDrawGetUserData(gw);
- cv->b1_tool = mi->mid;
- if ( cvtools!=NULL )
- GDrawRequestExpose(cvtools,NULL,false);
- CVToolsSetCursor(cv,0,NULL);
- }
- static void CVChangeSpiroMode(CharView *cv);
- static void CVMenuSpiroSet(GWindow gw,struct gmenuitem *mi,GEvent *e) {
- CharView *cv = (CharView *) GDrawGetUserData(gw);
- CVChangeSpiroMode(cv);
- }
- void cvtoollist_check(GWindow gw,struct gmenuitem *mi,GEvent *e) {
- CharView *cv = (CharView *) GDrawGetUserData(gw);
- int order2 = cv->b.layerheads[cv->b.drawmode]->order2;
- for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) {
- mi->ti.checked = mi->mid==cv->b1_tool;
- switch ( mi->mid ) {
- case cvt_freehand:
- mi->ti.disabled = order2;
- break;
- case cvt_spiro:
- mi->ti.disabled = !hasspiro();
- break;
- }
- }
- }
- /* Note: If you change this ordering, change enum cvtools */
- static char *popupsres[] = {
- N_("Pointer"), N_("Magnify (Minify with alt)"),
- N_("Draw a freehand curve"), N_("Scroll by hand"),
- N_("Cut splines in two"), N_("Measure distance, angle between points"),
- N_("Add a point, then drag out its control points"), N_("Change whether spiro is active or not"),
- N_("Add a curve point"), N_("Add a curve point always either horizontal or vertical"),
- N_("Add a corner point"), N_("Add a tangent point"),
- N_("Scale the selection"), N_("Rotate the selection"),
- N_("Flip the selection"), N_("Skew the selection"),
- N_("Rotate the selection in 3D and project back to plain"), N_("Perform a perspective transformation on the selection"),
- N_("Rectangle or Ellipse"), N_("Polygon or Star"),
- N_("Rectangle or Ellipse"), N_("Polygon or Star")};
- GMenuItem2 cvtoollist[] = {
- { { (unichar_t *) N_("_Pointer"), (GImage *) "toolspointer.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Pointer|No Shortcut"), NULL, NULL, CVMenuTool, cvt_pointer },
- { { (unichar_t *) N_("_Magnify"), (GImage *) "toolsmagnify.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Magnify|No Shortcut"), NULL, NULL, CVMenuTool, cvt_magnify },
- { { (unichar_t *) N_("_Freehand"), (GImage *) "toolsfreehand.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Freehand|No Shortcut"), NULL, NULL, CVMenuTool, cvt_freehand },
- { { (unichar_t *) N_("_Scroll"), (GImage *) "toolsscroll.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Scroll|No Shortcut"), NULL, NULL, CVMenuTool, cvt_hand },
- { { (unichar_t *) N_("_Knife"), (GImage *) "toolsknife.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Knife|No Shortcut"), NULL, NULL, CVMenuTool, cvt_knife },
- { { (unichar_t *) N_("_Ruler"), (GImage *) "toolsruler.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Ruler|No Shortcut"), NULL, NULL, CVMenuTool, cvt_ruler },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("P_en"), (GImage *) "toolspen.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Pen|No Shortcut"), NULL, NULL, CVMenuTool, cvt_pen },
- { { (unichar_t *) N_("_Activate Spiro"), (GImage *) "toolsspiro.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Activate Spiro|No Shortcut"), NULL, NULL, CVMenuSpiroSet, cvt_spiro },
- { { (unichar_t *) N_("_Curve"), (GImage *) "pointscurve.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Curve Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_curve },
- { { (unichar_t *) N_("_HVCurve"), (GImage *) "pointshvcurve.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'o' }, H_("HVCurve Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_hvcurve },
- { { (unichar_t *) N_("C_orner"), (GImage *) "pointscorner.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'o' }, H_("Corner Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_corner },
- { { (unichar_t *) N_("_Tangent"), (GImage *) "pointstangent.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Tangent Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_tangent },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("Sca_le"), (GImage *) "toolsscale.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Scale|No Shortcut"), NULL, NULL, CVMenuTool, cvt_scale },
- { { (unichar_t *) N_("Rotate"), (GImage *) "toolsrotate.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Rotate|No Shortcut"), NULL, NULL, CVMenuTool, cvt_rotate },
- { { (unichar_t *) N_("Flip"), (GImage *) "toolsflip.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Flip|No Shortcut"), NULL, NULL, CVMenuTool, cvt_flip },
- { { (unichar_t *) N_("Ske_w"), (GImage *) "toolsskew.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Skew|No Shortcut"), NULL, NULL, CVMenuTool, cvt_skew },
- { { (unichar_t *) N_("_3D Rotate"), (GImage *) "tools3drotate.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("3D Rotate|No Shortcut"), NULL, NULL, CVMenuTool, cvt_3d_rotate },
- { { (unichar_t *) N_("Perspecti_ve"), (GImage *) "toolsperspective.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Perspective|No Shortcut"), NULL, NULL, CVMenuTool, cvt_perspective },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("Rectan_gle"), (GImage *) "toolsrect.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Rectangle|No Shortcut"), NULL, NULL, CVMenuTool, cvt_rect },
- { { (unichar_t *) N_("Pol_ygon"), (GImage *) "toolspolygon.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Polygon|No Shortcut"), NULL, NULL, CVMenuTool, cvt_poly },
- { { (unichar_t *) N_("Ellipse"), (GImage *) "toolselipse.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Ellipse|No Shortcut"), NULL, NULL, CVMenuTool, cvt_elipse },
- { { (unichar_t *) N_("Star"), (GImage *) "toolsstar.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Star|No Shortcut"), NULL, NULL, CVMenuTool, cvt_star },
- GMENUITEM2_EMPTY
- };
- GMenuItem2 cvspirotoollist[] = {
- { { (unichar_t *) N_("_Pointer"), (GImage *) "toolspointer.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Pointer|No Shortcut"), NULL, NULL, CVMenuTool, cvt_pointer },
- { { (unichar_t *) N_("_Magnify"), (GImage *) "toolsmagnify.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Magnify|No Shortcut"), NULL, NULL, CVMenuTool, cvt_magnify },
- { { (unichar_t *) N_("_Freehand"), (GImage *) "toolsfreehand.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Freehand|No Shortcut"), NULL, NULL, CVMenuTool, cvt_freehand },
- { { (unichar_t *) N_("_Scroll"), (GImage *) "toolsscroll.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Scroll|No Shortcut"), NULL, NULL, CVMenuTool, cvt_hand },
- { { (unichar_t *) N_("_Knife"), (GImage *) "toolsknife.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Knife|No Shortcut"), NULL, NULL, CVMenuTool, cvt_knife },
- { { (unichar_t *) N_("_Ruler"), (GImage *) "toolsruler.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Ruler|No Shortcut"), NULL, NULL, CVMenuTool, cvt_ruler },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("_Knife"), (GImage *) "toolsknife.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Knife|No Shortcut"), NULL, NULL, CVMenuTool, cvt_knife },
- { { (unichar_t *) N_("_Ruler"), (GImage *) "toolsruler.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Ruler|No Shortcut"), NULL, NULL, CVMenuTool, cvt_ruler },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("De_activate Spiro"), (GImage *) "toolsspiro.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Activate Spiro|No Shortcut"), NULL, NULL, CVMenuSpiroSet, cvt_spiro },
- { { (unichar_t *) N_("C_orner"), (GImage *) "pointscorner.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'o' }, H_("Corner Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_spirocorner },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("G_4"), (GImage *) "pointscurve.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("G4 Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_spirog4 },
- { { (unichar_t *) N_("G_2"), (GImage *) "pointsG2curve.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'o' }, H_("G2 Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_spirog2 },
- { { (unichar_t *) N_("Lef_t"), (GImage *) "pointsspiroprev.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Left Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_spiroleft },
- { { (unichar_t *) N_("Rig_ht"), (GImage *) "pointsspironext.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Right Tool|No Shortcut"), NULL, NULL, CVMenuTool, cvt_spiroright },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("Sca_le"), (GImage *) "toolsscale.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Scale|No Shortcut"), NULL, NULL, CVMenuTool, cvt_scale },
- { { (unichar_t *) N_("Rotate"), (GImage *) "toolsrotate.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Rotate|No Shortcut"), NULL, NULL, CVMenuTool, cvt_rotate },
- { { (unichar_t *) N_("Flip"), (GImage *) "toolsflip.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Flip|No Shortcut"), NULL, NULL, CVMenuTool, cvt_flip },
- { { (unichar_t *) N_("Ske_w"), (GImage *) "toolsskew.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Skew|No Shortcut"), NULL, NULL, CVMenuTool, cvt_skew },
- { { (unichar_t *) N_("_3D Rotate"), (GImage *) "tools3drotate.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("3D Rotate|No Shortcut"), NULL, NULL, CVMenuTool, cvt_3d_rotate },
- { { (unichar_t *) N_("Perspecti_ve"), (GImage *) "toolsperspective.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Perspective|No Shortcut"), NULL, NULL, CVMenuTool, cvt_perspective },
- { { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, /* line */
- { { (unichar_t *) N_("Rectan_gle"), (GImage *) "toolsrect.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Rectangle|No Shortcut"), NULL, NULL, CVMenuTool, cvt_rect },
- { { (unichar_t *) N_("Pol_ygon"), (GImage *) "toolspolygon.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Polygon|No Shortcut"), NULL, NULL, CVMenuTool, cvt_poly },
- { { (unichar_t *) N_("Ellipse"), (GImage *) "toolselipse.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Ellipse|No Shortcut"), NULL, NULL, CVMenuTool, cvt_elipse },
- { { (unichar_t *) N_("Star"), (GImage *) "toolsstar.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Star|No Shortcut"), NULL, NULL, CVMenuTool, cvt_star },
- GMENUITEM2_EMPTY
- };
- static char *editablelayers[] = {
- /* GT: Foreground, make it short */
- N_("F_ore"),
- /* GT: Background, make it short */
- N_("_Back"),
- /* GT: Guide layer, make it short */
- N_("_Guide")
- };
- static real raddiam_x = 20, raddiam_y = 20, rotate_by=0;
- static StrokeInfo expand = {
- 25, lj_round, lc_butt, si_centerline,
- false, /* removeexternal */
- false, /* removeinternal */
- false, /* leave users */
- 3.1415926535897932/4, 25, NULL, 50,
- 0.0, 0, 0, NULL, NULL
- };
- real CVRoundRectRadius(void) {
- return( rr_radius );
- }
- int CVRectElipseCenter(void) {
- return( center_out[rectelipse] );
- }
- int CVPolyStarPoints(void) {
- return( ps_pointcnt );
- }
- real CVStarRatio(void) {
- if ( regular_star )
- return( sin(3.1415926535897932/ps_pointcnt)*tan(2*3.1415926535897932/ps_pointcnt)+cos(3.1415926535897932/ps_pointcnt) );
-
- return( star_percent );
- }
- StrokeInfo *CVFreeHandInfo(void) {
- return( &expand );
- }
-
- struct ask_info {
- GWindow gw;
- int done;
- int ret;
- float *val;
- int *co;
- GGadget *rb1;
- GGadget *reg;
- GGadget *pts;
- int ispolystar;
- int haspos;
- char *lab;
- CharView *cv;
- };
- #define CID_ValText 1001
- #define CID_PointPercent 1002
- #define CID_CentCornLab 1003
- #define CID_CentCornX 1004
- #define CID_CentCornY 1005
- #define CID_RadDiamLab 1006
- #define CID_RadDiamX 1007
- #define CID_RadDiamY 1008
- #define CID_Angle 1009
- static void FakeShapeEvents(CharView *cv) {
- GEvent event;
- real trans[6];
- cv->active_tool = rectelipse ? cvt_elipse : cvt_rect;
- if ( cv->b.sc->inspiro && hasspiro() ) {
- GDrawSetCursor(cv->v,spirotools[cv->active_tool]);
- GDrawSetCursor(cvtools,spirotools[cv->active_tool]);
- } else {
- GDrawSetCursor(cv->v,tools[cv->active_tool]);
- GDrawSetCursor(cvtools,tools[cv->active_tool]);
- }
- cv->showing_tool = cv->active_tool;
- memset(&event,0,sizeof(event));
- event.type = et_mousedown;
- CVMouseDownShape(cv,&event);
- cv->info.x += raddiam_x;
- cv->info.y += raddiam_y;
- CVMouseMoveShape(cv);
- CVMouseUpShape(cv);
- if ( raddiam_x!=0 && raddiam_y!=0 && rotate_by!=0 ) {
- trans[0] = trans[3] = cos ( rotate_by*3.1415926535897932/180. );
- trans[1] = sin( rotate_by*3.1415926535897932/180. );
- trans[2] = -trans[1];
- trans[4] = -cv->p.x*trans[0] - cv->p.y*trans[2] + cv->p.x;
- trans[5] = -cv->p.x*trans[1] - cv->p.y*trans[3] + cv->p.y;
- SplinePointListTransform(cv->b.layerheads[cv->b.drawmode]->splines,trans,
- interpCPsOnMotion?tpt_OnlySelectedInterpCPs:tpt_OnlySelected);
- SCUpdateAll(cv->b.sc);
- }
- cv->active_tool = cvt_none;
- }
- static int TA_OK(GGadget *g, GEvent *e) {
- if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
- struct ask_info *d = GDrawGetUserData(GGadgetGetWindow(g));
- real val, val2=0;
- int err=0;
- int re = !GGadgetIsChecked(d->rb1);
- if ( d->ispolystar ) {
- val = GetInt8(d->gw,CID_ValText,d->lab,&err);
- if ( !(regular_star = GGadgetIsChecked(d->reg)))
- val2 = GetReal8(d->gw,CID_PointPercent,_("Size of Points"),&err);
- } else {
- val = GetReal8(d->gw,CID_ValText,d->lab,&err);
- d->co[re] = !GGadgetIsChecked(d->reg);
- }
- if ( err )
- return( true );
- if ( d->haspos ) {
- real x,y, radx,rady, ang;
- x = GetInt8(d->gw,CID_CentCornX,_("_X"),&err);
- y = GetInt8(d->gw,CID_CentCornY,_("_Y"),&err);
- radx = GetInt8(d->gw,CID_RadDiamX,_("Radius: "),&err);
- rady = GetInt8(d->gw,CID_RadDiamY,_("Radius: "),&err);
- ang = GetInt8(d->gw,CID_Angle,_("Angle:"),&err);
- if ( err )
- return( true );
- d->cv->p.x = d->cv->info.x = x;
- d->cv->p.y = d->cv->info.y = y;
- raddiam_x = radx; raddiam_y = rady;
- rotate_by = ang;
- rectelipse = re;
- *d->val = val;
- FakeShapeEvents(d->cv);
- }
- *d->val = val;
- d->ret = re;
- d->done = true;
- if ( !regular_star && d->ispolystar )
- star_percent = val2/100;
- SavePrefs(true);
- }
- return( true );
- }
- static int TA_Cancel(GGadget *g, GEvent *e) {
- if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
- struct ask_info *d = GDrawGetUserData(GGadgetGetWindow(g));
- d->done = true;
- }
- return( true );
- }
- static int TA_CenRadChange(GGadget *g, GEvent *e) {
- if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
- struct ask_info *d = GDrawGetUserData(GGadgetGetWindow(g));
- int is_bb = GGadgetIsChecked(d->reg);
- GGadgetSetTitle8(GWidgetGetControl(d->gw,CID_CentCornLab),
- is_bb ? _("Corner") : _("C_enter"));
- GGadgetSetTitle8(GWidgetGetControl(d->gw,CID_RadDiamLab),
- is_bb ? _("Diameter:") : _("Radius: "));
- }
- return( true );
- }
- static int TA_RadChange(GGadget *g, GEvent *e) {
- if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
- struct ask_info *d = GDrawGetUserData(GGadgetGetWindow(g));
- int is_ellipse = !GGadgetIsChecked(d->rb1);
- GGadgetSetEnabled(GWidgetGetControl(d->gw,CID_ValText), !is_ellipse );
- GGadgetSetChecked(d->reg,!center_out[is_ellipse]);
- GGadgetSetChecked(d->pts,center_out[is_ellipse]);
- if ( d->haspos )
- TA_CenRadChange(g,e);
- }
- return( true );
- }
- static int toolask_e_h(GWindow gw, GEvent *event) {
- if ( event->type==et_close ) {
- struct ask_info *d = GDrawGetUserData(gw);
- d->done = true;
- } else if ( event->type == et_map ) {
- /* Above palettes */
- GDrawRaise(gw);
- }
- return( event->type!=et_char );
- }
- static int Ask(char *rb1, char *rb2, int rb, char *lab, float *val, int *co,
- int ispolystar, CharView *cv ) {
- struct ask_info d;
- char buffer[20], buf[20];
- char cenx[20], ceny[20], radx[20], rady[20], angle[20];
- GRect pos;
- GWindowAttrs wattrs;
- GGadgetCreateData gcd[19];
- GTextInfo label[19];
- int off = ((ispolystar&1)?15:0) + ((ispolystar&2)?84:0);
- int haspos = (ispolystar&2)?1:0;
- ispolystar &= 1;
- d.done = false;
- d.ret = rb;
- d.val = val;
- d.co = co;
- d.ispolystar = ispolystar;
- d.haspos = haspos;
- d.lab = lab;
- d.cv = cv;
- memset(&wattrs,0,sizeof(wattrs));
- wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
- wattrs.event_masks = ~(1<<et_charup);
- wattrs.restrict_input_to_me = 1;
- wattrs.undercursor = 1;
- wattrs.cursor = ct_pointer;
- wattrs.utf8_window_title = _("Shape Type");
- wattrs.is_dlg = true;
- pos.x = pos.y = 0;
- pos.width = GGadgetScale(GDrawPointsToPixels(NULL,190));
- pos.height = GDrawPointsToPixels(NULL,120+off);
- d.gw = GDrawCreateTopWindow(NULL,&pos,toolask_e_h,&d,&wattrs);
- memset(&label,0,sizeof(label));
- memset(&gcd,0,sizeof(gcd));
- label[0].text = (unichar_t *) rb1;
- label[0].text_is_1byte = true;
- gcd[0].gd.label = &label[0];
- gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 5;
- gcd[0].gd.flags = gg_enabled|gg_visible | (rb==0?gg_cb_on:0);
- gcd[0].creator = GRadioCreate;
- label[1].text = (unichar_t *) rb2;
- label[1].text_is_1byte = true;
- gcd[1].gd.label = &label[1];
- gcd[1].gd.pos.x = ispolystar?65:75; gcd[1].gd.pos.y = 5;
- gcd[1].gd.flags = gg_enabled|gg_visible | (rb==1?gg_cb_on:0);
- gcd[1].creator = GRadioCreate;
- label[2].text = (unichar_t *) lab;
- label[2].text_is_1byte = true;
- gcd[2].gd.label = &label[2];
- gcd[2].gd.pos.x = 5; gcd[2].gd.pos.y = 25;
- gcd[2].gd.flags = gg_enabled|gg_visible ;
- gcd[2].creator = GLabelCreate;
- sprintf( buffer, "%g", *val );
- label[3].text = (unichar_t *) buffer;
- label[3].text_is_1byte = true;
- gcd[3].gd.label = &label[3];
- gcd[3].gd.pos.x = 5; gcd[3].gd.pos.y = 40;
- gcd[3].gd.flags = gg_enabled|gg_visible ;
- gcd[3].gd.cid = CID_ValText;
- gcd[3].creator = GTextFieldCreate;
- gcd[4].gd.pos.x = 20-3; gcd[4].gd.pos.y = 85+off;
- gcd[4].gd.pos.width = -1; gcd[4].gd.pos.height = 0;
- gcd[4].gd.flags = gg_visible | gg_enabled | gg_but_default;
- label[4].text = (unichar_t *) _("_OK");
- label[4].text_is_1byte = true;
- label[4].text_in_resource = true;
- gcd[4].gd.mnemonic = 'O';
- gcd[4].gd.label = &label[4];
- gcd[4].gd.handle_controlevent = TA_OK;
- gcd[4].creator = GButtonCreate;
- gcd[5].gd.pos.x = -20; gcd[5].gd.pos.y = 85+3+off;
- gcd[5].gd.pos.width = -1; gcd[5].gd.pos.height = 0;
- gcd[5].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
- label[5].text = (unichar_t *) _("_Cancel");
- label[5].text_is_1byte = true;
- label[5].text_in_resource = true;
- gcd[5].gd.label = &label[5];
- gcd[5].gd.mnemonic = 'C';
- gcd[5].gd.handle_controlevent = TA_Cancel;
- gcd[5].creator = GButtonCreate;
- if ( ispolystar ) {
- label[6].text = (unichar_t *) _("Regular");
- label[6].text_is_1byte = true;
- gcd[6].gd.label = &label[6];
- gcd[6].gd.pos.x = 5; gcd[6].gd.pos.y = 70;
- gcd[6].gd.flags = gg_enabled|gg_visible | (rb==0?gg_cb_on:0);
- gcd[6].creator = GRadioCreate;
- label[7].text = (unichar_t *) _("Points:");
- label[7].text_is_1byte = true;
- gcd[7].gd.label = &label[7];
- gcd[7].gd.pos.x = 65; gcd[7].gd.pos.y = 70;
- gcd[7].gd.flags = gg_enabled|gg_visible | (rb==1?gg_cb_on:0);
- gcd[7].creator = GRadioCreate;
- sprintf( buf, "%4g", star_percent*100 );
- label[8].text = (unichar_t *) buf;
- label[8].text_is_1byte = true;
- gcd[8].gd.label = &label[8];
- gcd[8].gd.pos.x = 125; gcd[8].gd.pos.y = 70; gcd[8].gd.pos.width=50;
- gcd[8].gd.flags = gg_enabled|gg_visible ;
- gcd[8].gd.cid = CID_PointPercent;
- gcd[8].creator = GTextFieldCreate;
- label[9].text = (unichar_t *) "%";
- label[9].text_is_1byte = true;
- gcd[9].gd.label = &label[9];
- gcd[9].gd.pos.x = 180; gcd[9].gd.pos.y = 70;
- gcd[9].gd.flags = gg_enabled|gg_visible ;
- gcd[9].creator = GLabelCreate;
- } else {
- label[6].text = (unichar_t *) _("Bounding Box");
- label[6].text_is_1byte = true;
- gcd[6].gd.label = &label[6];
- gcd[6].gd.pos.x = 5; gcd[6].gd.pos.y = 65;
- gcd[6].gd.flags = gg_enabled|gg_visible | (co[rb]==0?gg_cb_on:0);
- gcd[6].creator = GRadioCreate;
- label[7].text = (unichar_t *) _("Center Out");
- label[7].text_is_1byte = true;
- gcd[7].gd.label = &label[7];
- gcd[7].gd.pos.x = 90; gcd[7].gd.pos.y = 65;
- gcd[7].gd.flags = gg_enabled|gg_visible | (co[rb]==1?gg_cb_on:0);
- gcd[7].creator = GRadioCreate;
- if ( rb )
- gcd[3].gd.flags = gg_visible;
- gcd[0].gd.handle_controlevent = TA_RadChange;
- gcd[1].gd.handle_controlevent = TA_RadChange;
- if ( haspos ) {
- gcd[6].gd.handle_controlevent = TA_CenRadChange;
- gcd[7].gd.handle_controlevent = TA_CenRadChange;
- label[8].text = (unichar_t *) _("_X");
- label[8].text_is_1byte = true;
- label[8].text_in_resource = true;
- gcd[8].gd.label = &label[8];
- gcd[8].gd.pos.x = 70; gcd[8].gd.pos.y = gcd[7].gd.pos.y+15;
- gcd[8].gd.flags = gg_enabled|gg_visible;
- gcd[8].creator = GLabelCreate;
- label[9].text = (unichar_t *) _("_Y");
- label[9].text_is_1byte = true;
- label[9].text_in_resource = true;
- gcd[9].gd.label = &label[9];
- gcd[9].gd.pos.x = 120; gcd[9].gd.pos.y = gcd[8].gd.pos.y;
- gcd[9].gd.flags = gg_enabled|gg_visible;
- gcd[9].creator = GLabelCreate;
- label[10].text = (unichar_t *) (co[rb] ? _("C_enter") : _("C_orner") );
- label[10].text_is_1byte = true;
- label[10].text_in_resource = true;
- gcd[10].gd.label = &label[10];
- gcd[10].gd.pos.x = 5; gcd[10].gd.pos.y = gcd[8].gd.pos.y+17;
- gcd[10].gd.flags = gg_enabled|gg_visible;
- gcd[10].gd.cid = CID_CentCornLab;
- gcd[10].creator = GLabelCreate;
- sprintf( cenx, "%g", (double) cv->info.x );
- label[11].text = (unichar_t *) cenx;
- label[11].text_is_1byte = true;
- gcd[11].gd.label = &label[11];
- gcd[11].gd.pos.x = 60; gcd[11].gd.pos.y = gcd[10].gd.pos.y-4;
- gcd[11].gd.pos.width = 40;
- gcd[11].gd.flags = gg_enabled|gg_visible;
- gcd[11].gd.cid = CID_CentCornX;
- gcd[11].creator = GTextFieldCreate;
- sprintf( ceny, "%g", (double) cv->info.y );
- label[12].text = (unichar_t *) ceny;
- label[12].text_is_1byte = true;
- gcd[12].gd.label = &label[12];
- gcd[12].gd.pos.x = 110; gcd[12].gd.pos.y = gcd[11].gd.pos.y;
- gcd[12].gd.pos.width = gcd[11].gd.pos.width;
- gcd[12].gd.flags = gg_enabled|gg_visible;
- gcd[12].gd.cid = CID_CentCornY;
- gcd[12].creator = GTextFieldCreate;
- label[13].text = (unichar_t *) (co[rb] ? _("Radius: ") : _("Diameter:") );
- label[13].text_is_1byte = true;
- gcd[13].gd.label = &label[13];
- gcd[13].gd.pos.x = 5; gcd[13].gd.pos.y = gcd[10].gd.pos.y+24;
- gcd[13].gd.flags = gg_enabled|gg_visible;
- gcd[13].gd.cid = CID_RadDiamLab;
- gcd[13].creator = GLabelCreate;
- sprintf( radx, "%g", (double) raddiam_x );
- label[14].text = (unichar_t *) radx;
- label[14].text_is_1byte = true;
- gcd[14].gd.label = &label[14];
- gcd[14].gd.pos.x = gcd[11].gd.pos.x; gcd[14].gd.pos.y = gcd[13].gd.pos.y-4;
- gcd[14].gd.pos.width = gcd[11].gd.pos.width;
- gcd[14].gd.flags = gg_enabled|gg_visible;
- gcd[14].gd.cid = CID_RadDiamX;
- gcd[14].creator = GTextFieldCreate;
- sprintf( rady, "%g", (double) raddiam_y );
- label[15].text = (unichar_t *) rady;
- label[15].text_is_1byte = true;
- gcd[15].gd.label = &label[15];
- gcd[15].gd.pos.x = gcd[12].gd.pos.x; gcd[15].gd.pos.y = gcd[14].gd.pos.y;
- gcd[15].gd.pos.width = gcd[11].gd.pos.width;
- gcd[15].gd.flags = gg_enabled|gg_visible;
- gcd[15].gd.cid = CID_RadDiamY;
- gcd[15].creator = GTextFieldCreate;
- label[16].text = (unichar_t *) _("Angle:");
- label[16].text_is_1byte = true;
- gcd[16].gd.label = &label[16];
- gcd[16].gd.pos.x = 5; gcd[16].gd.pos.y = gcd[13].gd.pos.y+24;
- gcd[16].gd.flags = gg_enabled|gg_visible;
- gcd[16].creator = GLabelCreate;
- sprintf( angle, "%g", (double) rotate_by );
- label[17].text = (unichar_t *) angle;
- label[17].text_is_1byte = true;
- gcd[17].gd.label = &label[17];
- gcd[17].gd.pos.x = 60; gcd[17].gd.pos.y = gcd[16].gd.pos.y-4;
- gcd[17].gd.pos.width = gcd[11].gd.pos.width;
- gcd[17].gd.flags = gg_enabled|gg_visible;
- gcd[17].gd.cid = CID_Angle;
- gcd[17].creator = GTextFieldCreate;
- }
- }
- GGadgetsCreate(d.gw,gcd);
- d.rb1 = gcd[0].ret;
- d.reg = gcd[6].ret;
- d.pts = gcd[7].ret;
- GWidgetHidePalettes();
- GDrawSetVisible(d.gw,true);
- while ( !d.done )
- GDrawProcessOneEvent(NULL);
- GDrawDestroyWindow(d.gw);
- return( d.ret );
- }
- static void CVRectElipse(CharView *cv) {
- rectelipse = Ask(_("Rectangle"),_("Ellipse"),rectelipse,
- _("Round Rectangle Radius"),&rr_radius,center_out,false, cv);
- GDrawRequestExpose(cvtools,NULL,false);
- }
- void CVRectEllipsePosDlg(CharView *cv) {
- rectelipse = Ask(_("Rectangle"),_("Ellipse"),rectelipse,
- _("Round Rectangle Radius"),&rr_radius,center_out,2, cv);
- GDrawRequestExpose(cvtools,NULL,false);
- }
- static void CVPolyStar(CharView *cv) {
- float temp = ps_pointcnt;
- int foo[2];
- polystar = Ask(_("Polygon"),_("Star"),polystar,
- _("Number of star points/Polygon vertices"),&temp,foo,true, cv);
- ps_pointcnt = temp;
- }
- static void ToolsExpose(GWindow pixmap, CharView *cv, GRect *r) {
- GRect old;
- /* Note: If you change this ordering, change enum cvtools */
- static GImage *normbuttons[][2] = { { &GIcon_pointer, &GIcon_magnify },
- { &GIcon_freehand, &GIcon_hand },
- { &GIcon_knife, &GIcon_ruler },
- { &GIcon_pen, &GIcon_spirodisabled },
- { &GIcon_curve, &GIcon_hvcurve },
- { &GIcon_corner, &GIcon_tangent},
- { &GIcon_scale, &GIcon_rotate },
- { &GIcon_flip, &GIcon_skew },
- { &GIcon_3drotate, &GIcon_perspective },
- { &GIcon_rect, &GIcon_poly},
- { &GIcon_elipse, &GIcon_star}};
- static GImage *spirobuttons[][2] = { { &GIcon_pointer, &GIcon_magnify },
- { &GIcon_freehand, &GIcon_hand },
- { &GIcon_knife, &GIcon_ruler },
- { &GIcon_spiroright, &GIcon_spirodown },
- { &GIcon_spirocurve, &GIcon_spirog2curve },
- { &GIcon_spirocorner, &GIcon_spiroleft },
- { &GIcon_scale, &GIcon_rotate },
- { &GIcon_flip, &GIcon_skew },
- { &GIcon_3drotate, &GIcon_perspective },
- { &GIcon_rect, &GIcon_poly},
- { &GIcon_elipse, &GIcon_star}};
- static GImage *normsmalls[] = { &GIcon_smallpointer, &GIcon_smallmag,
- &GIcon_smallpencil, &GIcon_smallhand,
- &GIcon_smallknife, &GIcon_smallruler,
- &GIcon_smallpen, NULL,
- &GIcon_smallcurve, &GIcon_smallhvcurve,
- &GIcon_smallcorner, &GIcon_smalltangent,
- &GIcon_smallscale, &GIcon_smallrotate,
- &GIcon_smallflip, &GIcon_smallskew,
- &GIcon_small3drotate, &GIcon_smallperspective,
- &GIcon_smallrect, &GIcon_smallpoly,
- &GIcon_smallelipse, &GIcon_smallstar };
- static GImage *spirosmalls[] = { &GIcon_smallpointer, &GIcon_smallmag,
- &GIcon_smallpencil, &GIcon_smallhand,
- &GIcon_smallknife, &GIcon_smallruler,
- &GIcon_smallspiroright, NULL,
- &GIcon_smallspirocurve, &GIcon_smallspirog2curve,
- &GIcon_smallspirocorner, &GIcon_smallspiroleft,
- &GIcon_smallscale, &GIcon_smallrotate,
- &GIcon_smallflip, &GIcon_smallskew,
- &GIcon_small3drotate, &GIcon_smallperspective,
- &GIcon_smallrect, &GIcon_smallpoly,
- &GIcon_smallelipse, &GIcon_smallstar };
- static const unichar_t _Mouse[][9] = {
- { 'M', 's', 'e', '1', '\0' },
- { '^', 'M', 's', 'e', '1', '\0' },
- { 'M', 's', 'e', '2', '\0' },
- { '^', 'M', 's', 'e', '2', '\0' }};
- int i,j,norm, mi;
- int tool = cv->cntrldown?cv->cb1_tool:cv->b1_tool;
- int dither = GDrawSetDither(NULL,false);
- GRect temp;
- int canspiro = hasspiro(), inspiro = canspiro && cv->b.sc->inspiro;
- GImage *(*buttons)[2] = inspiro ? spirobuttons : normbuttons;
- GImage **smalls = inspiro ? spirosmalls : normsmalls;
- normbuttons[3][1] = canspiro ? &GIcon_spiroup : &GIcon_spirodisabled;
- GDrawPushClip(pixmap,r,&old);
- GDrawFillRect(pixmap,r,GDrawGetDefaultBackground(NULL));
- GDrawSetLineWidth(pixmap,0);
- for ( i=0; i<sizeof(normbuttons)/sizeof(normbuttons[0])-1; ++i ) for ( j=0; j<2; ++j ) {
- mi = i;
- if ( i==(cvt_rect)/2 && ((j==0 && rectelipse) || (j==1 && polystar)) )
- ++mi;
- /* if ( cv->b.sc->parent->order2 && buttons[mi][j]==&GIcon_freehand ) */
- /* GDrawDrawImage(pixmap,&GIcon_greyfree,NULL,j*27+1,i*27+1); */
- /* else */
- GDrawDrawImage(pixmap,buttons[mi][j],NULL,j*27+1,i*27+1);
- norm = (mi*2+j!=tool);
- {
- // These are from charview.c.
- extern int cvbutton3d; // Default 1.
- extern Color cvbutton3dedgelightcol; // Default 0xe0e0e0.
- extern Color cvbutton3dedgedarkcol; // Default 0x707070.
- if (cvbutton3d) {
- GDrawDrawLine(pixmap,j*27,i*27,j*27+25,i*27,norm?cvbutton3dedgelightcol:cvbutton3dedgedarkcol);
- GDrawDrawLine(pixmap,j*27,i*27,j*27,i*27+25,norm?cvbutton3dedgelightcol:cvbutton3dedgedarkcol);
- GDrawDrawLine(pixmap,j*27,i*27+25,j*27+25,i*27+25,norm?cvbutton3dedgedarkcol:cvbutton3dedgelightcol);
- GDrawDrawLine(pixmap,j*27+25,i*27,j*27+25,i*27+25,norm?cvbutton3dedgedarkcol:cvbutton3dedgelightcol);
- }
- }
- }
- GDrawSetFont(pixmap,toolsfont);
- temp.x = 52-16; temp.y = i*27; temp.width = 16; temp.height = 4*12;
- GDrawFillRect(pixmap,&temp,GDrawGetDefaultBackground(NULL));
- for ( j=0; j<4; ++j ) {
- GDrawDrawText(pixmap,2,i*27+j*12+10,(unichar_t *) _Mouse[j],-1,GDrawGetDefaultForeground(NULL));
- if ( (&cv->b1_tool)[j]!=cvt_none && smalls[(&cv->b1_tool)[j]])
- GDrawDrawImage(pixmap,smalls[(&cv->b1_tool)[j]],NULL,52-16,i*27+j*12);
- }
- GDrawPopClip(pixmap,&old);
- GDrawSetDither(NULL,dither);
- }
- int TrueCharState(GEvent *event) {
- int bit = 0;
- /* X doesn't set the state until after the event. I want the state to */
- /* reflect whatever key just got depressed/released */
- int keysym = event->u.chr.keysym;
- if ( keysym == GK_Caps_Lock || keysym == GK_Shift_Lock ) {
- static int set_on_last_down = false;
- /* caps lock is sticky and doesn't work like the other modifiers */
- /* but it is even worse. the bit seems to be set on key down, but */
- /* unset on key up. In other words on key up, the bit will always */
- /* set and we have no idea which way it will go. So we guess, and */
- /* if they haven't messed with the key outside ff we should be right */
- if ( event->type == et_char ) {
- set_on_last_down = (event->u.chr.state ^ ksm_capslock)& ksm_capslock;
- return( event->u.chr.state ^ ksm_capslock );
- } else if ( !(event->u.chr.state & ksm_capslock) || set_on_last_down )
- return( event->u.chr.state );
- else
- return( event->u.chr.state & ~ksm_capslock );
- }
- if ( keysym == GK_Meta_L || keysym == GK_Meta_R ||
- keysym == GK_Alt_L || keysym == GK_Alt_R )
- bit = ksm_meta;
- else if ( keysym == GK_Shift_L || keysym == GK_Shift_R )
- bit = ksm_shift;
- else if ( keysym == GK_Control_L || keysym == GK_Control_R )
- bit = ksm_control;
- else if ( keysym == GK_Super_L || keysym == GK_Super_L )
- bit = ksm_super;
- else if ( keysym == GK_Hyper_L || keysym == GK_Hyper_L )
- bit = ksm_hyper;
- else
- return( event->u.chr.state );
- if ( event->type == et_char )
- return( event->u.chr.state | bit );
- else
- return( event->u.chr.state & ~bit );
- }
- void CVToolsSetCursor(CharView *cv, int state, char *device) {
- int shouldshow;
- int cntrl;
- if ( tools[0] == ct_pointer ) {
- tools[cvt_pointer] = ct_mypointer;
- tools[cvt_magnify] = ct_magplus;
- tools[cvt_freehand] = ct_pencil;
- tools[cvt_hand] = ct_myhand;
- tools[cvt_curve] = ct_circle;
- tools[cvt_hvcurve] = ct_hvcircle;
- tools[cvt_corner] = ct_square;
- tools[cvt_tangent] = ct_triangle;
- tools[cvt_pen] = ct_pen;
- tools[cvt_knife] = ct_knife;
- tools[cvt_ruler] = ct_ruler;
- tools[cvt_scale] = ct_scale;
- tools[cvt_flip] = ct_flip;
- tools[cvt_rotate] = ct_rotate;
- tools[cvt_skew] = ct_skew;
- tools[cvt_3d_rotate] = ct_3drotate;
- tools[cvt_perspective] = ct_perspective;
- tools[cvt_rect] = ct_rect;
- tools[cvt_poly] = ct_poly;
- tools[cvt_elipse] = ct_elipse;
- tools[cvt_star] = ct_star;
- tools[cvt_minify] = ct_magminus;
- memcpy(spirotools,tools,sizeof(tools));
- spirotools[cvt_spirog2] = ct_g2circle;
- spirotools[cvt_spiroleft] = ct_spiroleft;
- spirotools[cvt_spiroright] = ct_spiroright;
- }
- shouldshow = cvt_none;
- if ( cv->active_tool!=cvt_none )
- shouldshow = cv->active_tool;
- else if ( cv->pressed_display!=cvt_none )
- shouldshow = cv->pressed_display;
- else if ( device==NULL || strcmp(device,"Mouse1")==0 ) {
- if ( (state&(ksm_shift|ksm_control)) && (state&ksm_button4))
- shouldshow = cvt_magnify;
- else if ( (state&(ksm_shift|ksm_control)) && (state&ksm_button5))
- shouldshow = cvt_minify;
- else if ( (state&ksm_control) && (state&(ksm_button2|ksm_super)) )
- shouldshow = cv->cb2_tool;
- else if ( (state&(ksm_button2|ksm_super)) )
- shouldshow = cv->b2_tool;
- else if ( (state&ksm_control) )
- shouldshow = cv->cb1_tool;
- else
- shouldshow = cv->b1_tool;
- } else if ( strcmp(device,"eraser")==0 )
- shouldshow = cv->er_tool;
- else if ( strcmp(device,"stylus")==0 ) {
- if ( (state&(ksm_button2|ksm_control|ksm_super)) )
- shouldshow = cv->s2_tool;
- else
- shouldshow = cv->s1_tool;
- }
- if ( shouldshow==cvt_magnify && (state&ksm_meta))
- shouldshow = cvt_minify;
- if ( shouldshow!=cv->showing_tool ) {
- CPEndInfo(cv);
- if ( cv->b.sc->inspiro && hasspiro()) {
- GDrawSetCursor(cv->v,spirotools[shouldshow]);
- if ( cvtools!=NULL ) /* Might happen if window owning docked palette destroyed */
- GDrawSetCursor(cvtools,spirotools[shouldshow]);
- } else {
- GDrawSetCursor(cv->v,tools[shouldshow]);
- if ( cvtools!=NULL ) /* Might happen if window owning docked palette destroyed */
- GDrawSetCursor(cvtools,tools[shouldshow]);
- }
- cv->showing_tool = shouldshow;
- }
- if ( device==NULL || strcmp(device,"stylus")==0 ) {
- cntrl = (state&ksm_control)?1:0;
- if ( device!=NULL && (state&ksm_button2))
- cntrl = true;
- if ( cntrl != cv->cntrldown ) {
- cv->cntrldown = cntrl;
- GDrawRequestExpose(cvtools,NULL,false);
- }
- }
- }
- static int CVCurrentTool(CharView *cv, GEvent *event) {
- if ( event->u.mouse.device!=NULL && strcmp(event->u.mouse.device,"eraser")==0 )
- return( cv->er_tool );
- else if ( event->u.mouse.device!=NULL && strcmp(event->u.mouse.device,"stylus")==0 ) {
- if ( event->u.mouse.button==2 )
- /* Only thing that matters is touch which maps to button 1 */;
- else if ( cv->had_control )
- return( cv->s2_tool );
- else
- return( cv->s1_tool );
- }
- if ( cv->had_control && event->u.mouse.button==2 )
- return( cv->cb2_tool );
- else if ( event->u.mouse.button==2 )
- return( cv->b2_tool );
- else if ( cv->had_control ) {
- return( cv->cb1_tool );
- } else {
- return( cv->b1_tool );
- }
- }
- static void SCCheckForSSToOptimize(SplineChar *sc, SplineSet *ss,int order2) {
- for ( ; ss!=NULL ; ss = ss->next ) {
- if ( ss->beziers_need_optimizer ) {
- SplineSetAddExtrema(sc,ss,ae_only_good,sc->parent->ascent+sc->parent->descent);
- ss->beziers_need_optimizer = false;
- }
- if ( order2 && ss->first->next!=NULL && !ss->first->next->order2 ) {
- SplineSet *temp = SSttfApprox(ss), foo;
- foo = *ss;
- ss->first = temp->first; ss->last = temp->last;
- temp->first = foo.first; temp->last = foo.last;
- SplinePointListFree(temp);
- }
- }
- }
- static void CVChangeSpiroMode(CharView *cv) {
- if ( hasspiro() ) {
- cv->b.sc->inspiro = !cv->b.sc->inspiro;
- cv->showing_tool = cvt_none;
- CVClearSel(cv);
- if ( !cv->b.sc->inspiro )
- SCCheckForSSToOptimize(cv->b.sc,cv->b.layerheads[cv->b.drawmode]->splines,
- cv->b.layerheads[cv->b.drawmode]->order2);
- GDrawRequestExpose(cvtools,NULL,false);
- SCUpdateAll(cv->b.sc);
- } else
- #ifdef _NO_LIBSPIRO
- ff_post_error(_("You may not use spiros"),_("This version of fontforge was not linked with the spiro library, so you may not use them."));
- #else
- ff_post_error(_("You may not use spiros"),_("FontForge was unable to load libspiro, spiros are not available for use."));
- #endif
- }
- char* HKTextInfoToUntranslatedTextFromTextInfo( GTextInfo* ti ); // From ../gdraw/gmenu.c.
- static void ToolsMouse(CharView *cv, GEvent *event) {
- int i = (event->u.mouse.y/27), j = (event->u.mouse.x/27), mi=i;
- int pos;
- int isstylus = event->u.mouse.device!=NULL && strcmp(event->u.mouse.device,"stylus")==0;
- int styluscntl = isstylus && (event->u.mouse.state&0x200);
- static int settings[2];
- if(j >= 2)
- return; /* If the wm gave me a window the wrong size */
- if ( i==(cvt_rect)/2 ) {
- int current = CVCurrentTool(cv,event);
- int changed = false;
- if ( event->type == et_mousedown && event->u.mouse.clicks>=2 ) {
- rectelipse = settings[0];
- polystar = settings[1];
- } else if ( event->type == et_mousedown ) {
- settings[0] = rectelipse; settings[1] = polystar;
- /* A double click will change the type twice, which leaves it where it was, which is desired */
- if ( j==0 && ((!rectelipse && current==cvt_rect) || (rectelipse && current==cvt_elipse)) ) {
- rectelipse = !rectelipse;
- changed = true;
- } else if (j==1 && ((!polystar && current==cvt_poly) || (polystar && current==cvt_star)) ) {
- polystar = !polystar;
- changed = true;
- }
- if ( changed ) {
- SavePrefs(true);
- GDrawRequestExpose(cvtools,NULL,false);
- }
- }
- …
Large files files are truncated, but you can click here to view the full file